Skip to content

Commit

Permalink
nfs: handle overlapping reqs in lock_and_join
Browse files Browse the repository at this point in the history
This is needed for mirrored DS support, where multuple requests
cover the same range.

Signed-off-by: Weston Andros Adamson <dros@primarydata.com>
  • Loading branch information
Weston Andros Adamson authored and Tom Haynes committed Feb 3, 2015
1 parent 180bb5e commit 309a1d6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions fs/nfs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,18 @@ nfs_lock_and_join_requests(struct page *page, bool nonblock)
do {
/*
* Subrequests are always contiguous, non overlapping
* and in order. If not, it's a programming error.
* and in order - but may be repeated (mirrored writes).
*/
WARN_ON_ONCE(subreq->wb_offset !=
(head->wb_offset + total_bytes));

/* keep track of how many bytes this group covers */
total_bytes += subreq->wb_bytes;
if (subreq->wb_offset == (head->wb_offset + total_bytes)) {
/* keep track of how many bytes this group covers */
total_bytes += subreq->wb_bytes;
} else if (WARN_ON_ONCE(subreq->wb_offset < head->wb_offset ||
((subreq->wb_offset + subreq->wb_bytes) >
(head->wb_offset + total_bytes)))) {
nfs_page_group_unlock(head);
spin_unlock(&inode->i_lock);
return ERR_PTR(-EIO);
}

if (!nfs_lock_request(subreq)) {
/* releases page group bit lock and
Expand Down

0 comments on commit 309a1d6

Please sign in to comment.