aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/backing-dev.h1
-rw-r--r--mm/backing-dev.c29
2 files changed, 30 insertions, 0 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index fcbc26af00e4..e19c677f219c 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -101,6 +101,7 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
101 const char *fmt, ...); 101 const char *fmt, ...);
102int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); 102int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
103void bdi_unregister(struct backing_dev_info *bdi); 103void bdi_unregister(struct backing_dev_info *bdi);
104int bdi_setup_and_register(struct backing_dev_info *, char *, unsigned int);
104void bdi_start_writeback(struct backing_dev_info *bdi, struct super_block *sb, 105void bdi_start_writeback(struct backing_dev_info *bdi, struct super_block *sb,
105 long nr_pages); 106 long nr_pages);
106int bdi_writeback_task(struct bdi_writeback *wb); 107int bdi_writeback_task(struct bdi_writeback *wb);
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index f13e067e1467..dbda4707f593 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])