From 25836ff90c55c6a22f23a166bfe5ff3465a8927c Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Wed, 2 Jun 2021 20:10:47 -0400 Subject: [PATCH] LU-10948 mdt: New connect flag for non-open-by-fid lock While we removed the 2.1 check for open by fid when open lock is requested, when you talk to old servers that don't have that patch - they get an open error, so introduce a compat flag. Lustre-commit: 72c9a6e5fb6e11fca1b1438ac18f58ff7849ed7d Lustre-change: https://review.whamcloud.com/43907/ Change-Id: I94d50ad98a2828519853a35fa90c5063adf2feab Fixes: 41d99c4902 ("LU-10948 llite: Introduce inode open heat counter") Signed-off-by: Lai Siyao Signed-off-by: Oleg Drokin Reviewed-by: Andreas Dilger Reviewed-by: James Nunez Reviewed-on: https://review.whamcloud.com/44260 Tested-by: jenkins Tested-by: Maloo --- lustre/include/uapi/linux/lustre/lustre_idl.h | 4 +++- lustre/llite/llite_lib.c | 4 +++- lustre/llite/namei.c | 9 +++++++++ lustre/obdclass/lprocfs_status.c | 9 ++++++--- lustre/ptlrpc/wiretest.c | 2 ++ lustre/utils/wirecheck.c | 1 + lustre/utils/wiretest.c | 2 ++ 7 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lustre/include/uapi/linux/lustre/lustre_idl.h b/lustre/include/uapi/linux/lustre/lustre_idl.h index fd2e532..1a7c866 100644 --- a/lustre/include/uapi/linux/lustre/lustre_idl.h +++ b/lustre/include/uapi/linux/lustre/lustre_idl.h @@ -872,6 +872,7 @@ struct ptlrpc_body_v2 { #define OBD_CONNECT2_LSEEK 0x40000ULL /* SEEK_HOLE/DATA RPC */ #define OBD_CONNECT2_DOM_LVB 0x80000ULL /* pack DOM glimpse data in LVB */ #define OBD_CONNECT2_PCCRO 0x800000ULL /* Read-only PCC */ +#define OBD_CONNECT2_ATOMIC_OPEN_LOCK 0x4000000ULL/* request lock on 1st open */ /* XXX README XXX: * Please DO NOT add flag values here before first ensuring that this same * flag value is not in use on some other branch. Please clear any such @@ -932,7 +933,8 @@ struct ptlrpc_body_v2 { OBD_CONNECT2_ENCRYPT | \ OBD_CONNECT2_GETATTR_PFID | \ OBD_CONNECT2_LSEEK | OBD_CONNECT2_DOM_LVB | \ - OBD_CONNECT2_PCCRO) + OBD_CONNECT2_PCCRO | \ + OBD_CONNECT2_ATOMIC_OPEN_LOCK) #define OST_CONNECT_SUPPORTED (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \ OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \ diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 1a26784..e2b9741 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -285,7 +285,9 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) OBD_CONNECT2_PCC | OBD_CONNECT2_CRUSH | OBD_CONNECT2_LSEEK | OBD_CONNECT2_GETATTR_PFID | - OBD_CONNECT2_DOM_LVB | OBD_CONNECT2_PCCRO; + OBD_CONNECT2_DOM_LVB | + OBD_CONNECT2_PCCRO | + OBD_CONNECT2_ATOMIC_OPEN_LOCK; #ifdef HAVE_LRU_RESIZE_SUPPORT if (sbi->ll_flags & LL_SBI_LRU_RESIZE) diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 1c0c6c9..72fd9fc 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -1139,6 +1139,15 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, OBD_FAIL_TIMEOUT(OBD_FAIL_LLITE_CREATE_FILE_PAUSE2, cfs_fail_val); + /* We can only arrive at this path when we have no inode, so + * we only need to request open lock if it was requested + * for every open + */ + if (ll_i2sbi(dir)->ll_oc_thrsh_count == 1 && + exp_connect_flags2(ll_i2mdexp(dir)) & + OBD_CONNECT2_ATOMIC_OPEN_LOCK) + it->it_flags |= MDS_OPEN_LOCK; + /* Dentry added to dcache tree in ll_lookup_it */ de = ll_lookup_it(dir, dentry, it, &secctx, &secctxlen, &pca, encrypt, &encctx, &encctxlen); diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 4e678b7..7917990 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -642,10 +642,13 @@ static const char *obd_connect_names[] = { "getattr_pfid", /* 0x20000 */ "lseek", /* 0x40000 */ "dom_lvb", /* 0x80000 */ - "mne_type", /* 0x100000 */ - "ldlm_convert", /* 0x200000 */ + "reply_mbits", /* 0x100000 */ + "mode_convert", /* 0x200000 */ "batch_rpc", /* 0x400000 */ - "pccro", /* 0x800000 */ + "pcc_ro", /* 0x800000 */ + "mne_nid_type", /* 0x1000000 */ + "lock_contend", /* 0x2000000 */ + "atomic_open_lock", /* 0x4000000 */ NULL }; diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index 02fe3ab..3b042f9 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -1385,6 +1385,8 @@ void lustre_assert_wire_constants(void) OBD_CONNECT2_DOM_LVB); LASSERTF(OBD_CONNECT2_PCCRO == 0x800000ULL, "found 0x%.16llxULL\n", OBD_CONNECT2_PCCRO); + LASSERTF(OBD_CONNECT2_ATOMIC_OPEN_LOCK == 0x4000000ULL, "found 0x%.16llxULL\n", + OBD_CONNECT2_ATOMIC_OPEN_LOCK); LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n", (unsigned)OBD_CKSUM_CRC32); LASSERTF(OBD_CKSUM_ADLER == 0x00000002UL, "found 0x%.8xUL\n", diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index cc44cac..85016ff 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -629,6 +629,7 @@ check_obd_connect_data(void) CHECK_DEFINE_64X(OBD_CONNECT2_LSEEK); CHECK_DEFINE_64X(OBD_CONNECT2_DOM_LVB); CHECK_DEFINE_64X(OBD_CONNECT2_PCCRO); + CHECK_DEFINE_64X(OBD_CONNECT2_ATOMIC_OPEN_LOCK); CHECK_VALUE_X(OBD_CKSUM_CRC32); CHECK_VALUE_X(OBD_CKSUM_ADLER); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 97efe60..56e8a2c 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -1421,6 +1421,8 @@ void lustre_assert_wire_constants(void) OBD_CONNECT2_DOM_LVB); LASSERTF(OBD_CONNECT2_PCCRO == 0x800000ULL, "found 0x%.16llxULL\n", OBD_CONNECT2_PCCRO); + LASSERTF(OBD_CONNECT2_ATOMIC_OPEN_LOCK == 0x4000000ULL, "found 0x%.16llxULL\n", + OBD_CONNECT2_ATOMIC_OPEN_LOCK); LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n", (unsigned)OBD_CKSUM_CRC32); LASSERTF(OBD_CKSUM_ADLER == 0x00000002UL, "found 0x%.8xUL\n", -- 1.8.3.1