patch-2.1.17 linux/fs/super.c

Next file: linux/include/asm-alpha/bitops.h
Previous file: linux/fs/stat.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.16/linux/fs/super.c linux/fs/super.c
@@ -560,10 +560,9 @@
 
 void put_unnamed_dev(kdev_t dev)
 {
-	if (!dev)
+	if (!dev || MAJOR(dev) != UNNAMED_MAJOR)
 		return;
-	if (MAJOR(dev) == UNNAMED_MAJOR &&
-	    clear_bit(MINOR(dev), unnamed_dev_in_use))
+	if (clear_bit(MINOR(dev), unnamed_dev_in_use))
 		return;
 	printk("VFS: put_unnamed_dev: freeing unused device %s\n",
 			kdevname(dev));
@@ -673,8 +672,7 @@
 		fsync_dev(dev);
 		if (dev != ROOT_DEV) {
 			blkdev_release (inode);
-			if (MAJOR(dev) == UNNAMED_MAJOR)
-				put_unnamed_dev(dev);
+			put_unnamed_dev(dev);
 		}
 	}
 	if (inode != &dummy_inode)
@@ -906,14 +904,17 @@
 		flags = new_flags & ~MS_MGC_MSK;
 		retval = copy_mount_options(data, &page);
 		if (retval < 0) {
+			put_unnamed_dev(dev);
 			iput(inode);
 			return retval;
 		}
 	}
 	retval = do_mount(dev,dev_name,dir_name,t,flags,(void *) page);
 	free_page(page);
-	if (retval && fops && fops->release)
+	if (retval && fops && fops->release) {
 		fops->release(inode, NULL);
+		put_unnamed_dev(dev);
+	}
 	iput(inode);
 	return retval;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov