aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dax/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/dax/super.c')
-rw-r--r--drivers/dax/super.c41
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
26static dev_t dax_devt; 27static dev_t dax_devt;
27DEFINE_STATIC_SRCU(dax_srcu); 28DEFINE_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}
389EXPORT_SYMBOL_GPL(kill_dax); 388EXPORT_SYMBOL_GPL(kill_dax);
390 389
390void run_dax(struct dax_device *dax_dev)
391{
392 set_bit(DAXDEV_ALIVE, &dax_dev->flags);
393}
394EXPORT_SYMBOL_GPL(run_dax);
395
391static struct inode *dax_alloc_inode(struct super_block *sb) 396static 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
603void *dax_get_private(struct dax_device *dax_dev) 608void *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}
607EXPORT_SYMBOL_GPL(dax_get_private); 614EXPORT_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
618static int __dax_fs_init(void) 625static 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
650static void __dax_fs_exit(void) 657static 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
657static int __init dax_fs_init(void) 664static 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
681err_bus:
682 unregister_chrdev_region(dax_devt, MINORMASK+1);
683err_chrdev:
684 dax_fs_exit();
685 return 0;
669} 686}
670 687
671static void __exit dax_fs_exit(void) 688static 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
678MODULE_AUTHOR("Intel Corporation"); 695MODULE_AUTHOR("Intel Corporation");
679MODULE_LICENSE("GPL v2"); 696MODULE_LICENSE("GPL v2");
680subsys_initcall(dax_fs_init); 697subsys_initcall(dax_core_init);
681module_exit(dax_fs_exit); 698module_exit(dax_core_exit);