Whamcloud - gitweb
LU-15546 mdt: mdt_reint_open lookup before locking
authorEtienne AUJAMES <etienne.aujames@cea.fr>
Wed, 2 Mar 2022 17:58:20 +0000 (18:58 +0100)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 1 Jul 2022 04:08:22 +0000 (04:08 +0000)
commit438d9dfbeac3bf3065b22d860416eef39921334f
tree1b4bf991e7aadcb98e28e1800d4b14b98342129d
parent7db5d8fe55692f6f4c7ab60981b1278dc08993ab
LU-15546 mdt: mdt_reint_open lookup before locking

This patch is an optimization of 33dc40d ("LU-10262 mdt:
mdt_reint_open: check EEXIST without lock").

The current behavior is to take a LCK_PR on parent to verify if the
file exist and then take a LCK_PW to create the file.

Here we do a lookup to determine the mode before tacking a lock.
This avoid to re-lock each time for create cases.

Most of the time we have:
1. lookup the child in parent directory
2. take the parent lock: file_exist ? LCK_PR : LCK_PW
3. re-lookup the child

In a race senario (create/unlink) we have:
1. lookup child in parent directory -> file exists
2. take a LCK_PR on the parent
3. re-lookup the child -> file doesn't exist
2. take a LCK_PW on the parent
4. re-lookup the child

This patch fix the "SKIP" condition for sanityn 41i/43k/45j and clear
the LRU locks cache for sanityn 43k/45j.

Lustre-change: https://review.whamcloud.com/46679
Lustre-commit: f14090e56c9d94e3cfaa6f13f357173d6d570547

LU-15907 mdt: fix the OBD_FAIL_MDS_REINT_OPEN2 race

This patch fixes the sanityn test_41i OBD_FAIL_MDS_REINT_OPEN2 race
scenario.

With the "LU-15546 mdt: mdt_reint_open lookup before locking" patch,
we have to force taking a LCK_PR for OBD_FAIL_MDS_REINT_OPEN2 to test
the full lock cycle:

- take PR parent lock
- lockup child (do not exist)
- take PW parent lock
- re-lookup
- create child

Otherwise cfs_race() timeouts because PW lock requests from the 2
threads conflict with each other.

Lustre-change: https://review.whamcloud.com/47506
Lustre-commit: TBD (a15b4e389aa6d2a30d9b79a20f0884e3725c70d7)

Fixes: 33dc40d ("LU-10262 mdt: mdt_reint_open: check EEXIST without lock")
Signed-off-by: Etienne AUJAMES <eaujames@ddn.com>
Change-Id: I121abd4babfb516d7a64682b054a6443d38590ef
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Yingjin Qian <qian@ddn.com>
Reviewed-on: https://review.whamcloud.com/47810
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/mdt/mdt_open.c
lustre/tests/sanityn.sh