@@ -170,18 +170,12 @@ static void nd_blk_make_request(struct request_queue *q, struct bio *bio)
struct bvec_iter iter;
struct bio_vec bvec;
int err = 0, rw;
- sector_t sector;
- sector = bio->bi_iter.bi_sector;
- if (bio_end_sector(bio) > get_capacity(disk)) {
+ if (unlikely(bio_end_sector(bio) > get_capacity(disk))) {
err = -EIO;
goto out;
}
- BUG_ON(bio->bi_rw & REQ_DISCARD);
-
- rw = bio_data_dir(bio);
-
/*
* bio_integrity_enabled also checks if the bio already has an
* integrity payload attached. If it does, we *don't* do a
@@ -196,20 +190,20 @@ static void nd_blk_make_request(struct request_queue *q, struct bio *bio)
bip = bio_integrity(bio);
blk_dev = disk->private_data;
+ rw = bio_data_dir(bio);
bio_for_each_segment(bvec, bio, iter) {
unsigned int len = bvec.bv_len;
BUG_ON(len > PAGE_SIZE);
err = nd_blk_do_bvec(blk_dev, bip, bvec.bv_page, len,
- bvec.bv_offset, rw, sector);
+ bvec.bv_offset, rw, iter.bi_sector);
if (err) {
dev_info(&blk_dev->nsblk->dev,
"io error in %s sector %lld, len %d,\n",
(rw == READ) ? "READ" : "WRITE",
- (unsigned long long) sector, len);
+ (unsigned long long) iter.bi_sector, len);
goto out;
}
- sector += len >> SECTOR_SHIFT;
}
out:
@@ -1177,23 +1177,16 @@ static void btt_make_request(struct request_queue *q, struct bio *bio)
struct bio_integrity_payload *bip = bio_integrity(bio);
struct block_device *bdev = bio->bi_bdev;
struct btt *btt = q->queuedata;
- int rw;
- struct bio_vec bvec;
- sector_t sector;
struct bvec_iter iter;
- int err = 0;
+ struct bio_vec bvec;
+ int err = 0, rw;
- sector = bio->bi_iter.bi_sector;
if (bio_end_sector(bio) > get_capacity(bdev->bd_disk)) {
err = -EIO;
goto out;
}
- BUG_ON(bio->bi_rw & REQ_DISCARD);
-
- rw = bio_rw(bio);
- if (rw == READA)
- rw = READ;
+ rw = bio_data_dir(bio);
/*
* bio_integrity_enabled also checks if the bio already has an
@@ -1216,15 +1209,14 @@ static void btt_make_request(struct request_queue *q, struct bio *bio)
BUG_ON(len % btt->sector_size);
err = btt_do_bvec(btt, bip, bvec.bv_page, len, bvec.bv_offset,
- rw, sector);
+ rw, iter.bi_sector);
if (err) {
dev_info(&btt->nd_btt->dev,
"io error in %s sector %lld, len %d,\n",
(rw == READ) ? "READ" : "WRITE",
- (unsigned long long) sector, len);
+ (unsigned long long) iter.bi_sector, len);
goto out;
}
- sector += len >> SECTOR_SHIFT;
}
out:
@@ -58,28 +58,20 @@ static void pmem_do_bvec(struct pmem_device *pmem, struct page *page,
static void pmem_make_request(struct request_queue *q, struct bio *bio)
{
- struct block_device *bdev = bio->bi_bdev;
- struct pmem_device *pmem = bdev->bd_disk->private_data;
- int rw;
+ int err = 0;
struct bio_vec bvec;
- sector_t sector;
struct bvec_iter iter;
- int err = 0;
+ struct block_device *bdev = bio->bi_bdev;
+ struct pmem_device *pmem = bdev->bd_disk->private_data;
- if (bio_end_sector(bio) > get_capacity(bdev->bd_disk)) {
+ if (unlikely(bio_end_sector(bio) > get_capacity(bdev->bd_disk))) {
err = -EIO;
goto out;
}
- BUG_ON(bio->bi_rw & REQ_DISCARD);
-
- rw = bio_data_dir(bio);
- sector = bio->bi_iter.bi_sector;
- bio_for_each_segment(bvec, bio, iter) {
+ bio_for_each_segment(bvec, bio, iter)
pmem_do_bvec(pmem, bvec.bv_page, bvec.bv_len, bvec.bv_offset,
- rw, sector);
- sector += bvec.bv_len >> 9;
- }
+ bio_data_dir(bio), iter.bi_sector);
out:
bio_endio(bio, err);