All of lore.kernel.org
 help / color / mirror / Atom feed
From: Henry C Chang <henry.cy.chang@gmail.com>
To: Sage Weil <sage@newdream.net>
Cc: ceph-devel@vger.kernel.org
Subject: Re: O_DIRECT change
Date: Tue, 7 Jun 2011 17:39:42 +0800	[thread overview]
Message-ID: <BANLkTi=-opE84qCKbzw0+3mjiJGP+Nzp6A@mail.gmail.com> (raw)
In-Reply-To: <BANLkTimgt0aW800==OCj72ocrAizJSfFjw@mail.gmail.com>

Hi Sage,

I checked the stripe_read function and think the following two patches
are needed:

1. Move hit_stripe/was_short checking after the adjustment of
ceph_osdc_readpages return code

    Fix the following case:
    (i) Create a sparse file
        dd if=/dev/zero of=/mnt/fs_depot/dd3 bs=1 seek=1048576 count=0

    (ii) Read the file
        dd if=/mnt/fs_depot/dd3 of=/root/ddout1 skip=8 bs=500 count=2
iflag=direct

diff --git a/ceph/file.c b/ceph/file.c
index 1f36e2c..6e6297a 100644
--- a/ceph/file.c
+++ b/ceph/file.c
@@ -313,16 +313,18 @@ more:
                page_align = (pos - io_align + buf_align) & ~PAGE_MASK;
        else
                page_align = pos & ~PAGE_MASK;
+
        this_len = left;
        ret = ceph_osdc_readpages(&fsc->client->osdc, ceph_vino(inode),
                                  &ci->i_layout, pos, &this_len,
                                  ci->i_truncate_seq,
                                  ci->i_truncate_size,
                                  page_pos, pages_left, page_align);
-       hit_stripe = this_len < left;
-       was_short = ret >= 0 && ret < this_len;
        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" : "");


2. Fix didpages and the starting position of ceph_zero_page_vector_range

    This fixes segfault caused by the following scenario:
    (i) generate a sparse file by
        dd if=/dev/urandom of=/mnt/fs_depot/dd10 bs=500 seek=8388 count=1
    (ii) read the file from offset 4194300~500
        dd if=/mnt/fs_depot/dd10 of=/root/dd10out bs=500 skip=8388 count=1

diff --git a/ceph/file.c b/ceph/file.c
index 6e6297a..d7932bc 100644
--- a/ceph/file.c
+++ b/ceph/file.c
@@ -291,7 +291,6 @@ static int striped_read(struct inode *inode,
        struct ceph_inode_info *ci = ceph_inode(inode);
        u64 pos, this_len;
        int io_align, page_align;
-       int page_off = off & ~PAGE_CACHE_MASK; /* first byte's offset in page */
        int left, pages_left;
        int read;
        struct page **page_pos;
@@ -329,12 +328,11 @@ more:
             ret, hit_stripe ? " HITSTRIPE" : "", was_short ? " SHORT" : "");

        if (ret > 0) {
-               int didpages =
-                       ((pos & ~PAGE_CACHE_MASK) + ret) >> PAGE_CACHE_SHIFT;
+               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_off + read,
+                       ceph_zero_page_vector_range(page_align + read,
                                                    pos - off - read, pages);
                }
                pos += ret;
@@ -359,7 +357,7 @@ more:
                                left = inode->i_size - pos;

                        dout("zero tail %d\n", left);
-                       ceph_zero_page_vector_range(page_off + read, left,
+                       ceph_zero_page_vector_range(page_align + read, left,
                                                    pages);
                        read += left;
                }

  reply	other threads:[~2011-06-07  9:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-03 16:48 O_DIRECT change Sage Weil
2011-06-04  2:29 ` Henry C Chang
2011-06-07  9:39   ` Henry C Chang [this message]
2011-06-08  5:07     ` Sage Weil

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='BANLkTi=-opE84qCKbzw0+3mjiJGP+Nzp6A@mail.gmail.com' \
    --to=henry.cy.chang@gmail.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=sage@newdream.net \
    /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.