diff options
Diffstat (limited to 'fs/ext4/file.c')
-rw-r--r-- | fs/ext4/file.c | 53 |
1 files changed, 2 insertions, 51 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 27f3c5354c0e..5ca3eca70a1e 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -58,10 +58,7 @@ static ssize_t | |||
58 | ext4_file_write(struct kiocb *iocb, const struct iovec *iov, | 58 | ext4_file_write(struct kiocb *iocb, const struct iovec *iov, |
59 | unsigned long nr_segs, loff_t pos) | 59 | unsigned long nr_segs, loff_t pos) |
60 | { | 60 | { |
61 | struct file *file = iocb->ki_filp; | 61 | struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; |
62 | struct inode *inode = file->f_path.dentry->d_inode; | ||
63 | ssize_t ret; | ||
64 | int err; | ||
65 | 62 | ||
66 | /* | 63 | /* |
67 | * If we have encountered a bitmap-format file, the size limit | 64 | * If we have encountered a bitmap-format file, the size limit |
@@ -81,53 +78,7 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov, | |||
81 | } | 78 | } |
82 | } | 79 | } |
83 | 80 | ||
84 | ret = generic_file_aio_write(iocb, iov, nr_segs, pos); | 81 | return generic_file_aio_write(iocb, iov, nr_segs, pos); |
85 | /* | ||
86 | * Skip flushing if there was an error, or if nothing was written. | ||
87 | */ | ||
88 | if (ret <= 0) | ||
89 | return ret; | ||
90 | |||
91 | /* | ||
92 | * If the inode is IS_SYNC, or is O_SYNC and we are doing data | ||
93 | * journalling then we need to make sure that we force the transaction | ||
94 | * to disk to keep all metadata uptodate synchronously. | ||
95 | */ | ||
96 | if (file->f_flags & O_SYNC) { | ||
97 | /* | ||
98 | * If we are non-data-journaled, then the dirty data has | ||
99 | * already been flushed to backing store by generic_osync_inode, | ||
100 | * and the inode has been flushed too if there have been any | ||
101 | * modifications other than mere timestamp updates. | ||
102 | * | ||
103 | * Open question --- do we care about flushing timestamps too | ||
104 | * if the inode is IS_SYNC? | ||
105 | */ | ||
106 | if (!ext4_should_journal_data(inode)) | ||
107 | return ret; | ||
108 | |||
109 | goto force_commit; | ||
110 | } | ||
111 | |||
112 | /* | ||
113 | * So we know that there has been no forced data flush. If the inode | ||
114 | * is marked IS_SYNC, we need to force one ourselves. | ||
115 | */ | ||
116 | if (!IS_SYNC(inode)) | ||
117 | return ret; | ||
118 | |||
119 | /* | ||
120 | * Open question #2 --- should we force data to disk here too? If we | ||
121 | * don't, the only impact is that data=writeback filesystems won't | ||
122 | * flush data to disk automatically on IS_SYNC, only metadata (but | ||
123 | * historically, that is what ext2 has done.) | ||
124 | */ | ||
125 | |||
126 | force_commit: | ||
127 | err = ext4_force_commit(inode->i_sb); | ||
128 | if (err) | ||
129 | return err; | ||
130 | return ret; | ||
131 | } | 82 | } |
132 | 83 | ||
133 | static struct vm_operations_struct ext4_file_vm_ops = { | 84 | static struct vm_operations_struct ext4_file_vm_ops = { |