bug in lo_do_readdir()?
Hi,
I believe lo_do_readdir() has a bug: for FUSE_READDIR (not FUSE_READDIRPLUS), it does not call lo_do_lookup() -- which seems fine in itself --, but then it doesn't load the inode into the inode map (?) *at all*.
A subsequent FUSE_GETATTR that refers to one of the inode(s) learned via FUSE_READDIR (not FUSE_READDIRPLUS) gets -EBADF, because the requested inode is not in the map.
Because the inode is shared with the client through the normal (not "plus") dirent format too (that is, via FUSE_READDIR and not FUSE_READDIRPLUS), the server should remember the inode(s) from the FUSE_READDIR request as well, in my opinion.
Sorry if I'm mistaken.
The reason I'm not using FUSE_READDIRPLUS is three-fold:
- one fewer wrapper to implement (I need FUSE_READ anyway, for reading regular files, and FUSE_READDIR is identical, except for the opcode, while FUSE_READDIRPLUS isn't),
- FUSE_READDIRPLUS requires feature negotiation, while FUSE_READDIR doesn't, as far as I understand,
- performance for the firmware is not critical, so I'm fine calling a separate FUSE_GETATTR on each inode learned through FUSE_READDIR -- I don't need the attributes to come back together with the dirent.
Unfortunately, I'm not familiar enough with the virtiofsd internals at this point to propose a patch. It feels like adding a lookup-like, but lighter-weight, call, to the non-plus branch in lo_do_readdir(), should do the trick.
Thanks!
Laszlo
Quoted 7 lines · Laszlo Ersek
Hi,
I believe
lo_do_readdir()has a bug: forFUSE_READDIR(notFUSE_READDIRPLUS), it does not calllo_do_lookup()-- which seems fine in itself --, but then it doesn't load the inode into the inode map (?) *at all*.
Quoted 9 lines
A subsequent
FUSE_GETATTRthat refers to one of the inode(s) learned viaFUSE_READDIR(notFUSE_READDIRPLUS) gets-EBADF, because the requested inode is not in the map.Because the inode is shared with the client through the normal (not "plus") dirent format too (that is, via
FUSE_READDIRand notFUSE_READDIRPLUS), the server should remember the inode(s) from theFUSE_READDIRrequest as well, in my opinion.
tools/virtiofsd/fuse_lowlevel.h documents that readdir() does not affect lookup count.
* Returning a directory entry from readdir() does not affect
* its lookup count.
While, readdirplus() does change it.
* In contrast to readdir() (which does not affect the lookup counts),
* the lookup count of every entry returned by readdirplus(), except "."
* and "..", is incremented by one.
Thanks
Vivek
Quoted 27 lines
Sorry if I'm mistaken.
The reason I'm not using
FUSE_READDIRPLUSis three-fold:- one fewer wrapper to implement (I need
FUSE_READanyway, for reading regular files, andFUSE_READDIRis identical, except for the opcode, whileFUSE_READDIRPLUSisn't),-
FUSE_READDIRPLUSrequires feature negotiation, whileFUSE_READDIRdoesn't, as far as I understand,- performance for the firmware is not critical, so I'm fine calling a separate
FUSE_GETATTRon each inode learned throughFUSE_READDIR-- I don't need the attributes to come back together with the dirent.Unfortunately, I'm not familiar enough with the virtiofsd internals at this point to propose a patch. It feels like adding a lookup-like, but lighter-weight, call, to the non-plus branch in
lo_do_readdir(), should do the trick.Thanks!
Laszlo_______________________________________________
Virtio-fs mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virtio-fs
Quoted 21 lines · Vivek Goyal
Quoted 7 lines · Laszlo Ersek
Hi,
I believe
lo_do_readdir()has a bug: forFUSE_READDIR(notFUSE_READDIRPLUS), it does not calllo_do_lookup()-- which seems fine in itself --, but then it doesn't load the inode into the inode map (?) *at all*.Quoted 9 lines
A subsequent
FUSE_GETATTRthat refers to one of the inode(s) learned viaFUSE_READDIR(notFUSE_READDIRPLUS) gets-EBADF, because the requested inode is not in the map.Because the inode is shared with the client through the normal (not "plus") dirent format too (that is, via
FUSE_READDIRand notFUSE_READDIRPLUS), the server should remember the inode(s) from theFUSE_READDIRrequest as well, in my opinion.
tools/virtiofsd/fuse_lowlevel.hdocuments thatreaddir()does not affect lookup count.
Quoted 8 lines
* Returning a directory entry from
readdir()does not affect
* its lookup count.While,
readdirplus()does change it.* In contrast to
readdir()(which does not affect the lookup counts),
* the lookup count of every entry returned byreaddirplus(), except "."
* and "..", is incremented by one.
Thanks! I'll rework the code with readdirplus.
Laszlo
Quoted 27 lines
Quoted 27 lines
Sorry if I'm mistaken.
The reason I'm not using
FUSE_READDIRPLUSis three-fold:- one fewer wrapper to implement (I need
FUSE_READanyway, for reading regular files, andFUSE_READDIRis identical, except for the opcode, whileFUSE_READDIRPLUSisn't),-
FUSE_READDIRPLUSrequires feature negotiation, whileFUSE_READDIRdoesn't, as far as I understand,- performance for the firmware is not critical, so I'm fine calling a separate
FUSE_GETATTRon each inode learned throughFUSE_READDIR-- I don't need the attributes to come back together with the dirent.Unfortunately, I'm not familiar enough with the virtiofsd internals at this point to propose a patch. It feels like adding a lookup-like, but lighter-weight, call, to the non-plus branch in
lo_do_readdir(), should do the trick.Thanks!
Laszlo_______________________________________________
Virtio-fs mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virtio-fs