public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Markus Trippelsdorf <markus@trippelsdorf.de>
To: Josef Bacik <josef@redhat.com>
Cc: jack@suse.cz, linux-kernel@vger.kernel.org, xfs@oss.sgi.com,
	hch@infradead.org, viro@zeniv.linux.org.uk,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] fs: push i_mutex and filemap_write_and_wait down into ->fsync() handlers
Date: Sat, 23 Jul 2011 21:32:25 +0200	[thread overview]
Message-ID: <20110723193225.GA1652@x4.trippels.de> (raw)
In-Reply-To: <20110723180942.GA1616@x4.trippels.de>

On 2011.07.23 at 20:09 +0200, Markus Trippelsdorf wrote:
> On 2011.06.29 at 14:05 -0400, Josef Bacik wrote:
> > Btrfs needs to be able to control how filemap_write_and_wait_range() is called
> > in fsync to make it less of a painful operation, so push down taking i_mutex and
> > the calling of filemap_write_and_wait() down into the ->fsync() handlers.  Some
> > file systems can drop taking the i_mutex altogether it seems, like ext3 and
> > ocfs2.  For correctness sake I just pushed everything down in all cases to make
> > sure that we keep the current behavior the same for everybody, and then each
> > individual fs maintainer can make up their mind about what to do from there.
> 
> At least the xfs part of this patch is broken.
> Running the latest git-kernel bogofilter doesn't work anymore on my xfs
> partition. When I run "bogoutil -d wordlist.db" to dump the contents of
> the database, it produces no output at all. 
> 
> Reverting 02c24a82187d (or only the xfs part of that commit) "solves"
> the problem.

Looks like a locking problem (note the stale xfs_rw_ilock):

diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index 7f782af..fbbf657 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -127,6 +127,8 @@ xfs_iozero(
 STATIC int
 xfs_file_fsync(
 	struct file		*file,
+	loff_t			start,
+	loff_t			end,
 	int			datasync)
 {
 	struct inode		*inode = file->f_mapping->host;
@@ -138,6 +140,10 @@ xfs_file_fsync(
 
 	trace_xfs_file_fsync(ip);
 
+	error = filemap_write_and_wait_range(inode->i_mapping, start, end);
+	if (error)
+		return error;
+
 	if (XFS_FORCED_SHUTDOWN(mp))
 		return -XFS_ERROR(EIO);
 
@@ -875,18 +881,11 @@ xfs_file_aio_write(
 	/* Handle various SYNC-type writes */
 	if ((file->f_flags & O_DSYNC) || IS_SYNC(inode)) {
 		loff_t end = pos + ret - 1;
-		int error, error2;
 
 		xfs_rw_iunlock(ip, iolock);
-		error = filemap_write_and_wait_range(mapping, pos, end);
+		ret = -xfs_file_fsync(file, pos, end,
+				      (file->f_flags & __O_SYNC) ? 0 : 1);
 		xfs_rw_ilock(ip, iolock);
-
-		error2 = -xfs_file_fsync(file,
-					 (file->f_flags & __O_SYNC) ? 0 : 1);
-		if (error)
-			ret = error;
-		else if (error2)
-			ret = error2;
 	}
 
 out_unlock:

-- 
Markus

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2011-07-23 19:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1309370716-12235-1-git-send-email-josef@redhat.com>
2011-07-23 18:09 ` [PATCH] fs: push i_mutex and filemap_write_and_wait down into ->fsync() handlers Markus Trippelsdorf
2011-07-23 19:32   ` Markus Trippelsdorf [this message]
2011-07-23 20:26   ` Josef Bacik
2011-07-23 20:38     ` Markus Trippelsdorf
2011-07-23 22:02       ` Markus Trippelsdorf
2011-07-24 11:16         ` Christoph Hellwig
2011-07-24 11:42           ` Christoph Hellwig
2011-07-24 11:54           ` [PATCH] xfs: Fix wrong return value of xfs_file_aio_write Markus Trippelsdorf
2011-07-24 11:57             ` Christoph Hellwig
2011-07-24 11:58             ` [PATCH v2] " Markus Trippelsdorf
2011-07-24 12:03               ` [PATCH] " Markus Trippelsdorf
2011-07-24 12:11                 ` Christoph Hellwig
2011-07-26 15:21                 ` Alex Elder

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=20110723193225.GA1652@x4.trippels.de \
    --to=markus@trippelsdorf.de \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=josef@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --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