aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/backing-dev.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 9008c4e207f6..0b8ee66993dd 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -511,23 +511,16 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
511 const char *fmt, ...) 511 const char *fmt, ...)
512{ 512{
513 va_list args; 513 va_list args;
514 int ret = 0;
515 struct device *dev; 514 struct device *dev;
516 515
517 if (bdi->dev) /* The driver needs to use separate queues per device */ 516 if (bdi->dev) /* The driver needs to use separate queues per device */
518 goto exit; 517 return 0;
519 518
520 va_start(args, fmt); 519 va_start(args, fmt);
521 dev = device_create_vargs(bdi_class, parent, MKDEV(0, 0), bdi, fmt, args); 520 dev = device_create_vargs(bdi_class, parent, MKDEV(0, 0), bdi, fmt, args);
522 va_end(args); 521 va_end(args);
523 if (IS_ERR(dev)) { 522 if (IS_ERR(dev))
524 ret = PTR_ERR(dev); 523 return PTR_ERR(dev);
525 goto exit;
526 }
527
528 spin_lock_bh(&bdi_lock);
529 list_add_tail_rcu(&bdi->bdi_list, &bdi_list);
530 spin_unlock_bh(&bdi_lock);
531 524
532 bdi->dev = dev; 525 bdi->dev = dev;
533 526
@@ -541,20 +534,19 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
541 534
542 wb->task = kthread_run(bdi_forker_thread, wb, "bdi-%s", 535 wb->task = kthread_run(bdi_forker_thread, wb, "bdi-%s",
543 dev_name(dev)); 536 dev_name(dev));
544 if (IS_ERR(wb->task)) { 537 if (IS_ERR(wb->task))
545 wb->task = NULL; 538 return PTR_ERR(wb->task);
546 ret = -ENOMEM;
547
548 bdi_remove_from_list(bdi);
549 goto exit;
550 }
551 } 539 }
552 540
553 bdi_debug_register(bdi, dev_name(dev)); 541 bdi_debug_register(bdi, dev_name(dev));
554 set_bit(BDI_registered, &bdi->state); 542 set_bit(BDI_registered, &bdi->state);
543
544 spin_lock_bh(&bdi_lock);
545 list_add_tail_rcu(&bdi->bdi_list, &bdi_list);
546 spin_unlock_bh(&bdi_lock);
547
555 trace_writeback_bdi_register(bdi); 548 trace_writeback_bdi_register(bdi);
556exit: 549 return 0;
557 return ret;
558} 550}
559EXPORT_SYMBOL(bdi_register); 551EXPORT_SYMBOL(bdi_register);
560 552