Commit 19982ba8562e33083cb5bbb59a74855d8a9624ea
1 parent
8f7d5efbef
Exists in
master
and in
7 other branches
NFSv4.1: Fix an off-by-one error in pnfs_generic_pg_test
And document what is going on there... Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Showing 1 changed file with 16 additions and 5 deletions Side-by-side Diff
fs/nfs/pnfs.c
... | ... | @@ -1078,11 +1078,22 @@ |
1078 | 1078 | return true; |
1079 | 1079 | } |
1080 | 1080 | |
1081 | - if (req_offset(req) > end_offset(pgio->pg_lseg->pls_range.offset, | |
1082 | - pgio->pg_lseg->pls_range.length)) | |
1083 | - return false; | |
1084 | - | |
1085 | - return true; | |
1081 | + /* | |
1082 | + * Test if a nfs_page is fully contained in the pnfs_layout_range. | |
1083 | + * Note that this test makes several assumptions: | |
1084 | + * - that the previous nfs_page in the struct nfs_pageio_descriptor | |
1085 | + * is known to lie within the range. | |
1086 | + * - that the nfs_page being tested is known to be contiguous with the | |
1087 | + * previous nfs_page. | |
1088 | + * - Layout ranges are page aligned, so we only have to test the | |
1089 | + * start offset of the request. | |
1090 | + * | |
1091 | + * Please also note that 'end_offset' is actually the offset of the | |
1092 | + * first byte that lies outside the pnfs_layout_range. FIXME? | |
1093 | + * | |
1094 | + */ | |
1095 | + return req_offset(req) < end_offset(pgio->pg_lseg->pls_range.offset, | |
1096 | + pgio->pg_lseg->pls_range.length); | |
1086 | 1097 | } |
1087 | 1098 | EXPORT_SYMBOL_GPL(pnfs_generic_pg_test); |
1088 | 1099 |