Commit 31edeacd authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

zram: implement REQ_OP_WRITE_ZEROES

Just the same as discard if the block size equals the system page size.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent e850fd16
...@@ -829,10 +829,14 @@ static void __zram_make_request(struct zram *zram, struct bio *bio) ...@@ -829,10 +829,14 @@ static void __zram_make_request(struct zram *zram, struct bio *bio)
offset = (bio->bi_iter.bi_sector & offset = (bio->bi_iter.bi_sector &
(SECTORS_PER_PAGE - 1)) << SECTOR_SHIFT; (SECTORS_PER_PAGE - 1)) << SECTOR_SHIFT;
if (unlikely(bio_op(bio) == REQ_OP_DISCARD)) { switch (bio_op(bio)) {
case REQ_OP_DISCARD:
case REQ_OP_WRITE_ZEROES:
zram_bio_discard(zram, index, offset, bio); zram_bio_discard(zram, index, offset, bio);
bio_endio(bio); bio_endio(bio);
return; return;
default:
break;
} }
bio_for_each_segment(bvec, bio, iter) { bio_for_each_segment(bvec, bio, iter) {
...@@ -1192,6 +1196,8 @@ static int zram_add(void) ...@@ -1192,6 +1196,8 @@ static int zram_add(void)
zram->disk->queue->limits.max_sectors = SECTORS_PER_PAGE; zram->disk->queue->limits.max_sectors = SECTORS_PER_PAGE;
zram->disk->queue->limits.chunk_sectors = 0; zram->disk->queue->limits.chunk_sectors = 0;
blk_queue_max_discard_sectors(zram->disk->queue, UINT_MAX); blk_queue_max_discard_sectors(zram->disk->queue, UINT_MAX);
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, zram->disk->queue);
/* /*
* zram_bio_discard() will clear all logical blocks if logical block * zram_bio_discard() will clear all logical blocks if logical block
* size is identical with physical block size(PAGE_SIZE). But if it is * size is identical with physical block size(PAGE_SIZE). But if it is
...@@ -1201,10 +1207,7 @@ static int zram_add(void) ...@@ -1201,10 +1207,7 @@ static int zram_add(void)
* zeroed. * zeroed.
*/ */
if (ZRAM_LOGICAL_BLOCK_SIZE == PAGE_SIZE) if (ZRAM_LOGICAL_BLOCK_SIZE == PAGE_SIZE)
zram->disk->queue->limits.discard_zeroes_data = 1; blk_queue_max_write_zeroes_sectors(zram->disk->queue, UINT_MAX);
else
zram->disk->queue->limits.discard_zeroes_data = 0;
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, zram->disk->queue);
add_disk(zram->disk); add_disk(zram->disk);
......
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