From nobody Wed Oct 8 00:23:31 2025 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 3AE912FEE23; Thu, 3 Jul 2025 19:53:28 +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=1751572409; cv=none; b=jCMA7aM0ZS8kkenlOFerzuVmup/xgD3rBu6XqjdKMtjAf0isD2pmSU+NlTqDSSrUAAHgm77xvDlzh8zRLocXmrJMzeYClWckTnotArNl3C+VvuJaeof/wqs/otbQdmTs0I0WK6O9V+znoZFxiIIQc6F91GQZ53uuSClP62jjgUQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751572409; c=relaxed/simple; bh=HKeoW9KtUJiIjEPGllHFJTUrbGUFNAdPHChB/1LE1vk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hyGPm8UR7ZWVXvFz13zneOVa/kaKzn3RzPn8M50MaR6LmPlo7CFt1W0ofNAn/Amjd+Wxvoy4YZJcr4Nr5yDa0nwZ8SDQsAsBq6/2EFx90R0f2NC/GCjfv5qhGAi08ss/fLizv6hoMFmAeFhU4sV0ysC8mQezuzKuhcm63I7I8HM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qh8/ZLHR; 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="qh8/ZLHR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E18CCC4CEF2; Thu, 3 Jul 2025 19:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751572408; bh=HKeoW9KtUJiIjEPGllHFJTUrbGUFNAdPHChB/1LE1vk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qh8/ZLHRhjh2GWaXBw7kTfLOOTKXHCWg7p6BDI4UkkbeZ/Vqq01YvYP20dHSNYGyn oHOkiX+fL0Oy4NMi9UiVkfccL096WxCPCToLYG1UGBENZAdKsFdWB7ximZumB+wVQK ypBtFKpea0N2g21fur5hi1qbzAkCE9dyDQXp8MaFHKQTKPT1ckgDCjKuJJxlaxETjk xWE6gYSEyMZBRQnNVTbLbFP1pzihFuPmf7/J56V9AyT0Ne7wVdbmwkhOCjxCXfWcBv 3yPZN5ZS7csfctMicv7F40rA5ME3fAgEPBlQSEjMNo/9ChkfJ4Pu6kVDDmRLUYa5Kd ozNTOXcKIMdSw== From: Jeff Layton Date: Thu, 03 Jul 2025 15:53:12 -0400 Subject: [PATCH RFC 1/2] sunrpc: delay pc_release callback until after sending a reply Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250703-nfsd-testing-v1-1-cece54f36556@kernel.org> References: <20250703-nfsd-testing-v1-0-cece54f36556@kernel.org> In-Reply-To: <20250703-nfsd-testing-v1-0-cece54f36556@kernel.org> To: Trond Myklebust , Anna Schumaker , Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Mike Snitzer Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2536; i=jlayton@kernel.org; h=from:subject:message-id; bh=HKeoW9KtUJiIjEPGllHFJTUrbGUFNAdPHChB/1LE1vk=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBoZt+26Q/6FhBph5XRj0g3eQLABzh5R8vxmZX9S n62uZwjp6KJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaGbftgAKCRAADmhBGVaC FdWvD/4t6rSPB5chu3xDcvAo7m9dNqmao7LA1bEsQlq2FkUeLT+KCKgbWg0SHImEXKjRq8SRUr0 X2mhxKxgsdygQTjlnlmwRyvrfK8Dj8g9tR0guYY4gnQvhFIjIc2SwvVgvK7UoS1K88SgNrBO1lU XyI9UPmRv3Q89GyKyz1vx1nCG0WO2nuYh4D6v4F3X8hjIZDtOdmf07IQHvvdx/5eKqOyhfr9WOg EYLnV1XL8Ld4m1EIgg7PHSKfkBZx/l8kdni4McqQqliRn0fzIban3eyYC9dl0v7Pbv4PMs/NtyO oPll/PBhIKQEbj7saR3CdkDqEEhDGHHa+461x4sgdgMta+ySstsTd6BXnrx6rBFiCkU3VOssnyt pnfGCzFyQr7d3Htl+RLX/REzbF5FDmtK6D6vouKkNg/PPTIeA9k5ilTm7FevGHz6cfUZ/mAGO8k wx+yVQaS0410iADF4/Gc/KmSvQMC6V/rznoT7SF5rHZYnhBGu60SOCSWIWFq5CEk1hTychPd/Fk fVlad6G40lUTWYyhdt7Rvxsfr8NXk7ESwJSIoB+g2soS1vw96F5+AIVa6qTadhYoimqMUvbDv/i U2eD/xCwM61CCccq/uNGS1gNm89insTmSLFNxeyY7IYSY9n2wjDMwYppRh/C1X4b8Alzl5vWwXP Ix+BdnGTgn1birA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 The server-side sunrpc code currently calls pc_release before sending the reply. A later nfsd patch will change some pc_release callbacks to do extra work to clean the pagecache. There is no need to delay sending the reply for this, however. Change svc_process and svc_process_bc to call pc_release after sending the reply instead of before. Signed-off-by: Jeff Layton Reviewed-by: NeilBrown --- net/sunrpc/svc.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index b1fab3a6954437cf751e4725fa52cfc83eddf2ab..103bb6ba8e140fdccd6cab124e7= 15caeb41bb445 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -1426,8 +1426,6 @@ svc_process_common(struct svc_rqst *rqstp) =20 /* Call the function that processes the request. */ rc =3D process.dispatch(rqstp); - if (procp->pc_release) - procp->pc_release(rqstp); xdr_finish_decode(xdr); =20 if (!rc) @@ -1526,6 +1524,14 @@ static void svc_drop(struct svc_rqst *rqstp) trace_svc_drop(rqstp); } =20 +static void svc_release_rqst(struct svc_rqst *rqstp) +{ + const struct svc_procedure *procp =3D rqstp->rq_procinfo; + + if (procp && procp->pc_release) + procp->pc_release(rqstp); +} + /** * svc_process - Execute one RPC transaction * @rqstp: RPC transaction context @@ -1533,7 +1539,7 @@ static void svc_drop(struct svc_rqst *rqstp) */ void svc_process(struct svc_rqst *rqstp) { - struct kvec *resv =3D &rqstp->rq_res.head[0]; + struct kvec *resv =3D &rqstp->rq_res.head[0]; __be32 *p; =20 #if IS_ENABLED(CONFIG_FAIL_SUNRPC) @@ -1565,9 +1571,12 @@ void svc_process(struct svc_rqst *rqstp) if (unlikely(*p !=3D rpc_call)) goto out_baddir; =20 - if (!svc_process_common(rqstp)) + if (!svc_process_common(rqstp)) { + svc_release_rqst(rqstp); goto out_drop; + } svc_send(rqstp); + svc_release_rqst(rqstp); return; =20 out_baddir: @@ -1635,6 +1644,7 @@ void svc_process_bc(struct rpc_rqst *req, struct svc_= rqst *rqstp) if (!proc_error) { /* Processing error: drop the request */ xprt_free_bc_request(req); + svc_release_rqst(rqstp); return; } /* Finally, send the reply synchronously */ @@ -1648,6 +1658,7 @@ void svc_process_bc(struct rpc_rqst *req, struct svc_= rqst *rqstp) timeout.to_maxval =3D timeout.to_initval; memcpy(&req->rq_snd_buf, &rqstp->rq_res, sizeof(req->rq_snd_buf)); task =3D rpc_run_bc_task(req, &timeout); + svc_release_rqst(rqstp); =20 if (IS_ERR(task)) return; --=20 2.50.0 From nobody Wed Oct 8 00:23:31 2025 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 3422F2FF466; Thu, 3 Jul 2025 19:53:29 +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=1751572410; cv=none; b=Npc5L0CnXhfjgYuluyKXahzgpKkh0Mf/qi4ZfHRjR7fXk3sk+uYxgO2ciy5LQ6Ee1MwHDTNpTojTAEEJajd42uVbaLC2CTI0/yDMUXLI66trAmLeWiDJQJfncUShTFGd6xS2IaOu7Gwv4ddKq7iWjfeYGariV1Pa01NWCLyaBNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751572410; c=relaxed/simple; bh=smL/eB8fAl03uaDWHjZi76er77bcyUSMpdWXPH0CtxU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KVRJUhC1DmB+DvheGdulsp9jKIGIV4s4vYfei1EJtJCQMfgNI63n0P+MyWXNfNhG/hbVDQAQ0lCMWRqbh1Q582FawKS5EO0dbxl/c6fPGddSz2i+4WtvoGUQAdXn26q+0Dr78VpUasJKnQHxtbfueNKa+OEm2sf5inE+thEAvU8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oW5dY16Z; 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="oW5dY16Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFB50C4CEF5; Thu, 3 Jul 2025 19:53:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751572409; bh=smL/eB8fAl03uaDWHjZi76er77bcyUSMpdWXPH0CtxU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=oW5dY16ZprqAWGMN5f4RhSWHPr0Pm/FrhCt1R9qZf1H10cdtB5GwEci7RuafiloTq sDwbtp/ZGQb23UeqW2aFXva+WEQp22aXBwOmbp5oH1cXtQWg2Hrb1J1kq5Pb+RU4eH Xc3XW1FAyRY8bxPan0jfEybx8BfGXQyNFdciwFYcbjCyiHrOt9dfNnFnC0SnDZObQg 6hzQxEFHlOikGoNsDygIUb40EhicGuA2fJXWvwH53r80YyNo+chn3HoRO/1e2l1HSr awft1oMjh8rwAzLu1gdVOW0MvwQEFs22+fQ8cOrIf7VDdCnPfD1D0sktF5/nQi8GEg j6bGuM+IFkofw== From: Jeff Layton Date: Thu, 03 Jul 2025 15:53:13 -0400 Subject: [PATCH RFC 2/2] nfsd: call generic_fadvise after v3 READ, stable WRITE or COMMIT Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250703-nfsd-testing-v1-2-cece54f36556@kernel.org> References: <20250703-nfsd-testing-v1-0-cece54f36556@kernel.org> In-Reply-To: <20250703-nfsd-testing-v1-0-cece54f36556@kernel.org> To: Trond Myklebust , Anna Schumaker , Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Mike Snitzer Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=11642; i=jlayton@kernel.org; h=from:subject:message-id; bh=smL/eB8fAl03uaDWHjZi76er77bcyUSMpdWXPH0CtxU=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBoZt+23+RZ30jZf5uBOB+WifyhnAMa2xdwrM1vS F+bAbqSftCJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaGbftgAKCRAADmhBGVaC FY8bD/wM0gDyHQiTX8+OscbLSCXaz0A34f4RAijl8rMJNwSU2sHKzHUqthSRgZaEhCOl5DOVr4u /SjEvBlvsHrwYxWE5TfD83Z/l4yw9+19OM9w2uWhIwDgRTG+jep/8aeGxDPYmF13TRfaHtBhuJQ M9fERyUWCp4OR5O5/m6I+g2zlrHG5hWm3Af9OvhWmz2z8U+i1k7rKwA05LY2RxJAOzkcea2cpPo ll3j9rfLcLyQez8IZ9ln4n5jvb+W7NWOQuiIy8DvbyZOwP+/cH2phGnfyFiZQ7LPlxf33tXObxW +0fEJhubxx3WT5/qH5uknH9zOhx6njjWWWHKrecZa2cU8q3KiYwD4P6ZlLfnKR24sRBme8EEsG/ A3LVxjQcAUwuNCRPLr+gI7wQgULXq6E1FXmW1lt6N5y8Vqqd75tiXwyzU4ovjz0C0TuhoXSKMDE +54ksqliS2BMn1mcr7Tp8GY2XKihC/fUbJFmePK2WINieMYDQpXTNvYbEG/SAaynS41jOTRhO36 ZvBuRQFCZmd1CrpfW2XJ8pUqIYujnHqiJcBxqDhqvDxoXOMGHar/wiDTMmCe9uMiiAeF3pNBj3p 7X2dfYuge+hHhotOrxz74V5MVN11eE2xPuxFCzK8nVERCteIOBr7ZRm/CUKI37NN7vFHQIA8dCH dgiCjUP0VngohBA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Recent testing has shown that keeping pagecache pages around for too long can be detrimental to performance with nfsd. Clients only rarely revisit the same data, so the pages tend to just hang around. This patch changes the pc_release callbacks for NFSv3 READ, WRITE and COMMIT to call generic_fadvise(..., POSIX_FADV_DONTNEED) on the accessed range. Signed-off-by: Jeff Layton Reviewed-by: NeilBrown --- fs/nfsd/debugfs.c | 2 ++ fs/nfsd/nfs3proc.c | 59 +++++++++++++++++++++++++++++++++++++++++++++-----= ---- fs/nfsd/nfsd.h | 1 + fs/nfsd/nfsproc.c | 4 ++-- fs/nfsd/vfs.c | 21 ++++++++++++++----- fs/nfsd/vfs.h | 5 +++-- fs/nfsd/xdr3.h | 3 +++ 7 files changed, 77 insertions(+), 18 deletions(-) diff --git a/fs/nfsd/debugfs.c b/fs/nfsd/debugfs.c index 84b0c8b559dc90bd5c2d9d5e15c8e0682c0d610c..b007718dd959bc081166ec84e06= f577a8fc2b46b 100644 --- a/fs/nfsd/debugfs.c +++ b/fs/nfsd/debugfs.c @@ -44,4 +44,6 @@ void nfsd_debugfs_init(void) =20 debugfs_create_file("disable-splice-read", S_IWUSR | S_IRUGO, nfsd_top_dir, NULL, &nfsd_dsr_fops); + debugfs_create_bool("enable-fadvise-dontneed", 0644, + nfsd_top_dir, &nfsd_enable_fadvise_dontneed); } diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index b6d03e1ef5f7a5e8dd111b0d56c061f1e91abff7..11261cf67ea817ec566626f08b7= 33e09c9e121de 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -9,6 +9,7 @@ #include #include #include +#include =20 #include "cache.h" #include "xdr3.h" @@ -206,11 +207,25 @@ nfsd3_proc_read(struct svc_rqst *rqstp) =20 fh_copy(&resp->fh, &argp->fh); resp->status =3D nfsd_read(rqstp, &resp->fh, argp->offset, - &resp->count, &resp->eof); + &resp->count, &resp->eof, &resp->nf); resp->status =3D nfsd3_map_status(resp->status); return rpc_success; } =20 +static void +nfsd3_release_read(struct svc_rqst *rqstp) +{ + struct nfsd3_readargs *argp =3D rqstp->rq_argp; + struct nfsd3_readres *resp =3D rqstp->rq_resp; + + if (nfsd_enable_fadvise_dontneed && resp->status =3D=3D nfs_ok) + generic_fadvise(nfsd_file_file(resp->nf), argp->offset, resp->count, + POSIX_FADV_DONTNEED); + if (resp->nf) + nfsd_file_put(resp->nf); + fh_put(&resp->fh); +} + /* * Write data to a file */ @@ -236,12 +251,26 @@ nfsd3_proc_write(struct svc_rqst *rqstp) resp->committed =3D argp->stable; resp->status =3D nfsd_write(rqstp, &resp->fh, argp->offset, &argp->payload, &cnt, - resp->committed, resp->verf); + resp->committed, resp->verf, &resp->nf); resp->count =3D cnt; resp->status =3D nfsd3_map_status(resp->status); return rpc_success; } =20 +static void +nfsd3_release_write(struct svc_rqst *rqstp) +{ + struct nfsd3_writeargs *argp =3D rqstp->rq_argp; + struct nfsd3_writeres *resp =3D rqstp->rq_resp; + + if (nfsd_enable_fadvise_dontneed && resp->status =3D=3D nfs_ok && resp->c= ommitted) + generic_fadvise(nfsd_file_file(resp->nf), argp->offset, resp->count, + POSIX_FADV_DONTNEED); + if (resp->nf) + nfsd_file_put(resp->nf); + fh_put(&resp->fh); +} + /* * Implement NFSv3's unchecked, guarded, and exclusive CREATE * semantics for regular files. Except for the created file, @@ -748,7 +777,6 @@ nfsd3_proc_commit(struct svc_rqst *rqstp) { struct nfsd3_commitargs *argp =3D rqstp->rq_argp; struct nfsd3_commitres *resp =3D rqstp->rq_resp; - struct nfsd_file *nf; =20 dprintk("nfsd: COMMIT(3) %s %u@%Lu\n", SVCFH_fmt(&argp->fh), @@ -757,17 +785,30 @@ nfsd3_proc_commit(struct svc_rqst *rqstp) =20 fh_copy(&resp->fh, &argp->fh); resp->status =3D nfsd_file_acquire_gc(rqstp, &resp->fh, NFSD_MAY_WRITE | - NFSD_MAY_NOT_BREAK_LEASE, &nf); + NFSD_MAY_NOT_BREAK_LEASE, &resp->nf); if (resp->status) goto out; - resp->status =3D nfsd_commit(rqstp, &resp->fh, nf, argp->offset, + resp->status =3D nfsd_commit(rqstp, &resp->fh, resp->nf, argp->offset, argp->count, resp->verf); - nfsd_file_put(nf); out: resp->status =3D nfsd3_map_status(resp->status); return rpc_success; } =20 +static void +nfsd3_release_commit(struct svc_rqst *rqstp) +{ + struct nfsd3_commitargs *argp =3D rqstp->rq_argp; + struct nfsd3_commitres *resp =3D rqstp->rq_resp; + + if (nfsd_enable_fadvise_dontneed && resp->status =3D=3D nfs_ok) + generic_fadvise(nfsd_file_file(resp->nf), argp->offset, argp->count, + POSIX_FADV_DONTNEED); + if (resp->nf) + nfsd_file_put(resp->nf); + fh_put(&resp->fh); +} + =20 /* * NFSv3 Server procedures. @@ -864,7 +905,7 @@ static const struct svc_procedure nfsd_procedures3[22] = =3D { .pc_func =3D nfsd3_proc_read, .pc_decode =3D nfs3svc_decode_readargs, .pc_encode =3D nfs3svc_encode_readres, - .pc_release =3D nfs3svc_release_fhandle, + .pc_release =3D nfsd3_release_read, .pc_argsize =3D sizeof(struct nfsd3_readargs), .pc_argzero =3D sizeof(struct nfsd3_readargs), .pc_ressize =3D sizeof(struct nfsd3_readres), @@ -876,7 +917,7 @@ static const struct svc_procedure nfsd_procedures3[22] = =3D { .pc_func =3D nfsd3_proc_write, .pc_decode =3D nfs3svc_decode_writeargs, .pc_encode =3D nfs3svc_encode_writeres, - .pc_release =3D nfs3svc_release_fhandle, + .pc_release =3D nfsd3_release_write, .pc_argsize =3D sizeof(struct nfsd3_writeargs), .pc_argzero =3D sizeof(struct nfsd3_writeargs), .pc_ressize =3D sizeof(struct nfsd3_writeres), @@ -1039,7 +1080,7 @@ static const struct svc_procedure nfsd_procedures3[22= ] =3D { .pc_func =3D nfsd3_proc_commit, .pc_decode =3D nfs3svc_decode_commitargs, .pc_encode =3D nfs3svc_encode_commitres, - .pc_release =3D nfs3svc_release_fhandle, + .pc_release =3D nfsd3_release_commit, .pc_argsize =3D sizeof(struct nfsd3_commitargs), .pc_argzero =3D sizeof(struct nfsd3_commitargs), .pc_ressize =3D sizeof(struct nfsd3_commitres), diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index 1cd0bed57bc2f27248fd66a8efef692a5e9a390c..288904d88b9245c03eae0aa347e= 867037b7c85c5 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h @@ -152,6 +152,7 @@ static inline void nfsd_debugfs_exit(void) {} #endif =20 extern bool nfsd_disable_splice_read __read_mostly; +extern bool nfsd_enable_fadvise_dontneed __read_mostly; =20 extern int nfsd_max_blksize; =20 diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index 8f71f5748c75b69f15bae5e63799842e0e8b3139..bb8f98adb3e31b10adc4694987f= 8f5036726bf7f 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -225,7 +225,7 @@ nfsd_proc_read(struct svc_rqst *rqstp) resp->count =3D argp->count; fh_copy(&resp->fh, &argp->fh); resp->status =3D nfsd_read(rqstp, &resp->fh, argp->offset, - &resp->count, &eof); + &resp->count, &eof, NULL); if (resp->status =3D=3D nfs_ok) resp->status =3D fh_getattr(&resp->fh, &resp->stat); else if (resp->status =3D=3D nfserr_jukebox) @@ -258,7 +258,7 @@ nfsd_proc_write(struct svc_rqst *rqstp) =20 fh_copy(&resp->fh, &argp->fh); resp->status =3D nfsd_write(rqstp, &resp->fh, argp->offset, - &argp->payload, &cnt, NFS_DATA_SYNC, NULL); + &argp->payload, &cnt, NFS_DATA_SYNC, NULL, NULL); if (resp->status =3D=3D nfs_ok) resp->status =3D fh_getattr(&resp->fh, &resp->stat); else if (resp->status =3D=3D nfserr_jukebox) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index ee78b6fb17098b788b07f5cd90598e678244b57e..f23eb3a07bb99dc231be9ea6db4= e58b9e328a689 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -49,6 +49,7 @@ #define NFSDDBG_FACILITY NFSDDBG_FILEOP =20 bool nfsd_disable_splice_read __read_mostly; +bool nfsd_enable_fadvise_dontneed __read_mostly; =20 /** * nfserrno - Map Linux errnos to NFS errnos @@ -1280,6 +1281,7 @@ bool nfsd_read_splice_ok(struct svc_rqst *rqstp) * @offset: starting byte offset * @count: IN: requested number of bytes; OUT: number of bytes read * @eof: OUT: set non-zero if operation reached the end of the file + * @pnf: optional return pointer to pass back nfsd_file reference * * The caller must verify that there is enough space in @rqstp.rq_res * to perform this operation. @@ -1290,7 +1292,8 @@ bool nfsd_read_splice_ok(struct svc_rqst *rqstp) * returned. */ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, - loff_t offset, unsigned long *count, u32 *eof) + loff_t offset, unsigned long *count, u32 *eof, + struct nfsd_file **pnf) { struct nfsd_file *nf; struct file *file; @@ -1307,7 +1310,10 @@ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_= fh *fhp, else err =3D nfsd_iter_read(rqstp, fhp, file, offset, count, 0, eof); =20 - nfsd_file_put(nf); + if (pnf && err =3D=3D nfs_ok) + *pnf =3D nf; + else + nfsd_file_put(nf); trace_nfsd_read_done(rqstp, fhp, offset, *count); return err; } @@ -1321,8 +1327,10 @@ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_= fh *fhp, * @cnt: IN: number of bytes to write, OUT: number of bytes actually writt= en * @stable: An NFS stable_how value * @verf: NFS WRITE verifier + * @pnf: optional return pointer to pass back nfsd_file reference * - * Upon return, caller must invoke fh_put on @fhp. + * Upon return, caller must invoke fh_put() on @fhp. If it sets @pnf, + * then it must also call nfsd_file_put() on the returned reference. * * Return values: * An nfsstat value in network byte order. @@ -1330,7 +1338,7 @@ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_f= h *fhp, __be32 nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset, const struct xdr_buf *payload, unsigned long *cnt, int stable, - __be32 *verf) + __be32 *verf, struct nfsd_file **pnf) { struct nfsd_file *nf; __be32 err; @@ -1343,7 +1351,10 @@ nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fh= p, loff_t offset, =20 err =3D nfsd_vfs_write(rqstp, fhp, nf, offset, payload, cnt, stable, verf); - nfsd_file_put(nf); + if (pnf && err =3D=3D nfs_ok) + *pnf =3D nf; + else + nfsd_file_put(nf); out: trace_nfsd_write_done(rqstp, fhp, offset, *cnt); return err; diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h index eff04959606fe55c141ab4a2eed97c7e0716a5f5..2d063ee7786f499f34c39cd3ba7= e776bb7562d57 100644 --- a/fs/nfsd/vfs.h +++ b/fs/nfsd/vfs.h @@ -127,10 +127,11 @@ __be32 nfsd_iter_read(struct svc_rqst *rqstp, struct= svc_fh *fhp, bool nfsd_read_splice_ok(struct svc_rqst *rqstp); __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset, unsigned long *count, - u32 *eof); + u32 *eof, struct nfsd_file **pnf); __be32 nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset, const struct xdr_buf *payload, - unsigned long *cnt, int stable, __be32 *verf); + unsigned long *cnt, int stable, __be32 *verf, + struct nfsd_file **pnf); __be32 nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfsd_file *nf, loff_t offset, const struct xdr_buf *payload, diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index 522067b7fd755930a1c2e42b826d9132ac2993be..3f4c51983003188be51a0f8c2db= 2e0acc9a1363b 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -146,6 +146,7 @@ struct nfsd3_readres { unsigned long count; __u32 eof; struct page **pages; + struct nfsd_file *nf; }; =20 struct nfsd3_writeres { @@ -154,6 +155,7 @@ struct nfsd3_writeres { unsigned long count; int committed; __be32 verf[2]; + struct nfsd_file *nf; }; =20 struct nfsd3_renameres { @@ -217,6 +219,7 @@ struct nfsd3_commitres { __be32 status; struct svc_fh fh; __be32 verf[2]; + struct nfsd_file *nf; }; =20 struct nfsd3_getaclres { --=20 2.50.0