All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Mayhar <fmayhar@google.com>
To: Theodore Tso <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH] ext4: Make non-journal fsync work properly.  (Version 3)
Date: Fri, 25 Sep 2009 17:39:05 -0700	[thread overview]
Message-ID: <1253925545.22432.57.camel@bobble.smo.corp.google.com> (raw)
In-Reply-To: <1252517664.18594.3.camel@bobble.smo.corp.google.com>

This patch follows Aneesh' suggestion of just calling
sync_dirty_buffer() directly.  Sorry about the delay, I've been busy

Teach ext4_write_inode() about non-journal mode in a better way,
suggested upstream.  Instead of using ext4_do_update_inode(), it
now calls sync_dirty_buffer() directly.  Also handle possible
error return from that function.

Signed-off-by: Frank Mayhar <fmayhar@google.com>

 fs/ext4/inode.c |   37 +++++++++++++++++++++++++++++--------
 1 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d87f6a0..ab31cc4 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4892,19 +4892,40 @@ out_brelse:
  */
 int ext4_write_inode(struct inode *inode, int wait)
 {
+	int err;
+
 	if (current->flags & PF_MEMALLOC)
 		return 0;
 
-	if (ext4_journal_current_handle()) {
-		jbd_debug(1, "called recursively, non-PF_MEMALLOC!\n");
-		dump_stack();
-		return -EIO;
-	}
+	if (EXT4_SB(inode->i_sb)->s_journal) {
+		if (ext4_journal_current_handle()) {
+			jbd_debug(1, "called recursively, non-PF_MEMALLOC!\n");
+			dump_stack();
+			return -EIO;
+		}
 
-	if (!wait)
-		return 0;
+		if (!wait)
+			return 0;
+
+		err = ext4_force_commit(inode->i_sb);
+	} else {
+		struct ext4_iloc iloc;
 
-	return ext4_force_commit(inode->i_sb);
+		err = ext4_get_inode_loc(inode, &iloc);
+		if (err)
+			return err;
+		if (wait)
+			sync_dirty_buffer(iloc.bh);
+		if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) {
+			ext4_error(inode->i_sb, __func__,
+				   "IO error syncing inode, "
+				   "inode=%lu, block=%llu",
+				   inode->i_ino,
+				   (unsigned long long)iloc.bh->b_blocknr);
+			err = -EIO;
+		}
+	}
+	return err;
 }
 
 /*

-- 
Frank Mayhar <fmayhar@google.com>
Google, Inc.


  parent reply	other threads:[~2009-09-26  0:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-05  2:55 [PATCH] Make non-journal fsync work properly Frank Mayhar
2009-09-08  5:06 ` Theodore Tso
2009-09-08 14:57   ` Curt Wohlgemuth
2009-09-08 21:41     ` Theodore Tso
2009-09-08 15:41   ` Frank Mayhar
2009-09-08 22:05     ` Theodore Tso
2009-09-08 22:39       ` Frank Mayhar
2009-09-09 17:34       ` [PATCH] ext4: Make non-journal fsync work properly. REPOST Frank Mayhar
2009-09-10  2:55         ` Theodore Tso
2009-09-14 16:54         ` Aneesh Kumar K.V
2009-09-14 17:43           ` Frank Mayhar
2009-09-26  0:39         ` Frank Mayhar [this message]
2009-09-29 14:09           ` [PATCH] ext4: Make non-journal fsync work properly. (Version 3) Theodore Tso
2009-09-10  6:57 ` [PATCH] Make non-journal fsync work properly Aneesh Kumar K.V
2009-09-10 15:33   ` Frank Mayhar
2009-09-10 19:45     ` Theodore Tso

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=1253925545.22432.57.camel@bobble.smo.corp.google.com \
    --to=fmayhar@google.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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.