From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boaz Harrosh Subject: [PATCH ver2] exofs: exofs_file_fsync and exofs_file_flush correctness Date: Tue, 01 Jun 2010 19:11:06 +0300 Message-ID: <4C05311A.8000801@panasas.com> References: <20100531100927.GA11149@lst.de> <4C0527AF.6090502@panasas.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, open-osd To: Christoph Hellwig Return-path: Received: from daytona.panasas.com ([67.152.220.89]:54563 "EHLO daytona.int.panasas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756587Ab0FAQLI (ORCPT ); Tue, 1 Jun 2010 12:11:08 -0400 In-Reply-To: <4C0527AF.6090502@panasas.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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_range should do that job. FIXME: remove the sb_sync and fix that sb_update better. Signed-off-by: Boaz Harrosh --- 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..e0eb219 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 - #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 + * + * @datasync is not used. All metadata is written in one place 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 writeback_control wbc = { + .sync_mode = WB_SYNC_ALL, + .nr_to_write = 0, /* metadata-only; caller takes care of data */ + }; + struct inode *inode = filp->f_mapping->host; 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_range(file, 0, LLONG_MAX, 0); /* TODO: Flush the OSD target */ - return 0; + return ret; } const struct file_operations exofs_file_operations = { -- 1.6.6.1