Commit d7614e44 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

zram: nvdimm: use bio_{start,end}_io_acct and disk_{start,end}_io_acct

Switch zram to use the nicer bio accounting helpers, and as part of that
ensure each bio is counted as a single I/O request.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 0fd92f89
...@@ -1510,13 +1510,8 @@ static void zram_bio_discard(struct zram *zram, u32 index, ...@@ -1510,13 +1510,8 @@ static void zram_bio_discard(struct zram *zram, u32 index,
static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index, static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index,
int offset, unsigned int op, struct bio *bio) int offset, unsigned int op, struct bio *bio)
{ {
unsigned long start_time = jiffies;
struct request_queue *q = zram->disk->queue;
int ret; int ret;
generic_start_io_acct(q, op, bvec->bv_len >> SECTOR_SHIFT,
&zram->disk->part0);
if (!op_is_write(op)) { if (!op_is_write(op)) {
atomic64_inc(&zram->stats.num_reads); atomic64_inc(&zram->stats.num_reads);
ret = zram_bvec_read(zram, bvec, index, offset, bio); ret = zram_bvec_read(zram, bvec, index, offset, bio);
...@@ -1526,8 +1521,6 @@ static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index, ...@@ -1526,8 +1521,6 @@ static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index,
ret = zram_bvec_write(zram, bvec, index, offset, bio); ret = zram_bvec_write(zram, bvec, index, offset, bio);
} }
generic_end_io_acct(q, op, &zram->disk->part0, start_time);
zram_slot_lock(zram, index); zram_slot_lock(zram, index);
zram_accessed(zram, index); zram_accessed(zram, index);
zram_slot_unlock(zram, index); zram_slot_unlock(zram, index);
...@@ -1548,6 +1541,7 @@ static void __zram_make_request(struct zram *zram, struct bio *bio) ...@@ -1548,6 +1541,7 @@ static void __zram_make_request(struct zram *zram, struct bio *bio)
u32 index; u32 index;
struct bio_vec bvec; struct bio_vec bvec;
struct bvec_iter iter; struct bvec_iter iter;
unsigned long start_time;
index = bio->bi_iter.bi_sector >> SECTORS_PER_PAGE_SHIFT; index = bio->bi_iter.bi_sector >> SECTORS_PER_PAGE_SHIFT;
offset = (bio->bi_iter.bi_sector & offset = (bio->bi_iter.bi_sector &
...@@ -1563,6 +1557,7 @@ static void __zram_make_request(struct zram *zram, struct bio *bio) ...@@ -1563,6 +1557,7 @@ static void __zram_make_request(struct zram *zram, struct bio *bio)
break; break;
} }
start_time = bio_start_io_acct(bio);
bio_for_each_segment(bvec, bio, iter) { bio_for_each_segment(bvec, bio, iter) {
struct bio_vec bv = bvec; struct bio_vec bv = bvec;
unsigned int unwritten = bvec.bv_len; unsigned int unwritten = bvec.bv_len;
...@@ -1571,8 +1566,10 @@ static void __zram_make_request(struct zram *zram, struct bio *bio) ...@@ -1571,8 +1566,10 @@ static void __zram_make_request(struct zram *zram, struct bio *bio)
bv.bv_len = min_t(unsigned int, PAGE_SIZE - offset, bv.bv_len = min_t(unsigned int, PAGE_SIZE - offset,
unwritten); unwritten);
if (zram_bvec_rw(zram, &bv, index, offset, if (zram_bvec_rw(zram, &bv, index, offset,
bio_op(bio), bio) < 0) bio_op(bio), bio) < 0) {
goto out; bio->bi_status = BLK_STS_IOERR;
break;
}
bv.bv_offset += bv.bv_len; bv.bv_offset += bv.bv_len;
unwritten -= bv.bv_len; unwritten -= bv.bv_len;
...@@ -1580,12 +1577,8 @@ static void __zram_make_request(struct zram *zram, struct bio *bio) ...@@ -1580,12 +1577,8 @@ static void __zram_make_request(struct zram *zram, struct bio *bio)
update_position(&index, &offset, &bv); update_position(&index, &offset, &bv);
} while (unwritten); } while (unwritten);
} }
bio_end_io_acct(bio, start_time);
bio_endio(bio); bio_endio(bio);
return;
out:
bio_io_error(bio);
} }
/* /*
...@@ -1633,6 +1626,7 @@ static int zram_rw_page(struct block_device *bdev, sector_t sector, ...@@ -1633,6 +1626,7 @@ static int zram_rw_page(struct block_device *bdev, sector_t sector,
u32 index; u32 index;
struct zram *zram; struct zram *zram;
struct bio_vec bv; struct bio_vec bv;
unsigned long start_time;
if (PageTransHuge(page)) if (PageTransHuge(page))
return -ENOTSUPP; return -ENOTSUPP;
...@@ -1651,7 +1645,9 @@ static int zram_rw_page(struct block_device *bdev, sector_t sector, ...@@ -1651,7 +1645,9 @@ static int zram_rw_page(struct block_device *bdev, sector_t sector,
bv.bv_len = PAGE_SIZE; bv.bv_len = PAGE_SIZE;
bv.bv_offset = 0; bv.bv_offset = 0;
start_time = disk_start_io_acct(bdev->bd_disk, SECTORS_PER_PAGE, op);
ret = zram_bvec_rw(zram, &bv, index, offset, op, NULL); ret = zram_bvec_rw(zram, &bv, index, offset, op, NULL);
disk_end_io_acct(bdev->bd_disk, op, start_time);
out: out:
/* /*
* If I/O fails, just return error(ie, non-zero) without * If I/O fails, just return error(ie, non-zero) without
......
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