From patchwork Fri Mar 21 13:06:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7934EC36000 for ; Fri, 21 Mar 2025 13:07:20 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2m5342Dz1xSF; Fri, 21 Mar 2025 06:07:17 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2m34lJgz1whP for ; Fri, 21 Mar 2025 06:07:15 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm5-e204-208.ccs.ornl.gov [160.91.203.29]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 521DE17D1C2; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 4D1F7106BE16; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:44 -0400 Message-ID: <20250321130711.3257092-2-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 01/27] lustre: misc: cleanup #ifdef X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" With the porting of patches from the OpenSFS branch some if the build conditionals have leaked in. This patch removes them. Signed-off-by: James Simmons --- fs/lustre/llite/llite_internal.h | 6 ------ fs/lustre/obdclass/jobid.c | 2 -- fs/lustre/ptlrpc/wiretest.c | 6 ------ net/lnet/selftest/conctl.c | 19 ------------------- 4 files changed, 33 deletions(-) diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h index 746ef983edb8..ddcd88ed948d 100644 --- a/fs/lustre/llite/llite_internal.h +++ b/fs/lustre/llite/llite_internal.h @@ -536,19 +536,13 @@ static inline void obd_connect_set_name_enc(struct obd_connect_data *data) static inline bool obd_connect_has_enc_fid2path(struct obd_connect_data *data) { -#ifdef HAVE_LUSTRE_CRYPTO return data->ocd_connect_flags & OBD_CONNECT_FLAGS2 && data->ocd_connect_flags2 & OBD_CONNECT2_ENCRYPT_FID2PATH; -#else - return false; -#endif } static inline void obd_connect_set_enc_fid2path(struct obd_connect_data *data) { -#ifdef HAVE_LUSTRE_CRYPTO data->ocd_connect_flags2 |= OBD_CONNECT2_ENCRYPT_FID2PATH; -#endif } /* diff --git a/fs/lustre/obdclass/jobid.c b/fs/lustre/obdclass/jobid.c index 77ea5b26bdf6..1ade7218131b 100644 --- a/fs/lustre/obdclass/jobid.c +++ b/fs/lustre/obdclass/jobid.c @@ -34,9 +34,7 @@ #define DEBUG_SUBSYSTEM S_RPC #include #include -#ifdef HAVE_UIDGID_HEADER #include -#endif #include #include diff --git a/fs/lustre/ptlrpc/wiretest.c b/fs/lustre/ptlrpc/wiretest.c index cc81d4d6717d..b3135d4a7990 100644 --- a/fs/lustre/ptlrpc/wiretest.c +++ b/fs/lustre/ptlrpc/wiretest.c @@ -4656,14 +4656,8 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct hsm_request, hr_data_len)); LASSERTF((int)sizeof(((struct hsm_request *)0)->hr_data_len) == 4, "found %lld\n", (long long)(int)sizeof(((struct hsm_request *)0)->hr_data_len)); -#ifdef HAVE_SERVER_SUPPORT - LASSERTF(HSM_FORCE_ACTION == 0x00000001UL, "found 0x%.8xUL\n", - (unsigned int)HSM_FORCE_ACTION); - LASSERTF(HSM_GHOST_COPY == 0x00000002UL, "found 0x%.8xUL\n", - (unsigned int)HSM_GHOST_COPY); /* Checks for struct hsm_user_request */ -#endif LASSERTF((int)sizeof(struct hsm_user_request) == 24, "found %lld\n", (long long)(int)sizeof(struct hsm_user_request)); LASSERTF((int)offsetof(struct hsm_user_request, hur_request) == 0, "found %lld\n", diff --git a/net/lnet/selftest/conctl.c b/net/lnet/selftest/conctl.c index a7ec0d54fe02..f79368448d3e 100644 --- a/net/lnet/selftest/conctl.c +++ b/net/lnet/selftest/conctl.c @@ -1230,21 +1230,6 @@ static int lst_groups_show_dump(struct sk_buff *msg, return rc; } -#ifndef HAVE_NETLINK_CALLBACK_START -static int lst_old_groups_show_dump(struct sk_buff *msg, - struct netlink_callback *cb) -{ - if (!cb->args[0]) { - int rc = lst_groups_show_start(cb); - - if (rc < 0) - return rc; - } - - return lst_groups_show_dump(msg, cb); -} -#endif - static const struct genl_multicast_group lst_mcast_grps[] = { { .name = "sessions", }, { .name = "groups", }, @@ -1258,12 +1243,8 @@ static const struct genl_ops lst_genl_ops[] = { }, { .cmd = LNET_SELFTEST_CMD_GROUPS, -#ifdef HAVE_NETLINK_CALLBACK_START .start = lst_groups_show_start, .dumpit = lst_groups_show_dump, -#else - .dumpit = lst_old_groups_show_dump, -#endif .done = lst_groups_show_done, }, }; From patchwork Fri Mar 21 13:06:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025424 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27CCEC36001 for ; Fri, 21 Mar 2025 13:12:59 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2n44xGZz1y1h; Fri, 21 Mar 2025 06:08:08 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2m443KYz1x9v for ; Fri, 21 Mar 2025 06:07:16 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 55EE488F93C; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 5160E106BE17; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:45 -0400 Message-ID: <20250321130711.3257092-3-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 02/27] lnet: rework module loading X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Frank Sehr , Chris Horn , Serguei Smirnov , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" The kernel IS_MODULE() only works in the positive, ie no ifndef. So rework the LND module loading code to handle if modules are enabled and use the proper macro. Also don't use request_module in obdclass module as well unless IS_MODULE is true for Lustre. WC-bug-id: https://jira.whamcloud.com/browse/LU-12511 Lustre-commit: 6e76d3569bf602d71 ("LU-12511 lnet: rework lnd module loading") Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57946 Reviewed-by: Frank Sehr Reviewed-by: Serguei Smirnov Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin --- fs/lustre/obdclass/genops.c | 4 +++- net/lnet/lnet/api-ni.c | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/lustre/obdclass/genops.c b/fs/lustre/obdclass/genops.c index a3f7b59db47f..0cbc2c7c393d 100644 --- a/fs/lustre/obdclass/genops.c +++ b/fs/lustre/obdclass/genops.c @@ -36,6 +36,7 @@ */ #define DEBUG_SUBSYSTEM S_CLASS +#include #include #include #include @@ -97,7 +98,7 @@ static struct obd_type *class_get_type(const char *name) rcu_read_lock(); type = class_search_type(name); - +#if IS_MODULE(CONFIG_LUSTRE_FS) if (!type) { const char *modname = name; @@ -111,6 +112,7 @@ static struct obd_type *class_get_type(const char *name) rcu_read_lock(); type = class_search_type(name); } +#endif if (type) { /* * Holding rcu_read_lock() matches the synchronize_rcu() call diff --git a/net/lnet/lnet/api-ni.c b/net/lnet/lnet/api-ni.c index 870ae4312d78..d65ccb4e78aa 100644 --- a/net/lnet/lnet/api-ni.c +++ b/net/lnet/lnet/api-ni.c @@ -2556,22 +2556,22 @@ static struct lnet_lnd *lnet_load_lnd(u32 lnd_type) mutex_lock(&the_lnet.ln_lnd_mutex); lnd = lnet_find_lnd_by_type(lnd_type); if (!lnd) { +#if IS_MODULE(CONFIG_LNET) mutex_unlock(&the_lnet.ln_lnd_mutex); rc = request_module("%s", libcfs_lnd2modname(lnd_type)); mutex_lock(&the_lnet.ln_lnd_mutex); lnd = lnet_find_lnd_by_type(lnd_type); if (!lnd) { - mutex_unlock(&the_lnet.ln_lnd_mutex); CERROR("Can't load LND %s, module %s, rc=%d\n", libcfs_lnd2str(lnd_type), libcfs_lnd2modname(lnd_type), rc); -#ifndef HAVE_MODULE_LOADING_SUPPORT - LCONSOLE_ERROR_MSG(0x104, - "Your kernel must be compiled with kernel module loading support."); -#endif - return ERR_PTR(-EINVAL); + lnd = ERR_PTR(-EINVAL); } +#else + LCONSOLE_ERROR("Could not find LND %s\n", libcfs_lnd2str(lnd_type)); + lnd = ERR_PTR(-EINVAL); +#endif } mutex_unlock(&the_lnet.ln_lnd_mutex); From patchwork Fri Mar 21 13:06:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF105C36000 for ; Fri, 21 Mar 2025 13:09:32 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2mp617Pz1xny; Fri, 21 Mar 2025 06:07:54 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2m43VWsz1whP for ; Fri, 21 Mar 2025 06:07:16 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 593C717D1C3; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 5520C106BE18; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:46 -0400 Message-ID: <20250321130711.3257092-4-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 03/27] lustre: gss: no sec flavor on loopback connection X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aurelien Degremont , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Sebastien Buisson When using a local client, i.e. a client mounted on a server node, there is no benefit from a security standpoint to enforce an SSK or KRB flavor, since the data does not go over the network. So force the 'null' security flavor for connections on 0@lo, independently of the currently defined srpc flavor. WC-bug-id: https://jira.whamcloud.com/browse/LU-13343 Lustre-commit: e3e91ea95fd96a5ea ("LU-13343 gss: no sec flavor on loopback connection") Signed-off-by: Sebastien Buisson Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/46704 Reviewed-by: Aurelien Degremont Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/lmv/lmv_obd.c | 1 + fs/lustre/lov/lov_obd.c | 11 +++++++---- fs/lustre/ptlrpc/sec_config.c | 4 ++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/lustre/lmv/lmv_obd.c b/fs/lustre/lmv/lmv_obd.c index f7c7826d0baf..da28bc0e544b 100644 --- a/fs/lustre/lmv/lmv_obd.c +++ b/fs/lustre/lmv/lmv_obd.c @@ -471,6 +471,7 @@ static int lmv_check_connect(struct obd_device *obd) continue; --lmv->lmv_mdt_descs.ltd_lmv_desc.ld_active_tgt_count; + obd_register_observer(tgt->ltd_exp->exp_obd, NULL); obd_disconnect(tgt->ltd_exp); } diff --git a/fs/lustre/lov/lov_obd.c b/fs/lustre/lov/lov_obd.c index 392395f4c35e..f05091560e95 100644 --- a/fs/lustre/lov/lov_obd.c +++ b/fs/lustre/lov/lov_obd.c @@ -134,8 +134,10 @@ int lov_connect_osc(struct obd_device *obd, u32 index, int activate, tgt_obd = lov->lov_tgts[index]->ltd_obd; if (!tgt_obd->obd_set_up) { - CERROR("Target %s not set up\n", obd_uuid2str(tgt_uuid)); - return -EINVAL; + rc = -EINVAL; + CERROR("%s: target not set up: rc = %d\n", + obd_uuid2str(tgt_uuid), rc); + return rc; } /* override the sp_me from lov */ @@ -159,7 +161,7 @@ int lov_connect_osc(struct obd_device *obd, u32 index, int activate, rc = obd_register_observer(tgt_obd, obd); if (rc) { - CERROR("Target %s register_observer error %d\n", + CERROR("%s: target register_observer error: rc = %d\n", obd_uuid2str(tgt_uuid), rc); return rc; } @@ -174,8 +176,9 @@ int lov_connect_osc(struct obd_device *obd, u32 index, int activate, rc = obd_connect(NULL, &lov->lov_tgts[index]->ltd_exp, tgt_obd, &lov_osc_uuid, data, lov->lov_cache); if (rc || !lov->lov_tgts[index]->ltd_exp) { - CERROR("Target %s connect error %d\n", + CERROR("%s: target connect error: rc = %d\n", obd_uuid2str(tgt_uuid), rc); + obd_register_observer(tgt_obd, NULL); return -ENODEV; } diff --git a/fs/lustre/ptlrpc/sec_config.c b/fs/lustre/ptlrpc/sec_config.c index 95e0da4b2da2..35bd95315bd7 100644 --- a/fs/lustre/ptlrpc/sec_config.c +++ b/fs/lustre/ptlrpc/sec_config.c @@ -380,6 +380,10 @@ static int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset, struct sptlrpc_rule *r; int n; + if (nid_is_lo0(nid)) + /* do not enforce any sec flavor on loopback connection */ + return 0; + for (n = 0; n < rset->srs_nrule; n++) { r = &rset->srs_rules[n]; From patchwork Fri Mar 21 13:06:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025426 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36A3DC36000 for ; Fri, 21 Mar 2025 13:16:31 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2nS3DPnz1y5l; Fri, 21 Mar 2025 06:08:28 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2m52n25z1xSC for ; Fri, 21 Mar 2025 06:07:17 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm5-e204-208.ccs.ornl.gov [160.91.203.29]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 6263288F9D5; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 59500106BE19; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:47 -0400 Message-ID: <20250321130711.3257092-5-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 04/27] lustre: llite: improve readpage debug X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Patrick Farrell LU-16412 (which is a workaround for a kernel bug) added a debug message in ll_readpage(), but this message is printed every time rather than only when the kernel bug is hit. Let's fix this. Fixes: aaa089da3f ("lustre: llite: check truncated page in ->readpage()") WC-bug-id: https://jira.whamcloud.com/browse/LU-16805 Lustre-commit: c2f548dacc5fd7285 ("LU-16805 llite: improve readpage debug") Signed-off-by: Patrick Farrell Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50892 Reviewed-by: Andreas Dilger Reviewed-by: Timothy Day Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/rw.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/lustre/llite/rw.c b/fs/lustre/llite/rw.c index 276cad2b6eb7..e258d995c54b 100644 --- a/fs/lustre/llite/rw.c +++ b/fs/lustre/llite/rw.c @@ -1981,9 +1981,6 @@ int ll_readpage(struct file *file, struct page *vmpage) } if (lcc && lcc->lcc_type != LCC_MMAP) { - CDEBUG(D_VFSTRACE, "pgno:%ld, beyond read end_index:%ld\n", - vmpage->index, lcc->lcc_end_index); - /* * This handles a kernel bug introduced in kernel 5.12: * comment: cbd59c48ae2bcadc4a7599c29cf32fd3f9b78251 @@ -2009,6 +2006,10 @@ int ll_readpage(struct file *file, struct page *vmpage) * mentioned above. */ if (vmpage->index >= lcc->lcc_end_index) { + CDEBUG(D_VFSTRACE, + "pgno:%ld, beyond read end_index:%ld\n", + vmpage->index, lcc->lcc_end_index); + result = cl_io_read_ahead(env, io, vmpage->index, &ra); if (result < 0 || vmpage->index > ra.cra_end_idx) { cl_read_ahead_release(env, &ra); From patchwork Fri Mar 21 13:06:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025412 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7C17C36000 for ; Fri, 21 Mar 2025 13:08:30 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2mb511Zz1xfB; Fri, 21 Mar 2025 06:07:43 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2m526mVz1xNs for ; Fri, 21 Mar 2025 06:07:17 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 60FD817D1DE; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 5D14C106BE16; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:48 -0400 Message-ID: <20250321130711.3257092-6-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 05/27] lustre: nrs: Fix console messages X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Etienne AUJAMES Fix format of console messages and missing end-of-line. CERROR("%s.%d NRS: ....", service_name, cpt, ...); Fixes: f5e513a ("lustre: nrs: change nrs policies at run time") WC-bug-id: https://jira.whamcloud.com/browse/LU-16846 Lustre-commit: c1915c5f0dd865c13 ("LU-16846 nrs: Fix console messages") Signed-off-by: Etienne AUJAMES Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51121 Reviewed-by: Andreas Dilger Reviewed-by: Timothy Day Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/ptlrpc/nrs.c | 70 +++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/fs/lustre/ptlrpc/nrs.c b/fs/lustre/ptlrpc/nrs.c index 661bba7a0f06..eb0e65b6ddb7 100644 --- a/fs/lustre/ptlrpc/nrs.c +++ b/fs/lustre/ptlrpc/nrs.c @@ -209,6 +209,8 @@ static void nrs_policy_stop_primary(struct ptlrpc_nrs *nrs) static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy, char *arg) { struct ptlrpc_nrs *nrs = policy->pol_nrs; + struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; + char *srv_name = svcpt->scp_service->srv_name; int rc = 0; /** @@ -224,8 +226,10 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy, char *arg) return -EAGAIN; if (arg && strlen(arg) >= sizeof(policy->pol_arg)) { - CWARN("NRS: arg '%s' is too long\n", arg); - return -EINVAL; + rc = -EINVAL; + CWARN("%s.%d NRS: arg '%s' is too long: rc = %d\n", + srv_name, svcpt->scp_cpt, arg, rc); + return rc; } if (policy->pol_flags & PTLRPC_NRS_FL_FALLBACK) { @@ -277,9 +281,10 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy, char *arg) if (atomic_inc_return(&policy->pol_desc->pd_refs) == 1 && !try_module_get(policy->pol_desc->pd_owner)) { atomic_dec(&policy->pol_desc->pd_refs); - CERROR("NRS: cannot get module for policy %s; is it alive?\n", - policy->pol_desc->pd_name); - return -ENODEV; + rc = -ENODEV; + CERROR("%s.%d NRS: cannot get module for policy %s (is it alive?): rc = %d\n", + srv_name, svcpt->scp_cpt, policy->pol_desc->pd_name, rc); + return rc; } /** @@ -713,6 +718,8 @@ static int nrs_policy_ctl(struct ptlrpc_nrs *nrs, char *name, static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) { struct ptlrpc_nrs_policy *policy = NULL; + struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; + char *srv_name = svcpt->scp_service->srv_name; int rc = 0; spin_lock(&nrs->nrs_lock); @@ -720,14 +727,15 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) policy = nrs_policy_find_locked(nrs, name); if (!policy) { rc = -ENOENT; - CERROR("NRS: cannot find policy '%s': rc = %d\n", name, rc); + CERROR("%s.%d NRS: cannot find policy '%s': rc = %d\n", + srv_name, svcpt->scp_cpt, name, rc); goto out_unlock; } if (policy->pol_ref > 1) { rc = -EBUSY; - CERROR("NRS: policy '%s' is busy with %ld references: rc = %d", - name, policy->pol_ref, rc); + CERROR("%s.%d NRS: policy '%s' is busy with %ld references: rc = %d\n", + srv_name, svcpt->scp_cpt, name, policy->pol_ref, rc); goto out_put; } @@ -737,8 +745,9 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) if (policy->pol_state != NRS_POL_STATE_STOPPED) { rc = nrs_policy_stop_locked(policy); if (rc) { - CERROR("NRS: failed to stop policy '%s' with refcount %d: rc = %d\n", - name, refcount_read(&policy->pol_start_ref), rc); + CERROR("%s.%d NRS: failed to stop policy '%s' with refcount %d: rc = %d\n", + srv_name, svcpt->scp_cpt, name, + refcount_read(&policy->pol_start_ref), rc); goto out_put; } } @@ -775,6 +784,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, struct ptlrpc_nrs_policy *policy; struct ptlrpc_nrs_policy *tmp; struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; + char *srv_name = svcpt->scp_service->srv_name; int rc; LASSERT(desc->pd_ops->op_res_get); @@ -809,16 +819,17 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, tmp = nrs_policy_find_locked(nrs, policy->pol_desc->pd_name); if (tmp) { - CERROR("NRS policy %s has been registered, can't register it for %s\n", - policy->pol_desc->pd_name, - svcpt->scp_service->srv_name); + rc = -EEXIST; + CERROR("%s.%d NRS: policy %s has been registered, can't register it: rc = %d\n", + srv_name, svcpt->scp_cpt, policy->pol_desc->pd_name, + rc); nrs_policy_put_locked(tmp); spin_unlock(&nrs->nrs_lock); nrs_policy_fini(policy); kfree(policy); - return -EEXIST; + return rc; } list_add_tail(&policy->pol_list, &nrs->nrs_policy_list); @@ -921,9 +932,9 @@ static int nrs_register_policies_locked(struct ptlrpc_nrs *nrs) if (nrs_policy_compatible(svc, desc)) { rc = nrs_policy_register(nrs, desc); if (rc != 0) { - CERROR("Failed to register NRS policy %s for partition %d of service %s: %d\n", - desc->pd_name, svcpt->scp_cpt, - svc->srv_name, rc); + CERROR("%s.%d NRS: Failed to register policy %s: rc = %d\n", + svc->srv_name, svcpt->scp_cpt, + desc->pd_name, rc); /** * Fail registration if any of the policies' * registration fails. @@ -1108,6 +1119,7 @@ static int nrs_policy_unregister_locked(struct ptlrpc_nrs_pol_desc *desc) continue; ptlrpc_service_for_each_part(svcpt, i, svc) { + char *srv_name = svcpt->scp_service->srv_name; bool hp = false; again: @@ -1120,9 +1132,9 @@ static int nrs_policy_unregister_locked(struct ptlrpc_nrs_pol_desc *desc) if (rc == -ENOENT) { rc = 0; } else if (rc != 0) { - CERROR("Failed to unregister NRS policy %s for partition %d of service %s: %d\n", - desc->pd_name, svcpt->scp_cpt, - svcpt->scp_service->srv_name, rc); + CERROR("%s.%d NRS: Failed to unregister policy %s: rc = %d\n", + srv_name, svcpt->scp_cpt, desc->pd_name, + rc); return rc; } @@ -1182,17 +1194,18 @@ static int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) if ((conf->nc_flags & PTLRPC_NRS_FL_REG_EXTERN) && (conf->nc_flags & (PTLRPC_NRS_FL_FALLBACK | PTLRPC_NRS_FL_REG_START))) { - CERROR("NRS: failing to register policy %s. Please check policy flags; external policies cannot act as fallback policies, or be started immediately upon registration without interaction with lprocfs\n", - conf->nc_name); - return -EINVAL; + rc = -EINVAL; + CERROR("NRS: failing to register policy %s. Please check policy flags; external policies cannot act as fallback policies, or be started immediately upon registration without interaction with lprocfs: rc = %d\n", + conf->nc_name, rc); + return rc; } mutex_lock(&nrs_core.nrs_mutex); if (nrs_policy_find_desc_locked(conf->nc_name)) { - CERROR("NRS: failing to register policy %s which has already been registered with NRS core!\n", - conf->nc_name); rc = -EEXIST; + CERROR("NRS: failing to register policy %s which has already been registered with NRS core: rc = %d\n", + conf->nc_name, rc); goto fail; } @@ -1243,14 +1256,15 @@ static int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) ptlrpc_service_for_each_part(svcpt, i, svc) { struct ptlrpc_nrs *nrs; + char *srv_name = svcpt->scp_service->srv_name; bool hp = false; again: nrs = nrs_svcpt2nrs(svcpt, hp); rc = nrs_policy_register(nrs, desc); if (rc != 0) { - CERROR("Failed to register NRS policy %s for partition %d of service %s: %d\n", - desc->pd_name, svcpt->scp_cpt, - svcpt->scp_service->srv_name, rc); + CERROR("%s.%d NRS: Failed to register policy %s: rc = %d\n", + srv_name, svcpt->scp_cpt, + desc->pd_name, rc); rc2 = nrs_policy_unregister_locked(desc); /** From patchwork Fri Mar 21 13:06:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025434 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8CD1EC36000 for ; Fri, 21 Mar 2025 13:18:08 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2ns4wJNz1xfP; Fri, 21 Mar 2025 06:08:49 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2m82Hfdz1xch for ; Fri, 21 Mar 2025 06:07:20 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 6365488F9D6; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 60D40106BE1A; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:49 -0400 Message-ID: <20250321130711.3257092-7-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 06/27] lnet: libcfs: Remove reference to LASSERT_ATOMIC_GT X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arshad Hussain , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Arshad Hussain This patch removes all reference to LASSERT_ATOMIC_GT macro. WC-bug-id: https://jira.whamcloud.com/browse/LU-16796 Lustre-commit: acdc2c8bb7aaf8d19 ("LU-16796 libcfs: Remove reference to LASSERT_ATOMIC_GT") Signed-off-by: Arshad Hussain Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51189 Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Signed-off-by: James Simmons --- fs/lustre/ptlrpc/sec_null.c | 2 +- include/linux/libcfs/libcfs_private.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/fs/lustre/ptlrpc/sec_null.c b/fs/lustre/ptlrpc/sec_null.c index a7241bde7525..9f3a4ef43818 100644 --- a/fs/lustre/ptlrpc/sec_null.c +++ b/fs/lustre/ptlrpc/sec_null.c @@ -343,7 +343,7 @@ int null_alloc_rs(struct ptlrpc_request *req, int msgsize) static void null_free_rs(struct ptlrpc_reply_state *rs) { - LASSERT_ATOMIC_GT(&rs->rs_svc_ctx->sc_refcount, 1); + LASSERT(atomic_read(&rs->rs_svc_ctx->sc_refcount) > 1); atomic_dec(&rs->rs_svc_ctx->sc_refcount); if (!rs->rs_prealloc) { diff --git a/include/linux/libcfs/libcfs_private.h b/include/linux/libcfs/libcfs_private.h index cc9115a89f43..d46c66e8534b 100644 --- a/include/linux/libcfs/libcfs_private.h +++ b/include/linux/libcfs/libcfs_private.h @@ -112,10 +112,6 @@ int libcfs_debug_mark_buffer(const char *text); #define LASSERT_ATOMIC_EQ(a, v) \ LASSERTF(atomic_read(a) == v, "value: %d\n", atomic_read((a))) -/** assert value of @a is great than @v */ -#define LASSERT_ATOMIC_GT(a, v) \ - LASSERTF(atomic_read(a) > v, "value: %d\n", atomic_read((a))) - /** assert value of @a is great than @v1 and little than @v2 */ #define LASSERT_ATOMIC_GT_LT(a, v1, v2) \ do { \ @@ -126,7 +122,6 @@ do { \ #else /* !LASSERT_ATOMIC_ENABLED */ #define LASSERT_ATOMIC_EQ(a, v) do {} while (0) -#define LASSERT_ATOMIC_GT(a, v) do {} while (0) #define LASSERT_ATOMIC_GT_LT(a, v1, v2) do {} while (0) #endif /* LASSERT_ATOMIC_ENABLED */ From patchwork Fri Mar 21 13:06:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA684C36000 for ; Fri, 21 Mar 2025 13:15:31 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2nM6Smfz1y3g; Fri, 21 Mar 2025 06:08:23 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2m81Lkmz1xNs for ; Fri, 21 Mar 2025 06:07:20 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm4-e204-208.ccs.ornl.gov [160.91.203.22]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 6808D17D187; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 64A4A106BE14; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:50 -0400 Message-ID: <20250321130711.3257092-8-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 07/27] lustre: obd: fix style and clang error X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arshad Hussain , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Timothy Day Tabify the remaining code in this file and clean up some of the comments. Add SPDX text. Remove a function which is never used. Fix the style of and inline cl_io_invariant. Conserve a significant number of * so that they can be repurposed in other comments. WC-bug-id: https://jira.whamcloud.com/browse/LU-16518 Lustre-commit: 4fc3c208422e3f2a1 ("LU-16518 obd: fix style and clang error") Signed-off-by: Timothy Day Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51311 Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/include/cl_object.h | 7 ++-- fs/lustre/obdclass/cl_io.c | 68 ++++++++++++----------------------- 2 files changed, 26 insertions(+), 49 deletions(-) diff --git a/fs/lustre/include/cl_object.h b/fs/lustre/include/cl_object.h index b8ac31960a2f..9871b695a4fb 100644 --- a/fs/lustre/include/cl_object.h +++ b/fs/lustre/include/cl_object.h @@ -805,7 +805,8 @@ struct cl_page_slice { enum cl_lock_mode { CLM_READ, CLM_WRITE, - CLM_GROUP + CLM_GROUP, + CLM_MAX, }; /** @@ -1395,8 +1396,7 @@ typedef void (*cl_commit_cbt)(const struct lu_env *, struct cl_io *, struct pagevec *); struct cl_read_ahead { - /* - * Maximum page index the readahead window will end. + /* Maximum page index the readahead window will end. * This is determined DLM lock coverage, RPC and stripe boundary. * cra_end is included. */ @@ -1411,6 +1411,7 @@ struct cl_read_ahead { /* Callback data for cra_release routine */ void *cra_dlmlock; void *cra_oio; + /* whether lock is in contention */ bool cra_contention; }; diff --git a/fs/lustre/obdclass/cl_io.c b/fs/lustre/obdclass/cl_io.c index d6518e9f9c66..99672510aa5a 100644 --- a/fs/lustre/obdclass/cl_io.c +++ b/fs/lustre/obdclass/cl_io.c @@ -1,55 +1,34 @@ // SPDX-License-Identifier: GPL-2.0 -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ + /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * * Copyright (c) 2011, 2017, Intel Corporation. */ + /* * This file is part of Lustre, http://www.lustre.org/ * * Client IO. * - * Author: Nikita Danilov - * Author: Jinshan Xiong + * Author: Nikita Danilov + * Author: Jinshan Xiong */ #define DEBUG_SUBSYSTEM S_CLASS +#include +#include +#include #include #include #include -#include -#include -#include #include #include "cl_internal.h" -/***************************************************************************** - * +/* * cl_io interface. - * */ static inline int cl_io_type_is_valid(enum cl_io_type type) @@ -66,19 +45,15 @@ static inline int cl_io_is_loopable(const struct cl_io *io) * cl_io invariant that holds at all times when exported cl_io_*() functions * are entered and left. */ -static int cl_io_invariant(const struct cl_io *io) +static inline int cl_io_invariant(const struct cl_io *io) { - struct cl_io *up; - - up = io->ci_parent; - return - /* - * io can own pages only when it is ongoing. Sub-io might - * still be in CIS_LOCKED state when top-io is in - * CIS_IO_GOING. - */ - ergo(io->ci_owned_nr > 0, io->ci_state == CIS_IO_GOING || - (io->ci_state == CIS_LOCKED && up)); + /* + * io can own pages only when it is ongoing. Sub-io might + * still be in CIS_LOCKED state when top-io is in + * CIS_IO_GOING. + */ + return ergo(io->ci_owned_nr > 0, io->ci_state == CIS_IO_GOING || + (io->ci_state == CIS_LOCKED && io->ci_parent)); } /** @@ -92,8 +67,8 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) LINVRNT(cl_io_invariant(io)); while (!list_empty(&io->ci_layers)) { - slice = list_last_entry(&io->ci_layers, struct cl_io_slice, - cis_linkage); + slice = container_of(io->ci_layers.prev, struct cl_io_slice, + cis_linkage); list_del_init(&slice->cis_linkage); if (slice->cis_iop->op[io->ci_type].cio_fini) slice->cis_iop->op[io->ci_type].cio_fini(env, slice); @@ -111,7 +86,6 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) case CIT_READ: case CIT_WRITE: case CIT_DATA_VERSION: - break; case CIT_FAULT: break; case CIT_FSYNC: @@ -122,7 +96,6 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) /* Check ignore layout change conf */ LASSERT(ergo(io->ci_ignore_layout || !io->ci_verify_layout, !io->ci_need_restart)); - break; case CIT_GLIMPSE: break; case CIT_LADVISE: @@ -1256,7 +1229,10 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, /* * Holding the lock across both the decrement and * the wakeup ensures cl_sync_io_wait() doesn't complete - * before the wakeup completes. + * before the wakeup completes and the contents of + * the anchor become unsafe to access as the owner is free + * to immediately reclaim anchor when cl_sync_io_wait() + * completes. */ wake_up_locked(&anchor->csi_waitq); if (end_io) From patchwork Fri Mar 21 13:06:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0D52C36001 for ; Fri, 21 Mar 2025 13:20:04 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2pj4bM9z1yCh; Fri, 21 Mar 2025 06:09:33 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2mR3tMtz1xdm for ; Fri, 21 Mar 2025 06:07:35 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm5-e204-208.ccs.ornl.gov [160.91.203.29]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 6C36088F9D7; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 68FC6106BE17; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:51 -0400 Message-ID: <20250321130711.3257092-9-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 08/27] lustre: llite: call truncate_inode_pages() in inode lock X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Bobi Jam In some cases vvp_prune()->truncate_inode_pages() is get called without IO context, we need protect it with inode lock as well. So we add ll_inode_info::lli_inode_lock_owner and set it according to vfs lock rules (Documentation/filesystems/Locking or Documentation/filesystems/locking.rst), so before calling truncate_inode_pages(), we'd lock the inode if it's not locked in vfs. Fixes: 7ce53b7f2e ("lustre: llite: call truncate_inode_pages() under inode lock") WC-bug-id: https://jira.whamcloud.com/browse/LU-16637 Lustre-commit: 51d62f2122fee14fb ("LU-16637 llite: call truncate_inode_pages() in inode lock") Signed-off-by: Bobi Jam Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50857 Reviewed-by: Neil Brown Reviewed-by: Patrick Farrell Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/include/cl_object.h | 14 +++ fs/lustre/llite/dir.c | 4 +- fs/lustre/llite/file.c | 18 ++-- fs/lustre/llite/llite_internal.h | 39 +++++++- fs/lustre/llite/llite_lib.c | 42 ++++++--- fs/lustre/llite/llite_nfs.c | 4 +- fs/lustre/llite/namei.c | 151 ++++++++++++++++++++++++------- fs/lustre/llite/vvp_io.c | 8 +- fs/lustre/llite/vvp_object.c | 57 ++++++++++-- fs/lustre/llite/xattr.c | 52 +++++++---- fs/lustre/lov/lov_object.c | 58 ++++++++++-- fs/lustre/obdclass/cl_object.c | 17 ++++ 12 files changed, 369 insertions(+), 95 deletions(-) diff --git a/fs/lustre/include/cl_object.h b/fs/lustre/include/cl_object.h index 9871b695a4fb..9b90a2c4d2ba 100644 --- a/fs/lustre/include/cl_object.h +++ b/fs/lustre/include/cl_object.h @@ -297,6 +297,13 @@ struct cl_layout { bool cl_is_released; }; +enum coo_inode_opc { + COIO_INODE_LOCK, + COIO_INODE_UNLOCK, + COIO_SIZE_LOCK, + COIO_SIZE_UNLOCK, +}; + /** * Operations implemented for each cl object layer. * @@ -424,6 +431,11 @@ struct cl_object_operations { int (*coo_object_flush)(const struct lu_env *env, struct cl_object *obj, struct ldlm_lock *lock); + /** + * operate upon inode. Used in LOV to lock/unlock inode from vvp layer. + */ + int (*coo_inode_ops)(const struct lu_env *env, struct cl_object *obj, + enum coo_inode_opc opc, void *data); }; /** @@ -2150,6 +2162,8 @@ int cl_object_layout_get(const struct lu_env *env, struct cl_object *obj, loff_t cl_object_maxbytes(struct cl_object *obj); int cl_object_flush(const struct lu_env *env, struct cl_object *obj, struct ldlm_lock *lock); +int cl_object_inode_ops(const struct lu_env *env, struct cl_object *obj, + enum coo_inode_opc opc, void *data); /** diff --git a/fs/lustre/llite/dir.c b/fs/lustre/llite/dir.c index 93f8a27aace3..a7a419abf45a 100644 --- a/fs/lustre/llite/dir.c +++ b/fs/lustre/llite/dir.c @@ -2307,7 +2307,7 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin) bool api32 = ll_need_32bit_api(sbi); loff_t ret = -EINVAL; - inode_lock(inode); + ll_inode_lock(inode); switch (origin) { case SEEK_SET: break; @@ -2347,7 +2347,7 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin) } out: - inode_unlock(inode); + ll_inode_unlock(inode); return ret; } diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c index aee529098497..448aea7ceb12 100644 --- a/fs/lustre/llite/file.c +++ b/fs/lustre/llite/file.c @@ -2194,11 +2194,11 @@ static ssize_t ll_do_tiny_write(struct kiocb *iocb, struct iov_iter *iter) return 0; if (unlikely(lock_inode)) - inode_lock(inode); + ll_inode_lock(inode); result = __generic_file_write_iter(iocb, iter); if (unlikely(lock_inode)) - inode_unlock(inode); + ll_inode_unlock(inode); /* If the page is not already dirty, ll_tiny_write_begin returns * -ENODATA. We continue on to normal write. @@ -2918,9 +2918,9 @@ static int fid2path_for_enc_file(struct inode *parent, char *gfpath, if (enckey == 0 || nameenc == 0) continue; - inode_lock(parent); + ll_inode_lock(parent); de = lookup_one_len(p, de_parent, len); - inode_unlock(parent); + ll_inode_unlock(parent); if (IS_ERR_OR_NULL(de) || !de->d_inode) { dput(de_parent); rc = -ENODATA; @@ -3344,6 +3344,7 @@ static int ll_hsm_import(struct inode *inode, struct file *file, inode_lock(inode); + /* inode lock owner set in ll_setattr_raw() */ rc = ll_setattr_raw(file->f_path.dentry, attr, 0, true); if (rc == -ENODATA) rc = 0; @@ -3391,6 +3392,7 @@ static int ll_file_futimes_3(struct file *file, const struct ll_futimes_3 *lfu) return -EINVAL; inode_lock(inode); + /* inode lock owner set in ll_setattr_raw()*/ rc = ll_setattr_raw(file_dentry(file), &ia, OP_XVALID_CTIME_SET, false); inode_unlock(inode); @@ -3783,10 +3785,10 @@ int ll_ioctl_project(struct file *file, unsigned int cmd, void __user *uarg) /* apply child dentry if name is valid */ name_len = strnlen(lu_project.project_name, NAME_MAX); if (name_len > 0 && name_len <= NAME_MAX) { - inode_lock(inode); + ll_inode_lock(inode); child_dentry = lookup_one_len(lu_project.project_name, dentry, name_len); - inode_unlock(inode); + ll_inode_unlock(inode); if (IS_ERR(child_dentry)) { rc = PTR_ERR(child_dentry); goto out; @@ -5021,7 +5023,7 @@ int ll_migrate(struct inode *parent, struct file *file, struct lmv_user_md *lum, goto out_iput; } - inode_lock(child_inode); + ll_inode_lock(child_inode); op_data->op_fid3 = *ll_inode2fid(child_inode); if (!fid_is_sane(&op_data->op_fid3)) { CERROR("%s: migrate %s, but fid " DFID " is insane\n", @@ -5105,7 +5107,7 @@ int ll_migrate(struct inode *parent, struct file *file, struct lmv_user_md *lum, if (!rc) clear_nlink(child_inode); out_unlock: - inode_unlock(child_inode); + ll_inode_unlock(child_inode); ll_finish_md_op_data(op_data); out_iput: iput(child_inode); diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h index ddcd88ed948d..755fdae77709 100644 --- a/fs/lustre/llite/llite_internal.h +++ b/fs/lustre/llite/llite_internal.h @@ -94,7 +94,7 @@ struct ll_grouplock { unsigned long lg_gid; }; -enum ll_file_flags { +enum ll_inode_flags { /* File data is modified. */ LLIF_DATA_MODIFIED = 0, /* File is being restored */ @@ -109,6 +109,7 @@ enum ll_file_flags { LLIF_UPDATE_ATIME = 4, /* foreign file/dir can be unlinked unconditionnaly */ LLIF_FOREIGN_REMOVABLE = 5, + /* 6 is not used for now */ /* Xattr cache is filled */ LLIF_XATTR_CACHE_FILLED = 7, }; @@ -215,7 +216,8 @@ struct ll_inode_info { /* for non-directory */ struct { struct mutex lli_size_mutex; - char *lli_symlink_name; + struct task_struct *lli_size_lock_owner; + char *lli_symlink_name; struct ll_trunc_sem lli_trunc_sem; struct range_lock_tree lli_write_tree; struct mutex lli_setattr_mutex; @@ -300,6 +302,8 @@ struct ll_inode_info { struct list_head lli_xattrs; /* ll_xattr_entry->xe_list */ struct list_head lli_lccs; /* list of ll_cl_context */ seqlock_t lli_page_inv_lock; + + struct task_struct *lli_inode_lock_owner; }; static inline void ll_trunc_sem_init(struct ll_trunc_sem *sem) @@ -566,6 +570,35 @@ static inline struct pcc_inode *ll_i2pcci(struct inode *inode) return ll_i2info(inode)->lli_pcc_inode; } +static inline void ll_set_inode_lock_owner(struct inode *inode) +{ + ll_i2info(inode)->lli_inode_lock_owner = current; +} + +static inline void ll_clear_inode_lock_owner(struct inode *inode) +{ + ll_i2info(inode)->lli_inode_lock_owner = NULL; +} + +static inline struct task_struct *ll_get_inode_lock_owner(struct inode *inode) +{ + return ll_i2info(inode)->lli_inode_lock_owner; +} + +/* lock inode and set inode lock owener */ +static inline void ll_inode_lock(struct inode *inode) +{ + inode_lock(inode); + ll_set_inode_lock_owner(inode); +} + +/* clear inode lock owner and unlock it */ +static inline void ll_inode_unlock(struct inode *inode) +{ + ll_clear_inode_lock_owner(inode); + inode_unlock(inode); +} + /* default to use at least 16M for fast read if possible */ #define RA_REMAIN_WINDOW_MIN MiB_TO_PAGES(16UL) @@ -1294,7 +1327,7 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md); void ll_update_inode_flags(struct inode *inode, unsigned int ext_flags); void ll_update_dir_depth_dmv(struct inode *dir, struct dentry *de); int ll_read_inode2(struct inode *inode, void *opaque); -void ll_truncate_inode_pages_final(struct inode *inode, struct cl_io *io); +void ll_truncate_inode_pages_final(struct inode *inode); void ll_delete_inode(struct inode *inode); int ll_iocontrol(struct inode *inode, struct file *file, unsigned int cmd, void __user *uarg); diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c index 99b2982fa322..9adb7ef4ffac 100644 --- a/fs/lustre/llite/llite_lib.c +++ b/fs/lustre/llite/llite_lib.c @@ -1225,6 +1225,7 @@ void ll_lli_init(struct ll_inode_info *lli) /* ll_cl_context initialize */ INIT_LIST_HEAD(&lli->lli_lccs); seqlock_init(&lli->lli_page_inv_lock); + lli->lli_inode_lock_owner = NULL; } int ll_fill_super(struct super_block *sb) @@ -1865,10 +1866,10 @@ static int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data) */ op_data->op_attr.ia_valid &= ~(TIMES_SET_FLAGS | ATTR_SIZE); if (S_ISREG(inode->i_mode)) - inode_lock(inode); + ll_inode_lock(inode); rc = simple_setattr(dentry, &op_data->op_attr); if (S_ISREG(inode->i_mode)) - inode_unlock(inode); + ll_inode_unlock(inode); op_data->op_attr.ia_valid = ia_valid; rc = ll_update_inode(inode, &md); @@ -2099,6 +2100,9 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, ktime_t kstart = ktime_get(); int rc = 0; + /* VFS has locked the inode before calling this */ + ll_set_inode_lock_owner(inode); + CDEBUG(D_VFSTRACE, "%s: setattr inode " DFID "(%p) from %llu to %llu, valid %x, hsm_import %d\n", ll_i2sbi(inode)->ll_fsname, PFID(&lli->lli_fid), inode, i_size_read(inode), attr->ia_size, attr->ia_valid, hsm_import); @@ -2107,7 +2111,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, /* Check new size against VFS/VM file size limit and rlimit */ rc = inode_newsize_ok(inode, attr->ia_size); if (rc) - return rc; + goto clear; /* The maximum Lustre file size is variable, based on the * OST maximum object size and number of stripes. This @@ -2117,7 +2121,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, CDEBUG(D_INODE, "file " DFID " too large %llu > %llu\n", PFID(&lli->lli_fid), attr->ia_size, ll_file_maxbytes(inode)); - return -EFBIG; + rc = -EFBIG; + goto clear; } attr->ia_valid |= ATTR_MTIME | ATTR_CTIME; @@ -2126,8 +2131,10 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, /* POSIX: check before ATTR_*TIME_SET set (from setattr_prepare) */ if (attr->ia_valid & TIMES_SET_FLAGS) { if ((!uid_eq(current_fsuid(), inode->i_uid)) && - !capable(CAP_FOWNER)) - return -EPERM; + !capable(CAP_FOWNER)) { + rc = -EPERM; + goto clear; + } } /* We mark all of the fields "set" so MDS/OST does not re-set them */ @@ -2153,7 +2160,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, (s64)ktime_get_real_seconds()); if (S_ISREG(inode->i_mode)) - inode_unlock(inode); + ll_inode_unlock(inode); /* * We always do an MDS RPC, even if we're only changing the size; @@ -2339,7 +2346,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, ll_finish_md_op_data(op_data); if (S_ISREG(inode->i_mode)) { - inode_lock(inode); + ll_inode_lock(inode); if ((attr->ia_valid & ATTR_SIZE) && !hsm_import) inode_dio_wait(inode); /* Once we've got the i_mutex, it's safe to set the S_NOSEC @@ -2355,6 +2362,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, ll_stats_ops_tally(ll_i2sbi(inode), attr->ia_valid & ATTR_SIZE ? LPROC_LL_TRUNC : LPROC_LL_SETATTR, ktime_us_delta(ktime_get(), kstart)); +clear: + ll_clear_inode_lock_owner(inode); return rc; } @@ -2553,6 +2562,7 @@ void ll_inode_size_lock(struct inode *inode) lli = ll_i2info(inode); mutex_lock(&lli->lli_size_mutex); + lli->lli_size_lock_owner = current; } void ll_inode_size_unlock(struct inode *inode) @@ -2560,6 +2570,7 @@ void ll_inode_size_unlock(struct inode *inode) struct ll_inode_info *lli; lli = ll_i2info(inode); + lli->lli_size_lock_owner = NULL; mutex_unlock(&lli->lli_size_mutex); } @@ -2890,14 +2901,16 @@ void ll_update_dir_depth_dmv(struct inode *dir, struct dentry *de) lli->lli_inherit_depth); } -void ll_truncate_inode_pages_final(struct inode *inode, struct cl_io *io) +void ll_truncate_inode_pages_final(struct inode *inode) { struct address_space *mapping = &inode->i_data; unsigned long nrpages; unsigned long flags; - LASSERTF(io == NULL || inode_is_locked(inode), "io %p (type %d)\n", - io, io ? io->ci_type : 0); + LASSERTF((inode->i_state & I_FREEING) || inode_is_locked(inode), + DFID ":inode %p state %#lx, lli_flags %#lx\n", + PFID(ll_inode2fid(inode)), inode, inode->i_state, + ll_i2info(inode)->lli_flags); truncate_inode_pages_final(mapping); @@ -2915,10 +2928,11 @@ void ll_truncate_inode_pages_final(struct inode *inode, struct cl_io *io) xa_unlock_irqrestore(&mapping->i_pages, flags); } /* Workaround end */ - LASSERTF(nrpages == 0, "%s: inode="DFID"(%p) nrpages=%lu io %p (io_type %d), see https://jira.whamcloud.com/browse/LU-118\n", + LASSERTF(nrpages == 0, + "%s: inode="DFID"(%p) nrpages=%lu state %#lx, lli_flags %#lx, see https://jira.whamcloud.com/browse/LU-118\n", ll_i2sbi(inode)->ll_fsname, PFID(ll_inode2fid(inode)), inode, nrpages, - io, io ? io->ci_type : 0); + inode->i_state, ll_i2info(inode)->lli_flags); } int ll_read_inode2(struct inode *inode, void *opaque) @@ -2982,7 +2996,7 @@ void ll_delete_inode(struct inode *inode) CL_FSYNC_LOCAL : CL_FSYNC_DISCARD, 1); } - ll_truncate_inode_pages_final(inode, NULL); + ll_truncate_inode_pages_final(inode); ll_clear_inode(inode); clear_inode(inode); } diff --git a/fs/lustre/llite/llite_nfs.c b/fs/lustre/llite/llite_nfs.c index d505c206a62e..1fd74a11709e 100644 --- a/fs/lustre/llite/llite_nfs.c +++ b/fs/lustre/llite/llite_nfs.c @@ -219,9 +219,9 @@ static int ll_get_name(struct dentry *dentry, char *name, goto out; } - inode_lock(dir); + ll_inode_lock(dir); rc = ll_dir_read(dir, &pos, op_data, &lgd.ctx, NULL); - inode_unlock(dir); + ll_inode_unlock(dir); ll_finish_md_op_data(op_data); if (!rc && !lgd.lgd_found) rc = -ENOENT; diff --git a/fs/lustre/llite/namei.c b/fs/lustre/llite/namei.c index 657ad6fd961d..6159f8975847 100644 --- a/fs/lustre/llite/namei.c +++ b/fs/lustre/llite/namei.c @@ -1098,7 +1098,10 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry, unsigned int flags) { struct lookup_intent *itp, it = { .it_op = IT_GETATTR }; - struct dentry *de; + struct dentry *de = NULL; + + /* VFS has locked the inode before calling this */ + ll_set_inode_lock_owner(parent); CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir=" DFID "(%p),flags=%u\n", dentry, PFID(ll_inode2fid(parent)), parent, flags); @@ -1109,7 +1112,7 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry, */ if ((flags & LOOKUP_CREATE) && !(flags & LOOKUP_OPEN) && (inode_permission(parent, MAY_WRITE | MAY_EXEC) == 0)) - return NULL; + goto clear; if (flags & (LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE)) itp = NULL; @@ -1121,6 +1124,9 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry, if (itp) ll_intent_release(itp); +clear: + ll_clear_inode_lock_owner(parent); + return de; } @@ -1144,6 +1150,9 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, int open_threshold; int rc = 0; + /* VFS has locked the inode before calling this */ + ll_set_inode_lock_owner(dir); + CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir=" DFID "(%p), file %p, open_flags %x, mode %x\n", dentry, PFID(ll_inode2fid(dir)), dir, file, open_flags, mode); @@ -1157,8 +1166,10 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, * even though there's a minuscle chance it might succeed. * Either way it's a valid race to just return -ENOENT here. */ - if (!(open_flags & O_CREAT)) - return -ENOENT; + if (!(open_flags & O_CREAT)) { + rc = -ENOENT; + goto clear; + } /* Otherwise we just unhash it to be rehashed afresh via * lookup if necessary @@ -1167,8 +1178,10 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, } it = kzalloc(sizeof(*it), GFP_NOFS); - if (!it) - return -ENOMEM; + if (!it) { + rc = -ENOMEM; + goto clear; + } it->it_op = IT_OPEN; if (open_flags & O_CREAT) { @@ -1319,6 +1332,8 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, out_release: ll_intent_release(it); kfree(it); +clear: + ll_clear_inode_lock_owner(dir); return rc; } @@ -1780,6 +1795,9 @@ static int ll_mknod(struct inode *dir, struct dentry *dchild, ktime_t kstart = ktime_get(); int err; + /* VFS has locked the inode before calling this */ + ll_set_inode_lock_owner(dir); + CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir=" DFID "(%p) mode %o dev %x\n", dchild, PFID(ll_inode2fid(dir)), dir, mode, old_encode_dev(rdev)); @@ -1811,6 +1829,7 @@ static int ll_mknod(struct inode *dir, struct dentry *dchild, if (!err) ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_MKNOD, ktime_us_delta(ktime_get(), kstart)); + ll_clear_inode_lock_owner(dir); return err; } @@ -1824,6 +1843,9 @@ static int ll_create_nd(struct inode *dir, struct dentry *dentry, ktime_t kstart = ktime_get(); int rc; + /* VFS has locked the inode before calling this */ + ll_set_inode_lock_owner(dir); + CFS_FAIL_TIMEOUT(OBD_FAIL_LLITE_CREATE_FILE_PAUSE, cfs_fail_val); CDEBUG(D_VFSTRACE, @@ -1839,6 +1861,8 @@ static int ll_create_nd(struct inode *dir, struct dentry *dentry, ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_CREATE, ktime_us_delta(ktime_get(), kstart)); + ll_clear_inode_lock_owner(dir); + return rc; } @@ -1850,19 +1874,27 @@ static int ll_unlink(struct inode *dir, struct dentry *dchild) ktime_t kstart = ktime_get(); int rc; + /* VFS has locked the inodes before calling this */ + ll_set_inode_lock_owner(dir); + ll_set_inode_lock_owner(dchild->d_inode); + CDEBUG(D_VFSTRACE, "VFS Op:name=%pd,dir=%lu/%u(%p)\n", dchild, dir->i_ino, dir->i_generation, dir); /* some foreign file/dir may not be allowed to be unlinked */ - if (!ll_foreign_is_removable(dchild, false)) - return -EPERM; + if (!ll_foreign_is_removable(dchild, false)) { + rc = -EPERM; + goto clear; + } op_data = ll_prep_md_op_data(NULL, dir, NULL, dchild->d_name.name, dchild->d_name.len, 0, LUSTRE_OPC_ANY, NULL); - if (IS_ERR(op_data)) - return PTR_ERR(op_data); + if (IS_ERR(op_data)) { + rc = PTR_ERR(op_data); + goto clear; + } op_data->op_fid3 = *ll_inode2fid(dchild->d_inode); /* notify lower layer if inode has dirty pages */ @@ -1889,11 +1921,15 @@ static int ll_unlink(struct inode *dir, struct dentry *dchild) } ll_update_times(request, dir); - ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_UNLINK, +out: + ptlrpc_req_finished(request); + if (!rc) + ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_UNLINK, ktime_us_delta(ktime_get(), kstart)); +clear: + ll_clear_inode_lock_owner(dir); + ll_clear_inode_lock_owner(dchild->d_inode); - out: - ptlrpc_req_finished(request); return rc; } @@ -1902,6 +1938,9 @@ static int ll_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ktime_t kstart = ktime_get(); int err; + /* VFS has locked the inode before calling this */ + ll_set_inode_lock_owner(dir); + CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir" DFID "(%p)\n", dentry, PFID(ll_inode2fid(dir)), dir); @@ -1914,6 +1953,8 @@ static int ll_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_MKDIR, ktime_us_delta(ktime_get(), kstart)); + ll_clear_inode_lock_owner(dir); + return err; } @@ -1924,19 +1965,27 @@ static int ll_rmdir(struct inode *dir, struct dentry *dchild) struct md_op_data *op_data; int rc; + /* VFS has locked the inodes before calling this */ + ll_set_inode_lock_owner(dir); + ll_set_inode_lock_owner(dchild->d_inode); + CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir=" DFID "(%p)\n", dchild, PFID(ll_inode2fid(dir)), dir); /* some foreign dir may not be allowed to be removed */ - if (!ll_foreign_is_removable(dchild, false)) - return -EPERM; + if (!ll_foreign_is_removable(dchild, false)) { + rc = -EPERM; + goto out; + } op_data = ll_prep_md_op_data(NULL, dir, NULL, dchild->d_name.name, dchild->d_name.len, S_IFDIR, LUSTRE_OPC_ANY, NULL); - if (IS_ERR(op_data)) - return PTR_ERR(op_data); + if (IS_ERR(op_data)) { + rc = PTR_ERR(op_data); + goto out; + } if (dchild->d_inode) op_data->op_fid3 = *ll_inode2fid(dchild->d_inode); @@ -1965,6 +2014,9 @@ static int ll_rmdir(struct inode *dir, struct dentry *dchild) } ptlrpc_req_finished(request); +out: + ll_clear_inode_lock_owner(dir); + ll_clear_inode_lock_owner(dchild->d_inode); return rc; } @@ -1977,13 +2029,16 @@ static int ll_symlink(struct inode *dir, struct dentry *dchild, struct fscrypt_str disk_link; int err; + /* VFS has locked the inode before calling this */ + ll_set_inode_lock_owner(dir); + CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir=" DFID "(%p),target=%.*s\n", dchild, PFID(ll_inode2fid(dir)), dir, 3000, oldpath); err = fscrypt_prepare_symlink(dir, oldpath, len, dir->i_sb->s_blocksize, &disk_link); if (err) - return err; + goto out; err = ll_new_node(dir, dchild, oldpath, S_IFLNK | 0777, (u64)&disk_link, LUSTRE_OPC_SYMLINK); @@ -1994,6 +2049,8 @@ static int ll_symlink(struct inode *dir, struct dentry *dchild, if (!err) ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_SYMLINK, ktime_us_delta(ktime_get(), kstart)); +out: + ll_clear_inode_lock_owner(dir); return err; } @@ -2008,6 +2065,10 @@ static int ll_link(struct dentry *old_dentry, struct inode *dir, ktime_t kstart = ktime_get(); int err; + /* VFS has locked the inodes before calling this */ + ll_set_inode_lock_owner(src); + ll_set_inode_lock_owner(dir); + CDEBUG(D_VFSTRACE, "VFS Op: inode=" DFID "(%p), dir=" DFID "(%p), target=%pd\n", PFID(ll_inode2fid(src)), src, PFID(ll_inode2fid(dir)), dir, @@ -2015,13 +2076,15 @@ static int ll_link(struct dentry *old_dentry, struct inode *dir, err = fscrypt_prepare_link(old_dentry, dir, new_dentry); if (err) - return err; + goto clear; op_data = ll_prep_md_op_data(NULL, src, dir, new_dentry->d_name.name, new_dentry->d_name.len, 0, LUSTRE_OPC_ANY, NULL); - if (IS_ERR(op_data)) - return PTR_ERR(op_data); + if (IS_ERR(op_data)) { + err = PTR_ERR(op_data); + goto clear; + } err = md_link(sbi->ll_md_exp, op_data, &request); ll_finish_md_op_data(op_data); @@ -2033,6 +2096,10 @@ static int ll_link(struct dentry *old_dentry, struct inode *dir, ktime_us_delta(ktime_get(), kstart)); out: ptlrpc_req_finished(request); +clear: + ll_clear_inode_lock_owner(src); + ll_clear_inode_lock_owner(dir); + return err; } @@ -2048,25 +2115,38 @@ static int ll_rename(struct inode *src, struct dentry *src_dchild, umode_t mode = 0; int err; - if (flags) - return -EINVAL; + /* VFS has locked the inodes before calling this */ + ll_set_inode_lock_owner(src); + ll_set_inode_lock_owner(tgt); + if (tgt_dchild->d_inode) + ll_set_inode_lock_owner(tgt_dchild->d_inode); + + if (flags) { + err = -EINVAL; + goto out; + } CDEBUG(D_VFSTRACE, "VFS Op:oldname=%pd, src_dir=" DFID "(%p), newname=%pd, tgt_dir=" DFID "(%p)\n", src_dchild, PFID(ll_inode2fid(src)), src, tgt_dchild, PFID(ll_inode2fid(tgt)), tgt); - if (unlikely(d_mountpoint(src_dchild) || d_mountpoint(tgt_dchild))) - return -EBUSY; + if (unlikely(d_mountpoint(src_dchild) || d_mountpoint(tgt_dchild))) { + err = -EBUSY; + goto out; + } err = fscrypt_prepare_rename(src, src_dchild, tgt, tgt_dchild, flags); if (err) - return err; + goto out; + /* we prevent an encrypted file from being renamed * into an unencrypted dir */ - if (IS_ENCRYPTED(src) && !IS_ENCRYPTED(tgt)) - return -EXDEV; + if (IS_ENCRYPTED(src) && !IS_ENCRYPTED(tgt)) { + err = -EXDEV; + goto out; + } if (src_dchild->d_inode) mode = src_dchild->d_inode->i_mode; @@ -2076,8 +2156,10 @@ static int ll_rename(struct inode *src, struct dentry *src_dchild, op_data = ll_prep_md_op_data(NULL, src, tgt, NULL, 0, mode, LUSTRE_OPC_ANY, NULL); - if (IS_ERR(op_data)) - return PTR_ERR(op_data); + if (IS_ERR(op_data)) { + err = PTR_ERR(op_data); + goto out; + } /* If the client is using a subdir mount and does a rename to what it * sees as /.fscrypt, interpret it as the .fscrypt dir at fs root. @@ -2095,11 +2177,11 @@ static int ll_rename(struct inode *src, struct dentry *src_dchild, err = ll_setup_filename(src, &src_dchild->d_name, 1, &foldname, NULL); if (err) - return err; + goto out; err = ll_setup_filename(tgt, &tgt_dchild->d_name, 1, &fnewname, NULL); if (err) { fscrypt_free_filename(&foldname); - return err; + goto out; } err = md_rename(sbi->ll_md_exp, op_data, foldname.disk_name.name, foldname.disk_name.len, @@ -2119,6 +2201,11 @@ static int ll_rename(struct inode *src, struct dentry *src_dchild, ll_stats_ops_tally(sbi, LPROC_LL_RENAME, ktime_us_delta(ktime_get(), kstart)); } +out: + ll_clear_inode_lock_owner(src); + ll_clear_inode_lock_owner(tgt); + if (d_inode(tgt_dchild)) + ll_clear_inode_lock_owner(d_inode(tgt_dchild)); return err; } diff --git a/fs/lustre/llite/vvp_io.c b/fs/lustre/llite/vvp_io.c index c5f479c6f7e2..acc9c2935485 100644 --- a/fs/lustre/llite/vvp_io.c +++ b/fs/lustre/llite/vvp_io.c @@ -1258,10 +1258,10 @@ static int vvp_io_write_start(const struct lu_env *env, iter = *vio->vui_iter; if (unlikely(lock_inode)) - inode_lock(inode); + ll_inode_lock(inode); result = __generic_file_write_iter(vio->vui_iocb, &iter); if (unlikely(lock_inode)) - inode_unlock(inode); + ll_inode_unlock(inode); written = result; if (result > 0) @@ -1641,7 +1641,7 @@ static int vvp_io_lseek_start(const struct lu_env *env, struct inode *inode = vvp_object_inode(io->ci_obj); u64 start = io->u.ci_lseek.ls_start; - inode_lock(inode); + ll_inode_lock(inode); inode_dio_wait(inode); /* At the moment we have DLM lock so just update inode @@ -1664,7 +1664,7 @@ static void vvp_io_lseek_end(const struct lu_env *env, if (io->u.ci_lseek.ls_result > i_size_read(inode)) io->u.ci_lseek.ls_result = -ENXIO; - inode_unlock(inode); + ll_inode_unlock(inode); } static const struct cl_io_operations vvp_io_ops = { diff --git a/fs/lustre/llite/vvp_object.c b/fs/lustre/llite/vvp_object.c index f4b2f8921b6c..bc7870620355 100644 --- a/fs/lustre/llite/vvp_object.c +++ b/fs/lustre/llite/vvp_object.c @@ -153,7 +153,6 @@ static int vvp_conf_set(const struct lu_env *env, struct cl_object *obj, static int vvp_prune(const struct lu_env *env, struct cl_object *obj) { - struct cl_io *io = vvp_env_io(env)->vui_cl.cis_io; struct inode *inode = vvp_object_inode(obj); int rc; @@ -164,14 +163,16 @@ static int vvp_prune(const struct lu_env *env, struct cl_object *obj) return rc; } - if (io != NULL) - inode_lock(inode); + if (ll_get_inode_lock_owner(inode) != current) + /* ask LOV get inode lock then lo_type_guard */ + return -EAGAIN; - ll_truncate_inode_pages_final(inode, io); - mapping_clear_exiting(inode->i_mapping); + LASSERTF(inode_is_locked(inode), DFID ":inode %p lli_flags %#lx\n", + PFID(lu_object_fid(&obj->co_lu)), inode, + ll_i2info(inode)->lli_flags); - if (io != NULL) - inode_unlock(inode); + ll_truncate_inode_pages_final(inode); + mapping_clear_exiting(inode->i_mapping); return 0; } @@ -224,6 +225,45 @@ static void vvp_req_attr_set(const struct lu_env *env, struct cl_object *obj, memcpy(attr->cra_jobid, &lli->lli_jobid, sizeof(attr->cra_jobid)); } +static int vvp_inode_ops(const struct lu_env *env, struct cl_object *obj, + enum coo_inode_opc opc, void *data) +{ + struct inode *inode = vvp_object_inode(obj); + int rc = 0; + + switch (opc) { + case COIO_INODE_LOCK: + if (ll_get_inode_lock_owner(inode) != current) + ll_inode_lock(inode); + else + rc = -EALREADY; + break; + case COIO_INODE_UNLOCK: + if (ll_get_inode_lock_owner(inode) == current) + ll_inode_unlock(inode); + else + rc = -ENOLCK; + break; + case COIO_SIZE_LOCK: + if (ll_i2info(inode)->lli_size_lock_owner != current) + ll_inode_size_lock(inode); + else + rc = -EALREADY; + break; + case COIO_SIZE_UNLOCK: + if (ll_i2info(inode)->lli_size_lock_owner == current) + ll_inode_size_unlock(inode); + else + rc = -ENOLCK; + break; + default: + rc = -EINVAL; + break; + } + + return rc; +} + static const struct cl_object_operations vvp_ops = { .coo_page_init = vvp_page_init, .coo_io_init = vvp_io_init, @@ -232,7 +272,8 @@ static const struct cl_object_operations vvp_ops = { .coo_conf_set = vvp_conf_set, .coo_prune = vvp_prune, .coo_glimpse = vvp_object_glimpse, - .coo_req_attr_set = vvp_req_attr_set + .coo_req_attr_set = vvp_req_attr_set, + .coo_inode_ops = vvp_inode_ops, }; static int __vvp_object_init(const struct lu_env *env, diff --git a/fs/lustre/llite/xattr.c b/fs/lustre/llite/xattr.c index ceaad604a55b..930e890554fd 100644 --- a/fs/lustre/llite/xattr.c +++ b/fs/lustre/llite/xattr.c @@ -94,6 +94,9 @@ static int ll_xattr_set_common(const struct xattr_handler *handler, u64 valid; int rc; + /* VFS has locked the inode before calling this */ + ll_set_inode_lock_owner(inode); + /* When setxattr() is called with a size of 0 the value is * unconditionally replaced by "". When removexattr() is * called we get a NULL value and XATTR_REPLACE for flags. @@ -120,20 +123,24 @@ static int ll_xattr_set_common(const struct xattr_handler *handler, /*FIXME: enable IMA when the conditions are ready */ if (handler->flags == XATTR_SECURITY_T && - (!strcmp(name, "ima") || !strcmp(name, "evm"))) - return -EOPNOTSUPP; + (!strcmp(name, "ima") || !strcmp(name, "evm"))) { + rc = -EOPNOTSUPP; + goto out; + } rc = ll_security_secctx_name_filter(sbi, handler->flags, name); if (rc) - return rc; + goto out; /* * In user.* namespace, only regular files and directories can have * extended attributes. */ if (handler->flags == XATTR_USER_T) { - if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) - return -EPERM; + if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) { + rc = -EPERM; + goto out; + } } /* This check is required for compatibility with 2.14, in which @@ -143,12 +150,16 @@ static int ll_xattr_set_common(const struct xattr_handler *handler, * When new files/dirs are created in an encrypted dir, the enc * context is set directly in the create request. */ - if (handler->flags == XATTR_SECURITY_T && strcmp(name, "c") == 0) - return -EPERM; + if (handler->flags == XATTR_SECURITY_T && strcmp(name, "c") == 0) { + rc = -EPERM; + goto out; + } fullname = kasprintf(GFP_KERNEL, "%s%s", xattr_prefix(handler), name); - if (!fullname) - return -ENOMEM; + if (!fullname) { + rc = -ENOMEM; + goto out; + } rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, fullname, pv, size, flags, ll_i2suppgid(inode), &req); @@ -158,7 +169,7 @@ static int ll_xattr_set_common(const struct xattr_handler *handler, LCONSOLE_INFO("Disabling user_xattr feature because it is not supported on the server\n"); clear_bit(LL_SBI_USER_XATTR, sbi->ll_flags); } - return rc; + goto out; } ll_i2info(inode)->lli_synced_to_mds = false; @@ -167,8 +178,10 @@ static int ll_xattr_set_common(const struct xattr_handler *handler, ll_stats_ops_tally(ll_i2sbi(inode), valid == OBD_MD_FLXATTRRM ? LPROC_LL_REMOVEXATTR : LPROC_LL_SETXATTR, ktime_us_delta(ktime_get(), kstart)); +out: + ll_clear_inode_lock_owner(inode); - return 0; + return rc; } static int get_hsm_state(struct inode *inode, u32 *hus_states) @@ -329,11 +342,14 @@ static int ll_xattr_set(const struct xattr_handler *handler, ktime_t kstart = ktime_get(); int op_type = flags == XATTR_REPLACE ? LPROC_LL_REMOVEXATTR : LPROC_LL_SETXATTR; - int rc; + int rc = 0; LASSERT(inode); LASSERT(name); + /* VFS has locked the inode before calling this */ + ll_set_inode_lock_owner(inode); + CDEBUG(D_VFSTRACE, "VFS Op:inode=" DFID "(%p), xattr %s\n", PFID(ll_inode2fid(inode)), inode, name); @@ -343,11 +359,11 @@ static int ll_xattr_set(const struct xattr_handler *handler, size); ll_stats_ops_tally(ll_i2sbi(inode), op_type, ktime_us_delta(ktime_get(), kstart)); - return rc; + goto out; } else if (!strcmp(name, "lma") || !strcmp(name, "link")) { ll_stats_ops_tally(ll_i2sbi(inode), op_type, ktime_us_delta(ktime_get(), kstart)); - return 0; + goto out; } if (strncmp(name, "lov.", 4) == 0 && @@ -355,8 +371,12 @@ static int ll_xattr_set(const struct xattr_handler *handler, le32_to_cpu(LOV_MAGIC_MASK)) == le32_to_cpu(LOV_MAGIC_MAGIC)) lustre_swab_lov_user_md((struct lov_user_md *)value, 0); - return ll_xattr_set_common(handler, dentry, inode, name, value, size, - flags); + rc = ll_xattr_set_common(handler, dentry, inode, name, value, size, + flags); +out: + ll_clear_inode_lock_owner(inode); + + return rc; } int ll_xattr_list(struct inode *inode, const char *name, int type, void *buffer, diff --git a/fs/lustre/lov/lov_object.c b/fs/lustre/lov/lov_object.c index bc0f0a772d1d..27f005c807fe 100644 --- a/fs/lustre/lov/lov_object.c +++ b/fs/lustre/lov/lov_object.c @@ -317,10 +317,11 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov, LASSERT(!r0->lo_sub[idx]); } -static void lov_delete_raid0(const struct lu_env *env, struct lov_object *lov, +static int lov_delete_raid0(const struct lu_env *env, struct lov_object *lov, struct lov_layout_entry *lle) { struct lov_layout_raid0 *r0 = &lle->lle_raid0; + int rc; if (r0->lo_sub) { int i; @@ -329,7 +330,9 @@ static void lov_delete_raid0(const struct lu_env *env, struct lov_object *lov, struct lovsub_object *los = r0->lo_sub[i]; if (los) { - cl_object_prune(env, &los->lso_cl); + rc = cl_object_prune(env, &los->lso_cl); + if (rc) + return rc; /* * If top-level object is to be evicted from * the cache, so are its sub-objects. @@ -338,6 +341,8 @@ static void lov_delete_raid0(const struct lu_env *env, struct lov_object *lov, } } } + + return 0; } static void lov_fini_raid0(const struct lu_env *env, @@ -848,6 +853,7 @@ static int lov_delete_composite(const struct lu_env *env, union lov_layout_state *state) { struct lov_layout_entry *entry; + int rc; dump_lsm(D_INODE, lov->lo_lsm); @@ -856,7 +862,9 @@ static int lov_delete_composite(const struct lu_env *env, if (entry->lle_lsme && lsme_is_foreign(entry->lle_lsme)) continue; - lov_delete_raid0(env, lov, entry); + rc = lov_delete_raid0(env, lov, entry); + if (rc) + return rc; } return 0; @@ -1339,6 +1347,9 @@ static int lov_conf_set(const struct lu_env *env, struct cl_object *obj, { struct lov_stripe_md *lsm = NULL; struct lov_object *lov = cl2lov(obj); + struct cl_object *top = cl_object_top(obj); + bool unlock_inode = false; + bool lock_inode_size = false; int result = 0; if (conf->coc_opc == OBJECT_CONF_SET && @@ -1357,6 +1368,7 @@ static int lov_conf_set(const struct lu_env *env, struct cl_object *obj, goto out_lsm; } +retry: lov_conf_lock(lov); if (conf->coc_opc == OBJECT_CONF_WAIT) { if (test_bit(LO_LAYOUT_INVALID, &lov->lo_obj_flags) && @@ -1408,13 +1420,47 @@ static int lov_conf_set(const struct lu_env *env, struct cl_object *obj, } result = lov_layout_change(env, lov, lsm, conf); - if (result) + if (result) { + if (result == -EAGAIN) { + /** + * we need unlocked lov conf and get inode lock. + * It's possible we have already taken inode's size + * mutex, so we need keep such lock order, lest deadlock + * happens: + * inode lock (ll_inode_lock()) + * inode size lock (ll_inode_size_lock()) + * lov conf lock (lov_conf_lock()) + * + * e.g. + * vfs_setxattr inode locked + * ll_lov_setstripe_ea_info inode size locked + * ll_prep_inode + * ll_file_inode_init + * cl_conf_set + * lov_conf_set lov conf locked + */ + lov_conf_unlock(lov); + if (cl_object_inode_ops(env, top, COIO_SIZE_UNLOCK, + NULL) == 0) + lock_inode_size = true; + + /* take lock in order */ + if (cl_object_inode_ops(env, top, COIO_INODE_LOCK, + NULL) == 0) + unlock_inode = true; + if (lock_inode_size) + cl_object_inode_ops(env, top, COIO_SIZE_LOCK, + NULL); + goto retry; + } set_bit(LO_LAYOUT_INVALID, &lov->lo_obj_flags); - else + } else { clear_bit(LO_LAYOUT_INVALID, &lov->lo_obj_flags); - + } out: lov_conf_unlock(lov); + if (unlock_inode) + cl_object_inode_ops(env, top, COIO_INODE_UNLOCK, NULL); out_lsm: lov_lsm_put(lsm); CDEBUG(D_INODE, DFID " lo_layout_invalid=%u\n", diff --git a/fs/lustre/obdclass/cl_object.c b/fs/lustre/obdclass/cl_object.c index 28bf1e433c25..7c4a73590bed 100644 --- a/fs/lustre/obdclass/cl_object.c +++ b/fs/lustre/obdclass/cl_object.c @@ -409,6 +409,23 @@ int cl_object_flush(const struct lu_env *env, struct cl_object *obj, } EXPORT_SYMBOL(cl_object_flush); +int cl_object_inode_ops(const struct lu_env *env, struct cl_object *top, + enum coo_inode_opc opc, void *data) +{ + struct cl_object *obj; + int rc = 0; + + cl_object_for_each(obj, top) { + if (obj->co_ops->coo_inode_ops) { + rc = obj->co_ops->coo_inode_ops(env, obj, opc, data); + if (rc) + break; + } + } + return rc; +} +EXPORT_SYMBOL(cl_object_inode_ops); + /** * Helper function removing all object locks, and marking object for * deletion. All object pages must have been deleted at this point. From patchwork Fri Mar 21 13:06:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AFFA9C36000 for ; Fri, 21 Mar 2025 13:23:19 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2q72c21z20Vt; Fri, 21 Mar 2025 06:09:55 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2mR3v9Zz1xdq for ; Fri, 21 Mar 2025 06:07:35 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 6D62F17D18B; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 6C7A0106BE16; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:52 -0400 Message-ID: <20250321130711.3257092-10-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 09/27] lustre: llite: skip fast reads if layout is invalid X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Alex Zhuravlev don't let fast reads from the pagecache if the layout is not valid. WC-bug-id: https://jira.whamcloud.com/browse/LU-15431 Lustre-commit: fe2fafa1af7edc251 ("LU-15431 llite: skip fast reads if layout is invalid") Signed-off-by: Alex Zhuravlev Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/46282 Reviewed-by: Andreas Dilger Reviewed-by: Patrick Farrell Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c index 448aea7ceb12..c7f77295d3b3 100644 --- a/fs/lustre/llite/file.c +++ b/fs/lustre/llite/file.c @@ -1983,6 +1983,7 @@ ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args, static ssize_t ll_do_fast_read(struct kiocb *iocb, struct iov_iter *iter) { + struct ll_inode_info *lli = ll_i2info(file_inode(iocb->ki_filp)); ssize_t result; if (!ll_sbi_has_fast_read(ll_i2sbi(file_inode(iocb->ki_filp)))) @@ -1995,6 +1996,9 @@ ll_do_fast_read(struct kiocb *iocb, struct iov_iter *iter) if (iocb->ki_filp->f_flags & O_DIRECT) return 0; + if (ll_layout_version_get(lli) == CL_LAYOUT_GEN_NONE) + return 0; + result = generic_file_read_iter(iocb, iter); /* If the first page is not in cache, generic_file_aio_read() will be From patchwork Fri Mar 21 13:06:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 133DCC36001 for ; Fri, 21 Mar 2025 13:21:04 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2pk1YhMz1yCv; Fri, 21 Mar 2025 06:09:34 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2mq251rz1xp6 for ; Fri, 21 Mar 2025 06:07:55 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 724E888F9D8; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 70B74106BE18; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:53 -0400 Message-ID: <20250321130711.3257092-11-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 10/27] lustre: llite: Rename ldp_aio to sdio X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Patrick Farrell ldp_aio is a weird name for a 'sub dio' struct - rename it to sdio. WC-bug-id: https://jira.whamcloud.com/browse/LU-13805 Lustre-commit: 7c416273ad1a8f559 ("LU-13805 llite: Rename ldp_aio to sdio") Signed-off-by: Patrick Farrell Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50170 Reviewed-by: Qian Yingjin Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Signed-off-by: James Simmons --- fs/lustre/llite/rw26.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/lustre/llite/rw26.c b/fs/lustre/llite/rw26.c index 9239e029276e..5e9dcefa84f0 100644 --- a/fs/lustre/llite/rw26.c +++ b/fs/lustre/llite/rw26.c @@ -307,7 +307,7 @@ static ssize_t ll_direct_IO(struct kiocb *iocb, struct iov_iter *iter) struct file *file = iocb->ki_filp; struct inode *inode = file->f_mapping->host; struct cl_dio_aio *ll_dio_aio; - struct cl_sub_dio *ldp_aio; + struct cl_sub_dio *sdio; size_t count = iov_iter_count(iter); ssize_t tot_bytes = 0, result = 0; loff_t file_offset = iocb->ki_pos; @@ -378,21 +378,21 @@ static ssize_t ll_direct_IO(struct kiocb *iocb, struct iov_iter *iter) * otherwise it is freed on the final call to cl_sync_io_note * (either in this function or from a ptlrpcd daemon) */ - ldp_aio = cl_sub_dio_alloc(ll_dio_aio, sync_submit); - if (!ldp_aio) { + sdio = cl_sub_dio_alloc(ll_dio_aio, sync_submit); + if (!sdio) { result = -ENOMEM; goto out; } - pvec = &ldp_aio->csd_dio_pages; + pvec = &sdio->csd_dio_pages; result = ll_get_user_pages(rw, iter, &pages, &pvec->ldp_count, count); if (unlikely(result <= 0)) { - cl_sync_io_note(env, &ldp_aio->csd_sync, result); + cl_sync_io_note(env, &sdio->csd_sync, result); if (sync_submit) { - LASSERT(ldp_aio->csd_creator_free); - cl_sub_dio_free(ldp_aio); + LASSERT(sdio->csd_creator_free); + cl_sub_dio_free(sdio); } goto out; } @@ -402,19 +402,19 @@ static ssize_t ll_direct_IO(struct kiocb *iocb, struct iov_iter *iter) pvec->ldp_pages = pages; result = ll_direct_rw_pages(env, io, count, - rw, inode, ldp_aio); + rw, inode, sdio); /* We've submitted pages and can now remove the extra * reference for that */ - cl_sync_io_note(env, &ldp_aio->csd_sync, result); + cl_sync_io_note(env, &sdio->csd_sync, result); if (sync_submit) { - rc2 = cl_sync_io_wait(env, &ldp_aio->csd_sync, + rc2 = cl_sync_io_wait(env, &sdio->csd_sync, 0); if (result == 0 && rc2) result = rc2; - LASSERT(ldp_aio->csd_creator_free); - cl_sub_dio_free(ldp_aio); + LASSERT(sdio->csd_creator_free); + cl_sub_dio_free(sdio); } if (unlikely(result < 0)) goto out; From patchwork Fri Mar 21 13:06:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31134C36000 for ; Fri, 21 Mar 2025 13:18:33 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2nw3Wywz1xh4; Fri, 21 Mar 2025 06:08:52 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2mq19L5z1xp1 for ; Fri, 21 Mar 2025 06:07:55 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm4-e204-208.ccs.ornl.gov [160.91.203.22]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 7636D17B5A5; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 74805106BE14; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:54 -0400 Message-ID: <20250321130711.3257092-12-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 11/27] lnet: remove unused, fix non-static functions X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arshad Hussain , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Timothy Day lnet_net_is_pref_rtr_locked() is never called. This patch removes this function. Static analysis shows that a number of functions could be made static. This patch also declares several functions in lnet static. WC-bug-id: https://jira.whamcloud.com/browse/LU-8191 Lustre-commit: 43cbc93f1edc493e4 ("LU-8191 lnet: remove unused, fix non-static functions") Signed-off-by: Timothy Day Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51436 Reviewed-by: Neil Brown Reviewed-by: Arshad Hussain Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- net/lnet/klnds/o2iblnd/o2iblnd.c | 2 +- net/lnet/klnds/socklnd/socklnd.c | 2 +- net/lnet/lnet/api-ni.c | 31 ++++--------------------------- net/lnet/lnet/lib-move.c | 4 ++-- net/lnet/lnet/lib-msg.c | 4 ++-- net/lnet/lnet/module.c | 4 ++-- net/lnet/lnet/peer.c | 4 ++-- net/lnet/selftest/conctl.c | 2 +- 8 files changed, 15 insertions(+), 38 deletions(-) diff --git a/net/lnet/klnds/o2iblnd/o2iblnd.c b/net/lnet/klnds/o2iblnd/o2iblnd.c index c954df32ab50..b9d6b2477e2d 100644 --- a/net/lnet/klnds/o2iblnd/o2iblnd.c +++ b/net/lnet/klnds/o2iblnd/o2iblnd.c @@ -2390,7 +2390,7 @@ kiblnd_set_ni_fatal_on(struct kib_hca_dev *hdev, int val) lnet_update_ping_buffer(); } -void +static void kiblnd_event_handler(struct ib_event_handler *handler, struct ib_event *event) { rwlock_t *g_lock = &kiblnd_data.kib_global_lock; diff --git a/net/lnet/klnds/socklnd/socklnd.c b/net/lnet/klnds/socklnd/socklnd.c index d8fc20d18d44..2db7fc0b0e48 100644 --- a/net/lnet/klnds/socklnd/socklnd.c +++ b/net/lnet/klnds/socklnd/socklnd.c @@ -1655,7 +1655,7 @@ ksocknal_close_matching_conns(struct lnet_processid *id, u32 ipaddr) return count ? 0 : -ENOENT; } -void +static void ksocknal_notify_gw_down(struct lnet_nid *gw_nid) { /* The router is telling me she's been notified of a change in diff --git a/net/lnet/lnet/api-ni.c b/net/lnet/lnet/api-ni.c index d65ccb4e78aa..d87bc33b1103 100644 --- a/net/lnet/lnet/api-ni.c +++ b/net/lnet/lnet/api-ni.c @@ -1505,29 +1505,6 @@ __must_hold(&the_lnet.ln_api_mutex) return 0; } -bool -lnet_net_is_pref_rtr_locked(struct lnet_net *net, struct lnet_nid *rtr_nid) -{ - struct lnet_nid_list *ne; - - CDEBUG(D_NET, "%s: rtr pref empty: %d\n", - libcfs_net2str(net->net_id), - list_empty(&net->net_rtr_pref_nids)); - - if (list_empty(&net->net_rtr_pref_nids)) - return false; - - list_for_each_entry(ne, &net->net_rtr_pref_nids, nl_list) { - CDEBUG(D_NET, "Comparing pref %s with gw %s\n", - libcfs_nidstr(&ne->nl_nid), - libcfs_nidstr(rtr_nid)); - if (nid_same(rtr_nid, &ne->nl_nid)) - return true; - } - - return false; -} - static unsigned int lnet_nid4_cpt_hash(lnet_nid_t nid, unsigned int number) { @@ -3388,7 +3365,7 @@ lnet_get_net_config(struct lnet_ioctl_config_data *config) return rc; } -int +static int lnet_get_ni_config(struct lnet_ioctl_config_ni *cfg_ni, struct lnet_ioctl_config_lnd_tunables *tun, struct lnet_ioctl_element_stats *stats, @@ -3415,7 +3392,7 @@ lnet_get_ni_config(struct lnet_ioctl_config_ni *cfg_ni, return rc; } -int lnet_get_ni_stats(struct lnet_ioctl_element_msg_stats *msg_stats) +static int lnet_get_ni_stats(struct lnet_ioctl_element_msg_stats *msg_stats) { struct lnet_ni *ni; int cpt; @@ -5379,8 +5356,8 @@ static int lnet_route_show_done(struct netlink_callback *cb) return 0; } -int lnet_scan_route(struct lnet_genl_route_list *rlist, - struct lnet_route_properties *settings) +static int lnet_scan_route(struct lnet_genl_route_list *rlist, + struct lnet_route_properties *settings) { struct lnet_remotenet *rnet; struct list_head *rn_list; diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c index d9f5eb94ff6e..48b65aeb0bc1 100644 --- a/net/lnet/lnet/lib-move.c +++ b/net/lnet/lnet/lib-move.c @@ -1890,7 +1890,7 @@ lnet_handle_spec_local_mr_dst(struct lnet_send_data *sd) return -EHOSTUNREACH; } -struct lnet_ni * +static struct lnet_ni * lnet_find_best_ni_on_spec_net(struct lnet_ni *cur_best_ni, struct lnet_peer *peer, struct lnet_peer_net *peer_net, @@ -2248,7 +2248,7 @@ lnet_handle_spec_router_dst(struct lnet_send_data *sd) return lnet_handle_send(sd); } -struct lnet_ni * +static struct lnet_ni * lnet_find_best_ni_on_local_net(struct lnet_peer *peer, int md_cpt, struct lnet_msg *msg, bool discovery) { diff --git a/net/lnet/lnet/lib-msg.c b/net/lnet/lnet/lib-msg.c index 420236dfaf52..af2a295d8bf0 100644 --- a/net/lnet/lnet/lib-msg.c +++ b/net/lnet/lnet/lib-msg.c @@ -628,7 +628,7 @@ lnet_resend_msg_locked(struct lnet_msg *msg) complete(&the_lnet.ln_mt_wait_complete); } -int +static int lnet_check_finalize_recursion_locked(struct lnet_msg *msg, struct list_head *containerq, int nworkers, void **workers) @@ -654,7 +654,7 @@ lnet_check_finalize_recursion_locked(struct lnet_msg *msg, return my_slot; } -int +static int lnet_attempt_msg_resend(struct lnet_msg *msg) { struct lnet_msg_container *container; diff --git a/net/lnet/lnet/module.c b/net/lnet/lnet/module.c index 6e41e4b985cd..e6e34dcad90e 100644 --- a/net/lnet/lnet/module.c +++ b/net/lnet/lnet/module.c @@ -41,7 +41,7 @@ MODULE_PARM_DESC(config_on_load, "configure network at module load"); static DEFINE_MUTEX(lnet_config_mutex); -int lnet_configure(void *arg) +static int lnet_configure(void *arg) { /* 'arg' only there so I can be passed to cfs_create_thread() */ int rc = 0; @@ -67,7 +67,7 @@ int lnet_configure(void *arg) return rc; } -int lnet_unconfigure(void) +static int lnet_unconfigure(void) { int refcount; diff --git a/net/lnet/lnet/peer.c b/net/lnet/lnet/peer.c index 0aa4a77ab0d4..061afcf5e63e 100644 --- a/net/lnet/lnet/peer.c +++ b/net/lnet/lnet/peer.c @@ -1090,7 +1090,7 @@ lnet_peer_ni_set_non_mr_pref_nid(struct lnet_peer_ni *lpni, * Clear the preferred NID from a non-multi-rail peer_ni, provided * this preference was set by lnet_peer_ni_set_non_mr_pref_nid(). */ -int +static int lnet_peer_ni_clr_non_mr_pref_nid(struct lnet_peer_ni *lpni) { int rc = 0; @@ -1120,7 +1120,7 @@ lnet_peer_ni_set_selection_priority(struct lnet_peer_ni *lpni, u32 priority) /* * Clear the preferred NIDs from a non-multi-rail peer. */ -void +static void lnet_peer_clr_non_mr_pref_nids(struct lnet_peer *lp) { struct lnet_peer_ni *lpni = NULL; diff --git a/net/lnet/selftest/conctl.c b/net/lnet/selftest/conctl.c index f79368448d3e..9d3e3268731e 100644 --- a/net/lnet/selftest/conctl.c +++ b/net/lnet/selftest/conctl.c @@ -921,7 +921,7 @@ static char *lst_node_state2str(int state) return "Unknown"; } -int lst_node_str2state(char *str) +static int lst_node_str2state(char *str) { int state = 0; From patchwork Fri Mar 21 13:06:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EE51AC36001 for ; Fri, 21 Mar 2025 13:25:42 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2rB3Lddz20vC; Fri, 21 Mar 2025 06:10:50 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2n44VvBz1y1d for ; Fri, 21 Mar 2025 06:08:08 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm5-e204-208.ccs.ornl.gov [160.91.203.29]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 7B86788F9E9; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 7892D106BE16; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:55 -0400 Message-ID: <20250321130711.3257092-13-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 12/27] lustre: llite: convert functions to static X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arshad Hussain , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Timothy Day Static analysis shows that a number of functions could be made static. This patch declares several functions in llite static. Also, conserve more * in comments. WC-bug-id: https://jira.whamcloud.com/browse/LU-8191 Lustre-commit: a586a2bbc37879dc2 ("LU-8191 llite: convert functions to static") Signed-off-by: Timothy Day Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51441 Reviewed-by: Neil Brown Reviewed-by: Arshad Hussain Reviewed-by: jsimmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/dir.c | 2 +- fs/lustre/llite/file.c | 8 ++++---- fs/lustre/llite/llite_lib.c | 6 +++--- fs/lustre/llite/namei.c | 2 +- fs/lustre/llite/pcc.c | 6 +++--- fs/lustre/llite/rw.c | 2 +- fs/lustre/llite/vvp_dev.c | 10 ++-------- fs/lustre/llite/vvp_io.c | 2 +- 8 files changed, 16 insertions(+), 22 deletions(-) diff --git a/fs/lustre/llite/dir.c b/fs/lustre/llite/dir.c index a7a419abf45a..0c1b1ed31601 100644 --- a/fs/lustre/llite/dir.c +++ b/fs/lustre/llite/dir.c @@ -1346,7 +1346,7 @@ int quotactl_ioctl(struct super_block *sb, struct if_quotactl *qctl) return rc; } -int ll_rmfid(struct file *file, void __user *arg) +static int ll_rmfid(struct file *file, void __user *arg) { const struct fid_array __user *ufa = arg; struct inode *inode = file_inode(file); diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c index c7f77295d3b3..8564ee4a879c 100644 --- a/fs/lustre/llite/file.c +++ b/fs/lustre/llite/file.c @@ -4566,7 +4566,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return rc; } -loff_t ll_lseek(struct file *file, loff_t offset, int whence) +static loff_t ll_lseek(struct file *file, loff_t offset, int whence) { struct inode *inode = file_inode(file); struct lu_env *env; @@ -5496,8 +5496,8 @@ int ll_getattr(const struct path *path, struct kstat *stat, false); } -int cl_falloc(struct file *file, struct inode *inode, int mode, loff_t offset, - loff_t len) +static int cl_falloc(struct file *file, struct inode *inode, int mode, + loff_t offset, loff_t len) { loff_t size = i_size_read(inode); struct lu_env *env; @@ -5559,7 +5559,7 @@ int cl_falloc(struct file *file, struct inode *inode, int mode, loff_t offset, return rc; } -long ll_fallocate(struct file *filp, int mode, loff_t offset, loff_t len) +static long ll_fallocate(struct file *filp, int mode, loff_t offset, loff_t len) { struct inode *inode = file_inode(filp); int rc; diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c index 9adb7ef4ffac..b4d5b3dca0a7 100644 --- a/fs/lustre/llite/llite_lib.c +++ b/fs/lustre/llite/llite_lib.c @@ -1897,8 +1897,8 @@ static int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data) * Return: 0 on success * errno on failure */ -int ll_io_zero_page(struct inode *inode, pgoff_t index, pgoff_t offset, - unsigned int len) +static int ll_io_zero_page(struct inode *inode, pgoff_t index, pgoff_t offset, + unsigned int len) { struct ll_inode_info *lli = ll_i2info(inode); struct cl_object *clob = lli->lli_clob; @@ -2753,7 +2753,7 @@ static inline bool ll_default_lmv_inherited(struct lmv_stripe_md *pdmv, /* if default LMV is implicitly inherited, subdir default LMV is maintained on * client side. */ -int ll_dir_default_lmv_inherit(struct inode *dir, struct inode *inode) +static int ll_dir_default_lmv_inherit(struct inode *dir, struct inode *inode) { struct ll_inode_info *plli = ll_i2info(dir); struct ll_inode_info *lli = ll_i2info(inode); diff --git a/fs/lustre/llite/namei.c b/fs/lustre/llite/namei.c index 6159f8975847..79df426fcbbb 100644 --- a/fs/lustre/llite/namei.c +++ b/fs/lustre/llite/namei.c @@ -384,7 +384,7 @@ static void ll_lock_cancel_bits(struct ldlm_lock *lock, u64 to_cancel) /* Check if the given lock may be downgraded instead of canceling and * that convert is really needed. */ -int ll_md_need_convert(struct ldlm_lock *lock) +static int ll_md_need_convert(struct ldlm_lock *lock) { struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); struct inode *inode; diff --git a/fs/lustre/llite/pcc.c b/fs/lustre/llite/pcc.c index ac9124f9554e..677f5f38f100 100644 --- a/fs/lustre/llite/pcc.c +++ b/fs/lustre/llite/pcc.c @@ -795,7 +795,7 @@ pcc_dataset_add(struct pcc_super *super, struct pcc_cmd *cmd) return rc; } -struct pcc_dataset * +static struct pcc_dataset * pcc_dataset_get(struct pcc_super *super, enum lu_pcc_type type, u32 id) { struct pcc_dataset *dataset; @@ -2152,8 +2152,8 @@ static int __pcc_inode_create(struct pcc_dataset *dataset, * Reset uid, gid or size for the PCC copy masked by @valid. * TODO: Set the project ID for PCC copy. */ -int pcc_inode_reset_iattr(struct dentry *dentry, unsigned int valid, - kuid_t uid, kgid_t gid, loff_t size) +static int pcc_inode_reset_iattr(struct dentry *dentry, unsigned int valid, + kuid_t uid, kgid_t gid, loff_t size) { struct inode *inode = dentry->d_inode; struct iattr attr; diff --git a/fs/lustre/llite/rw.c b/fs/lustre/llite/rw.c index e258d995c54b..04fde756035f 100644 --- a/fs/lustre/llite/rw.c +++ b/fs/lustre/llite/rw.c @@ -150,7 +150,7 @@ void ll_ra_stats_inc(struct inode *inode, enum ra_stat which) ll_ra_stats_inc_sbi(sbi, which); } -void ll_ra_stats_add(struct inode *inode, enum ra_stat which, long count) +static void ll_ra_stats_add(struct inode *inode, enum ra_stat which, long count) { struct ll_sb_info *sbi = ll_i2sbi(inode); diff --git a/fs/lustre/llite/vvp_dev.c b/fs/lustre/llite/vvp_dev.c index 298720c5bfc2..0864ac499c4e 100644 --- a/fs/lustre/llite/vvp_dev.c +++ b/fs/lustre/llite/vvp_dev.c @@ -42,13 +42,9 @@ #include "llite_internal.h" #include "vvp_internal.h" -/***************************************************************************** - * +/* * Vvp device and device type functions. * - */ - -/* * vvp_ prefix stands for "Vfs Vm Posix". It corresponds to historical * "llite_" (var. "ll_") prefix. */ @@ -297,10 +293,8 @@ void vvp_global_fini(void) lu_kmem_fini(vvp_caches); } -/***************************************************************************** - * +/* * mirror obd-devices into cl devices. - * */ int cl_sb_init(struct super_block *sb) diff --git a/fs/lustre/llite/vvp_io.c b/fs/lustre/llite/vvp_io.c index acc9c2935485..1eb254b2a687 100644 --- a/fs/lustre/llite/vvp_io.c +++ b/fs/lustre/llite/vvp_io.c @@ -974,7 +974,7 @@ static int vvp_io_commit_sync(const struct lu_env *env, struct cl_io *io, * v5.2-rc4-224-ge01e060fe0 * */ -void vvp_set_pagevec_dirty(struct pagevec *pvec) +static void vvp_set_pagevec_dirty(struct pagevec *pvec) { struct page *page = pvec->pages[0]; struct address_space *mapping = page->mapping; From patchwork Fri Mar 21 13:06:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025444 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8876AC36001 for ; Fri, 21 Mar 2025 13:23:20 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2q75yDhz20Vv; Fri, 21 Mar 2025 06:09:55 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2n45Y2Wz1y1k for ; Fri, 21 Mar 2025 06:08:08 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 7E13117B5A6; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 7C1C7106BE17; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:56 -0400 Message-ID: <20250321130711.3257092-14-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 13/27] lustre: convert ec, ldlm functions to static X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arshad Hussain , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Timothy Day Static analysis shows that a number of functions could be made static. This patch declares several functions in ec, and ldlm static. WC-bug-id: https://jira.whamcloud.com/browse/LU-8191 Lustre-commit: bcc828bdf88f8a19e ("LU-8191 lustre: convert ec,fid,ldlm,quota functions to static") Signed-off-by: Timothy Day Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51476 Reviewed-by: Neil Brown Reviewed-by: Arshad Hussain Reviewed-by: jsimmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/ec/ec_base.c | 4 ++-- fs/lustre/ldlm/ldlm_request.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/lustre/ec/ec_base.c b/fs/lustre/ec/ec_base.c index e5204668eea1..4241659d28de 100644 --- a/fs/lustre/ec/ec_base.c +++ b/fs/lustre/ec/ec_base.c @@ -106,7 +106,7 @@ void ec_init_tables(int k, int rows, unsigned char *a, unsigned char *g_tbls) } EXPORT_SYMBOL(ec_init_tables); -unsigned char gf_mul(unsigned char a, unsigned char b) +static unsigned char gf_mul(unsigned char a, unsigned char b) { int i; @@ -117,7 +117,7 @@ unsigned char gf_mul(unsigned char a, unsigned char b) return gff_base[i > 254 ? i - 255 : i]; } -unsigned char gf_inv(unsigned char a) +static unsigned char gf_inv(unsigned char a) { if (a == 0) return 0; diff --git a/fs/lustre/ldlm/ldlm_request.c b/fs/lustre/ldlm/ldlm_request.c index bccce8b8e5e8..127f5777a5a3 100644 --- a/fs/lustre/ldlm/ldlm_request.c +++ b/fs/lustre/ldlm/ldlm_request.c @@ -2355,7 +2355,7 @@ static int lock_can_replay(struct obd_import *imp) 1 + min_t(u32, cli->cl_max_rpcs_in_flight, 8); } -int __ldlm_replay_locks(struct obd_import *imp, bool rate_limit) +static int __ldlm_replay_locks(struct obd_import *imp, bool rate_limit) { struct ldlm_namespace *ns = imp->imp_obd->obd_namespace; LIST_HEAD(list); From patchwork Fri Mar 21 13:06:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8654EC36000 for ; Fri, 21 Mar 2025 13:28:01 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2rb5qLpz20wG; Fri, 21 Mar 2025 06:11:11 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2n93mmHz1y1x for ; Fri, 21 Mar 2025 06:08:13 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 8223C88F9EB; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 7FBAB106BE18; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:57 -0400 Message-ID: <20250321130711.3257092-15-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 14/27] lustre: osc: convert more functions to static X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arshad Hussain , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Timothy Day Static analysis shows that a number of functions could be made static. This patch declares several functions in osc as static. Also, fix a few minor style issues. WC-bug-id: https://jira.whamcloud.com/browse/LU-8191 Lustre-commit: 2fa075d10f72f1400 ("U-8191 lustre: convert osp,osd,osc,ofd functions to static") Signed-off-by: Timothy Day Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51477 Reviewed-by: Neil Brown Reviewed-by: Arshad Hussain Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/osc/lproc_osc.c | 9 +++------ fs/lustre/osc/osc_io.c | 4 ++-- fs/lustre/osc/osc_request.c | 14 ++++++++------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/fs/lustre/osc/lproc_osc.c b/fs/lustre/osc/lproc_osc.c index d3131ee7eef1..2e2cec9db148 100644 --- a/fs/lustre/osc/lproc_osc.c +++ b/fs/lustre/osc/lproc_osc.c @@ -840,7 +840,7 @@ static ssize_t osc_stats_seq_write(struct file *file, LDEBUGFS_SEQ_FOPS(osc_stats); -void lproc_osc_attach_seqstat(struct obd_device *obd) +static void ldebugfs_osc_attach_seqstat(struct obd_device *obd) { debugfs_create_file("osc_stats", 0644, obd->obd_debugfs_entry, obd, &osc_stats_fops); @@ -884,17 +884,14 @@ int osc_tunables_init(struct obd_device *obd) if (rc) return rc; + ldebugfs_osc_attach_seqstat(obd); + rc = sptlrpc_lprocfs_cliobd_attach(obd); if (rc) { lprocfs_obd_cleanup(obd); return rc; } - debugfs_create_file("osc_stats", 0644, obd->obd_debugfs_entry, obd, - &osc_stats_fops); - debugfs_create_file("rpc_stats", 0644, obd->obd_debugfs_entry, obd, - &osc_rpc_stats_fops); - ptlrpc_lprocfs_register_obd(obd); return 0; } diff --git a/fs/lustre/osc/osc_io.c b/fs/lustre/osc/osc_io.c index 900edf8b9a41..5b4abb1cb625 100644 --- a/fs/lustre/osc/osc_io.c +++ b/fs/lustre/osc/osc_io.c @@ -937,8 +937,8 @@ int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, } EXPORT_SYMBOL(osc_fsync_ost); -int osc_io_fsync_start(const struct lu_env *env, - const struct cl_io_slice *slice) +static int osc_io_fsync_start(const struct lu_env *env, + const struct cl_io_slice *slice) { struct cl_io *io = slice->cis_io; struct cl_fsync_io *fio = &io->u.ci_fsync; diff --git a/fs/lustre/osc/osc_request.c b/fs/lustre/osc/osc_request.c index 5c9f93b91609..4a739b1858e5 100644 --- a/fs/lustre/osc/osc_request.c +++ b/fs/lustre/osc/osc_request.c @@ -2927,10 +2927,11 @@ static int osc_set_lock_data(struct ldlm_lock *lock, void *data) return set; } -int osc_enqueue_fini(struct ptlrpc_request *req, osc_enqueue_upcall_f upcall, - void *cookie, struct lustre_handle *lockh, - enum ldlm_mode mode, u64 *flags, int speculative, - int errcode) +static int osc_enqueue_fini(struct ptlrpc_request *req, + osc_enqueue_upcall_f upcall, + void *cookie, struct lustre_handle *lockh, + enum ldlm_mode mode, u64 *flags, + int speculative, int errcode) { bool intent = *flags & LDLM_FL_HAS_INTENT; int rc; @@ -2962,8 +2963,9 @@ int osc_enqueue_fini(struct ptlrpc_request *req, osc_enqueue_upcall_f upcall, return rc; } -int osc_enqueue_interpret(const struct lu_env *env, struct ptlrpc_request *req, - void *args, int rc) +static int osc_enqueue_interpret(const struct lu_env *env, + struct ptlrpc_request *req, + void *args, int rc) { struct osc_enqueue_args *aa = args; struct ldlm_lock *lock; From patchwork Fri Mar 21 13:06:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025452 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26BBFC36000 for ; Fri, 21 Mar 2025 13:31:29 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2sV5fHjz1xsl; Fri, 21 Mar 2025 06:11:58 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2nB6n5Bz1xf1 for ; Fri, 21 Mar 2025 06:08:14 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm4-e204-208.ccs.ornl.gov [160.91.203.22]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 845D317B5A7; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 836EC106BE14; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:58 -0400 Message-ID: <20250321130711.3257092-16-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 15/27] lustre: convert mdc, mgc functions to static X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arshad Hussain , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Timothy Day Static analysis shows that a number of functions could be made static. This patch declares several functions in mdc, and mgc static. Also, remove mgs_client_add() since it was unused, and move a declaration from a c-file to the proper header file. WC-bug-id: https://jira.whamcloud.com/browse/LU-8191 Lustre-commit: 38d151f2f65d76fc3 ("LU-8191 lustre: convert mdc,mdd,mdt,mgc functions to static") Signed-off-by: Timothy Day Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51478 Reviewed-by: Neil Brown Reviewed-by: Arshad Hussain Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/mdc/mdc_dev.c | 67 +++++++++++++++++++------------------ fs/lustre/mdc/mdc_request.c | 5 +-- fs/lustre/mgc/lproc_mgc.c | 8 ++--- 3 files changed, 42 insertions(+), 38 deletions(-) diff --git a/fs/lustre/mdc/mdc_dev.c b/fs/lustre/mdc/mdc_dev.c index eccd9819ca56..672015546f3a 100644 --- a/fs/lustre/mdc/mdc_dev.c +++ b/fs/lustre/mdc/mdc_dev.c @@ -93,12 +93,13 @@ static int mdc_set_dom_lock_data(struct ldlm_lock *lock, void *data) return set; } -int mdc_dom_lock_match(const struct lu_env *env, struct obd_export *exp, - struct ldlm_res_id *res_id, enum ldlm_type type, - union ldlm_policy_data *policy, enum ldlm_mode mode, - u64 *flags, struct osc_object *obj, - struct lustre_handle *lockh, - enum ldlm_match_flags match_flags) +static int mdc_dom_lock_match(const struct lu_env *env, struct obd_export *exp, + struct ldlm_res_id *res_id, enum ldlm_type type, + union ldlm_policy_data *policy, + enum ldlm_mode mode, u64 *flags, + struct osc_object *obj, + struct lustre_handle *lockh, + enum ldlm_match_flags match_flags) { struct obd_device *obd = exp->exp_obd; u64 lflags = *flags; @@ -135,9 +136,10 @@ int mdc_dom_lock_match(const struct lu_env *env, struct obd_export *exp, * Finds an existing lock covering a page with given index. * Copy of osc_obj_dlmlock_at_pgoff() but for DoM IBITS lock. */ -struct ldlm_lock *mdc_dlmlock_at_pgoff(const struct lu_env *env, - struct osc_object *obj, pgoff_t index, - enum osc_dap_flags dap_flags) +static struct ldlm_lock *mdc_dlmlock_at_pgoff(const struct lu_env *env, + struct osc_object *obj, + pgoff_t index, + enum osc_dap_flags dap_flags) { struct osc_thread_info *info = osc_env_info(env); struct ldlm_res_id *resname = &info->oti_resname; @@ -278,8 +280,8 @@ static int mdc_lock_flush(const struct lu_env *env, struct osc_object *obj, return result; } -void mdc_lock_lockless_cancel(const struct lu_env *env, - const struct cl_lock_slice *slice) +static void mdc_lock_lockless_cancel(const struct lu_env *env, + const struct cl_lock_slice *slice) { struct osc_lock *ols = cl2osc_lock(slice); struct osc_object *osc = cl2osc(slice->cls_obj); @@ -570,10 +572,10 @@ int mdc_fill_lvb(struct req_capsule *pill, struct ost_lvb *lvb) return 0; } -int mdc_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, - osc_enqueue_upcall_f upcall, void *cookie, - struct lustre_handle *lockh, enum ldlm_mode mode, - u64 *flags, int errcode) +static int mdc_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, + osc_enqueue_upcall_f upcall, void *cookie, + struct lustre_handle *lockh, enum ldlm_mode mode, + u64 *flags, int errcode) { struct osc_lock *ols = cookie; bool glimpse = *flags & LDLM_FL_HAS_INTENT; @@ -627,8 +629,9 @@ int mdc_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, return rc; } -int mdc_enqueue_interpret(const struct lu_env *env, struct ptlrpc_request *req, - void *args, int rc) +static int mdc_enqueue_interpret(const struct lu_env *env, + struct ptlrpc_request *req, + void *args, int rc) { struct osc_enqueue_args *aa = args; struct ldlm_lock *lock; @@ -685,11 +688,11 @@ int mdc_enqueue_interpret(const struct lu_env *env, struct ptlrpc_request *req, * is excluded from the cluster -- such scenarious make the life difficult, so * release locks just after they are obtained. */ -int mdc_enqueue_send(const struct lu_env *env, struct obd_export *exp, - struct ldlm_res_id *res_id, u64 *flags, - union ldlm_policy_data *policy, struct ost_lvb *lvb, - osc_enqueue_upcall_f upcall, void *cookie, - struct ldlm_enqueue_info *einfo, int async) +static int mdc_enqueue_send(const struct lu_env *env, struct obd_export *exp, + struct ldlm_res_id *res_id, u64 *flags, + union ldlm_policy_data *policy, struct ost_lvb *lvb, + osc_enqueue_upcall_f upcall, void *cookie, + struct ldlm_enqueue_info *einfo, int async) { struct obd_device *obd = exp->exp_obd; struct lustre_handle lockh = { 0 }; @@ -930,8 +933,8 @@ static const struct cl_lock_operations mdc_lock_ops = { .clo_print = osc_lock_print, }; -int mdc_lock_init(const struct lu_env *env, struct cl_object *obj, - struct cl_lock *lock, const struct cl_io *io) +static int mdc_lock_init(const struct lu_env *env, struct cl_object *obj, + struct cl_lock *lock, const struct cl_io *io) { struct osc_lock *ols; u32 enqflags = lock->cll_descr.cld_enq_flags; @@ -1150,8 +1153,8 @@ static int mdc_io_read_ahead(const struct lu_env *env, return 0; } -int mdc_io_fsync_start(const struct lu_env *env, - const struct cl_io_slice *slice) +static int mdc_io_fsync_start(const struct lu_env *env, + const struct cl_io_slice *slice) { struct cl_io *io = slice->cis_io; struct cl_fsync_io *fio = &io->u.ci_fsync; @@ -1345,8 +1348,8 @@ static const struct cl_io_operations mdc_io_ops = { .cio_extent_release = osc_io_extent_release, }; -int mdc_io_init(const struct lu_env *env, struct cl_object *obj, - struct cl_io *io) +static int mdc_io_init(const struct lu_env *env, struct cl_object *obj, + struct cl_io *io) { struct osc_io *oio = osc_env_io(env); @@ -1445,7 +1448,7 @@ static int mdc_object_ast_clear(struct ldlm_lock *lock, void *data) return LDLM_ITER_CONTINUE; } -int mdc_object_prune(const struct lu_env *env, struct cl_object *obj) +static int mdc_object_prune(const struct lu_env *env, struct cl_object *obj) { struct osc_object *osc = cl2osc(obj); struct ldlm_res_id *resname = &osc_env_info(env)->oti_resname; @@ -1514,9 +1517,9 @@ static const struct lu_object_operations mdc_lu_obj_ops = { .loo_object_invariant = NULL }; -struct lu_object *mdc_object_alloc(const struct lu_env *env, - const struct lu_object_header *unused, - struct lu_device *dev) +static struct lu_object *mdc_object_alloc(const struct lu_env *env, + const struct lu_object_header *unused, + struct lu_device *dev) { struct osc_object *osc; struct lu_object *obj; diff --git a/fs/lustre/mdc/mdc_request.c b/fs/lustre/mdc/mdc_request.c index b9b962c6f723..ad625fbbd666 100644 --- a/fs/lustre/mdc/mdc_request.c +++ b/fs/lustre/mdc/mdc_request.c @@ -2660,8 +2660,9 @@ struct mdc_rmfid_args { int mra_nr; }; -int mdc_rmfid_interpret(const struct lu_env *env, struct ptlrpc_request *req, - void *args, int rc) +static int mdc_rmfid_interpret(const struct lu_env *env, + struct ptlrpc_request *req, + void *args, int rc) { struct mdc_rmfid_args *aa; int *rcs, size; diff --git a/fs/lustre/mgc/lproc_mgc.c b/fs/lustre/mgc/lproc_mgc.c index 6a945c5b9b93..7bda1e289eb5 100644 --- a/fs/lustre/mgc/lproc_mgc.c +++ b/fs/lustre/mgc/lproc_mgc.c @@ -70,8 +70,8 @@ LUSTRE_RO_ATTR(conn_uuid); LUSTRE_RW_ATTR(ping); -ssize_t dynamic_nids_show(struct kobject *kobj, struct attribute *attr, - char *buf) +static ssize_t dynamic_nids_show(struct kobject *kobj, struct attribute *attr, + char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); @@ -79,8 +79,8 @@ ssize_t dynamic_nids_show(struct kobject *kobj, struct attribute *attr, return scnprintf(buf, PAGE_SIZE, "%u\n", obd->obd_dynamic_nids); } -ssize_t dynamic_nids_store(struct kobject *kobj, struct attribute *attr, - const char *buffer, size_t count) +static ssize_t dynamic_nids_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); From patchwork Fri Mar 21 13:06:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025446 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BB97C36007 for ; Fri, 21 Mar 2025 13:25:44 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2rF0ZQTz20vF; Fri, 21 Mar 2025 06:10:53 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2nC30zYz1xdl for ; Fri, 21 Mar 2025 06:08:15 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm5-e204-208.ccs.ornl.gov [160.91.203.29]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 8864A88F9FA; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 86F9D106BE19; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:06:59 -0400 Message-ID: <20250321130711.3257092-17-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 16/27] lustre: ptlrpc: add missing header X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arshad Hussain , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Timothy Day Missing headers for layout.c in ptlrpc cause functions to be incorrectly marked as only being used within layout.c. This patch adds the missing header. WC-bug-id: https://jira.whamcloud.com/browse/LU-8181 Lustre-commit: fba78a416621343aa ("LU-8191 ptlrpc: add missing headers") Signed-off-by: Timothy Day Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51480 Reviewed-by: Neil Brown Reviewed-by: Arshad Hussain Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/ptlrpc/layout.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/lustre/ptlrpc/layout.c b/fs/lustre/ptlrpc/layout.c index 64e0224ce496..263a926d1e02 100644 --- a/fs/lustre/ptlrpc/layout.c +++ b/fs/lustre/ptlrpc/layout.c @@ -58,6 +58,8 @@ #include #include +#include "ptlrpc_internal.h" + /* * RQFs (see below) refer to two struct req_msg_field arrays describing the * client request and server reply, respectively. From patchwork Fri Mar 21 13:07:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025450 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CBF1CC36000 for ; Fri, 21 Mar 2025 13:27:26 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2rf6XmYz1xs6; Fri, 21 Mar 2025 06:11:14 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2nN3Lhzz1y4G for ; Fri, 21 Mar 2025 06:08:24 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 8C27D17B5A8; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 8AA95106BE16; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:07:00 -0400 Message-ID: <20250321130711.3257092-18-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 17/27] lustre: client: use EOPNOTSUPP instead of ENOTSUPP X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Andreas Dilger Don't return NFS-specific error code ENOTSUPP back to userspace, instead use EOPNOTSUPP. ENOTSUPP does not print a useful error message from strerror() if it is hit by an application. WC-bug-id: https://jira.whamcloud.com/browse/LU-14301 Lustre-commit: ffd2fc1e17822c013 ("LU-14301 client: use EOPNOTSUPP instead of ENOTSUPP") Signed-off-by: Andreas Dilger Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51511 Reviewed-by: Oleg Drokin Reviewed-by: Neil Brown Reviewed-by: James Simmons Signed-off-by: James Simmons --- fs/lustre/llite/dir.c | 4 ++-- fs/lustre/llite/lcommon_misc.c | 2 +- fs/lustre/llite/lproc_llite.c | 2 +- fs/lustre/lov/lov_object.c | 4 ++-- fs/lustre/mdc/lproc_mdc.c | 2 +- fs/lustre/mdc/mdc_dev.c | 2 +- fs/lustre/mdc/mdc_request.c | 2 +- fs/lustre/osc/lproc_osc.c | 2 +- fs/lustre/osc/osc_io.c | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/lustre/llite/dir.c b/fs/lustre/llite/dir.c index 0c1b1ed31601..b628e11e759c 100644 --- a/fs/lustre/llite/dir.c +++ b/fs/lustre/llite/dir.c @@ -1232,7 +1232,7 @@ int quotactl_ioctl(struct super_block *sb, struct if_quotactl *qctl) default: CERROR("%s: unsupported quotactl op: %#x: rc = %d\n", sbi->ll_fsname, cmd, -EOPNOTSUPP); - return -ENOTSUPP; + return -EOPNOTSUPP; } if (valid != QC_GENERAL) { @@ -1670,7 +1670,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case LOV_USER_MAGIC_V1: break; default: - rc = -ENOTSUPP; + rc = -EOPNOTSUPP; goto out; } diff --git a/fs/lustre/llite/lcommon_misc.c b/fs/lustre/llite/lcommon_misc.c index 3b0c0f4a39f1..add1601510c7 100644 --- a/fs/lustre/llite/lcommon_misc.c +++ b/fs/lustre/llite/lcommon_misc.c @@ -140,7 +140,7 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, cl_env_put(env, &refcheck); /* Does not make sense to take GL for released layout */ if (rc > 0) - rc = -ENOTSUPP; + rc = -EOPNOTSUPP; return rc; } diff --git a/fs/lustre/llite/lproc_llite.c b/fs/lustre/llite/lproc_llite.c index 4ea0bb2cbbaa..189dc31d4152 100644 --- a/fs/lustre/llite/lproc_llite.c +++ b/fs/lustre/llite/lproc_llite.c @@ -1087,7 +1087,7 @@ static ssize_t xattr_cache_store(struct kobject *kobj, return rc; if (val && !test_bit(LL_SBI_XATTR_CACHE, sbi->ll_flags)) - return -ENOTSUPP; + return -EOPNOTSUPP; sbi->ll_xattr_cache_enabled = val; sbi->ll_xattr_cache_set = 1; diff --git a/fs/lustre/lov/lov_object.c b/fs/lustre/lov/lov_object.c index 27f005c807fe..e9c3ace52bab 100644 --- a/fs/lustre/lov/lov_object.c +++ b/fs/lustre/lov/lov_object.c @@ -1980,14 +1980,14 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj, if (lsm->lsm_entry_count > 1 || (lsm->lsm_entry_count == 1 && lsm->lsm_entries[0]->lsme_stripe_count > 1)) { - rc = -ENOTSUPP; + rc = -EOPNOTSUPP; goto out_lsm; } } /* No support for DOM layout yet. */ if (lsme_is_dom(lsm->lsm_entries[0])) { - rc = -ENOTSUPP; + rc = -EOPNOTSUPP; goto out_lsm; } diff --git a/fs/lustre/mdc/lproc_mdc.c b/fs/lustre/mdc/lproc_mdc.c index d8dded8ed8a6..53beafb845e4 100644 --- a/fs/lustre/mdc/lproc_mdc.c +++ b/fs/lustre/mdc/lproc_mdc.c @@ -140,7 +140,7 @@ static ssize_t mdc_checksum_type_seq_write(struct file *file, obd->u.cli.cl_cksum_type = BIT(i); rc = count; } else { - rc = -ENOTSUPP; + rc = -EOPNOTSUPP; } break; } diff --git a/fs/lustre/mdc/mdc_dev.c b/fs/lustre/mdc/mdc_dev.c index 672015546f3a..1c993fd3cd7f 100644 --- a/fs/lustre/mdc/mdc_dev.c +++ b/fs/lustre/mdc/mdc_dev.c @@ -1294,7 +1294,7 @@ static void mdc_io_data_version_end(const struct lu_env *env, slice->cis_io->ci_result = 0; if (!(oio->oi_oa.o_valid & (OBD_MD_LAYOUT_VERSION | OBD_MD_FLDATAVERSION))) - slice->cis_io->ci_result = -ENOTSUPP; + slice->cis_io->ci_result = -EOPNOTSUPP; if (oio->oi_oa.o_valid & OBD_MD_LAYOUT_VERSION) dv->dv_layout_version = oio->oi_oa.o_layout_version; diff --git a/fs/lustre/mdc/mdc_request.c b/fs/lustre/mdc/mdc_request.c index ad625fbbd666..d0f51b2e0051 100644 --- a/fs/lustre/mdc/mdc_request.c +++ b/fs/lustre/mdc/mdc_request.c @@ -102,7 +102,7 @@ static int mdc_get_root(struct obd_export *exp, const char *fileset, int rc; if (fileset && !(exp_connect_flags(exp) & OBD_CONNECT_SUBTREE)) - return -ENOTSUPP; + return -EOPNOTSUPP; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GET_ROOT); diff --git a/fs/lustre/osc/lproc_osc.c b/fs/lustre/osc/lproc_osc.c index 2e2cec9db148..9d20555d80d3 100644 --- a/fs/lustre/osc/lproc_osc.c +++ b/fs/lustre/osc/lproc_osc.c @@ -438,7 +438,7 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, obd->u.cli.cl_cksum_type = BIT(i); rc = count; } else { - rc = -ENOTSUPP; + rc = -EOPNOTSUPP; } break; } diff --git a/fs/lustre/osc/osc_io.c b/fs/lustre/osc/osc_io.c index 5b4abb1cb625..f97808f56138 100644 --- a/fs/lustre/osc/osc_io.c +++ b/fs/lustre/osc/osc_io.c @@ -850,7 +850,7 @@ static void osc_io_data_version_end(const struct lu_env *env, slice->cis_io->ci_result = 0; if (!(oa->o_valid & (OBD_MD_LAYOUT_VERSION | OBD_MD_FLDATAVERSION))) - slice->cis_io->ci_result = -ENOTSUPP; + slice->cis_io->ci_result = -EOPNOTSUPP; if (oa->o_valid & OBD_MD_LAYOUT_VERSION) dv->dv_layout_version = oa->o_layout_version; From patchwork Fri Mar 21 13:07:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025455 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0136C36000 for ; Fri, 21 Mar 2025 13:34:18 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2tT4ksXz20yK; Fri, 21 Mar 2025 06:12:49 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2nN3mK4z1xdv for ; Fri, 21 Mar 2025 06:08:24 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 91FE2891205; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 8F3CE106BE17; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:07:01 -0400 Message-ID: <20250321130711.3257092-19-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 18/27] lustre: fld: use list_first/last_entry() for list heads X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arshad Hussain , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mr NeilBrown This patch changes list_entry(foo.next, ...) to list_first_entry(&foo, ...) in cases where 'foo' is a list head - not a list member. WC-bug-id: https://jira.whamcloud.com/browse/LU-6142 Lustre-commit: 94b72e3478d73133c ("LU-6142 lustre: use list_first/last_entry() for list heads") Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50828 Reviewed-by: Arshad Hussain Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/fld/fld_request.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/lustre/fld/fld_request.c b/fs/lustre/fld/fld_request.c index 0fe8cef6e945..eb9f43cf8fe1 100644 --- a/fs/lustre/fld/fld_request.c +++ b/fs/lustre/fld/fld_request.c @@ -447,7 +447,7 @@ int fld_client_lookup(struct lu_client_fld *fld, u64 seq, u32 *mds, target = list_entry(fld->lcf_targets.next, struct lu_fld_target, ft_chain); else - target = list_entry(target->ft_chain.next, + target = list_first_entry(&target->ft_chain, struct lu_fld_target, ft_chain); spin_unlock(&fld->lcf_lock); From patchwork Fri Mar 21 13:07:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025454 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3DF3C36001 for ; Fri, 21 Mar 2025 13:33:27 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2t35bzSz20y0; Fri, 21 Mar 2025 06:12:27 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2nW0DtQz1y66 for ; Fri, 21 Mar 2025 06:08:30 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm4-e204-208.ccs.ornl.gov [160.91.203.22]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 967B017B5A9; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 934A7106BE14; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:07:02 -0400 Message-ID: <20250321130711.3257092-20-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 19/27] lnet: libcfs: move ioctl device to lnet X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Horn , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mr NeilBrown The misc device "/dev/lnet" is currently managed in libcfs code, despite that fact that it is named "lnet" and almost all ioctl handlers are in lnet code. So move the management of the device to lnet code, leaving just the minimal amount in libcfs: case IOC_LIBCFS_CLEAR_DEBUG: case IOC_LIBCFS_MARK_DEBUG: Also rename various parts of the interface from libcfs_ioctl* to lnet_ioctl*. ioctl names, data structures, and include files are left unchanged for now. Note that the return value from LNetCtl() was previously passed through notifier_from_errno() and notifier_to_errno(). This had the effect of turning any positive value to zero. We need to preserve that and not return positive results. PING would return a positive result. lnd->lnd_ctl probably doesn't, but due to the difficulty of auditing, it is safer to always force the result to non-positive. WC-bug-id: https://jira.whamcloud.com/browse/LU-9859 Lustre-commit: 2d4d7febb124686d4 ("LU-9859 lnet: move ioctl device to lnet") Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50833 Reviewed-by: Chris Horn Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- include/linux/libcfs/libcfs.h | 12 +- include/linux/lnet/lib-lnet.h | 9 + include/uapi/linux/lnet/libcfs_ioctl.h | 10 +- net/lnet/libcfs/module.c | 232 +------------------------ net/lnet/lnet/api-ni.c | 3 +- net/lnet/lnet/module.c | 220 +++++++++++++++++++++-- net/lnet/selftest/console.c | 4 +- 7 files changed, 228 insertions(+), 262 deletions(-) diff --git a/include/linux/libcfs/libcfs.h b/include/linux/libcfs/libcfs.h index e29b007946ff..2490ee811d33 100644 --- a/include/linux/libcfs/libcfs.h +++ b/include/linux/libcfs/libcfs.h @@ -33,10 +33,9 @@ #ifndef __LIBCFS_LIBCFS_H__ #define __LIBCFS_LIBCFS_H__ -#include #include -#include +#include #include #include #include @@ -45,15 +44,8 @@ typedef s32 timeout_t; -extern struct blocking_notifier_head libcfs_ioctl_list; -static inline int notifier_from_ioctl_errno(int err) -{ - if (err == -EINVAL) - return NOTIFY_OK; - return notifier_from_errno(err) | NOTIFY_STOP_MASK; -} - int libcfs_setup(void); +int libcfs_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data); extern struct workqueue_struct *cfs_rehash_wq; diff --git a/include/linux/lnet/lib-lnet.h b/include/linux/lnet/lib-lnet.h index ce4ad5ae7eb7..ffe887525dc9 100644 --- a/include/linux/lnet/lib-lnet.h +++ b/include/linux/lnet/lib-lnet.h @@ -1225,4 +1225,13 @@ lnet_set_route_aliveness(struct lnet_route *route, bool alive) alive ? "up" : "down"); } void lnet_update_ping_buffer(void); + +extern struct blocking_notifier_head lnet_ioctl_list; +static inline int notifier_from_ioctl_errno(int err) +{ + if (err == -EINVAL) + return NOTIFY_OK; + return notifier_from_errno(err) | NOTIFY_STOP_MASK; +} + #endif diff --git a/include/uapi/linux/lnet/libcfs_ioctl.h b/include/uapi/linux/lnet/libcfs_ioctl.h index 2a067cdafc48..7a3a6f8f507e 100644 --- a/include/uapi/linux/lnet/libcfs_ioctl.h +++ b/include/uapi/linux/lnet/libcfs_ioctl.h @@ -36,8 +36,8 @@ * */ -#ifndef __LIBCFS_IOCTL_H__ -#define __LIBCFS_IOCTL_H__ +#ifndef __UAPI_LIBCFS_IOCTL_H__ +#define __UAPI_LIBCFS_IOCTL_H__ #include #include @@ -49,8 +49,8 @@ #define __user #endif -#define LIBCFS_IOCTL_VERSION 0x0001000a -#define LIBCFS_IOCTL_VERSION2 0x0001000b +#define LNET_IOCTL_VERSION 0x0001000a +#define LNET_IOCTL_VERSION2 0x0001000b struct libcfs_ioctl_hdr { __u32 ioc_len; @@ -159,4 +159,4 @@ struct libcfs_ioctl_data { #define IOC_LIBCFS_SET_PEER _IOWR(IOC_LIBCFS_TYPE, 112, IOCTL_CONFIG_SIZE) #define IOC_LIBCFS_MAX_NR 112 -#endif /* __LIBCFS_IOCTL_H__ */ +#endif /* __UAPI_LIBCFS_IOCTL_H__ */ diff --git a/net/lnet/libcfs/module.c b/net/lnet/libcfs/module.c index 17cb8e4b818f..a8110af3c99f 100644 --- a/net/lnet/libcfs/module.c +++ b/net/lnet/libcfs/module.c @@ -29,7 +29,6 @@ /* * This file is part of Lustre, http://www.lustre.org/ */ -#include #include #include #include @@ -65,230 +64,26 @@ struct lnet_debugfs_symlink_def { static struct dentry *lnet_debugfs_root; -BLOCKING_NOTIFIER_HEAD(libcfs_ioctl_list); -EXPORT_SYMBOL(libcfs_ioctl_list); - -static inline size_t libcfs_ioctl_packlen(struct libcfs_ioctl_data *data) -{ - size_t len = sizeof(*data); - - len += round_up(data->ioc_inllen1, 8); - len += round_up(data->ioc_inllen2, 8); - return len; -} - -static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data) -{ - const int maxlen = 1 << 30; - - if (data->ioc_hdr.ioc_len > maxlen) - return true; - - if (data->ioc_inllen1 > maxlen) - return true; - - if (data->ioc_inllen2 > maxlen) - return true; - - if (data->ioc_inlbuf1 && !data->ioc_inllen1) { - CERROR("LIBCFS ioctl: inlbuf1 pointer but 0 length\n"); - return true; - } - if (data->ioc_inlbuf2 && !data->ioc_inllen2) { - CERROR("LIBCFS ioctl: inlbuf2 pointer but 0 length\n"); - return true; - } - if (data->ioc_pbuf1 && !data->ioc_plen1) { - CERROR("LIBCFS ioctl: pbuf1 pointer but 0 length\n"); - return true; - } - if (data->ioc_pbuf2 && !data->ioc_plen2) { - CERROR("LIBCFS ioctl: pbuf2 pointer but 0 length\n"); - return true; - } - if (data->ioc_plen1 && !data->ioc_pbuf1) { - CERROR("LIBCFS ioctl: plen1 nonzero but no pbuf1 pointer\n"); - return true; - } - if (data->ioc_plen2 && !data->ioc_pbuf2) { - CERROR("LIBCFS ioctl: plen2 nonzero but no pbuf2 pointer\n"); - return true; - } - if ((u32)libcfs_ioctl_packlen(data) != data->ioc_hdr.ioc_len) { - CERROR("LIBCFS ioctl: packlen != ioc_len\n"); - return true; - } - if (data->ioc_inllen1 && - data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') { - CERROR("LIBCFS ioctl: inlbuf1 not 0 terminated\n"); - return true; - } - if (data->ioc_inllen2 && - data->ioc_bulk[round_up(data->ioc_inllen1, 8) + - data->ioc_inllen2 - 1] != '\0') { - CERROR("LIBCFS ioctl: inlbuf2 not 0 terminated\n"); - return true; - } - return false; -} - -static int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data) -{ - if (libcfs_ioctl_is_invalid(data)) { - CERROR("libcfs ioctl: parameter not correctly formatted\n"); - return -EINVAL; - } - - if (data->ioc_inllen1) - data->ioc_inlbuf1 = &data->ioc_bulk[0]; - - if (data->ioc_inllen2) - data->ioc_inlbuf2 = &data->ioc_bulk[0] + - round_up(data->ioc_inllen1, 8); - - return 0; -} - -static int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp, - const struct libcfs_ioctl_hdr __user *uhdr) -{ - struct libcfs_ioctl_hdr hdr; - int err; - - if (copy_from_user(&hdr, uhdr, sizeof(hdr))) - return -EFAULT; - - if (hdr.ioc_version != LIBCFS_IOCTL_VERSION && - hdr.ioc_version != LIBCFS_IOCTL_VERSION2) { - CERROR("libcfs ioctl: version mismatch expected %#x, got %#x\n", - LIBCFS_IOCTL_VERSION, hdr.ioc_version); - return -EINVAL; - } - - if (hdr.ioc_len < sizeof(hdr)) { - CERROR("libcfs ioctl: user buffer too small for ioctl\n"); - return -EINVAL; - } - - if (hdr.ioc_len > LIBCFS_IOC_DATA_MAX) { - CERROR("libcfs ioctl: user buffer is too large %d/%d\n", - hdr.ioc_len, LIBCFS_IOC_DATA_MAX); - return -EINVAL; - } - - *hdr_pp = kvmalloc(hdr.ioc_len, GFP_KERNEL); - if (!*hdr_pp) - return -ENOMEM; - - if (copy_from_user(*hdr_pp, uhdr, hdr.ioc_len)) { - err = -EFAULT; - goto free; - } - - if ((*hdr_pp)->ioc_version != hdr.ioc_version || - (*hdr_pp)->ioc_len != hdr.ioc_len) { - err = -EINVAL; - goto free; - } - - return 0; - -free: - kvfree(*hdr_pp); - return err; -} - -static int libcfs_ioctl(unsigned long cmd, void __user *uparam) +int libcfs_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data) { - struct libcfs_ioctl_data *data = NULL; - struct libcfs_ioctl_hdr *hdr; - int err; - - err = libcfs_setup(); - if (err) - return err; - /* 'cmd' and permissions get checked in our arch-specific caller */ - err = libcfs_ioctl_getdata(&hdr, uparam); - if (err) { - CDEBUG_LIMIT(D_ERROR, - "libcfs ioctl: data header error %d\n", err); - return err; - } - - if (hdr->ioc_version == LIBCFS_IOCTL_VERSION) { - /* - * The libcfs_ioctl_data_adjust() function performs adjustment - * operations on the libcfs_ioctl_data structure to make - * it usable by the code. This doesn't need to be called - * for new data structures added. - */ - data = container_of(hdr, struct libcfs_ioctl_data, ioc_hdr); - err = libcfs_ioctl_data_adjust(data); - if (err) - goto out; - } - - CDEBUG(D_IOCTL, "libcfs ioctl cmd %lu\n", cmd); switch (cmd) { case IOC_LIBCFS_CLEAR_DEBUG: libcfs_debug_clear_buffer(); break; - case IOC_LIBCFS_MARK_DEBUG: if (!data || !data->ioc_inlbuf1 || - data->ioc_inlbuf1[data->ioc_inllen1 - 1] != '\0') { - err = -EINVAL; - goto out; - } + data->ioc_inlbuf1[data->ioc_inllen1 - 1] != '\0') + return -EINVAL; + libcfs_debug_mark_buffer(data->ioc_inlbuf1); break; default: - err = blocking_notifier_call_chain(&libcfs_ioctl_list, - cmd, hdr); - if (!(err & NOTIFY_STOP_MASK)) - /* No-one claimed the ioctl */ - err = -EINVAL; - else - err = notifier_to_errno(err); - if (copy_to_user(uparam, hdr, hdr->ioc_len) && !err) - err = -EFAULT; - break; - } -out: - kvfree(hdr); - return err; -} - -static long -libcfs_psdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - if (!capable(CAP_SYS_ADMIN)) - return -EACCES; - - if (_IOC_TYPE(cmd) != IOC_LIBCFS_TYPE || - _IOC_NR(cmd) < IOC_LIBCFS_MIN_NR || - _IOC_NR(cmd) > IOC_LIBCFS_MAX_NR) { - CDEBUG(D_IOCTL, "invalid ioctl ( type %d, nr %d, size %d )\n", - _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd)); return -EINVAL; } - - return libcfs_ioctl(cmd, (void __user *)arg); + return 0; } - -static const struct file_operations libcfs_fops = { - .owner = THIS_MODULE, - .unlocked_ioctl = libcfs_psdev_ioctl, -}; - -static struct miscdevice libcfs_dev = { - .minor = MISC_DYNAMIC_MINOR, - .name = "lnet", - .fops = &libcfs_fops, -}; - -static int libcfs_dev_registered; +EXPORT_SYMBOL(libcfs_ioctl); static int proc_dobitmasks(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) @@ -836,9 +631,6 @@ int libcfs_setup(void) if (libcfs_active) goto out; - if (!libcfs_dev_registered) - goto err; - rc = libcfs_debug_init(5 * 1024 * 1024); if (rc < 0) { pr_err("LustreError: libcfs_debug_init: rc = %d\n", rc); @@ -880,18 +672,11 @@ EXPORT_SYMBOL(libcfs_setup); static int libcfs_init(void) { - int rc; - lnet_insert_debugfs(lnet_table, THIS_MODULE, &debugfs_state); if (!IS_ERR_OR_NULL(lnet_debugfs_root)) lnet_insert_debugfs_links(lnet_debugfs_symlinks); - rc = misc_register(&libcfs_dev); - if (rc) - CERROR("misc_register: error %d\n", rc); - else - libcfs_dev_registered = 1; - return rc; + return 0; } static void libcfs_exit(void) @@ -909,9 +694,6 @@ static void libcfs_exit(void) cfs_crypto_unregister(); - if (libcfs_dev_registered) - misc_deregister(&libcfs_dev); - cfs_cpu_fini(); /* the below message is checked in test-framework.sh check_mem_leak() */ diff --git a/net/lnet/lnet/api-ni.c b/net/lnet/lnet/api-ni.c index d87bc33b1103..f8add2c28284 100644 --- a/net/lnet/lnet/api-ni.c +++ b/net/lnet/lnet/api-ni.c @@ -4470,6 +4470,7 @@ LNetCtl(unsigned int cmd, void *arg) if (rc < 0) goto report_ping_err; count = rc; + rc = 0; for (i = 0; i < count; i++) { struct lnet_processid *result; @@ -4631,7 +4632,7 @@ LNetCtl(unsigned int cmd, void *arg) rc = ni->ni_net->net_lnd->lnd_ctl(ni, cmd, arg); lnet_ni_decref(ni); - return rc; + return rc <= 0 ? rc : 0; } /* not reached */ } diff --git a/net/lnet/lnet/module.c b/net/lnet/lnet/module.c index e6e34dcad90e..edb41ff28d80 100644 --- a/net/lnet/lnet/module.c +++ b/net/lnet/lnet/module.c @@ -32,6 +32,7 @@ #define DEBUG_SUBSYSTEM S_LNET +#include #include #include @@ -178,11 +179,9 @@ lnet_dyn_unconfigure_ni(struct libcfs_ioctl_hdr *hdr) } static int -lnet_ioctl(struct notifier_block *nb, - unsigned long cmd, void *vdata) +lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) { int rc; - struct libcfs_ioctl_hdr *hdr = vdata; switch (cmd) { case IOC_LIBCFS_CONFIGURE: { @@ -219,8 +218,7 @@ lnet_ioctl(struct notifier_block *nb, break; default: - /* - * Passing LNET_PID_ANY only gives me a ref if the net is up + /* Passing LNET_PID_ANY only gives me a ref if the net is up * already; I'll need it to ensure the net can't go down while * I'm called into it */ @@ -231,11 +229,198 @@ lnet_ioctl(struct notifier_block *nb, } break; } - return notifier_from_ioctl_errno(rc); + return rc; +} + +BLOCKING_NOTIFIER_HEAD(lnet_ioctl_list); +EXPORT_SYMBOL(lnet_ioctl_list); + +static inline size_t lnet_ioctl_packlen(struct libcfs_ioctl_data *data) +{ + size_t len = sizeof(*data); + + len += round_up(data->ioc_inllen1, 8); + len += round_up(data->ioc_inllen2, 8); + return len; +} + +static bool lnet_ioctl_is_invalid(struct libcfs_ioctl_data *data) +{ + const int maxlen = 1 << 30; + + if (data->ioc_hdr.ioc_len > maxlen) + return true; + + if (data->ioc_inllen1 > maxlen) + return true; + + if (data->ioc_inllen2 > maxlen) + return true; + + if (data->ioc_inlbuf1 && !data->ioc_inllen1) + return true; + + if (data->ioc_inlbuf2 && !data->ioc_inllen2) + return true; + + if (data->ioc_pbuf1 && !data->ioc_plen1) + return true; + + if (data->ioc_pbuf2 && !data->ioc_plen2) + return true; + + if (data->ioc_plen1 && !data->ioc_pbuf1) + return true; + + if (data->ioc_plen2 && !data->ioc_pbuf2) + return true; + + if (lnet_ioctl_packlen(data) != data->ioc_hdr.ioc_len) + return true; + + if (data->ioc_inllen1 && + data->ioc_bulk[round_up(data->ioc_inllen1, 8) + + data->ioc_inllen2 - 1] != '\0') + return true; + + return false; +} + +static int lnet_ioctl_data_adjust(struct libcfs_ioctl_data *data) +{ + if (lnet_ioctl_is_invalid(data)) { + CERROR("lnet ioctl: parameter not correctly formatted\n"); + return -EINVAL; + } + + if (data->ioc_inllen1 != 0) + data->ioc_inlbuf1 = &data->ioc_bulk[0]; + + if (data->ioc_inllen2 != 0) + data->ioc_inlbuf2 = (&data->ioc_bulk[0] + + round_up(data->ioc_inllen1, 8)); + + return 0; +} + +static int lnet_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp, + struct libcfs_ioctl_hdr __user *uhdr) +{ + struct libcfs_ioctl_hdr hdr; + int err; + + if (copy_from_user(&hdr, uhdr, sizeof(hdr))) + return -EFAULT; + + if (hdr.ioc_version != LNET_IOCTL_VERSION && + hdr.ioc_version != LNET_IOCTL_VERSION2) { + CERROR("lnet ioctl: version mismatch expected %#x, got %#x\n", + LNET_IOCTL_VERSION, hdr.ioc_version); + return -EINVAL; + } + + if (hdr.ioc_len < sizeof(struct libcfs_ioctl_hdr)) { + CERROR("lnet ioctl: user buffer too small for ioctl\n"); + return -EINVAL; + } + + if (hdr.ioc_len > LIBCFS_IOC_DATA_MAX) { + CERROR("lnet ioctl: user buffer is too large %d/%d\n", + hdr.ioc_len, LIBCFS_IOC_DATA_MAX); + return -EINVAL; + } + + *hdr_pp = kmalloc(hdr.ioc_len, GFP_KERNEL); + if (!*hdr_pp) + return -ENOMEM; + + if (copy_from_user(*hdr_pp, uhdr, hdr.ioc_len)) { + err = -EFAULT; + goto free; + } + + if ((*hdr_pp)->ioc_version != hdr.ioc_version || + (*hdr_pp)->ioc_len != hdr.ioc_len) { + err = -EINVAL; + goto free; + } + + return 0; + +free: + kfree(*hdr_pp); + return err; +} + +static long +lnet_psdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + void __user *uparam = (void __user *)arg; + struct libcfs_ioctl_data *data = NULL; + struct libcfs_ioctl_hdr *hdr; + int err; + + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; + + if (_IOC_TYPE(cmd) != IOC_LIBCFS_TYPE || + _IOC_NR(cmd) < IOC_LIBCFS_MIN_NR || + _IOC_NR(cmd) > IOC_LIBCFS_MAX_NR) { + CDEBUG(D_IOCTL, "invalid ioctl ( type %d, nr %d, size %d )\n", + _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd)); + return -EINVAL; + } + + /* 'cmd' and permissions get checked in our arch-specific caller */ + err = lnet_ioctl_getdata(&hdr, uparam); + if (err != 0) { + CDEBUG_LIMIT(D_ERROR, + "lnet ioctl: data header error %d\n", err); + return err; + } + + if (hdr->ioc_version == LNET_IOCTL_VERSION) { + /* The lnet_ioctl_data_adjust() function performs adjustment + * operations on the libcfs_ioctl_data structure to make + * it usable by the code. This doesn't need to be called + * for new data structures added. + */ + data = container_of(hdr, struct libcfs_ioctl_data, ioc_hdr); + err = lnet_ioctl_data_adjust(data); + if (err != 0) + goto out; + } + + CDEBUG(D_IOCTL, "lnet ioctl cmd %u\n", cmd); + + err = libcfs_ioctl(cmd, data); + if (err == -EINVAL) + err = lnet_ioctl(cmd, hdr); + if (err == -EINVAL) { + err = blocking_notifier_call_chain(&lnet_ioctl_list, + cmd, hdr); + if (!(err & NOTIFY_STOP_MASK)) + /* No-one claimed the ioctl */ + err = -EINVAL; + else + err = notifier_to_errno(err); + } + if (copy_to_user(uparam, hdr, hdr->ioc_len) && !err) + err = -EFAULT; +out: + kfree(hdr); + return err; } -static struct notifier_block lnet_ioctl_handler = { - .notifier_call = lnet_ioctl, +static const struct file_operations lnet_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = lnet_psdev_ioctl, +}; + +static struct miscdevice lnet_dev = { + .minor = MISC_DYNAMIC_MINOR, + .name = "lnet", + .fops = &lnet_fops, }; static int __init lnet_init(void) @@ -248,7 +433,13 @@ static int __init lnet_init(void) rc = lnet_lib_init(); if (rc) { - CERROR("lnet_lib_init: error %d\n", rc); + CERROR("lnet_lib_init: rc = %d\n", rc); + return rc; + } + + rc = misc_register(&lnet_dev); + if (rc) { + CERROR("misc_register: rc = %d\n", rc); return rc; } @@ -256,10 +447,6 @@ static int __init lnet_init(void) dead_router_check_interval != INT_MIN) LCONSOLE_WARN("live_router_check_interval and dead_router_check_interval have been deprecated. Use alive_router_check_interval instead. Ignoring these deprecated parameters.\n"); - rc = blocking_notifier_chain_register(&libcfs_ioctl_list, - &lnet_ioctl_handler); - LASSERT(!rc); - if (config_on_load) { /* * Have to schedule a separate thread to avoid deadlocking @@ -273,12 +460,7 @@ static int __init lnet_init(void) static void __exit lnet_exit(void) { - int rc; - - rc = blocking_notifier_chain_unregister(&libcfs_ioctl_list, - &lnet_ioctl_handler); - LASSERT(!rc); - + misc_deregister(&lnet_dev); lnet_router_exit(); lnet_lib_exit(); } diff --git a/net/lnet/selftest/console.c b/net/lnet/selftest/console.c index b6c98820d0bf..cac1752a51b8 100644 --- a/net/lnet/selftest/console.c +++ b/net/lnet/selftest/console.c @@ -1989,7 +1989,7 @@ lstcon_console_init(void) if (rc < 0) goto out; - rc = blocking_notifier_chain_register(&libcfs_ioctl_list, + rc = blocking_notifier_chain_register(&lnet_ioctl_list, &lstcon_ioctl_handler); if (rc < 0) { @@ -2016,7 +2016,7 @@ lstcon_console_fini(void) { int i; - blocking_notifier_chain_unregister(&libcfs_ioctl_list, + blocking_notifier_chain_unregister(&lnet_ioctl_list, &lstcon_ioctl_handler); lstcon_fini_netlink(); From patchwork Fri Mar 21 13:07:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D9A5C36000 for ; Fri, 21 Mar 2025 13:38:42 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2vX0Rx5z210K; Fri, 21 Mar 2025 06:13:44 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2nW0FCwz1y69 for ; Fri, 21 Mar 2025 06:08:30 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm5-e204-208.ccs.ornl.gov [160.91.203.29]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 98E2889123E; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 96FBE106BE18; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:07:03 -0400 Message-ID: <20250321130711.3257092-21-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 20/27] lustre: llite: simplify parsing in pcc_conds_parse() X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Feng Lei , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mr NeilBrown If we duplicate the string to be parsed we can use standard parsing tools like strsep() and strcmp(). WC-bug-id: https://jira.whamcloud.com/browse/LU-9859 Lustre-commit: d6136c5df6267712f ("LU-9859 llite: simplify parsing in pcc_conds_parse()") Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50839 Reviewed-by: Feng Lei Reviewed-by: James Simmons Reviewed-by: Qian Yingjin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/pcc.c | 131 ++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 76 deletions(-) diff --git a/fs/lustre/llite/pcc.c b/fs/lustre/llite/pcc.c index 677f5f38f100..a95d92404326 100644 --- a/fs/lustre/llite/pcc.c +++ b/fs/lustre/llite/pcc.c @@ -205,9 +205,9 @@ static void pcc_cmd_fini(struct pcc_cmd *cmd) } } -#define PCC_DISJUNCTION_DELIM (',') -#define PCC_CONJUNCTION_DELIM ('&') -#define PCC_EXPRESSION_DELIM ('=') +#define PCC_DISJUNCTION_DELIM (",") +#define PCC_CONJUNCTION_DELIM ("&") +#define PCC_EXPRESSION_DELIM ("=") static int pcc_fname_list_add(struct cfs_lstr *id, struct list_head *fname_list) @@ -255,34 +255,27 @@ pcc_fname_list_parse(char *str, int len, struct list_head *fname_list) } static int -pcc_id_list_parse(char *str, int len, struct list_head *id_list, +pcc_id_list_parse(char *str, struct list_head *id_list, enum pcc_field type) { - struct cfs_lstr src; - struct cfs_lstr res; int rc = 0; if (type != PCC_FIELD_UID && type != PCC_FIELD_GID && type != PCC_FIELD_PROJID) return -EINVAL; - src.ls_str = str; - src.ls_len = len; INIT_LIST_HEAD(id_list); - while (src.ls_str) { + while (str) { + char *num; struct pcc_match_id *id; - u32 id_val; + unsigned long id_val; - if (cfs_gettok(&src, ' ', &res) == 0) { - rc = -EINVAL; - goto out; - } - - if (!cfs_str2num_check(res.ls_str, res.ls_len, - &id_val, 0, (u32)~0U)) { - rc = -EINVAL; + num = strsep(&str, " "); + if (!*num) + continue; + rc = kstrtoul(num, 0, &id_val); + if (rc) goto out; - } id = kzalloc(sizeof(*id), GFP_KERNEL); if (!id) { @@ -293,73 +286,70 @@ pcc_id_list_parse(char *str, int len, struct list_head *id_list, id->pmi_id = id_val; list_add_tail(&id->pmi_linkage, id_list); } + if (list_empty(id_list)) + rc = -EINVAL; out: if (rc) pcc_id_list_free(id_list); return rc; } -static inline bool -pcc_check_field(struct cfs_lstr *field, char *str) -{ - int len = strlen(str); - - return (field->ls_len == len && - strncmp(field->ls_str, str, len) == 0); -} - static int -pcc_expression_parse(struct cfs_lstr *src, struct list_head *cond_list) +pcc_expression_parse(char *str, struct list_head *cond_list) { struct pcc_expression *expr; - struct cfs_lstr field; + char *field; + int len; int rc = 0; expr = kzalloc(sizeof(*expr), GFP_KERNEL); if (!expr) return -ENOMEM; - rc = cfs_gettok(src, PCC_EXPRESSION_DELIM, &field); - if (rc == 0 || src->ls_len <= 2 || src->ls_str[0] != '{' || - src->ls_str[src->ls_len - 1] != '}') { + field = strim(strsep(&str, PCC_EXPRESSION_DELIM)); + if (!*field || !str) { + /* No LHS or no '=' */ + rc = -EINVAL; + goto out; + } + str = skip_spaces(str); + len = strlen(str); + if (str[0] != '{' || str[len - 1] != '}') { rc = -EINVAL; goto out; } /* Skip '{' and '}' */ - src->ls_str++; - src->ls_len -= 2; + str[len - 1] = '\0'; + str += 1; + len -= 2; - if (pcc_check_field(&field, "uid")) { - if (pcc_id_list_parse(src->ls_str, - src->ls_len, + if (strcmp(field, "uid") == 0) { + if (pcc_id_list_parse(str, &expr->pe_cond, PCC_FIELD_UID) < 0) { rc = -EINVAL; goto out; } expr->pe_field = PCC_FIELD_UID; - } else if (pcc_check_field(&field, "gid")) { - if (pcc_id_list_parse(src->ls_str, - src->ls_len, + } else if (strcmp(field, "gid") == 0) { + if (pcc_id_list_parse(str, &expr->pe_cond, PCC_FIELD_GID) < 0) { rc = -EINVAL; goto out; } expr->pe_field = PCC_FIELD_GID; - } else if (pcc_check_field(&field, "projid")) { - if (pcc_id_list_parse(src->ls_str, - src->ls_len, + } else if (strcmp(field, "projid") == 0) { + if (pcc_id_list_parse(str, &expr->pe_cond, PCC_FIELD_PROJID) < 0) { rc = -EINVAL; goto out; } expr->pe_field = PCC_FIELD_PROJID; - } else if (pcc_check_field(&field, "fname")) { - if (pcc_fname_list_parse(src->ls_str, - src->ls_len, + } else if (strcmp(field, "fname") == 0) { + if (pcc_fname_list_parse(str, len, &expr->pe_cond) < 0) { rc = -EINVAL; goto out; @@ -378,10 +368,9 @@ pcc_expression_parse(struct cfs_lstr *src, struct list_head *cond_list) } static int -pcc_conjunction_parse(struct cfs_lstr *src, struct list_head *cond_list) +pcc_conjunction_parse(char *str, struct list_head *cond_list) { struct pcc_conjunction *conjunction; - struct cfs_lstr expr; int rc = 0; conjunction = kzalloc(sizeof(*conjunction), GFP_KERNEL); @@ -391,39 +380,31 @@ pcc_conjunction_parse(struct cfs_lstr *src, struct list_head *cond_list) INIT_LIST_HEAD(&conjunction->pc_expressions); list_add_tail(&conjunction->pc_linkage, cond_list); - while (src->ls_str) { - rc = cfs_gettok(src, PCC_CONJUNCTION_DELIM, &expr); - if (rc == 0) { - rc = -EINVAL; - break; - } - rc = pcc_expression_parse(&expr, - &conjunction->pc_expressions); - if (rc) - break; + while (rc == 0 && str) { + char *expr = strsep(&str, PCC_CONJUNCTION_DELIM); + + rc = pcc_expression_parse(expr, &conjunction->pc_expressions); } return rc; } -static int pcc_conds_parse(char *str, int len, struct list_head *cond_list) +static int pcc_conds_parse(char *orig, struct list_head *cond_list) { - struct cfs_lstr src; - struct cfs_lstr res; + char *str; int rc = 0; - src.ls_str = str; - src.ls_len = len; + orig = kstrdup(orig, GFP_KERNEL); + if (!orig) + return -ENOMEM; + str = orig; + INIT_LIST_HEAD(cond_list); - while (src.ls_str) { - rc = cfs_gettok(&src, PCC_DISJUNCTION_DELIM, &res); - if (rc == 0) { - rc = -EINVAL; - break; - } - rc = pcc_conjunction_parse(&res, cond_list); - if (rc) - break; + while (rc == 0 && str) { + char *term = strsep(&str, PCC_DISJUNCTION_DELIM); + + rc = pcc_conjunction_parse(term, cond_list); } + kfree(orig); return rc; } @@ -438,7 +419,6 @@ static int pcc_id_parse(struct pcc_cmd *cmd, const char *id) memcpy(cmd->u.pccc_add.pccc_conds_str, id, strlen(id)); rc = pcc_conds_parse(cmd->u.pccc_add.pccc_conds_str, - strlen(cmd->u.pccc_add.pccc_conds_str), &cmd->u.pccc_add.pccc_conds); if (rc) pcc_cmd_fini(cmd); @@ -598,8 +578,7 @@ pcc_dataset_rule_init(struct pcc_match_rule *rule, struct pcc_cmd *cmd) INIT_LIST_HEAD(&rule->pmr_conds); if (!list_empty(&cmd->u.pccc_add.pccc_conds)) rc = pcc_conds_parse(rule->pmr_conds_str, - strlen(rule->pmr_conds_str), - &rule->pmr_conds); + &rule->pmr_conds); if (rc) pcc_dataset_rule_fini(rule); From patchwork Fri Mar 21 13:07:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F08BCC36000 for ; Fri, 21 Mar 2025 13:41:23 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2w94nDJz211L; Fri, 21 Mar 2025 06:14:17 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2nd0zYWz1y7N for ; Fri, 21 Mar 2025 06:08:37 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 9BB5617B5AA; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 9AAAC106BE16; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:07:04 -0400 Message-ID: <20250321130711.3257092-22-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 21/27] lustre: llite: create fileattr_[get|set] functions X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mr NeilBrown Move the code for FS_IOC_SETFLAGS and GETFLAGS into their functions. This is done ahead of the >fileattr_get/set inode_operations API that hasn't stabilize just yet. WC-bug-id: https://jira.whamcloud.com/browse/LU-15969 Lustre-commit: d7aa8de396f585e70 ("LU-15969 llite: add support for ->fileattr_get/set") Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51107 Reviewed-by: Shaun Tancheff Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/file.c | 3 +- fs/lustre/llite/llite_internal.h | 1 + fs/lustre/llite/llite_lib.c | 180 ++++++++++++++++++------------- fs/lustre/llite/namei.c | 2 + 4 files changed, 109 insertions(+), 77 deletions(-) diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c index 8564ee4a879c..48c4245d61b3 100644 --- a/fs/lustre/llite/file.c +++ b/fs/lustre/llite/file.c @@ -3711,7 +3711,7 @@ int ll_ioctl_check_project(struct inode *inode, u32 xflags, return 0; } -static int ll_set_project(struct inode *inode, u32 xflags, u32 projid) +int ll_set_project(struct inode *inode, u32 xflags, u32 projid) { struct ptlrpc_request *req = NULL; struct md_op_data *op_data; @@ -5778,6 +5778,7 @@ const struct inode_operations ll_file_inode_operations = { .listxattr = ll_listxattr, .fiemap = ll_fiemap, .get_acl = ll_get_acl, + .set_acl = ll_set_acl, }; const struct file_operations *ll_select_file_operations(struct ll_sb_info *sbi) diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h index 755fdae77709..2db240f07b83 100644 --- a/fs/lustre/llite/llite_internal.h +++ b/fs/lustre/llite/llite_internal.h @@ -1262,6 +1262,7 @@ int ll_get_fid_by_name(struct inode *parent, const char *name, int namelen, struct lu_fid *fid, struct inode **inode); int ll_inode_permission(struct inode *inode, int mask); int ll_ioctl_check_project(struct inode *inode, u32 xflags, u32 projid); +int ll_set_project(struct inode *inode, u32 xflags, u32 projid); int ll_ioctl_fsgetxattr(struct inode *inode, unsigned int cmd, void __user *uarg); int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd, diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c index b4d5b3dca0a7..39b8074bd306 100644 --- a/fs/lustre/llite/llite_lib.c +++ b/fs/lustre/llite/llite_lib.c @@ -3001,13 +3001,103 @@ void ll_delete_inode(struct inode *inode) clear_inode(inode); } +static int fileattr_get(struct inode *inode, int *flags, u32 *xflags, + u32 *projid) +{ + struct ll_sb_info *sbi = ll_i2sbi(inode); + struct ptlrpc_request *req = NULL; + struct md_op_data *op_data; + struct mdt_body *body; + int rc; + + op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, + 0, 0, LUSTRE_OPC_ANY, + NULL); + if (IS_ERR(op_data)) + return PTR_ERR(op_data); + + op_data->op_valid = OBD_MD_FLFLAGS; + rc = md_getattr(sbi->ll_md_exp, op_data, &req); + ll_finish_md_op_data(op_data); + if (rc) { + CERROR("%s: failure inode "DFID": rc = %d\n", + sbi->ll_md_exp->exp_obd->obd_name, + PFID(ll_inode2fid(inode)), rc); + return -abs(rc); + } + + body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); + + *flags = body->mbo_flags; + /* if Lustre specific LUSTRE_ENCRYPT_FL flag is set, also set + * ext4 equivalent to please lsattr and other e2fsprogs tools + */ + if (*flags & LUSTRE_ENCRYPT_FL) + *flags |= STATX_ATTR_ENCRYPTED; + + ptlrpc_req_finished(req); + + *xflags = ll_inode_flags_to_xflags(inode->i_flags); + if (test_bit(LLIF_PROJECT_INHERIT, &ll_i2info(inode)->lli_flags)) + *xflags |= FS_XFLAG_PROJINHERIT; + *projid = ll_i2info(inode)->lli_projid; + + return 0; +} + +static int fileattr_set(struct inode *inode, int flags) +{ + struct ll_sb_info *sbi = ll_i2sbi(inode); + struct ptlrpc_request *req = NULL; + struct md_op_data *op_data; + struct cl_object *obj; + struct fsxattr fa = { 0 }; + struct iattr *attr; + int rc; + + fa.fsx_projid = ll_i2info(inode)->lli_projid; + if (flags & LUSTRE_PROJINHERIT_FL) + fa.fsx_xflags = FS_XFLAG_PROJINHERIT; + + rc = ll_ioctl_check_project(inode, fa.fsx_xflags, + fa.fsx_projid); + if (rc) + return rc; + + op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, + LUSTRE_OPC_ANY, NULL); + if (IS_ERR(op_data)) + return PTR_ERR(op_data); + + op_data->op_attr_flags = flags; + op_data->op_xvalid |= OP_XVALID_FLAGS; + rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, &req); + ll_finish_md_op_data(op_data); + ptlrpc_req_finished(req); + if (rc) + return rc; + + ll_update_inode_flags(inode, flags); + + obj = ll_i2info(inode)->lli_clob; + if (!obj) + return 0; + + attr = kzalloc(sizeof(*attr), GFP_KERNEL); + if (!attr) + return -ENOMEM; + + rc = cl_setattr_ost(obj, attr, OP_XVALID_FLAGS, flags); + kfree(attr); + + return rc; +} + /* ioctl commands shared between files and directories */ int ll_iocontrol(struct inode *inode, struct file *file, unsigned int cmd, void __user *uarg) { - struct ll_sb_info *sbi = ll_i2sbi(inode); - struct ptlrpc_request *req = NULL; - int rc = 0, flags = 0; + int rc; switch (cmd) { case BLKSSZGET: @@ -3018,92 +3108,29 @@ int ll_iocontrol(struct inode *inode, struct file *file, rc = put_user(inode->i_generation, (int __user *)uarg); break; case FS_IOC_GETFLAGS: { - struct mdt_body *body; - struct md_op_data *op_data; + u32 xflags = 0, projid = 0; + int flags = 0; - if (!access_ok(uarg, sizeof(int))) - return -EFAULT; - - op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, - LUSTRE_OPC_ANY, NULL); - if (IS_ERR(op_data)) { - rc = PTR_ERR(op_data); - break; - } - op_data->op_valid = OBD_MD_FLFLAGS; - rc = md_getattr(sbi->ll_md_exp, op_data, &req); - ll_finish_md_op_data(op_data); - if (rc) { - CERROR("%s: failure inode " DFID ": rc = %d\n", - sbi->ll_md_exp->exp_obd->obd_name, - PFID(ll_inode2fid(inode)), rc); - rc = -abs(rc); + if (!access_ok(uarg, sizeof(int))) { + rc = -EFAULT; break; } - body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); + rc = fileattr_get(file->f_inode, &flags, &xflags, &projid); + if (rc == 0) + rc = put_user(flags, (int __user *)uarg); - flags = body->mbo_flags; - /* if Lustre specific LUSTRE_ENCRYPT_FL flag is set, also set - * ext4 equivalent to please lsattr and other e2fsprogs tools - */ - if (flags & LUSTRE_ENCRYPT_FL) - flags |= STATX_ATTR_ENCRYPTED; - - ptlrpc_req_finished(req); - - rc = put_user(flags, (int __user *)uarg); break; } case FS_IOC_SETFLAGS: { - struct md_op_data *op_data; - struct cl_object *obj; - struct iattr *attr; - struct fsxattr fa = { 0 }; + int flags = 0; if (get_user(flags, (int __user *)uarg)) { rc = -EFAULT; break; } - fa.fsx_projid = ll_i2info(inode)->lli_projid; - if (flags & LUSTRE_PROJINHERIT_FL) - fa.fsx_xflags = FS_XFLAG_PROJINHERIT; - - rc = ll_ioctl_check_project(inode, fa.fsx_xflags, - fa.fsx_projid); - if (rc) - break; - - op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, - LUSTRE_OPC_ANY, NULL); - if (IS_ERR(op_data)) { - rc = PTR_ERR(op_data); - break; - } - - op_data->op_attr_flags = flags; - op_data->op_xvalid |= OP_XVALID_FLAGS; - rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, &req); - ll_finish_md_op_data(op_data); - ptlrpc_req_finished(req); - if (rc) - break; - - ll_update_inode_flags(inode, flags); - - obj = ll_i2info(inode)->lli_clob; - if (!obj) - break; - - attr = kzalloc(sizeof(*attr), GFP_NOFS); - if (!attr) { - rc = -ENOMEM; - break; - } - - rc = cl_setattr_ost(obj, attr, OP_XVALID_FLAGS, flags); - kfree(attr); + rc = fileattr_set(file->f_inode, flags); break; } case FS_IOC_FSGETXATTR: @@ -3197,7 +3224,8 @@ int ll_iocontrol(struct inode *inode, struct file *file, break; #ifdef OBD_IOC_GETNAME_OLD case_OBD_IOC_DEPRECATED_FT(OBD_IOC_GETNAME_OLD, - sbi->ll_md_exp->exp_obd->obd_name, 2, 16); + ll_i2sbi(inode)->ll_md_exp->exp_obd->obd_name, + 2, 16); #endif case OBD_IOC_GETDTNAME: fallthrough; diff --git a/fs/lustre/llite/namei.c b/fs/lustre/llite/namei.c index 79df426fcbbb..1d21626588ec 100644 --- a/fs/lustre/llite/namei.c +++ b/fs/lustre/llite/namei.c @@ -2227,6 +2227,7 @@ const struct inode_operations ll_dir_inode_operations = { .permission = ll_inode_permission, .listxattr = ll_listxattr, .get_acl = ll_get_acl, + .set_acl = ll_set_acl, }; const struct inode_operations ll_special_inode_operations = { @@ -2235,4 +2236,5 @@ const struct inode_operations ll_special_inode_operations = { .permission = ll_inode_permission, .listxattr = ll_listxattr, .get_acl = ll_get_acl, + .set_acl = ll_set_acl, }; From patchwork Fri Mar 21 13:07:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025456 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37343C36000 for ; Fri, 21 Mar 2025 13:35:56 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2tq51WWz20yq; Fri, 21 Mar 2025 06:13:07 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2nd1cqCz1y7P for ; Fri, 21 Mar 2025 06:08:37 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id A1373893D84; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id 9E4A3106BE19; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:07:05 -0400 Message-ID: <20250321130711.3257092-23-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 22/27] lnet: libcfs: Remove reference to LASSERT_ATOMIC_GT_LT X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arshad Hussain , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Arshad Hussain This patch removes all reference to LASSERT_ATOMIC_GT_LT macro. WC-bug-id: https://jira.whamcloud.com/browse/LU-16796 Lustre-commit: 5cc0c6b2630e955ee ("LU-16796 libcfs: Remove reference to LASSERT_ATOMIC_GT_LT") Signed-off-by: Arshad Hussain Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51157 Reviewed-by: Neil Brown Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/include/lustre_log.h | 8 ++++++-- fs/lustre/ldlm/ldlm_resource.c | 5 ++++- include/linux/libcfs/libcfs_private.h | 8 -------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fs/lustre/include/lustre_log.h b/fs/lustre/include/lustre_log.h index 1586595399cf..60d451ca1710 100644 --- a/fs/lustre/include/lustre_log.h +++ b/fs/lustre/include/lustre_log.h @@ -286,10 +286,14 @@ static inline struct llog_ctxt *llog_ctxt_get(struct llog_ctxt *ctxt) static inline void llog_ctxt_put(struct llog_ctxt *ctxt) { + int refcount; + if (!ctxt) return; - LASSERT(refcount_read(&ctxt->loc_refcount) > 0); - LASSERT(refcount_read(&ctxt->loc_refcount) < LI_POISON); + + refcount = refcount_read(&ctxt->loc_refcount); + LASSERT(refcount > 0 && refcount < LI_POISON); + CDEBUG(D_INFO, "PUTting ctxt %p : new refcount %d\n", ctxt, refcount_read(&ctxt->loc_refcount) - 1); __llog_ctxt_put(NULL, ctxt); diff --git a/fs/lustre/ldlm/ldlm_resource.c b/fs/lustre/ldlm/ldlm_resource.c index 7da47976e994..db0f7f169701 100644 --- a/fs/lustre/ldlm/ldlm_resource.c +++ b/fs/lustre/ldlm/ldlm_resource.c @@ -1220,8 +1220,11 @@ void ldlm_resource_putref(struct ldlm_resource *res) { struct ldlm_namespace *ns = ldlm_res_to_ns(res); struct cfs_hash_bd bd; + int refcount; + + refcount = atomic_read(&res->lr_refcount); + LASSERT(refcount > 0 && refcount < LI_POISON); - LASSERT_ATOMIC_GT_LT(&res->lr_refcount, 0, LI_POISON); CDEBUG(D_INFO, "putref res: %p count: %d\n", res, atomic_read(&res->lr_refcount) - 1); diff --git a/include/linux/libcfs/libcfs_private.h b/include/linux/libcfs/libcfs_private.h index d46c66e8534b..0a377f09d6dd 100644 --- a/include/linux/libcfs/libcfs_private.h +++ b/include/linux/libcfs/libcfs_private.h @@ -112,17 +112,9 @@ int libcfs_debug_mark_buffer(const char *text); #define LASSERT_ATOMIC_EQ(a, v) \ LASSERTF(atomic_read(a) == v, "value: %d\n", atomic_read((a))) -/** assert value of @a is great than @v1 and little than @v2 */ -#define LASSERT_ATOMIC_GT_LT(a, v1, v2) \ -do { \ - int __v = atomic_read(a); \ - LASSERTF(__v > v1 && __v < v2, "value: %d\n", __v); \ -} while (0) - #else /* !LASSERT_ATOMIC_ENABLED */ #define LASSERT_ATOMIC_EQ(a, v) do {} while (0) -#define LASSERT_ATOMIC_GT_LT(a, v1, v2) do {} while (0) #endif /* LASSERT_ATOMIC_ENABLED */ From patchwork Fri Mar 21 13:07:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B9F5BC36000 for ; Fri, 21 Mar 2025 13:40:57 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2vh5PC9z210b; Fri, 21 Mar 2025 06:13:52 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2p94VxMz1y9c for ; Fri, 21 Mar 2025 06:09:05 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm4-e204-208.ccs.ornl.gov [160.91.203.22]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id A505617B5B2; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id A3714106BE14; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:07:06 -0400 Message-ID: <20250321130711.3257092-24-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 23/27] lustre: llite: deadlock on lli_lsm_sem X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vitaly Fertman , Andriy Skulysh , Vitaly Fertman , Lai Siyao , Alexey Lyashkov , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Vitaly Fertman it may happen that one process is doing lookup, and after reply while holding the LDLM lock is trying to update LSM/default LSM under the write lli_lsm_sem for a dir. another process has taken the read lli_lsm_sem (taken for all the MD ops in ll_prep_md_op_data()) and is waiting for a conflicting PW LDLM lock on server for its modification for this dir. it may happen on restriping with LSM, on changing the default LSM, but even more often way is racer run even without striped dirs: - racer does LFS mkdir -i $i per each MDS, what creates a default LSM on these subdirs inherited endlessly - to keep the MDS index; - racer also does mkdir -p , in which case we do: ll_new_node - create a parent dir, no RMF_DEFAULT_MDT_MD in reply ll_lookup parent it=open - no RMF_DEFAULT_MDT_MD in reply ll_new_node - create a child the default LSM is inherited on the parent creation, however as those RPCs do not have lookup LDLM lock and no data - the default layout is not set for the parent in inode at the time of a child creation. thus a parallel lookup which gets the LSM deadlocks with this ll_new_node(). at the same time, similar to CLIO, we do not need to hold a sem nor an LDLM lock over the whole operation to avoid LSM modification on server, we just need to take an uptodate LSM (this is a subject for LU-16320) and to guarantee this op will be working on the client on this LSM for the whole operation. the solution is to let MD ops to work on a copy of LSM therefore letting others to modify LSM attached to inode in parallel if needed. HPE-bug-id: LUS-10725 WC-bug-id: https://jira.whamcloud.com/browse/LU-15535 Lustre-commit: 3ebc8e0528e34a11f ("LU-15535 llite: deadlock on lli_lsm_sem") Signed-off-by: Vitaly Fertman Reviewed-on: https://es-gerrit.hpc.amslabs.hpecorp.net/161525 Reviewed-by: Alexey Lyashkov Reviewed-by: Andriy Skulysh Tested-by: Vitaly Fertman Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50489 Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/include/lustre_lmv.h | 84 +++--- fs/lustre/include/obd.h | 28 +- fs/lustre/include/obd_class.h | 24 +- fs/lustre/llite/dir.c | 12 +- fs/lustre/llite/file.c | 17 +- fs/lustre/llite/llite_foreign.c | 26 +- fs/lustre/llite/llite_foreign_symlink.c | 10 +- fs/lustre/llite/llite_internal.h | 19 +- fs/lustre/llite/llite_lib.c | 247 ++++++++--------- fs/lustre/llite/namei.c | 43 +-- fs/lustre/lmv/lmv_intent.c | 21 +- fs/lustre/lmv/lmv_internal.h | 16 +- fs/lustre/lmv/lmv_obd.c | 353 ++++++++++++++---------- fs/lustre/mdc/mdc_request.c | 45 +-- 14 files changed, 510 insertions(+), 435 deletions(-) diff --git a/fs/lustre/include/lustre_lmv.h b/fs/lustre/include/lustre_lmv.h index c3b55d4b63e0..58f9be40f97d 100644 --- a/fs/lustre/include/lustre_lmv.h +++ b/fs/lustre/include/lustre_lmv.h @@ -55,31 +55,39 @@ struct lmv_stripe_md { struct lmv_oinfo lsm_md_oinfo[0]; }; -static inline bool lmv_dir_striped(const struct lmv_stripe_md *lsm) +struct lmv_stripe_object { + atomic_t lso_refs; + union { + struct lmv_stripe_md lso_lsm; + struct lmv_foreign_md lso_lfm; + }; +}; + +static inline bool lmv_dir_striped(const struct lmv_stripe_object *lso) { - return lsm && lsm->lsm_md_magic == LMV_MAGIC; + return lso && lso->lso_lsm.lsm_md_magic == LMV_MAGIC; } -static inline bool lmv_dir_foreign(const struct lmv_stripe_md *lsm) +static inline bool lmv_dir_foreign(const struct lmv_stripe_object *lso) { - return lsm && lsm->lsm_md_magic == LMV_MAGIC_FOREIGN; + return lso && lso->lso_lsm.lsm_md_magic == LMV_MAGIC_FOREIGN; } -static inline bool lmv_dir_layout_changing(const struct lmv_stripe_md *lsm) +static inline bool lmv_dir_layout_changing(const struct lmv_stripe_object *lso) { - return lmv_dir_striped(lsm) && - lmv_hash_is_layout_changing(lsm->lsm_md_hash_type); + return lmv_dir_striped(lso) && + lmv_hash_is_layout_changing(lso->lso_lsm.lsm_md_hash_type); } -static inline bool lmv_dir_bad_hash(const struct lmv_stripe_md *lsm) +static inline bool lmv_dir_bad_hash(const struct lmv_stripe_object *lso) { - if (!lmv_dir_striped(lsm)) + if (!lmv_dir_striped(lso)) return false; - if (lsm->lsm_md_hash_type & LMV_HASH_FLAG_BAD_TYPE) + if (lso->lso_lsm.lsm_md_hash_type & LMV_HASH_FLAG_BAD_TYPE) return true; - return !lmv_is_known_hash_type(lsm->lsm_md_hash_type); + return !lmv_is_known_hash_type(lso->lso_lsm.lsm_md_hash_type); } static inline u8 lmv_inherit_next(u8 inherit) @@ -109,9 +117,11 @@ static inline bool lmv_is_inheritable(u8 inherit) (inherit > LMV_INHERIT_END && inherit <= LMV_INHERIT_MAX); } -static inline bool -lsm_md_eq(const struct lmv_stripe_md *lsm1, const struct lmv_stripe_md *lsm2) +static inline bool lsm_md_eq(const struct lmv_stripe_object *lso1, + const struct lmv_stripe_object *lso2) { + const struct lmv_stripe_md *lsm1 = &lso1->lso_lsm; + const struct lmv_stripe_md *lsm2 = &lso2->lso_lsm; u32 idx; if (lsm1->lsm_md_magic != lsm2->lsm_md_magic || @@ -129,7 +139,7 @@ lsm_md_eq(const struct lmv_stripe_md *lsm1, const struct lmv_stripe_md *lsm2) sizeof(lsm1->lsm_md_pool_name)) != 0) return false; - if (lmv_dir_striped(lsm1)) { + if (lmv_dir_striped(lso1)) { for (idx = 0; idx < lsm1->lsm_md_stripe_count; idx++) { if (!lu_fid_eq(&lsm1->lsm_md_oinfo[idx].lmo_fid, &lsm2->lsm_md_oinfo[idx].lmo_fid)) @@ -146,14 +156,16 @@ lsm_md_eq(const struct lmv_stripe_md *lsm1, const struct lmv_stripe_md *lsm2) return true; } -static inline void lsm_md_dump(int mask, const struct lmv_stripe_md *lsm) +static inline void +lmv_stripe_object_dump(int mask, const struct lmv_stripe_object *lsmo) { + const struct lmv_stripe_md *lsm = &lsmo->lso_lsm; int i; CDEBUG_LIMIT(mask, - "dump LMV: magic=%#x count=%u index=%u hash=%s:%#x max_inherit=%hhu max_inherit_rr=%hhu version=%u migrate_offset=%u migrate_hash=%s:%x pool=%.*s\n", - lsm->lsm_md_magic, lsm->lsm_md_stripe_count, - lsm->lsm_md_master_mdt_index, + "dump LMV: refs %u magic=%#x count=%u index=%u hash=%s:%#x max_inherit=%hhu max_inherit_rr=%hhu version=%u migrate_offset=%u migrate_hash=%s:%x pool=%.*s\n", + lsm->lsm_md_magic, atomic_read(&lsmo->lso_refs), + lsm->lsm_md_stripe_count, lsm->lsm_md_master_mdt_index, lmv_is_known_hash_type(lsm->lsm_md_hash_type) ? mdt_hash_name[lsm->lsm_md_hash_type & LMV_HASH_TYPE_MASK] : "invalid", lsm->lsm_md_hash_type, @@ -164,7 +176,7 @@ static inline void lsm_md_dump(int mask, const struct lmv_stripe_md *lsm) "invalid", lsm->lsm_md_migrate_hash, LOV_MAXPOOLNAME, lsm->lsm_md_pool_name); - if (!lmv_dir_striped(lsm)) + if (!lmv_dir_striped(lsmo)) return; for (i = 0; i < lsm->lsm_md_stripe_count; i++) @@ -173,24 +185,34 @@ static inline void lsm_md_dump(int mask, const struct lmv_stripe_md *lsm) } static inline bool -lsm_md_inherited(const struct lmv_stripe_md *plsm, - const struct lmv_stripe_md *clsm) +lmv_object_inherited(const struct lmv_stripe_object *plsm, + const struct lmv_stripe_object *clsm) { return plsm && clsm && - plsm->lsm_md_magic == clsm->lsm_md_magic && - plsm->lsm_md_stripe_count == clsm->lsm_md_stripe_count && - plsm->lsm_md_master_mdt_index == - clsm->lsm_md_master_mdt_index && - plsm->lsm_md_hash_type == clsm->lsm_md_hash_type && - lmv_inherit_next(plsm->lsm_md_max_inherit) == - clsm->lsm_md_max_inherit && - lmv_inherit_rr_next(plsm->lsm_md_max_inherit_rr) == - clsm->lsm_md_max_inherit_rr; + plsm->lso_lsm.lsm_md_magic == + clsm->lso_lsm.lsm_md_magic && + plsm->lso_lsm.lsm_md_stripe_count == + clsm->lso_lsm.lsm_md_stripe_count && + plsm->lso_lsm.lsm_md_master_mdt_index == + clsm->lso_lsm.lsm_md_master_mdt_index && + plsm->lso_lsm.lsm_md_hash_type == + clsm->lso_lsm.lsm_md_hash_type && + lmv_inherit_next(plsm->lso_lsm.lsm_md_max_inherit) == + clsm->lso_lsm.lsm_md_max_inherit && + lmv_inherit_rr_next(plsm->lso_lsm.lsm_md_max_inherit_rr) == + clsm->lso_lsm.lsm_md_max_inherit_rr; } union lmv_mds_md; -void lmv_free_memmd(struct lmv_stripe_md *lsm); +struct lmv_stripe_object *lmv_stripe_object_alloc(u32 magic, + const union lmv_mds_md *lmm, + size_t lmm_size); + +void lmv_stripe_object_put(struct lmv_stripe_object **lsm_obj); + +struct lmv_stripe_object * + lmv_stripe_object_get(struct lmv_stripe_object *lsm_obj); static inline void lmv1_le_to_cpu(struct lmv_mds_md_v1 *lmv_dst, const struct lmv_mds_md_v1 *lmv_src) diff --git a/fs/lustre/include/obd.h b/fs/lustre/include/obd.h index 604739ca92c2..8f6d42544711 100644 --- a/fs/lustre/include/obd.h +++ b/fs/lustre/include/obd.h @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -759,11 +760,9 @@ struct md_op_data { s64 op_mod_time; const char *op_name; size_t op_namelen; - struct rw_semaphore *op_mea1_sem; - struct rw_semaphore *op_mea2_sem; - struct lmv_stripe_md *op_mea1; - struct lmv_stripe_md *op_mea2; - struct lmv_stripe_md *op_default_mea1; /* default LMV */ + struct lmv_stripe_object *op_lso1; + struct lmv_stripe_object *op_lso2; + struct lmv_stripe_object *op_default_lso1; /* default LMV */ u32 op_suppgids[2]; u32 op_fsuid; u32 op_fsgid; @@ -1020,11 +1019,8 @@ struct obd_ops { struct lustre_md { struct mdt_body *body; struct lu_buf layout; - union { - struct lmv_stripe_md *lmv; - struct lmv_foreign_md *lfm; - }; - struct lmv_stripe_md *default_lmv; + struct lmv_stripe_object *lsm_obj; + struct lmv_stripe_object *def_lsm_obj; #ifdef CONFIG_LUSTRE_FS_POSIX_ACL struct posix_acl *posix_acl; #endif @@ -1123,10 +1119,10 @@ struct md_ops { struct obd_export *, struct obd_export *, struct lustre_md *); - int (*free_lustre_md)(struct obd_export *, struct lustre_md *); + int (*put_lustre_md)(struct obd_export *, struct lustre_md *); int (*merge_attr)(struct obd_export *exp, - const struct lmv_stripe_md *lsm, + const struct lmv_stripe_object *, struct cl_attr *attr, ldlm_blocking_callback); int (*set_open_replay_data)(struct obd_export *, @@ -1147,7 +1143,7 @@ struct md_ops { enum ldlm_cancel_flags flags, void *opaque); int (*get_fid_from_lsm)(struct obd_export *, - const struct lmv_stripe_md *, + const struct lmv_stripe_object *, const char *name, int namelen, struct lu_fid *fid); @@ -1157,8 +1153,10 @@ struct md_ops { int (*revalidate_lock)(struct obd_export *, struct lookup_intent *, struct lu_fid *, u64 *bits); - int (*unpackmd)(struct obd_export *exp, struct lmv_stripe_md **plsm, - const union lmv_mds_md *lmv, size_t lmv_size); + int (*stripe_object_create)(struct obd_export *exp, + struct lmv_stripe_object **plso, + const union lmv_mds_md *lmv, + size_t lmv_size); int (*rmfid)(struct obd_export *exp, struct fid_array *fa, int *rcs, struct ptlrpc_request_set *set); struct lu_batch *(*batch_create)(struct obd_export *exp, diff --git a/fs/lustre/include/obd_class.h b/fs/lustre/include/obd_class.h index f8ae45b6e986..a6a554ce6af7 100644 --- a/fs/lustre/include/obd_class.h +++ b/fs/lustre/include/obd_class.h @@ -1446,8 +1446,8 @@ static inline int md_get_lustre_md(struct obd_export *exp, return MDP(exp->exp_obd, get_lustre_md)(exp, pill, dt_exp, md_exp, md); } -static inline int md_free_lustre_md(struct obd_export *exp, - struct lustre_md *md) +static inline int md_put_lustre_md(struct obd_export *exp, + struct lustre_md *md) { int rc; @@ -1455,11 +1455,11 @@ static inline int md_free_lustre_md(struct obd_export *exp, if (rc) return rc; - return MDP(exp->exp_obd, free_lustre_md)(exp, md); + return MDP(exp->exp_obd, put_lustre_md)(exp, md); } static inline int md_merge_attr(struct obd_export *exp, - const struct lmv_stripe_md *lsm, + const struct lmv_stripe_object *lso, struct cl_attr *attr, ldlm_blocking_callback cb) { @@ -1469,7 +1469,7 @@ static inline int md_merge_attr(struct obd_export *exp, if (rc) return rc; - return MDP(exp->exp_obd, merge_attr)(exp, lsm, attr, cb); + return MDP(exp->exp_obd, merge_attr)(exp, lso, attr, cb); } static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid, @@ -1625,7 +1625,7 @@ static inline int md_revalidate_lock(struct obd_export *exp, } static inline int md_get_fid_from_lsm(struct obd_export *exp, - const struct lmv_stripe_md *lsm, + const struct lmv_stripe_object *lso, const char *name, int namelen, struct lu_fid *fid) { @@ -1635,7 +1635,8 @@ static inline int md_get_fid_from_lsm(struct obd_export *exp, if (rc) return rc; - return MDP(exp->exp_obd, get_fid_from_lsm)(exp, lsm, name, namelen, fid); + return MDP(exp->exp_obd, get_fid_from_lsm)(exp, lso, name, namelen, + fid); } /* @@ -1645,9 +1646,10 @@ static inline int md_get_fid_from_lsm(struct obd_export *exp, * If *plsm != NULL and lmm == NULL then *lsm will be freed. * If *plsm == NULL then it will be allocated. */ -static inline int md_unpackmd(struct obd_export *exp, - struct lmv_stripe_md **plsm, - const union lmv_mds_md *lmm, size_t lmm_size) +static inline int md_stripe_object_create(struct obd_export *exp, + struct lmv_stripe_object **lsop, + const union lmv_mds_md *lmm, + size_t lmm_size) { int rc; @@ -1655,7 +1657,7 @@ static inline int md_unpackmd(struct obd_export *exp, if (rc) return rc; - return MDP(exp->exp_obd, unpackmd)(exp, plsm, lmm, lmm_size); + return MDP(exp->exp_obd, stripe_object_create)(exp, lsop, lmm, lmm_size); } static inline int md_rmfid(struct obd_export *exp, struct fid_array *fa, diff --git a/fs/lustre/llite/dir.c b/fs/lustre/llite/dir.c index b628e11e759c..2e43e31c5cd0 100644 --- a/fs/lustre/llite/dir.c +++ b/fs/lustre/llite/dir.c @@ -167,8 +167,7 @@ void ll_release_page(struct inode *inode, struct page *page, bool remove) /* Always remove the page for striped dir, because the page is * built from temporarily in LMV layer */ - if (inode && S_ISDIR(inode->i_mode) && - lmv_dir_striped(ll_i2info(inode)->lli_lsm_md)) { + if (inode && ll_dir_striped(inode)) { __free_page(page); return; } @@ -362,8 +361,7 @@ static int ll_readdir(struct file *filp, struct dir_context *ctx) } /* foreign dirs are browsed out of Lustre */ - if (unlikely(op_data->op_mea1 && - op_data->op_mea1->lsm_md_magic == LMV_MAGIC_FOREIGN)) { + if (unlikely(lmv_dir_foreign(op_data->op_lso1))) { ll_finish_md_op_data(op_data); return -ENODATA; } @@ -656,9 +654,9 @@ static int ll_dir_get_default_lmv(struct inode *inode, struct lmv_user_md *lum) int rc = -ENODATA; retry: - if (lli->lli_default_lsm_md) { + if (lli->lli_def_lsm_obj) { down_read(&lli->lli_lsm_sem); - lsm = lli->lli_default_lsm_md; + lsm = &lli->lli_def_lsm_obj->lso_lsm; if (lsm) { lum->lum_magic = lsm->lsm_md_magic; lum->lum_stripe_count = lsm->lsm_md_stripe_count; @@ -1984,7 +1982,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) * instead of the client. */ if (cmd == LL_IOC_MDC_GETINFO_V2 && - ll_i2info(inode)->lli_lsm_md) + ll_dir_striped(inode)) valid &= ~(OBD_MD_FLSIZE | OBD_MD_FLBLOCKS); if (flagsp && copy_to_user(flagsp, &valid, diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c index 48c4245d61b3..881beb1c887f 100644 --- a/fs/lustre/llite/file.c +++ b/fs/lustre/llite/file.c @@ -5043,7 +5043,7 @@ int ll_migrate(struct inode *parent, struct file *file, struct lmv_user_md *lum, /* migrate dirent only for subdirs if MDS_MIGRATE_NSONLY set */ if (S_ISDIR(child_inode->i_mode) && (flags & MDS_MIGRATE_NSONLY) && - lmv_dir_layout_changing(ll_i2info(parent)->lli_lsm_md)) + lmv_dir_layout_changing(op_data->op_lso1)) op_data->op_bias |= MDS_MIGRATE_NSONLY; again: @@ -5294,18 +5294,21 @@ static int ll_inode_revalidate(struct dentry *dentry, enum ldlm_intent_flags op) static int ll_merge_md_attr(struct inode *inode) { struct ll_inode_info *lli = ll_i2info(inode); + struct lmv_stripe_object *lsm_obj; struct cl_attr attr = { 0 }; int rc; - LASSERT(lli->lli_lsm_md); - - if (!lmv_dir_striped(lli->lli_lsm_md)) + if (!ll_dir_striped(inode)) return 0; down_read(&lli->lli_lsm_sem); - rc = md_merge_attr(ll_i2mdexp(inode), lli->lli_lsm_md, &attr, - ll_md_blocking_ast); + LASSERT(lli->lli_lsm_obj); + lsm_obj = lmv_stripe_object_get(lli->lli_lsm_obj); up_read(&lli->lli_lsm_sem); + + rc = md_merge_attr(ll_i2mdexp(inode), lsm_obj, + &attr, ll_md_blocking_ast); + lmv_stripe_object_put(&lsm_obj); if (rc) return rc; @@ -5403,7 +5406,7 @@ int ll_getattr_dentry(struct dentry *de, struct kstat *stat, u32 request_mask, } else { /* If object isn't regular a file then don't validate size. */ /* foreign dir is not striped dir */ - if (ll_dir_striped(inode) && !foreign) { + if (!foreign) { rc = ll_merge_md_attr(inode); if (rc < 0) return rc; diff --git a/fs/lustre/llite/llite_foreign.c b/fs/lustre/llite/llite_foreign.c index ed958f50762c..5f8f2e67c8ae 100644 --- a/fs/lustre/llite/llite_foreign.c +++ b/fs/lustre/llite/llite_foreign.c @@ -117,17 +117,16 @@ int ll_manage_foreign(struct inode *inode, struct lustre_md *lmd) cl_env_put(env, &refcheck); } } else if (S_ISDIR((inode)->i_mode)) { - if (lmd->lfm && - lmd->lfm->lfm_magic == LMV_MAGIC_FOREIGN) { - ll_manage_foreign_dir(inode, lmd->lfm); + if (lmv_dir_foreign(lmd->lsm_obj)) { + ll_manage_foreign_dir(inode, &lmd->lsm_obj->lso_lfm); } else { struct ll_inode_info *lli = ll_i2info(inode); - struct lmv_foreign_md *lfm; + struct lmv_stripe_object *lsm_obj; down_read(&lli->lli_lsm_sem); - lfm = (struct lmv_foreign_md *)(lli->lli_lsm_md); - if (lfm && lfm->lfm_magic == LMV_MAGIC_FOREIGN) - ll_manage_foreign_dir(inode, lfm); + lsm_obj = lli->lli_lsm_obj; + if (lmv_dir_foreign(lsm_obj)) + ll_manage_foreign_dir(inode, &lsm_obj->lso_lfm); up_read(&lli->lli_lsm_sem); } } @@ -256,18 +255,19 @@ bool ll_foreign_is_removable(struct dentry *dentry, bool unset) } } else if (S_ISDIR(inode->i_mode)) { struct ll_inode_info *lli = ll_i2info(inode); - struct lmv_foreign_md *lfm; + struct lmv_stripe_object *lsm_obj; down_read(&lli->lli_lsm_sem); - lfm = (struct lmv_foreign_md *)(lli->lli_lsm_md); - if (!lfm) + lsm_obj = lli->lli_lsm_obj; + if (!lsm_obj) CDEBUG(D_INFO, "unable to check if dir (%.*s, "DFID") is foreign...\n", name->len, name->name, PFID(ll_inode2fid(inode))); - else if (lfm->lfm_magic == LMV_MAGIC_FOREIGN) - preserve_foreign = should_preserve_foreign_dir(lfm, lli, - unset); + else if (lmv_dir_foreign(lsm_obj)) + preserve_foreign = + should_preserve_foreign_dir(&lsm_obj->lso_lfm, + lli, unset); up_read(&lli->lli_lsm_sem); if (preserve_foreign) { CDEBUG(D_INFO, diff --git a/fs/lustre/llite/llite_foreign_symlink.c b/fs/lustre/llite/llite_foreign_symlink.c index 64bc5db8b291..e9564f71ece8 100644 --- a/fs/lustre/llite/llite_foreign_symlink.c +++ b/fs/lustre/llite/llite_foreign_symlink.c @@ -221,6 +221,7 @@ static int ll_foreign_readlink_internal(struct inode *inode, char **symname) { struct ll_inode_info *lli = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); + struct lmv_stripe_object *lsm_obj = NULL; struct lov_foreign_md *lfm = NULL; char *destname = NULL; size_t lfm_size = 0; @@ -279,8 +280,11 @@ static int ll_foreign_readlink_internal(struct inode *inode, char **symname) * and LMV formats are identical, and then we also only need * one set of parsing routines for both foreign files and dirs! */ - lfm = (struct lov_foreign_md *)(lli->lli_lsm_md); - if (lfm) { + lsm_obj = lmv_stripe_object_get(lli->lli_lsm_obj); + up_read(&lli->lli_lsm_sem); + + if (lsm_obj) { + lfm = (struct lov_foreign_md *)&lsm_obj->lso_lfm; CDEBUG(D_INFO, "%s: inode "DFID": LMV cached found\n", sbi->ll_fsname, PFID(ll_inode2fid(inode))); } else { @@ -301,7 +305,7 @@ static int ll_foreign_readlink_internal(struct inode *inode, char **symname) rc = ll_foreign_symlink_parse(sbi, inode, lfm, &destname); failed: if (S_ISDIR(inode->i_mode)) - up_read(&lli->lli_lsm_sem); + lmv_stripe_object_put(&lsm_obj); if (S_ISREG(inode->i_mode) && lfm) kfree(lfm); diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h index 2db240f07b83..9c11cf198864 100644 --- a/fs/lustre/llite/llite_internal.h +++ b/fs/lustre/llite/llite_internal.h @@ -202,15 +202,15 @@ struct ll_inode_info { * is for old server, or default LMV is set by * "lfs setdirstripe -D". */ - lli_default_lmv_set:1; + lli_def_lsm_obj_set:1; /* generation for statahead */ unsigned int lli_sa_generation; /* rw lock protects lli_lsm_md */ struct rw_semaphore lli_lsm_sem; /* directory stripe information */ - struct lmv_stripe_md *lli_lsm_md; + struct lmv_stripe_object *lli_lsm_obj; /* directory default LMV */ - struct lmv_stripe_md *lli_default_lsm_md; + struct lmv_stripe_object *lli_def_lsm_obj; }; /* for non-directory */ @@ -1502,9 +1502,18 @@ static inline struct lu_fid *ll_inode2fid(struct inode *inode) static inline bool ll_dir_striped(struct inode *inode) { + bool rc; LASSERT(inode); - return S_ISDIR(inode->i_mode) && - lmv_dir_striped(ll_i2info(inode)->lli_lsm_md); + + if (!S_ISDIR(inode->i_mode)) + return false; + + down_read(&ll_i2info(inode)->lli_lsm_sem); + rc = !!(ll_i2info(inode)->lli_lsm_obj && + lmv_dir_striped(ll_i2info(inode)->lli_lsm_obj)); + up_read(&ll_i2info(inode)->lli_lsm_sem); + + return rc; } static inline loff_t ll_file_maxbytes(struct inode *inode) diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c index 39b8074bd306..3455622f4ba2 100644 --- a/fs/lustre/llite/llite_lib.c +++ b/fs/lustre/llite/llite_lib.c @@ -712,7 +712,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) LASSERT(fid_is_sane(&sbi->ll_root_fid)); api32 = test_bit(LL_SBI_32BIT_API, sbi->ll_flags); root = ll_iget(sb, cl_fid_build_ino(&sbi->ll_root_fid, api32), &lmd); - md_free_lustre_md(sbi->ll_md_exp, &lmd); + md_put_lustre_md(sbi->ll_md_exp, &lmd); if (IS_ERR(root)) { lmd_clear_acl(&lmd); @@ -1487,16 +1487,10 @@ void ll_dir_clear_lsm_md(struct inode *inode) struct ll_inode_info *lli = ll_i2info(inode); LASSERT(S_ISDIR(inode->i_mode)); - - if (lli->lli_lsm_md) { - lmv_free_memmd(lli->lli_lsm_md); - lli->lli_lsm_md = NULL; - } - - if (lli->lli_default_lsm_md) { - lmv_free_memmd(lli->lli_default_lsm_md); - lli->lli_default_lsm_md = NULL; - } + down_write(&lli->lli_lsm_sem); + lmv_stripe_object_put(&lli->lli_lsm_obj); + lmv_stripe_object_put(&lli->lli_def_lsm_obj); + up_write(&lli->lli_lsm_sem); } static struct inode *ll_iget_anon_dir(struct super_block *sb, @@ -1509,7 +1503,7 @@ static struct inode *ll_iget_anon_dir(struct super_block *sb, struct inode *inode; ino_t ino; - LASSERT(md->lmv); + LASSERT(md->lsm_obj); ino = cl_fid_build_ino(fid, test_bit(LL_SBI_32BIT_API, sbi->ll_flags)); inode = iget_locked(sb, ino); if (!inode) { @@ -1553,18 +1547,19 @@ static struct inode *ll_iget_anon_dir(struct super_block *sb, static int ll_init_lsm_md(struct inode *inode, struct lustre_md *md) { - struct lmv_stripe_md *lsm = md->lmv; + struct lmv_stripe_md *lsm; struct ll_inode_info *lli = ll_i2info(inode); struct lu_fid *fid; int i; - LASSERT(lsm); + LASSERT(md->lsm_obj); + lsm = &md->lsm_obj->lso_lsm; CDEBUG(D_INODE, "%s: "DFID" set dir layout:\n", ll_i2sbi(inode)->ll_fsname, PFID(&lli->lli_fid)); - lsm_md_dump(D_INODE, lsm); + lmv_stripe_object_dump(D_INODE, md->lsm_obj); - if (!lmv_dir_striped(lsm)) + if (!lmv_dir_striped(md->lsm_obj)) goto out; /* @@ -1598,36 +1593,36 @@ static int ll_init_lsm_md(struct inode *inode, struct lustre_md *md) } } out: - lli->lli_lsm_md = lsm; - + /* move lsm_obj to lli */ + lli->lli_lsm_obj = md->lsm_obj; + md->lsm_obj = NULL; return 0; } static void ll_update_default_lsm_md(struct inode *inode, struct lustre_md *md) { + struct lmv_stripe_object *lsm_obj = md->def_lsm_obj; struct ll_inode_info *lli = ll_i2info(inode); - if (!md->default_lmv) { + if (!lsm_obj) { /* clear default lsm */ - if (lli->lli_default_lsm_md && lli->lli_default_lmv_set) { + if (lli->lli_def_lsm_obj && lli->lli_def_lsm_obj_set) { down_write(&lli->lli_lsm_sem); - if (lli->lli_default_lsm_md && - lli->lli_default_lmv_set) { - lmv_free_memmd(lli->lli_default_lsm_md); - lli->lli_default_lsm_md = NULL; + if (lli->lli_def_lsm_obj_set) { + lmv_stripe_object_put(&lli->lli_def_lsm_obj); lli->lli_inherit_depth = 0; - lli->lli_default_lmv_set = 0; + lli->lli_def_lsm_obj_set = 0; } up_write(&lli->lli_lsm_sem); } return; } - if (lli->lli_default_lsm_md) { + if (lli->lli_def_lsm_obj) { /* do nonthing if default lsm isn't changed */ down_read(&lli->lli_lsm_sem); - if (lli->lli_default_lsm_md && - lsm_md_eq(lli->lli_default_lsm_md, md->default_lmv)) { + if (lli->lli_def_lsm_obj && + lsm_md_eq(lli->lli_def_lsm_obj, lsm_obj)) { up_read(&lli->lli_lsm_sem); return; } @@ -1635,28 +1630,28 @@ static void ll_update_default_lsm_md(struct inode *inode, struct lustre_md *md) } down_write(&lli->lli_lsm_sem); - if (lli->lli_default_lsm_md) - lmv_free_memmd(lli->lli_default_lsm_md); - lli->lli_default_lsm_md = md->default_lmv; - lli->lli_default_lmv_set = 1; - lsm_md_dump(D_INODE, md->default_lmv); - md->default_lmv = NULL; + /* update default lsm. */ + lmv_stripe_object_put(&lli->lli_def_lsm_obj); + lli->lli_def_lsm_obj = lsm_obj; + lli->lli_def_lsm_obj_set = 1; + lmv_stripe_object_dump(D_INODE, lsm_obj); + md->def_lsm_obj = NULL; up_write(&lli->lli_lsm_sem); } static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md) { + struct lmv_stripe_object *lsm_obj = md->lsm_obj; struct ll_inode_info *lli = ll_i2info(inode); - struct lmv_stripe_md *lsm = md->lmv; - struct cl_attr *attr; + struct cl_attr *attr; int rc = 0; LASSERT(S_ISDIR(inode->i_mode)); - CDEBUG(D_INODE, "update lsm %p of " DFID "\n", lli->lli_lsm_md, + CDEBUG(D_INODE, "update lsm_obj %p of "DFID"\n", lli->lli_lsm_obj, PFID(ll_inode2fid(inode))); /* update default LMV */ - if (md->default_lmv) + if (md->def_lsm_obj) ll_update_default_lsm_md(inode, md); /* after dir migration/restripe, a stripe may be turned into a @@ -1669,7 +1664,7 @@ static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md) * no striped information from request, lustre_md from req does not * include stripeEA, see ll_md_setattr() */ - if (!lsm) + if (!lsm_obj) return 0; /* @@ -1679,8 +1674,19 @@ static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md) down_read(&lli->lli_lsm_sem); /* some current lookup initialized lsm, and unchanged */ - if (lli->lli_lsm_md && lsm_md_eq(lli->lli_lsm_md, lsm)) + if (lli->lli_lsm_obj && lsm_md_eq(lli->lli_lsm_obj, lsm_obj)) { + up_read(&lli->lli_lsm_sem); + return 0; + } + + up_read(&lli->lli_lsm_sem); + down_write(&lli->lli_lsm_sem); + + /* check again in case of a race */ + if (lli->lli_lsm_obj && lsm_md_eq(lli->lli_lsm_obj, lsm_obj)) { + rc = 0; goto unlock; + } /* if dir layout doesn't match, check whether version is increased, * which means layout is changed, this happens in dir split/merge and @@ -1688,52 +1694,40 @@ static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md) * * foreign LMV should not change. */ - if (lli->lli_lsm_md && lmv_dir_striped(lli->lli_lsm_md) && - lsm->lsm_md_layout_version <= - lli->lli_lsm_md->lsm_md_layout_version) { + if (lli->lli_lsm_obj && lmv_dir_striped(lli->lli_lsm_obj) && + lsm_obj->lso_lsm.lsm_md_layout_version <= + lli->lli_lsm_obj->lso_lsm.lsm_md_layout_version) { CERROR("%s: " DFID " dir layout mismatch:\n", ll_i2sbi(inode)->ll_fsname, PFID(&lli->lli_fid)); - lsm_md_dump(D_ERROR, lli->lli_lsm_md); - lsm_md_dump(D_ERROR, lsm); + lmv_stripe_object_dump(D_ERROR, lli->lli_lsm_obj); + lmv_stripe_object_dump(D_ERROR, lsm_obj); rc = -EINVAL; goto unlock; } - up_read(&lli->lli_lsm_sem); - down_write(&lli->lli_lsm_sem); /* clear existing lsm */ - if (lli->lli_lsm_md) { - lmv_free_memmd(lli->lli_lsm_md); - lli->lli_lsm_md = NULL; - } + lmv_stripe_object_put(&lli->lli_lsm_obj); rc = ll_init_lsm_md(inode, md); - up_write(&lli->lli_lsm_sem); - if (rc) - return rc; - - /* set md->lmv to NULL, so the following free lustre_md will not free - * this lsm. - */ - md->lmv = NULL; - - /* md_merge_attr() may take long, since lsm is already set, switch to - * read lock. - */ - down_read(&lli->lli_lsm_sem); + goto unlock; - if (!lmv_dir_striped(lli->lli_lsm_md)) + if (!lmv_dir_striped(lli->lli_lsm_obj)) { + rc = 0; goto unlock; + } + + lsm_obj = lmv_stripe_object_get(lli->lli_lsm_obj); + up_write(&lli->lli_lsm_sem); attr = kzalloc(sizeof(*attr), GFP_NOFS); if (!attr) { rc = -ENOMEM; - goto unlock; + goto err; } /* validate the lsm */ - rc = md_merge_attr(ll_i2mdexp(inode), lli->lli_lsm_md, attr, + rc = md_merge_attr(ll_i2mdexp(inode), lsm_obj, attr, ll_md_blocking_ast); if (!rc) { if (md->body->mbo_valid & OBD_MD_FLNLINK) @@ -1749,9 +1743,11 @@ static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md) } kfree(attr); +err: + lmv_stripe_object_put(&lsm_obj); + return rc; unlock: - up_read(&lli->lli_lsm_sem); - + up_write(&lli->lli_lsm_sem); return rc; } @@ -1874,6 +1870,7 @@ static int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data) rc = ll_update_inode(inode, &md); ptlrpc_req_finished(request); + md_put_lustre_md(sbi->ll_md_exp, &md); return rc; } @@ -2757,8 +2754,8 @@ static int ll_dir_default_lmv_inherit(struct inode *dir, struct inode *inode) { struct ll_inode_info *plli = ll_i2info(dir); struct ll_inode_info *lli = ll_i2info(inode); - struct lmv_stripe_md *plsm; - struct lmv_stripe_md *lsm; + struct lmv_stripe_object *plsm_obj; + struct lmv_stripe_object *lsm_obj; int rc = 0; /* ROOT default LMV is not inherited */ @@ -2768,25 +2765,24 @@ static int ll_dir_default_lmv_inherit(struct inode *dir, struct inode *inode) return 0; /* nothing to do if no default LMV on both */ - if (!plli->lli_default_lsm_md && !lli->lli_default_lsm_md) + if (!plli->lli_def_lsm_obj && !lli->lli_def_lsm_obj) return 0; /* subdir default LMV comes from disk */ - if (lli->lli_default_lsm_md && lli->lli_default_lmv_set) + if (lli->lli_def_lsm_obj && lli->lli_def_lsm_obj_set) return 0; /* delete subdir default LMV if parent's is deleted or becomes * uninheritable. */ down_read(&plli->lli_lsm_sem); - plsm = plli->lli_default_lsm_md; - if (!plsm || !lmv_is_inheritable(plsm->lsm_md_max_inherit)) { - if (lli->lli_default_lsm_md && !lli->lli_default_lmv_set) { + plsm_obj = plli->lli_def_lsm_obj; + if (!plsm_obj || + !lmv_is_inheritable(plsm_obj->lso_lsm.lsm_md_max_inherit)) { + if (lli->lli_def_lsm_obj && !lli->lli_def_lsm_obj_set) { down_write(&lli->lli_lsm_sem); - if (lli->lli_default_lsm_md && - !lli->lli_default_lmv_set) { - lmv_free_memmd(lli->lli_default_lsm_md); - lli->lli_default_lsm_md = NULL; + if (!lli->lli_def_lsm_obj_set) { + lmv_stripe_object_put(&lli->lli_def_lsm_obj); lli->lli_inherit_depth = 0; } up_write(&lli->lli_lsm_sem); @@ -2796,11 +2792,12 @@ static int ll_dir_default_lmv_inherit(struct inode *dir, struct inode *inode) } /* do nothing if inherited LMV is unchanged */ - if (lli->lli_default_lsm_md) { + if (lli->lli_def_lsm_obj) { rc = 1; down_read(&lli->lli_lsm_sem); - if (!lli->lli_default_lmv_set) - rc = lsm_md_inherited(plsm, lli->lli_default_lsm_md); + if (!lli->lli_def_lsm_obj_set) + rc = lmv_object_inherited(plsm_obj, + lli->lli_def_lsm_obj); up_read(&lli->lli_lsm_sem); if (rc == 1) { rc = 0; @@ -2810,31 +2807,31 @@ static int ll_dir_default_lmv_inherit(struct inode *dir, struct inode *inode) /* inherit default LMV */ down_write(&lli->lli_lsm_sem); - if (lli->lli_default_lsm_md) { + if (lli->lli_def_lsm_obj) { /* checked above, but in case of race, check again with lock */ - if (lli->lli_default_lmv_set) { + if (lli->lli_def_lsm_obj_set) { rc = 0; goto unlock_child; } /* always update subdir default LMV in case parent's changed */ - lsm = lli->lli_default_lsm_md; + lsm_obj = lli->lli_def_lsm_obj; } else { - lsm = kzalloc(sizeof(*lsm), GFP_NOFS); - if (!lsm) { - rc = -ENOMEM; + lsm_obj = lmv_stripe_object_alloc(LMV_USER_MAGIC, NULL, 0); + if (IS_ERR(lsm_obj)) { + rc = PTR_ERR(lsm_obj); goto unlock_child; } - lli->lli_default_lsm_md = lsm; + lli->lli_def_lsm_obj = lsm_obj; } - *lsm = *plsm; - lsm->lsm_md_max_inherit = lmv_inherit_next(plsm->lsm_md_max_inherit); - lsm->lsm_md_max_inherit_rr = - lmv_inherit_rr_next(plsm->lsm_md_max_inherit_rr); + lsm_obj->lso_lsm = plsm_obj->lso_lsm; + lsm_obj->lso_lsm.lsm_md_max_inherit = + lmv_inherit_next(plsm_obj->lso_lsm.lsm_md_max_inherit); + lsm_obj->lso_lsm.lsm_md_max_inherit_rr = + lmv_inherit_rr_next(plsm_obj->lso_lsm.lsm_md_max_inherit_rr); lli->lli_inherit_depth = plli->lli_inherit_depth + 1; - lsm_md_dump(D_INODE, lsm); - + lmv_stripe_object_dump(D_INODE, lsm_obj); unlock_child: up_write(&lli->lli_lsm_sem); unlock_parent: @@ -2872,12 +2869,12 @@ void ll_update_dir_depth_dmv(struct inode *dir, struct dentry *de) plli = ll_i2info(dir); lli = ll_i2info(inode); lli->lli_dir_depth = plli->lli_dir_depth + 1; - if (lli->lli_default_lsm_md && lli->lli_default_lmv_set) { - if (plli->lli_default_lsm_md) { + if (lli->lli_def_lsm_obj && lli->lli_def_lsm_obj_set) { + if (plli->lli_def_lsm_obj) { down_read_nested(&plli->lli_lsm_sem, LSM_SEM_PARENT); down_read_nested(&lli->lli_lsm_sem, LSM_SEM_CHILD); - if (lsm_md_inherited(plli->lli_default_lsm_md, - lli->lli_default_lsm_md)) + if (lmv_object_inherited(plli->lli_def_lsm_obj, + lli->lli_def_lsm_obj)) lli->lli_inherit_depth = plli->lli_inherit_depth + 1; else @@ -2893,11 +2890,11 @@ void ll_update_dir_depth_dmv(struct inode *dir, struct dentry *de) ll_dir_default_lmv_inherit(dir, inode); } - if (lli->lli_default_lsm_md) + if (lli->lli_def_lsm_obj) CDEBUG(D_INODE, "%s "DFID" depth %hu %s default LMV inherit depth %hu\n", de->d_name.name, PFID(&lli->lli_fid), lli->lli_dir_depth, - lli->lli_default_lmv_set ? "server" : "client", + lli->lli_def_lsm_obj_set ? "server" : "client", lli->lli_inherit_depth); } @@ -3383,7 +3380,7 @@ static int ll_fileset_default_lmv_fixup(struct inode *inode, LASSERT(is_root_inode(inode)); LASSERT(!fid_is_root(&sbi->ll_root_fid)); - LASSERT(!md->default_lmv); + LASSERT(!md->def_lsm_obj); rc = ll_dir_get_default_layout(inode, (void **)&lmm, &size, &req, OBD_MD_DEFAULT_MEA, @@ -3393,7 +3390,8 @@ static int ll_fileset_default_lmv_fixup(struct inode *inode, rc = 0; if (lmm && size) { - rc = md_unpackmd(sbi->ll_md_exp, &md->default_lmv, lmm, size); + rc = md_stripe_object_create(sbi->ll_md_exp, &md->def_lsm_obj, + lmm, size); if (rc < 0) goto out; rc = 0; @@ -3425,7 +3423,7 @@ int ll_prep_inode(struct inode **inode, struct req_capsule *pill, * ll_update_lsm_md() may change md. */ if (it && (it->it_op & (IT_LOOKUP | IT_GETATTR)) && - S_ISDIR(md.body->mbo_mode) && !md.default_lmv) { + S_ISDIR(md.body->mbo_mode) && !md.def_lsm_obj) { if (unlikely(*inode && is_root_inode(*inode) && !fid_is_root(&sbi->ll_root_fid))) { rc = ll_fileset_default_lmv_fixup(*inode, &md); @@ -3433,7 +3431,7 @@ int ll_prep_inode(struct inode **inode, struct req_capsule *pill, goto out; } - if (!md.default_lmv) + if (!md.def_lsm_obj) default_lmv_deleted = true; } @@ -3504,7 +3502,7 @@ int ll_prep_inode(struct inode **inode, struct req_capsule *pill, rc = ll_manage_foreign(*inode, &md); out: /* cleanup will be done if necessary */ - md_free_lustre_md(sbi->ll_md_exp, &md); + md_put_lustre_md(sbi->ll_md_exp, &md); if (rc != 0 && it && it->it_op & IT_OPEN) { ll_intent_drop_lock(it); @@ -3575,15 +3573,9 @@ int ll_obd_statfs(struct inode *inode, void __user *uarg) */ void ll_unlock_md_op_lsm(struct md_op_data *op_data) { - if (op_data->op_mea2_sem) { - up_read_non_owner(op_data->op_mea2_sem); - op_data->op_mea2_sem = NULL; - } - - if (op_data->op_mea1_sem) { - up_read_non_owner(op_data->op_mea1_sem); - op_data->op_mea1_sem = NULL; - } + lmv_stripe_object_put(&op_data->op_lso2); + lmv_stripe_object_put(&op_data->op_lso1); + lmv_stripe_object_put(&op_data->op_default_lso1); } /* this function prepares md_op_data hint for passing ot down to MD stack. */ @@ -3631,24 +3623,21 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, op_data->op_fid1 = *ll_inode2fid(i1); if (S_ISDIR(i1->i_mode)) { - down_read_non_owner(&ll_i2info(i1)->lli_lsm_sem); - op_data->op_mea1_sem = &ll_i2info(i1)->lli_lsm_sem; - op_data->op_mea1 = ll_i2info(i1)->lli_lsm_md; - op_data->op_default_mea1 = ll_i2info(i1)->lli_default_lsm_md; + down_read(&ll_i2info(i1)->lli_lsm_sem); + op_data->op_lso1 = + lmv_stripe_object_get(ll_i2info(i1)->lli_lsm_obj); + op_data->op_default_lso1 = + lmv_stripe_object_get(ll_i2info(i1)->lli_def_lsm_obj); + up_read(&ll_i2info(i1)->lli_lsm_sem); } if (i2) { op_data->op_fid2 = *ll_inode2fid(i2); if (S_ISDIR(i2->i_mode)) { - if (i2 != i1) { - /* i2 is typically a child of i1, and MUST be - * further from the root to avoid deadlocks. - */ - down_read_non_owner(&ll_i2info(i2)->lli_lsm_sem); - op_data->op_mea2_sem = - &ll_i2info(i2)->lli_lsm_sem; - } - op_data->op_mea2 = ll_i2info(i2)->lli_lsm_md; + down_read(&ll_i2info(i2)->lli_lsm_sem); + op_data->op_lso2 = + lmv_stripe_object_get(ll_i2info(i2)->lli_lsm_obj); + up_read(&ll_i2info(i2)->lli_lsm_sem); } } else { fid_zero(&op_data->op_fid2); diff --git a/fs/lustre/llite/namei.c b/fs/lustre/llite/namei.c index 1d21626588ec..7b7f0b4e66a1 100644 --- a/fs/lustre/llite/namei.c +++ b/fs/lustre/llite/namei.c @@ -753,10 +753,12 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, /* If it is striped directory, get the real stripe parent */ if (unlikely(ll_dir_striped(parent))) { + down_read(&ll_i2info(parent)->lli_lsm_sem); rc = md_get_fid_from_lsm(ll_i2mdexp(parent), - ll_i2info(parent)->lli_lsm_md, + ll_i2info(parent)->lli_lsm_obj, (*de)->d_name.name, (*de)->d_name.len, &fid); + up_read(&ll_i2info(parent)->lli_lsm_sem); if (rc) return rc; } @@ -1482,11 +1484,11 @@ static void ll_qos_mkdir_prep(struct md_op_data *op_data, struct inode *dir) depth = lli->lli_dir_depth; /* parent directory is striped */ - if (unlikely(lli->lli_lsm_md)) + if (unlikely(ll_dir_striped(dir))) return; /* default LMV set on parent directory */ - if (unlikely(lli->lli_default_lsm_md)) + if (unlikely(lli->lli_def_lsm_obj)) return; /* parent is ROOT */ @@ -1494,13 +1496,13 @@ static void ll_qos_mkdir_prep(struct md_op_data *op_data, struct inode *dir) return; /* default LMV not set on ROOT */ - if (!rlli->lli_default_lsm_md) + if (!rlli->lli_def_lsm_obj) return; down_read(&rlli->lli_lsm_sem); - lsm = rlli->lli_default_lsm_md; - if (!lsm) + if (!rlli->lli_def_lsm_obj) goto unlock; + lsm = &rlli->lli_def_lsm_obj->lso_lsm; /* not space balanced */ if (lsm->lsm_md_master_mdt_index != LMV_OFFSET_DEFAULT) @@ -1562,7 +1564,7 @@ static int ll_new_node(struct inode *dir, struct dentry *dchild, ll_qos_mkdir_prep(op_data, dir); if ((exp_connect_flags2(ll_i2mdexp(dir)) & OBD_CONNECT2_DMV_IMP_INHERIT) && - op_data->op_default_mea1 && !lum) { + op_data->op_default_lso1 && !lum) { const struct lmv_stripe_md *lsm; /* once DMV_IMP_INHERIT is set, pack default LMV in @@ -1573,7 +1575,7 @@ static int ll_new_node(struct inode *dir, struct dentry *dchild, err = -ENOMEM; goto err_exit; } - lsm = op_data->op_default_mea1; + lsm = &op_data->op_default_lso1->lso_lsm; lum->lum_magic = cpu_to_le32(lsm->lsm_md_magic); lum->lum_stripe_count = cpu_to_le32(lsm->lsm_md_stripe_count); @@ -1685,37 +1687,38 @@ static int ll_new_node(struct inode *dir, struct dentry *dchild, goto err_exit; } - md.default_lmv = kzalloc(sizeof(*md.default_lmv), + md.def_lsm_obj = kzalloc(sizeof(*md.def_lsm_obj), GFP_NOFS); - if (!md.default_lmv) { + if (!md.def_lsm_obj) { err = -ENOMEM; goto err_exit; } - md.default_lmv->lsm_md_magic = lum->lum_magic; - md.default_lmv->lsm_md_stripe_count = + md.def_lsm_obj->lso_lsm.lsm_md_magic = lum->lum_magic; + md.def_lsm_obj->lso_lsm.lsm_md_stripe_count = lum->lum_stripe_count; - md.default_lmv->lsm_md_master_mdt_index = + md.def_lsm_obj->lso_lsm.lsm_md_master_mdt_index = lum->lum_stripe_offset; - md.default_lmv->lsm_md_hash_type = lum->lum_hash_type; - md.default_lmv->lsm_md_max_inherit = + md.def_lsm_obj->lso_lsm.lsm_md_hash_type = + lum->lum_hash_type; + md.def_lsm_obj->lso_lsm.lsm_md_max_inherit = lum->lum_max_inherit; - md.default_lmv->lsm_md_max_inherit_rr = + md.def_lsm_obj->lso_lsm.lsm_md_max_inherit_rr = lum->lum_max_inherit_rr; + atomic_set(&md.def_lsm_obj->lso_refs, 1); err = ll_update_inode(dir, &md); - md_free_lustre_md(sbi->ll_md_exp, &md); + md_put_lustre_md(sbi->ll_md_exp, &md); if (err) goto err_exit; - } else if (err2 == -ENODATA && lli->lli_default_lsm_md) { + } else if (err2 == -ENODATA && lli->lli_def_lsm_obj) { /* * If there are no default stripe EA on the MDT, but the * client has default stripe, then it probably means * default stripe EA has just been deleted. */ down_write(&lli->lli_lsm_sem); - kfree(lli->lli_default_lsm_md); - lli->lli_default_lsm_md = NULL; + lmv_stripe_object_put(&lli->lli_def_lsm_obj); up_write(&lli->lli_lsm_sem); } else { goto err_exit; diff --git a/fs/lustre/lmv/lmv_intent.c b/fs/lustre/lmv/lmv_intent.c index 2322b6a6ae92..399ba0c3fb55 100644 --- a/fs/lustre/lmv/lmv_intent.c +++ b/fs/lustre/lmv/lmv_intent.c @@ -302,15 +302,15 @@ static int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, int rc; /* do not allow file creation in foreign dir */ - if ((it->it_op & IT_CREAT) && lmv_dir_foreign(op_data->op_mea1)) + if ((it->it_op & IT_CREAT) && lmv_dir_foreign(op_data->op_lso1)) return -ENODATA; if ((it->it_op & IT_CREAT) && !(flags & MDS_OPEN_BY_FID)) { /* don't allow create under dir with bad hash */ - if (lmv_dir_bad_hash(op_data->op_mea1)) + if (lmv_dir_bad_hash(op_data->op_lso1)) return -EBADF; - if (lmv_dir_layout_changing(op_data->op_mea1)) { + if (lmv_dir_layout_changing(op_data->op_lso1)) { if (flags & O_EXCL) { /* * open(O_CREAT | O_EXCL) needs to check @@ -338,12 +338,11 @@ static int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, if (it->it_flags & MDS_OPEN_BY_FID) { LASSERT(fid_is_sane(&op_data->op_fid2)); - /* - * for striped directory, we can't know parent stripe fid + /* for striped directory, we can't know parent stripe fid * without name, but we can set it to child fid, and MDT * will obtain it from linkea in open in such case. */ - if (lmv_dir_striped(op_data->op_mea1)) + if (lmv_dir_striped(op_data->op_lso1)) op_data->op_fid1 = op_data->op_fid2; tgt = lmv_fid2tgt(lmv, &op_data->op_fid2); @@ -443,7 +442,7 @@ static int lmv_intent_lookup(struct obd_export *exp, int rc; /* foreign dir is not striped */ - if (lmv_dir_foreign(op_data->op_mea1)) { + if (lmv_dir_foreign(op_data->op_lso1)) { /* only allow getattr/lookup for itself */ if (op_data->op_name) return -ENODATA; @@ -502,12 +501,12 @@ static int lmv_intent_lookup(struct obd_export *exp, return rc; if (!*reqp) { - /* - * If RPC happens, lsm information will be revalidated + /* If RPC happens, lsm information will be revalidated * during update_inode process (see ll_update_lsm_md) */ - if (lmv_dir_striped(op_data->op_mea2)) { - rc = lmv_revalidate_slaves(exp, op_data->op_mea2, + if (lmv_dir_striped(op_data->op_lso2)) { + rc = lmv_revalidate_slaves(exp, + &op_data->op_lso2->lso_lsm, cb_blocking, extra_lock_flags); if (rc != 0) diff --git a/fs/lustre/lmv/lmv_internal.h b/fs/lustre/lmv/lmv_internal.h index 64ec4ae9dc17..b89e53bf35d3 100644 --- a/fs/lustre/lmv/lmv_internal.h +++ b/fs/lustre/lmv/lmv_internal.h @@ -166,13 +166,15 @@ static inline int lmv_stripe_md_size(int stripe_count) /* for file under migrating directory, return the target stripe info */ static inline const struct lmv_oinfo * -lsm_name_to_stripe_info(const struct lmv_stripe_md *lsm, const char *name, +lsm_name_to_stripe_info(const struct lmv_stripe_object *lso, const char *name, int namelen, bool new_layout) { + const struct lmv_stripe_md *lsm; int stripe_index; - LASSERT(lmv_dir_striped(lsm)); + LASSERT(lmv_dir_striped(lso)); + lsm = &lso->lso_lsm; stripe_index = __lmv_name_to_stripe_index(lsm->lsm_md_hash_type, lsm->lsm_md_stripe_count, lsm->lsm_md_migrate_hash, @@ -186,18 +188,18 @@ lsm_name_to_stripe_info(const struct lmv_stripe_md *lsm, const char *name, static inline bool lmv_dir_retry_check_update(struct md_op_data *op_data) { - const struct lmv_stripe_md *lsm = op_data->op_mea1; + const struct lmv_stripe_object *lso = op_data->op_lso1; - if (!lsm) + if (!lso) return false; - if (lmv_dir_layout_changing(lsm) && !op_data->op_new_layout) { + if (lmv_dir_layout_changing(lso) && !op_data->op_new_layout) { op_data->op_new_layout = true; return true; } - if (lmv_dir_bad_hash(lsm) && - op_data->op_stripe_index < lsm->lsm_md_stripe_count - 1) { + if (lmv_dir_bad_hash(lso) && + op_data->op_stripe_index < lso->lso_lsm.lsm_md_stripe_count - 1) { op_data->op_stripe_index++; return true; } diff --git a/fs/lustre/lmv/lmv_obd.c b/fs/lustre/lmv/lmv_obd.c index da28bc0e544b..eb9f0e86291f 100644 --- a/fs/lustre/lmv/lmv_obd.c +++ b/fs/lustre/lmv/lmv_obd.c @@ -1666,14 +1666,14 @@ static struct lu_tgt_desc *lmv_locate_tgt_lf(struct lmv_obd *lmv) * which stripe its dirent is stored. */ static struct lmv_tgt_desc * -lmv_locate_tgt_by_name(struct lmv_obd *lmv, struct lmv_stripe_md *lsm, +lmv_locate_tgt_by_name(struct lmv_obd *lmv, struct lmv_stripe_object *lso, const char *name, int namelen, struct lu_fid *fid, u32 *mds, bool new_layout) { const struct lmv_oinfo *oinfo; struct lmv_tgt_desc *tgt; - if (!lmv_dir_striped(lsm) || !namelen) { + if (!lmv_dir_striped(lso) || !namelen) { tgt = lmv_fid2tgt(lmv, fid); if (IS_ERR(tgt)) return tgt; @@ -1683,11 +1683,11 @@ lmv_locate_tgt_by_name(struct lmv_obd *lmv, struct lmv_stripe_md *lsm, } if (CFS_FAIL_CHECK(OBD_FAIL_LFSCK_BAD_NAME_HASH)) { - if (cfs_fail_val >= lsm->lsm_md_stripe_count) + if (cfs_fail_val >= lso->lso_lsm.lsm_md_stripe_count) return ERR_PTR(-EBADF); - oinfo = &lsm->lsm_md_oinfo[cfs_fail_val]; + oinfo = &lso->lso_lsm.lsm_md_oinfo[cfs_fail_val]; } else { - oinfo = lsm_name_to_stripe_info(lsm, name, namelen, new_layout); + oinfo = lsm_name_to_stripe_info(lso, name, namelen, new_layout); if (IS_ERR(oinfo)) return ERR_CAST(oinfo); } @@ -1717,7 +1717,7 @@ lmv_locate_tgt_by_name(struct lmv_obd *lmv, struct lmv_stripe_md *lsm, * * @lmv: LMV device * @op_data: client MD stack parameters, name, namelen etc, - * op_mds and op_fid1 will be updated if op_mea1 + * op_mds and op_fid1 will be updated if op_lso1 * indicates fid1 represents a striped directory. * * Returns: pointer to the lmv_tgt_desc if succeed. @@ -1726,11 +1726,11 @@ lmv_locate_tgt_by_name(struct lmv_obd *lmv, struct lmv_stripe_md *lsm, struct lmv_tgt_desc * lmv_locate_tgt(struct lmv_obd *lmv, struct md_op_data *op_data) { - struct lmv_stripe_md *lsm = op_data->op_mea1; + struct lmv_stripe_md *lsm; struct lmv_oinfo *oinfo; struct lmv_tgt_desc *tgt; - if (lmv_dir_foreign(lsm)) + if (lmv_dir_foreign(op_data->op_lso1)) return ERR_PTR(-ENODATA); /* @@ -1744,10 +1744,11 @@ lmv_locate_tgt(struct lmv_obd *lmv, struct md_op_data *op_data) if (!tgt) return ERR_PTR(-ENODEV); - if (lmv_dir_striped(lsm)) { + if (lmv_dir_striped(op_data->op_lso1)) { int i; /* refill the right parent fid */ + lsm = &op_data->op_lso1->lso_lsm; for (i = 0; i < lsm->lsm_md_stripe_count; i++) { oinfo = &lsm->lsm_md_oinfo[i]; if (oinfo->lmo_mds == op_data->op_mds) { @@ -1759,7 +1760,9 @@ lmv_locate_tgt(struct lmv_obd *lmv, struct md_op_data *op_data) if (i == lsm->lsm_md_stripe_count) op_data->op_fid1 = lsm->lsm_md_oinfo[0].lmo_fid; } - } else if (lmv_dir_bad_hash(lsm)) { + } else if (lmv_dir_bad_hash(op_data->op_lso1)) { + lsm = &op_data->op_lso1->lso_lsm; + LASSERT(op_data->op_stripe_index < lsm->lsm_md_stripe_count); oinfo = &lsm->lsm_md_oinfo[op_data->op_stripe_index]; @@ -1770,7 +1773,7 @@ lmv_locate_tgt(struct lmv_obd *lmv, struct md_op_data *op_data) if (!tgt) return ERR_PTR(-ENODEV); } else { - tgt = lmv_locate_tgt_by_name(lmv, op_data->op_mea1, + tgt = lmv_locate_tgt_by_name(lmv, op_data->op_lso1, op_data->op_name, op_data->op_namelen, &op_data->op_fid1, @@ -1789,26 +1792,26 @@ lmv_locate_tgt2(struct lmv_obd *lmv, struct md_op_data *op_data) int rc; LASSERT(op_data->op_name); - if (lmv_dir_layout_changing(op_data->op_mea2)) { + if (lmv_dir_layout_changing(op_data->op_lso2)) { struct lu_fid fid1 = op_data->op_fid1; - struct lmv_stripe_md *lsm1 = op_data->op_mea1; + struct lmv_stripe_object *lso1 = op_data->op_lso1; struct ptlrpc_request *request = NULL; /* * avoid creating new file under old layout of migrating * directory, check it here. */ - tgt = lmv_locate_tgt_by_name(lmv, op_data->op_mea2, + tgt = lmv_locate_tgt_by_name(lmv, op_data->op_lso2, op_data->op_name, op_data->op_namelen, &op_data->op_fid2, &op_data->op_mds, false); if (IS_ERR(tgt)) return tgt; op_data->op_fid1 = op_data->op_fid2; - op_data->op_mea1 = op_data->op_mea2; + op_data->op_lso1 = op_data->op_lso2; rc = md_getattr_name(tgt->ltd_exp, op_data, &request); op_data->op_fid1 = fid1; - op_data->op_mea1 = lsm1; + op_data->op_lso1 = lso1; if (!rc) { ptlrpc_req_finished(request); return ERR_PTR(-EEXIST); @@ -1818,9 +1821,10 @@ lmv_locate_tgt2(struct lmv_obd *lmv, struct md_op_data *op_data) return ERR_PTR(rc); } - return lmv_locate_tgt_by_name(lmv, op_data->op_mea2, op_data->op_name, - op_data->op_namelen, &op_data->op_fid2, - &op_data->op_mds, true); + return lmv_locate_tgt_by_name(lmv, op_data->op_lso2, + op_data->op_name, op_data->op_namelen, + &op_data->op_fid2, &op_data->op_mds, + true); } int lmv_old_layout_lookup(struct lmv_obd *lmv, struct md_op_data *op_data) @@ -1829,7 +1833,7 @@ int lmv_old_layout_lookup(struct lmv_obd *lmv, struct md_op_data *op_data) struct ptlrpc_request *request; int rc; - LASSERT(lmv_dir_layout_changing(op_data->op_mea1)); + LASSERT(lmv_dir_layout_changing(op_data->op_lso1)); LASSERT(!op_data->op_new_layout); tgt = lmv_locate_tgt(lmv, op_data); @@ -1857,7 +1861,7 @@ static inline bool lmv_op_user_qos_mkdir(const struct md_op_data *op_data) if (op_data->op_code != LUSTRE_OPC_MKDIR) return false; - if (lmv_dir_striped(op_data->op_mea1)) + if (lmv_dir_striped(op_data->op_lso1)) return false; return (op_data->op_cli_flags & CLI_SET_MEA) && lum && @@ -1868,16 +1872,17 @@ static inline bool lmv_op_user_qos_mkdir(const struct md_op_data *op_data) /* mkdir by QoS if either ROOT or parent default LMV is space balanced. */ static inline bool lmv_op_default_qos_mkdir(const struct md_op_data *op_data) { - const struct lmv_stripe_md *lsm = op_data->op_default_mea1; + const struct lmv_stripe_object *lso = op_data->op_default_lso1; if (op_data->op_code != LUSTRE_OPC_MKDIR) return false; - if (lmv_dir_striped(op_data->op_mea1)) + if (lmv_dir_striped(op_data->op_lso1)) return false; return (op_data->op_flags & MF_QOS_MKDIR) || - (lsm && lsm->lsm_md_master_mdt_index == LMV_OFFSET_DEFAULT); + (lso && lso->lso_lsm.lsm_md_master_mdt_index == + LMV_OFFSET_DEFAULT); } /* if parent default LMV is space balanced, and @@ -1889,11 +1894,11 @@ static inline bool lmv_op_default_qos_mkdir(const struct md_op_data *op_data) */ static inline bool lmv_op_default_rr_mkdir(const struct md_op_data *op_data) { - const struct lmv_stripe_md *lsm = op_data->op_default_mea1; + const struct lmv_stripe_object *lso = op_data->op_default_lso1; return (op_data->op_flags & MF_RR_MKDIR) || - (lsm && lsm->lsm_md_max_inherit_rr != LMV_INHERIT_RR_NONE) || - fid_is_root(&op_data->op_fid1); + (lso && lso->lso_lsm.lsm_md_max_inherit_rr != + LMV_INHERIT_RR_NONE) || fid_is_root(&op_data->op_fid1); } /* 'lfs mkdir -i ' */ @@ -1913,8 +1918,8 @@ static inline bool lmv_op_default_specific_mkdir(const struct md_op_data *op_data) { return op_data->op_code == LUSTRE_OPC_MKDIR && - op_data->op_default_mea1 && - op_data->op_default_mea1->lsm_md_master_mdt_index != + op_data->op_default_lso1 && + op_data->op_default_lso1->lso_lsm.lsm_md_master_mdt_index != LMV_OFFSET_DEFAULT; } @@ -1964,10 +1969,10 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data, if (!lmv->lmv_mdt_descs.ltd_lmv_desc.ld_active_tgt_count) return -EIO; - if (lmv_dir_bad_hash(op_data->op_mea1)) + if (lmv_dir_bad_hash(op_data->op_lso1)) return -EBADF; - if (lmv_dir_layout_changing(op_data->op_mea1)) { + if (lmv_dir_layout_changing(op_data->op_lso1)) { /* * if parent is migrating, create() needs to lookup existing * name in both old and new layout, check old layout on client. @@ -2001,8 +2006,9 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data, if (IS_ERR(tgt)) return PTR_ERR(tgt); } else if (lmv_op_default_specific_mkdir(op_data)) { - op_data->op_mds = - op_data->op_default_mea1->lsm_md_master_mdt_index; + struct lmv_stripe_md *lsm = &op_data->op_default_lso1->lso_lsm; + + op_data->op_mds = lsm->lsm_md_master_mdt_index; tgt = lmv_tgt(lmv, op_data->op_mds); if (!tgt) return -ENODEV; @@ -2215,7 +2221,7 @@ static inline bool lmv_op_topdir_migrate(const struct md_op_data *op_data) if (!S_ISDIR(op_data->op_mode)) return false; - if (lmv_dir_layout_changing(op_data->op_mea1)) + if (lmv_dir_layout_changing(op_data->op_lso1)) return false; return true; @@ -2250,7 +2256,7 @@ static inline bool lmv_subdir_specific_migrate(const struct md_op_data *op_data) if (!S_ISDIR(op_data->op_mode)) return false; - if (!lmv_dir_layout_changing(op_data->op_mea1)) + if (!lmv_dir_layout_changing(op_data->op_lso1)) return false; return le32_to_cpu(lum->lum_stripe_offset) != LMV_OFFSET_DEFAULT; @@ -2262,7 +2268,7 @@ static int lmv_migrate(struct obd_export *exp, struct md_op_data *op_data, { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - struct lmv_stripe_md *lsm = op_data->op_mea1; + struct lmv_stripe_object *lso = op_data->op_lso1; struct lmv_tgt_desc *parent_tgt; struct lmv_tgt_desc *sp_tgt; struct lmv_tgt_desc *tp_tgt = NULL; @@ -2284,10 +2290,10 @@ static int lmv_migrate(struct obd_export *exp, struct md_op_data *op_data, if (IS_ERR(parent_tgt)) return PTR_ERR(parent_tgt); - if (lmv_dir_striped(lsm)) { + if (lmv_dir_striped(lso)) { const struct lmv_oinfo *oinfo; - oinfo = lsm_name_to_stripe_info(lsm, name, namelen, false); + oinfo = lsm_name_to_stripe_info(lso, name, namelen, false); if (IS_ERR(oinfo)) return PTR_ERR(oinfo); @@ -2301,8 +2307,8 @@ static int lmv_migrate(struct obd_export *exp, struct md_op_data *op_data, * if parent is being migrated too, fill op_fid2 with target * stripe fid, otherwise the target stripe is not created yet. */ - if (lmv_dir_layout_changing(lsm)) { - oinfo = lsm_name_to_stripe_info(lsm, name, namelen, + if (lmv_dir_layout_changing(lso)) { + oinfo = lsm_name_to_stripe_info(lso, name, namelen, true); if (IS_ERR(oinfo)) return PTR_ERR(oinfo); @@ -2729,7 +2735,7 @@ static struct lu_dirent *stripe_dirent_load(struct lmv_dir_ctxt *ctxt, hash = end; } - oinfo = &op_data->op_mea1->lsm_md_oinfo[stripe_index]; + oinfo = &op_data->op_lso1->lso_lsm.lsm_md_oinfo[stripe_index]; if (!oinfo->lmo_root) { rc = -ENOENT; break; @@ -2912,7 +2918,7 @@ static int lmv_striped_read_page(struct obd_export *exp, last_ent = ent; /* initialize dir read context */ - stripe_count = op_data->op_mea1->lsm_md_stripe_count; + stripe_count = op_data->op_lso1->lso_lsm.lsm_md_stripe_count; ctxt = kzalloc(offsetof(typeof(*ctxt), ldc_stripes[stripe_count]), GFP_NOFS); if (!ctxt) { @@ -3005,10 +3011,10 @@ static int lmv_read_page(struct obd_export *exp, struct md_op_data *op_data, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; - if (unlikely(lmv_dir_foreign(op_data->op_mea1))) + if (unlikely(lmv_dir_foreign(op_data->op_lso1))) return -ENODATA; - if (unlikely(lmv_dir_striped(op_data->op_mea1))) { + if (unlikely(lmv_dir_striped(op_data->op_lso1))) { return lmv_striped_read_page(exp, op_data, mrinfo, offset, ppage); } @@ -3414,117 +3420,187 @@ static inline int lmv_unpack_user_md(struct obd_export *exp, return 0; } -static int lmv_unpackmd(struct obd_export *exp, struct lmv_stripe_md **lsmp, - const union lmv_mds_md *lmm, size_t lmm_size) +struct lmv_stripe_object *lmv_stripe_object_alloc(u32 magic, + const union lmv_mds_md *lmm, + size_t lmm_size) { - struct lmv_stripe_md *lsm; - bool allocated = false; - int lsm_size, rc; + struct lmv_stripe_object *lsm_obj; + int size; - LASSERT(lsmp); + if (magic == LMV_MAGIC_FOREIGN) { + struct lmv_foreign_md *lfm; - lsm = *lsmp; - /* Free memmd */ - if (lsm && !lmm) { - int i; - struct lmv_foreign_md *lfm = (struct lmv_foreign_md *)lsm; + size = offsetof(typeof(*lfm), lfm_value[0]); + if (lmm_size < size) + return ERR_PTR(-EPROTO); - if (lfm->lfm_magic == LMV_MAGIC_FOREIGN) { - size_t lfm_size; + size += le32_to_cpu(lmm->lmv_foreign_md.lfm_length); + if (lmm_size < size) + return ERR_PTR(-EPROTO); - lfm_size = lfm->lfm_length + offsetof(typeof(*lfm), - lfm_value[0]); - kvfree(lfm); - return 0; - } + lsm_obj = kvmalloc(lmm_size + + offsetof(typeof(*lsm_obj), lso_lfm), + GFP_NOFS); + } else { + if (magic == LMV_MAGIC_V1) { + int count; + + size = offsetof(struct lmv_mds_md_v1, + lmv_stripe_fids[0]); + if (lmm_size < size) + return ERR_PTR(-EPROTO); + + count = lmv_mds_md_stripe_count_get(lmm); + size += count * sizeof(struct lu_fid); + if (lmm_size < size) + return ERR_PTR(-EPROTO); - if (lmv_dir_striped(lsm)) { - for (i = 0; i < lsm->lsm_md_stripe_count; i++) - iput(lsm->lsm_md_oinfo[i].lmo_root); - lsm_size = lmv_stripe_md_size(lsm->lsm_md_stripe_count); + size = lmv_stripe_md_size(count); } else { - lsm_size = lmv_stripe_md_size(0); + if (lmm && lmm_size < sizeof(struct lmv_user_md)) + return ERR_PTR(-EPROTO); + + /** + * Unpack default dirstripe(lmv_user_md) to + * lmv_stripe_md, stripecount should be 0 then. + */ + size = lmv_stripe_md_size(0); } - kvfree(lsm); - *lsmp = NULL; - return 0; + size += offsetof(typeof(*lsm_obj), lso_lsm); + lsm_obj = kzalloc(size, GFP_NOFS); } - /* foreign lmv case */ - if (le32_to_cpu(lmm->lmv_magic) == LMV_MAGIC_FOREIGN) { - struct lmv_foreign_md *lfm = (struct lmv_foreign_md *)lsm; - - if (!lfm) { - lfm = kvzalloc(lmm_size, GFP_NOFS); - if (!lfm) - return -ENOMEM; - *lsmp = (struct lmv_stripe_md *)lfm; - } - lfm->lfm_magic = le32_to_cpu(lmm->lmv_foreign_md.lfm_magic); - lfm->lfm_length = le32_to_cpu(lmm->lmv_foreign_md.lfm_length); - lfm->lfm_type = le32_to_cpu(lmm->lmv_foreign_md.lfm_type); - lfm->lfm_flags = le32_to_cpu(lmm->lmv_foreign_md.lfm_flags); - memcpy(&lfm->lfm_value, &lmm->lmv_foreign_md.lfm_value, - lfm->lfm_length); - return lmm_size; + if (lsm_obj) { + atomic_set(&lsm_obj->lso_refs, 1); + return lsm_obj; } - if (le32_to_cpu(lmm->lmv_magic) == LMV_MAGIC_STRIPE) + return ERR_PTR(-ENOMEM); +} +EXPORT_SYMBOL(lmv_stripe_object_alloc); + +static int lmv_stripe_object_create(struct obd_export *exp, + struct lmv_stripe_object **lsop, + const union lmv_mds_md *lmm, + size_t lmm_size) +{ + struct lmv_stripe_object *lsm_obj; + u32 magic; + int rc; + + LASSERT(lsop && !*lsop); + if (lmm_size == 0) + return -EPROTO; + + magic = le32_to_cpu(lmm->lmv_magic); + if (magic == LMV_MAGIC_STRIPE) return -EPERM; - /* Unpack memmd */ - if (le32_to_cpu(lmm->lmv_magic) != LMV_MAGIC_V1 && - le32_to_cpu(lmm->lmv_magic) != LMV_USER_MAGIC) { + if (magic != LMV_MAGIC_V1 && magic != LMV_USER_MAGIC && + magic != LMV_MAGIC_FOREIGN) { CERROR("%s: invalid lmv magic %x: rc = %d\n", - exp->exp_obd->obd_name, le32_to_cpu(lmm->lmv_magic), - -EIO); + exp->exp_obd->obd_name, magic, -EIO); return -EIO; } - if (le32_to_cpu(lmm->lmv_magic) == LMV_MAGIC_V1) - lsm_size = lmv_stripe_md_size(lmv_mds_md_stripe_count_get(lmm)); - else - /** - * Unpack default dirstripe(lmv_user_md) to lmv_stripe_md, - * stripecount should be 0 then. - */ - lsm_size = lmv_stripe_md_size(0); + /* foreign lmv case */ + if (magic == LMV_MAGIC_FOREIGN) { + struct lmv_foreign_md *lfm; - if (!lsm) { - lsm = kvzalloc(lsm_size, GFP_NOFS); - if (!lsm) - return -ENOMEM; - allocated = true; - *lsmp = lsm; + lsm_obj = lmv_stripe_object_alloc(magic, lmm, lmm_size); + if (IS_ERR(lsm_obj)) + return PTR_ERR(lsm_obj); + + *lsop = lsm_obj; + lfm = &lsm_obj->lso_lfm; + lfm->lfm_magic = magic; + lfm->lfm_length = le32_to_cpu(lmm->lmv_foreign_md.lfm_length); + lfm->lfm_type = le32_to_cpu(lmm->lmv_foreign_md.lfm_type); + lfm->lfm_flags = le32_to_cpu(lmm->lmv_foreign_md.lfm_flags); + memcpy(&lfm->lfm_value, &lmm->lmv_foreign_md.lfm_value, + lfm->lfm_length); + return 0; } - switch (le32_to_cpu(lmm->lmv_magic)) { + /* Unpack memmd */ + lsm_obj = lmv_stripe_object_alloc(magic, lmm, lmm_size); + if (IS_ERR(lsm_obj)) + return PTR_ERR(lsm_obj); + + switch (magic) { case LMV_MAGIC_V1: - rc = lmv_unpack_md_v1(exp, lsm, &lmm->lmv_md_v1); + rc = lmv_unpack_md_v1(exp, &lsm_obj->lso_lsm, &lmm->lmv_md_v1); break; case LMV_USER_MAGIC: - rc = lmv_unpack_user_md(exp, lsm, &lmm->lmv_user_md); + rc = lmv_unpack_user_md(exp, &lsm_obj->lso_lsm, + &lmm->lmv_user_md); break; default: CERROR("%s: unrecognized magic %x\n", exp->exp_obd->obd_name, - le32_to_cpu(lmm->lmv_magic)); + magic); rc = -EINVAL; break; } - if (rc && allocated) { - kvfree(lsm); - *lsmp = NULL; - lsm_size = rc; - } - return lsm_size; + if (rc != 0) + lmv_stripe_object_put(&lsm_obj); + + *lsop = lsm_obj; + return rc; +} + +struct lmv_stripe_object * +lmv_stripe_object_get(struct lmv_stripe_object *lsm_obj) +{ + if (!lsm_obj) + return NULL; + + atomic_inc(&lsm_obj->lso_refs); + CDEBUG(D_INODE, "get %p %u\n", lsm_obj, + atomic_read(&lsm_obj->lso_refs)); + return lsm_obj; } +EXPORT_SYMBOL(lmv_stripe_object_get); -void lmv_free_memmd(struct lmv_stripe_md *lsm) +void lmv_stripe_object_put(struct lmv_stripe_object **lsop) { - lmv_unpackmd(NULL, &lsm, NULL, 0); + struct lmv_stripe_object *lsm_obj; + size_t size; + int i; + + LASSERT(lsop); + + lsm_obj = *lsop; + if (!lsm_obj) + return; + + *lsop = NULL; + CDEBUG(D_INODE, "put %p %u\n", lsm_obj, + atomic_read(&lsm_obj->lso_refs) - 1); + + if (!atomic_dec_and_test(&lsm_obj->lso_refs)) + return; + + if (lmv_dir_foreign(lsm_obj)) { + size = lsm_obj->lso_lfm.lfm_length + + offsetof(typeof(lsm_obj->lso_lfm), lfm_value[0]) + + offsetof(typeof(*lsm_obj), lso_lsm); + kvfree(lsm_obj); + return; + } + + if (lmv_dir_striped(lsm_obj)) { + struct lmv_stripe_md *lsm = &lsm_obj->lso_lsm; + + for (i = 0; i < lsm->lsm_md_stripe_count; i++) + iput(lsm->lsm_md_oinfo[i].lmo_root); + size = lmv_stripe_md_size(lsm->lsm_md_stripe_count); + } else { + size = lmv_stripe_md_size(0); + } + kfree(lsm_obj); } -EXPORT_SYMBOL(lmv_free_memmd); +EXPORT_SYMBOL(lmv_stripe_object_put); static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, union ldlm_policy_data *policy, @@ -3633,23 +3709,18 @@ static int lmv_get_lustre_md(struct obd_export *exp, return md_get_lustre_md(tgt->ltd_exp, pill, dt_exp, md_exp, md); } -static int lmv_free_lustre_md(struct obd_export *exp, struct lustre_md *md) +static int lmv_put_lustre_md(struct obd_export *exp, struct lustre_md *md) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt = lmv_tgt(lmv, 0); - if (md->default_lmv) { - lmv_free_memmd(md->default_lmv); - md->default_lmv = NULL; - } - if (md->lmv) { - lmv_free_memmd(md->lmv); - md->lmv = NULL; - } + lmv_stripe_object_put(&md->def_lsm_obj); + lmv_stripe_object_put(&md->lsm_obj); + if (!tgt || !tgt->ltd_exp) return -EINVAL; - return md_free_lustre_md(tgt->ltd_exp, md); + return 0; } static int lmv_set_open_replay_data(struct obd_export *exp, @@ -3725,16 +3796,15 @@ static int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, return md_revalidate_lock(tgt->ltd_exp, it, fid, bits); } -static int -lmv_get_fid_from_lsm(struct obd_export *exp, - const struct lmv_stripe_md *lsm, - const char *name, int namelen, struct lu_fid *fid) +static int lmv_get_fid_from_lsm(struct obd_export *exp, + const struct lmv_stripe_object *lso, + const char *name, int namelen, + struct lu_fid *fid) { const struct lmv_oinfo *oinfo; - LASSERT(lmv_dir_striped(lsm)); - - oinfo = lsm_name_to_stripe_info(lsm, name, namelen, false); + LASSERT(lmv_dir_striped(lso)); + oinfo = lsm_name_to_stripe_info(lso, name, namelen, false); if (IS_ERR(oinfo)) return PTR_ERR(oinfo); @@ -3789,13 +3859,14 @@ static int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, } static int lmv_merge_attr(struct obd_export *exp, - const struct lmv_stripe_md *lsm, + const struct lmv_stripe_object *lso, struct cl_attr *attr, ldlm_blocking_callback cb_blocking) { + const struct lmv_stripe_md *lsm = &lso->lso_lsm; int rc, i; - if (!lmv_dir_striped(lsm)) + if (!lmv_dir_striped(lso)) return 0; rc = lmv_revalidate_slaves(exp, lsm, cb_blocking, 0); @@ -4073,14 +4144,14 @@ static const struct md_ops lmv_md_ops = { .set_lock_data = lmv_set_lock_data, .lock_match = lmv_lock_match, .get_lustre_md = lmv_get_lustre_md, - .free_lustre_md = lmv_free_lustre_md, + .put_lustre_md = lmv_put_lustre_md, .merge_attr = lmv_merge_attr, .set_open_replay_data = lmv_set_open_replay_data, .clear_open_replay_data = lmv_clear_open_replay_data, .intent_getattr_async = lmv_intent_getattr_async, .revalidate_lock = lmv_revalidate_lock, .get_fid_from_lsm = lmv_get_fid_from_lsm, - .unpackmd = lmv_unpackmd, + .stripe_object_create = lmv_stripe_object_create, .rmfid = lmv_rmfid, .batch_create = lmv_batch_create, .batch_add = lmv_batch_add, diff --git a/fs/lustre/mdc/mdc_request.c b/fs/lustre/mdc/mdc_request.c index d0f51b2e0051..64f19a2f3a40 100644 --- a/fs/lustre/mdc/mdc_request.c +++ b/fs/lustre/mdc/mdc_request.c @@ -617,29 +617,17 @@ static int mdc_get_lustre_md(struct obd_export *exp, struct req_capsule *pill, goto out; } - rc = md_unpackmd(md_exp, &md->lmv, lmv, lmv_size); + rc = md_stripe_object_create(md_exp, &md->lsm_obj, + lmv, lmv_size); if (rc < 0) goto out; - - if (rc < (int)sizeof(*md->lmv)) { - struct lmv_foreign_md *lfm = md->lfm; - - /* short (< sizeof(struct lmv_stripe_md)) - * foreign LMV case - */ - if (lfm->lfm_magic != LMV_MAGIC_FOREIGN) { - CDEBUG(D_INFO, - "lmv size too small: %d < %d\n", - rc, (int)sizeof(*md->lmv)); - rc = -EPROTO; - goto out; - } - } } /* since 2.12.58 intent_getattr fetches default LMV */ if (md->body->mbo_valid & OBD_MD_DEFAULT_MEA) { - lmv_size = sizeof(struct lmv_user_md); + lmv_size = req_capsule_get_size(pill, + &RMF_DEFAULT_MDT_MD, + RCL_SERVER); lmv = req_capsule_server_sized_get(pill, &RMF_DEFAULT_MDT_MD, lmv_size); @@ -648,18 +636,10 @@ static int mdc_get_lustre_md(struct obd_export *exp, struct req_capsule *pill, goto out; } - rc = md_unpackmd(md_exp, &md->default_lmv, lmv, - lmv_size); + rc = md_stripe_object_create(md_exp, &md->def_lsm_obj, + lmv, lmv_size); if (rc < 0) goto out; - - if (rc < (int)sizeof(*md->default_lmv)) { - CDEBUG(D_INFO, - "default lmv size too small: %d < %d\n", - rc, (int)sizeof(*md->lmv)); - rc = -EPROTO; - goto out; - } } } rc = 0; @@ -671,19 +651,15 @@ static int mdc_get_lustre_md(struct obd_export *exp, struct req_capsule *pill, */ if (md->body->mbo_valid & OBD_MD_FLACL) rc = mdc_unpack_acl(pill, md); - out: - if (rc) + if (rc) { lmd_clear_acl(md); + md_put_lustre_md(md_exp, md); + } return rc; } -static int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md) -{ - return 0; -} - void mdc_replay_open(struct ptlrpc_request *req) { struct md_open_data *mod = req->rq_cb_data; @@ -3030,7 +3006,6 @@ static const struct md_ops mdc_md_ops = { .set_lock_data = mdc_set_lock_data, .lock_match = mdc_lock_match, .get_lustre_md = mdc_get_lustre_md, - .free_lustre_md = mdc_free_lustre_md, .set_open_replay_data = mdc_set_open_replay_data, .clear_open_replay_data = mdc_clear_open_replay_data, .intent_getattr_async = mdc_intent_getattr_async, From patchwork Fri Mar 21 13:07:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025460 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC794C36000 for ; Fri, 21 Mar 2025 13:41:51 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2wL45zdz211N; Fri, 21 Mar 2025 06:14:26 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2pB6H7xz1y9f for ; Fri, 21 Mar 2025 06:09:06 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm5-e204-208.ccs.ornl.gov [160.91.203.29]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id A9458893DA1; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id A700F106BE16; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:07:07 -0400 Message-ID: <20250321130711.3257092-25-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 24/27] lustre: llite: Improve sync_io comments X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Patrick Farrell Correct and improve comments on cl_sync_io_wait_recycle. WC-bug-id: https://jira.whamcloud.com/browse/LU-13805 Lustre-commit: 8fa28e42ce38cb3b6 ("LU-13805 llite: Improve sync_io comments") Signed-off-by: Patrick Farrell Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50167 Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Reviewed-by: Qian Yingjin Signed-off-by: James Simmons --- fs/lustre/obdclass/cl_io.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/lustre/obdclass/cl_io.c b/fs/lustre/obdclass/cl_io.c index 99672510aa5a..6132f42b77e5 100644 --- a/fs/lustre/obdclass/cl_io.c +++ b/fs/lustre/obdclass/cl_io.c @@ -1259,6 +1259,10 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, } EXPORT_SYMBOL(cl_sync_io_note); +/* this function waits for completion of outstanding io and then re-initializes + * the anchor used to track it. This is used to wait to complete DIO before + * returning to userspace, and is never called for true AIO + */ int cl_sync_io_wait_recycle(const struct lu_env *env, struct cl_sync_io *anchor, long timeout, int ioret) { @@ -1271,10 +1275,8 @@ int cl_sync_io_wait_recycle(const struct lu_env *env, struct cl_sync_io *anchor, * count to be zero. */ cl_sync_io_note(env, anchor, ioret); - /* Wait for completion of normal dio. - * This replaces the EIOCBQEUED return from the DIO/AIO - * path, and this is where AIO and DIO implementations - * split. + /* Wait for completion of outstanding dio before re-initializing for + * possible restart */ rc = cl_sync_io_wait(env, anchor, timeout); /** From patchwork Fri Mar 21 13:07:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94ECAC36000 for ; Fri, 21 Mar 2025 13:44:22 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2wv3tg6z212R; Fri, 21 Mar 2025 06:14:55 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2pt0Y9fz1yGY for ; Fri, 21 Mar 2025 06:09:41 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id AC43417B5B7; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id AABE1106BE17; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:07:08 -0400 Message-ID: <20250321130711.3257092-26-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 25/27] lustre: dne: refactor commit-on-sharing for DNE X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lai Siyao , Mikhail Pershin , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Lai Siyao Commit-on-sharing for DNE is different from the original commit-on-sharing: * the original commit-on-sharing is to eliminate dependency between operations from different clients. * while commit-on-sharing for DNE is to eliminate dependency between operations handled by different MDTs, so that upon multiple MDT failures, an operaiton replay won't fail because its dependent operation is not replayed by another MDT yet. Current CoS for DNE implementation checks dependency in MDT layer, and it decides by checking whether current operation is a distributed transaction, if so, it will trigger CoS upon conflicting locks. Actually this may miss some cases that should trigger CoS (even local transaction should trigger CoS if it depends on a distributed transaction), and on the other hand it may trigger extra CoS because if two operations are handled by the same MDT, the dependency is ensured because they will always be replayed by transaction number. And to avoid mixing the code of two different CoS, the following changes are made: * add new ldlm lock mode LCK_TXN. On DNE system, downgrade PW/EX locks to this mode after transaction stop. * add li_initiator_id in struct ldlm_inodebits, which is the index of MDT where the lock is enqueued, i.e. where operation is handled. If another operation handled by a different MDT requests a conflicting PW|EX mode lock against this TXN mode lock, it will trigger commit to ensure the dependent operation is committed to disk (NB, it doesn't trigger commit on all involved MDTs, but only the MDT where the conflict happens, which is enough to allow replay succeed). * remove LDLM_FL_COS_INCOMPAT and LDLM_FL_COS_ENABLED. * MDT layer doesn't need to check such dependency any more, since lock itself knows. * updated sanityn 33c, 33d and 33e since fewer CoS are triggered now. WC-bug-id: https://jira.whamcloud.com/browse/LU-15527 Lustre-commit: 2a78a9e2cda149ede5 ("LU-15527 dne: refactor commit-on-sharing for DNE") Signed-off-by: Lai Siyao Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/46641 Reviewed-by: Andreas Dilger Reviewed-by: Mikhail Pershin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/include/lustre_dlm.h | 43 ++++++++++++++++---------- fs/lustre/ldlm/ldlm_inodebits.c | 4 +++ fs/lustre/ldlm/ldlm_lib.c | 1 + fs/lustre/ldlm/ldlm_lock.c | 10 +++--- fs/lustre/ptlrpc/pack_generic.c | 2 +- fs/lustre/ptlrpc/service.c | 10 +++--- fs/lustre/ptlrpc/wiretest.c | 16 ++++++++-- include/uapi/linux/lustre/lustre_idl.h | 5 ++- 8 files changed, 61 insertions(+), 30 deletions(-) diff --git a/fs/lustre/include/lustre_dlm.h b/fs/lustre/include/lustre_dlm.h index 4217a8ad4501..a749e8acb5df 100644 --- a/fs/lustre/include/lustre_dlm.h +++ b/fs/lustre/include/lustre_dlm.h @@ -111,7 +111,7 @@ enum ldlm_side { * Lock types are described in their respective implementation files: * ldlm_{extent,flock,inodebits,plain}.c. * - * There are six lock modes along with a compatibility matrix to indicate if + * There are nine lock modes along with a compatibility matrix to indicate if * two locks are compatible. * * - EX: Exclusive mode. Before a new file is created, MDS requests EX lock @@ -126,26 +126,37 @@ enum ldlm_side { * - CR Concurrent Read mode. When a client performs a path lookup, MDS grants * an inodebit lock with the CR mode on the intermediate path component. * - NL Null mode. + * - GROUP: Group mode. Locks with the same group ID are compatible with each + * other. + * - COS: Commit-on-Sharing mode. If Commit-on-Sharing is enabled, PW/EX locks + * held in transactions are downgraded to COS mode after transaction stop. + * - TXN: Transaction mode. If Commit-on-Sharing is diabled on a DNE system, + * PW/EX locks held in transactions are downgraded to TXN mode after + * transaction stop. * *
- *       NL  CR  CW  PR  PW  EX
- *  NL    1   1   1   1   1   1
- *  CR    1   1   1   1   1   0
- *  CW    1   1   1   0   0   0
- *  PR    1   1   0   1   0   0
- *  PW    1   1   0   0   0   0
- *  EX    1   0   0   0   0   0
+ *       NL  CR  CW  PR  PW  EX GROUP COS TXN
+ *  NL    1   1   1   1   1   1   1   1   1
+ *  CR    1   1   1   1   1   0   0   0   1
+ *  CW    1   1   1   0   0   0   0   0   1
+ *  PR    1   1   0   1   0   0   0   0   1
+ *  PW    1   1   0   0   0   0   0   0   0
+ *  EX    1   0   0   0   0   0   0   0   0
+ *  GROUP 1   0   0   0   0   0   1   0   0
+ *  COS   1   0   0   0   0   0   0   1   0
+ *  TXN   1   1   1   1   0   0   0   0   1
  * 
