Skip to content

Commit 411a99a

Browse files
westonandrosadamsontrondmypd
authored andcommitted
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>
1 parent e6cf82d commit 411a99a

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

‎fs/nfs/filelayout/filelayout.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,14 +1009,14 @@ static u32 select_bucket_index(struct nfs4_filelayout_segment *fl, u32 j)
10091009

10101010
/* The generic layer is about to remove the req from the commit list.
10111011
* 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
10121013
*/
10131014
static void
10141015
filelayout_clear_request_commit(struct nfs_page *req,
10151016
struct nfs_commit_info *cinfo)
10161017
{
10171018
struct pnfs_layout_segment *freeme = NULL;
10181019

1019-
spin_lock(cinfo->lock);
10201020
if (!test_and_clear_bit(PG_COMMIT_TO_DS, &req->wb_flags))
10211021
goto out;
10221022
cinfo->ds->nwritten--;
@@ -1031,8 +1031,7 @@ filelayout_clear_request_commit(struct nfs_page *req,
10311031
}
10321032
out:
10331033
nfs_request_remove_commit_list(req, cinfo);
1034-
spin_unlock(cinfo->lock);
1035-
pnfs_put_lseg(freeme);
1034+
pnfs_put_lseg_async(freeme);
10361035
}
10371036

10381037
static void

‎fs/nfs/write.c‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,6 @@ nfs_destroy_unlinked_subrequests(struct nfs_page *destroy_list,
404404
subreq->wb_head = subreq;
405405
subreq->wb_this_page = subreq;
406406

407-
nfs_clear_request_commit(subreq);
408-
409407
/* subreq is now totally disconnected from page group or any
410408
* write / commit lists. last chance to wake any waiters */
411409
nfs_unlock_request(subreq);
@@ -515,7 +513,7 @@ nfs_lock_and_join_requests(struct page *page, bool nonblock)
515513
* Commit list removal accounting is done after locks are dropped */
516514
subreq = head;
517515
do {
518-
nfs_list_remove_request(subreq);
516+
nfs_clear_request_commit(subreq);
519517
subreq = subreq->wb_this_page;
520518
} while (subreq != head);
521519

@@ -545,15 +543,11 @@ nfs_lock_and_join_requests(struct page *page, bool nonblock)
545543

546544
nfs_page_group_unlock(head);
547545

548-
/* drop lock to clear_request_commit the head req and clean up
549-
* requests on destroy list */
546+
/* drop lock to clean uprequests on destroy list */
550547
spin_unlock(&inode->i_lock);
551548

552549
nfs_destroy_unlinked_subrequests(destroy_list, head);
553550

554-
/* clean up commit list state */
555-
nfs_clear_request_commit(head);
556-
557551
/* still holds ref on head from nfs_page_find_head_request_locked
558552
* and still has lock on head from lock loop */
559553
return head;
@@ -837,6 +831,7 @@ nfs_clear_page_commit(struct page *page)
837831
dec_bdi_stat(page_file_mapping(page)->backing_dev_info, BDI_RECLAIMABLE);
838832
}
839833

834+
/* Called holding inode (/cinfo) lock */
840835
static void
841836
nfs_clear_request_commit(struct nfs_page *req)
842837
{
@@ -846,9 +841,7 @@ nfs_clear_request_commit(struct nfs_page *req)
846841

847842
nfs_init_cinfo_from_inode(&cinfo, inode);
848843
if (!pnfs_clear_request_commit(req, &cinfo)) {
849-
spin_lock(cinfo.lock);
850844
nfs_request_remove_commit_list(req, &cinfo);
851-
spin_unlock(cinfo.lock);
852845
}
853846
nfs_clear_page_commit(req->wb_page);
854847
}
@@ -1061,9 +1054,9 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,
10611054
else
10621055
req->wb_bytes = rqend - req->wb_offset;
10631056
out_unlock:
1064-
spin_unlock(&inode->i_lock);
10651057
if (req)
10661058
nfs_clear_request_commit(req);
1059+
spin_unlock(&inode->i_lock);
10671060
return req;
10681061
out_flushme:
10691062
spin_unlock(&inode->i_lock);

0 commit comments

Comments
 (0)