client: allow looking up snapped inodes by inode number+snapid tuple
Currently, we have ceph_ll_lookup_inode(), but that only takes an inode number and can't deal with a snapped inode. Add a new lookup function to libcephfs that allows you to look up snapped or non-snapped inodes by inode number and snapid.
This is necessary to allow ganesha to work properly when dealing with snapped inodes.
#2 Updated by Jeff Layton 3 months ago
I started looking at this today, and it's a little trickier than I thought. The current client code that sends the LOOKUPINO request (_lookup_ino) always just leaves the snapid field zeroed out (AFAICT).
The corresponding handler on the MDS (Server::handle_client_lookup_ino), seems to rely on that though:
if ((uint64_t)req->head.args.lookupino.snapid > 0) return _lookup_snap_ino(mdr);
That condition is weird, in that "snapid" is le64, so this is effectively casting that to u64 (regardless of host endianness), and the if statement just a check to see whether that value != 0. CEPH_NOSNAP, however is defined as (__u64)-2, which will evaluate as being >0 in the above conditional.
It's not clear why this is testing for 0 instead of CEPH_NOSNAP. I guess I need to understand why CEPH_NOSNAP is -2 and not 0. What is the special significance of snapid being 0 in the if condition in Server::handle_client_lookup_ino?
#4 Updated by Patrick Donnelly 2 months ago
- Tracker changed from Bug to Feature
- Subject changed from allow looking up snapped inodes by inode number+snapid tuple to client: allow looking up snapped inodes by inode number+snapid tuple
- Status changed from Fix Under Review to Pending Backport
- Component(FS) Client added