patch-2.4.14 linux/fs/block_dev.c

Next file: linux/fs/buffer.c
Previous file: linux/fs/binfmt_aout.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.13/linux/fs/block_dev.c linux/fs/block_dev.c
@@ -537,14 +537,20 @@
 		bdev->bd_op = get_blkfops(MAJOR(dev));
 	if (bdev->bd_op) {
 		ret = 0;
+		if (bdev->bd_op->owner)
+			__MOD_INC_USE_COUNT(bdev->bd_op->owner);
 		if (bdev->bd_op->open)
 			ret = bdev->bd_op->open(inode, file);
 		if (!ret) {
 			bdev->bd_openers++;
 			bdev->bd_inode->i_size = blkdev_size(dev);
 			bdev->bd_inode->i_blkbits = blksize_bits(block_size(dev));
-		} else if (!bdev->bd_openers)
-			bdev->bd_op = NULL;
+		} else {
+			if (bdev->bd_op->owner)
+				__MOD_DEC_USE_COUNT(bdev->bd_op->owner);
+			if (!bdev->bd_openers)
+				bdev->bd_op = NULL;
+		}
 	}
 	unlock_kernel();
 	up(&bdev->bd_sem);
@@ -605,6 +611,8 @@
 		kill_bdev(bdev);
 	if (bdev->bd_op->release)
 		ret = bdev->bd_op->release(bd_inode, NULL);
+	if (bdev->bd_op->owner)
+		__MOD_DEC_USE_COUNT(bdev->bd_op->owner);
 	if (!bdev->bd_openers)
 		bdev->bd_op = NULL;
 	unlock_kernel();

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)