From patchwork Thu Oct 3 19:34:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 13821461 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 693261A727F for ; Thu, 3 Oct 2024 19:35:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984107; cv=none; b=unIQaEJ1l6fsACK6LDOYSgt7mtvBnBcwKkxWEbh2UFEcQtMyzfeXY4uMPw7dFPsQiyTxlYMVLdUeQk+4l7o0ujtfWvKzhIf8DbkV4gTy0YdRiExSiAXGI5NB+GZc24W7XkGRGBSm71JvfjGa2EYvIiLNAsjKjYzGowX2lp6xs7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984107; c=relaxed/simple; bh=Zb7197YfQ1LtCHlCEuSs83CLgWL9vDqTe3kpj30t1aU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B6wOaXyYBhyaOgZ8MgBP/hAdbl45rfGqUoihkY7rxU1ArIKRtuWSe9ZLTTUKkzsogm4L/oyKVqjJegZDz2jP8rNXcJuqQYlZ85ua3sX/PqvnKIyT1ts0hbmX7QLtqszRYJGtLCEiewXYd1wRgvS1vY+JEmsTSwBTJdVxBTwIF6Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fpjtDnhW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fpjtDnhW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1BABC4CEC5; Thu, 3 Oct 2024 19:35:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727984107; bh=Zb7197YfQ1LtCHlCEuSs83CLgWL9vDqTe3kpj30t1aU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fpjtDnhWwYB1aO1vbi5sp3u9+kUtTC3R294aPV6drXdu8FELMWa56XqK9iG1j8Kl5 97+iUosgRwVCI8FfZ5VRvZRksk2hJJ4QFOTtI+5QNA1h6qmlr2+deLoSqtXpzVVCbv AASgcYDfUgLyLHV/axdNpwfU99x+bHvP2LHJ3U+dvqt2FK3Z3z99ZOCJPTro02SDq4 /kGOsyOPAC5JN1hkLWZZEnXrSQhjTxM2GwVBGqnm9GilinYL5xEzatK+Of7mvIEB3F dOKqhwRYKxmAS8M9Gqaorx1kkFoaVpT3Oor/vPWtgCN+OsHhQA1KxA/bnaDEW0yNz/ LuKSRGA3TJQyw== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Anna Schumaker , Trond Myklebust , NeilBrown , Matthew Wilcox , Christian Brauner Subject: [6.12-rc2 v2 PATCH 1/7] nfs_common: fix race in NFS calls to nfsd_file_put_local() and nfsd_serv_put() Date: Thu, 3 Oct 2024 15:34:58 -0400 Message-ID: <20241003193504.34640-2-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241003193504.34640-1-snitzer@kernel.org> References: <20241003193504.34640-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add nfs_to_nfsd_file_put_local() interface to fix race with nfsd module unload. Similarly, use RCU around nfs_open_local_fh()'s error path call to nfs_to->nfsd_serv_put(). Holding RCU ensures that NFS will safely _call and return_ from its nfs_to calls into the NFSD functions nfsd_file_put_local() and nfsd_serv_put(). Otherwise, if RCU isn't used then there is a narrow window when NFS's reference for the nfsd_file and nfsd_serv are dropped and the NFSD module could be unloaded, which could result in a crash from the return instruction for either nfs_to->nfsd_file_put_local() or nfs_to->nfsd_serv_put(). Reported-by: NeilBrown Signed-off-by: Mike Snitzer --- fs/nfs/localio.c | 6 +++--- fs/nfs_common/nfslocalio.c | 5 ++++- fs/nfsd/filecache.c | 2 +- fs/nfsd/localio.c | 2 +- fs/nfsd/nfssvc.c | 4 ++-- include/linux/nfslocalio.h | 15 +++++++++++++++ 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c index c29cdf51c458..d124c265b8fd 100644 --- a/fs/nfs/localio.c +++ b/fs/nfs/localio.c @@ -341,7 +341,7 @@ nfs_local_pgio_release(struct nfs_local_kiocb *iocb) { struct nfs_pgio_header *hdr = iocb->hdr; - nfs_to->nfsd_file_put_local(iocb->localio); + nfs_to_nfsd_file_put_local(iocb->localio); nfs_local_iocb_free(iocb); nfs_local_hdr_release(hdr, hdr->task.tk_ops); } @@ -622,7 +622,7 @@ int nfs_local_doio(struct nfs_client *clp, struct nfsd_file *localio, } out: if (status != 0) { - nfs_to->nfsd_file_put_local(localio); + nfs_to_nfsd_file_put_local(localio); hdr->task.tk_status = status; nfs_local_hdr_release(hdr, call_ops); } @@ -673,7 +673,7 @@ nfs_local_release_commit_data(struct nfsd_file *localio, struct nfs_commit_data *data, const struct rpc_call_ops *call_ops) { - nfs_to->nfsd_file_put_local(localio); + nfs_to_nfsd_file_put_local(localio); call_ops->rpc_call_done(&data->task, data); call_ops->rpc_release(data); } diff --git a/fs/nfs_common/nfslocalio.c b/fs/nfs_common/nfslocalio.c index 42b479b9191f..5c8ce5066c16 100644 --- a/fs/nfs_common/nfslocalio.c +++ b/fs/nfs_common/nfslocalio.c @@ -142,8 +142,11 @@ struct nfsd_file *nfs_open_local_fh(nfs_uuid_t *uuid, /* We have an implied reference to net thanks to nfsd_serv_try_get */ localio = nfs_to->nfsd_open_local_fh(net, uuid->dom, rpc_clnt, cred, nfs_fh, fmode); - if (IS_ERR(localio)) + if (IS_ERR(localio)) { + rcu_read_lock(); nfs_to->nfsd_serv_put(net); + rcu_read_unlock(); + } return localio; } EXPORT_SYMBOL_GPL(nfs_open_local_fh); diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index 19bb88c7eebd..53070e1de3d9 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -398,7 +398,7 @@ nfsd_file_put(struct nfsd_file *nf) * reference to the associated nn->nfsd_serv. */ void -nfsd_file_put_local(struct nfsd_file *nf) +nfsd_file_put_local(struct nfsd_file *nf) __must_hold(rcu) { struct net *net = nf->nf_net; diff --git a/fs/nfsd/localio.c b/fs/nfsd/localio.c index 291e9c69cae4..f441cb9f74d5 100644 --- a/fs/nfsd/localio.c +++ b/fs/nfsd/localio.c @@ -53,7 +53,7 @@ void nfsd_localio_ops_init(void) * * On successful return, returned nfsd_file will have its nf_net member * set. Caller (NFS client) is responsible for calling nfsd_serv_put and - * nfsd_file_put (via nfs_to->nfsd_file_put_local). + * nfsd_file_put (via nfs_to_nfsd_file_put_local). */ struct nfsd_file * nfsd_open_local_fh(struct net *net, struct auth_domain *dom, diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index e236135ddc63..47172b407be8 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -214,14 +214,14 @@ int nfsd_minorversion(struct nfsd_net *nn, u32 minorversion, enum vers_op change return 0; } -bool nfsd_serv_try_get(struct net *net) +bool nfsd_serv_try_get(struct net *net) __must_hold(rcu) { struct nfsd_net *nn = net_generic(net, nfsd_net_id); return (nn && percpu_ref_tryget_live(&nn->nfsd_serv_ref)); } -void nfsd_serv_put(struct net *net) +void nfsd_serv_put(struct net *net) __must_hold(rcu) { struct nfsd_net *nn = net_generic(net, nfsd_net_id); diff --git a/include/linux/nfslocalio.h b/include/linux/nfslocalio.h index b353abe00357..b0dd9b1eef4f 100644 --- a/include/linux/nfslocalio.h +++ b/include/linux/nfslocalio.h @@ -65,10 +65,25 @@ struct nfsd_file *nfs_open_local_fh(nfs_uuid_t *, struct rpc_clnt *, const struct cred *, const struct nfs_fh *, const fmode_t); +static inline void nfs_to_nfsd_file_put_local(struct nfsd_file *localio) +{ + /* + * Once reference to nfsd_serv is dropped, NFSD could be + * unloaded, so ensure safe return from nfsd_file_put_local() + * by always taking RCU. + */ + rcu_read_lock(); + nfs_to->nfsd_file_put_local(localio); + rcu_read_unlock(); +} + #else /* CONFIG_NFS_LOCALIO */ static inline void nfsd_localio_ops_init(void) { } +static inline void nfs_to_nfsd_file_put_local(struct nfsd_file *localio) +{ +} #endif /* CONFIG_NFS_LOCALIO */ #endif /* __LINUX_NFSLOCALIO_H */ From patchwork Thu Oct 3 19:34:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 13821462 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E4AE1A727F for ; Thu, 3 Oct 2024 19:35:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984108; cv=none; b=ZELKyFs9ZwYFuscXqVK3vCLl9vsT6JZG7DopOTTqAVqAXzEylvY2BtsBfnjlB1HpSLcyLiuu4oXOD5Hmpn3QfgxgQmx/KzhX2sXktxv+qpZnE7XaflGtJ4DuuByzfa0N7sKwKZZD7VdKrcxxhNma5FvGNycQamp7OlIc46uP+Zc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984108; c=relaxed/simple; bh=XPyoE9dVY62vPXx3WG6hzS+O/HREZFHslty1olFBUd4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Sapppmdngj2QQ26SdT/VmpiqrfcZhuR2PfGNisVB0mSJ26Qn4VDctFpuWduSUg+MM3luuyeb0C9ScZySuoatgmd/oMHzBZi6ZuzRVGllMYEMakEyS1WHeJoEoEd36O6AVqL0IU6B6TF4/HX9bpSY538vHRMpnImzsYvf8FztUjU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gCenL5EZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gCenL5EZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11A92C4CEC5; Thu, 3 Oct 2024 19:35:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727984108; bh=XPyoE9dVY62vPXx3WG6hzS+O/HREZFHslty1olFBUd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gCenL5EZMr/nA0+LlZCBKbVw9taIcMw+uF1nwRwJiF7O/XkJqP52IGbIgNZ8KS2/r mf0/8GH3Vj4QWZITHqPdhgWJWXJrA6ph5yFWrHEd2Sz27VBkPEyLo+EV2iIp1ba0Qr k7++ZwgvMfyCpvbLQqZtS7vYk6EL20BrbVIxFA+VQYT0bHNQ4MKhhvFjkcXwDek5l5 c1z/JR8cIui9uIjlZ2vZagPuGr0BwHpstjglSgrUiBe3Es0uSmgHUM0YMevvdJaD3j yjyt6PeXoYkCTRnPL+yk4Tx+bt6N2DNAI2EaKHpGlm7vYmmM5PJf15rqtdLFyY+wuv qwO/x76w38aKA== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Anna Schumaker , Trond Myklebust , NeilBrown , Matthew Wilcox , Christian Brauner Subject: [6.12-rc2 v2 PATCH 2/7] nfs_common: fix Kconfig for NFS_COMMON_LOCALIO_SUPPORT Date: Thu, 3 Oct 2024 15:34:59 -0400 Message-ID: <20241003193504.34640-3-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241003193504.34640-1-snitzer@kernel.org> References: <20241003193504.34640-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The 'default n' that was in NFS_COMMON_LOCALIO_SUPPORT caused these extra defaults to be missed: default y if NFSD=y || NFS_FS=y default m if NFSD=m && NFS_FS=m Remove the 'default n' for NFS_COMMON_LOCALIO_SUPPORT so that the correct tristate is selected based on how NFSD and NFS_FS are configured. This fixes the reported case where NFS_FS=y but NFS_COMMON_LOCALIO_SUPPORT=m, it is now correctly set to =y. In addition, add extra 'depends on NFS_LOCALIO' to NFS_COMMON_LOCALIO_SUPPORT so that if NFS_LOCALIO isn't set then NFS_COMMON_LOCALIO_SUPPORT will not be either. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202410031944.hMCFY9BO-lkp@intel.com/ Signed-off-by: Mike Snitzer --- fs/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/Kconfig b/fs/Kconfig index 24d4e4b419d1..da8ad9aba3e9 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -384,7 +384,7 @@ config NFS_COMMON config NFS_COMMON_LOCALIO_SUPPORT tristate - default n + depends on NFS_LOCALIO default y if NFSD=y || NFS_FS=y default m if NFSD=m && NFS_FS=m select SUNRPC From patchwork Thu Oct 3 19:35:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 13821463 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD8951A727F for ; Thu, 3 Oct 2024 19:35:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984109; cv=none; b=eczSw9icDnfFsgmh7YjFtRN1SZbduoLPqt7h27XCnbJ7Bd6YgKiNiN/wTyXUu4rwNlNREj6IdWgHrub4n5j3G9rKJNQB7BbJhtA/HkB4z3stnkusJB0EFbpceuZK7aplqQZGep4QYXCbCst50GfbmXhYxTgJp+64GNgrhY9aZrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984109; c=relaxed/simple; bh=Y5JAYdrl1fcRPxjfNiaeXTuXBy4NCDXId8+T/RaDQU8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HcdoNRTzaWAkHP2Zvv+QJMN/cj/RDpj2C8TZJRQk+jMI6BxRYj1Ccpn1GHbP/dMj8+EPyhfvT2p17AoSRQxWbh4a/6NB6sANYkGMy3Cqk16KhDpEddZIKe1S+XhEE/HlRSeNwsa3fyU8G9WhIwXvn4lXvHsbAuEr57VSvN5di3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Faqniezg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Faqniezg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 681AAC4CEC5; Thu, 3 Oct 2024 19:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727984109; bh=Y5JAYdrl1fcRPxjfNiaeXTuXBy4NCDXId8+T/RaDQU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FaqniezgCaB9At80lswrlGNSJtw8BSEiy2h6jDUw1R/YBpD1c40gHhTeQko8hr5Xu yF59qWVv3cphStkw58t+qbC5FeupupGLm4UY+JsGmbyAC/eTWCJG89pb/G/N6yvwWr wnUNv3jS2udx99RG7Mb/O8PybGNJDMNQiOVd27lPBWZ+XhovUJJpQzTclYxMyCZMeV K+1fniwUZWPiWpz5R1xuCutSjXvZBkfO2udm4a2IXAUbmbIllMoiOZ17IZhxnPW+e2 ERlFnTesNC8/iQSDcMocK4Tk9mDV/bHD9y9jR4x0rcYkXsTWh10XA9rf8ZatoCWlKF l7wkxjnIi9Gqw== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Anna Schumaker , Trond Myklebust , NeilBrown , Matthew Wilcox , Christian Brauner Subject: [6.12-rc2 v2 PATCH 3/7] nfsd/localio: fix nfsd_file tracepoints to handle NULL rqstp Date: Thu, 3 Oct 2024 15:35:00 -0400 Message-ID: <20241003193504.34640-4-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241003193504.34640-1-snitzer@kernel.org> References: <20241003193504.34640-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Otherwise nfsd_file_acquire, nfsd_file_insert_err, and nfsd_file_cons_err will hit a NULL pointer when they are enabled and LOCALIO used. Example trace output (note xid is 0x0 and LOCALIO flag set): nfsd_file_acquire: xid=0x0 inode=0000000069a1b2e7 may_flags=WRITE|LOCALIO ref=1 nf_flags=HASHED|GC nf_may=WRITE nf_file=0000000070123234 status=0 Fixes: c63f0e48febf ("nfsd: add nfsd_file_acquire_local()") Signed-off-by: Mike Snitzer Reviewed-by: Chuck Lever --- fs/nfsd/trace.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index c625966cfcf3..b8470d4cbe99 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -1113,7 +1113,7 @@ TRACE_EVENT(nfsd_file_acquire, ), TP_fast_assign( - __entry->xid = be32_to_cpu(rqstp->rq_xid); + __entry->xid = rqstp ? be32_to_cpu(rqstp->rq_xid) : 0; __entry->inode = inode; __entry->may_flags = may_flags; __entry->nf_ref = nf ? refcount_read(&nf->nf_ref) : 0; @@ -1147,7 +1147,7 @@ TRACE_EVENT(nfsd_file_insert_err, __field(long, error) ), TP_fast_assign( - __entry->xid = be32_to_cpu(rqstp->rq_xid); + __entry->xid = rqstp ? be32_to_cpu(rqstp->rq_xid) : 0; __entry->inode = inode; __entry->may_flags = may_flags; __entry->error = error; @@ -1177,7 +1177,7 @@ TRACE_EVENT(nfsd_file_cons_err, __field(const void *, nf_file) ), TP_fast_assign( - __entry->xid = be32_to_cpu(rqstp->rq_xid); + __entry->xid = rqstp ? be32_to_cpu(rqstp->rq_xid) : 0; __entry->inode = inode; __entry->may_flags = may_flags; __entry->nf_ref = refcount_read(&nf->nf_ref); From patchwork Thu Oct 3 19:35:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 13821464 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6442C1AAE0C for ; Thu, 3 Oct 2024 19:35:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984111; cv=none; b=eNV84dzwp+MWseG1ptaZUs9l1VJnbq9ShO8wD2Q74dSt3m9g4z6qno+goJiCfeC5gifmd8S824X3ss3szbSsWlS1HqSsvnhiOAvthp4FSYpxReOI3Iox4zqB2Jj1md2nOICqd5RhFl4MyPQJFaDuAvcLE+ZXY+1PjecBzmgfDCQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984111; c=relaxed/simple; bh=dO9gozPdQl2OhaD5p9iHUgs5avHYX0qx6mcdaqSzgvU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pGezhtJS5Mj+/Ole2LhjJuUhRXUvZ6YlhImgfRDPYEWBHJ72DuPFUL7qxu/kB7S8Z38goX7aGZP39r/ON78KM6bm9jnvpPKwyTFkXvJQ/dUNtSyfpCJ8LgZxIhdftd0wlswrt8Ha1L1PjoPm23ndV9xct4gak5gU7Us1SPLGuYM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZwuIIBN7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZwuIIBN7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7C37C4CEC5; Thu, 3 Oct 2024 19:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727984110; bh=dO9gozPdQl2OhaD5p9iHUgs5avHYX0qx6mcdaqSzgvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZwuIIBN7tZN7x0xAKa/l+UaZYPf7hmftHQYTZPvv3/g8ziN8rOf0QJx/C/Jf18dpD 7osM44OHVEBYWnepTfQVeV78aCfKeFQUvvWxnQUbZZ/3xxV1ORRyoIOo5pFJMM0qwb b1GAhJtpve4caZSLkDUmoFpyESbZnTIr7tqR/jK4uaiBa4g0+WIOxDHZcCqUkz7U2B IcgiHQOkxBRydVumR+O5Q7qZOczIcHN7LdxQ9tNpCEkeBW8t3XFlOx0D3WmLWJ4xZ1 DGQJYer0nTmO7qaeK3Zoit0ZM2I/XfrOqxGztCzprbtOyp+nPgyoPGeCBUh+zxo+dx DD4wBD7f70cZQ== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Anna Schumaker , Trond Myklebust , NeilBrown , Matthew Wilcox , Christian Brauner Subject: [6.12-rc2 v2 PATCH 4/7] nfs/localio: remove redundant suid/sgid handling Date: Thu, 3 Oct 2024 15:35:01 -0400 Message-ID: <20241003193504.34640-5-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241003193504.34640-1-snitzer@kernel.org> References: <20241003193504.34640-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mike Snitzer nfs_writeback_done() will take care of suid/sgid corner case. Signed-off-by: Mike Snitzer --- fs/nfs/localio.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c index d124c265b8fd..88b6658b93fc 100644 --- a/fs/nfs/localio.c +++ b/fs/nfs/localio.c @@ -521,12 +521,7 @@ nfs_local_write_done(struct nfs_local_kiocb *iocb, long status) } if (status < 0) nfs_reset_boot_verifier(inode); - else if (nfs_should_remove_suid(inode)) { - /* Deal with the suid/sgid bit corner case */ - spin_lock(&inode->i_lock); - nfs_set_cache_invalid(inode, NFS_INO_INVALID_MODE); - spin_unlock(&inode->i_lock); - } + nfs_local_pgio_done(hdr, status); } From patchwork Thu Oct 3 19:35:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 13821465 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FDFD1AAE0C for ; Thu, 3 Oct 2024 19:35:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984112; cv=none; b=uPgezLpREoELofsGMqy7MAgJTVTuFLWsAFXQM8ZAskdfgz8dG4gmc4qzPQqJpYgB13aywKWzyU1R5oirBn6yZPviy/XI1ajlV5u8780QkIZl8Aj6RozHMvgv14CSrhd+k/HmLajybJwELAf8uODJT6Mr64PWGPD0aIzpqNg9kfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984112; c=relaxed/simple; bh=7ldDcdObu85WuKTz+1DDacI/L7k70lt+f+X9H03hq7M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I0bKkOVOP2grcfIKoKOH4tP0kSulESXIgp50I9tQyJyN8T/ykCogTVaMQQUsxQ4v4OT79jBaYme9bXzyOiqEuZ+92wRRIW9xPco7JF3AGOv8JoO+tIyfB36sf6AUTWIOkluXUk14/D1QRoYFAsiLexockBx7nINrCw82iunOFi8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LKm5mArS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LKm5mArS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14153C4CEC5; Thu, 3 Oct 2024 19:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727984112; bh=7ldDcdObu85WuKTz+1DDacI/L7k70lt+f+X9H03hq7M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LKm5mArS2X/UjI5eI7oIaFqMz4gUXXnhbHsIdOEzlnGl2M89CD5OpNK7R5S3lLvLk /IFeEOYVRpBOMP1qeSYYxnHKa0Ntn1Pz+XvSCrLcmW2DbLUskJKOKmUnR4OrzF84cr qR798ug55KTx1WhvHikVuBOo1kCy32PNukkO1Xf5SgJdqdzWShRPIqT3l+TpffHda5 QmRHyAOwGNOvQYy3WSbBHJ2DNPPgVEzH6H2Jwz2KMOBolQWi3kO89t+16l1TZmSYu6 hBwLG2y4QD/ilC4OyFnldis50KSuSJPLrQGibucieRQkPHcXNECPdiAHIoETofohYz BVp5Gt6HoD7iw== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Anna Schumaker , Trond Myklebust , NeilBrown , Matthew Wilcox , Christian Brauner Subject: [6.12-rc2 v2 PATCH 5/7] nfs/localio: eliminate unnecessary kref in nfs_local_fsync_ctx Date: Thu, 3 Oct 2024 15:35:02 -0400 Message-ID: <20241003193504.34640-6-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241003193504.34640-1-snitzer@kernel.org> References: <20241003193504.34640-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 nfs_local_commit() doesn't need async cleanup of nfs_local_fsync_ctx, so there is no need to use a kref. Signed-off-by: Mike Snitzer --- fs/nfs/localio.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c index 88b6658b93fc..2f302b03b253 100644 --- a/fs/nfs/localio.c +++ b/fs/nfs/localio.c @@ -43,7 +43,6 @@ struct nfs_local_fsync_ctx { struct nfsd_file *localio; struct nfs_commit_data *data; struct work_struct work; - struct kref kref; struct completion *done; }; static void nfs_local_fsync_work(struct work_struct *work); @@ -683,30 +682,17 @@ nfs_local_fsync_ctx_alloc(struct nfs_commit_data *data, ctx->localio = localio; ctx->data = data; INIT_WORK(&ctx->work, nfs_local_fsync_work); - kref_init(&ctx->kref); ctx->done = NULL; } return ctx; } -static void -nfs_local_fsync_ctx_kref_free(struct kref *kref) -{ - kfree(container_of(kref, struct nfs_local_fsync_ctx, kref)); -} - -static void -nfs_local_fsync_ctx_put(struct nfs_local_fsync_ctx *ctx) -{ - kref_put(&ctx->kref, nfs_local_fsync_ctx_kref_free); -} - static void nfs_local_fsync_ctx_free(struct nfs_local_fsync_ctx *ctx) { nfs_local_release_commit_data(ctx->localio, ctx->data, ctx->data->task.tk_ops); - nfs_local_fsync_ctx_put(ctx); + kfree(ctx); } static void @@ -739,7 +725,7 @@ int nfs_local_commit(struct nfsd_file *localio, } nfs_local_init_commit(data, call_ops); - kref_get(&ctx->kref); + if (how & FLUSH_SYNC) { DECLARE_COMPLETION_ONSTACK(done); ctx->done = &done; @@ -747,6 +733,6 @@ int nfs_local_commit(struct nfsd_file *localio, wait_for_completion(&done); } else queue_work(nfsiod_workqueue, &ctx->work); - nfs_local_fsync_ctx_put(ctx); + return 0; } From patchwork Thu Oct 3 19:35:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 13821467 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D117A1AAE0C for ; Thu, 3 Oct 2024 19:35:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984113; cv=none; b=CIfXHb5I4BMqQujUV14Fj2cYTGvh0kM+a0r1PkrP2q8g6Ej+31mD2Esi7yp0/3v8za5flyw5+b7mzmngo61E9ENHMZ17wiTYAQRQSYAEIRrCLyL549RoOir1h9SOg3KTZ65yGKFu4eVkC6sCjanjXMALrlYi6V7HJGN3CcnaWEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984113; c=relaxed/simple; bh=g4o1E9ZHJpVvV8UBqlxcay2i9cSQlVEOIAKY8yV+YOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YxIfoef4mPNuqMti2V89bvkGcsGiUGLwk/rEo0Ii3U+nbV+A98S5F4K6oAxtZIMBCbanV3kNcGi8fw6mHkMuGM0QTNy9YuUg9SVqKS9zig7dzdnoJheLp2QGxE7hHdyvni8sCToPgqysohoFOUY/Qpgl+92yyQrKr2eFyL4D1k4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DOcXfJQk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DOcXfJQk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 583BAC4CEC5; Thu, 3 Oct 2024 19:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727984113; bh=g4o1E9ZHJpVvV8UBqlxcay2i9cSQlVEOIAKY8yV+YOw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DOcXfJQkets+DhcYTXeBR/OFX66irKPQUycBGCjhWNw5ixoux8DPPf3bJzr/I1xo2 8CoTEGPFI2ypy3IbEKTl7dT0tDUoTPw9L6rW0bfYV4+7y0uEsugozdey2pQ2hEQHNt YnbJsCFofXo0/PMN2y+EJIjDKstiQEAZ7GvEkFmxdmOHOgs8d1JDESgCujQZsFnUYK /MEvI3P/1+rvrvnX/XokKRXtj2sB7qgzIFrj13WeDV2O2dhVXGuwHadgoe7muTAFXP LSLKuVAKBfuXYDZq1UM/0YAjBXADG7NVC5TOfjXC7ar/xbZiQoqM+/9HH2gF/6Faxc injEAVczAz86A== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Anna Schumaker , Trond Myklebust , NeilBrown , Matthew Wilcox , Christian Brauner Subject: [6.12-rc2 v2 PATCH 6/7] nfs/localio: remove extra indirect nfs_to call to check {read,write}_iter Date: Thu, 3 Oct 2024 15:35:03 -0400 Message-ID: <20241003193504.34640-7-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241003193504.34640-1-snitzer@kernel.org> References: <20241003193504.34640-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Push the read_iter and write_iter availability checks down to nfs_do_local_read and nfs_do_local_write respectively. This eliminates a redundant nfs_to->nfsd_file_file() call. Signed-off-by: Mike Snitzer --- fs/nfs/localio.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c index 2f302b03b253..12d3e200156c 100644 --- a/fs/nfs/localio.c +++ b/fs/nfs/localio.c @@ -273,7 +273,7 @@ nfs_local_iocb_free(struct nfs_local_kiocb *iocb) static struct nfs_local_kiocb * nfs_local_iocb_alloc(struct nfs_pgio_header *hdr, - struct nfsd_file *localio, gfp_t flags) + struct file *file, gfp_t flags) { struct nfs_local_kiocb *iocb; @@ -286,9 +286,8 @@ nfs_local_iocb_alloc(struct nfs_pgio_header *hdr, kfree(iocb); return NULL; } - init_sync_kiocb(&iocb->kiocb, nfs_to->nfsd_file_file(localio)); + init_sync_kiocb(&iocb->kiocb, file); iocb->kiocb.ki_pos = hdr->args.offset; - iocb->localio = localio; iocb->hdr = hdr; iocb->kiocb.ki_flags &= ~IOCB_APPEND; return iocb; @@ -389,13 +388,19 @@ nfs_do_local_read(struct nfs_pgio_header *hdr, const struct rpc_call_ops *call_ops) { struct nfs_local_kiocb *iocb; + struct file *file = nfs_to->nfsd_file_file(localio); + + /* Don't support filesystems without read_iter */ + if (!file->f_op->read_iter) + return -EAGAIN; dprintk("%s: vfs_read count=%u pos=%llu\n", __func__, hdr->args.count, hdr->args.offset); - iocb = nfs_local_iocb_alloc(hdr, localio, GFP_KERNEL); + iocb = nfs_local_iocb_alloc(hdr, file, GFP_KERNEL); if (iocb == NULL) return -ENOMEM; + iocb->localio = localio; nfs_local_pgio_init(hdr, call_ops); hdr->res.eof = false; @@ -558,14 +563,20 @@ nfs_do_local_write(struct nfs_pgio_header *hdr, const struct rpc_call_ops *call_ops) { struct nfs_local_kiocb *iocb; + struct file *file = nfs_to->nfsd_file_file(localio); + + /* Don't support filesystems without write_iter */ + if (!file->f_op->write_iter) + return -EAGAIN; dprintk("%s: vfs_write count=%u pos=%llu %s\n", __func__, hdr->args.count, hdr->args.offset, (hdr->args.stable == NFS_UNSTABLE) ? "unstable" : "stable"); - iocb = nfs_local_iocb_alloc(hdr, localio, GFP_NOIO); + iocb = nfs_local_iocb_alloc(hdr, file, GFP_NOIO); if (iocb == NULL) return -ENOMEM; + iocb->localio = localio; switch (hdr->args.stable) { default: @@ -591,16 +602,9 @@ int nfs_local_doio(struct nfs_client *clp, struct nfsd_file *localio, const struct rpc_call_ops *call_ops) { int status = 0; - struct file *filp = nfs_to->nfsd_file_file(localio); if (!hdr->args.count) return 0; - /* Don't support filesystems without read_iter/write_iter */ - if (!filp->f_op->read_iter || !filp->f_op->write_iter) { - nfs_local_disable(clp); - status = -EAGAIN; - goto out; - } switch (hdr->rw_mode) { case FMODE_READ: @@ -614,8 +618,10 @@ int nfs_local_doio(struct nfs_client *clp, struct nfsd_file *localio, hdr->rw_mode); status = -EINVAL; } -out: + if (status != 0) { + if (status == -EAGAIN) + nfs_local_disable(clp); nfs_to_nfsd_file_put_local(localio); hdr->task.tk_status = status; nfs_local_hdr_release(hdr, call_ops); From patchwork Thu Oct 3 19:35:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 13821466 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F25121AC429 for ; Thu, 3 Oct 2024 19:35:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984115; cv=none; b=hWMqlkKt/W88JfKTR2X2Tn8AC+rXJM0B4MDzQYwTIsZ6HI6sQ4JweKUHzngJAFiDs0UmdIPybYLnsCKDa/L4rMq2lbjMN/hvXQndvtMsehlLSNfiXe+j/Ss/CCdBe0hG0ZSU6rVeIvjDsrU7NBaNeJqA7a+iMgM1+H4SmO2sH18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727984115; c=relaxed/simple; bh=wf+uxwVhQ23mgHRQ1/toeoe9veu4h6XUqaiUyiHud5k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iGdiJ6WvwqsbKZ3YtS//Cat+FzgkyFmD2WF8oU3DllS1m5jxVNl9ZcrPVt6ENUj/+CGuCYm+j1S8tK2erJ9hXkznP89I1na00XXl5sdR8uyBFfPo/Lj6ThiIvz3ah8+YylRYFS7SfV7luyiAcApdBg/huz+b3ldshfuT5kLXJ1k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Nct6g8xG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Nct6g8xG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1538C4CECC; Thu, 3 Oct 2024 19:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727984114; bh=wf+uxwVhQ23mgHRQ1/toeoe9veu4h6XUqaiUyiHud5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nct6g8xGd35mkIc2fqpHaxGsQgNW4ZZUkEOgI5RIdUYSscMjPoM8bLidS0BDDRLDk nZK1IMd0z0wmrgCqXsof7LdvY2swFBM16SJJBPVVVVHkKQ8e0oax8YQUg4ZAkyCSyx wHvvX7huXaOEp6yL7PCK/nsMgUowTGbobiLFIY190vQx3dpRpq3mquCFqjozpi/wO3 fwVS3szaS1Vtb+hZwyIbqQA5lJBDiZcFjThLsyyivLeXqn2y1Z2k3d+5Jt81ZCFGxE lE5oO1jHoGA8gIcOQcjYRrWwE4uUmYDzPn6sujcIhkDdy5HM3vKT+OxOMTc5OaDAze ONjuCk9vPdz+Q== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Anna Schumaker , Trond Myklebust , NeilBrown , Matthew Wilcox , Christian Brauner Subject: [6.12-rc2 v2 PATCH 7/7] nfs/localio: eliminate need for nfs_local_fsync_work forward declaration Date: Thu, 3 Oct 2024 15:35:04 -0400 Message-ID: <20241003193504.34640-8-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241003193504.34640-1-snitzer@kernel.org> References: <20241003193504.34640-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move nfs_local_fsync_ctx_alloc() after nfs_local_fsync_work(). Signed-off-by: Mike Snitzer --- fs/nfs/localio.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c index 12d3e200156c..98cd572426b4 100644 --- a/fs/nfs/localio.c +++ b/fs/nfs/localio.c @@ -45,7 +45,6 @@ struct nfs_local_fsync_ctx { struct work_struct work; struct completion *done; }; -static void nfs_local_fsync_work(struct work_struct *work); static bool localio_enabled __read_mostly = true; module_param(localio_enabled, bool, 0644); @@ -678,21 +677,6 @@ nfs_local_release_commit_data(struct nfsd_file *localio, call_ops->rpc_release(data); } -static struct nfs_local_fsync_ctx * -nfs_local_fsync_ctx_alloc(struct nfs_commit_data *data, - struct nfsd_file *localio, gfp_t flags) -{ - struct nfs_local_fsync_ctx *ctx = kmalloc(sizeof(*ctx), flags); - - if (ctx != NULL) { - ctx->localio = localio; - ctx->data = data; - INIT_WORK(&ctx->work, nfs_local_fsync_work); - ctx->done = NULL; - } - return ctx; -} - static void nfs_local_fsync_ctx_free(struct nfs_local_fsync_ctx *ctx) { @@ -717,6 +701,21 @@ nfs_local_fsync_work(struct work_struct *work) nfs_local_fsync_ctx_free(ctx); } +static struct nfs_local_fsync_ctx * +nfs_local_fsync_ctx_alloc(struct nfs_commit_data *data, + struct nfsd_file *localio, gfp_t flags) +{ + struct nfs_local_fsync_ctx *ctx = kmalloc(sizeof(*ctx), flags); + + if (ctx != NULL) { + ctx->localio = localio; + ctx->data = data; + INIT_WORK(&ctx->work, nfs_local_fsync_work); + ctx->done = NULL; + } + return ctx; +} + int nfs_local_commit(struct nfsd_file *localio, struct nfs_commit_data *data, const struct rpc_call_ops *call_ops, int how)