From patchwork Wed Mar 12 04:24:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guangliang Zhao X-Patchwork-Id: 3815481 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C25FBBF540 for ; Wed, 12 Mar 2014 04:25:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EAFF720173 for ; Wed, 12 Mar 2014 04:25:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16BCE2010C for ; Wed, 12 Mar 2014 04:25:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751298AbaCLEZb (ORCPT ); Wed, 12 Mar 2014 00:25:31 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:60070 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751025AbaCLEZB (ORCPT ); Wed, 12 Mar 2014 00:25:01 -0400 Received: by mail-pa0-f48.google.com with SMTP id hz1so526863pad.21 for ; Tue, 11 Mar 2014 21:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yY2yMjytbB+yob8wC/Qt9iK7dAu73jlai3FlNeC6C9k=; b=sTISY4k2P7g0XUkrEtVxrDsNLAAeCZ+2LulS/f+brRvXkpboLvQryiPiG7nRgpx+M8 OZe9meX6zKRHcxnLCOUMC3ecJFRfyzjHnUVNQRaE7RSmU5UVkIkzz1c41PebZgyh/1Vk Lli/ASqv7atO5H1IHpscCsi574MWclj4L5ze+SiUdFgKTCwJpIap0R1ZHtON/rbxxkuK u6vlLFWPHHkarOfxczY1OIl3kqm8cttP4Bo8nQTv6ASgzihmdYFvQpjgxEr6SOQYCQta bSPIG/LdbkzyRxtWMcfWk7XPnE3OTufKKd/MO0ZlJqBK9Rj176+AAPJ+GLwo2NWlPmQU QMUw== X-Received: by 10.66.231.104 with SMTP id tf8mr2291862pac.48.1394598300863; Tue, 11 Mar 2014 21:25:00 -0700 (PDT) Received: from localhost ([220.181.11.232]) by mx.google.com with ESMTPSA id sh5sm2614034pbc.21.2014.03.11.21.24.58 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 11 Mar 2014 21:25:00 -0700 (PDT) From: Guangliang Zhao To: ceph-devel@vger.kernel.org Cc: sage@inktank.com Subject: [PATCH 1/3] rbd: skip the copyup when an entire object writing Date: Wed, 12 Mar 2014 12:24:43 +0800 Message-Id: <1394598285-17225-2-git-send-email-lucienchao@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1394598285-17225-1-git-send-email-lucienchao@gmail.com> References: <1394598285-17225-1-git-send-email-lucienchao@gmail.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It need to copyup the parent's content when layered writing, but an entire object write would overwrite it, so skip it. Signed-off-by: Guangliang Zhao Reviewed-by: Alex Elder --- drivers/block/rbd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index b365e0d..965b9b9 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -2629,12 +2629,14 @@ static int rbd_img_obj_request_submit(struct rbd_obj_request *obj_request) struct rbd_img_request *img_request; struct rbd_device *rbd_dev; bool known; + u64 obj_size; rbd_assert(obj_request_img_data_test(obj_request)); img_request = obj_request->img_request; rbd_assert(img_request); rbd_dev = img_request->rbd_dev; + obj_size = (u64) 1 << rbd_dev->header.obj_order; /* * Only writes to layered images need special handling. @@ -2644,11 +2646,15 @@ static int rbd_img_obj_request_submit(struct rbd_obj_request *obj_request) * simple object requests. Finally, if the target object is * known to already exist, its parent data has already been * copied, so a write to the object can also be handled as a - * simple object request. + * simple object request. Another type: if the obj_request + * aligns with the boundary and equals to the size of an object, + * it doesn't need copyup, because the obj_request will overwrite + * it finally. */ if (!img_request_write_test(img_request) || !img_request_layered_test(img_request) || rbd_dev->parent_overlap <= obj_request->img_offset || + ((!obj_request->offset) && (obj_request->length == obj_size)) || ((known = obj_request_known_test(obj_request)) && obj_request_exists_test(obj_request))) {