From: majianpeng <majianpeng@gmail.com>
To: "Yan, Zheng" <ukernel@gmail.com>
Cc: sage <sage@inktank.com>, ceph-devel <ceph-devel@vger.kernel.org>
Subject: Re: Re: question about striped_read
Date: Thu, 1 Aug 2013 14:30:49 +0800 [thread overview]
Message-ID: <201308011402430151561@gmail.com> (raw)
In-Reply-To: CAAM7YAkP5LAY5Q+6fmuJkV6t9c-GZtQrwrC3awxRZ=LcRpt4xg@mail.gmail.com
>On Thu, Aug 1, 2013 at 9:45 AM, majianpeng <majianpeng@gmail.com> wrote:
>>>On Wed, Jul 31, 2013 at 3:32 PM, majianpeng <majianpeng@gmail.com> wrote:
>>>>
>>>> [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.
>>>>
>>>
>>>This patch looks good. But I still hope not to duplicate code.
>>>
>>>how about change
>>> "hit_stripe = this_len < left;"
>>>to
>>> "hit_stripe = this_len < left && (ret == this_len || pos + this_len <
>>>inode->i_size);"
>>>
>> To make the code easy to understand, i don't apply your suggestion.But i add this check on the judgement of
>> whether read more contents.
>> The follow is the latest patch.Can you check?
>>
>> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
>> index 2ddf061..3d8d14d 100644
>> --- a/fs/ceph/file.c
>> +++ b/fs/ceph/file.c
>> @@ -349,44 +349,38 @@ 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 (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 (ret >= 0) {
>> + 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,
>> + tmp, pages);
>> + ret += tmp;
>> }
>> +
>> + 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)
>> + /* hit stripe and need continue*/
>> + if (left && hit_stripe && pos < inode->i_size)
>> goto more;
>> +
>> }
>>
>> - if (was_short) {
>> + if (ret >= 0) {
>> + ret = read;
>> /* did we bounce off eof? */
>> if (pos + left > inode->i_size)
>> *checkeof = 1;
>> -
>> - /* zero trailing bytes (inside i_size) */
>> - if (left > 0 && pos < inode->i_size) {
>> - 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,
>> - pages);
>> - read += left;
>> - }
>> }
>>
>> - if (ret >= 0)
>> - ret = read;
>
>I think this line should be "if (read > 0) ret = read;". Other than
>this, your patch looks good.
Because you metioned this, I noticed for ceph_sync_read/write the result are && the every striped read/write.
That is if we met one error, the total result is error.It can't return partial result.
I think i should write anthor patch for that.
>You can add "Reviewed-by: Yan, Zheng <zheng.z.yan@intel.com>" to your
>formal patch.
Ok ,thanks your times.
Thanks!
Jianpeng Ma
>
>Regards
>Yan, Zheng
>
>
>> dout("striped_read returns %d\n", ret);
>> return ret;
>> }
>>
>> Thanks!
>> Jianpeng Ma
Thanks!
Jianpeng Ma
>On Thu, Aug 1, 2013 at 9:45 AM, majianpeng <majianpeng@gmail.com> wrote:
>>>On Wed, Jul 31, 2013 at 3:32 PM, majianpeng <majianpeng@gmail.com> wrote:
>>>>
>>>> [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.
>>>>
>>>
>>>This patch looks good. But I still hope not to duplicate code.
>>>
>>>how about change
>>> "hit_stripe = this_len < left;"
>>>to
>>> "hit_stripe = this_len < left && (ret == this_len || pos + this_len <
>>>inode->i_size);"
>>>
>> To make the code easy to understand, i don't apply your suggestion.But i add this check on the judgement of
>> whether read more contents.
>> The follow is the latest patch.Can you check?
>>
>> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
>> index 2ddf061..3d8d14d 100644
>> --- a/fs/ceph/file.c
>> +++ b/fs/ceph/file.c
>> @@ -349,44 +349,38 @@ 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 (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 (ret >= 0) {
>> + 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,
>> + tmp, pages);
>> + ret += tmp;
>> }
>> +
>> + 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)
>> + /* hit stripe and need continue*/
>> + if (left && hit_stripe && pos < inode->i_size)
>> goto more;
>> +
>> }
>>
>> - if (was_short) {
>> + if (ret >= 0) {
>> + ret = read;
>> /* did we bounce off eof? */
>> if (pos + left > inode->i_size)
>> *checkeof = 1;
>> -
>> - /* zero trailing bytes (inside i_size) */
>> - if (left > 0 && pos < inode->i_size) {
>> - 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,
>> - pages);
>> - read += left;
>> - }
>> }
>>
>> - if (ret >= 0)
>> - ret = read;
>
>I think this line should be "if (read > 0) ret = read;". Other than
>this, your patch looks good.
>You can add "Reviewed-by: Yan, Zheng <zheng.z.yan@intel.com>" to your
>formal patch.
>
>Regards
>Yan, Zheng
>
>
>> dout("striped_read returns %d\n", ret);
>> return ret;
>> }
>>
>> Thanks!
>> Jianpeng Ma
next prev parent reply other threads:[~2013-08-01 6:30 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-25 0:52 question about striped_read majianpeng
2013-07-25 5:54 ` Sage Weil
2013-07-25 6:55 ` majianpeng
2013-07-25 12:27 ` Yan, Zheng
2013-07-25 15:50 ` Sage Weil
2013-07-26 0:48 ` majianpeng
2013-07-26 1:14 ` Yan, Zheng
2013-07-26 1:22 ` majianpeng
2013-07-26 1:36 ` Yan, Zheng
2013-07-26 1:38 ` majianpeng
2013-07-26 1:59 ` Yan, Zheng
2013-07-26 2:07 ` majianpeng
[not found] ` <CAAM7YAkNQA5PqVr15CXRQ5xPLk42VCCb3kf3U8ic9f6n3d9SGg@mail.gmail.com>
2013-07-29 3:00 ` majianpeng
2013-07-29 5:02 ` Yan, Zheng
2013-07-30 2:08 ` majianpeng
2013-07-30 2:56 ` Yan, Zheng
2013-07-30 11:01 ` majianpeng
2013-07-30 11:14 ` Yan, Zheng
2013-07-30 11:20 ` majianpeng
2013-07-30 11:41 ` majianpeng
2013-07-30 12:25 ` Yan, Zheng
2013-07-31 0:27 ` majianpeng
2013-07-31 0:40 ` Sage Weil
2013-07-31 0:44 ` majianpeng
2013-07-31 0:47 ` Sage Weil
2013-07-31 1:36 ` majianpeng
[not found] ` <CAAM7YAnGaXcQm1LcaCUGL71FGRV5zfNx1iRObFkvXsyVpu91Ag@mail.gmail.com>
2013-07-31 5:46 ` majianpeng
[not found] ` <CAAM7YAmv6Ar_oTdYG31YSHnQwyUUYSNq3Zj_4fHcwMoOvno7Sw@mail.gmail.com>
2013-07-31 7:32 ` majianpeng
2013-07-31 8:26 ` Yan, Zheng
2013-08-01 1:45 ` majianpeng
2013-08-01 3:29 ` Yan, Zheng
2013-08-01 6:30 ` majianpeng [this message]
2013-08-01 7:19 ` Yan, Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201308011402430151561@gmail.com \
--to=majianpeng@gmail.com \
--cc=ceph-devel@vger.kernel.org \
--cc=sage@inktank.com \
--cc=ukernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.