diff mbox

[5/7] rbd: simplify snap_by_name() interface

Message ID 5049FA95.3040505@inktank.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alex Elder Sept. 7, 2012, 1:45 p.m. UTC
There is only one caller of snap_by_name(), and it passes two values
to be assigned, both of which are found within an rbd device
structure.

Change the interface so it just passes the address of the rbd_dev,
and make the assignments to its fields directly.

Signed-off-by: Alex Elder <elder@inktank.com>
---
 drivers/block/rbd.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

 	rbd_assert(header->snapc != NULL);
@@ -633,10 +633,9 @@ static int snap_by_name(struct rbd_image_header
*header, const char *snap_name,

 			/* Found it.  Pass back its id and/or size */

-			if (seq)
-				*seq = header->snapc->snaps[i];
-			if (size)
-				*size = header->snap_sizes[i];
+			rbd_dev->mapping.snap_id = header->snapc->snaps[i];
+			rbd_dev->mapping.size = header->snap_sizes[i];
+
 			return i;
 		}
 		p += strlen(p) + 1;	/* Skip ahead to the next name */
@@ -657,9 +656,7 @@ static int rbd_header_set_snap(struct rbd_device
*rbd_dev, char *snap_name)
 		rbd_dev->mapping.snap_exists = false;
 		rbd_dev->mapping.read_only = rbd_dev->rbd_opts.read_only;
 	} else {
-		ret = snap_by_name(&rbd_dev->header, snap_name,
-					&rbd_dev->mapping.snap_id,
-					&rbd_dev->mapping.size);
+		ret = snap_by_name(rbd_dev, snap_name);
 		if (ret < 0)
 			goto done;
 		rbd_dev->mapping.snap_exists = true;

Comments

Josh Durgin Sept. 7, 2012, 7:41 p.m. UTC | #1
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>

On 09/07/2012 06:45 AM, Alex Elder wrote:
> There is only one caller of snap_by_name(), and it passes two values
> to be assigned, both of which are found within an rbd device
> structure.
>
> Change the interface so it just passes the address of the rbd_dev,
> and make the assignments to its fields directly.
>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
>   drivers/block/rbd.c |   15 ++++++---------
>   1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 23fa962..46b8f8e 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -621,10 +621,10 @@ out_err:
>   	return -ENOMEM;
>   }
>
> -static int snap_by_name(struct rbd_image_header *header, const char
> *snap_name,
> -			u64 *seq, u64 *size)
> +static int snap_by_name(struct rbd_device *rbd_dev, const char *snap_name)
>   {
>   	int i;
> +	struct rbd_image_header *header = &rbd_dev->header;
>   	char *p = header->snap_names;
>
>   	rbd_assert(header->snapc != NULL);
> @@ -633,10 +633,9 @@ static int snap_by_name(struct rbd_image_header
> *header, const char *snap_name,
>
>   			/* Found it.  Pass back its id and/or size */
>
> -			if (seq)
> -				*seq = header->snapc->snaps[i];
> -			if (size)
> -				*size = header->snap_sizes[i];
> +			rbd_dev->mapping.snap_id = header->snapc->snaps[i];
> +			rbd_dev->mapping.size = header->snap_sizes[i];
> +
>   			return i;
>   		}
>   		p += strlen(p) + 1;	/* Skip ahead to the next name */
> @@ -657,9 +656,7 @@ static int rbd_header_set_snap(struct rbd_device
> *rbd_dev, char *snap_name)
>   		rbd_dev->mapping.snap_exists = false;
>   		rbd_dev->mapping.read_only = rbd_dev->rbd_opts.read_only;
>   	} else {
> -		ret = snap_by_name(&rbd_dev->header, snap_name,
> -					&rbd_dev->mapping.snap_id,
> -					&rbd_dev->mapping.size);
> +		ret = snap_by_name(rbd_dev, snap_name);
>   		if (ret < 0)
>   			goto done;
>   		rbd_dev->mapping.snap_exists = true;
>

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 23fa962..46b8f8e 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -621,10 +621,10 @@  out_err:
 	return -ENOMEM;
 }

-static int snap_by_name(struct rbd_image_header *header, const char
*snap_name,
-			u64 *seq, u64 *size)
+static int snap_by_name(struct rbd_device *rbd_dev, const char *snap_name)
 {
 	int i;
+	struct rbd_image_header *header = &rbd_dev->header;
 	char *p = header->snap_names;