public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergey Bashirov <sergeybashirov@gmail.com>
To: Chuck Lever <chuck.lever@oracle.com>,
	Christoph Hellwig <hch@infradead.org>,
	Dai Ngo <Dai.Ngo@oracle.com>, Jeff Layton <jlayton@kernel.org>,
	NeilBrown <neil@brown.name>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Tom Talpey <tom@talpey.com>
Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sergey Bashirov <sergeybashirov@gmail.com>
Subject: [PATCH v2 1/4] NFSD/blocklayout: Fix minlength check in proc_layoutget
Date: Thu,  2 Oct 2025 23:31:11 +0300	[thread overview]
Message-ID: <20251002203121.182395-2-sergeybashirov@gmail.com> (raw)
In-Reply-To: <20251002203121.182395-1-sergeybashirov@gmail.com>

Minor fix as part of the functional changes. The extent returned by
the file system may have a smaller offset than the segment offset
requested by the client. In this case, the minimum segment length
must be checked against the requested range. Otherwise, the client
may not be able to continue the read/write operation.

Signed-off-by: Sergey Bashirov <sergeybashirov@gmail.com>
---
 fs/nfsd/blocklayout.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c
index fde5539cf6a6..425648565ab2 100644
--- a/fs/nfsd/blocklayout.c
+++ b/fs/nfsd/blocklayout.c
@@ -23,6 +23,7 @@ nfsd4_block_proc_layoutget(struct svc_rqst *rqstp, struct inode *inode,
 {
 	struct nfsd4_layout_seg *seg = &args->lg_seg;
 	struct super_block *sb = inode->i_sb;
+	u64 length;
 	u32 block_size = i_blocksize(inode);
 	struct pnfs_block_extent *bex;
 	struct iomap iomap;
@@ -56,7 +57,8 @@ nfsd4_block_proc_layoutget(struct svc_rqst *rqstp, struct inode *inode,
 		goto out_error;
 	}
 
-	if (iomap.length < args->lg_minlength) {
+	length = iomap.offset + iomap.length - seg->offset;
+	if (length < args->lg_minlength) {
 		dprintk("pnfsd: extent smaller than minlength\n");
 		goto out_layoutunavailable;
 	}
-- 
2.43.0


  reply	other threads:[~2025-10-02 20:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-02 20:31 [PATCH v2 0/4] NFSD: Impl multiple extents in block/scsi layoutget Sergey Bashirov
2025-10-02 20:31 ` Sergey Bashirov [this message]
2025-10-03  6:54   ` [PATCH v2 1/4] NFSD/blocklayout: Fix minlength check in proc_layoutget Christoph Hellwig
2025-10-03 14:11     ` Chuck Lever
2025-10-04  4:22       ` Christoph Hellwig
2025-10-02 20:31 ` [PATCH v2 2/4] NFSD/blocklayout: Extract extent mapping from proc_layoutget Sergey Bashirov
2025-10-03  6:56   ` Christoph Hellwig
2025-10-02 20:31 ` [PATCH v2 3/4] NFSD/blocklayout: Introduce layout content structure Sergey Bashirov
2025-10-03  6:57   ` Christoph Hellwig
2025-10-02 20:31 ` [PATCH v2 4/4] NFSD/blocklayout: Support multiple extents per LAYOUTGET Sergey Bashirov
2025-10-03  6:58   ` 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=20251002203121.182395-2-sergeybashirov@gmail.com \
    --to=sergeybashirov@gmail.com \
    --cc=Dai.Ngo@oracle.com \
    --cc=chuck.lever@oracle.com \
    --cc=hch@infradead.org \
    --cc=jlayton@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.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