Commit edc870e5 authored by Dan Williams's avatar Dan Williams

pmem: make_request cleanups

Various cleanups:

1/ Kill the BUG_ON since we've already told the block layer we don't
   support DISCARD on all these drivers.

2/ Kill the 'rw' variable, no need to cache it.

3/ Kill the local 'sector' variable.  bio_for_each_segment() is already
   advancing the iterator's sector number by the bio_vec length.

4/ Kill the check for accessing past the end of device
   generic_make_request_checks() already does that.
Suggested-by: default avatarChristoph Hellwig <hch@lst.de>
[hch: kill access past end of the device check]
Reviewed-by: default avatarVishal Verma <vishal.l.verma@linux.intel.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 43d3fa3a
...@@ -58,31 +58,15 @@ static void pmem_do_bvec(struct pmem_device *pmem, struct page *page, ...@@ -58,31 +58,15 @@ static void pmem_do_bvec(struct pmem_device *pmem, struct page *page,
static void pmem_make_request(struct request_queue *q, struct bio *bio) 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;
struct bio_vec bvec; struct bio_vec bvec;
sector_t sector;
struct bvec_iter iter; 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)) {
err = -EIO;
goto out;
}
BUG_ON(bio->bi_rw & REQ_DISCARD);
rw = bio_data_dir(bio); bio_for_each_segment(bvec, bio, iter)
sector = bio->bi_iter.bi_sector;
bio_for_each_segment(bvec, bio, iter) {
pmem_do_bvec(pmem, bvec.bv_page, bvec.bv_len, bvec.bv_offset, pmem_do_bvec(pmem, bvec.bv_page, bvec.bv_len, bvec.bv_offset,
rw, sector); bio_data_dir(bio), iter.bi_sector);
sector += bvec.bv_len >> 9; bio_endio(bio, 0);
}
out:
bio_endio(bio, err);
} }
static int pmem_rw_page(struct block_device *bdev, sector_t sector, static int pmem_rw_page(struct block_device *bdev, sector_t sector,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment