public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: ioctl: Fix coding style issues
@ 2011-07-01  9:09 Chris Forbes
  2011-07-01  9:16 ` Chris Forbes
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Forbes @ 2011-07-01  9:09 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, Chris Forbes

Fixed issues as flagged by checkpatch.pl

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
---
 block/ioctl.c |  105 +++++++++++++++++++++++++++++----------------------------
 1 files changed, 53 insertions(+), 52 deletions(-)

diff --git a/block/ioctl.c b/block/ioctl.c
index 1124cd2..fa284e5 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -6,10 +6,10 @@
 #include <linux/backing-dev.h>
 #include <linux/buffer_head.h>
 #include <linux/blktrace_api.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
-static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user *arg)
-{
+static int blkpg_ioctl(struct block_device *bdev,
+			struct blkpg_ioctl_arg __user *arg) {
 	struct block_device *bdevp;
 	struct gendisk *disk;
 	struct hd_struct *part;
@@ -31,28 +31,29 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
 	partno = p.pno;
 	if (partno <= 0)
 		return -EINVAL;
+
 	switch (a.op) {
-		case BLKPG_ADD_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;
-			}
+	case BLKPG_ADD_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);
+		mutex_lock(&bdev->bd_mutex);
 
-			/* overlap? */
-			disk_part_iter_init(&piter, disk,
-					    DISK_PITER_INCL_EMPTY);
-			while ((part = disk_part_iter_next(&piter))) {
-				if (!(start + length <= part->start_sect ||
-				      start >= part->start_sect + part->nr_sects)) {
-					disk_part_iter_exit(&piter);
+		/* overlap? */
+		disk_part_iter_init(&piter, disk,
+				    DISK_PITER_INCL_EMPTY);
+		while ((part = disk_part_iter_next(&piter))) {
+			if (!(start + length <= part->start_sect ||
+			      start >= part->start_sect + part->nr_sects)) {
+				disk_part_iter_exit(&piter);
 					mutex_unlock(&bdev->bd_mutex);
 					return -EBUSY;
 				}
@@ -64,35 +65,35 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
 					     ADDPART_FLAG_NONE, NULL);
 			mutex_unlock(&bdev->bd_mutex);
 			return IS_ERR(part) ? PTR_ERR(part) : 0;
-		case BLKPG_DEL_PARTITION:
-			part = disk_get_part(disk, partno);
-			if (!part)
-				return -ENXIO;
-
-			bdevp = bdget(part_devt(part));
-			disk_put_part(part);
-			if (!bdevp)
-				return -ENOMEM;
-
-			mutex_lock(&bdevp->bd_mutex);
-			if (bdevp->bd_openers) {
-				mutex_unlock(&bdevp->bd_mutex);
-				bdput(bdevp);
-				return -EBUSY;
-			}
-			/* all seems OK */
-			fsync_bdev(bdevp);
-			invalidate_bdev(bdevp);
-
-			mutex_lock_nested(&bdev->bd_mutex, 1);
-			delete_partition(disk, partno);
-			mutex_unlock(&bdev->bd_mutex);
+	case BLKPG_DEL_PARTITION:
+		part = disk_get_part(disk, partno);
+		if (!part)
+			return -ENXIO;
+
+		bdevp = bdget(part_devt(part));
+		disk_put_part(part);
+		if (!bdevp)
+			return -ENOMEM;
+
+		mutex_lock(&bdevp->bd_mutex);
+		if (bdevp->bd_openers) {
 			mutex_unlock(&bdevp->bd_mutex);
 			bdput(bdevp);
+			return -EBUSY;
+		}
+		/* all seems OK */
+		fsync_bdev(bdevp);
+		invalidate_bdev(bdevp);
 
-			return 0;
-		default:
-			return -EINVAL;
+		mutex_lock_nested(&bdev->bd_mutex, 1);
+		delete_partition(disk, partno);
+		mutex_unlock(&bdev->bd_mutex);
+		mutex_unlock(&bdevp->bd_mutex);
+		bdput(bdevp);
+
+		return 0;
+	default:
+		return -EINVAL;
 	}
 }
 
@@ -189,7 +190,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
 	loff_t size;
 	int ret, n;
 
-	switch(cmd) {
+	switch (cmd) {
 	case BLKFLSBUF:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
@@ -279,7 +280,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
 		return put_ushort(arg, queue_max_sectors(bdev_get_queue(bdev)));
 	case BLKRASET:
 	case BLKFRASET:
-		if(!capable(CAP_SYS_ADMIN))
+		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
 		bdi = blk_get_backing_dev_info(bdev);
 		if (bdi == NULL)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] block: ioctl: Fix coding style issues
  2011-07-01  9:09 [PATCH] block: ioctl: Fix coding style issues Chris Forbes
@ 2011-07-01  9:16 ` Chris Forbes
  2011-07-01  9:44   ` [PATCH v2] " Chris Forbes
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Forbes @ 2011-07-01  9:16 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, Chris Forbes

Sorry, please disregard -- indentation is still bogus.

-- Chris

On Fri, Jul 1, 2011 at 9:09 PM, Chris Forbes <chrisf@ijw.co.nz> wrote:
> Fixed issues as flagged by checkpatch.pl
>
> Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
> ---
>  block/ioctl.c |  105 +++++++++++++++++++++++++++++----------------------------
>  1 files changed, 53 insertions(+), 52 deletions(-)
>
> diff --git a/block/ioctl.c b/block/ioctl.c
> index 1124cd2..fa284e5 100644
> --- a/block/ioctl.c
> +++ b/block/ioctl.c
> @@ -6,10 +6,10 @@
>  #include <linux/backing-dev.h>
>  #include <linux/buffer_head.h>
>  #include <linux/blktrace_api.h>
> -#include <asm/uaccess.h>
> +#include <linux/uaccess.h>
>
> -static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user *arg)
> -{
> +static int blkpg_ioctl(struct block_device *bdev,
> +                       struct blkpg_ioctl_arg __user *arg) {
>        struct block_device *bdevp;
>        struct gendisk *disk;
>        struct hd_struct *part;
> @@ -31,28 +31,29 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
>        partno = p.pno;
>        if (partno <= 0)
>                return -EINVAL;
> +
>        switch (a.op) {
> -               case BLKPG_ADD_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;
> -                       }
> +       case BLKPG_ADD_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);
> +               mutex_lock(&bdev->bd_mutex);
>
> -                       /* overlap? */
> -                       disk_part_iter_init(&piter, disk,
> -                                           DISK_PITER_INCL_EMPTY);
> -                       while ((part = disk_part_iter_next(&piter))) {
> -                               if (!(start + length <= part->start_sect ||
> -                                     start >= part->start_sect + part->nr_sects)) {
> -                                       disk_part_iter_exit(&piter);
> +               /* overlap? */
> +               disk_part_iter_init(&piter, disk,
> +                                   DISK_PITER_INCL_EMPTY);
> +               while ((part = disk_part_iter_next(&piter))) {
> +                       if (!(start + length <= part->start_sect ||
> +                             start >= part->start_sect + part->nr_sects)) {
> +                               disk_part_iter_exit(&piter);
>                                        mutex_unlock(&bdev->bd_mutex);
>                                        return -EBUSY;
>                                }
> @@ -64,35 +65,35 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
>                                             ADDPART_FLAG_NONE, NULL);
>                        mutex_unlock(&bdev->bd_mutex);
>                        return IS_ERR(part) ? PTR_ERR(part) : 0;
> -               case BLKPG_DEL_PARTITION:
> -                       part = disk_get_part(disk, partno);
> -                       if (!part)
> -                               return -ENXIO;
> -
> -                       bdevp = bdget(part_devt(part));
> -                       disk_put_part(part);
> -                       if (!bdevp)
> -                               return -ENOMEM;
> -
> -                       mutex_lock(&bdevp->bd_mutex);
> -                       if (bdevp->bd_openers) {
> -                               mutex_unlock(&bdevp->bd_mutex);
> -                               bdput(bdevp);
> -                               return -EBUSY;
> -                       }
> -                       /* all seems OK */
> -                       fsync_bdev(bdevp);
> -                       invalidate_bdev(bdevp);
> -
> -                       mutex_lock_nested(&bdev->bd_mutex, 1);
> -                       delete_partition(disk, partno);
> -                       mutex_unlock(&bdev->bd_mutex);
> +       case BLKPG_DEL_PARTITION:
> +               part = disk_get_part(disk, partno);
> +               if (!part)
> +                       return -ENXIO;
> +
> +               bdevp = bdget(part_devt(part));
> +               disk_put_part(part);
> +               if (!bdevp)
> +                       return -ENOMEM;
> +
> +               mutex_lock(&bdevp->bd_mutex);
> +               if (bdevp->bd_openers) {
>                        mutex_unlock(&bdevp->bd_mutex);
>                        bdput(bdevp);
> +                       return -EBUSY;
> +               }
> +               /* all seems OK */
> +               fsync_bdev(bdevp);
> +               invalidate_bdev(bdevp);
>
> -                       return 0;
> -               default:
> -                       return -EINVAL;
> +               mutex_lock_nested(&bdev->bd_mutex, 1);
> +               delete_partition(disk, partno);
> +               mutex_unlock(&bdev->bd_mutex);
> +               mutex_unlock(&bdevp->bd_mutex);
> +               bdput(bdevp);
> +
> +               return 0;
> +       default:
> +               return -EINVAL;
>        }
>  }
>
> @@ -189,7 +190,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
>        loff_t size;
>        int ret, n;
>
> -       switch(cmd) {
> +       switch (cmd) {
>        case BLKFLSBUF:
>                if (!capable(CAP_SYS_ADMIN))
>                        return -EACCES;
> @@ -279,7 +280,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
>                return put_ushort(arg, queue_max_sectors(bdev_get_queue(bdev)));
>        case BLKRASET:
>        case BLKFRASET:
> -               if(!capable(CAP_SYS_ADMIN))
> +               if (!capable(CAP_SYS_ADMIN))
>                        return -EACCES;
>                bdi = blk_get_backing_dev_info(bdev);
>                if (bdi == NULL)
> --
> 1.7.4.1
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] block: ioctl: Fix coding style issues
  2011-07-01  9:16 ` Chris Forbes
