From patchwork Thu Jul 19 21:09:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1218621 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 B112B3FD48 for ; Thu, 19 Jul 2012 21:09:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751856Ab2GSVJH (ORCPT ); Thu, 19 Jul 2012 17:09:07 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:40265 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751739Ab2GSVJG (ORCPT ); Thu, 19 Jul 2012 17:09:06 -0400 Received: by mail-yx0-f174.google.com with SMTP id l2so3302595yen.19 for ; Thu, 19 Jul 2012 14:09:06 -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=QmuKsp06LVa+iR6CTwaM9PxsMrlgV1noFuhEDF7dOx4=; b=TuXG+mFnV5TE9Kk720fXs7UntFb5EFL8Z1dtJyDK+tQ4ANhoQmXAa7/sbMKHWggbAv 6u8Z6akJYsGfJ10SRYLzD2yyZAk5wpHuX6LefA/8ZG46TVbHSU3vE3vgxPUwvzzUdtlH 9N0UHBoWn6qDx3pUeRfji1CP0OURPBbOLilESTJsedxN8tg1Mdwuu6GAsSF9jrc3dmSv OnvbC0GsMLguaKpkxdG2g8xgZ+CtcUKe8lXNXGnCry/6X4wyGMMojOssEZBXn95PJFn4 rBsdepwWrMKugARoBHwQd1kXkwznjT8fnGDNLthKR2Qo/Cq+v8M7UmqPf3yxEciE15hm RhIQ== Received: by 10.50.213.106 with SMTP id nr10mr6495974igc.58.1342732145856; Thu, 19 Jul 2012 14:09:05 -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 ay5sm17810943igb.15.2012.07.19.14.09.05 (version=SSLv3 cipher=OTHER); Thu, 19 Jul 2012 14:09:05 -0700 (PDT) Message-ID: <50087770.6060307@inktank.com> Date: Thu, 19 Jul 2012 16:09:04 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 11/12] rbd: always pass ops array to rbd_req_sync_op() References: <500874F5.4090205@inktank.com> In-Reply-To: <500874F5.4090205@inktank.com> X-Gm-Message-State: ALoCoQkFBMjTlottTbYFE+GE3RGDuQ+aLccIG/IOzJkO0oJVXj2ochyIHIe/IuoVJNS+Etr/85+m Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org All of the callers of rbd_req_sync_op() except one pass a non-null "ops" pointer. The only one that does not is rbd_req_sync_read(), which passes CEPH_OSD_OP_READ as its "opcode" and, CEPH_OSD_FLAG_READ for "flags". By allocating the ops array in rbd_req_sync_read() and moving the special case code for the null ops pointer into it, it becomes clear that much of that code is not even necessary. In addition, the "opcode" argument to rbd_req_sync_op() is never actually used, so get rid of that. Signed-off-by: Alex Elder --- drivers/block/rbd.c | 46 ++++++++++++++++------------------------------ 1 files changed, 16 insertions(+), 30 deletions(-) char *buf, @@ -1025,28 +1024,14 @@ static int rbd_req_sync_op(struct rbd_device *rbd_dev, int ret; struct page **pages; int num_pages; - struct ceph_osd_req_op *ops = orig_ops; - u32 payload_len; + + BUG_ON(ops == NULL); num_pages = calc_pages_for(ofs , len); pages = ceph_alloc_page_vector(num_pages, GFP_KERNEL); if (IS_ERR(pages)) return PTR_ERR(pages); - if (!orig_ops) { - payload_len = (flags & CEPH_OSD_FLAG_WRITE ? len : 0); - ret = -ENOMEM; - ops = rbd_create_rw_ops(1, opcode, payload_len); - if (!ops) - goto done; - - if ((flags & CEPH_OSD_FLAG_WRITE) && buf) { - ret = ceph_copy_to_page_vector(pages, buf, ofs, len); - if (ret < 0) - goto done_ops; - } - } - ret = rbd_do_request(NULL, rbd_dev, snapc, snapid, object_name, ofs, len, NULL, pages, num_pages, @@ -1056,14 +1041,11 @@ static int rbd_req_sync_op(struct rbd_device *rbd_dev, NULL, linger_req, ver); if (ret < 0) - goto done_ops; + goto done; if ((flags & CEPH_OSD_FLAG_READ) && buf) ret = ceph_copy_from_page_vector(pages, buf, ofs, ret); -done_ops: - if (!orig_ops) - rbd_destroy_ops(ops); done: ceph_release_page_vector(pages, num_pages); return ret; @@ -1170,12 +1152,20 @@ static int rbd_req_sync_read(struct rbd_device *rbd_dev, char *buf, u64 *ver) { - return rbd_req_sync_op(rbd_dev, NULL, + struct ceph_osd_req_op *ops; + int ret; + + ops = rbd_create_rw_ops(1, CEPH_OSD_OP_READ, 0); + if (!ops) + return -ENOMEM; + + ret = rbd_req_sync_op(rbd_dev, NULL, snapid, - CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, - NULL, - object_name, ofs, len, buf, NULL, ver); + ops, object_name, ofs, len, buf, NULL, ver); + rbd_destroy_ops(ops); + + return ret; } /* @@ -1257,7 +1247,6 @@ static int rbd_req_sync_watch(struct rbd_device *rbd_dev, ret = rbd_req_sync_op(rbd_dev, NULL, CEPH_NOSNAP, - 0, CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, ops, object_name, 0, 0, NULL, @@ -1296,7 +1285,6 @@ static int rbd_req_sync_unwatch(struct rbd_device *rbd_dev, ret = rbd_req_sync_op(rbd_dev, NULL, CEPH_NOSNAP, - 0, CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, ops, object_name, 0, 0, NULL, NULL, NULL); @@ -1353,7 +1341,6 @@ static int rbd_req_sync_notify(struct rbd_device *rbd_dev, ret = rbd_req_sync_op(rbd_dev, NULL, CEPH_NOSNAP, - 0, CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, ops, object_name, 0, 0, NULL, NULL, NULL); @@ -1402,7 +1389,6 @@ static int rbd_req_sync_exec(struct rbd_device *rbd_dev, ret = rbd_req_sync_op(rbd_dev, NULL, CEPH_NOSNAP, - 0, CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, ops, object_name, 0, 0, NULL, NULL, NULL); diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 0535612..6279186 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1013,9 +1013,8 @@ static void rbd_simple_req_cb(struct ceph_osd_request *req, struct ceph_msg *msg static int rbd_req_sync_op(struct rbd_device *rbd_dev, struct ceph_snap_context *snapc, u64 snapid, - int opcode, int flags, - struct ceph_osd_req_op *orig_ops, + struct ceph_osd_req_op *ops, const char *object_name, u64 ofs, u64 len,