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

bdi: remove BDI_CAP_SYNCHRONOUS_IO

BDI_CAP_SYNCHRONOUS_IO is only checked in the swap code, and used to
decided if ->rw_page can be used on a block device.  Just check up for
the method instead.  The only complication is that zram needs a second
set of block_device_operations as it can switch between modes that
actually support ->rw_page and those who don't.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent ed7b6b4f
...@@ -403,7 +403,6 @@ static struct brd_device *brd_alloc(int i) ...@@ -403,7 +403,6 @@ static struct brd_device *brd_alloc(int i)
disk->flags = GENHD_FL_EXT_DEVT; disk->flags = GENHD_FL_EXT_DEVT;
sprintf(disk->disk_name, "ram%d", i); sprintf(disk->disk_name, "ram%d", i);
set_capacity(disk, rd_size * 2); set_capacity(disk, rd_size * 2);
brd->brd_queue->backing_dev_info->capabilities |= BDI_CAP_SYNCHRONOUS_IO;
/* Tell the block layer that this is not a rotational device */ /* Tell the block layer that this is not a rotational device */
blk_queue_flag_set(QUEUE_FLAG_NONROT, brd->brd_queue); blk_queue_flag_set(QUEUE_FLAG_NONROT, brd->brd_queue);
......
...@@ -52,6 +52,9 @@ static unsigned int num_devices = 1; ...@@ -52,6 +52,9 @@ static unsigned int num_devices = 1;
*/ */
static size_t huge_class_size; static size_t huge_class_size;
static const struct block_device_operations zram_devops;
static const struct block_device_operations zram_wb_devops;
static void zram_free_page(struct zram *zram, size_t index); static void zram_free_page(struct zram *zram, size_t index);
static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec, static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
u32 index, int offset, struct bio *bio); u32 index, int offset, struct bio *bio);
...@@ -408,8 +411,7 @@ static void reset_bdev(struct zram *zram) ...@@ -408,8 +411,7 @@ static void reset_bdev(struct zram *zram)
zram->backing_dev = NULL; zram->backing_dev = NULL;
zram->old_block_size = 0; zram->old_block_size = 0;
zram->bdev = NULL; zram->bdev = NULL;
zram->disk->queue->backing_dev_info->capabilities |= zram->disk->fops = &zram_devops;
BDI_CAP_SYNCHRONOUS_IO;
kvfree(zram->bitmap); kvfree(zram->bitmap);
zram->bitmap = NULL; zram->bitmap = NULL;
} }
...@@ -529,8 +531,7 @@ static ssize_t backing_dev_store(struct device *dev, ...@@ -529,8 +531,7 @@ static ssize_t backing_dev_store(struct device *dev,
* freely but in fact, IO is going on so finally could cause * freely but in fact, IO is going on so finally could cause
* use-after-free when the IO is really done. * use-after-free when the IO is really done.
*/ */
zram->disk->queue->backing_dev_info->capabilities &= zram->disk->fops = &zram_wb_devops;
~BDI_CAP_SYNCHRONOUS_IO;
up_write(&zram->init_lock); up_write(&zram->init_lock);
pr_info("setup backing device %s\n", file_name); pr_info("setup backing device %s\n", file_name);
...@@ -1820,6 +1821,13 @@ static const struct block_device_operations zram_devops = { ...@@ -1820,6 +1821,13 @@ static const struct block_device_operations zram_devops = {
.owner = THIS_MODULE .owner = THIS_MODULE
}; };
static const struct block_device_operations zram_wb_devops = {
.open = zram_open,
.submit_bio = zram_submit_bio,
.swap_slot_free_notify = zram_slot_free_notify,
.owner = THIS_MODULE
};
static DEVICE_ATTR_WO(compact); static DEVICE_ATTR_WO(compact);
static DEVICE_ATTR_RW(disksize); static DEVICE_ATTR_RW(disksize);
static DEVICE_ATTR_RO(initstate); static DEVICE_ATTR_RO(initstate);
...@@ -1947,8 +1955,7 @@ static int zram_add(void) ...@@ -1947,8 +1955,7 @@ static int zram_add(void)
if (ZRAM_LOGICAL_BLOCK_SIZE == PAGE_SIZE) if (ZRAM_LOGICAL_BLOCK_SIZE == PAGE_SIZE)
blk_queue_max_write_zeroes_sectors(zram->disk->queue, UINT_MAX); blk_queue_max_write_zeroes_sectors(zram->disk->queue, UINT_MAX);
zram->disk->queue->backing_dev_info->capabilities |= zram->disk->queue->backing_dev_info->capabilities |= BDI_CAP_STABLE_WRITES;
(BDI_CAP_STABLE_WRITES | BDI_CAP_SYNCHRONOUS_IO);
device_add_disk(NULL, zram->disk, zram_disk_attr_groups); device_add_disk(NULL, zram->disk, zram_disk_attr_groups);
strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor)); strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor));
......
...@@ -1537,8 +1537,6 @@ static int btt_blk_init(struct btt *btt) ...@@ -1537,8 +1537,6 @@ static int btt_blk_init(struct btt *btt)
btt->btt_disk->private_data = btt; btt->btt_disk->private_data = btt;
btt->btt_disk->queue = btt->btt_queue; btt->btt_disk->queue = btt->btt_queue;
btt->btt_disk->flags = GENHD_FL_EXT_DEVT; btt->btt_disk->flags = GENHD_FL_EXT_DEVT;
btt->btt_disk->queue->backing_dev_info->capabilities |=
BDI_CAP_SYNCHRONOUS_IO;
blk_queue_logical_block_size(btt->btt_queue, btt->sector_size); blk_queue_logical_block_size(btt->btt_queue, btt->sector_size);
blk_queue_max_hw_sectors(btt->btt_queue, UINT_MAX); blk_queue_max_hw_sectors(btt->btt_queue, UINT_MAX);
......
...@@ -475,7 +475,6 @@ static int pmem_attach_disk(struct device *dev, ...@@ -475,7 +475,6 @@ static int pmem_attach_disk(struct device *dev,
disk->queue = q; disk->queue = q;
disk->flags = GENHD_FL_EXT_DEVT; disk->flags = GENHD_FL_EXT_DEVT;
disk->private_data = pmem; disk->private_data = pmem;
disk->queue->backing_dev_info->capabilities |= BDI_CAP_SYNCHRONOUS_IO;
nvdimm_namespace_disk_name(ndns, disk->disk_name); nvdimm_namespace_disk_name(ndns, disk->disk_name);
set_capacity(disk, (pmem->size - pmem->pfn_pad - pmem->data_offset) set_capacity(disk, (pmem->size - pmem->pfn_pad - pmem->data_offset)
/ 512); / 512);
......
...@@ -122,9 +122,6 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); ...@@ -122,9 +122,6 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
* BDI_CAP_NO_WRITEBACK: Don't write pages back * BDI_CAP_NO_WRITEBACK: Don't write pages back
* BDI_CAP_NO_ACCT_WB: Don't automatically account writeback pages * BDI_CAP_NO_ACCT_WB: Don't automatically account writeback pages
* BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold. * BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold.
*
* BDI_CAP_SYNCHRONOUS_IO: Device is so fast that asynchronous IO would be
* inefficient.
*/ */
#define BDI_CAP_NO_ACCT_DIRTY 0x00000001 #define BDI_CAP_NO_ACCT_DIRTY 0x00000001
#define BDI_CAP_NO_WRITEBACK 0x00000002 #define BDI_CAP_NO_WRITEBACK 0x00000002
...@@ -132,7 +129,6 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); ...@@ -132,7 +129,6 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
#define BDI_CAP_STABLE_WRITES 0x00000008 #define BDI_CAP_STABLE_WRITES 0x00000008
#define BDI_CAP_STRICTLIMIT 0x00000010 #define BDI_CAP_STRICTLIMIT 0x00000010
#define BDI_CAP_CGROUP_WRITEBACK 0x00000020 #define BDI_CAP_CGROUP_WRITEBACK 0x00000020
#define BDI_CAP_SYNCHRONOUS_IO 0x00000040
#define BDI_CAP_NO_ACCT_AND_WRITEBACK \ #define BDI_CAP_NO_ACCT_AND_WRITEBACK \
(BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB) (BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB)
...@@ -174,11 +170,6 @@ static inline int wb_congested(struct bdi_writeback *wb, int cong_bits) ...@@ -174,11 +170,6 @@ static inline int wb_congested(struct bdi_writeback *wb, int cong_bits)
long congestion_wait(int sync, long timeout); long congestion_wait(int sync, long timeout);
long wait_iff_congested(int sync, long timeout); long wait_iff_congested(int sync, long timeout);
static inline bool bdi_cap_synchronous_io(struct backing_dev_info *bdi)
{
return bdi->capabilities & BDI_CAP_SYNCHRONOUS_IO;
}
static inline bool bdi_cap_stable_pages_required(struct backing_dev_info *bdi) static inline bool bdi_cap_stable_pages_required(struct backing_dev_info *bdi)
{ {
return bdi->capabilities & BDI_CAP_STABLE_WRITES; return bdi->capabilities & BDI_CAP_STABLE_WRITES;
......
...@@ -3240,7 +3240,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) ...@@ -3240,7 +3240,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
if (bdi_cap_stable_pages_required(inode_to_bdi(inode))) if (bdi_cap_stable_pages_required(inode_to_bdi(inode)))
p->flags |= SWP_STABLE_WRITES; p->flags |= SWP_STABLE_WRITES;
if (bdi_cap_synchronous_io(inode_to_bdi(inode))) if (p->bdev && p->bdev->bd_disk->fops->rw_page)
p->flags |= SWP_SYNCHRONOUS_IO; p->flags |= SWP_SYNCHRONOUS_IO;
if (p->bdev && blk_queue_nonrot(bdev_get_queue(p->bdev))) { if (p->bdev && blk_queue_nonrot(bdev_get_queue(p->bdev))) {
......
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