From: Trond Myklebust <trond.myklebust@fys.uio.no>
To: Andrew Morton <akpm@osdl.org>
Cc: lkml-z@robsims.com, linux-kernel@vger.kernel.org
Subject: Re: Change in NFS client behavior
Date: Fri, 02 Sep 2005 00:19:07 -0400 [thread overview]
Message-ID: <1125634747.8635.17.camel@lade.trondhjem.org> (raw)
In-Reply-To: <1125634523.8635.16.camel@lade.trondhjem.org>
[-- Attachment #1: Type: text/plain, Size: 204 bytes --]
fr den 02.09.2005 Klokka 00:15 (-0400) skreiv Trond Myklebust:
> Sure. The other problem is that the test is made before the i_sem is
> grabbed. OK, so how about the appended patch instead?
Doh!
Trond
[-- Attachment #2: linux-2.6.13-37-fix_create_truncate.dif --]
[-- Type: text/plain, Size: 3472 bytes --]
VFS/NFS: Fix up behaviour w.r.t. truncate() and open(O_TRUNC)
POSIX and the SUSv3 specify that open(O_TRUNC) should always bump ctime/mtime
whereas truncate() should only do so if the file size actually changes.
Fix the behaviour of NFS, which currently is broken w.r.t. open(), and fix
the VFS truncate() so that it no enforces the POSIX rules.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
attr.c | 14 +++-----------
nfs/inode.c | 5 -----
open.c | 25 +++++++++++++++++++++++--
3 files changed, 26 insertions(+), 18 deletions(-)
Index: linux-2.6.13/fs/nfs/inode.c
===================================================================
--- linux-2.6.13.orig/fs/nfs/inode.c
+++ linux-2.6.13/fs/nfs/inode.c
@@ -833,11 +833,6 @@ nfs_setattr(struct dentry *dentry, struc
struct nfs_fattr fattr;
int error;
- if (attr->ia_valid & ATTR_SIZE) {
- if (!S_ISREG(inode->i_mode) || attr->ia_size == i_size_read(inode))
- attr->ia_valid &= ~ATTR_SIZE;
- }
-
/* Optimization: if the end result is no change, don't RPC */
attr->ia_valid &= NFS_VALID_ATTRS;
if (attr->ia_valid == 0)
Index: linux-2.6.13/fs/open.c
===================================================================
--- linux-2.6.13.orig/fs/open.c
+++ linux-2.6.13/fs/open.c
@@ -206,11 +206,32 @@ int do_truncate(struct dentry *dentry, l
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
down(&dentry->d_inode->i_sem);
+ /* This should be used for open(O_TRUNC) and functions that need to
+ * set mtime/ctime whether or not the size changes
+ */
+ if (length == i_size_read(dentry->d_inode))
+ newattrs.ia_valid &= ~ATTR_SIZE;
err = notify_change(dentry, &newattrs);
up(&dentry->d_inode->i_sem);
return err;
}
+static int do_posix_truncate(struct dentry *dentry, loff_t length)
+{
+ int err = 0;
+ struct iattr newattrs;
+
+ newattrs.ia_size = length;
+ newattrs.ia_valid = ATTR_SIZE;
+
+ down(&dentry->d_inode->i_sem);
+ /* In SuS/Posix lore, truncate to the current file size is a no-op */
+ if (length != i_size_read(dentry->d_inode))
+ err = notify_change(dentry, &newattrs);
+ up(&dentry->d_inode->i_sem);
+ return err;
+}
+
static inline long do_sys_truncate(const char __user * path, loff_t length)
{
struct nameidata nd;
@@ -261,7 +282,7 @@ static inline long do_sys_truncate(const
error = locks_verify_truncate(inode, NULL, length);
if (!error) {
DQUOT_INIT(inode);
- error = do_truncate(nd.dentry, length);
+ error = do_posix_truncate(nd.dentry, length);
}
put_write_access(inode);
@@ -313,7 +334,7 @@ static inline long do_sys_ftruncate(unsi
error = locks_verify_truncate(inode, file, length);
if (!error)
- error = do_truncate(dentry, length);
+ error = do_posix_truncate(dentry, length);
out_putf:
fput(file);
out:
Index: linux-2.6.13/fs/attr.c
===================================================================
--- linux-2.6.13.orig/fs/attr.c
+++ linux-2.6.13/fs/attr.c
@@ -70,17 +70,9 @@ int inode_setattr(struct inode * inode,
int error = 0;
if (ia_valid & ATTR_SIZE) {
- if (attr->ia_size != i_size_read(inode)) {
- error = vmtruncate(inode, attr->ia_size);
- if (error || (ia_valid == ATTR_SIZE))
- goto out;
- } else {
- /*
- * We skipped the truncate but must still update
- * timestamps
- */
- ia_valid |= ATTR_MTIME|ATTR_CTIME;
- }
+ error = vmtruncate(inode, attr->ia_size);
+ if (error || (ia_valid == ATTR_SIZE))
+ goto out;
}
if (ia_valid & ATTR_UID)
next prev parent reply other threads:[~2005-09-02 4:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-31 14:55 Rob Sims
2005-09-01 23:38 ` Trond Myklebust
2005-09-02 3:43 ` Trond Myklebust
2005-09-02 3:45 ` Andrew Morton
2005-09-02 3:52 ` Trond Myklebust
2005-09-02 4:07 ` Andrew Morton
2005-09-02 4:15 ` Trond Myklebust
2005-09-02 4:19 ` Trond Myklebust [this message]
2005-09-02 4:38 ` Andrew Morton
2005-09-07 14:25 ` Rob Sims
2005-09-02 15:39 ` Rob Sims
2005-09-02 15:06 ` Drop NFS speed on move from kernel 2.4 to 2.6 (was: Change in NFS client behavior) Tomasz Kłoczko
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=1125634747.8635.17.camel@lade.trondhjem.org \
--to=trond.myklebust@fys.uio.no \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml-z@robsims.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
all inboxes | Powered by JetHome®