public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Maxim V. Patlasov" <mpatlasov@parallels.com>
To: Vivek Goyal <vgoyal@redhat.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"dm-devel@redhat.com" <dm-devel@redhat.com>,
	"kzak@redhat.com" <kzak@redhat.com>,
	"psusi@ubuntu.com" <psusi@ubuntu.com>,
	"psusi@cfl.rr.com" <psusi@cfl.rr.com>,
	"maxim.patlasov@gmail.com" <maxim.patlasov@gmail.com>
Subject: Re: [PATCH 1/2] block: add partition resize function to blkpg ioctl
Date: Mon, 9 Apr 2012 20:40:35 +0400	[thread overview]
Message-ID: <4F831103.3050704@parallels.com> (raw)
In-Reply-To: <1329251991-22468-2-git-send-email-vgoyal@redhat.com>

Hi Vivek,

See please inline comments below...

On 02/15/2012 12:39 AM, Vivek Goyal wrote:
> ...
> @@ -765,8 +765,8 @@ void __init printk_all_partitions(void)
>
>   			printk("%s%s %10llu %s %s", is_part0 ? "" : "  ",
>   			       bdevt_str(part_devt(part), devt_buf),
> -			       (unsigned long long)part->nr_sects>>  1,
> -			       disk_name(disk, part->partno, name_buf), uuid);
> +			       (unsigned long long)part_nr_sects_read(part)>>  1
> +			       , disk_name(disk, part->partno, name_buf), uuid);

A line starting from comma looks unusual. Is it what you intended?

> diff --git a/block/ioctl.c b/block/ioctl.c
> index ba15b2d..ddbc649 100644
> --- a/block/ioctl.c
> +++ b/block/ioctl.c
> ...
> @@ -92,6 +92,57 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
>   			bdput(bdevp);
>
>   			return 0;
> +		case BLKPG_RESIZE_PARTITION:
> +			start = p.start>>  9;
> +			/* new length of partition in bytes */
> +			length = p.length>>  9;
> +			/* check for fit in a hd_struct */
> +			if (sizeof(sector_t) == sizeof(long)&&
> +			    sizeof(long long)>  sizeof(long)) {
> +				long pstart = start, plength = length;
> +				if (pstart != start || plength != length
> +				    || pstart<  0 || plength<  0)
> +					return -EINVAL;
> +			}
> +			part = disk_get_part(disk, partno);
> +			if (!part)
> +				return -ENXIO;
> +			bdevp = bdget(part_devt(part));
> +			if (!bdevp) {
> +				disk_put_part(part);
> +				return -ENOMEM;
> +			}
> +			mutex_lock(&bdevp->bd_mutex);
> +			mutex_lock_nested(&bdev->bd_mutex, 1);
> +			if (start != part->start_sect) {
> +				mutex_unlock(&bdevp->bd_mutex);
> +				mutex_unlock(&bdev->bd_mutex);
> +				disk_put_part(part);
> +				return -EINVAL;

bdput(bdevp) missed?


> +			}
> +			/* overlap? */
> +			disk_part_iter_init(&piter, disk,
> +					    DISK_PITER_INCL_EMPTY);
> +			while ((lpart = disk_part_iter_next(&piter))) {
> +				if (lpart->partno != partno&&
> +				   !(start + length<= lpart->start_sect ||
> +				   start>= lpart->start_sect + lpart->nr_sects)
> +				   ) {
> +					disk_part_iter_exit(&piter);
> +					mutex_unlock(&bdevp->bd_mutex);
> +					mutex_unlock(&bdev->bd_mutex);
> +					disk_put_part(part);
> +					return -EBUSY;

bdput(bdevp) missed?

> +				}
> +			}
> +			disk_part_iter_exit(&piter);
> +			part_nr_sects_write(part, (sector_t)length);
> +			i_size_write(bdevp->bd_inode, p.length);
> +			mutex_unlock(&bdevp->bd_mutex);
> +			mutex_unlock(&bdev->bd_mutex);
> +			bdput(bdevp);
> +			disk_put_part(part);
> +			return 0;
>   		default:
>   			return -EINVAL;
>   	}

Thanks,
Maxim

  parent reply	other threads:[~2012-04-09 16:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-14 20:39 [PATCH 0/2][V3] block: Support online resize of disk partitions Vivek Goyal
2012-02-14 20:39 ` [PATCH 1/2] block: add partition resize function to blkpg ioctl Vivek Goyal
2012-02-20 14:42   ` Vivek Goyal
2012-02-20 15:17     ` Phillip Susi
2012-02-20 15:28   ` Vivek Goyal
2012-03-02 18:54     ` Vivek Goyal
2012-07-07  1:51       ` Phillip Susi
2012-07-09 15:13         ` Vivek Goyal
2012-04-09 16:40   ` Maxim V. Patlasov [this message]
2012-02-14 20:39 ` [PATCH 2/2] util-linux: resizepart: Utility to resize a partition Vivek Goyal
  -- strict thread matches above, loose matches on Subject: below --
2012-07-09 21:34 [patch 0/2] [V4] block: Support online resize of disk partitions vgoyal
2012-07-09 21:34 ` [patch 1/2] block: add partition resize function to blkpg ioctl vgoyal
2012-02-13 19:30 [PATCH 0/2] block: online resize of disk partitions Vivek Goyal
2012-02-13 19:30 ` [PATCH 1/2] block: add partition resize function to blkpg ioctl Vivek Goyal

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=4F831103.3050704@parallels.com \
    --to=mpatlasov@parallels.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=kzak@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxim.patlasov@gmail.com \
    --cc=psusi@cfl.rr.com \
    --cc=psusi@ubuntu.com \
    --cc=vgoyal@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox