aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2010-04-22 05:37:01 -0400
committerJens Axboe <jens.axboe@oracle.com>2010-04-22 05:39:36 -0400
commitc3c532061e46156e8aab1268f38d66cfb63aeb2d (patch)
tree8c5b027873b823b04f5564d442477e80e82e8edb /mm
parenta534dbe96e9929c7245924d8252d89048c23d569 (diff)
bdi: add helper function for doing init and register of a bdi for a file system
Pretty trivial helper, just sets up the bdi and registers it. An atomic sequence count is used to ensure that the registered sysfs names are unique. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'mm')
-rw-r--r--mm/backing-dev.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index f13e067e146..dbda4707f59 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -11,6 +11,8 @@
11#include <linux/writeback.h> 11#include <linux/writeback.h>
12#include <linux/device.h> 12#include <linux/device.h>
13 13
14static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
15
14void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page) 16void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
15{ 17{
16} 18}
@@ -715,6 +717,33 @@ void bdi_destroy(struct backing_dev_info *bdi)
715} 717}
716EXPORT_SYMBOL(bdi_destroy); 718EXPORT_SYMBOL(bdi_destroy);
717 719
720/*
721 * For use from filesystems to quickly init and register a bdi associated
722 * with dirty writeback
723 */
724int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
725 unsigned int cap)
726{
727 char tmp[32];
728 int err;
729
730 bdi->name = name;
731 bdi->capabilities = cap;
732 err = bdi_init(bdi);
733 if (err)
734 return err;
735
736 sprintf(tmp, "%.28s%s", name, "-%d");
737 err = bdi_register(bdi, NULL, tmp, atomic_long_inc_return(&bdi_seq));
738 if (err) {
739 bdi_destroy(bdi);
740 return err;
741 }
742
743 return 0;
744}
745EXPORT_SYMBOL(bdi_setup_and_register);
746
718static wait_queue_head_t congestion_wqh[2] = { 747static wait_queue_head_t congestion_wqh[2] = {
719 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[0]), 748 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[0]),
720 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1]) 749 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1])