> > > 2. exportfs_encode_fh(dentry,... in fanotify_alloc_fid() > > Can be converted to exportfs_encode_inode_fh(inode,... > > If you have the parent inode then yes. In lot of cases we do have it, not > sure if in all of them (but likely yes so that we can do proper > FS_EVENT_ON_CHILD) handling. > We do not need the parent inode, because we are not encoding a "connectable" file handle. we need: exportfs_encode_inode_fh(inode, (struct fid *)fid->f_handle, &dwords, NULL); > > 3. statfs_by_dentry(dentry,... in fanotify_alloc_fid() > > Can be converted to statfs_by_dentry(inode->i_sb->sb_root,... > > This might be problematic e.g. with btrfs subvolumes which have each > different fsid so the fsid-handle pair might be actually invalid or even > point to a file with different contents. Maybe we could just store the > fsid in the fsnotify_mark when it is created and use it when generating > events? That would also get rid of the overhead of calling statfs for each > generated event which I don't like... > OK, I was not being accurate when I wrote that these are the only 3 places we use dentry. Those are the only 3 places in fanotify, but we also use dentry->d_sb in fsnotify() to get to the sb mark of course, so we will be using inode->i_sb instead. w.r.t btrfs - btrfs has a single sb for multiple subvolumes so by definition the FAN_MARK_FILESYSTEM feature is only capable of watching ALL subvolumes. If we wanted to implement subvolume watch for btrfs, we would need to support attaching a mark to a btrfs subvolume struct (or fs_view [1]). Basically, the purpose, of fid->fsid is: 1. A key for finding a mount point to use as mount_fd argument to open_by_handle_at() 2. Make fid unique across the system Since btrfs file handles encode the subvolume root object id in the file handle, fid->fsid is only needed to find a btrfs mount of the same sb (blockdev). Regardless, IIUC, btrfs_statfs() returns an fsid which is associated with the single super block struct, so all dentries in all subvolumes will return the same fsid: btrfs_sb(dentry->d_sb)->fsid. CC some btrfs folks to correct me if I am wrong. Thanks, Amir. [1] https://lwn.net/Articles/753917/