*/ /** @{ */ -#define LCK_COMPAT_EX LCK_NL -#define LCK_COMPAT_PW (LCK_COMPAT_EX | LCK_CR) -#define LCK_COMPAT_PR (LCK_COMPAT_PW | LCK_PR) -#define LCK_COMPAT_CW (LCK_COMPAT_PW | LCK_CW) -#define LCK_COMPAT_CR (LCK_COMPAT_CW | LCK_PR | LCK_PW) -#define LCK_COMPAT_NL (LCK_COMPAT_CR | LCK_EX | LCK_GROUP) -#define LCK_COMPAT_GROUP (LCK_GROUP | LCK_NL) -#define LCK_COMPAT_COS (LCK_COS) +#define LCK_COMPAT_EX LCK_NL +#define LCK_COMPAT_PW (LCK_COMPAT_EX | LCK_CR) +#define LCK_COMPAT_PR (LCK_COMPAT_PW | LCK_PR | LCK_TXN) +#define LCK_COMPAT_CW (LCK_COMPAT_PW | LCK_CW | LCK_TXN) +#define LCK_COMPAT_CR (LCK_COMPAT_CW | LCK_PR | LCK_PW | LCK_TXN) +#define LCK_COMPAT_NL (LCK_COMPAT_CR | LCK_EX | LCK_GROUP | LCK_COS) +#define LCK_COMPAT_GROUP (LCK_NL | LCK_GROUP) +#define LCK_COMPAT_COS (LCK_NL | LCK_COS) +#define LCK_COMPAT_TXN (LCK_COMPAT_PR | LCK_CW) /** @} Lock Compatibility Matrix */ extern enum ldlm_mode lck_compat_array[]; diff --git a/fs/lustre/ldlm/ldlm_inodebits.c b/fs/lustre/ldlm/ldlm_inodebits.c index 892a0dd82fee..d73955ded917 100644 --- a/fs/lustre/ldlm/ldlm_inodebits.c +++ b/fs/lustre/ldlm/ldlm_inodebits.c @@ -58,6 +58,8 @@ void ldlm_ibits_policy_wire_to_local(const union ldlm_wire_policy_data *wpolicy, union ldlm_policy_data *lpolicy) { lpolicy->l_inodebits.bits = wpolicy->l_inodebits.bits; + lpolicy->l_inodebits.li_initiator_id = + wpolicy->l_inodebits.li_initiator_id; /** * try_bits and li_gid are to be handled outside of generic * write_to_local due to different behavior on a server and client. @@ -70,6 +72,8 @@ void ldlm_ibits_policy_local_to_wire(const union ldlm_policy_data *lpolicy, memset(wpolicy, 0, sizeof(*wpolicy)); wpolicy->l_inodebits.bits = lpolicy->l_inodebits.bits; wpolicy->l_inodebits.li_gid = lpolicy->l_inodebits.li_gid; + wpolicy->l_inodebits.li_initiator_id = + lpolicy->l_inodebits.li_initiator_id; } /** diff --git a/fs/lustre/ldlm/ldlm_lib.c b/fs/lustre/ldlm/ldlm_lib.c index c9a10f0d87ea..497c40c425ba 100644 --- a/fs/lustre/ldlm/ldlm_lib.c +++ b/fs/lustre/ldlm/ldlm_lib.c @@ -878,6 +878,7 @@ enum ldlm_mode lck_compat_array[] = { [LCK_NL] = LCK_COMPAT_NL, [LCK_GROUP] = LCK_COMPAT_GROUP, [LCK_COS] = LCK_COMPAT_COS, + [LCK_TXN] = LCK_COMPAT_TXN, }; /** diff --git a/fs/lustre/ldlm/ldlm_lock.c b/fs/lustre/ldlm/ldlm_lock.c index 739798bd95d9..35a0610344e1 100644 --- a/fs/lustre/ldlm/ldlm_lock.c +++ b/fs/lustre/ldlm/ldlm_lock.c @@ -55,6 +55,7 @@ char *ldlm_lockname[] = { [LCK_NL] = "NL", [LCK_GROUP] = "GROUP", [LCK_COS] = "COS", + [LCK_TXN] = "TXN", }; EXPORT_SYMBOL(ldlm_lockname); @@ -668,7 +669,7 @@ void ldlm_lock_addref_internal_nolock(struct ldlm_lock *lock, lock->l_readers++; lu_ref_add_atomic(&lock->l_reference, "reader", lock); } - if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS)) { + if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS | LCK_TXN)) { lock->l_writers++; lu_ref_add_atomic(&lock->l_reference, "writer", lock); } @@ -733,7 +734,7 @@ void ldlm_lock_decref_internal_nolock(struct ldlm_lock *lock, lu_ref_del(&lock->l_reference, "reader", lock); lock->l_readers--; } - if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS)) { + if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS | LCK_TXN)) { LASSERT(lock->l_writers > 0); lu_ref_del(&lock->l_reference, "writer", lock); lock->l_writers--; @@ -1980,7 +1981,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, case LDLM_IBITS: libcfs_debug_msg(msgdata, - "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s gid %llu flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lld lvb_type: %d\n", + "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s gid %llu flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lld lvb_type: %d initiator: MDT%d\n", &vaf, ldlm_lock_to_ns_name(lock), lock, lock->l_handle.h_cookie, @@ -1997,7 +1998,8 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, lock->l_remote_handle.cookie, exp ? refcount_read(&exp->exp_handle.h_ref) : -99, lock->l_pid, lock->l_callback_timestamp, - lock->l_lvb_type); + lock->l_lvb_type, + lock->l_policy_data.l_inodebits.li_initiator_id); break; default: diff --git a/fs/lustre/ptlrpc/pack_generic.c b/fs/lustre/ptlrpc/pack_generic.c index e1692986dd4c..60fa2e820273 100644 --- a/fs/lustre/ptlrpc/pack_generic.c +++ b/fs/lustre/ptlrpc/pack_generic.c @@ -2446,7 +2446,7 @@ static void lustre_swab_ldlm_policy_data(union ldlm_wire_policy_data *d) __swab64s(&d->l_extent.start); __swab64s(&d->l_extent.end); __swab64s(&d->l_extent.gid); - __swab64s(&d->l_flock.lfw_owner); + __swab32s(&d->l_flock.lfw_padding); __swab32s(&d->l_flock.lfw_pid); } diff --git a/fs/lustre/ptlrpc/service.c b/fs/lustre/ptlrpc/service.c index 3acf1bbed0ef..259f79c9b995 100644 --- a/fs/lustre/ptlrpc/service.c +++ b/fs/lustre/ptlrpc/service.c @@ -1887,11 +1887,6 @@ static int ptlrpc_handle_rs(struct ptlrpc_reply_state *rs) LASSERT(rs->rs_scheduled); LASSERT(list_empty(&rs->rs_list)); - spin_lock(&exp->exp_lock); - /* Noop if removed already */ - list_del_init(&rs->rs_exp_list); - spin_unlock(&exp->exp_lock); - /* * The disk commit callback holds exp_uncommitted_replies_lock while it * iterates over newly committed replies, removing them from @@ -1921,6 +1916,11 @@ static int ptlrpc_handle_rs(struct ptlrpc_reply_state *rs) spin_unlock(&exp->exp_uncommitted_replies_lock); } + spin_lock(&exp->exp_lock); + /* Noop if removed already */ + list_del_init(&rs->rs_exp_list); + spin_unlock(&exp->exp_lock); + spin_lock(&rs->rs_lock); been_handled = rs->rs_handled; diff --git a/fs/lustre/ptlrpc/wiretest.c b/fs/lustre/ptlrpc/wiretest.c index b3135d4a7990..ecc7e966aa52 100644 --- a/fs/lustre/ptlrpc/wiretest.c +++ b/fs/lustre/ptlrpc/wiretest.c @@ -321,9 +321,11 @@ void lustre_assert_wire_constants(void) (long long)LCK_GROUP); LASSERTF(LCK_COS == 128, "found %lld\n", (long long)LCK_COS); - LASSERTF(LCK_MAXMODE == 129, "found %lld\n", + LASSERTF(LCK_TXN == 256, "found %lld\n", + (long long)LCK_TXN); + LASSERTF(LCK_MAXMODE == 257, "found %lld\n", (long long)LCK_MAXMODE); - LASSERTF(LCK_MODE_NUM == 8, "found %lld\n", + LASSERTF(LCK_MODE_NUM == 9, "found %lld\n", (long long)LCK_MODE_NUM); BUILD_BUG_ON(LDLM_PLAIN != 10); BUILD_BUG_ON(LDLM_EXTENT != 11); @@ -3328,7 +3330,7 @@ void lustre_assert_wire_constants(void) (long long)(int)sizeof(((struct ldlm_extent *)0)->gid)); /* Checks for struct ldlm_inodebits */ - LASSERTF((int)sizeof(struct ldlm_inodebits) == 24, "found %lld\n", + LASSERTF((int)sizeof(struct ldlm_inodebits) == 32, "found %lld\n", (long long)(int)sizeof(struct ldlm_inodebits)); LASSERTF((int)offsetof(struct ldlm_inodebits, bits) == 0, "found %lld\n", (long long)(int)offsetof(struct ldlm_inodebits, bits)); @@ -3342,6 +3344,14 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct ldlm_inodebits, li_gid)); LASSERTF((int)sizeof(((struct ldlm_inodebits *)0)->li_gid) == 8, "found %lld\n", (long long)(int)sizeof(((struct ldlm_inodebits *)0)->li_gid)); + LASSERTF((int)offsetof(struct ldlm_inodebits, li_padding) == 24, "found %lld\n", + (long long)(int)offsetof(struct ldlm_inodebits, li_padding)); + LASSERTF((int)sizeof(((struct ldlm_inodebits *)0)->li_padding) == 4, "found %lld\n", + (long long)(int)sizeof(((struct ldlm_inodebits *)0)->li_padding)); + LASSERTF((int)offsetof(struct ldlm_inodebits, li_initiator_id) == 28, "found %lld\n", + (long long)(int)offsetof(struct ldlm_inodebits, li_initiator_id)); + LASSERTF((int)sizeof(((struct ldlm_inodebits *)0)->li_initiator_id) == 4, "found %lld\n", + (long long)(int)sizeof(((struct ldlm_inodebits *)0)->li_initiator_id)); /* Checks for struct ldlm_flock_wire */ LASSERTF((int)sizeof(struct ldlm_flock_wire) == 32, "found %lld\n", diff --git a/include/uapi/linux/lustre/lustre_idl.h b/include/uapi/linux/lustre/lustre_idl.h index b61fa5c6d9a1..ecd4456e3074 100644 --- a/include/uapi/linux/lustre/lustre_idl.h +++ b/include/uapi/linux/lustre/lustre_idl.h @@ -2159,10 +2159,11 @@ enum ldlm_mode { LCK_NL = 32, LCK_GROUP = 64, LCK_COS = 128, + LCK_TXN = 256, LCK_MAXMODE }; -#define LCK_MODE_NUM 8 +#define LCK_MODE_NUM 9 enum ldlm_type { LDLM_PLAIN = 10, @@ -2190,6 +2191,8 @@ struct ldlm_inodebits { __u64 bits; __u64 cancel_bits; /* for lock convert */ __u64 li_gid; + __u32 li_padding; + __u32 li_initiator_id; /* index of MDT that initiated this lock */ }; struct ldlm_flock_wire { From patchwork Fri Mar 21 13:07:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025464 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A079C36000 for ; Fri, 21 Mar 2025 13:45:42 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2ws4Bs1z1y20; Fri, 21 Mar 2025 06:14:53 -0700 (PDT) Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2q70T2rz1yhy for ; Fri, 21 Mar 2025 06:09:55 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm3-e204-208.ccs.ornl.gov [160.91.203.26]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id B0B2F893E88; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id AE493106BE18; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:07:09 -0400 Message-ID: <20250321130711.3257092-27-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 26/27] lustre: ptlrpc: OBD_FAIL_PTLRPC_DELAY_SEND_FAIL fixes X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Horn , Alex Deiter , Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Chris Horn Modify test to ensure idle disconnect is enabled for all targets except OST0000. This prevents an issue where an idle ping is sent to another target instead of OST0000. Re-work test to check the debug log for all relevant messages. Added a debug statement to ptl_send_rpc(), and moved an existing one, to faciliate debugging any future test failures. Fixes: ecba969 ("lustre: ptlrpc: Track highest reply XID") WC-bug-id: https://jira.whamcloud.com/browse/LU-16843 Lustre-commit: fdfdf5c05cf642940 ("LU-16483 tests: replay-single test_200 fixes") Signed-off-by: Chris Horn Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50891 Reviewed-by: Andreas Dilger Reviewed-by: Alex Deiter Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/ptlrpc/niobuf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/lustre/ptlrpc/niobuf.c b/fs/lustre/ptlrpc/niobuf.c index d426d3c678b7..e06857376019 100644 --- a/fs/lustre/ptlrpc/niobuf.c +++ b/fs/lustre/ptlrpc/niobuf.c @@ -726,12 +726,15 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) request->rq_deadline = request->rq_sent + request->rq_timeout + ptlrpc_at_get_net_latency(request); + DEBUG_REQ(D_INFO, request, "send flags=%x", + lustre_msg_get_flags(request->rq_reqmsg)); + if (unlikely(opc == OBD_PING && - CFS_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_DELAY_SEND_FAIL, cfs_fail_val))) + CFS_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_DELAY_SEND_FAIL, cfs_fail_val))) { + DEBUG_REQ(D_INFO, request, "Simulate delay send failure"); goto skip_send; + } - DEBUG_REQ(D_INFO, request, "send flags=%x", - lustre_msg_get_flags(request->rq_reqmsg)); rc = ptl_send_buf(&request->rq_req_md_h, request->rq_reqbuf, request->rq_reqdata_len, LNET_NOACK_REQ, &request->rq_req_cbid, From patchwork Fri Mar 21 13:07:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 14025465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from pdx1-mailman-customer002.dreamhost.com (listserver-buz.dreamhost.com [69.163.136.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D1F9EC36000 for ; Fri, 21 Mar 2025 13:46:21 +0000 (UTC) Received: from pdx1-mailman-customer002.dreamhost.com (localhost [127.0.0.1]) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTP id 4ZK2xq2Sd0z2138; Fri, 21 Mar 2025 06:15:43 -0700 (PDT) Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pdx1-mailman-customer002.dreamhost.com (Postfix) with ESMTPS id 4ZK2q72WZVz1ynp for ; Fri, 21 Mar 2025 06:09:55 -0700 (PDT) Received: from star2.ccs.ornl.gov (ltm4-e204-208.ccs.ornl.gov [160.91.203.22]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id B324A17B5B8; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) Received: by star2.ccs.ornl.gov (Postfix, from userid 2004) id B1CEB106BE14; Fri, 21 Mar 2025 09:07:14 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Fri, 21 Mar 2025 09:07:10 -0400 Message-ID: <20250321130711.3257092-28-jsimmons@infradead.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250321130711.3257092-1-jsimmons@infradead.org> References: <20250321130711.3257092-1-jsimmons@infradead.org> MIME-Version: 1.0 Subject: [lustre-devel] [PATCH 27/27] lustre: obd: remove unused obd_evict_inprogress X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Timothy Day Remove the atomic_t struct field obd_evict_inprogress from 'struct obd_device'. This field was only ever incremented in a unused function that was removed in a previous patch. Hence, remove it altogther. This patch also removes the associated wait queue. WC-bug-id: https://jira.whamcloud.com/browse/LU-16965 Lustre-commit: d5051f374799bed52 ("LU-16965 obd: remove unused obd_evict_inprogress") Signed-off-by: Timothy Day Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51681 Reviewed-by: Patrick Farrell Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/include/obd.h | 2 -- fs/lustre/obdclass/genops.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/fs/lustre/include/obd.h b/fs/lustre/include/obd.h index 8f6d42544711..f385c677020e 100644 --- a/fs/lustre/include/obd.h +++ b/fs/lustre/include/obd.h @@ -620,8 +620,6 @@ struct obd_device { struct lprocfs_stats *obd_svc_stats; const struct attribute **obd_attrs; struct ldebugfs_vars *obd_vars; - atomic_t obd_evict_inprogress; - wait_queue_head_t obd_evict_inprogress_waitq; struct list_head obd_evict_list; /* protected with pet_lock */ /** diff --git a/fs/lustre/obdclass/genops.c b/fs/lustre/obdclass/genops.c index 0cbc2c7c393d..935ba92c387a 100644 --- a/fs/lustre/obdclass/genops.c +++ b/fs/lustre/obdclass/genops.c @@ -309,8 +309,6 @@ struct obd_device *class_newdev(const char *type_name, const char *name, /* XXX belongs in setup not attach */ init_rwsem(&newdev->obd_observer_link_sem); - /* recovery data */ - init_waitqueue_head(&newdev->obd_evict_inprogress_waitq); llog_group_init(&newdev->obd_olg); /* Detach drops this */