diff options
author | Jan Kara <jack@suse.cz> | 2009-08-17 13:52:36 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2009-09-14 11:08:15 -0400 |
commit | 148f948ba877f4d3cdef036b1ff6d9f68986706a (patch) | |
tree | c07963f08bf8c2119ec00df64e4293e2e60acaa1 /mm/filemap.c | |
parent | eef99380679e20e7edc096aa4d8a98b875404d79 (diff) |
vfs: Introduce new helpers for syncing after writing to O_SYNC file or IS_SYNC inode
Introduce new function for generic inode syncing (vfs_fsync_range) and use
it from fsync() path. Introduce also new helper for syncing after a sync
write (generic_write_sync) using the generic function.
Use these new helpers for syncing from generic VFS functions. This makes
O_SYNC writes to block devices acquire i_mutex for syncing. If we really
care about this, we can make block_fsync() drop the i_mutex and reacquire
it before it returns.
CC: Evgeniy Polyakov <zbr@ioremap.net>
CC: ocfs2-devel@oss.oracle.com
CC: Joel Becker <joel.becker@oracle.com>
CC: Felix Blyakher <felixb@sgi.com>
CC: xfs@oss.sgi.com
CC: Anton Altaparmakov <aia21@cantab.net>
CC: linux-ntfs-dev@lists.sourceforge.net
CC: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
CC: linux-ext4@vger.kernel.org
CC: tytso@mit.edu
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 3587554f45ef..849293c4f418 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -39,11 +39,10 @@ | |||
39 | /* | 39 | /* |
40 | * FIXME: remove all knowledge of the buffer layer from the core VM | 40 | * FIXME: remove all knowledge of the buffer layer from the core VM |
41 | */ | 41 | */ |
42 | #include <linux/buffer_head.h> /* for generic_osync_inode */ | 42 | #include <linux/buffer_head.h> /* for try_to_free_buffers */ |
43 | 43 | ||
44 | #include <asm/mman.h> | 44 | #include <asm/mman.h> |
45 | 45 | ||
46 | |||
47 | /* | 46 | /* |
48 | * Shared mappings implemented 30.11.1994. It's not fully working yet, | 47 | * Shared mappings implemented 30.11.1994. It's not fully working yet, |
49 | * though. | 48 | * though. |
@@ -2477,8 +2476,7 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2477 | unsigned long nr_segs, loff_t pos) | 2476 | unsigned long nr_segs, loff_t pos) |
2478 | { | 2477 | { |
2479 | struct file *file = iocb->ki_filp; | 2478 | struct file *file = iocb->ki_filp; |
2480 | struct address_space *mapping = file->f_mapping; | 2479 | struct inode *inode = file->f_mapping->host; |
2481 | struct inode *inode = mapping->host; | ||
2482 | ssize_t ret; | 2480 | ssize_t ret; |
2483 | 2481 | ||
2484 | BUG_ON(iocb->ki_pos != pos); | 2482 | BUG_ON(iocb->ki_pos != pos); |
@@ -2487,11 +2485,10 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2487 | ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); | 2485 | ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); |
2488 | mutex_unlock(&inode->i_mutex); | 2486 | mutex_unlock(&inode->i_mutex); |
2489 | 2487 | ||
2490 | if ((ret > 0 || ret == -EIOCBQUEUED) && | 2488 | if (ret > 0 || ret == -EIOCBQUEUED) { |
2491 | ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { | ||
2492 | ssize_t err; | 2489 | ssize_t err; |
2493 | 2490 | ||
2494 | err = sync_page_range(inode, mapping, pos, ret); | 2491 | err = generic_write_sync(file, pos, ret); |
2495 | if (err < 0 && ret > 0) | 2492 | if (err < 0 && ret > 0) |
2496 | ret = err; | 2493 | ret = err; |
2497 | } | 2494 | } |