Эх сурвалжийг харах

fix(FileArray): release the spinlock before dropping inner files

greatbridf 7 сар өмнө
parent
commit
1513e66772

+ 1 - 1
src/kernel/vfs/file.rs

@@ -516,7 +516,7 @@ impl File {
 
 
     pub fn as_path(&self) -> Option<&Arc<Dentry>> {
     pub fn as_path(&self) -> Option<&Arc<Dentry>> {
         match self {
         match self {
-            File::Inode(inode_file) if s_isdir(inode_file.mode) => Some(&inode_file.dentry),
+            File::Inode(inode_file) => Some(&inode_file.dentry),
             _ => None,
             _ => None,
         }
         }
     }
     }

+ 5 - 3
src/kernel/vfs/filearray.rs

@@ -79,9 +79,11 @@ impl FileArray {
     }
     }
 
 
     pub fn close_all(&self) {
     pub fn close_all(&self) {
-        let mut inner = self.inner.lock();
-        inner.fd_min_avail = FD(0);
-        inner.files.clear();
+        let _old_files = {
+            let mut inner = self.inner.lock();
+            inner.fd_min_avail = FD(0);
+            core::mem::take(&mut inner.files)
+        };
     }
     }
 
 
     pub fn close(&self, fd: FD) -> KResult<()> {
     pub fn close(&self, fd: FD) -> KResult<()> {