[PATCH] blkdev_open/bd_claim vs BLKBSZSET
From: Nathan Scott
Date: Mon Feb 23 2004 - 18:20:12 EST
Hi there,
I was modifying mkfs.xfs to use O_EXCL for 2.6, and hit a snag.
It seems that once I've opened a block dev with O_EXCL I can no
longer issue the BLKBSZSET ioctl to it. (Is that the expected
behavior? If so, ignore...)
The fs/block_dev.c code for blkdev_open does:
int blkdev_open(struct inode * inode, struct file * filp)
...
if (!(res = bd_claim(bdev, filp)))
return 0;
And the drivers/block/ioctl.c code for BLKBSZSET does this:
int holder;
...
case BLKBSZSET:
...
if (bd_claim(bdev, &holder) < 0)
return -EBUSY;
ret = set_blocksize(bdev, n);
bd_release(bdev);
And mkfs gets EBUSY back from the ioctl. Using the patch
below, the ioctl succeeds cos the original filp bdev owner
from open now matches with the owner in the ioctl call. I
suspect that would be the correct behavior, but perhaps I'm
overlooking some good reason for it being this way?
cheers.
--
Nathan
--- /usr/tmp/TmpDir.4274-0/drivers/block/ioctl.c_1.1 2004-02-24 08:58:28.000000000 +1100
+++ drivers/block/ioctl.c 2004-02-23 20:12:24.216909064 +1100
@@ -138,7 +138,6 @@
struct block_device *bdev = inode->i_bdev;
struct gendisk *disk = bdev->bd_disk;
struct backing_dev_info *bdi;
- int holder;
int ret, n;
switch (cmd) {
@@ -175,7 +174,7 @@
return -EINVAL;
if (get_user(n, (int *) arg))
return -EFAULT;
- if (bd_claim(bdev, &holder) < 0)
+ if (bd_claim(bdev, file) < 0)
return -EBUSY;
ret = set_blocksize(bdev, n);
bd_release(bdev);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/