Skip to content

Commit 23c47d2

Browse files
minchanktorvalds
authored andcommitted
bdi: introduce BDI_CAP_SYNCHRONOUS_IO
As discussed at https://lkml.kernel.org/r/<[email protected]> someday we will remove rw_page(). If so, we need something to detect such super-fast storage on which synchronous IO operations like the current rw_page are always a win. Introduces BDI_CAP_SYNCHRONOUS_IO to indicate such devices. With it, we could use various optimization techniques. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Minchan Kim <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Dan Williams <[email protected]> Cc: Ross Zwisler <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Ilya Dryomov <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: Huang Ying <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent e447a01 commit 23c47d2

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed

drivers/block/brd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/radix-tree.h>
2121
#include <linux/fs.h>
2222
#include <linux/slab.h>
23+
#include <linux/backing-dev.h>
2324
#ifdef CONFIG_BLK_DEV_RAM_DAX
2425
#include <linux/pfn_t.h>
2526
#include <linux/dax.h>
@@ -448,6 +449,7 @@ static struct brd_device *brd_alloc(int i)
448449
disk->flags = GENHD_FL_EXT_DEVT;
449450
sprintf(disk->disk_name, "ram%d", i);
450451
set_capacity(disk, rd_size * 2);
452+
disk->queue->backing_dev_info->capabilities |= BDI_CAP_SYNCHRONOUS_IO;
451453

452454
#ifdef CONFIG_BLK_DEV_RAM_DAX
453455
queue_flag_set_unlocked(QUEUE_FLAG_DAX, brd->brd_queue);

drivers/block/zram/zram_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ static int zram_add(void)
15581558
blk_queue_max_write_zeroes_sectors(zram->disk->queue, UINT_MAX);
15591559

15601560
zram->disk->queue->backing_dev_info->capabilities |=
1561-
BDI_CAP_STABLE_WRITES;
1561+
(BDI_CAP_STABLE_WRITES | BDI_CAP_SYNCHRONOUS_IO);
15621562
add_disk(zram->disk);
15631563

15641564
ret = sysfs_create_group(&disk_to_dev(zram->disk)->kobj,

drivers/nvdimm/btt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/ndctl.h>
2424
#include <linux/fs.h>
2525
#include <linux/nd.h>
26+
#include <linux/backing-dev.h>
2627
#include "btt.h"
2728
#include "nd.h"
2829

@@ -1402,6 +1403,8 @@ static int btt_blk_init(struct btt *btt)
14021403
btt->btt_disk->private_data = btt;
14031404
btt->btt_disk->queue = btt->btt_queue;
14041405
btt->btt_disk->flags = GENHD_FL_EXT_DEVT;
1406+
btt->btt_disk->queue->backing_dev_info->capabilities |=
1407+
BDI_CAP_SYNCHRONOUS_IO;
14051408

14061409
blk_queue_make_request(btt->btt_queue, btt_make_request);
14071410
blk_queue_logical_block_size(btt->btt_queue, btt->sector_size);

drivers/nvdimm/pmem.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/uio.h>
3232
#include <linux/dax.h>
3333
#include <linux/nd.h>
34+
#include <linux/backing-dev.h>
3435
#include "pmem.h"
3536
#include "pfn.h"
3637
#include "nd.h"
@@ -394,6 +395,7 @@ static int pmem_attach_disk(struct device *dev,
394395
disk->fops = &pmem_fops;
395396
disk->queue = q;
396397
disk->flags = GENHD_FL_EXT_DEVT;
398+
disk->queue->backing_dev_info->capabilities |= BDI_CAP_SYNCHRONOUS_IO;
397399
nvdimm_namespace_disk_name(ndns, disk->disk_name);
398400
set_capacity(disk, (pmem->size - pmem->pfn_pad - pmem->data_offset)
399401
/ 512);

include/linux/backing-dev.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,16 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
122122
* BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold.
123123
*
124124
* BDI_CAP_CGROUP_WRITEBACK: Supports cgroup-aware writeback.
125+
* BDI_CAP_SYNCHRONOUS_IO: Device is so fast that asynchronous IO would be
126+
* inefficient.
125127
*/
126128
#define BDI_CAP_NO_ACCT_DIRTY 0x00000001
127129
#define BDI_CAP_NO_WRITEBACK 0x00000002
128130
#define BDI_CAP_NO_ACCT_WB 0x00000004
129131
#define BDI_CAP_STABLE_WRITES 0x00000008
130132
#define BDI_CAP_STRICTLIMIT 0x00000010
131133
#define BDI_CAP_CGROUP_WRITEBACK 0x00000020
134+
#define BDI_CAP_SYNCHRONOUS_IO 0x00000040
132135

133136
#define BDI_CAP_NO_ACCT_AND_WRITEBACK \
134137
(BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB)
@@ -174,6 +177,11 @@ static inline int wb_congested(struct bdi_writeback *wb, int cong_bits)
174177
long congestion_wait(int sync, long timeout);
175178
long wait_iff_congested(struct pglist_data *pgdat, int sync, long timeout);
176179

180+
static inline bool bdi_cap_synchronous_io(struct backing_dev_info *bdi)
181+
{
182+
return bdi->capabilities & BDI_CAP_SYNCHRONOUS_IO;
183+
}
184+
177185
static inline bool bdi_cap_stable_pages_required(struct backing_dev_info *bdi)
178186
{
179187
return bdi->capabilities & BDI_CAP_STABLE_WRITES;

0 commit comments

Comments
 (0)