diff options
Diffstat (limited to 'mm/backing-dev.c')
-rw-r--r-- | mm/backing-dev.c | 29 |
1 files changed, 29 insertions, 0 deletions
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 | ||
14 | static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0); | ||
15 | |||
14 | void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page) | 16 | void 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 | } |
716 | EXPORT_SYMBOL(bdi_destroy); | 718 | EXPORT_SYMBOL(bdi_destroy); |
717 | 719 | ||
720 | /* | ||
721 | * For use from filesystems to quickly init and register a bdi associated | ||
722 | * with dirty writeback | ||
723 | */ | ||
724 | int 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 | } | ||
745 | EXPORT_SYMBOL(bdi_setup_and_register); | ||
746 | |||
718 | static wait_queue_head_t congestion_wqh[2] = { | 747 | static 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]) |