From patchwork Sun Apr 21 21:17:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2469501 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 31A83DF230 for ; Sun, 21 Apr 2013 21:17:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751853Ab3DUVRO (ORCPT ); Sun, 21 Apr 2013 17:17:14 -0400 Received: from mail-ia0-f174.google.com ([209.85.210.174]:58906 "EHLO mail-ia0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751720Ab3DUVRO (ORCPT ); Sun, 21 Apr 2013 17:17:14 -0400 Received: by mail-ia0-f174.google.com with SMTP id h23so219053iae.33 for ; Sun, 21 Apr 2013 14:17:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=Y2d/hNM0hCMjXv1LEqqn+NWiDYQf+Od7fJbHLQAZ2wk=; b=MgYGru7QwjrckIbv+S0Ip2gYg7NcN5uTw1yrt4RlZ8+2hqI8wzL2yYEa2kbGUzju2P JZeYdg1qUhrenzfAi18RcZgTtPfJ2fGnrDL0tcxDD1dxh3BpbN8xNhccUqO7+Ao3/BdY kDYzd9YZQyqNe154jWekv91vgt+B4WcYO9rjQRBavOj9M1skrLQclQkktNbLGN6+pB/o ShSIVIVDTOpAEh796wJk4sIFLEkI6bf7vhVPBBxgEtGoANY/F+qEK4iaPr76+drJa1Nf ZfAmG72PUxBBqVzVHaisRnppeDTvAjpb+d9RF134QEkbhYkOR/3mOv1ytpDvb4Gq/bs9 2y0Q== X-Received: by 10.50.11.18 with SMTP id m18mr2402135igb.98.1366579033556; Sun, 21 Apr 2013 14:17:13 -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 ESMTPSA id ua6sm12933298igb.0.2013.04.21.14.17.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 21 Apr 2013 14:17:12 -0700 (PDT) Message-ID: <51745757.4070307@inktank.com> Date: Sun, 21 Apr 2013 16:17:11 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 2/2] rbd: void data pointers for rbd_obj_method_sync() References: <5174571C.4010203@inktank.com> In-Reply-To: <5174571C.4010203@inktank.com> X-Gm-Message-State: ALoCoQk66rhCCO2qkQ29AMHNETe1ie02XHvQOxu6dREso+ZlLw3Cb6j5APQAoYpBlX5rsN+bFRzw Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Make the inbound and outbound data parameters have void rather than character type for rbd_obj_method_sync(). This makes it more clear they don't expect typed data, and eliminates the need for some silly type casts. One more unrelated change: define the features buffer used in _rbd_dev_v2_snap_features() to be a packed data structure. Signed-off-by: Alex Elder --- drivers/block/rbd.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) { @@ -3577,8 +3577,8 @@ static int _rbd_dev_v2_snap_size(struct rbd_device *rbd_dev, u64 snap_id, ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_name, "rbd", "get_size", - (char *) &snapid, sizeof (snapid), - (char *) &size_buf, sizeof (size_buf), NULL); + &snapid, sizeof (snapid), + &size_buf, sizeof (size_buf), NULL); dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret); if (ret < 0) return ret; @@ -3611,8 +3611,7 @@ static int rbd_dev_v2_object_prefix(struct rbd_device *rbd_dev) return -ENOMEM; ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_name, - "rbd", "get_object_prefix", - NULL, 0, + "rbd", "get_object_prefix", NULL, 0, reply_buf, RBD_OBJ_PREFIX_LEN_MAX, NULL); dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret); if (ret < 0) @@ -3643,15 +3642,14 @@ static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id, struct { __le64 features; __le64 incompat; - } features_buf = { 0 }; + } __attribute__ ((packed)) features_buf = { 0 }; u64 incompat; int ret; ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_name, "rbd", "get_features", - (char *) &snapid, sizeof (snapid), - (char *) &features_buf, sizeof (features_buf), - NULL); + &snapid, sizeof (snapid), + &features_buf, sizeof (features_buf), NULL); dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret); if (ret < 0) return ret; @@ -3705,15 +3703,15 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev) snapid = cpu_to_le64(CEPH_NOSNAP); ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_name, "rbd", "get_parent", - (char *) &snapid, sizeof (snapid), - (char *) reply_buf, size, NULL); + &snapid, sizeof (snapid), + reply_buf, size, NULL); dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret); if (ret < 0) goto out_err; ret = -ERANGE; p = reply_buf; - end = (char *) reply_buf + size; + end = reply_buf + size; ceph_decode_64_safe(&p, end, parent_spec->pool_id, out_err); if (parent_spec->pool_id == CEPH_NOPOOL) goto out; /* No parent? No problem. */ @@ -3766,7 +3764,7 @@ static char *rbd_dev_image_name(struct rbd_device *rbd_dev) return NULL; p = image_id; - end = (char *) image_id + image_id_size; + end = image_id + image_id_size; ceph_encode_string(&p, end, rbd_dev->spec->image_id, (u32) len); size = sizeof (__le32) + RBD_IMAGE_NAME_LEN_MAX; @@ -3777,11 +3775,11 @@ static char *rbd_dev_image_name(struct rbd_device *rbd_dev) ret = rbd_obj_method_sync(rbd_dev, RBD_DIRECTORY, "rbd", "dir_get_name", image_id, image_id_size, - (char *) reply_buf, size, NULL); + reply_buf, size, NULL); if (ret < 0) goto out; p = reply_buf; - end = (char *) reply_buf + size; + end = reply_buf + size; image_name = ceph_extract_encoded_string(&p, end, &len, GFP_KERNEL); if (IS_ERR(image_name)) image_name = NULL; @@ -3830,7 +3828,7 @@ static int rbd_dev_probe_update_spec(struct rbd_device *rbd_dev) name = rbd_dev_image_name(rbd_dev); if (name) - rbd_dev->spec->image_name = (char *) name; + rbd_dev->spec->image_name = (char *)name; else rbd_warn(rbd_dev, "unable to get image name"); @@ -3881,8 +3879,7 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev, u64 *ver) return -ENOMEM; ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_name, - "rbd", "get_snapcontext", - NULL, 0, + "rbd", "get_snapcontext", NULL, 0, reply_buf, size, ver); dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret); if (ret < 0) @@ -3890,7 +3887,7 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev, u64 *ver) ret = -ERANGE; p = reply_buf; - end = (char *) reply_buf + size; + end = reply_buf + size; ceph_decode_64_safe(&p, end, seq, out); ceph_decode_32_safe(&p, end, snap_count, out); @@ -3951,14 +3948,14 @@ static char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev, u32 which) snap_id = cpu_to_le64(rbd_dev->header.snapc->snaps[which]); ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_name, "rbd", "get_snapshot_name", - (char *) &snap_id, sizeof (snap_id), + &snap_id, sizeof (snap_id), reply_buf, size, NULL); dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret); if (ret < 0) goto out; p = reply_buf; - end = (char *) reply_buf + size; + end = reply_buf + size; snap_name = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL); if (IS_ERR(snap_name)) { ret = PTR_ERR(snap_name); @@ -4554,8 +4551,7 @@ static int rbd_dev_image_id(struct rbd_device *rbd_dev) } ret = rbd_obj_method_sync(rbd_dev, object_name, - "rbd", "get_id", - NULL, 0, + "rbd", "get_id", NULL, 0, response, RBD_IMAGE_ID_LEN_MAX, NULL); dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret); if (ret < 0) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index e6da301..46d9bf7 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -2623,9 +2623,9 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev, const char *object_name, const char *class_name, const char *method_name, - const char *outbound, + const void *outbound, size_t outbound_size, - char *inbound, + void *inbound, size_t inbound_size, u64 *version)