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

nfs: modify pg_test interface to return size_t

This is a step toward allowing pg_test to inform the the
coalescing code to reduce the size of requests so they may fit in
whatever scheme the pg_test callback wants to define.

For now, just return the size of the request if there is space, or 0
if there is not. This shouldn't change any behavior as it acts
the same as when the pg_test functions returned bool.

Signed-off-by: Weston Andros Adamson <dros@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>

authored by

Weston Andros Adamson and committed by
Trond Myklebust
b4fdac1a 8c8f1ac1

+62 -23
+12 -4
fs/nfs/blocklayout/blocklayout.c
··· 1189 1189 pnfs_generic_pg_init_read(pgio, req); 1190 1190 } 1191 1191 1192 - static bool 1192 + /* 1193 + * Return 0 if @req cannot be coalesced into @pgio, otherwise return the number 1194 + * of bytes (maximum @req->wb_bytes) that can be coalesced. 1195 + */ 1196 + static size_t 1193 1197 bl_pg_test_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, 1194 1198 struct nfs_page *req) 1195 1199 { 1196 1200 if (pgio->pg_dreq != NULL && 1197 1201 !is_aligned_req(req, SECTOR_SIZE)) 1198 - return false; 1202 + return 0; 1199 1203 1200 1204 return pnfs_generic_pg_test(pgio, prev, req); 1201 1205 } ··· 1245 1241 } 1246 1242 } 1247 1243 1248 - static bool 1244 + /* 1245 + * Return 0 if @req cannot be coalesced into @pgio, otherwise return the number 1246 + * of bytes (maximum @req->wb_bytes) that can be coalesced. 1247 + */ 1248 + static size_t 1249 1249 bl_pg_test_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, 1250 1250 struct nfs_page *req) 1251 1251 { 1252 1252 if (pgio->pg_dreq != NULL && 1253 1253 !is_aligned_req(req, PAGE_CACHE_SIZE)) 1254 - return false; 1254 + return 0; 1255 1255 1256 1256 return pnfs_generic_pg_test(pgio, prev, req); 1257 1257 }
+7 -5
fs/nfs/nfs4filelayout.c
··· 915 915 /* 916 916 * filelayout_pg_test(). Called by nfs_can_coalesce_requests() 917 917 * 918 - * return true : coalesce page 919 - * return false : don't coalesce page 918 + * Return 0 if @req cannot be coalesced into @pgio, otherwise return the number 919 + * of bytes (maximum @req->wb_bytes) that can be coalesced. 920 920 */ 921 - static bool 921 + static size_t 922 922 filelayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, 923 923 struct nfs_page *req) 924 924 { ··· 927 927 928 928 if (!pnfs_generic_pg_test(pgio, prev, req) || 929 929 !nfs_generic_pg_test(pgio, prev, req)) 930 - return false; 930 + return 0; 931 931 932 932 p_stripe = (u64)req_offset(prev); 933 933 r_stripe = (u64)req_offset(req); ··· 936 936 do_div(p_stripe, stripe_unit); 937 937 do_div(r_stripe, stripe_unit); 938 938 939 - return (p_stripe == r_stripe); 939 + if (p_stripe == r_stripe) 940 + return req->wb_bytes; 941 + return 0; 940 942 } 941 943 942 944 static void
+10 -5
fs/nfs/objlayout/objio_osd.c
··· 564 564 return 0; 565 565 } 566 566 567 - static bool objio_pg_test(struct nfs_pageio_descriptor *pgio, 567 + /* 568 + * Return 0 if @req cannot be coalesced into @pgio, otherwise return the number 569 + * of bytes (maximum @req->wb_bytes) that can be coalesced. 570 + */ 571 + static size_t objio_pg_test(struct nfs_pageio_descriptor *pgio, 568 572 struct nfs_page *prev, struct nfs_page *req) 569 573 { 570 - if (!pnfs_generic_pg_test(pgio, prev, req)) 571 - return false; 574 + if (!pnfs_generic_pg_test(pgio, prev, req) || 575 + pgio->pg_count + req->wb_bytes > 576 + (unsigned long)pgio->pg_layout_private) 577 + return 0; 572 578 573 - return pgio->pg_count + req->wb_bytes <= 574 - (unsigned long)pgio->pg_layout_private; 579 + return req->wb_bytes; 575 580 } 576 581 577 582 static void objio_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
+19 -3
fs/nfs/pagelist.c
··· 280 280 TASK_UNINTERRUPTIBLE); 281 281 } 282 282 283 - bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, struct nfs_page *prev, struct nfs_page *req) 283 + /* 284 + * nfs_generic_pg_test - determine if requests can be coalesced 285 + * @desc: pointer to descriptor 286 + * @prev: previous request in desc, or NULL 287 + * @req: this request 288 + * 289 + * Returns zero if @req can be coalesced into @desc, otherwise it returns 290 + * the size of the request. 291 + */ 292 + size_t nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, 293 + struct nfs_page *prev, struct nfs_page *req) 284 294 { 285 295 /* 286 296 * FIXME: ideally we should be able to coalesce all requests ··· 302 292 if (desc->pg_bsize < PAGE_SIZE) 303 293 return 0; 304 294 305 - return desc->pg_count + req->wb_bytes <= desc->pg_bsize; 295 + if (desc->pg_count + req->wb_bytes <= desc->pg_bsize) 296 + return req->wb_bytes; 297 + return 0; 306 298 } 307 299 EXPORT_SYMBOL_GPL(nfs_generic_pg_test); 308 300 ··· 759 747 struct nfs_page *req, 760 748 struct nfs_pageio_descriptor *pgio) 761 749 { 750 + size_t size; 751 + 762 752 if (!nfs_match_open_context(req->wb_context, prev->wb_context)) 763 753 return false; 764 754 if (req->wb_context->dentry->d_inode->i_flock != NULL && ··· 772 758 return false; 773 759 if (req_offset(req) != req_offset(prev) + prev->wb_bytes) 774 760 return false; 775 - return pgio->pg_ops->pg_test(pgio, prev, req); 761 + size = pgio->pg_ops->pg_test(pgio, prev, req); 762 + WARN_ON_ONCE(size && size != req->wb_bytes); 763 + return size > 0; 776 764 } 777 765 778 766 /**
+9 -3
fs/nfs/pnfs.c
··· 1434 1434 } 1435 1435 EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write); 1436 1436 1437 - bool 1437 + /* 1438 + * Return 0 if @req cannot be coalesced into @pgio, otherwise return the number 1439 + * of bytes (maximum @req->wb_bytes) that can be coalesced. 1440 + */ 1441 + size_t 1438 1442 pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, 1439 1443 struct nfs_page *req) 1440 1444 { ··· 1459 1455 * first byte that lies outside the pnfs_layout_range. FIXME? 1460 1456 * 1461 1457 */ 1462 - return req_offset(req) < end_offset(pgio->pg_lseg->pls_range.offset, 1463 - pgio->pg_lseg->pls_range.length); 1458 + if (req_offset(req) < end_offset(pgio->pg_lseg->pls_range.offset, 1459 + pgio->pg_lseg->pls_range.length)) 1460 + return req->wb_bytes; 1461 + return 0; 1464 1462 } 1465 1463 EXPORT_SYMBOL_GPL(pnfs_generic_pg_test); 1466 1464
+2 -1
fs/nfs/pnfs.h
··· 187 187 void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, 188 188 struct nfs_page *req, u64 wb_size); 189 189 int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc); 190 - bool pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req); 190 + size_t pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, 191 + struct nfs_page *prev, struct nfs_page *req); 191 192 void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg); 192 193 struct pnfs_layout_segment *pnfs_layout_process(struct nfs4_layoutget *lgp); 193 194 void pnfs_free_lseg_list(struct list_head *tmp_list);
+3 -2
include/linux/nfs_page.h
··· 46 46 struct nfs_pageio_descriptor; 47 47 struct nfs_pageio_ops { 48 48 void (*pg_init)(struct nfs_pageio_descriptor *, struct nfs_page *); 49 - bool (*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *, struct nfs_page *); 49 + size_t (*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *, 50 + struct nfs_page *); 50 51 int (*pg_doio)(struct nfs_pageio_descriptor *); 51 52 }; 52 53 ··· 103 102 struct nfs_page *); 104 103 extern void nfs_pageio_complete(struct nfs_pageio_descriptor *desc); 105 104 extern void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *, pgoff_t); 106 - extern bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, 105 + extern size_t nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, 107 106 struct nfs_page *prev, 108 107 struct nfs_page *req); 109 108 extern int nfs_wait_on_request(struct nfs_page *);