public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Lachlan McIlroy <lachlan@sgi.com>
To: xfs-dev <xfs-dev@sgi.com>
Cc: xfs-oss <xfs@oss.sgi.com>
Subject: [PATCH] ensure file size is logged on synchronous writes
Date: Mon, 03 Sep 2007 13:07:12 +1000	[thread overview]
Message-ID: <46DB7A60.4050203@sgi.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 334 bytes --]

Synchronous writes currently log inode changes before syncing
pages to disk.  Since the file size is updated on I/O completion
we wont be writing out the updated file size and if we crash the
file will have the wrong size.  This change moves the logging
after the syncing of the pages to ensure we log the correct file
size.

Lachlan

[-- Attachment #2: xfs_write.diff --]
[-- Type: text/x-patch, Size: 815 bytes --]

--- fs/xfs/linux-2.6/xfs_lrw.c_1.266	2007-08-30 17:38:53.000000000 +1000
+++ fs/xfs/linux-2.6/xfs_lrw.c	2007-08-31 15:38:49.000000000 +1000
@@ -895,20 +895,19 @@ retry:
 
 	/* Handle various SYNC-type writes */
 	if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) {
-		error = xfs_write_sync_logforce(mp, xip);
-		if (error)
-			goto out_unlock_internal;
-
+		int error2;
 		xfs_rwunlock(xip, locktype);
 		if (need_i_mutex)
 			mutex_unlock(&inode->i_mutex);
-
-		error = sync_page_range(inode, mapping, pos, ret);
+		error2 = sync_page_range(inode, mapping, pos, ret);
 		if (!error)
-			error = -ret;
+			error = error2;
 		if (need_i_mutex)
 			mutex_lock(&inode->i_mutex);
 		xfs_rwlock(xip, locktype);
+		error2 = xfs_write_sync_logforce(mp, xip);
+		if (!error)
+			error = error2;
 	}
 
  out_unlock_internal:

             reply	other threads:[~2007-09-03  3:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-03  3:07 Lachlan McIlroy [this message]
2007-09-10 15:07 ` [PATCH] ensure file size is logged on synchronous writes 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=46DB7A60.4050203@sgi.com \
    --to=lachlan@sgi.com \
    --cc=xfs-dev@sgi.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