[PATCH 2/3] fs: super: switch to using ida_simple_.. functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ida handling can be much simplified using the ida_simple_.. functions.
This also removes the need for an own spinlock.

Signed-off-by: Heiner Kallweit <hkallweit1@xxxxxxxxx>
---
 fs/super.c | 29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index 362e765..37de8f5 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -880,34 +880,20 @@ void emergency_remount(void)
  */
 
 static DEFINE_IDA(unnamed_dev_ida);
-static DEFINE_SPINLOCK(unnamed_dev_lock);/* protects the above */
 
 int get_anon_bdev(dev_t *p)
 {
 	int dev;
-	int error;
 
- retry:
-	if (ida_pre_get(&unnamed_dev_ida, GFP_ATOMIC) == 0)
-		return -ENOMEM;
-	spin_lock(&unnamed_dev_lock);
 	/* Many userspace utilities consider an FSID of 0 invalid.
 	 * Always return at least 1 from get_anon_bdev.
 	 */
-	error = ida_get_new_above(&unnamed_dev_ida, 1, &dev);
-	spin_unlock(&unnamed_dev_lock);
-	if (error == -EAGAIN)
-		/* We raced and lost with another CPU. */
-		goto retry;
-	else if (error)
-		return -EAGAIN;
-
-	if (dev >= (1 << MINORBITS)) {
-		spin_lock(&unnamed_dev_lock);
-		ida_remove(&unnamed_dev_ida, dev);
-		spin_unlock(&unnamed_dev_lock);
+	dev = ida_simple_get(&unnamed_dev_ida, 1, 1 << MINORBITS, GFP_ATOMIC);
+	if (dev == -ENOSPC)
 		return -EMFILE;
-	}
+	else if (dev < 0)
+		return dev;
+
 	*p = MKDEV(0, dev & MINORMASK);
 	return 0;
 }
@@ -915,10 +901,7 @@ EXPORT_SYMBOL(get_anon_bdev);
 
 void free_anon_bdev(dev_t dev)
 {
-	int slot = MINOR(dev);
-	spin_lock(&unnamed_dev_lock);
-	ida_remove(&unnamed_dev_ida, slot);
-	spin_unlock(&unnamed_dev_lock);
+	ida_simple_remove(&unnamed_dev_ida, MINOR(dev));
 }
 EXPORT_SYMBOL(free_anon_bdev);
 
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux