History

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.

NeilBrown committed 11 years ago

Commit aad653a1 parent a8b253b4 files · +1 −20Browse files

Unified · Split

4 files
  1. block/genhd.c +0 −1
  2. include/linux/backing-dev.h +0 −1
  3. include/trace/events/writeback.h +0 −1
  4. mm/backing-dev.c +1 −17
block/genhd.c+0−1
@@ -653,7 +653,6 @@ void del_gendisk(struct gendisk *disk) · 652 unmodified lines
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
include/linux/backing-dev.h+0−1
@@ -116,7 +116,6 @@ __printf(3, 4) · 115 unmodified lines
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);
include/trace/events/writeback.h+0−1
@@ -250,7 +250,6 @@ DEFINE_EVENT(writeback_class, name, \ · 249 unmodified lines
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),
mm/backing-dev.c+1−17
@@ -359,23 +359,6 @@ static void bdi_wb_shutdown(struct backing_dev_info *bdi) · 358 unmodified lines
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) · 61 unmodified lines
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));

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t