Skip to content

Commit

Permalink
orangefs: clean up truncate ctime and mtime setting
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Mike Marshall <[email protected]>
  • Loading branch information
Martin Brandenburg authored and hubcapsc committed Apr 8, 2016
1 parent 2fa37fd commit f83140c
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions fs/orangefs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,22 +204,8 @@ static int orangefs_setattr_size(struct inode *inode, struct iattr *iattr)
if (ret != 0)
return ret;

/*
* Only change the c/mtime if we are changing the size or we are
* explicitly asked to change it. This handles the semantic difference
* between truncate() and ftruncate() as implemented in the VFS.
*
* The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a
* special case where we need to update the times despite not having
* these flags set. For all other operations the VFS set these flags
* explicitly if it wants a timestamp update.
*/
if (orig_size != i_size_read(inode) &&
!(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) {
iattr->ia_ctime = iattr->ia_mtime =
current_fs_time(inode->i_sb);
if (orig_size != i_size_read(inode))
iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME;
}

return ret;
}
Expand Down

0 comments on commit f83140c

Please sign in to comment.