diff options
Diffstat (limited to 'drivers/dax/super.c')
-rw-r--r-- | drivers/dax/super.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 0cb8c30ea278..0a339b85133e 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/uio.h> | 22 | #include <linux/uio.h> |
23 | #include <linux/dax.h> | 23 | #include <linux/dax.h> |
24 | #include <linux/fs.h> | 24 | #include <linux/fs.h> |
25 | #include "dax-private.h" | ||
25 | 26 | ||
26 | static dev_t dax_devt; | 27 | static dev_t dax_devt; |
27 | DEFINE_STATIC_SRCU(dax_srcu); | 28 | DEFINE_STATIC_SRCU(dax_srcu); |
@@ -383,11 +384,15 @@ void kill_dax(struct dax_device *dax_dev) | |||
383 | spin_lock(&dax_host_lock); | 384 | spin_lock(&dax_host_lock); |
384 | hlist_del_init(&dax_dev->list); | 385 | hlist_del_init(&dax_dev->list); |
385 | spin_unlock(&dax_host_lock); | 386 | spin_unlock(&dax_host_lock); |
386 | |||
387 | dax_dev->private = NULL; | ||
388 | } | 387 | } |
389 | EXPORT_SYMBOL_GPL(kill_dax); | 388 | EXPORT_SYMBOL_GPL(kill_dax); |
390 | 389 | ||
390 | void run_dax(struct dax_device *dax_dev) | ||
391 | { | ||
392 | set_bit(DAXDEV_ALIVE, &dax_dev->flags); | ||
393 | } | ||
394 | EXPORT_SYMBOL_GPL(run_dax); | ||
395 | |||
391 | static struct inode *dax_alloc_inode(struct super_block *sb) | 396 | static struct inode *dax_alloc_inode(struct super_block *sb) |
392 | { | 397 | { |
393 | struct dax_device *dax_dev; | 398 | struct dax_device *dax_dev; |
@@ -602,6 +607,8 @@ EXPORT_SYMBOL_GPL(dax_inode); | |||
602 | 607 | ||
603 | void *dax_get_private(struct dax_device *dax_dev) | 608 | void *dax_get_private(struct dax_device *dax_dev) |
604 | { | 609 | { |
610 | if (!test_bit(DAXDEV_ALIVE, &dax_dev->flags)) | ||
611 | return NULL; | ||
605 | return dax_dev->private; | 612 | return dax_dev->private; |
606 | } | 613 | } |
607 | EXPORT_SYMBOL_GPL(dax_get_private); | 614 | EXPORT_SYMBOL_GPL(dax_get_private); |
@@ -615,7 +622,7 @@ static void init_once(void *_dax_dev) | |||
615 | inode_init_once(inode); | 622 | inode_init_once(inode); |
616 | } | 623 | } |
617 | 624 | ||
618 | static int __dax_fs_init(void) | 625 | static int dax_fs_init(void) |
619 | { | 626 | { |
620 | int rc; | 627 | int rc; |
621 | 628 | ||
@@ -647,35 +654,45 @@ static int __dax_fs_init(void) | |||
647 | return rc; | 654 | return rc; |
648 | } | 655 | } |
649 | 656 | ||
650 | static void __dax_fs_exit(void) | 657 | static void dax_fs_exit(void) |
651 | { | 658 | { |
652 | kern_unmount(dax_mnt); | 659 | kern_unmount(dax_mnt); |
653 | unregister_filesystem(&dax_fs_type); | 660 | unregister_filesystem(&dax_fs_type); |
654 | kmem_cache_destroy(dax_cache); | 661 | kmem_cache_destroy(dax_cache); |
655 | } | 662 | } |
656 | 663 | ||
657 | static int __init dax_fs_init(void) | 664 | static int __init dax_core_init(void) |
658 | { | 665 | { |
659 | int rc; | 666 | int rc; |
660 | 667 | ||
661 | rc = __dax_fs_init(); | 668 | rc = dax_fs_init(); |
662 | if (rc) | 669 | if (rc) |
663 | return rc; | 670 | return rc; |
664 | 671 | ||
665 | rc = alloc_chrdev_region(&dax_devt, 0, MINORMASK+1, "dax"); | 672 | rc = alloc_chrdev_region(&dax_devt, 0, MINORMASK+1, "dax"); |
666 | if (rc) | 673 | if (rc) |
667 | __dax_fs_exit(); | 674 | goto err_chrdev; |
668 | return rc; | 675 | |
676 | rc = dax_bus_init(); | ||
677 | if (rc) | ||
678 | goto err_bus; | ||
679 | return 0; | ||
680 | |||
681 | err_bus: | ||
682 | unregister_chrdev_region(dax_devt, MINORMASK+1); | ||
683 | err_chrdev: | ||
684 | dax_fs_exit(); | ||
685 | return 0; | ||
669 | } | 686 | } |
670 | 687 | ||
671 | static void __exit dax_fs_exit(void) | 688 | static void __exit dax_core_exit(void) |
672 | { | 689 | { |
673 | unregister_chrdev_region(dax_devt, MINORMASK+1); | 690 | unregister_chrdev_region(dax_devt, MINORMASK+1); |
674 | ida_destroy(&dax_minor_ida); | 691 | ida_destroy(&dax_minor_ida); |
675 | __dax_fs_exit(); | 692 | dax_fs_exit(); |
676 | } | 693 | } |
677 | 694 | ||
678 | MODULE_AUTHOR("Intel Corporation"); | 695 | MODULE_AUTHOR("Intel Corporation"); |
679 | MODULE_LICENSE("GPL v2"); | 696 | MODULE_LICENSE("GPL v2"); |
680 | subsys_initcall(dax_fs_init); | 697 | subsys_initcall(dax_core_init); |
681 | module_exit(dax_fs_exit); | 698 | module_exit(dax_core_exit); |