From patchwork Fri Apr 19 22:49:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2467421 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 6FABE3FD8C for ; Fri, 19 Apr 2013 22:49:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964911Ab3DSWtw (ORCPT ); Fri, 19 Apr 2013 18:49:52 -0400 Received: from mail-ia0-f171.google.com ([209.85.210.171]:53779 "EHLO mail-ia0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964846Ab3DSWtw (ORCPT ); Fri, 19 Apr 2013 18:49:52 -0400 Received: by mail-ia0-f171.google.com with SMTP id f27so3892524iae.2 for ; Fri, 19 Apr 2013 15:49:51 -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=YqwlyJ9ANnRxpz6PVrZKBqDwPA87+cOR/YfaOYA5v4A=; b=lotK+Enqgo6Umu1QzRjOaIuHMtBFy8NQpN5Kdzxt4ARTCY0A/tJugwzXPzy8xGEbnp ULn7s5TZlvfudQMy3VSKpMlOYRDTuzJVDijpTK+nX6WLxhN2wS5j6EknAAKN6Ji4mN73 Sig8o+GXwa65ZZliRKxK9pcyc8pDKq4VYUKINHHLWSrPxjQEF7J13u27v4vBhB6Mg+mn 8NuE6ya4ksb0owP5VmD49xRI3mV/9/xASEPMmLeAM6G1Yqfna35Gbx0Y4olFiqHJVbFq cBBJUcers72UMiB0w4TJcggov4B73v2SfG0vKuUZ7nD0rgcXMt3KjPbGUz2GunVd4SCC Aj5A== X-Received: by 10.50.20.135 with SMTP id n7mr3241290ige.31.1366411791880; Fri, 19 Apr 2013 15:49:51 -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 wn10sm4977217igb.2.2013.04.19.15.49.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Apr 2013 15:49:51 -0700 (PDT) Message-ID: <5171CA0E.3020402@inktank.com> Date: Fri, 19 Apr 2013 17:49:50 -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 Subject: [PATCH 1/4] rbd: define separate read and write format funcs References: <5171C963.2050402@inktank.com> In-Reply-To: <5171C963.2050402@inktank.com> X-Gm-Message-State: ALoCoQkY5HV82SoXrhVL+Bsl0xjRLlzEVZukaGshdSEO2AnwHRAtfbNVY+shgl9emgBHYjIFuhku Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Separate rbd_osd_req_format() into two functions, one for read requests and the other for write requests. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) static struct ceph_osd_request *rbd_osd_req_create( @@ -1845,7 +1848,11 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request, 0, 0); osd_req_op_extent_osd_data_bio(osd_req, 0, obj_request->bio_list, obj_request->length); - rbd_osd_req_format(obj_request, write_request); + + if (write_request) + rbd_osd_req_format_write(obj_request); + else + rbd_osd_req_format_read(obj_request); obj_request->img_offset = img_offset; rbd_img_obj_request_add(img_request, obj_request); @@ -1969,7 +1976,7 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request) osd_req_op_init(stat_request->osd_req, 0, CEPH_OSD_OP_STAT); osd_req_op_raw_data_in_pages(stat_request->osd_req, 0, pages, size, 0, false, false); - rbd_osd_req_format(stat_request, false); + rbd_osd_req_format_read(stat_request); osdc = &rbd_dev->rbd_client->client->osdc; ret = rbd_obj_request_submit(osdc, stat_request); @@ -2091,7 +2098,7 @@ static int rbd_obj_notify_ack(struct rbd_device *rbd_dev, osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_NOTIFY_ACK, notify_id, ver, 0); - rbd_osd_req_format(obj_request, false); + rbd_osd_req_format_read(obj_request); ret = rbd_obj_request_submit(osdc, obj_request); out: @@ -2161,7 +2168,7 @@ static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, int start) osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_WATCH, rbd_dev->watch_event->cookie, rbd_dev->header.obj_version, start); - rbd_osd_req_format(obj_request, true); + rbd_osd_req_format_write(obj_request); ret = rbd_obj_request_submit(osdc, obj_request); if (ret) @@ -2262,7 +2269,7 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev, osd_req_op_cls_response_data_pages(obj_request->osd_req, 0, obj_request->pages, inbound_size, 0, false, false); - rbd_osd_req_format(obj_request, false); + rbd_osd_req_format_read(obj_request); ret = rbd_obj_request_submit(osdc, obj_request); if (ret) @@ -2473,7 +2480,7 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev, obj_request->length, obj_request->offset & ~PAGE_MASK, false, false); - rbd_osd_req_format(obj_request, false); + rbd_osd_req_format_read(obj_request); ret = rbd_obj_request_submit(osdc, obj_request); if (ret) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index ce2fb3a..a185239 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1489,28 +1489,31 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, rbd_obj_request_complete(obj_request); } -static void rbd_osd_req_format(struct rbd_obj_request *obj_request, - bool write_request) +static void rbd_osd_req_format_read(struct rbd_obj_request *obj_request) { struct rbd_img_request *img_request = obj_request->img_request; struct ceph_osd_request *osd_req = obj_request->osd_req; - struct ceph_snap_context *snapc = NULL; - u64 snap_id = CEPH_NOSNAP; - struct timespec *mtime = NULL; - struct timespec now; + u64 snap_id; rbd_assert(osd_req != NULL); - if (write_request) { - now = CURRENT_TIME; - mtime = &now; - if (img_request) - snapc = img_request->snapc; - } else if (img_request) { - snap_id = img_request->snap_id; - } + snap_id = img_request ? img_request->snap_id : CEPH_NOSNAP; + ceph_osdc_build_request(osd_req, obj_request->offset, + NULL, snap_id, NULL); +} + +static void rbd_osd_req_format_write(struct rbd_obj_request *obj_request) +{ + struct rbd_img_request *img_request = obj_request->img_request; + struct ceph_osd_request *osd_req = obj_request->osd_req; + struct ceph_snap_context *snapc; + struct timespec mtime = CURRENT_TIME; + + rbd_assert(osd_req != NULL); + + snapc = img_request ? img_request->snapc : NULL; ceph_osdc_build_request(osd_req, obj_request->offset, - snapc, snap_id, mtime); + snapc, CEPH_NOSNAP, &mtime); }