From patchwork Fri Sep 7 13:45:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1422561 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B28F83FC85 for ; Fri, 7 Sep 2012 13:46:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755807Ab2IGNp7 (ORCPT ); Fri, 7 Sep 2012 09:45:59 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:49099 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753283Ab2IGNp7 (ORCPT ); Fri, 7 Sep 2012 09:45:59 -0400 Received: by iahk25 with SMTP id k25so3208671iah.19 for ; Fri, 07 Sep 2012 06:45:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=idLMi7G4qgWpISuS0QdsaMmqEO5eDEdQhXACKSetn5Q=; b=ZfhF3wK7tpVtkNu0qbpkJ8oEAkokBt8aNbhFGwgvJchlv3HH8UBuNE4u9o+yIonaQb gm4NohNae8IQIbTc1AhP1XseEzr2wJ8kaWLGO+xqyUR0dC1LBUIG292kpJo96Y2XMPPM geqOLsfVcFze516gPfsoFwpwzxP6iicIrI45FWsgE6umRGD7HDwsODkJz9yWfoLzoktw hAKWuR0aobimiZ6bunK8SoFhP8DYjeH6AGhGr6CsAEKCqV3yLrCTS9Y8RrHQMavLdJwv c8Rb69zmZ75SvHZm9+fm2YLFhfdatpRdvOj8g7Hbp/a21vzNiykiOA85GoXqKL5Q7hL/ rYaA== Received: by 10.50.57.202 with SMTP id k10mr8937723igq.45.1347025558793; Fri, 07 Sep 2012 06:45:58 -0700 (PDT) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPS id ud8sm12999965igb.4.2012.09.07.06.45.57 (version=SSLv3 cipher=OTHER); Fri, 07 Sep 2012 06:45:58 -0700 (PDT) Message-ID: <5049FA95.3040505@inktank.com> Date: Fri, 07 Sep 2012 08:45:57 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 5/7] rbd: simplify snap_by_name() interface References: <5049F951.2030706@inktank.com> In-Reply-To: <5049F951.2030706@inktank.com> X-Gm-Message-State: ALoCoQmijWe/q1RfnKf+Hfgo++aRs/v+F9udB0keYhBCZfYFOqvzircE8Pd0447sUQH7OGl1dmx6 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org 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 Reviewed-by: Josh Durgin --- 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; 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;