···473473 do {474474 /*475475 * Subrequests are always contiguous, non overlapping476476- * and in order. If not, it's a programming error.476476+ * and in order - but may be repeated (mirrored writes).477477 */478478- WARN_ON_ONCE(subreq->wb_offset !=479479- (head->wb_offset + total_bytes));480480-481481- /* keep track of how many bytes this group covers */482482- total_bytes += subreq->wb_bytes;478478+ if (subreq->wb_offset == (head->wb_offset + total_bytes)) {479479+ /* keep track of how many bytes this group covers */480480+ total_bytes += subreq->wb_bytes;481481+ } else if (WARN_ON_ONCE(subreq->wb_offset < head->wb_offset ||482482+ ((subreq->wb_offset + subreq->wb_bytes) >483483+ (head->wb_offset + total_bytes)))) {484484+ nfs_page_group_unlock(head);485485+ spin_unlock(&inode->i_lock);486486+ return ERR_PTR(-EIO);487487+ }483488484489 if (!nfs_lock_request(subreq)) {485490 /* releases page group bit lock and