lkml.org 
[lkml]   [2011]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] Add partition resize function to BLKPG ioctl
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


\
 
 \ /
  Last update: 2011-12-19 21:27    [W:0.091 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site