linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Steve French" <smfrench@gmail.com>
To: "Jeff Layton" <jlayton@redhat.com>
Cc: Nick Piggin <npiggin@suse.de>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	pbadari@us.ibm.com,
	"linux-cifs-client@lists.samba.org"
	<linux-cifs-client@lists.samba.org>
Subject: Re: Re: fsx-linux failing with latest cifs-2.6 git tree
Date: Sun, 23 Nov 2008 20:32:05 -0600	[thread overview]
Message-ID: <524f69650811231832v12a03252ycbf53d9b06f178f8@mail.gmail.com> (raw)
In-Reply-To: <20081123065715.029b6ceb@tleilax.poochiereds.net>

Looks fine to me, you can add in the acked-by ... if Dave or Nick
agree and it tests out ok then I will push to cifs-2.6.git within next
day or so.

On Sun, Nov 23, 2008 at 5:57 AM, Jeff Layton <jlayton@redhat.com> wrote:
> On Sat, 22 Nov 2008 14:27:44 -0600
> Dave Kleikamp <shaggy@linux.vnet.ibm.com> wrote:
>
>> Just took a real quick look, but I have one comment.  I'd leave the page
>> alone if it's already PageUptodate.  I wouldn't bother setting
>> PageChecked and let cifs_write_end leave it alone when its already
>> uptodate.
>
> Ok, it makes sense not to flip page bits unless we need to. How's this
> instead? It also switches the code to use zero_user_segments() instead
> of calling kmap/memset directly.
>
> I've dropped Steve's SoB for now since this has morphed quite a bit from
> his original patch. Steve, feel free to add it back if you approve.
>
> --------------------[snip]--------------------
>
> From da222d5125ec4095f10e9a4c984b6bd6b0cacf18 Mon Sep 17 00:00:00 2001
> From: Jeff Layton <jlayton@redhat.com>
> Date: Sun, 23 Nov 2008 06:54:42 -0500
> Subject: [PATCH] cifs: fix regression in cifs_write_begin/cifs_write_end
>
> The conversion to write_begin/write_end interfaces had a bug where we
> were passing a bad parameter to cifs_readpage_worker. Rather than
> passing the page offset of the start of the write, we needed to pass the
> offset of the beginning of the page. This was reliably showing up as
> data corruption in the fsx-linux test from LTP.
>
> It also became evident that this code was occasionally doing unnecessary
> read calls. Optimize those away by using the PG_checked flag to indicate
> that the unwritten part of the page has been initialized.
>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
>  fs/cifs/file.c |   68 +++++++++++++++++++++++++++++++++++++++++--------------
>  1 files changed, 50 insertions(+), 18 deletions(-)
>
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index b691b89..9114ea5 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -1475,7 +1475,10 @@ static int cifs_write_end(struct file *file, struct address_space *mapping,
>        cFYI(1, ("write_end for page %p from pos %lld with %d bytes",
>                 page, pos, copied));
>
> -       if (!PageUptodate(page) && copied == PAGE_CACHE_SIZE)
> +       if (PageChecked(page)) {
> +               SetPageUptodate(page);
> +               ClearPageChecked(page);
> +       } else if (!PageUptodate(page) && copied == PAGE_CACHE_SIZE)
>                SetPageUptodate(page);
>
>        if (!PageUptodate(page)) {
> @@ -2062,39 +2065,68 @@ static int cifs_write_begin(struct file *file, struct address_space *mapping,
>  {
>        pgoff_t index = pos >> PAGE_CACHE_SHIFT;
>        loff_t offset = pos & (PAGE_CACHE_SIZE - 1);
> +       loff_t page_start = pos & PAGE_MASK;
> +       loff_t i_size;
> +       struct inode *inode;
> +       struct page *page;
> +       int rc = 0;
>
>        cFYI(1, ("write_begin from %lld len %d", (long long)pos, len));
>
> -       *pagep = __grab_cache_page(mapping, index);
> -       if (!*pagep)
> -               return -ENOMEM;
> +       page = __grab_cache_page(mapping, index);
> +       if (!page) {
> +               rc = -ENOMEM;
> +               goto out;
> +       }
>
> -       if (PageUptodate(*pagep))
> -               return 0;
> +       if (PageUptodate(page))
> +               goto out;
>
>        /* If we are writing a full page it will be up to date,
>           no need to read from the server */
>        if (len == PAGE_CACHE_SIZE && flags & AOP_FLAG_UNINTERRUPTIBLE)
> -               return 0;
> -
> -       if ((file->f_flags & O_ACCMODE) != O_WRONLY) {
> -               int rc;
> +               goto out;
>
> -               /* might as well read a page, it is fast enough */
> -               rc = cifs_readpage_worker(file, *pagep, &offset);
> +       /*
> +        * optimize away the read when we have an oplock, and we're not
> +        * expecting to use any of the data we'd be reading in. That is, when
> +        * the page lies beyond the EOF, or straddles the EOF and the write
> +        * would cover all of the existing data in the file.
> +        */
> +       inode = page->mapping->host;
> +       if (CIFS_I(inode)->clientCanCacheRead) {
> +               i_size = i_size_read(inode);
> +               if (page_start >= i_size ||
> +                   (offset == 0 && (pos + len) >= i_size)) {
> +                       zero_user_segments(page, 0, offset, offset + len,
> +                                          PAGE_CACHE_SIZE);
> +                       /*
> +                        * PageChecked means that the parts of the page to
> +                        * which we're not writing are considered up to date.
> +                        * Once the write data is copied to the page, it can
> +                        * be set uptodate.
> +                        */
> +                       SetPageChecked(page);
> +                       goto out;
> +               }
> +       }
>
> -               /* we do not need to pass errors back
> -                  e.g. if we do not have read access to the file
> -                  because cifs_write_end will attempt synchronous writes
> -                  -- shaggy */
> +       if ((file->f_flags & O_ACCMODE) != O_WRONLY) {
> +               /*
> +                * might as well read a page, it is fast enough. If we get
> +                * an error, we don't need to return it. cifs_write_end will
> +                * do a sync write instead since PG_uptodate isn't set.
> +                */
> +               cifs_readpage_worker(file, page, &page_start);
>        } else {
>                /* we could try using another file handle if there is one -
>                   but how would we lock it to prevent close of that handle
>                   racing with this read? In any case
>                   this will be written out by write_end so is fine */
>        }
> -
> -       return 0;
> +out:
> +       *pagep = page;
> +       return rc;
>  }
>
>  const struct address_space_operations cifs_addr_ops = {
> --
> 1.5.5.1
>
>



-- 
Thanks,

Steve

  reply	other threads:[~2008-11-24  2:32 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20081121105613.09a8cb8e@tleilax.poochiereds.net>
     [not found] ` <524f69650811210820s549de2bah3181cbc0c5633091@mail.gmail.com>
     [not found]   ` <20081121112249.0b408b55@tleilax.poochiereds.net>
     [not found]     ` <524f69650811210846q7502fd99m6f4d335bb6ac1b65@mail.gmail.com>
     [not found]       ` <524f69650811211109w659e5decoa34a8e0f907772a3@mail.gmail.com>
     [not found]         ` <524f69650811211113q4fffcc70of88cb85db531c358@mail.gmail.com>
     [not found]           ` <1227296476.20845.8.camel@norville.austin.ibm.com>
     [not found]             ` <524f69650811211218v78295682lcf6dce842327b097@mail.gmail.com>
2008-11-21 20:38               ` Fwd: fsx-linux failing with latest cifs-2.6 git tree Steve French
2008-11-21 20:41                 ` Dave Kleikamp
2008-11-21 21:02                   ` Steve French
2008-11-21 23:44                   ` Nick Piggin
2008-11-21 20:50                 ` Jeff Layton
2008-11-21 22:50                 ` Jeff Layton
2008-11-21 23:02                   ` Dave Kleikamp
2008-11-21 23:25                     ` Jeff Layton
2008-11-22  1:04                       ` Steve French
2008-11-22  1:50                         ` Jeff Layton
2008-11-21 23:53                   ` Nick Piggin
2008-11-22  1:51                     ` Jeff Layton
2008-11-22  2:02                       ` Steve French
2008-11-22  4:47                         ` Dave Kleikamp
2008-11-22 15:39                           ` [linux-cifs-client] " Jeff Layton
2008-11-22 20:27                             ` Dave Kleikamp
2008-11-23 11:57                               ` Jeff Layton
2008-11-24  2:32                                 ` Steve French [this message]
2008-11-24 11:19                                   ` Jeff Layton
2008-11-26  4:04                                     ` Steve French
2008-11-26 11:54                                       ` Jeff Layton
2008-11-26 12:11                                       ` Jeff Layton
2008-11-26 13:09                                         ` [linux-cifs-client] " Nick Piggin
2008-11-26 15:08                                           ` Jeff Layton
2008-11-26 15:23                                             ` Nick Piggin
2008-11-26 16:37                                               ` Jeff Layton
2008-11-27  8:33                                                 ` Nick Piggin
2008-11-28 12:18                                                   ` Jeff Layton
2008-11-30 21:44                                                     ` Steve French
2008-11-30 22:17                                                       ` Jeff Layton
2008-12-01  8:44                                                         ` Nick Piggin
2008-12-01 11:28                                                           ` Jeff Layton
2008-12-01 11:32                                                             ` Nick Piggin
2008-12-01 11:55                                                               ` Jeff Layton
2008-12-01 17:43                                                                 ` Steve French
2008-11-26 19:46                                               ` Steve French
2008-11-24 20:00                                 ` Dave Kleikamp
2008-11-26 13:02                       ` Nick Piggin

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=524f69650811231832v12a03252ycbf53d9b06f178f8@mail.gmail.com \
    --to=smfrench@gmail.com \
    --cc=jlayton@redhat.com \
    --cc=linux-cifs-client@lists.samba.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=npiggin@suse.de \
    --cc=pbadari@us.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).