[PATCH 1/2][FAT] miss-sync issues on sync mount (miss-sync on write)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch fixes miss-sync issue on write() system call.
This updates inode attrs flags, mtime and ctime on every
comit_write call, due to locking.

---
Hiroyuki Machida

Signed-off-by: Hiroyuki Machida <[email protected]>
 ---

 file.c  |   20 +-------------------
 inode.c |   21 ++++++++++++++++++++-
 2 files changed, 21 insertions(+), 20 deletions(-)


--- linux-2.6.13.org/fs/fat/inode.c	2005-08-29 08:41:01.000000000 +0900
+++ linux-2.6.13/fs/fat/inode.c	2005-09-09 17:22:44.305189111 +0900
@@ -107,12 +107,31 @@ static sector_t _fat_bmap(struct address
 	return generic_block_bmap(mapping, block, fat_get_block);
 }
 
+static int fat_commit_write(struct file *file, struct page *page,
+		unsigned from, unsigned to)
+{
+	struct inode *inode = page->mapping->host;
+	loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
+	block_commit_write(page,from,to);
+	/*
+	 * No need to use i_size_read() here, the i_size
+	 * cannot change under us because we hold i_sem.
+	 */
+	if (pos > inode->i_size) {
+		i_size_write(inode, pos);
+	}
+	inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
+	MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
+	mark_inode_dirty(inode);
+	return 0;
+}
+
 static struct address_space_operations fat_aops = {
 	.readpage	= fat_readpage,
 	.writepage	= fat_writepage,
 	.sync_page	= block_sync_page,
 	.prepare_write	= fat_prepare_write,
-	.commit_write	= generic_commit_write,
+	.commit_write	= fat_commit_write,
 	.bmap		= _fat_bmap
 };
 
--- linux-2.6.13.org/fs/fat/file.c	2005-08-29 08:41:01.000000000 +0900
+++ linux-2.6.13/fs/fat/file.c	2005-09-08 17:13:03.000000000 +0900
@@ -12,24 +12,6 @@
 #include <linux/smp_lock.h>
 #include <linux/buffer_head.h>
 
-static ssize_t fat_file_aio_write(struct kiocb *iocb, const char __user *buf,
-				  size_t count, loff_t pos)
-{
-	struct inode *inode = iocb->ki_filp->f_dentry->d_inode;
-	int retval;
-
-	retval = generic_file_aio_write(iocb, buf, count, pos);
-	if (retval > 0) {
-		inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
-		MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
-		mark_inode_dirty(inode);
-//		check the locking rules
-//		if (IS_SYNC(inode))
-//			fat_sync_inode(inode);
-	}
-	return retval;
-}
-
 static ssize_t fat_file_writev(struct file *filp, const struct iovec *iov,
 			       unsigned long nr_segs, loff_t *ppos)
 {
@@ -150,7 +132,7 @@ struct file_operations fat_file_operatio
 	.readv		= generic_file_readv,
 	.writev		= fat_file_writev,
 	.aio_read	= generic_file_aio_read,
-	.aio_write	= fat_file_aio_write,
+	.aio_write	= generic_file_aio_write,
 	.mmap		= generic_file_mmap,
 	.ioctl		= fat_generic_ioctl,
 	.fsync		= file_fsync,

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux