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
653653 disk->flags &= ~GENHD_FL_UP;
654654
655655 sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi");
656− bdi_unregister(&disk->queue->backing_dev_info);
657656 blk_unregister_queue(disk);
658657 blk_unregister_region(disk_devt(disk), disk->minors);
659658
include/linux/backing-dev.h+0−1
@@ -116,7 +116,6 @@ __printf(3, 4) · 115 unmodified lines
116116 int bdi_register(struct backing_dev_info *bdi, struct device *parent,
117117 const char *fmt, ...);
118118 int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
119−void bdi_unregister(struct backing_dev_info *bdi);
120119 int __must_check bdi_setup_and_register(struct backing_dev_info *, char *);
121120 void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages,
122121 enum wb_reason reason);
include/trace/events/writeback.h+0−1
@@ -250,7 +250,6 @@ DEFINE_EVENT(writeback_class, name, \ · 249 unmodified lines
250250 DEFINE_WRITEBACK_EVENT(writeback_nowork);
251251 DEFINE_WRITEBACK_EVENT(writeback_wake_background);
252252 DEFINE_WRITEBACK_EVENT(writeback_bdi_register);
253−DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister);
254253
255254 DECLARE_EVENT_CLASS(wbc_class,
256255 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
359359 flush_delayed_work(&bdi->wb.dwork);
360360 }
361361
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− */
370−void 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−}
377−EXPORT_SYMBOL(bdi_unregister);
378−
379362 static void bdi_wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi)
380363 {
381364 memset(wb, 0, sizeof(*wb));
@@ -443,6 +426,7 @@ void bdi_destroy(struct backing_dev_info *bdi) · 61 unmodified lines
443426 int i;
444427
445428 bdi_wb_shutdown(bdi);
429+ bdi_set_min_ratio(bdi, 0);
446430
447431 WARN_ON(!list_empty(&bdi->work_list));
448432 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