All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Milan Broz <mbroz@redhat.com>
Cc: Nikanth Karthikesan <knikanth@suse.de>,
	device-mapper development <dm-devel@redhat.com>,
	Alasdair G Kergon <agk@redhat.com>,
	Jens Axboe <jens.axboe@oracle.com>
Subject: Re: [PATCH][RFC] Emulate BLKRRPART on device-mapper
Date: Wed, 22 Jul 2009 09:06:08 +0200	[thread overview]
Message-ID: <4A66BA60.2020500@suse.de> (raw)
In-Reply-To: <4A65E912.6020706@redhat.com>

Milan Broz wrote:
> Alasdair G Kergon wrote:
>> On Wed, Jul 08, 2009 at 02:14:50PM +0530, Nikanth Karthikesan wrote:
>>   
>>> From: Hannes Reinecke <hare@suse.de>
>>> Subject: Emulate BLKRRPART on device-mapper
>>>
>>> Partitions on device-mapper devices are managed by kpartx (if at
>>> all). So if we were just to send out a 'change' event if someone
>>> called BLKRRPART on these devices, kpartx will be triggered via udev
>>> and can manage the partitions accordingly.
>>>
>>>     
>> Please could I have a 'Tested-by' for this one?
>>   
> I am afraid that this patch cannot work, BLRRPART never reach this code.
> I tried another idea - or is there better way how to achieve that?
> 
Hey, that is cool. And what's more, that's exactly what I need for another
pet-project of mine, switching off the in-kernel partitioning code altogether.

But there are some comments, see below.

> Milan
> ---
> 
> From: Milan Broz <mbroz@redhat.com>
> 
> Add genhd flag requesting notification of partition changes only.
> 
> This patch provides notification mechanism which allows handle partition
> code in userspace.
> 
> If the BLKRRPART ioctl arrives and GENHD_FL_PARTITION_CHANGE_NOTIFY
> is set, just send uevent and ignore in-kernel partitioning code.
> 
> This is useful e.g. for device-mapper devices, which can use kpartx
> or similar tool in udev rules.
> 
> Signed-off-by: Milan Broz <mbroz@redhat.com>
> ---
>  block/ioctl.c         |    3 ++-
>  drivers/md/dm.c       |    1 +
>  fs/partitions/check.c |    6 ++++++
>  include/linux/genhd.h |    8 ++++++++
>  4 files changed, 17 insertions(+), 1 deletions(-)
> 
> diff --git a/block/ioctl.c b/block/ioctl.c
> index 500e4c7..bce793f 100644
> --- a/block/ioctl.c
> +++ b/block/ioctl.c
> @@ -101,7 +101,8 @@ static int blkdev_reread_part(struct block_device *bdev)
>  	struct gendisk *disk = bdev->bd_disk;
>  	int res;
>  
> -	if (!disk_partitionable(disk) || bdev != bdev->bd_contains)
> +	if (!disk_userspace_partitions(disk) &&
> +	    (!disk_partitionable(disk) || bdev != bdev->bd_contains))
>  		return -EINVAL;
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EACCES;
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index 9acd54a..1186ce1 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -1791,6 +1791,7 @@ static struct mapped_device *alloc_dev(int minor)
>  	md->disk->queue = md->queue;
>  	md->disk->private_data = md;
>  	sprintf(md->disk->disk_name, "dm-%d", minor);
> +	md->disk->flags |= GENHD_FL_PARTITION_CHANGE_NOTIFY;
>  	add_disk(md->disk);
>  	format_dev_t(md->name, MKDEV(_major, minor));
>  
> diff --git a/fs/partitions/check.c b/fs/partitions/check.c
> index ea4e6cb..bb42c44 100644
> --- a/fs/partitions/check.c
> +++ b/fs/partitions/check.c
> @@ -521,6 +521,12 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
>  	struct parsed_partitions *state;
>  	int p, highest, res;
>  
> +	/* partitions handled in userspace, just send change event */
> +	if (disk_userspace_partitions(disk)) {
> +		kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE);
> +		return 0;
> +	}
> +
Wrong. If you do it here, you'll never be able to catch any size changes
of the disk. You'll have to move it to after the 'bdev->bd_invalidated = 0'
line.

>  	if (bdev->bd_part_count)
>  		return -EBUSY;
>  	res = invalidate_partition(disk, 0);
> diff --git a/include/linux/genhd.h b/include/linux/genhd.h
> index 45fc320..a241bd6 100644
> --- a/include/linux/genhd.h
> +++ b/include/linux/genhd.h
> @@ -116,6 +116,9 @@ struct hd_struct {
>  #define GENHD_FL_EXT_DEVT			64 /* allow extended devt */
>  #define GENHD_FL_NATIVE_CAPACITY		128
>  
> +/* notify udev instead of use in-kernel partitioning */
> +#define GENHD_FL_PARTITION_CHANGE_NOTIFY	256
> +
I would suggest renaming it to GENHD_FL_USERSPACE_PARTITIONS, as this is
more in line with the function of the flag.
Plus I have a patch making use of it :-)

I'll send an adapted patchset.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)

  reply	other threads:[~2009-07-22  7:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-08  8:44 [PATCH] Emulate BLKRRPART on device-mapper Nikanth Karthikesan
2009-07-20 18:23 ` Alasdair G Kergon
2009-07-21 16:13   ` [PATCH][RFC] " Milan Broz
2009-07-22  7:06     ` Hannes Reinecke [this message]
2009-07-22  8:12       ` Milan Broz
2009-07-22  8:19         ` Hannes Reinecke

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=4A66BA60.2020500@suse.de \
    --to=hare@suse.de \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=jens.axboe@oracle.com \
    --cc=knikanth@suse.de \
    --cc=mbroz@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.