From: Eric Sandeen <sandeen@sandeen.net>
To: Eric Sandeen <sandeen@redhat.com>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH, RFC] xfs: add heuristic to flush on rename
Date: Fri, 25 Apr 2014 15:00:50 -0500 [thread overview]
Message-ID: <535ABEF2.80003@sandeen.net> (raw)
In-Reply-To: <535ABA9D.2060305@redhat.com>
On 4/25/14, 2:42 PM, Eric Sandeen wrote:
> Add a heuristic to flush data to a file which looks like it's
> going through a tmpfile/rename dance, but not fsynced.
>
> I had a report of a system with many 0-length files after
> package updates; as it turns out, the user had basically
> done 'yum update' and punched the power button when it was
> done.
>
> Granted, the admin should not do this. Granted, the package
> manager should ensure persistence of files it updated.
>
> Ext4, however, added a heuristic like this for just this case;
> someone who writes file.tmp, then renames over file, but
> never issues an fsync.
>
> Now, this does smack of O_PONIES, but I would hope that it's
> fairly benign. If someone already synced the tmpfile, it's
> a no-op.
>
> And it's not THAT far off our "flush on close if the file was
> truncated" heuristic.
>
> Comments? Flames? Testing anyone would like to see?
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index ef1ca01..5c95ef5 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -371,6 +371,19 @@ xfs_vn_rename(
> xfs_dentry_to_name(&oname, odentry, 0);
> xfs_dentry_to_name(&nname, ndentry, odentry->d_inode->i_mode);
>
> + /*
> + * If we are renaming a just-written file over an existing
> + * file, be pedantic and flush it out if it looks like somebody
> + * is doing a tmpfile dance, and didn't fsync. Best effort;
> + * ignore errors.
> + */
> + if (new_inode) {
> + xfs_inode_t *ip = XFS_I(odentry->d_inode);
> +
> + if (VN_DIRTY(VFS_I(ip)) && ip->i_delayed_blks > 0)
> + filemap_flush(new_inode->i_mapping);
Uhhh I flushed the wrong inode (thanks Brian!) but you get the idea ;)
should be:
+ filemap_flush(odentry->d_inode->i_mapping);
-Eric
> + }
> +
> return -xfs_rename(XFS_I(odir), &oname, XFS_I(odentry->d_inode),
> XFS_I(ndir), &nname, new_inode ?
> XFS_I(new_inode) : NULL);
>
> _______________________________________________
> 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-04-25 20:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-25 19:42 [PATCH, RFC] xfs: add heuristic to flush on rename Eric Sandeen
2014-04-25 19:55 ` Christoph Hellwig
2014-04-25 19:59 ` Eric Sandeen
2014-04-25 20:00 ` Eric Sandeen [this message]
2014-04-27 21:20 ` Dave Chinner
2014-04-27 21:56 ` Eric Sandeen
2014-04-27 23:15 ` Dave Chinner
2014-04-28 0:20 ` Eric Sandeen
2014-04-28 0:48 ` Dave Chinner
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=535ABEF2.80003@sandeen.net \
--to=sandeen@sandeen.net \
--cc=sandeen@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).