Skip to content

Commit

Permalink
block: handle partial completions for special payload requests
Browse files Browse the repository at this point in the history
SCSI devices can return short writes on Write Same just like for normal
writes, so we need to handle this case for our special payload requests
as well.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
Tested-by: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Christoph Hellwig authored and axboe committed May 11, 2017
1 parent f36ea50 commit ed6565e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2644,8 +2644,6 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
return false;
}

WARN_ON_ONCE(req->rq_flags & RQF_SPECIAL_PAYLOAD);

req->__data_len -= total_bytes;

/* update sector only for requests with clear definition of sector */
Expand All @@ -2658,17 +2656,19 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
req->cmd_flags |= req->bio->bi_opf & REQ_FAILFAST_MASK;
}

/*
* If total number of sectors is less than the first segment
* size, something has gone terribly wrong.
*/
if (blk_rq_bytes(req) < blk_rq_cur_bytes(req)) {
blk_dump_rq_flags(req, "request botched");
req->__data_len = blk_rq_cur_bytes(req);
}
if (!(req->rq_flags & RQF_SPECIAL_PAYLOAD)) {
/*
* If total number of sectors is less than the first segment
* size, something has gone terribly wrong.
*/
if (blk_rq_bytes(req) < blk_rq_cur_bytes(req)) {
blk_dump_rq_flags(req, "request botched");
req->__data_len = blk_rq_cur_bytes(req);
}

/* recalculate the number of segments */
blk_recalc_rq_segments(req);
/* recalculate the number of segments */
blk_recalc_rq_segments(req);
}

return true;
}
Expand Down

0 comments on commit ed6565e

Please sign in to comment.