aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2015-05-19 01:58:37 -0400
committerJens Axboe <axboe@fb.com>2015-05-28 12:12:42 -0400
commitaad653a0bc09dd4ebcb5579f9f835bbae9ef2ba3 (patch)
treee994719be9179966d4e8ef0862970eeeeb7aa27a
parenta8b253b9f253c05e5e10b829b8d1fb24556f4b56 (diff)
block: discard bdi_unregister() in favour of bdi_destroy()
bdi_unregister() now contains very little functionality. It contains a "WARN_ON" if bdi->dev is NULL. This warning is of no real consequence as bdi->dev isn't needed by anything else in the function, and it triggers if blk_cleanup_queue() -> bdi_destroy() is called before bdi_unregister, which happens since Commit: 6cd18e711dd8 ("block: destroy bdi before blockdev is unregistered.") So this isn't wanted. It also calls bdi_set_min_ratio(). This needs to be called after writes through the bdi have all been flushed, and before the bdi is destroyed. Calling it early is better than calling it late as it frees up a global resource. Calling it immediately after bdi_wb_shutdown() in bdi_destroy() perfectly fits these requirements. So bdi_unregister() can be discarded with the important content moved to bdi_destroy(), as can the writeback_bdi_unregister event which is already not used. Reported-by: Mike Snitzer <snitzer@redhat.com> Cc: stable@vger.kernel.org (v4.0) Fixes: c4db59d31e39 ("fs: don't reassign dirty inodes to default_backing_dev_info") Fixes: 6cd18e711dd8 ("block: destroy bdi before blockdev is unregistered.") Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Dan Williams <dan.j.williams@intel.com> Tested-by: Nicholas Moulin <nicholas.w.moulin@linux.intel.com> Signed-off-by: NeilBrown <neilb@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--block/genhd.c1
-rw-r--r--include/linux/backing-dev.h1
-rw-r--r--include/trace/events/writeback.h1
-rw-r--r--mm/backing-dev.c18
4 files changed, 1 insertions, 20 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 0a536dc05f3b..666e11b83983 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -653,7 +653,6 @@ void del_gendisk(struct gendisk *disk)
653 disk->flags &= ~GENHD_FL_UP; 653 disk->flags &= ~GENHD_FL_UP;
654 654
655 sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi"); 655 sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi");
656 bdi_unregister(&disk->queue->backing_dev_info);
657 blk_unregister_queue(disk); 656 blk_unregister_queue(disk);
658 blk_unregister_region(disk_devt(disk), disk->minors); 657 blk_unregister_region(disk_devt(disk), disk->minors);
659 658
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index aff923ae8c4b..d87d8eced064 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -116,7 +116,6 @@ __printf(3, 4)
116int bdi_register(struct backing_dev_info *bdi, struct device *parent, 116int bdi_register(struct backing_dev_info *bdi, struct device *parent,
117 const char *fmt, ...); 117 const char *fmt, ...);
118int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); 118int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
119void bdi_unregister(struct backing_dev_info *bdi);
120int __must_check bdi_setup_and_register(struct backing_dev_info *, char *); 119int __must_check bdi_setup_and_register(struct backing_dev_info *, char *);
121void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages, 120void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages,
122 enum wb_reason reason); 121 enum wb_reason reason);
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index 880dd7437172..c178d13d6f4c 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -250,7 +250,6 @@ DEFINE_EVENT(writeback_class, name, \
250DEFINE_WRITEBACK_EVENT(writeback_nowork); 250DEFINE_WRITEBACK_EVENT(writeback_nowork);
251DEFINE_WRITEBACK_EVENT(writeback_wake_background); 251DEFINE_WRITEBACK_EVENT(writeback_wake_background);
252DEFINE_WRITEBACK_EVENT(writeback_bdi_register); 252DEFINE_WRITEBACK_EVENT(writeback_bdi_register);
253DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister);
254 253
255DECLARE_EVENT_CLASS(wbc_class, 254DECLARE_EVENT_CLASS(wbc_class,
256 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), 255 TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 6dc4580df2af..000e7b3b9896 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -359,23 +359,6 @@ static void bdi_wb_shutdown(struct backing_dev_info *bdi)
359 flush_delayed_work(&bdi->wb.dwork); 359 flush_delayed_work(&bdi->wb.dwork);
360} 360}
361 361
362/*
363 * Called when the device behind @bdi has been removed or ejected.
364 *
365 * We can't really do much here except for reducing the dirty ratio at
366 * the moment. In the future we should be able to set a flag so that
367 * the filesystem can handle errors at mark_inode_dirty time instead
368 * of only at writeback time.
369 */
370void bdi_unregister(struct backing_dev_info *bdi)
371{
372 if (WARN_ON_ONCE(!bdi->dev))
373 return;
374
375 bdi_set_min_ratio(bdi, 0);
376}
377EXPORT_SYMBOL(bdi_unregister);
378
379static void bdi_wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi) 362static void bdi_wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi)
380{ 363{
381 memset(wb, 0, sizeof(*wb)); 364 memset(wb, 0, sizeof(*wb));
@@ -443,6 +426,7 @@ void bdi_destroy(struct backing_dev_info *bdi)
443 int i; 426 int i;
444 427
445 bdi_wb_shutdown(bdi); 428 bdi_wb_shutdown(bdi);
429 bdi_set_min_ratio(bdi, 0);
446 430
447 WARN_ON(!list_empty(&bdi->work_list)); 431 WARN_ON(!list_empty(&bdi->work_list));
448 WARN_ON(delayed_work_pending(&bdi->wb.dwork)); 432 WARN_ON(delayed_work_pending(&bdi->wb.dwork));