From: Brian Foster <bfoster@redhat.com>
To: xfs@oss.sgi.com
Subject: Re: [PATCH] xfs: ensure correct timestamp updates from truncate
Date: Thu, 30 Jan 2014 08:57:37 -0500 [thread overview]
Message-ID: <52EA5A51.9050100@redhat.com> (raw)
In-Reply-To: <20140130080652.GA23758@infradead.org>
On 01/30/2014 03:06 AM, Christoph Hellwig wrote:
> The VFS doesn't set the proper ATTR_CTIME and ATTR_MTIME values for truncate,
> so filesystems have to manually add them. The introduction of
> xfs_setattr_time accidentally broke this special case an caused a
> regression in generic/313. Fix this by removing the local mask variable
> in xfs_setattr_size so that we only have a single place to keep the
> attribute information.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
>
Thanks Christoph!
Reviewed-by: Brian Foster <bfoster@redhat.com>
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 0ce1d75..ce966c5 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -714,7 +714,6 @@ xfs_setattr_size(
> {
> struct xfs_mount *mp = ip->i_mount;
> struct inode *inode = VFS_I(ip);
> - int mask = iattr->ia_valid;
> xfs_off_t oldsize, newsize;
> struct xfs_trans *tp;
> int error;
> @@ -735,8 +734,8 @@ xfs_setattr_size(
>
> ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
> ASSERT(S_ISREG(ip->i_d.di_mode));
> - ASSERT((mask & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET|
> - ATTR_MTIME_SET|ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0);
> + ASSERT((iattr->ia_valid & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET|
> + ATTR_MTIME_SET|ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0);
>
> oldsize = inode->i_size;
> newsize = iattr->ia_size;
> @@ -745,7 +744,7 @@ xfs_setattr_size(
> * Short circuit the truncate case for zero length files.
> */
> if (newsize == 0 && oldsize == 0 && ip->i_d.di_nextents == 0) {
> - if (!(mask & (ATTR_CTIME|ATTR_MTIME)))
> + if (!(iattr->ia_valid & (ATTR_CTIME|ATTR_MTIME)))
> return 0;
>
> /*
> @@ -833,10 +832,11 @@ xfs_setattr_size(
> * these flags set. For all other operations the VFS set these flags
> * explicitly if it wants a timestamp update.
> */
> - if (newsize != oldsize && (!(mask & (ATTR_CTIME | ATTR_MTIME)))) {
> + if (newsize != oldsize &&
> + !(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) {
> iattr->ia_ctime = iattr->ia_mtime =
> current_fs_time(inode->i_sb);
> - mask |= ATTR_CTIME | ATTR_MTIME;
> + iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME;
> }
>
> /*
> @@ -872,9 +872,9 @@ xfs_setattr_size(
> xfs_inode_clear_eofblocks_tag(ip);
> }
>
> - if (mask & ATTR_MODE)
> + if (iattr->ia_valid & ATTR_MODE)
> xfs_setattr_mode(ip, iattr);
> - if (mask & (ATTR_ATIME|ATTR_CTIME|ATTR_MTIME))
> + if (iattr->ia_valid & (ATTR_ATIME|ATTR_CTIME|ATTR_MTIME))
> xfs_setattr_time(ip, iattr);
>
> xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2014-01-30 13:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-10 12:27 [xfs] c91c46c12: xfstests generic/313 regression fengguang.wu
2014-01-10 13:22 ` Jeff Liu
2014-01-10 13:33 ` Christoph Hellwig
2014-01-10 14:01 ` Jeff Liu
2014-01-11 11:10 ` Christoph Hellwig
2014-01-29 13:13 ` Brian Foster
2014-01-29 16:35 ` Christoph Hellwig
2014-01-30 8:06 ` [PATCH] xfs: ensure correct timestamp updates from truncate Christoph Hellwig
2014-01-30 8:33 ` Jeff Liu
2014-01-30 13:57 ` Brian Foster [this message]
2014-01-30 15:47 ` Ben Myers
2014-02-03 10:23 ` Christoph Hellwig
2014-02-08 7:11 ` Christoph Hellwig
2014-02-16 14:45 ` Christoph Hellwig
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=52EA5A51.9050100@redhat.com \
--to=bfoster@redhat.com \
--cc=xfs@oss.sgi.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).