linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Phillip Susi <psusi@cfl.rr.com>
Cc: joe@perches.com, kzak@redhat.com, linux-kernel@vger.kernel.org,
	jaxboe@fusionio.com
Subject: Re: [PATCH 1/2] Add partition resize function to BLKPG ioctl
Date: Mon, 19 Dec 2011 15:25:27 -0500	[thread overview]
Message-ID: <20111219202527.GF7175@redhat.com> (raw)
In-Reply-To: <1323735382-5972-1-git-send-email-psusi@cfl.rr.com>

On Mon, Dec 12, 2011 at 07:16:21PM -0500, Phillip Susi wrote:

[..]
> +		case BLKPG_RESIZE_PARTITION:
> +			start = p.start >> 9;
> +			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;
> +			}
> +
> +			mutex_lock(&bdev->bd_mutex);
> +
> +			/* overlap? */
> +			disk_part_iter_init(&piter, disk,
> +					    DISK_PITER_INCL_EMPTY);
> +			while ((part = disk_part_iter_next(&piter))) {
> +				if (part->partno != partno && !(start + length <= part->start_sect ||
> +				      start >= part->start_sect + part->nr_sects)) {
> +					disk_part_iter_exit(&piter);
> +					mutex_unlock(&bdev->bd_mutex);
> +					return -EBUSY;
> +				}
> +			}
> +			disk_part_iter_exit(&piter);
> +			part = disk_get_part(disk, partno);
> +			if (!part)
> +			{
> +				mutex_unlock(&bdev->bd_mutex);
> +				return -ENXIO;
> +			}
> +			if (start != part->start_sect)
> +			{
> +				mutex_unlock(&bdev->bd_mutex);
> +				disk_put_part(part);
> +				return -EINVAL;
> +			}
> +			part->nr_sects = length;
> +			bdevp = bdget(part_devt(part));
> +			mutex_lock(&bdevp->bd_mutex);

Are there any restrictions on order of partition bdev and disk bdev
locking.

I see that DEL_PARTITION ioctl first takes partition mutex and then 
disk mutex using mutex_lock_nested().

In your implementation you take disk mutex first and the partition 
bdev mutex. 

- Is that a problem from deadlock point of view? Two threads calling
  ioctl on same fd.

- Is it an issue from lock validator point of view. I am not familiar
  with mutex_lock_nested(). So thought of asking.

Thanks
Vivek

  parent reply	other threads:[~2011-12-19 20:25 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1322709471.git.psusi@cfl.rr.com>
2011-12-01  3:23 ` [PATCH 1/2] Add partition resize function to BLKPG ioctl Phillip Susi
2011-12-08 12:30   ` Karel Zak
2011-12-08 14:22     ` Phillip Susi
2011-12-08 15:16       ` Karel Zak
2011-12-08 15:25         ` Phillip Susi
2011-12-08 15:58           ` Vivek Goyal
2011-12-08 16:06             ` Phillip Susi
2011-12-08 16:28               ` Vivek Goyal
2011-12-08 16:55                 ` Phillip Susi
2011-12-09  2:53                 ` Phillip Susi
2011-12-12 14:53                   ` Vivek Goyal
2011-12-12 17:43                     ` Phillip Susi
2011-12-12 17:49                       ` Joe Perches
2011-12-12 18:04                         ` Vivek Goyal
2011-12-13  0:15                           ` Phillip Susi
2011-12-13  0:16                             ` Phillip Susi
2011-12-13  0:16                               ` [PATCH 2/2] Add BLKPG_GET_PARTITION operation Phillip Susi
2011-12-19 20:25                               ` Vivek Goyal [this message]
2011-12-21  1:53                                 ` [PATCH 1/2] Add partition resize function to BLKPG ioctl Phillip Susi
2011-12-21  1:54                                   ` Phillip Susi
2011-12-21  1:54                                     ` [PATCH 2/2] Add BLKPG_GET_PARTITION operation Phillip Susi
2011-12-21 20:46                                   ` [PATCH 1/2] Add partition resize function to BLKPG ioctl Vivek Goyal
2011-12-24 21:36                                     ` Phillip Susi
2011-12-24 22:21                                       ` Phillip Susi
2011-12-24 22:21                                         ` [PATCH 2/2] Add BLKPG_GET_PARTITION operation Phillip Susi
2011-12-01  3:23 ` Phillip Susi
2011-12-08 12:35   ` Karel Zak
2011-12-08 14:25     ` Phillip Susi
2011-12-29 17:06 [PATCH 1/2] Add partition resize function to BLKPG ioctl Maxim Patlasov
2011-12-30  0:09 ` Phillip Susi
2012-01-01 21:49   ` Phillip Susi
2012-01-26 19:01   ` Vivek Goyal
2012-01-26 20:35     ` Phillip Susi
2012-01-26 21:04       ` Vivek Goyal
2012-01-26 21:48         ` Phillip Susi
2012-01-30 15:49           ` 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=20111219202527.GF7175@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=jaxboe@fusionio.com \
    --cc=joe@perches.com \
    --cc=kzak@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=psusi@cfl.rr.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;
as well as URLs for NNTP newsgroup(s).