From patchwork Tue Jul 30 11:01:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: majianpeng X-Patchwork-Id: 2835528 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 B0EFDC0319 for ; Tue, 30 Jul 2013 11:01:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0D61720303 for ; Tue, 30 Jul 2013 11:01:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 550E3202F9 for ; Tue, 30 Jul 2013 11:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751482Ab3G3LBt (ORCPT ); Tue, 30 Jul 2013 07:01:49 -0400 Received: from mail-pb0-f54.google.com ([209.85.160.54]:40461 "EHLO mail-pb0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751194Ab3G3LBs (ORCPT ); Tue, 30 Jul 2013 07:01:48 -0400 Received: by mail-pb0-f54.google.com with SMTP id ro12so2651892pbb.13 for ; Tue, 30 Jul 2013 04:01:48 -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=LEbCkK7LHtcK7YeJMEdf613g2PtKSkgdFaSnEKje2x0=; b=sUv8FOEw0NpLyssGEl191sJX8B3KAhheg3LUjKd8ATbt6ADXTyZ0n2NSlou3fbaw++ eZoYHCWn3Jewe9AS2nVll4sYelnZaJgKcOuIl2SDMrLj1qvudWwAW1tMFQ/rkogE6Lsp ev3iaRLqbcKZwLMz7+dfTz1Utr9pvMKoBa+nd2m+ZZ0LVXKLDhtv37WRBtCITW9rRKCn D8AQTns5YGv6nxRc0r/7dKWQ8qaNQBHNaadZ9z6yjNJsfkwgeAiKXZNj3YoSn2rFwq3z i5EwJJ62qyTyNPGy8RaFx9uwmgUH/WK759woy6T/yHvvdwuRglc5xJJ4lROznTBChNOM PB7A== X-Received: by 10.68.224.161 with SMTP id rd1mr73420485pbc.121.1375182108141; Tue, 30 Jul 2013 04:01:48 -0700 (PDT) Received: from majianpeng ([218.242.10.182]) by mx.google.com with ESMTPSA id kd1sm814807pab.20.2013.07.30.04.01.43 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 30 Jul 2013 04:01:46 -0700 (PDT) Date: Tue, 30 Jul 2013 19:01:43 +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> <201307251455102701172@gmail.com> <201307260848241340451@gmail.com> <201307260922285205344@gmail.com> <201307260938095935695@gmail.com> <201307261007003577701@gmail.com> <201307291100080913443@gmail.com>, X-Priority: 3 X-GUID: 4CF38993-5602-4090-9F26-F535F358FF55 X-Has-Attach: no X-Mailer: Foxmail 7.0.1.90[en] Mime-Version: 1.0 Message-ID: <201307301707312612641@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 >On Mon, Jul 29, 2013 at 11:00 AM, majianpeng wrote: >> >> [snip] >> >I don't think the later was_short can handle the hole case. For the hole case, >> >we should try reading next strip object instead of return. how about >> >below patch. >> > >> Hi Yan, >> i uesed this demo to test hole case. >> dd if=/dev/urandom bs=4096 count=2 of=file_with_holes >> dd if=/dev/urandom bs=4096 seek=7 count=2 of=file_with_holes >> >> dd if=file_with_holes of=/dev/null bs=16k count=1 iflag=direct >> Using the dynamic_debug in striped_read, the message are: >> >[ 8743.663499] ceph: file.c:350 : striped_read 0~16384 (read 0) got 16384 >> >[ 8743.663502] ceph: file.c:390 : striped_read returns 16384 >> From the messages, we can see it can't hit the short-read. >> For the ceph-file-hole, how does the ceph handle? >> Or am i missing something? > >the default strip size is 4M, all data are written to the first object >in your test case. >could you try something like below. > >dd if=/dev/urandom bs=1M count=2 of=file_with_holes >dd if=/dev/urandom bs=1M count=2 seek=4 of=file_with_holes conv=notrunc >dd if=file_with_holes bs=8M >/dev/null > This patch can do those case. It only add ret== 0 in judgement 'ret > 0". But i think i will add a parameter about hit_hole. It will make the code easy to understand. >Regards >Yan, Zheng > > >> >> >> Thanks! >> Jianpeng Ma >> >> >Regards >> >Yan, Zheng >> >--- >> >diff --git a/fs/ceph/file.c b/fs/ceph/file.c >> >index 271a346..6ca2921 100644 >> >--- a/fs/ceph/file.c >> >+++ b/fs/ceph/file.c >> >@@ -350,16 +350,17 @@ more: >> > ret, hit_stripe ? " HITSTRIPE" : "", was_short ? " SHORT" : ""); >> > >> > if (ret > 0) { >> >- int didpages = (page_align + ret) >> PAGE_CACHE_SHIFT; >> >+ int didpages = (page_align + this_len) >> 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); >> >+ if (was_short) { >> >+ dout(" zero gap %llu to %llu\n", >> >+ pos + ret, pos + this_len); >> >+ ceph_zero_page_vector_range(page_align + ret, >> >+ this_len - ret, page_pos); >> > } >> >- pos += ret; >> >+ pos += this_len; >> > read = pos - off; >> >- left -= ret; >> >+ left -= this_len; >> > page_pos += didpages; >> > pages_left -= didpages; >> > Thanks! Jianpeng Ma >On Mon, Jul 29, 2013 at 11:00 AM, majianpeng wrote: >> >> [snip] >> >I don't think the later was_short can handle the hole case. For the hole case, >> >we should try reading next strip object instead of return. how about >> >below patch. >> > >> Hi Yan, >> i uesed this demo to test hole case. >> dd if=/dev/urandom bs=4096 count=2 of=file_with_holes >> dd if=/dev/urandom bs=4096 seek=7 count=2 of=file_with_holes >> >> dd if=file_with_holes of=/dev/null bs=16k count=1 iflag=direct >> Using the dynamic_debug in striped_read, the message are: >> >[ 8743.663499] ceph: file.c:350 : striped_read 0~16384 (read 0) got 16384 >> >[ 8743.663502] ceph: file.c:390 : striped_read returns 16384 >> From the messages, we can see it can't hit the short-read. >> For the ceph-file-hole, how does the ceph handle? >> Or am i missing something? > >the default strip size is 4M, all data are written to the first object >in your test case. >could you try something like below. > >dd if=/dev/urandom bs=1M count=2 of=file_with_holes >dd if=/dev/urandom bs=1M count=2 seek=4 of=file_with_holes conv=notrunc >dd if=file_with_holes bs=8M >/dev/null > >Regards >Yan, Zheng > > >> >> >> Thanks! >> Jianpeng Ma >> >> >Regards >> >Yan, Zheng >> >--- >> >diff --git a/fs/ceph/file.c b/fs/ceph/file.c >> >index 271a346..6ca2921 100644 >> >--- a/fs/ceph/file.c >> >+++ b/fs/ceph/file.c >> >@@ -350,16 +350,17 @@ more: >> > ret, hit_stripe ? " HITSTRIPE" : "", was_short ? " SHORT" : ""); >> > >> > if (ret > 0) { >> >- int didpages = (page_align + ret) >> PAGE_CACHE_SHIFT; >> >+ int didpages = (page_align + this_len) >> 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); >> >+ if (was_short) { >> >+ dout(" zero gap %llu to %llu\n", >> >+ pos + ret, pos + this_len); >> >+ ceph_zero_page_vector_range(page_align + ret, >> >+ this_len - ret, page_pos); >> > } >> >- pos += ret; >> >+ pos += this_len; >> > read = pos - off; >> >- left -= ret; >> >+ left -= this_len; >> > page_pos += didpages; >> > pages_left -= didpages; >> > diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 2ddf061..22a98e5 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -349,17 +349,17 @@ more: 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 (ret >= 0) { + int didpages = (page_align + this_len) >> 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); + if (was_short) { + dout(" zero gap %llu to %llu\n", pos + ret, pos + this_len); + ceph_zero_page_vector_range(page_align + ret, + this_len - ret, pages); } - pos += ret; + pos += this_len; read = pos - off; - left -= ret; + left -= this_len; page_pos += didpages; pages_left -= didpages;