From: majianpeng <majianpeng@gmail.com>
To: sage <sage@inktank.com>, "Yan, Zheng" <ukernel@gmail.com>
Cc: ceph-devel <ceph-devel@vger.kernel.org>
Subject: Re: Re: question about striped_read
Date: Fri, 26 Jul 2013 08:48:28 +0800 [thread overview]
Message-ID: <201307260848241340451@gmail.com> (raw)
In-Reply-To: alpine.DEB.2.00.1307250848160.29435@cobra.newdream.net
>On Thu, 25 Jul 2013, Yan, Zheng wrote:
>> On Thu, Jul 25, 2013 at 2:55 PM, majianpeng <majianpeng@gmail.com> wrote:
>> >>On Thu, 25 Jul 2013, majianpeng wrote:
>> >>> Hi all,
>> >>> I met a problem and ask somebody could help me.
>> >>> In func striped_read()
>> >>> > 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);
>> >>> > }
>> >>> > pos += ret;
>>
>> I think you are right. probably above line should be 'pos += this_len'
>
>It should be easy to construct a simple test for this. E.g., something
>like
>
> pwrite(fd, buf, 0, 3000000);
> pwrite(fd, buf, 4194304, 1000);
> pread(fd, buf, 0, 6000000);
> ...
>
>and whatever else to verify that pos was in fact advanced properly?
>
The following is my test code:
void hole_test()
{
char buf[4194304];
ssize_t ret;
int fd = open("/media/ceph/test", O_RDWR|O_CREAT|O_DIRECT|O_TRUNC);
if (fd < 0) {
printf("open error %s\n", strerror(errno));
return;
}
ret = pwrite(fd, buf, 0, 3000000);
ret = pwrite(fd, buf, 4194304, 1000);
ret = pread(fd, buf , 0, 6000000);
close(fd);
}
The debug message from striped_read are:
[ 267.530266] ceph: file.c:356 : striped_read 6000000~0 (read 0) got 0
[ 267.530270] ceph: file.c:396 : striped_read returns 0
The result isn't what's your said.
Am i missing something?
BTW, i think Yan is ok,
The code
pos += ret; should pos += this_len.
Because this_len can larger than ret.
But the question is what's condition can cause this?
And can the short_read operation handle this situation?
>sage
>
>>
>> regards
>> yan, zheng
>>
>>
>> >>> > read = pos - off;
>> >>>
>> >>> At first , pos = off and off don't modify.
>> >>> Why does it judge 'read < pos -off ' ?
>> >>> Because the read = pos -off, so the read must equal pos -off.
>> >>
>> >>This block triggers if we hit a stripe. off is always the original
>> >>starting offset. pos is the current position that we just tried to read
>> >>from. We might:
>> >>
>> >> - try to read a big extent from off == pos
>> >> - readpages truncates this to the end of the object
>> >> - we get a short read (not a complete object)
>> > What's the mean of not a complete object?
>> > FYI,a short read maybe met the boundry of stripe(object) or the EOF of file.
>> > For the hole of file, i don't know how to handle.
>> >> - read is some partial amount
>> >> - pos is off + read + a gap
>> > From the code : read = pos - off; after that, the pos don't change.
>> > So the a gap where is from?
>> >
>> > Thanks!
>> > Jianpeng Ma
>> >> - we try to read from the next object and there is data
>> >> => there was a hole and we need to zero the gap
>> >>
>> >>If, on the other hand, there isn't data in the next object, then we don't
>> >>want to zero the hole.. and least not until we decide where EOF is.
>> >>That's why this block is where it is, and never triggers on the first
>> >>iteration.
>> >>
>> >>Does that make sense?
>> >>sage
>>
>>
next prev parent reply other threads:[~2013-07-26 0:48 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 [this message]
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
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=201307260848241340451@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.