From: Borislav Petkov <petkovbb@googlemail.com>
To: Tejun Heo <tj@kernel.org>, axboe@kernel.dk
Cc: bzolnier@gmail.com, linux-ide@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] ide-floppy partitions
Date: Sat, 1 Nov 2008 21:14:20 +0100 [thread overview]
Message-ID: <20081101201419.GA29462@gollum.tnic> (raw)
In-Reply-To: <20081029071319.GA9205@gollum.tnic>
On Wed, Oct 29, 2008 at 08:13:19AM +0100, Borislav Petkov wrote:
> 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;
Tejun, Jens,
can you guys please ACK/NACK this so that we can have an agreed upon solution
and so that I can stop applying it ontop of current git before testing any
further.
Thanks.
--
Regards/Gruss,
Boris.
next parent reply other threads:[~2008-11-01 20:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20081029071319.GA9205@gollum.tnic>
2008-11-01 20:14 ` Borislav Petkov [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081101201419.GA29462@gollum.tnic \
--to=petkovbb@googlemail.com \
--cc=axboe@kernel.dk \
--cc=bzolnier@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=petkovbb@gmail.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®