Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFSD: Fix bad update of layout in nfsd4_return_file_layout

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

authored by

Kinglong Mee and committed by
J. Bruce Fields
7890203d 376675da

+2 -3
+2 -3
fs/nfsd/nfs4layouts.c
··· 440 440 list_move_tail(&lp->lo_perstate, reaplist); 441 441 return; 442 442 } 443 - end = seg->offset; 443 + lo->offset = layout_end(seg); 444 444 } else { 445 445 /* retain the whole layout segment on a split. */ 446 446 if (layout_end(seg) < end) { 447 447 dprintk("%s: split not supported\n", __func__); 448 448 return; 449 449 } 450 - 451 - lo->offset = layout_end(seg); 450 + end = seg->offset; 452 451 } 453 452 454 453 layout_update_len(lo, end);