diff options
author | Tom Haynes <thomas.haynes@primarydata.com> | 2015-02-17 17:58:15 -0500 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2015-02-18 10:20:35 -0500 |
commit | 338d00cfef07d74a072f96821c64b20f98517d72 (patch) | |
tree | 6c08180ef0e965862675a33a53ccffb8f0d59114 /fs | |
parent | 487b9b8afde60986b606b3ee05169fb893adc153 (diff) |
pnfs: Refactor the *_layout_mark_request_commit to use pnfs_layout_mark_request_commit
The File Layout's filelayout_mark_request_commit() is almost the
Flex File Layout's ff_layout_mark_request_commit(). And that can
be reduced by calling into nfs_request_add_commit_list().
Signed-off-by: Tom Haynes <loghyr@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/filelayout/filelayout.c | 48 | ||||
-rw-r--r-- | fs/nfs/flexfilelayout/flexfilelayout.c | 38 | ||||
-rw-r--r-- | fs/nfs/pnfs.h | 4 | ||||
-rw-r--r-- | fs/nfs/pnfs_nfs.c | 30 |
4 files changed, 45 insertions, 75 deletions
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c index e1e5ea262a13..91e88a7ecef0 100644 --- a/fs/nfs/filelayout/filelayout.c +++ b/fs/nfs/filelayout/filelayout.c | |||
@@ -960,48 +960,20 @@ filelayout_mark_request_commit(struct nfs_page *req, | |||
960 | { | 960 | { |
961 | struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg); | 961 | struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg); |
962 | u32 i, j; | 962 | u32 i, j; |
963 | struct list_head *list; | ||
964 | struct pnfs_commit_bucket *buckets; | ||
965 | 963 | ||
966 | if (fl->commit_through_mds) { | 964 | if (fl->commit_through_mds) { |
967 | list = &cinfo->mds->list; | 965 | nfs_request_add_commit_list(req, &cinfo->mds->list, cinfo); |
968 | spin_lock(cinfo->lock); | 966 | } else { |
969 | goto mds_commit; | 967 | /* Note that we are calling nfs4_fl_calc_j_index on each page |
970 | } | 968 | * that ends up being committed to a data server. An attractive |
971 | 969 | * alternative is to add a field to nfs_write_data and nfs_page | |
972 | /* Note that we are calling nfs4_fl_calc_j_index on each page | 970 | * to store the value calculated in filelayout_write_pagelist |
973 | * that ends up being committed to a data server. An attractive | 971 | * and just use that here. |
974 | * alternative is to add a field to nfs_write_data and nfs_page | ||
975 | * to store the value calculated in filelayout_write_pagelist | ||
976 | * and just use that here. | ||
977 | */ | ||
978 | j = nfs4_fl_calc_j_index(lseg, req_offset(req)); | ||
979 | i = select_bucket_index(fl, j); | ||
980 | spin_lock(cinfo->lock); | ||
981 | buckets = cinfo->ds->buckets; | ||
982 | list = &buckets[i].written; | ||
983 | if (list_empty(list)) { | ||
984 | /* Non-empty buckets hold a reference on the lseg. That ref | ||
985 | * is normally transferred to the COMMIT call and released | ||
986 | * there. It could also be released if the last req is pulled | ||
987 | * off due to a rewrite, in which case it will be done in | ||
988 | * pnfs_generic_clear_request_commit | ||
989 | */ | 972 | */ |
990 | buckets[i].wlseg = pnfs_get_lseg(lseg); | 973 | j = nfs4_fl_calc_j_index(lseg, req_offset(req)); |
974 | i = select_bucket_index(fl, j); | ||
975 | pnfs_layout_mark_request_commit(req, lseg, cinfo, i); | ||
991 | } | 976 | } |
992 | set_bit(PG_COMMIT_TO_DS, &req->wb_flags); | ||
993 | cinfo->ds->nwritten++; | ||
994 | |||
995 | mds_commit: | ||
996 | /* nfs_request_add_commit_list(). We need to add req to list without | ||
997 | * dropping cinfo lock. | ||
998 | */ | ||
999 | set_bit(PG_CLEAN, &(req)->wb_flags); | ||
1000 | nfs_list_add_request(req, list); | ||
1001 | cinfo->mds->ncommit++; | ||
1002 | spin_unlock(cinfo->lock); | ||
1003 | if (!cinfo->dreq) | ||
1004 | nfs_mark_page_unstable(req->wb_page); | ||
1005 | } | 977 | } |
1006 | 978 | ||
1007 | static u32 calc_ds_index_from_commit(struct pnfs_layout_segment *lseg, u32 i) | 979 | static u32 calc_ds_index_from_commit(struct pnfs_layout_segment *lseg, u32 i) |
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index 423c2bc371fa..315cc68945b9 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c | |||
@@ -1332,42 +1332,6 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync) | |||
1332 | return PNFS_ATTEMPTED; | 1332 | return PNFS_ATTEMPTED; |
1333 | } | 1333 | } |
1334 | 1334 | ||
1335 | static void | ||
1336 | ff_layout_mark_request_commit(struct nfs_page *req, | ||
1337 | struct pnfs_layout_segment *lseg, | ||
1338 | struct nfs_commit_info *cinfo, | ||
1339 | u32 ds_commit_idx) | ||
1340 | { | ||
1341 | struct list_head *list; | ||
1342 | struct pnfs_commit_bucket *buckets; | ||
1343 | |||
1344 | spin_lock(cinfo->lock); | ||
1345 | buckets = cinfo->ds->buckets; | ||
1346 | list = &buckets[ds_commit_idx].written; | ||
1347 | if (list_empty(list)) { | ||
1348 | /* Non-empty buckets hold a reference on the lseg. That ref | ||
1349 | * is normally transferred to the COMMIT call and released | ||
1350 | * there. It could also be released if the last req is pulled | ||
1351 | * off due to a rewrite, in which case it will be done in | ||
1352 | * pnfs_common_clear_request_commit | ||
1353 | */ | ||
1354 | WARN_ON_ONCE(buckets[ds_commit_idx].wlseg != NULL); | ||
1355 | buckets[ds_commit_idx].wlseg = pnfs_get_lseg(lseg); | ||
1356 | } | ||
1357 | set_bit(PG_COMMIT_TO_DS, &req->wb_flags); | ||
1358 | cinfo->ds->nwritten++; | ||
1359 | |||
1360 | /* nfs_request_add_commit_list(). We need to add req to list without | ||
1361 | * dropping cinfo lock. | ||
1362 | */ | ||
1363 | set_bit(PG_CLEAN, &(req)->wb_flags); | ||
1364 | nfs_list_add_request(req, list); | ||
1365 | cinfo->mds->ncommit++; | ||
1366 | spin_unlock(cinfo->lock); | ||
1367 | if (!cinfo->dreq) | ||
1368 | nfs_mark_page_unstable(req->wb_page); | ||
1369 | } | ||
1370 | |||
1371 | static u32 calc_ds_index_from_commit(struct pnfs_layout_segment *lseg, u32 i) | 1335 | static u32 calc_ds_index_from_commit(struct pnfs_layout_segment *lseg, u32 i) |
1372 | { | 1336 | { |
1373 | return i; | 1337 | return i; |
@@ -1535,7 +1499,7 @@ static struct pnfs_layoutdriver_type flexfilelayout_type = { | |||
1535 | .pg_write_ops = &ff_layout_pg_write_ops, | 1499 | .pg_write_ops = &ff_layout_pg_write_ops, |
1536 | .get_ds_info = ff_layout_get_ds_info, | 1500 | .get_ds_info = ff_layout_get_ds_info, |
1537 | .free_deviceid_node = ff_layout_free_deveiceid_node, | 1501 | .free_deviceid_node = ff_layout_free_deveiceid_node, |
1538 | .mark_request_commit = ff_layout_mark_request_commit, | 1502 | .mark_request_commit = pnfs_layout_mark_request_commit, |
1539 | .clear_request_commit = pnfs_generic_clear_request_commit, | 1503 | .clear_request_commit = pnfs_generic_clear_request_commit, |
1540 | .scan_commit_lists = pnfs_generic_scan_commit_lists, | 1504 | .scan_commit_lists = pnfs_generic_scan_commit_lists, |
1541 | .recover_commit_reqs = pnfs_generic_recover_commit_reqs, | 1505 | .recover_commit_reqs = pnfs_generic_recover_commit_reqs, |
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 797cd6253adf..635f0865671c 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h | |||
@@ -344,6 +344,10 @@ void nfs4_pnfs_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds, | |||
344 | struct nfs4_pnfs_ds_addr *nfs4_decode_mp_ds_addr(struct net *net, | 344 | struct nfs4_pnfs_ds_addr *nfs4_decode_mp_ds_addr(struct net *net, |
345 | struct xdr_stream *xdr, | 345 | struct xdr_stream *xdr, |
346 | gfp_t gfp_flags); | 346 | gfp_t gfp_flags); |
347 | void pnfs_layout_mark_request_commit(struct nfs_page *req, | ||
348 | struct pnfs_layout_segment *lseg, | ||
349 | struct nfs_commit_info *cinfo, | ||
350 | u32 ds_commit_idx); | ||
347 | 351 | ||
348 | static inline bool nfs_have_layout(struct inode *inode) | 352 | static inline bool nfs_have_layout(struct inode *inode) |
349 | { | 353 | { |
diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c index fdc4f6562bb7..54e36b38fb5f 100644 --- a/fs/nfs/pnfs_nfs.c +++ b/fs/nfs/pnfs_nfs.c | |||
@@ -838,3 +838,33 @@ out_err: | |||
838 | return NULL; | 838 | return NULL; |
839 | } | 839 | } |
840 | EXPORT_SYMBOL_GPL(nfs4_decode_mp_ds_addr); | 840 | EXPORT_SYMBOL_GPL(nfs4_decode_mp_ds_addr); |
841 | |||
842 | void | ||
843 | pnfs_layout_mark_request_commit(struct nfs_page *req, | ||
844 | struct pnfs_layout_segment *lseg, | ||
845 | struct nfs_commit_info *cinfo, | ||
846 | u32 ds_commit_idx) | ||
847 | { | ||
848 | struct list_head *list; | ||
849 | struct pnfs_commit_bucket *buckets; | ||
850 | |||
851 | spin_lock(cinfo->lock); | ||
852 | buckets = cinfo->ds->buckets; | ||
853 | list = &buckets[ds_commit_idx].written; | ||
854 | if (list_empty(list)) { | ||
855 | /* Non-empty buckets hold a reference on the lseg. That ref | ||
856 | * is normally transferred to the COMMIT call and released | ||
857 | * there. It could also be released if the last req is pulled | ||
858 | * off due to a rewrite, in which case it will be done in | ||
859 | * pnfs_common_clear_request_commit | ||
860 | */ | ||
861 | WARN_ON_ONCE(buckets[ds_commit_idx].wlseg != NULL); | ||
862 | buckets[ds_commit_idx].wlseg = pnfs_get_lseg(lseg); | ||
863 | } | ||
864 | set_bit(PG_COMMIT_TO_DS, &req->wb_flags); | ||
865 | cinfo->ds->nwritten++; | ||
866 | spin_unlock(cinfo->lock); | ||
867 | |||
868 | nfs_request_add_commit_list(req, list, cinfo); | ||
869 | } | ||
870 | EXPORT_SYMBOL_GPL(pnfs_layout_mark_request_commit); | ||