Re: [RFC PATCH V2 08/12] fs/xfs: Add lock/unlock mode to xfs

From: Jan Kara
Date: Thu Jan 16 2020 - 04:24:50 EST


On Fri 10-01-20 11:29:38, ira.weiny@xxxxxxxxx wrote:
> From: Ira Weiny <ira.weiny@xxxxxxxxx>
>
> XFS requires regular files to be locked while changing to/from DAX mode.
>
> Define a new DAX lock type and implement the [un]lock_mode() inode
> operation callbacks.
>
> We define a new XFS_DAX_* lock type to carry the lock through the
> transaction because we don't want to use IOLOCK as that would cause
> performance issues with locking of the inode itself.
>
> Signed-off-by: Ira Weiny <ira.weiny@xxxxxxxxx>
...
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 492e53992fa9..693ca66bd89b 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -67,6 +67,9 @@ typedef struct xfs_inode {
> spinlock_t i_ioend_lock;
> struct work_struct i_ioend_work;
> struct list_head i_ioend_list;
> +
> + /* protect changing the mode to/from DAX */
> + struct percpu_rw_semaphore i_dax_sem;
> } xfs_inode_t;

This adds overhead of ~32k per inode for typical distro kernel. That's not
going to fly. That's why ext4 has similar kind of lock in the superblock
shared by all inodes. For read side it does not matter because that's
per-cpu and shared lock. For write side we don't care as changing inode
access mode should be rare.

Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR