Messages in this thread | | | Date | Mon, 19 Dec 2011 15:25:27 -0500 | From | Vivek Goyal <> | Subject | Re: [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
| |