All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Sidorenko <asid@hp.com>
To: linux-nfs@vger.kernel.org
Subject: FLushing cached writes in nfs_getattr() and stat() delay
Date: Thu, 6 Nov 2008 10:34:06 -0500	[thread overview]
Message-ID: <200811061034.06486.asid@hp.com> (raw)

Hello,

I am an HP engineer participating in L3 Linux support. Recently we have found 
that current design of nfs_getattr() might create huge delays in stat() on 
the file we are writing to (this is important for big files only, >2Gb).

The problem
-----------

Assuming that /nfs is an NFS-mounted FS:

1. In one shell, start
$ dd if=/dev/zero of=/nfs/dir/big bs=1G count=20

2. In another shell, start

$ ls -l /nfs/dir

or

$ ls -l /nfs/dir/big

'ls' does not return until the whole /nfs/dir/big is written.

Analysis
--------

Kernel 2.6.16 has introduced the following change in nfs_getattr():


    NFS: Make stat() return updated mtimes after a write()

    The SuS states that a call to write() will cause mtime to be updated on
    the file. In order to satisfy that requirement, we need to flush out
    any cached writes in nfs_getattr().
    Speed things up slightly by not committing the writes.

    Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

+	/* Flush out writes to the server in order to update c/mtime */
+	nfs_sync_inode(inode, 0, 0, FLUSH_WAIT|FLUSH_NOCOMMIT);

Then later:

2.6.16-rc6:

http://www.linux-nfs.org/Linux-2.6.x/2.6.16-rc6/linux-2.6.16-99-fix_nfs_sync_inode_race.dif

 	/* Flush out writes to the server in order to update c/mtime */
-	nfs_sync_inode(inode, 0, 0, FLUSH_WAIT|FLUSH_NOCOMMIT);
+	nfs_sync_inode_wait(inode, 0, 0, FLUSH_NOCOMMIT);


I understand the reasoning behind that. From application point of view, NFS 
file/directory should behave the same as on local FS. If we have queued many 
writes, without this patch stat() will return incorrect results, both for 
mtime and file length. Some applications may depend on stat() results being 
correct.

At the same time, the fact that we have to wait forever while copying big 
files and doing 'ls -l' on that directory (or on the file being written) is 
not very good either (two HP customers have complained about this after 
migrating from RHEL4 to RHEL5).

The problem is still there in 2.6.27. I am not sure what can be done to both 
reduce the stat() delay and guarantee reasonable stat() results. 

It is interesting that with 'noac' stat() returns much faster (just 1-3s 
delay).

Best regards,
Alex

-- 
------------------------------------------------------------------
Alexandre Sidorenko             email: asid@hp.com
Global Solutions Engineering:   Unix Networking
Hewlett-Packard (Canada)
------------------------------------------------------------------

             reply	other threads:[~2008-11-06 15:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-06 15:34 Alex Sidorenko [this message]
2008-11-06 16:40 ` FLushing cached writes in nfs_getattr() and stat() delay Chuck Lever
2008-11-06 18:49 ` Trond Myklebust
     [not found]   ` <1225997396.387.30.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-11-06 19:15     ` Chuck Lever
2008-11-06 19:22     ` Alex Sidorenko
2008-11-06 19:32       ` Trond Myklebust
2008-11-06 19:45       ` Chuck Lever
2008-11-06 19:55         ` Alex Sidorenko

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=200811061034.06486.asid@hp.com \
    --to=asid@hp.com \
    --cc=linux-nfs@vger.kernel.org \
    /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.