diff mbox

NFSD: Fix bad update of layout in nfsd4_return_file_layout

Message ID 550ECEF0.6030505@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kinglong Mee March 22, 2015, 2:17 p.m. UTC
With return layout as, (seg is return layout, lo is record layout) 
seg->offset <= lo->offset and layout_end(seg) < layout_end(lo), 
nfsd should update lo's offset to seg's end,
and, 
seg->offset > lo->offset and layout_end(seg) >= layout_end(lo),
nfsd should update lo's end to seg's offset.

Fixes: 9cf514ccfa ("nfsd: implement pNFS operations")
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 fs/nfsd/nfs4layouts.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig March 25, 2015, 8:34 a.m. UTC | #1
Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

Guess we need some good testcase for these artifical partial segment
returns that don't happen with the real client..
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
J. Bruce Fields March 26, 2015, 1:15 a.m. UTC | #2
On Wed, Mar 25, 2015 at 09:34:45AM +0100, Christoph Hellwig wrote:
> Looks good,
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> Guess we need some good testcase for these artifical partial segment
> returns that don't happen with the real client..

pynfs might do it?  But I'm not volunteering.

Anyway, applying these three for 4.0. (NFSD: Printk blocklayout length
a.., NFSD: Take care the return value.., NFSD: Fix bad update of layout
in...).

--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c
index 6964613..80e236b 100644
--- a/fs/nfsd/nfs4layouts.c
+++ b/fs/nfsd/nfs4layouts.c
@@ -440,15 +440,14 @@  nfsd4_return_file_layout(struct nfs4_layout *lp, struct nfsd4_layout_seg *seg,
 			list_move_tail(&lp->lo_perstate, reaplist);
 			return;
 		}
-		end = seg->offset;
+		lo->offset = layout_end(seg);
 	} else {
 		/* retain the whole layout segment on a split. */
 		if (layout_end(seg) < end) {
 			dprintk("%s: split not supported\n", __func__);
 			return;
 		}
-
-		lo->offset = layout_end(seg);
+		end = seg->offset;
 	}
 
 	layout_update_len(lo, end);