Skip to content

Commit

Permalink
zram: use set_capacity_and_notify
Browse files Browse the repository at this point in the history
Use set_capacity_and_notify to set the size of both the disk and block
device.  This also gets the uevent notifications for the resize for free.

Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Nov 16, 2020
1 parent 230272b commit 6e017a3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/block/zram/zram_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ static void zram_reset_device(struct zram *zram)
disksize = zram->disksize;
zram->disksize = 0;

set_capacity(zram->disk, 0);
set_capacity_and_notify(zram->disk, 0);
part_stat_set_all(&zram->disk->part0, 0);

up_write(&zram->init_lock);
Expand Down Expand Up @@ -1741,9 +1741,7 @@ static ssize_t disksize_store(struct device *dev,

zram->comp = comp;
zram->disksize = disksize;
set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);

revalidate_disk_size(zram->disk, true);
set_capacity_and_notify(zram->disk, zram->disksize >> SECTOR_SHIFT);
up_write(&zram->init_lock);

return len;
Expand Down Expand Up @@ -1790,7 +1788,6 @@ static ssize_t reset_store(struct device *dev,
/* Make sure all the pending I/O are finished */
fsync_bdev(bdev);
zram_reset_device(zram);
revalidate_disk_size(zram->disk, true);
bdput(bdev);

mutex_lock(&bdev->bd_mutex);
Expand Down

0 comments on commit 6e017a3

Please sign in to comment.