aboutsummaryrefslogtreecommitdiffstats
path: root/fs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/super.c')
-rw-r--r--fs/super.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/fs/super.c b/fs/super.c
index 0d77ac20d03e..400a7608f15e 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -682,7 +682,7 @@ void emergency_remount(void)
682 * filesystems which don't use real block-devices. -- jrs 682 * filesystems which don't use real block-devices. -- jrs
683 */ 683 */
684 684
685static struct idr unnamed_dev_idr; 685static DEFINE_IDA(unnamed_dev_ida);
686static DEFINE_SPINLOCK(unnamed_dev_lock);/* protects the above */ 686static DEFINE_SPINLOCK(unnamed_dev_lock);/* protects the above */
687 687
688int set_anon_super(struct super_block *s, void *data) 688int set_anon_super(struct super_block *s, void *data)
@@ -691,10 +691,10 @@ int set_anon_super(struct super_block *s, void *data)
691 int error; 691 int error;
692 692
693 retry: 693 retry:
694 if (idr_pre_get(&unnamed_dev_idr, GFP_ATOMIC) == 0) 694 if (ida_pre_get(&unnamed_dev_ida, GFP_ATOMIC) == 0)
695 return -ENOMEM; 695 return -ENOMEM;
696 spin_lock(&unnamed_dev_lock); 696 spin_lock(&unnamed_dev_lock);
697 error = idr_get_new(&unnamed_dev_idr, NULL, &dev); 697 error = ida_get_new(&unnamed_dev_ida, &dev);
698 spin_unlock(&unnamed_dev_lock); 698 spin_unlock(&unnamed_dev_lock);
699 if (error == -EAGAIN) 699 if (error == -EAGAIN)
700 /* We raced and lost with another CPU. */ 700 /* We raced and lost with another CPU. */
@@ -704,7 +704,7 @@ int set_anon_super(struct super_block *s, void *data)
704 704
705 if ((dev & MAX_ID_MASK) == (1 << MINORBITS)) { 705 if ((dev & MAX_ID_MASK) == (1 << MINORBITS)) {
706 spin_lock(&unnamed_dev_lock); 706 spin_lock(&unnamed_dev_lock);
707 idr_remove(&unnamed_dev_idr, dev); 707 ida_remove(&unnamed_dev_ida, dev);
708 spin_unlock(&unnamed_dev_lock); 708 spin_unlock(&unnamed_dev_lock);
709 return -EMFILE; 709 return -EMFILE;
710 } 710 }
@@ -720,17 +720,12 @@ void kill_anon_super(struct super_block *sb)
720 720
721 generic_shutdown_super(sb); 721 generic_shutdown_super(sb);
722 spin_lock(&unnamed_dev_lock); 722 spin_lock(&unnamed_dev_lock);
723 idr_remove(&unnamed_dev_idr, slot); 723 ida_remove(&unnamed_dev_ida, slot);
724 spin_unlock(&unnamed_dev_lock); 724 spin_unlock(&unnamed_dev_lock);
725} 725}
726 726
727EXPORT_SYMBOL(kill_anon_super); 727EXPORT_SYMBOL(kill_anon_super);
728 728
729void __init unnamed_dev_init(void)
730{
731 idr_init(&unnamed_dev_idr);
732}
733
734void kill_litter_super(struct super_block *sb) 729void kill_litter_super(struct super_block *sb)
735{ 730{
736 if (sb->s_root) 731 if (sb->s_root)