From: Tejun Heo <tj@kernel.org>
To: axboe@kernel.dk
Cc: linux-kernel@vger.kernel.org, jack@suse.cz, hch@infradead.org,
hannes@cmpxchg.org, linux-fsdevel@vger.kernel.org,
vgoyal@redhat.com, lizefan@huawei.com, cgroups@vger.kernel.org,
linux-mm@kvack.org, mhocko@suse.cz, Tejun Heo <tj@kernel.org>,
Wu Fengguang <fengguang.wu@intel.com>
Subject: [PATCH 12/16] writeback: reorganize mm/backing-dev.c
Date: Tue, 6 Jan 2015 14:29:13 -0500 [thread overview]
Message-ID: <1420572557-11572-13-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1420572557-11572-1-git-send-email-tj@kernel.org>
Move wb_shutdown(), bdi_register(), bdi_register_dev(),
bdi_prune_sb(), bdi_remove_from_list() and bdi_unregister() so that
init / exit functions are grouped together. This will make updating
init / exit paths for cgroup writeback support easier.
This is pure source file reorganization.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jan Kara <jack@suse.cz>
Cc: Wu Fengguang <fengguang.wu@intel.com>
---
mm/backing-dev.c | 206 +++++++++++++++++++++++++++----------------------------
1 file changed, 103 insertions(+), 103 deletions(-)
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index dbd321e..a98a957 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -338,109 +338,6 @@ void wb_wakeup_delayed(struct bdi_writeback *wb)
}
/*
- * Remove bdi from bdi_list, and ensure that it is no longer visible
- */
-static void bdi_remove_from_list(struct backing_dev_info *bdi)
-{
- spin_lock_bh(&bdi_lock);
- list_del_rcu(&bdi->bdi_list);
- spin_unlock_bh(&bdi_lock);
-
- synchronize_rcu_expedited();
-}
-
-int bdi_register(struct backing_dev_info *bdi, struct device *parent,
- const char *fmt, ...)
-{
- 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);
-
- bdi->dev = dev;
-
- bdi_debug_register(bdi, dev_name(dev));
- set_bit(WB_registered, &bdi->wb.state);
-
- spin_lock_bh(&bdi_lock);
- list_add_tail_rcu(&bdi->bdi_list, &bdi_list);
- spin_unlock_bh(&bdi_lock);
-
- trace_writeback_bdi_register(bdi);
- return 0;
-}
-EXPORT_SYMBOL(bdi_register);
-
-int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev)
-{
- return bdi_register(bdi, NULL, "%u:%u", MAJOR(dev), MINOR(dev));
-}
-EXPORT_SYMBOL(bdi_register_dev);
-
-/*
- * Remove bdi from the global list and shutdown any threads we have running
- */
-static void wb_shutdown(struct bdi_writeback *wb)
-{
- /* Make sure nobody queues further work */
- spin_lock_bh(&wb->work_lock);
- clear_bit(WB_registered, &wb->state);
- spin_unlock_bh(&wb->work_lock);
-
- /*
- * Drain work list and shutdown the delayed_work. !WB_registered
- * tells wb_workfn() that @wb is dying and its work_list needs to
- * be drained no matter what.
- */
- mod_delayed_work(bdi_wq, &wb->dwork, 0);
- flush_delayed_work(&wb->dwork);
- WARN_ON(!list_empty(&wb->work_list));
- WARN_ON(delayed_work_pending(&wb->dwork));
-}
-
-/*
- * This bdi is going away now, make sure that no super_blocks point to it
- */
-static void bdi_prune_sb(struct backing_dev_info *bdi)
-{
- struct super_block *sb;
-
- spin_lock(&sb_lock);
- list_for_each_entry(sb, &super_blocks, s_list) {
- if (sb->s_bdi == bdi)
- sb->s_bdi = &default_backing_dev_info;
- }
- spin_unlock(&sb_lock);
-}
-
-void bdi_unregister(struct backing_dev_info *bdi)
-{
- if (bdi->dev) {
- bdi_set_min_ratio(bdi, 0);
- trace_writeback_bdi_unregister(bdi);
- bdi_prune_sb(bdi);
-
- if (bdi_cap_writeback_dirty(bdi)) {
- /* make sure nobody finds us on the bdi_list anymore */
- bdi_remove_from_list(bdi);
- wb_shutdown(&bdi->wb);
- }
-
- bdi_debug_unregister(bdi);
- device_unregister(bdi->dev);
- bdi->dev = NULL;
- }
-}
-EXPORT_SYMBOL(bdi_unregister);
-
-/*
* Initial write bandwidth: 100 MB/s
*/
#define INIT_BW (100 << (20 - PAGE_SHIFT))
@@ -485,6 +382,27 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi)
return 0;
}
+/*
+ * Remove bdi from the global list and shutdown any threads we have running
+ */
+static void wb_shutdown(struct bdi_writeback *wb)
+{
+ /* Make sure nobody queues further work */
+ spin_lock_bh(&wb->work_lock);
+ clear_bit(WB_registered, &wb->state);
+ spin_unlock_bh(&wb->work_lock);
+
+ /*
+ * Drain work list and shutdown the delayed_work. !WB_registered
+ * tells wb_workfn() that @wb is dying and its work_list needs to
+ * be drained no matter what.
+ */
+ mod_delayed_work(bdi_wq, &wb->dwork, 0);
+ flush_delayed_work(&wb->dwork);
+ WARN_ON(!list_empty(&wb->work_list));
+ WARN_ON(delayed_work_pending(&wb->dwork));
+}
+
static void wb_exit(struct bdi_writeback *wb)
{
int i;
@@ -540,6 +458,88 @@ int bdi_init(struct backing_dev_info *bdi)
}
EXPORT_SYMBOL(bdi_init);
+int bdi_register(struct backing_dev_info *bdi, struct device *parent,
+ const char *fmt, ...)
+{
+ 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);
+
+ bdi->dev = dev;
+
+ bdi_debug_register(bdi, dev_name(dev));
+ set_bit(WB_registered, &bdi->wb.state);
+
+ spin_lock_bh(&bdi_lock);
+ list_add_tail_rcu(&bdi->bdi_list, &bdi_list);
+ spin_unlock_bh(&bdi_lock);
+
+ trace_writeback_bdi_register(bdi);
+ return 0;
+}
+EXPORT_SYMBOL(bdi_register);
+
+int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev)
+{
+ return bdi_register(bdi, NULL, "%u:%u", MAJOR(dev), MINOR(dev));
+}
+EXPORT_SYMBOL(bdi_register_dev);
+
+/*
+ * This bdi is going away now, make sure that no super_blocks point to it
+ */
+static void bdi_prune_sb(struct backing_dev_info *bdi)
+{
+ struct super_block *sb;
+
+ spin_lock(&sb_lock);
+ list_for_each_entry(sb, &super_blocks, s_list) {
+ if (sb->s_bdi == bdi)
+ sb->s_bdi = &default_backing_dev_info;
+ }
+ spin_unlock(&sb_lock);
+}
+
+/*
+ * Remove bdi from bdi_list, and ensure that it is no longer visible
+ */
+static void bdi_remove_from_list(struct backing_dev_info *bdi)
+{
+ spin_lock_bh(&bdi_lock);
+ list_del_rcu(&bdi->bdi_list);
+ spin_unlock_bh(&bdi_lock);
+
+ synchronize_rcu_expedited();
+}
+
+void bdi_unregister(struct backing_dev_info *bdi)
+{
+ if (bdi->dev) {
+ bdi_set_min_ratio(bdi, 0);
+ trace_writeback_bdi_unregister(bdi);
+ bdi_prune_sb(bdi);
+
+ if (bdi_cap_writeback_dirty(bdi)) {
+ /* make sure nobody finds us on the bdi_list anymore */
+ bdi_remove_from_list(bdi);
+ wb_shutdown(&bdi->wb);
+ }
+
+ bdi_debug_unregister(bdi);
+ device_unregister(bdi->dev);
+ bdi->dev = NULL;
+ }
+}
+EXPORT_SYMBOL(bdi_unregister);
+
void bdi_destroy(struct backing_dev_info *bdi)
{
bdi_unregister(bdi);
--
2.1.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2015-01-06 19:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-06 19:29 [PATCHSET v2 block/for-next] writeback: prepare for cgroup writeback support Tejun Heo
2015-01-06 19:29 ` [PATCH 01/16] blkcg: move block/blk-cgroup.h to include/linux/blk-cgroup.h Tejun Heo
2015-01-06 19:29 ` [PATCH 02/16] update !CONFIG_BLK_CGROUP dummies in include/linux/blk-cgroup.h Tejun Heo
2015-01-06 19:29 ` [PATCH 03/16] blkcg: add blkcg_root_css Tejun Heo
2015-01-06 19:29 ` [PATCH 04/16] cgroup, block: implement task_get_css() and use it in bio_associate_current() Tejun Heo
2015-01-06 19:29 ` [PATCH 05/16] blkcg: implement task_get_blkcg_css() Tejun Heo
2015-01-06 19:29 ` [PATCH 06/16] blkcg: implement bio_associate_blkcg() Tejun Heo
2015-01-06 19:29 ` [PATCH 07/16] writeback: move backing_dev_info->state into bdi_writeback Tejun Heo
2015-01-06 19:29 ` [PATCH 08/16] writeback: move backing_dev_info->bdi_stat[] " Tejun Heo
2015-01-06 19:29 ` [PATCH 09/16] writeback: move bandwidth related fields from backing_dev_info " Tejun Heo
2015-01-06 19:29 ` [PATCH 10/16] writeback: move backing_dev_info->wb_lock and ->worklist " Tejun Heo
2015-01-06 19:29 ` [PATCH 11/16] writeback: move lingering dirty IO lists transfer from bdi_destroy() to wb_exit() Tejun Heo
2015-01-06 19:29 ` Tejun Heo [this message]
2015-01-06 19:29 ` [PATCH 13/16] writeback: separate out include/linux/backing-dev-defs.h Tejun Heo
2015-01-06 19:29 ` [PATCH 14/16] writeback: cosmetic change in account_page_dirtied() Tejun Heo
2015-01-06 19:29 ` [PATCH 15/16] writeback: add @gfp to wb_init() Tejun Heo
2015-01-06 19:29 ` [PATCH 16/16] writeback: move inode_to_bdi() to include/linux/backing-dev.h Tejun Heo
2015-01-07 14:19 ` [PATCHSET v2 block/for-next] writeback: prepare for cgroup writeback support Christoph Hellwig
2015-01-07 15:11 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1420572557-11572-13-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=axboe@kernel.dk \
--cc=cgroups@vger.kernel.org \
--cc=fengguang.wu@intel.com \
--cc=hannes@cmpxchg.org \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan@huawei.com \
--cc=mhocko@suse.cz \
--cc=vgoyal@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).