On 10/6/20 5:50 AM, Pavel Reichl wrote: > > > On 10/6/20 6:14 AM, Darrick J. Wong wrote: >> On Mon, Oct 05, 2020 at 11:38:52PM +0200, Pavel Reichl wrote: >>> Remove mrlock_t as it does not provide any extra value over >>> rw_semaphores. Make i_lock and i_mmaplock native rw_semaphores and >>> replace mr*() functions with native rwsem calls. >>> >>> Release the lock in xfs_btree_split() just before the work-queue >>> executing xfs_btree_split_worker() is scheduled and make >>> xfs_btree_split_worker() to acquire the lock as a first thing and >>> release it just before returning from the function. This it done so the >>> ownership of the lock is transfered between kernel threads and thus >>> lockdep won't complain about lock being held by a different kernel >>> thread. >>> >>> Signed-off-by: Pavel Reichl <preichl@xxxxxxxxxx> >>> --- >>> fs/xfs/libxfs/xfs_btree.c | 10 +++++ >>> fs/xfs/mrlock.h | 78 --------------------------------------- >>> fs/xfs/xfs_inode.c | 36 ++++++++++-------- >>> fs/xfs/xfs_inode.h | 4 +- >>> fs/xfs/xfs_iops.c | 4 +- >>> fs/xfs/xfs_linux.h | 2 +- >>> fs/xfs/xfs_super.c | 6 +-- >>> 7 files changed, 37 insertions(+), 103 deletions(-) >>> delete mode 100644 fs/xfs/mrlock.h >>> >>> diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c >>> index 2d25bab68764..d798d288eed1 100644 >>> --- a/fs/xfs/libxfs/xfs_btree.c >>> +++ b/fs/xfs/libxfs/xfs_btree.c >>> @@ -2816,6 +2816,7 @@ xfs_btree_split_worker( >>> unsigned long pflags; >>> unsigned long new_pflags = PF_MEMALLOC_NOFS; >>> >>> + rwsem_acquire(&args->cur->bc_ino.ip->i_lock.dep_map, 0, 0, _RET_IP_); >>> /* >>> * we are in a transaction context here, but may also be doing work >>> * in kswapd context, and hence we may need to inherit that state >>> @@ -2832,6 +2833,7 @@ xfs_btree_split_worker( >>> complete(args->done); >>> >>> current_restore_flags_nested(&pflags, new_pflags); >>> + rwsem_release(&args->cur->bc_ino.ip->i_lock.dep_map, _THIS_IP_); >>> } >>> >>> /* >>> @@ -2863,8 +2865,16 @@ xfs_btree_split( >>> args.done = &done; >>> args.kswapd = current_is_kswapd(); >>> INIT_WORK_ONSTACK(&args.work, xfs_btree_split_worker); >>> + >>> + /* Release the lock so it can be acquired in the kernel thread which >> >> Strange comment style. > > OK, I'll try to think about something better, but ideas are welcome :-). /* * Typical multi-line XFS comments are like this, with no * comment text on the opening or closing lines */ /* Single-line comments are fine like this though */ -Eric