Skip to content

Commit

Permalink
bdi: Provide bdi_register_va() and bdi_alloc()
Browse files Browse the repository at this point in the history
Add function that registers bdi and takes va_list instead of variable
number of arguments.

Add bdi_alloc() as simple wrapper for NUMA-unaware users allocating BDI.

Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
jankara authored and axboe committed Apr 20, 2017
1 parent 2bc19cd commit baf7a61
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
6 changes: 6 additions & 0 deletions include/linux/backing-dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@ void bdi_put(struct backing_dev_info *bdi);
__printf(3, 4)
int bdi_register(struct backing_dev_info *bdi, struct device *parent,
const char *fmt, ...);
int bdi_register_va(struct backing_dev_info *bdi, struct device *parent,
const char *fmt, va_list args);
int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
int bdi_register_owner(struct backing_dev_info *bdi, struct device *owner);
void bdi_unregister(struct backing_dev_info *bdi);

int __must_check bdi_setup_and_register(struct backing_dev_info *, char *);
void bdi_destroy(struct backing_dev_info *bdi);
struct backing_dev_info *bdi_alloc_node(gfp_t gfp_mask, int node_id);
static inline struct backing_dev_info *bdi_alloc(gfp_t gfp_mask)
{
return bdi_alloc_node(gfp_mask, NUMA_NO_NODE);
}

void wb_start_writeback(struct bdi_writeback *wb, long nr_pages,
bool range_cyclic, enum wb_reason reason);
Expand Down
20 changes: 15 additions & 5 deletions mm/backing-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,18 +856,15 @@ struct backing_dev_info *bdi_alloc_node(gfp_t gfp_mask, int node_id)
return bdi;
}

int bdi_register(struct backing_dev_info *bdi, struct device *parent,
const char *fmt, ...)
int bdi_register_va(struct backing_dev_info *bdi, struct device *parent,
const char *fmt, va_list args)
{
va_list args;
struct device *dev;

if (bdi->dev) /* The driver needs to use separate queues per device */
return 0;

va_start(args, fmt);
dev = device_create_vargs(bdi_class, parent, MKDEV(0, 0), bdi, fmt, args);
va_end(args);
if (IS_ERR(dev))
return PTR_ERR(dev);

Expand All @@ -884,6 +881,19 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
trace_writeback_bdi_register(bdi);
return 0;
}
EXPORT_SYMBOL(bdi_register_va);

int bdi_register(struct backing_dev_info *bdi, struct device *parent,
const char *fmt, ...)
{
va_list args;
int ret;

va_start(args, fmt);
ret = bdi_register_va(bdi, parent, fmt, args);
va_end(args);
return ret;
}
EXPORT_SYMBOL(bdi_register);

int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev)
Expand Down

0 comments on commit baf7a61

Please sign in to comment.