diff options
author | Martin Brandenburg <martin@omnibond.com> | 2016-04-04 16:26:36 -0400 |
---|---|---|
committer | Mike Marshall <hubcap@omnibond.com> | 2016-04-08 14:10:31 -0400 |
commit | f83140c1467e22ba9ee9389bc4e6c3e117f2296e (patch) | |
tree | 1c0b480efa801c3395f4e6f77a37926705933c3b | |
parent | 2fa37fd71396b8eff72d23cafc8c583dd8eb928c (diff) |
orangefs: clean up truncate ctime and mtime setting
The ctime and mtime are always updated on a successful ftruncate and
only updated on a successful truncate where the size changed.
We handle the ``if the size changed'' bit.
This matches FUSE's behavior.
Signed-off-by: Martin Brandenburg <martin@omnibond.com>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
-rw-r--r-- | fs/orangefs/inode.c | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c index 2382e267b49e..975a7966a446 100644 --- a/fs/orangefs/inode.c +++ b/fs/orangefs/inode.c | |||
@@ -204,22 +204,8 @@ static int orangefs_setattr_size(struct inode *inode, struct iattr *iattr) | |||
204 | if (ret != 0) | 204 | if (ret != 0) |
205 | return ret; | 205 | return ret; |
206 | 206 | ||
207 | /* | 207 | if (orig_size != i_size_read(inode)) |
208 | * Only change the c/mtime if we are changing the size or we are | ||
209 | * explicitly asked to change it. This handles the semantic difference | ||
210 | * between truncate() and ftruncate() as implemented in the VFS. | ||
211 | * | ||
212 | * The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a | ||
213 | * special case where we need to update the times despite not having | ||
214 | * these flags set. For all other operations the VFS set these flags | ||
215 | * explicitly if it wants a timestamp update. | ||
216 | */ | ||
217 | if (orig_size != i_size_read(inode) && | ||
218 | !(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) { | ||
219 | iattr->ia_ctime = iattr->ia_mtime = | ||
220 | current_fs_time(inode->i_sb); | ||
221 | iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME; | 208 | iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME; |
222 | } | ||
223 | 209 | ||
224 | return ret; | 210 | return ret; |
225 | } | 211 | } |