Skip to content

Commit f4293a9

Browse files
Champ-Goblembergwolf
authored andcommitted
fuse: Ensure readdir returns same ino as lookup
The filesystem test utility xfs-tests[1] failed on test generic/637 with the error entry 8 has inode 72057594038044051, expected 112052 The expected inode returned from readdir is neither converted nor the same inode as assigned by do_lookup, as stated in the docs for DirEntry.ino. Update readdir to perform do_lookup to get the correct inode number and then convert this inode number to the expected format. After this change the test generic/637 passes and no regressions in other tests. [1] https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/tree/ Signed-off-by: Champ-Goblem <[email protected]>
1 parent 9f9b50c commit f4293a9

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/api/vfs/sync_io.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,18 @@ impl FileSystem for Vfs {
544544
)
545545
}
546546

547-
(Right(fs), idata) => fs.readdir(ctx, idata.ino(), handle, size, offset, add_entry),
547+
(Right(fs), idata) => fs.readdir(
548+
ctx,
549+
idata.ino(),
550+
handle,
551+
size,
552+
offset,
553+
&mut |mut dir_entry| {
554+
let new_ino = self.convert_inode(idata.fs_idx(), dir_entry.ino)?;
555+
dir_entry.ino = new_ino;
556+
add_entry(dir_entry)
557+
},
558+
),
548559
}
549560
}
550561

src/passthrough/sync_io.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
436436
if self.no_readdir.load(Ordering::Relaxed) {
437437
return Ok(());
438438
}
439-
self.do_readdir(inode, handle, size, offset, &mut |mut dir_entry, dir| {
439+
self.do_readdir(inode, handle, size, offset, &mut |mut dir_entry, _dir| {
440440
dir_entry.ino = {
441441
// Safe because do_readdir() has ensured dir_entry.name is a
442442
// valid [u8] generated by CStr::to_bytes().
@@ -447,8 +447,10 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
447447
))
448448
};
449449

450-
let st = Self::stat(&dir, Some(name))?;
451-
st.st_ino
450+
let entry = self.do_lookup(inode, name)?;
451+
let mut inodes = self.inode_map.get_map_mut();
452+
self.forget_one(&mut inodes, entry.inode, 1);
453+
entry.inode
452454
};
453455

454456
add_entry(dir_entry)

0 commit comments

Comments
 (0)