From patchwork Wed Jul 31 07:32:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: majianpeng X-Patchwork-Id: 2836127 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 CE041C0319 for ; Wed, 31 Jul 2013 07:32:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B89B201B2 for ; Wed, 31 Jul 2013 07:32:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B34120198 for ; Wed, 31 Jul 2013 07:32:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759138Ab3GaHcN (ORCPT ); Wed, 31 Jul 2013 03:32:13 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:59394 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754795Ab3GaHcN (ORCPT ); Wed, 31 Jul 2013 03:32:13 -0400 Received: by mail-pd0-f174.google.com with SMTP id 10so432610pdc.33 for ; Wed, 31 Jul 2013 00:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:reply-to:subject:references:x-priority:x-guid :x-has-attach:x-mailer:mime-version:message-id:content-type :content-transfer-encoding; bh=k8LwP8R6XLyiYUBC+WDfIgGjPO0z1mXP4ui/V67WMuM=; b=ZSCePdwrnnxF+spq6YhHL/o46VJuiIImRT8Dfrj13q/HBXo/SXrI6ARy5TcDUvxto1 V3hyuahlDCbHBCYDJ4oaAaGApxJT6p4hbHBTWpZHdkjzMDPL10FULgoxlUwPf/eQ7+aD j8Hqjo/0tZQsOh4qb12k8geL7d1orDHKOv7/NKLCHbjltApJtSirPw06gfeMFa+BjxwK vKqAiyc0FZmuC9aYa4rh/KNA2x15THo8GlkadR7HTFBDUc8ddHDl0RGjDAMCpfwh5LKQ qe8kQ//TlLpAnD+FM/UUuAmmKnqnjZgbQUnN5fZSSjtgVyr0+2d18qNU/RP69s1ul0u6 Kl0A== X-Received: by 10.68.232.41 with SMTP id tl9mr78540888pbc.204.1375255932530; Wed, 31 Jul 2013 00:32:12 -0700 (PDT) Received: from majianpeng ([218.242.10.182]) by mx.google.com with ESMTPSA id mr3sm426942pbb.27.2013.07.31.00.32.09 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 31 Jul 2013 00:32:11 -0700 (PDT) Date: Wed, 31 Jul 2013 15:32:08 +0800 From: majianpeng To: =?gb2312?B?WWFuLCBaaGVuZw==?= Cc: sage , ceph-devel Reply-To: majianpeng Subject: Re: Re: question about striped_read References: <201307250852310158703@gmail.com> <201307260848241340451@gmail.com> <201307260922285205344@gmail.com> <201307260938095935695@gmail.com> <201307261007003577701@gmail.com> <201307291100080913443@gmail.com> <201307301707312612641@gmail.com> <201307301941552785741@gmail.com> <201307310827296030660@gmail.com> <201307310844488455702@gmail.com> <201307310933358798964@gmail.com> <2013073113222469570311@gmail.com>, X-Priority: 3 X-GUID: E9E2A61E-870D-4D14-AC66-6DB783B15E29 X-Has-Attach: no X-Mailer: Foxmail 7.0.1.90[en] Mime-Version: 1.0 Message-ID: <201307311532055128853@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=-8.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 [snip] Test case A: touch file dd if=file of=/dev/null bs=5M count=1 iflag=direct B: [data(2M)|hole(2m)][data(2M)] dd if=file of=/dev/null bs=8M count=1 iflag=direct C: [data(4M)[hole(4M)][hole(4M)][data(2M)] dd if=file of=/dev/null bs=16M count=1 iflag=direct D: touch file;truncate -s 5M file dd if=file of=/dev/null bs=8M count=1 iflag=direct Those cases can work. Now i make different processing for short-read between 'ret > 0' and "ret =0". For the short-read which ret > 0, it don't do read-page rather than zero the left area. This means reduce one meaningless read operation. + tmp, pages); + ret += tmp; } + didpages = (page_align + ret) >> PAGE_CACHE_SHIFT; pos += ret; read = pos - off; left -= ret; @@ -375,13 +379,25 @@ more: /* zero trailing bytes (inside i_size) */ if (left > 0 && pos < inode->i_size) { + int didpages; if (pos + left > inode->i_size) left = inode->i_size - pos; - dout("zero tail %d\n", left); - ceph_zero_page_vector_range(page_align + read, left, + ret = min(left, this_len); + dout("zero tail %d\n", ret); + ceph_zero_page_vector_range(page_align + read, ret, pages); - read += left; + didpages = (page_align + ret) >> PAGE_CACHE_SHIFT; + + pos += ret; + read = pos - off; + left -= ret; + page_pos += didpages; + pages_left -= didpages; + + /* hit stripe? */ + if (left && hit_stripe) + goto more; } } diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 2ddf061..f643ec8 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -350,13 +350,17 @@ more: ret, hit_stripe ? " HITSTRIPE" : "", was_short ? " SHORT" : ""); if (ret > 0) { - int didpages = (page_align + ret) >> PAGE_CACHE_SHIFT; - - if (read < pos - off) { diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 2ddf061..f643ec8 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -350,13 +350,17 @@ more: ret, hit_stripe ? " HITSTRIPE" : "", was_short ? " SHORT" : ""); if (ret > 0) { - int didpages = (page_align + ret) >> PAGE_CACHE_SHIFT; - - if (read < pos - off) { - dout(" zero gap %llu to %llu\n", off + read, pos); - ceph_zero_page_vector_range(page_align + read, - pos - off - read, pages); + int didpages; + + if (was_short && pos + ret < inode->i_size) { + u64 tmp = min(this_len - ret, + inode->i_size - pos - ret); + dout(" zero gap %llu to %llu\n", pos + ret, pos + ret + tmp); + ceph_zero_page_vector_range(page_align + read + ret,