aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorWeston Andros Adamson <dros@primarydata.com>2014-07-17 20:42:19 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-08-03 17:05:26 -0400
commit411a99adffb4f993eee29759f744de01487044ac (patch)
treecea4af52189a179a8001d5ae5c2d5ed28bd5f7d7 /fs
parente6cf82d1830f5e16a10d566f58db70f297ba5da8 (diff)
nfs: clear_request_commit while holding i_lock
Signed-off-by: Weston Andros Adamson <dros@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/filelayout/filelayout.c5
-rw-r--r--fs/nfs/write.c15
2 files changed, 6 insertions, 14 deletions
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index 524e66f6bb9c..1359c4a27393 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -1009,6 +1009,7 @@ static u32 select_bucket_index(struct nfs4_filelayout_segment *fl, u32 j)
1009 1009
1010/* The generic layer is about to remove the req from the commit list. 1010/* The generic layer is about to remove the req from the commit list.
1011 * If this will make the bucket empty, it will need to put the lseg reference. 1011 * If this will make the bucket empty, it will need to put the lseg reference.
1012 * Note this is must be called holding the inode (/cinfo) lock
1012 */ 1013 */
1013static void 1014static void
1014filelayout_clear_request_commit(struct nfs_page *req, 1015filelayout_clear_request_commit(struct nfs_page *req,
@@ -1016,7 +1017,6 @@ filelayout_clear_request_commit(struct nfs_page *req,
1016{ 1017{
1017 struct pnfs_layout_segment *freeme = NULL; 1018 struct pnfs_layout_segment *freeme = NULL;
1018 1019
1019 spin_lock(cinfo->lock);
1020 if (!test_and_clear_bit(PG_COMMIT_TO_DS, &req->wb_flags)) 1020 if (!test_and_clear_bit(PG_COMMIT_TO_DS, &req->wb_flags))
1021 goto out; 1021 goto out;
1022 cinfo->ds->nwritten--; 1022 cinfo->ds->nwritten--;
@@ -1031,8 +1031,7 @@ filelayout_clear_request_commit(struct nfs_page *req,
1031 } 1031 }
1032out: 1032out:
1033 nfs_request_remove_commit_list(req, cinfo); 1033 nfs_request_remove_commit_list(req, cinfo);
1034 spin_unlock(cinfo->lock); 1034 pnfs_put_lseg_async(freeme);
1035 pnfs_put_lseg(freeme);
1036} 1035}
1037 1036
1038static void 1037static void
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index ba417692b80d..1065de26190b 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -404,8 +404,6 @@ nfs_destroy_unlinked_subrequests(struct nfs_page *destroy_list,
404 subreq->wb_head = subreq; 404 subreq->wb_head = subreq;
405 subreq->wb_this_page = subreq; 405 subreq->wb_this_page = subreq;
406 406
407 nfs_clear_request_commit(subreq);
408
409 /* subreq is now totally disconnected from page group or any 407 /* subreq is now totally disconnected from page group or any
410 * write / commit lists. last chance to wake any waiters */ 408 * write / commit lists. last chance to wake any waiters */
411 nfs_unlock_request(subreq); 409 nfs_unlock_request(subreq);
@@ -515,7 +513,7 @@ try_again:
515 * Commit list removal accounting is done after locks are dropped */ 513 * Commit list removal accounting is done after locks are dropped */
516 subreq = head; 514 subreq = head;
517 do { 515 do {
518 nfs_list_remove_request(subreq); 516 nfs_clear_request_commit(subreq);
519 subreq = subreq->wb_this_page; 517 subreq = subreq->wb_this_page;
520 } while (subreq != head); 518 } while (subreq != head);
521 519
@@ -545,15 +543,11 @@ try_again:
545 543
546 nfs_page_group_unlock(head); 544 nfs_page_group_unlock(head);
547 545
548 /* drop lock to clear_request_commit the head req and clean up 546 /* drop lock to clean uprequests on destroy list */
549 * requests on destroy list */
550 spin_unlock(&inode->i_lock); 547 spin_unlock(&inode->i_lock);
551 548
552 nfs_destroy_unlinked_subrequests(destroy_list, head); 549 nfs_destroy_unlinked_subrequests(destroy_list, head);
553 550
554 /* clean up commit list state */
555 nfs_clear_request_commit(head);
556
557 /* still holds ref on head from nfs_page_find_head_request_locked 551 /* still holds ref on head from nfs_page_find_head_request_locked
558 * and still has lock on head from lock loop */ 552 * and still has lock on head from lock loop */
559 return head; 553 return head;
@@ -837,6 +831,7 @@ nfs_clear_page_commit(struct page *page)
837 dec_bdi_stat(page_file_mapping(page)->backing_dev_info, BDI_RECLAIMABLE); 831 dec_bdi_stat(page_file_mapping(page)->backing_dev_info, BDI_RECLAIMABLE);
838} 832}
839 833
834/* Called holding inode (/cinfo) lock */
840static void 835static void
841nfs_clear_request_commit(struct nfs_page *req) 836nfs_clear_request_commit(struct nfs_page *req)
842{ 837{
@@ -846,9 +841,7 @@ nfs_clear_request_commit(struct nfs_page *req)
846 841
847 nfs_init_cinfo_from_inode(&cinfo, inode); 842 nfs_init_cinfo_from_inode(&cinfo, inode);
848 if (!pnfs_clear_request_commit(req, &cinfo)) { 843 if (!pnfs_clear_request_commit(req, &cinfo)) {
849 spin_lock(cinfo.lock);
850 nfs_request_remove_commit_list(req, &cinfo); 844 nfs_request_remove_commit_list(req, &cinfo);
851 spin_unlock(cinfo.lock);
852 } 845 }
853 nfs_clear_page_commit(req->wb_page); 846 nfs_clear_page_commit(req->wb_page);
854 } 847 }
@@ -1061,9 +1054,9 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,
1061 else 1054 else
1062 req->wb_bytes = rqend - req->wb_offset; 1055 req->wb_bytes = rqend - req->wb_offset;
1063out_unlock: 1056out_unlock:
1064 spin_unlock(&inode->i_lock);
1065 if (req) 1057 if (req)
1066 nfs_clear_request_commit(req); 1058 nfs_clear_request_commit(req);
1059 spin_unlock(&inode->i_lock);
1067 return req; 1060 return req;
1068out_flushme: 1061out_flushme:
1069 spin_unlock(&inode->i_lock); 1062 spin_unlock(&inode->i_lock);