From: Steven Whitehouse <swhiteho@redhat.com>
To: npiggin@kernel.dk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [patch 7/7] fs: fix or note I_DIRTY handling bugs in filesystems
Date: Tue, 23 Nov 2010 15:04:10 +0000 [thread overview]
Message-ID: <1290524650.2423.13.camel@dolmen> (raw)
In-Reply-To: <20101123140708.132861329@kernel.dk>
Hi,
On Wed, 2010-11-24 at 01:06 +1100, npiggin@kernel.dk wrote:
> plain text document attachment (fs-fix-dirty-flags.patch)
> Comments?
>
> Index: linux-2.6/drivers/staging/pohmelfs/inode.c
> ===================================================================
> --- linux-2.6.orig/drivers/staging/pohmelfs/inode.c 2010-11-23 22:57:45.000000000 +1100
> +++ linux-2.6/drivers/staging/pohmelfs/inode.c 2010-11-23 22:59:47.000000000 +1100
> @@ -373,6 +373,7 @@ static int pohmelfs_write_inode_create_c
> dprintk("%s: parent: %llu, ino: %llu, inode: %p.\n",
> __func__, parent->ino, n->ino, inode);
>
> + /* XXX: is this race WRT writeback? */
> if (inode && (inode->i_state & I_DIRTY)) {
> struct pohmelfs_inode *pi = POHMELFS_I(inode);
> pohmelfs_write_create_inode(pi);
> Index: linux-2.6/fs/gfs2/file.c
> ===================================================================
> --- linux-2.6.orig/fs/gfs2/file.c 2010-11-23 22:54:47.000000000 +1100
> +++ linux-2.6/fs/gfs2/file.c 2010-11-24 00:58:42.000000000 +1100
> @@ -557,23 +557,43 @@ static int gfs2_close(struct inode *inod
> static int gfs2_fsync(struct file *file, int datasync)
> {
> struct inode *inode = file->f_mapping->host;
> - int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC);
> + unsigned dirty, mask;
> int ret = 0;
>
> - /* XXX: testing i_state is broken without proper synchronization */
> -
> if (gfs2_is_jdata(GFS2_I(inode))) {
> gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl);
> return 0;
> }
>
> - if (sync_state != 0) {
> - if (!datasync)
> - ret = write_inode_now(inode, 0);
> + spin_lock(&inode_lock);
> + inode_writeback_begin(inode, 1);
> +
> + if (datasync)
> + mask = I_DIRTY_DATASYNC;
> + else
> + mask = I_DIRTY_SYNC | I_DIRTY_DATASYNC;
> + dirty = inode->i_state & mask;
> + inode->i_state &= ~mask;
> + if (dirty) {
> + spin_unlock(&inode_lock);
> +
> + if (!datasync) {
> + struct writeback_control wbc = {
> + .sync_mode = WB_SYNC_ALL,
> + };
> + ret = inode->i_sb->s_op->write_inode(inode, &wbc);
> + } else {
> + if (gfs2_is_stuffed(GFS2_I(inode)))
> + gfs2_log_flush(GFS2_SB(inode),
> + GFS2_I(inode)->i_gl);
> + }
>
> - if (gfs2_is_stuffed(GFS2_I(inode)))
> - gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl);
> + spin_lock(&inode_lock);
> }
> + if (ret)
> + inode->i_state |= dirty;
> + inode_writeback_end(inode);
> + spin_unlock(&inode_lock);
>
> return ret;
> }
The GFS2 changes seem to make sense to me, so:
Acked-by: Steven Whitehouse <swhiteho@redhat.com>
Steve.
next prev parent reply other threads:[~2010-11-23 15:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-23 14:06 [patch 0/7] icache dirty / sync fixes npiggin
2010-11-23 14:06 ` [patch 1/7] fs: mark_inode_dirty barrier fix npiggin
2010-11-23 14:06 ` [patch 2/7] fs: simple fsync race fix npiggin
2010-11-29 14:58 ` Christoph Hellwig
2010-11-30 0:05 ` Nick Piggin
2010-11-23 14:06 ` [patch 3/7] fs: introduce inode writeback helpers npiggin
2010-11-29 15:13 ` Christoph Hellwig
2010-11-30 0:22 ` Nick Piggin
2010-11-23 14:06 ` [patch 4/7] fs: preserve inode dirty bits on failed metadata writeback npiggin
2010-11-29 14:59 ` Christoph Hellwig
2010-11-30 0:08 ` Nick Piggin
2010-11-23 14:06 ` [patch 5/7] fs: ext2 inode sync fix npiggin
2010-11-30 11:26 ` Boaz Harrosh
2010-11-23 14:06 ` [patch 6/7] fs: fsync optimisations npiggin
2010-11-29 15:03 ` Christoph Hellwig
2010-11-30 0:11 ` Nick Piggin
2010-11-23 14:06 ` [patch 7/7] fs: fix or note I_DIRTY handling bugs in filesystems npiggin
2010-11-23 15:04 ` Steven Whitehouse [this message]
2010-11-23 22:51 ` Dave Chinner
2010-11-24 0:23 ` Nick Piggin
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=1290524650.2423.13.camel@dolmen \
--to=swhiteho@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=npiggin@kernel.dk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.