Skip to content

Commit

Permalink
nfs/write: Use common error handling code in nfs_lock_and_join_reques…
Browse files Browse the repository at this point in the history
…ts()

Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
  • Loading branch information
elfring authored and amschuma-ntap committed Nov 17, 2017
1 parent fcd8843 commit 0671d8f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions fs/nfs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,8 @@ nfs_lock_and_join_requests(struct page *page)
}

ret = nfs_page_group_lock(head);
if (ret < 0) {
nfs_unlock_and_release_request(head);
return ERR_PTR(ret);
}
if (ret < 0)
goto release_request;

/* lock each request in the page group */
total_bytes = head->wb_bytes;
Expand All @@ -515,8 +513,7 @@ nfs_lock_and_join_requests(struct page *page)
if (ret < 0) {
nfs_unroll_locks(inode, head, subreq);
nfs_release_request(subreq);
nfs_unlock_and_release_request(head);
return ERR_PTR(ret);
goto release_request;
}
}
/*
Expand All @@ -532,8 +529,8 @@ nfs_lock_and_join_requests(struct page *page)
nfs_page_group_unlock(head);
nfs_unroll_locks(inode, head, subreq);
nfs_unlock_and_release_request(subreq);
nfs_unlock_and_release_request(head);
return ERR_PTR(-EIO);
ret = -EIO;
goto release_request;
}
}

Expand Down Expand Up @@ -576,6 +573,10 @@ nfs_lock_and_join_requests(struct page *page)
/* still holds ref on head from nfs_page_find_head_request
* and still has lock on head from lock loop */
return head;

release_request:
nfs_unlock_and_release_request(head);
return ERR_PTR(ret);
}

static void nfs_write_error_remove_page(struct nfs_page *req)
Expand Down

0 comments on commit 0671d8f

Please sign in to comment.