From patchwork Fri Apr 19 22:50:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2467431 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 8A77B3FD8C for ; Fri, 19 Apr 2013 22:50:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964919Ab3DSWuG (ORCPT ); Fri, 19 Apr 2013 18:50:06 -0400 Received: from mail-ie0-f173.google.com ([209.85.223.173]:64670 "EHLO mail-ie0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964846Ab3DSWuF (ORCPT ); Fri, 19 Apr 2013 18:50:05 -0400 Received: by mail-ie0-f173.google.com with SMTP id k5so5241221iea.32 for ; Fri, 19 Apr 2013 15:50:04 -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=J/WzISTgnYjRiwbk74u40NvHArv8WEuTdZVQkzwJums=; b=KTWtAMrF0ttRdytoY4jclU1fA9mM29h+5UGblrXurm/K6s2zjtSRYJEni+k/xgWVNl X6t/02/wykxvLS7xU/7TYWiT9hevBXaRv+1TIQ+c1pzzmN4izikbZF3og4xgWsIctSid 9iZVuab0mWrn0lfdbI6/ErTh4MM99WaonVLUERK7bOeF95euT12PBVIR5rbeUwKBvK2g omDk71+7rbi+yB8skPFyjf/tppwmdWFfciRLgTjFAmLpddhwJgACdVLD4UPB2dMKB0FP YuEn/rIV0Fm2hhNwg4+6mih+enS1vtU26CADSygTo76raXPzA92MBleyFqp9T7TZ3Wnh npxQ== X-Received: by 10.50.212.105 with SMTP id nj9mr2946514igc.17.1366411804215; Fri, 19 Apr 2013 15:50:04 -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 wn10sm4973570igb.2.2013.04.19.15.50.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Apr 2013 15:50:03 -0700 (PDT) Message-ID: <5171CA1A.6010908@inktank.com> Date: Fri, 19 Apr 2013 17:50:02 -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 2/4] rbd: encapsulate submission of image object requests References: <5171C963.2050402@inktank.com> In-Reply-To: <5171C963.2050402@inktank.com> X-Gm-Message-State: ALoCoQlTo9MZ4N0iqaCsc+l+JPpMHBTijbu0uGbimSVckrsz0tJjTCKmi1KOtUNrWojPparTuPwf Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Object requests that are part of an image request are subject to some additional handling. Define rbd_img_obj_request_submit() to encapsulate that, and use it when initially submitting an image object request, and when re-submitting it during callback of an object existence check. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 65 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 22 deletions(-) static int rbd_dev_v2_refresh(struct rbd_device *rbd_dev, u64 *hver); @@ -1874,8 +1875,6 @@ out_unwind: static void rbd_img_obj_exists_callback(struct rbd_obj_request *obj_request) { - struct rbd_device *rbd_dev; - struct ceph_osd_client *osdc; struct rbd_obj_request *orig_request; int result; @@ -1901,8 +1900,6 @@ static void rbd_img_obj_exists_callback(struct rbd_obj_request *obj_request) rbd_assert(orig_request); rbd_assert(orig_request->img_request); - rbd_dev = orig_request->img_request->rbd_dev; - osdc = &rbd_dev->rbd_client->client->osdc; /* * Our only purpose here is to determine whether the object @@ -1923,7 +1920,7 @@ static void rbd_img_obj_exists_callback(struct rbd_obj_request *obj_request) * Resubmit the original request now that we have recorded * whether the target object exists. */ - orig_request->result = rbd_obj_request_submit(osdc, orig_request); + orig_request->result = rbd_img_obj_request_submit(orig_request); out_err: if (orig_request->result) rbd_obj_request_complete(orig_request); @@ -1987,32 +1984,56 @@ out: return ret; } +static int rbd_img_obj_request_submit(struct rbd_obj_request *obj_request) +{ + struct rbd_img_request *img_request; + + rbd_assert(obj_request_img_data_test(obj_request)); + + img_request = obj_request->img_request; + rbd_assert(img_request); + + /* (At the moment we don't care whether it exists or not...) */ + (void) obj_request_exists_test; + + /* + * Only layered writes need special handling. If it's not a + * layered write, or it is a layered write but we know the + * target object exists, it's no different from any other + * object request. + */ + if (!img_request_write_test(img_request) || + !img_request_layered_test(img_request) || + obj_request_known_test(obj_request)) { + + struct rbd_device *rbd_dev; + struct ceph_osd_client *osdc; + + rbd_dev = obj_request->img_request->rbd_dev; + osdc = &rbd_dev->rbd_client->client->osdc; + + return rbd_obj_request_submit(osdc, obj_request); + } + + /* + * It's a layered write and we don't know whether the target + * exists. Issue existence check; once that completes the + * original request will be submitted again. + */ + + return rbd_img_obj_exists_submit(obj_request); +} + static int rbd_img_request_submit(struct rbd_img_request *img_request) { - struct rbd_device *rbd_dev = img_request->rbd_dev; - struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; struct rbd_obj_request *obj_request; struct rbd_obj_request *next_obj_request; - bool write_request = img_request_write_test(img_request); - bool layered = img_request_layered_test(img_request); dout("%s: img %p\n", __func__, img_request); for_each_obj_request_safe(img_request, obj_request, next_obj_request) { - bool known; - bool object_exists; int ret; - /* - * We need to know whether the target object exists - * for a layered write. Issue an existence check - * first if we need to. - */ - known = obj_request_known_test(obj_request); - object_exists = known && obj_request_exists_test(obj_request); - if (!write_request || !layered || object_exists) - ret = rbd_obj_request_submit(osdc, obj_request); - else - ret = rbd_img_obj_exists_submit(obj_request); + ret = rbd_img_obj_request_submit(obj_request); if (ret) return ret; } diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index a185239..894af4f 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -423,6 +423,7 @@ void rbd_warn(struct rbd_device *rbd_dev, const char *fmt, ...) #endif /* !RBD_DEBUG */ static void rbd_img_parent_read(struct rbd_obj_request *obj_request); +static int rbd_img_obj_request_submit(struct rbd_obj_request *obj_request); static int rbd_dev_refresh(struct rbd_device *rbd_dev, u64 *hver);