From patchwork Wed Jul 31 01:36:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: majianpeng X-Patchwork-Id: 2836012 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 04BEB9F7D6 for ; Wed, 31 Jul 2013 01:38:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7D20620201 for ; Wed, 31 Jul 2013 01:38:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DC109201EE for ; Wed, 31 Jul 2013 01:38:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758667Ab3GaBij (ORCPT ); Tue, 30 Jul 2013 21:38:39 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:48341 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752619Ab3GaBii (ORCPT ); Tue, 30 Jul 2013 21:38:38 -0400 Received: by mail-pa0-f44.google.com with SMTP id jh10so238269pab.31 for ; Tue, 30 Jul 2013 18:38:38 -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=HE5pH+Im4va4YCwfo+DR9Shzwix+IE+idi1IpHPAgVI=; b=0LYUxZqOJChqtpx4m5d64HTk/RXcMinqMkWj+dz/Wu4a/qJpvYARqnCbLEU3vlTcNd LlCXsAUfYt1XI1tjHoA61ALl9+YIqC6d7XdgwA4lo2yn5tUAavLi6TSS5h0BCsDVKhJB B++CKTxllfySS2y91p4yHFNVtNCr93ffVCGxR0uiylP0RFN3Yhxi68Fk+7Zzxi1DedjS rq2UPd/f4GAAIcmetfXzmINR4ANqRSr7cQW+6FeMYHZqI3zOGSyR+lDvBMd2uX+Ga1aL 71gXt6d7Xok0s94pt9Mn4yN7yEgadKx7O7PBgKa+lf2fdHckVPXzVlk+W6L/SEsnQebc CbRg== X-Received: by 10.66.164.71 with SMTP id yo7mr78540452pab.92.1375234718417; Tue, 30 Jul 2013 18:38:38 -0700 (PDT) Received: from majianpeng ([218.242.10.182]) by mx.google.com with ESMTPSA id ll5sm993463pab.19.2013.07.30.18.36.54 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 30 Jul 2013 18:38:37 -0700 (PDT) Date: Wed, 31 Jul 2013 09:36:52 +0800 From: majianpeng To: sage Cc: =?gb2312?B?WWFuLCBaaGVuZw==?= , 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>, X-Priority: 3 X-GUID: 425969A9-FAFA-4F76-89A6-FDC87C9E59A8 X-Has-Attach: no X-Mailer: Foxmail 7.0.1.90[en] Mime-Version: 1.0 Message-ID: <201307310933358798964@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] I think this patch can do work: Those case which i tested A: filesize=0, buffer=1M B: data[2M] | hole| data[2M], bs= 6M/7M C: data[4m] | hole | hole |data[2M] bs=16M/18M Are there some case ignore? Thanks! Jianpeng Ma diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 2ddf061..96ce893 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -319,7 +319,7 @@ static int striped_read(struct inode *inode, int read; struct page **page_pos; int ret; - bool hit_stripe, was_short; + bool hit_stripe, was_short, hit_hole = false; /* * we may need to do multiple reads. not atomic, unfortunately. @@ -342,21 +342,30 @@ more: ci->i_truncate_seq, ci->i_truncate_size, page_pos, pages_left, page_align); - if (ret == -ENOENT) + + if ((ret == 0 || ret == -ENOENT) && pos < inode->i_size) + hit_hole = true; + else if (ret == -ENOENT) ret = 0; + hit_stripe = this_len < left; - was_short = ret >= 0 && ret < this_len; - dout("striped_read %llu~%u (read %u) got %d%s%s\n", pos, left, read, - 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); + was_short = ret > 0 && ret < this_len; + dout("striped_read %llu~%u (read %u) got %d%s%s%s\n", pos, left, read, + ret, hit_stripe ? " HITSTRIPE" : "", was_short ? " SHORT" : "", + hit_hole ? " HITHOLE" : ""); + + if (ret > 0 || hit_hole) { + int didpages; + + if (hit_hole) { + ret = this_len; + dout(" zero hole %llu to %llu\n", pos , pos + ret); + ceph_zero_page_vector_range(page_align + read, + ret, pages); + hit_hole = false; } + didpages = (page_align + ret) >> PAGE_CACHE_SHIFT; + pos += ret; read = pos - off; left -= ret;