Commit b2848349296f3428850eb34c3a52d586f48d4b04
1 parent
85dc7878c6
Exists in
master
and in
4 other branches
exofs: exofs_file_fsync and exofs_file_flush correctness
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>
Showing 1 changed file with 17 additions and 12 deletions Side-by-side Diff
fs/exofs/file.c
... | ... | @@ -30,9 +30,6 @@ |
30 | 30 | * along with exofs; if not, write to the Free Software |
31 | 31 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
32 | 32 | */ |
33 | - | |
34 | -#include <linux/buffer_head.h> | |
35 | - | |
36 | 33 | #include "exofs.h" |
37 | 34 | |
38 | 35 | static int exofs_release_file(struct inode *inode, struct file *filp) |
39 | 36 | |
40 | 37 | |
41 | 38 | |
... | ... | @@ -40,19 +37,27 @@ |
40 | 37 | return 0; |
41 | 38 | } |
42 | 39 | |
40 | +/* exofs_file_fsync - flush the inode to disk | |
41 | + * | |
42 | + * Note, in exofs all metadata is written as part of inode, regardless. | |
43 | + * The writeout is synchronous | |
44 | + */ | |
43 | 45 | static int exofs_file_fsync(struct file *filp, int datasync) |
44 | 46 | { |
45 | 47 | int ret; |
46 | - struct address_space *mapping = filp->f_mapping; | |
47 | - struct inode *inode = mapping->host; | |
48 | + struct inode *inode = filp->f_mapping->host; | |
49 | + struct writeback_control wbc = { | |
50 | + .sync_mode = WB_SYNC_ALL, | |
51 | + .nr_to_write = 0, /* metadata-only; caller takes care of data */ | |
52 | + }; | |
48 | 53 | struct super_block *sb; |
49 | 54 | |
50 | - ret = filemap_write_and_wait(mapping); | |
51 | - if (ret) | |
52 | - return ret; | |
55 | + if (!(inode->i_state & I_DIRTY)) | |
56 | + return 0; | |
57 | + if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) | |
58 | + return 0; | |
53 | 59 | |
54 | - /* sync the inode attributes */ | |
55 | - ret = write_inode_now(inode, 1); | |
60 | + ret = sync_inode(inode, &wbc); | |
56 | 61 | |
57 | 62 | /* This is a good place to write the sb */ |
58 | 63 | /* TODO: Sechedule an sb-sync on create */ |
59 | 64 | |
... | ... | @@ -65,9 +70,9 @@ |
65 | 70 | |
66 | 71 | static int exofs_flush(struct file *file, fl_owner_t id) |
67 | 72 | { |
68 | - exofs_file_fsync(file, 1); | |
73 | + int ret = vfs_fsync(file, 0); | |
69 | 74 | /* TODO: Flush the OSD target */ |
70 | - return 0; | |
75 | + return ret; | |
71 | 76 | } |
72 | 77 | |
73 | 78 | const struct file_operations exofs_file_operations = { |