linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] ide-floppy partitions
@ 2008-10-29  7:13 Borislav Petkov
  2008-10-29  7:42 ` [PATCH] ide-gd: re-get floppy capacity on revalidate Borislav Petkov
  2008-11-01 20:14 ` [RFC PATCH] ide-floppy partitions Borislav Petkov
  0 siblings, 2 replies; 9+ messages in thread
From: Borislav Petkov @ 2008-10-29  7:13 UTC (permalink / raw)
  To: Tejun Heo; +Cc: bzolnier, axboe, linux-ide

Hi Tejun,

recent changes at 0762b8bde9729f10f8e6249809660ff2ec3ad735 and around
break ide-floppy. Since it is a removable media drive and the partition
scan during boot returns empty (no media in the drive), when you later
put in a disk and try to mount it, mount returns saying

/dev/hdc4 is not a valid block device.

Which brings me to the other possible issue: Since having a hdc4
partition as a single FAT16 partition on a ZIP drive is the "factory
default" you could fabricate a case where you have a partition number> 1
as the only partition on a hard drive too, i.e. no continuous
partition numbering and the mount would theoretically fail there too
since, for example, there's a check in disk_get_part() which does:

if (likely(partno < ptbl->len)) {

and in this case the check will fail if partno >= 1 while you have only
one partition on the disk with a number higher than the partition table
length and the above described failure will happen too. Anyways, this is
just a hypothesis, but it happens with the ZIP drive here so other block
devices should behave similarly.

Here's a patch that fixes the ide-floppy case a bit clumsily, I admit.

---
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 88a776f..b798ea0 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1011,6 +1011,23 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
 	disk = get_gendisk(bdev->bd_dev, &partno);
 	if (!disk)
 		goto out_unlock_kernel;
+
+	part = disk_get_part(disk, partno);
+	if (!part) {
+		struct block_device *whole;
+
+		mutex_lock_nested(&bdev->bd_mutex, for_part);
+		whole = bdget_disk(disk, 0);
+		ret = -ENOMEM;
+		if (!whole)
+			goto out_clear;
+		ret = __blkdev_get(whole, mode, 1);
+		if (ret)
+			goto out_clear;
+		bdev->bd_contains = whole;
+		mutex_unlock(&bdev->bd_mutex);
+	}
+
 	part = disk_get_part(disk, partno);
 	if (!part)
 		goto out_unlock_kernel;



-- 
Regards/Gruss,
    Boris.

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-11-05  9:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-29  7:13 [RFC PATCH] ide-floppy partitions Borislav Petkov
2008-10-29  7:42 ` [PATCH] ide-gd: re-get floppy capacity on revalidate Borislav Petkov
2008-10-29 19:22   ` Bartlomiej Zolnierkiewicz
2008-11-01 20:14 ` [RFC PATCH] ide-floppy partitions Borislav Petkov
2008-11-03 15:37   ` Tejun Heo
2008-11-03 17:56     ` Borislav Petkov
2008-11-04  4:16       ` Subject: [PATCH] block: fix __blkdev_get() for removable devices Tejun Heo
2008-11-05  9:04         ` Borislav Petkov
2008-11-05  9:19           ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).