linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boaz Harrosh <bharrosh@panasas.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-fsdevel@vger.kernel.org, open-osd <osd-dev@open-osd.org>
Subject: [PATCH ver3] exofs: exofs_file_fsync and exofs_file_flush correctness
Date: Tue, 01 Jun 2010 20:03:39 +0300	[thread overview]
Message-ID: <4C053D6B.3000704@panasas.com> (raw)
In-Reply-To: <4C0527AF.6090502@panasas.com>


As per Christoph advise: no need to call filemap_write_and_wait().
In exofs all metadata is at the inode so just writing the inode is
all is needed. ->fsync implies this must be done synchronously.

But now exofs_file_fsync can not be used by exofs_file_flush.
vfs_fsync() should do that job correctly.

FIXME: remove the sb_sync and fix that sb_update better.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 fs/exofs/file.c |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/fs/exofs/file.c b/fs/exofs/file.c
index f9bfe2b..68cb23e 100644
--- a/fs/exofs/file.c
+++ b/fs/exofs/file.c
@@ -30,9 +30,6 @@
  * along with exofs; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
-
-#include <linux/buffer_head.h>
-
 #include "exofs.h"
 
 static int exofs_release_file(struct inode *inode, struct file *filp)
@@ -40,19 +37,27 @@ static int exofs_release_file(struct inode *inode, struct file *filp)
 	return 0;
 }
 
+/* exofs_file_fsync - flush the inode to disk
+ *
+ *   Note, in exofs all metadata is written as part of inode, regardless.
+ *   The writeout is synchronous
+ */
 static int exofs_file_fsync(struct file *filp, int datasync)
 {
 	int ret;
-	struct address_space *mapping = filp->f_mapping;
-	struct inode *inode = mapping->host;
+	struct inode *inode = filp->f_mapping->host;
+	struct writeback_control wbc = {
+		.sync_mode = WB_SYNC_ALL,
+		.nr_to_write = 0, /* metadata-only; caller takes care of data */
+	};
 	struct super_block *sb;
 
-	ret = filemap_write_and_wait(mapping);
-	if (ret)
-		return ret;
+	if (!(inode->i_state & I_DIRTY))
+		return 0;
+	if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
+		return 0;
 
-	/* sync the inode attributes */
-	ret = write_inode_now(inode, 1);
+	ret = sync_inode(inode, &wbc);
 
 	/* This is a good place to write the sb */
 	/* TODO: Sechedule an sb-sync on create */
@@ -65,9 +70,9 @@ static int exofs_file_fsync(struct file *filp, int datasync)
 
 static int exofs_flush(struct file *file, fl_owner_t id)
 {
-	exofs_file_fsync(file, 1);
+	int ret = vfs_fsync(file, 0);
 	/* TODO: Flush the OSD target */
-	return 0;
+	return ret;
 }
 
 const struct file_operations exofs_file_operations = {
-- 
1.6.6.1



      parent reply	other threads:[~2010-06-01 17:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-31 10:09 exofs_file_fsync Christoph Hellwig
2010-05-31 10:23 ` exofs_file_fsync Boaz Harrosh
2010-05-31 10:27   ` exofs_file_fsync Christoph Hellwig
2010-05-31 10:31     ` exofs_file_fsync Boaz Harrosh
2010-05-31 10:33       ` exofs_file_fsync Christoph Hellwig
2010-05-31 13:43         ` exofs_file_fsync Boaz Harrosh
2010-05-31 13:46           ` exofs_file_fsync Boaz Harrosh
2010-06-01 10:05             ` exofs_file_fsync Christoph Hellwig
2010-06-01 10:04           ` exofs_file_fsync Christoph Hellwig
2010-06-01 15:29             ` exofs_file_fsync Boaz Harrosh
2010-06-01 15:30 ` [PATCH] exofs: exofs_file_fsync correctness Boaz Harrosh
2010-06-01 15:33   ` [osd-dev] " Boaz Harrosh
2010-06-01 15:34   ` Christoph Hellwig
2010-06-01 15:40     ` Boaz Harrosh
2010-06-01 15:47       ` Christoph Hellwig
2010-06-01 16:10         ` Boaz Harrosh
2010-06-01 16:11   ` [PATCH ver2] exofs: exofs_file_fsync and exofs_file_flush correctness Boaz Harrosh
2010-06-01 16:17     ` Christoph Hellwig
2010-06-01 16:36       ` Boaz Harrosh
2010-06-01 17:03   ` Boaz Harrosh [this message]

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=4C053D6B.3000704@panasas.com \
    --to=bharrosh@panasas.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=osd-dev@open-osd.org \
    /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).