Whamcloud - gitweb
LU-11047 mdt: standardize mdt object locking 64/40764/46
authorLai Siyao <lai.siyao@whamcloud.com>
Fri, 23 Sep 2022 02:45:19 +0000 (22:45 -0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 11 Apr 2023 20:04:56 +0000 (20:04 +0000)
commitca59060c4221a78bc696055f94d2fe4793ad7560
tree8e84b873219df57cbc51403a54b48869ac43539a
parent4435d0121f72aac3ad01c98a33b265a496359890
LU-11047 mdt: standardize mdt object locking

* object LOOKUP lock should be taken from parent MDT if object and
  its parent are located on different MDTs, but current mdt object
  locking doesn't handle this explicitly, instead it implies its
  parent is on local MDT.
* PDO locking should be put into a separate function.
* with the above changes, mdt_object_lock_internal() becomes a simple
  wrapper: it calls mdt_remote_object_lock_try() if object is remote,
  and mdt_fid_lock() otherwise.
* the MDT object locking functions are as below:
    . mdt_object_lock(): lock object, this is used in most places, and
normally lock ibits doesn't contain LOOKUP, unless the caller
knows its parent is on the same MDT.
    . mdt_object_check_lock(): lock object with LOOKUP and other
ibits, it needs to check whether parent is on different MDT,
if so, take LOOKUP lock on parent MDT, and then lock other
ibits on child MDT.
    . mdt_parent_lock(): take parent UPDATE lock with specific mode,
if parent is local, take PDO lock, otherwise take regular
lock.
    . mdt_object_stripes_lock(): lock object which should be local,
and if it's a striped directory, lock its stripes. This is
called in operations which modify dir object and its stripes.
    . mdt_object_lock_try(): lock object with trybits, the trybits
contains optional inode lock bits that can be granted. This is
called by getattr/open to fetch more inode lock bits to
client, and is also called by dir migration to lock link
parent in non-block mode to avoid deadlock.
    . rename/migrate source object are locked in specific functions,
because source object and its parent may be located on
        different remote MDTs.

Test-Parameters: mdscount=2 mdtcount=4 testlist=racer,racer,racer
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: I8225cbee4a1f5db8f77399866061f12e0a4cbb47
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/40764
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Qian Yingjin <qian@ddn.com>
Reviewed-by: jsimmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_coordinator.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_hsm.c
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_io.c
lustre/mdt/mdt_open.c
lustre/mdt/mdt_reint.c
lustre/mdt/mdt_restripe.c
lustre/mdt/mdt_xattr.c