From: Jeff Layton <jlayton@kernel.org>
To: Sergey Bashirov <sergeybashirov@gmail.com>,
Chuck Lever <chuck.lever@oracle.com>,
NeilBrown <neil@brown.name>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Konstantin Evtushenko <koevtushenko@yandex.com>
Subject: Re: [PATCH v2] NFSD: Disallow layoutget during grace period
Date: Thu, 04 Sep 2025 06:14:21 -0400 [thread overview]
Message-ID: <2452805383edf28c67474ecdfcc8a0b8b893c855.camel@kernel.org> (raw)
In-Reply-To: <20250903193438.62613-1-sergeybashirov@gmail.com>
On Wed, 2025-09-03 at 22:34 +0300, Sergey Bashirov wrote:
> When the block/scsi layout server is recovering from a reboot and is in a
> grace period, any operation that may result in deletion or reallocation of
> block extents should not be allowed. See RFC 8881, section 18.43.3.
>
> If multiple clients write data to the same file, rebooting the server
> during writing can result in the file corruption. Observed this behavior
> while testing pNFS block volume setup.
>
> Co-developed-by: Konstantin Evtushenko <koevtushenko@yandex.com>
> Signed-off-by: Konstantin Evtushenko <koevtushenko@yandex.com>
> Signed-off-by: Sergey Bashirov <sergeybashirov@gmail.com>
> ---
> Changes in v2:
> - Push down the check to layout driver level
>
> fs/nfsd/blocklayout.c | 8 +++++++-
> fs/nfsd/flexfilelayout.c | 2 +-
> fs/nfsd/nfs4proc.c | 3 ++-
> fs/nfsd/pnfs.h | 2 +-
> 4 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c
> index 0822d8a119c6..1fbc5bbde07f 100644
> --- a/fs/nfsd/blocklayout.c
> +++ b/fs/nfsd/blocklayout.c
> @@ -19,7 +19,7 @@
>
> static __be32
> nfsd4_block_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,
> - struct nfsd4_layoutget *args)
> + struct nfsd4_layoutget *args, bool in_grace)
> {
> struct nfsd4_layout_seg *seg = &args->lg_seg;
> struct super_block *sb = inode->i_sb;
> @@ -34,6 +34,9 @@ nfsd4_block_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,
> goto out_layoutunavailable;
> }
>
> + if (in_grace)
> + goto out_grace;
> +
> /*
> * Some clients barf on non-zero block numbers for NONE or INVALID
> * layouts, so make sure to zero the whole structure.
> @@ -111,6 +114,9 @@ nfsd4_block_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,
> out_layoutunavailable:
> seg->length = 0;
> return nfserr_layoutunavailable;
> +out_grace:
> + seg->length = 0;
> + return nfserr_grace;
> }
>
> static __be32
> diff --git a/fs/nfsd/flexfilelayout.c b/fs/nfsd/flexfilelayout.c
> index 3ca5304440ff..274a1e9bb596 100644
> --- a/fs/nfsd/flexfilelayout.c
> +++ b/fs/nfsd/flexfilelayout.c
> @@ -21,7 +21,7 @@
>
> static __be32
> nfsd4_ff_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,
> - struct nfsd4_layoutget *args)
> + struct nfsd4_layoutget *args, bool in_grace)
> {
> struct nfsd4_layout_seg *seg = &args->lg_seg;
> u32 device_generation = 0;
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index d7c58aa64f06..5d1d343a4e23 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -2435,6 +2435,7 @@ static __be32
> nfsd4_layoutget(struct svc_rqst *rqstp,
> struct nfsd4_compound_state *cstate, union nfsd4_op_u *u)
> {
> + struct net *net = SVC_NET(rqstp);
> struct nfsd4_layoutget *lgp = &u->layoutget;
> struct svc_fh *current_fh = &cstate->current_fh;
> const struct nfsd4_layout_ops *ops;
> @@ -2498,7 +2499,7 @@ nfsd4_layoutget(struct svc_rqst *rqstp,
> goto out_put_stid;
>
> nfserr = ops->proc_layoutget(d_inode(current_fh->fh_dentry),
> - current_fh, lgp);
> + current_fh, lgp, locks_in_grace(net));
> if (nfserr)
> goto out_put_stid;
>
> diff --git a/fs/nfsd/pnfs.h b/fs/nfsd/pnfs.h
> index dfd411d1f363..61c2528ef077 100644
> --- a/fs/nfsd/pnfs.h
> +++ b/fs/nfsd/pnfs.h
> @@ -30,7 +30,7 @@ struct nfsd4_layout_ops {
> const struct nfsd4_getdeviceinfo *gdevp);
>
> __be32 (*proc_layoutget)(struct inode *, const struct svc_fh *fhp,
> - struct nfsd4_layoutget *lgp);
> + struct nfsd4_layoutget *lgp, bool in_grace);
> __be32 (*encode_layoutget)(struct xdr_stream *xdr,
> const struct nfsd4_layoutget *lgp);
>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2025-09-04 10:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 19:34 [PATCH v2] NFSD: Disallow layoutget during grace period Sergey Bashirov
2025-09-04 5:26 ` Christoph Hellwig
2025-09-04 10:14 ` Jeff Layton [this message]
2025-09-04 15:54 ` Chuck Lever
2025-09-05 13:41 ` Chuck Lever
2025-09-04 15:57 ` Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2452805383edf28c67474ecdfcc8a0b8b893c855.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=koevtushenko@yandex.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=sergeybashirov@gmail.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox