On Mon, Jun 22, 2020 at 11:20:13AM -0500, Goldwyn Rodrigues wrote: > From: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx> > > btrfs_inode_lock/unlock() acquires the inode->i_rwsem depending on the > flags passed. ilock_flags determines the type of lock to be taken: > > BTRFS_ILOCK_SHARED - for shared locks, for possible parallel DIO > BTRFS_ILOCK_TRY - for the RWF_NOWAIT sequence > > Signed-off-by: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx> > --- > fs/btrfs/ctree.h | 8 ++++++++ > fs/btrfs/file.c | 51 +++++++++++++++++++++++++++++++++++++++--------- > 2 files changed, 50 insertions(+), 9 deletions(-) > > diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h > index 161533040978..346fea668ca0 100644 > --- a/fs/btrfs/ctree.h > +++ b/fs/btrfs/ctree.h > @@ -2953,6 +2953,14 @@ void btrfs_update_ioctl_balance_args(struct btrfs_fs_info *fs_info, > struct btrfs_ioctl_balance_args *bargs); > > /* file.c */ > + > +/* ilock flags definition */ > +#define BTRFS_ILOCK_SHARED 0x1 > +#define BTRFS_ILOCK_TRY 0x2 > + > +int btrfs_inode_lock(struct inode *inode, int ilock_flags); > +void btrfs_inode_unlock(struct inode *inode, int ilock_flags); There's another lock in btrfs_inode, and the locking functions added here have the 'btrfs_' prefix, yet take the VFS inode structure. This is confusing. The flags are not btrfs-specific so it could be even a generic VFS helper but for now I think it can be in fs/btrfs until it's finalized.