@ 2011-07-01  9:44   ` Chris Forbes
  2011-07-01  9:58     ` Joe Perches
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Forbes @ 2011-07-01  9:44 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, Chris Forbes

Fixed issues as flagged by checkpatch.pl

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
---
 block/ioctl.c |  123 +++++++++++++++++++++++++++++----------------------------
 1 files changed, 62 insertions(+), 61 deletions(-)

diff --git a/block/ioctl.c b/block/ioctl.c
index 1124cd2..75ac68c 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -6,10 +6,10 @@
 #include <linux/backing-dev.h>
 #include <linux/buffer_head.h>
 #include <linux/blktrace_api.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
-static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user *arg)
-{
+static int blkpg_ioctl(struct block_device *bdev,
+			struct blkpg_ioctl_arg __user *arg) {
 	struct block_device *bdevp;
 	struct gendisk *disk;
 	struct hd_struct *part;
@@ -31,68 +31,69 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
 	partno = p.pno;
 	if (partno <= 0)
 		return -EINVAL;
+
 	switch (a.op) {
-		case BLKPG_ADD_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;
-			}
+	case BLKPG_ADD_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 (!(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);
-
-			/* all seems OK */
-			part = add_partition(disk, partno, start, length,
-					     ADDPART_FLAG_NONE, NULL);
-			mutex_unlock(&bdev->bd_mutex);
-			return IS_ERR(part) ? PTR_ERR(part) : 0;
-		case BLKPG_DEL_PARTITION:
-			part = disk_get_part(disk, partno);
-			if (!part)
-				return -ENXIO;
-
-			bdevp = bdget(part_devt(part));
-			disk_put_part(part);
-			if (!bdevp)
-				return -ENOMEM;
-
-			mutex_lock(&bdevp->bd_mutex);
-			if (bdevp->bd_openers) {
-				mutex_unlock(&bdevp->bd_mutex);
-				bdput(bdevp);
+		mutex_lock(&bdev->bd_mutex);
+
+		/* overlap? */
+		disk_part_iter_init(&piter, disk,
+				    DISK_PITER_INCL_EMPTY);
+		while ((part = disk_part_iter_next(&piter))) {
+			if (!(start + length <= part->start_sect ||
+			      start >= part->start_sect + part->nr_sects)) {
+				disk_part_iter_exit(&piter);
+				mutex_unlock(&bdev->bd_mutex);
 				return -EBUSY;
 			}
-			/* all seems OK */
-			fsync_bdev(bdevp);
-			invalidate_bdev(bdevp);
-
-			mutex_lock_nested(&bdev->bd_mutex, 1);
-			delete_partition(disk, partno);
-			mutex_unlock(&bdev->bd_mutex);
+		}
+		disk_part_iter_exit(&piter);
+
+		/* all seems OK */
+		part = add_partition(disk, partno, start, length,
+				     ADDPART_FLAG_NONE, NULL);
+		mutex_unlock(&bdev->bd_mutex);
+		return IS_ERR(part) ? PTR_ERR(part) : 0;
+	case BLKPG_DEL_PARTITION:
+		part = disk_get_part(disk, partno);
+		if (!part)
+			return -ENXIO;
+
+		bdevp = bdget(part_devt(part));
+		disk_put_part(part);
+		if (!bdevp)
+			return -ENOMEM;
+
+		mutex_lock(&bdevp->bd_mutex);
+		if (bdevp->bd_openers) {
 			mutex_unlock(&bdevp->bd_mutex);
 			bdput(bdevp);
+			return -EBUSY;
+		}
+		/* all seems OK */
+		fsync_bdev(bdevp);
+		invalidate_bdev(bdevp);
 
-			return 0;
-		default:
-			return -EINVAL;
+		mutex_lock_nested(&bdev->bd_mutex, 1);
+		delete_partition(disk, partno);
+		mutex_unlock(&bdev->bd_mutex);
+		mutex_unlock(&bdevp->bd_mutex);
+		bdput(bdevp);
+
+		return 0;
+	default:
+		return -EINVAL;
 	}
 }
 
@@ -189,7 +190,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
 	loff_t size;
 	int ret, n;
 
-	switch(cmd) {
+	switch (cmd) {
 	case BLKFLSBUF:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
@@ -279,7 +280,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
 		return put_ushort(arg, queue_max_sectors(bdev_get_queue(bdev)));
 	case BLKRASET:
 	case BLKFRASET:
-		if(!capable(CAP_SYS_ADMIN))
+		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
 		bdi = blk_get_backing_dev_info(bdev);
 		if (bdi == NULL)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] block: ioctl: Fix coding style issues
  2011-07-01  9:44   ` [PATCH v2] " Chris Forbes
@ 2011-07-01  9:58     ` Joe Perches
  2011-07-01 10:08       ` [PATCH v3] block: ioctl: Fixed " Chris Forbes
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2011-07-01  9:58 UTC (permalink / raw)
  To: Chris Forbes; +Cc: Jens Axboe, linux-kernel

On Fri, 2011-07-01 at 21:44 +1200, Chris Forbes wrote:
> Fixed issues as flagged by checkpatch.pl
> diff --git a/block/ioctl.c b/block/ioctl.c
[]
> @@ -6,10 +6,10 @@
>  #include <linux/backing-dev.h>
>  #include <linux/buffer_head.h>
>  #include <linux/blktrace_api.h>
> -#include <asm/uaccess.h>
> +#include <linux/uaccess.h>
>  
> -static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user *arg)
> -{
> +static int blkpg_ioctl(struct block_device *bdev,
> +			struct blkpg_ioctl_arg __user *arg) {

Hey Chris.

Sorry, that's not right.
The open brace needs to be on a new line.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3] block: ioctl: Fixed coding style issues.
  2011-07-01  9:58     ` Joe Perches
@ 2011-07-01 10:08       ` Chris Forbes
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Forbes @ 2011-07-01 10:08 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, Chris Forbes

Fixed coding style issues as flagged by checkpatch.pl
Corrected error in previous version of patch.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
---
 block/ioctl.c |  122 +++++++++++++++++++++++++++++----------------------------
 1 files changed, 62 insertions(+), 60 deletions(-)

diff --git a/block/ioctl.c b/block/ioctl.c
index 1124cd2..729bfac 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -6,9 +6,10 @@
 #include <linux/backing-dev.h>
 #include <linux/buffer_head.h>
 #include <linux/blktrace_api.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
-static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user *arg)
+static int blkpg_ioctl(struct block_device *bdev,
+			struct blkpg_ioctl_arg __user *arg)
 {
 	struct block_device *bdevp;
 	struct gendisk *disk;
@@ -31,68 +32,69 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
 	partno = p.pno;
 	if (partno <= 0)
 		return -EINVAL;
+
 	switch (a.op) {
-		case BLKPG_ADD_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;
-			}
+	case BLKPG_ADD_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 (!(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);
-
-			/* all seems OK */
-			part = add_partition(disk, partno, start, length,
-					     ADDPART_FLAG_NONE, NULL);
-			mutex_unlock(&bdev->bd_mutex);
-			return IS_ERR(part) ? PTR_ERR(part) : 0;
-		case BLKPG_DEL_PARTITION:
-			part = disk_get_part(disk, partno);
-			if (!part)
-				return -ENXIO;
-
-			bdevp = bdget(part_devt(part));
-			disk_put_part(part);
-			if (!bdevp)
-				return -ENOMEM;
-
-			mutex_lock(&bdevp->bd_mutex);
-			if (bdevp->bd_openers) {
-				mutex_unlock(&bdevp->bd_mutex);
-				bdput(bdevp);
+		mutex_lock(&bdev->bd_mutex);
+
+		/* overlap? */
+		disk_part_iter_init(&piter, disk,
+				    DISK_PITER_INCL_EMPTY);
+		while ((part = disk_part_iter_next(&piter))) {
+			if (!(start + length <= part->start_sect ||
+			      start >= part->start_sect + part->nr_sects)) {
+				disk_part_iter_exit(&piter);
+				mutex_unlock(&bdev->bd_mutex);
 				return -EBUSY;
 			}
-			/* all seems OK */
-			fsync_bdev(bdevp);
-			invalidate_bdev(bdevp);
-
-			mutex_lock_nested(&bdev->bd_mutex, 1);
-			delete_partition(disk, partno);
-			mutex_unlock(&bdev->bd_mutex);
+		}
+		disk_part_iter_exit(&piter);
+
+		/* all seems OK */
+		part = add_partition(disk, partno, start, length,
+				     ADDPART_FLAG_NONE, NULL);
+		mutex_unlock(&bdev->bd_mutex);
+		return IS_ERR(part) ? PTR_ERR(part) : 0;
+	case BLKPG_DEL_PARTITION:
+		part = disk_get_part(disk, partno);
+		if (!part)
+			return -ENXIO;
+
+		bdevp = bdget(part_devt(part));
+		disk_put_part(part);
+		if (!bdevp)
+			return -ENOMEM;
+
+		mutex_lock(&bdevp->bd_mutex);
+		if (bdevp->bd_openers) {
 			mutex_unlock(&bdevp->bd_mutex);
 			bdput(bdevp);
+			return -EBUSY;
+		}
+		/* all seems OK */
+		fsync_bdev(bdevp);
+		invalidate_bdev(bdevp);
 
-			return 0;
-		default:
-			return -EINVAL;
+		mutex_lock_nested(&bdev->bd_mutex, 1);
+		delete_partition(disk, partno);
+		mutex_unlock(&bdev->bd_mutex);
+		mutex_unlock(&bdevp->bd_mutex);
+		bdput(bdevp);
+
+		return 0;
+	default:
+		return -EINVAL;
 	}
 }
 
@@ -189,7 +191,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
 	loff_t size;
 	int ret, n;
 
-	switch(cmd) {
+	switch (cmd) {
 	case BLKFLSBUF:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
@@ -279,7 +281,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
 		return put_ushort(arg, queue_max_sectors(bdev_get_queue(bdev)));
 	case BLKRASET:
 	case BLKFRASET:
-		if(!capable(CAP_SYS_ADMIN))
+		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
 		bdi = blk_get_backing_dev_info(bdev);
 		if (bdi == NULL)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-07-01 10:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-01  9:09 [PATCH] block: ioctl: Fix coding style issues Chris Forbes
2011-07-01  9:16 ` Chris Forbes
2011-07-01  9:44   ` [PATCH v2] " Chris Forbes
2011-07-01  9:58     ` Joe Perches
2011-07-01 10:08       ` [PATCH v3] block: ioctl: Fixed " Chris Forbes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox