Commit 84f8a2da authored by Weston Andros Adamson's avatar Weston Andros Adamson Committed by Greg Kroah-Hartman

nfs: clear_request_commit while holding i_lock

commit 411a99ad upstream.
Signed-off-by: default avatarWeston Andros Adamson <dros@primarydata.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 31171a06
...@@ -1015,6 +1015,7 @@ static u32 select_bucket_index(struct nfs4_filelayout_segment *fl, u32 j) ...@@ -1015,6 +1015,7 @@ static u32 select_bucket_index(struct nfs4_filelayout_segment *fl, u32 j)
/* The generic layer is about to remove the req from the commit list. /* The generic layer is about to remove the req from the commit list.
* If this will make the bucket empty, it will need to put the lseg reference. * If this will make the bucket empty, it will need to put the lseg reference.
* Note this is must be called holding the inode (/cinfo) lock
*/ */
static void static void
filelayout_clear_request_commit(struct nfs_page *req, filelayout_clear_request_commit(struct nfs_page *req,
...@@ -1022,7 +1023,6 @@ filelayout_clear_request_commit(struct nfs_page *req, ...@@ -1022,7 +1023,6 @@ filelayout_clear_request_commit(struct nfs_page *req,
{ {
struct pnfs_layout_segment *freeme = NULL; struct pnfs_layout_segment *freeme = NULL;
spin_lock(cinfo->lock);
if (!test_and_clear_bit(PG_COMMIT_TO_DS, &req->wb_flags)) if (!test_and_clear_bit(PG_COMMIT_TO_DS, &req->wb_flags))
goto out; goto out;
cinfo->ds->nwritten--; cinfo->ds->nwritten--;
...@@ -1037,8 +1037,7 @@ filelayout_clear_request_commit(struct nfs_page *req, ...@@ -1037,8 +1037,7 @@ filelayout_clear_request_commit(struct nfs_page *req,
} }
out: out:
nfs_request_remove_commit_list(req, cinfo); nfs_request_remove_commit_list(req, cinfo);
spin_unlock(cinfo->lock); pnfs_put_lseg_async(freeme);
pnfs_put_lseg(freeme);
} }
static struct list_head * static struct list_head *
......
...@@ -379,8 +379,6 @@ nfs_destroy_unlinked_subrequests(struct nfs_page *destroy_list, ...@@ -379,8 +379,6 @@ nfs_destroy_unlinked_subrequests(struct nfs_page *destroy_list,
subreq->wb_head = subreq; subreq->wb_head = subreq;
subreq->wb_this_page = subreq; subreq->wb_this_page = subreq;
nfs_clear_request_commit(subreq);
/* subreq is now totally disconnected from page group or any /* subreq is now totally disconnected from page group or any
* write / commit lists. last chance to wake any waiters */ * write / commit lists. last chance to wake any waiters */
nfs_unlock_request(subreq); nfs_unlock_request(subreq);
...@@ -490,7 +488,7 @@ nfs_lock_and_join_requests(struct page *page, bool nonblock) ...@@ -490,7 +488,7 @@ nfs_lock_and_join_requests(struct page *page, bool nonblock)
* Commit list removal accounting is done after locks are dropped */ * Commit list removal accounting is done after locks are dropped */
subreq = head; subreq = head;
do { do {
nfs_list_remove_request(subreq); nfs_clear_request_commit(subreq);
subreq = subreq->wb_this_page; subreq = subreq->wb_this_page;
} while (subreq != head); } while (subreq != head);
...@@ -520,15 +518,11 @@ nfs_lock_and_join_requests(struct page *page, bool nonblock) ...@@ -520,15 +518,11 @@ nfs_lock_and_join_requests(struct page *page, bool nonblock)
nfs_page_group_unlock(head); nfs_page_group_unlock(head);
/* drop lock to clear_request_commit the head req and clean up /* drop lock to clean uprequests on destroy list */
* requests on destroy list */
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
nfs_destroy_unlinked_subrequests(destroy_list, head); nfs_destroy_unlinked_subrequests(destroy_list, head);
/* clean up commit list state */
nfs_clear_request_commit(head);
/* still holds ref on head from nfs_page_find_head_request_locked /* still holds ref on head from nfs_page_find_head_request_locked
* and still has lock on head from lock loop */ * and still has lock on head from lock loop */
return head; return head;
...@@ -810,6 +804,7 @@ nfs_clear_page_commit(struct page *page) ...@@ -810,6 +804,7 @@ nfs_clear_page_commit(struct page *page)
dec_bdi_stat(page_file_mapping(page)->backing_dev_info, BDI_RECLAIMABLE); dec_bdi_stat(page_file_mapping(page)->backing_dev_info, BDI_RECLAIMABLE);
} }
/* Called holding inode (/cinfo) lock */
static void static void
nfs_clear_request_commit(struct nfs_page *req) nfs_clear_request_commit(struct nfs_page *req)
{ {
...@@ -819,9 +814,7 @@ nfs_clear_request_commit(struct nfs_page *req) ...@@ -819,9 +814,7 @@ nfs_clear_request_commit(struct nfs_page *req)
nfs_init_cinfo_from_inode(&cinfo, inode); nfs_init_cinfo_from_inode(&cinfo, inode);
if (!pnfs_clear_request_commit(req, &cinfo)) { if (!pnfs_clear_request_commit(req, &cinfo)) {
spin_lock(cinfo.lock);
nfs_request_remove_commit_list(req, &cinfo); nfs_request_remove_commit_list(req, &cinfo);
spin_unlock(cinfo.lock);
} }
nfs_clear_page_commit(req->wb_page); nfs_clear_page_commit(req->wb_page);
} }
...@@ -1040,9 +1033,9 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode, ...@@ -1040,9 +1033,9 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,
else else
req->wb_bytes = rqend - req->wb_offset; req->wb_bytes = rqend - req->wb_offset;
out_unlock: out_unlock:
spin_unlock(&inode->i_lock);
if (req) if (req)
nfs_clear_request_commit(req); nfs_clear_request_commit(req);
spin_unlock(&inode->i_lock);
return req; return req;
out_flushme: out_flushme:
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment