Re: [PATCH 1/2] block: add partition resize function to blkpg ioctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel


[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux