linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: Sergey Bashirov <sergeybashirov@gmail.com>,
	Christoph Hellwig <hch@infradead.org>,
	Jeff Layton <jlayton@kernel.org>, NeilBrown <neil@brown.name>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Konstantin Evtushenko <koevtushenko@yandex.com>
Subject: Re: [PATCH] nfsd: Use correct error code when decoding extents
Date: Mon, 16 Jun 2025 05:38:39 -0700	[thread overview]
Message-ID: <aFAQTwpSSJtDUmu8@infradead.org> (raw)
In-Reply-To: <b6ba7275-ceab-4619-9e5b-a886daf34689@oracle.com>

On Wed, Jun 11, 2025 at 12:29:51PM -0400, Chuck Lever wrote:
> On 6/11/25 12:24 PM, Sergey Bashirov wrote:
> > I also have some doubts about this code:
> > if (xdr_stream_decode_u64(&xdr, &bex.len))
> >         return -NFS4ERR_BADXDR;
> > if (bex.len & (block_size - 1))
> >         return -NFS4ERR_BADXDR;
> > 
> > The first error code is clear to me, it is all about decoding. But should
> > not we return -NFS4ERR_EINVAL in the second check? On one hand, we
> > encountered an invalid value after successful decoding, but on the other
> > hand, we stopped decoding the extent array, so we can say that this is
> > also a decoding error.
> 
> On first read of Section 2.3 of RFC 5663, there's no mandated alignment
> requirement for bex_length. IMO this is a case where the implementation
> is deciding that a decoded value is not valid, so NFS4ERR_INVAL might be
> a better choice here.

Section 2.1 of RFC 5663 says:

Clients must be able to perform I/O to the block extents without 
affecting additional areas of storage (especially important for writes);
therefore, extents MUST be aligned to 512-byte boundaries, and writable
extents MUST be aligned to the block size used by the NFSv4 server in
managing the actual file system (4 kilobytes and 8 kilobytes are common
block sizes).  This block size is available as the NFSv4.1 layout_blksize
attribute.

While it would be nice to state this again in 2.3, the language looks
normative enough (TM) to me.

  reply	other threads:[~2025-06-16 12:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-11 15:44 [PATCH] nfsd: Use correct error code when decoding extents Sergey Bashirov
2025-06-11 15:58 ` Chuck Lever
2025-06-11 16:24   ` Sergey Bashirov
2025-06-11 16:29     ` Chuck Lever
2025-06-16 12:38       ` Christoph Hellwig [this message]
2025-06-16 13:21         ` Chuck Lever
2025-06-16 13:23           ` Christoph Hellwig

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=aFAQTwpSSJtDUmu8@infradead.org \
    --to=hch@infradead.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=chuck.lever@oracle.com \
    --cc=jlayton@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).