diff options
-rw-r--r-- | fs/cifs/file.c | 4 | ||||
-rw-r--r-- | fs/ext4/file.c | 2 | ||||
-rw-r--r-- | fs/ntfs/file.c | 2 | ||||
-rw-r--r-- | fs/sync.c | 17 | ||||
-rw-r--r-- | fs/xfs/xfs_file.c | 2 | ||||
-rw-r--r-- | include/linux/fs.h | 8 | ||||
-rw-r--r-- | mm/filemap.c | 4 |
7 files changed, 14 insertions, 25 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 853d6d1cc822..a7eda8ebfacc 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -2559,8 +2559,8 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov, | |||
2559 | if (rc > 0) { | 2559 | if (rc > 0) { |
2560 | ssize_t err; | 2560 | ssize_t err; |
2561 | 2561 | ||
2562 | err = generic_write_sync(file, pos, rc); | 2562 | err = generic_write_sync(file, iocb->ki_pos - rc, rc); |
2563 | if (err < 0 && rc > 0) | 2563 | if (err < 0) |
2564 | rc = err; | 2564 | rc = err; |
2565 | } | 2565 | } |
2566 | 2566 | ||
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 43e64f6022eb..1a5073959f32 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -152,7 +152,7 @@ ext4_file_dio_write(struct kiocb *iocb, const struct iovec *iov, | |||
152 | if (ret > 0) { | 152 | if (ret > 0) { |
153 | ssize_t err; | 153 | ssize_t err; |
154 | 154 | ||
155 | err = generic_write_sync(file, pos, ret); | 155 | err = generic_write_sync(file, iocb->ki_pos - ret, ret); |
156 | if (err < 0 && ret > 0) | 156 | if (err < 0 && ret > 0) |
157 | ret = err; | 157 | ret = err; |
158 | } | 158 | } |
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index ea4ba9daeb47..db9bd8a31725 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c | |||
@@ -2134,7 +2134,7 @@ static ssize_t ntfs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2134 | ret = ntfs_file_aio_write_nolock(iocb, iov, nr_segs, &iocb->ki_pos); | 2134 | ret = ntfs_file_aio_write_nolock(iocb, iov, nr_segs, &iocb->ki_pos); |
2135 | mutex_unlock(&inode->i_mutex); | 2135 | mutex_unlock(&inode->i_mutex); |
2136 | if (ret > 0) { | 2136 | if (ret > 0) { |
2137 | int err = generic_write_sync(file, pos, ret); | 2137 | int err = generic_write_sync(file, iocb->ki_pos - ret, ret); |
2138 | if (err < 0) | 2138 | if (err < 0) |
2139 | ret = err; | 2139 | ret = err; |
2140 | } | 2140 | } |
@@ -222,23 +222,6 @@ SYSCALL_DEFINE1(fdatasync, unsigned int, fd) | |||
222 | return do_fsync(fd, 1); | 222 | return do_fsync(fd, 1); |
223 | } | 223 | } |
224 | 224 | ||
225 | /** | ||
226 | * generic_write_sync - perform syncing after a write if file / inode is sync | ||
227 | * @file: file to which the write happened | ||
228 | * @pos: offset where the write started | ||
229 | * @count: length of the write | ||
230 | * | ||
231 | * This is just a simple wrapper about our general syncing function. | ||
232 | */ | ||
233 | int generic_write_sync(struct file *file, loff_t pos, loff_t count) | ||
234 | { | ||
235 | if (!(file->f_flags & O_DSYNC) && !IS_SYNC(file->f_mapping->host)) | ||
236 | return 0; | ||
237 | return vfs_fsync_range(file, pos, pos + count - 1, | ||
238 | (file->f_flags & __O_SYNC) ? 0 : 1); | ||
239 | } | ||
240 | EXPORT_SYMBOL(generic_write_sync); | ||
241 | |||
242 | /* | 225 | /* |
243 | * sys_sync_file_range() permits finely controlled syncing over a segment of | 226 | * sys_sync_file_range() permits finely controlled syncing over a segment of |
244 | * a file in the range offset .. (offset+nbytes-1) inclusive. If nbytes is | 227 | * a file in the range offset .. (offset+nbytes-1) inclusive. If nbytes is |
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 2e7989e3a2d6..64b48eade91d 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
@@ -799,7 +799,7 @@ xfs_file_aio_write( | |||
799 | XFS_STATS_ADD(xs_write_bytes, ret); | 799 | XFS_STATS_ADD(xs_write_bytes, ret); |
800 | 800 | ||
801 | /* Handle various SYNC-type writes */ | 801 | /* Handle various SYNC-type writes */ |
802 | err = generic_write_sync(file, pos, ret); | 802 | err = generic_write_sync(file, iocb->ki_pos - ret, ret); |
803 | if (err < 0) | 803 | if (err < 0) |
804 | ret = err; | 804 | ret = err; |
805 | } | 805 | } |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 09f553c59813..75ff961be051 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -2273,7 +2273,13 @@ extern int filemap_fdatawrite_range(struct address_space *mapping, | |||
2273 | extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end, | 2273 | extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end, |
2274 | int datasync); | 2274 | int datasync); |
2275 | extern int vfs_fsync(struct file *file, int datasync); | 2275 | extern int vfs_fsync(struct file *file, int datasync); |
2276 | extern int generic_write_sync(struct file *file, loff_t pos, loff_t count); | 2276 | static inline int generic_write_sync(struct file *file, loff_t pos, loff_t count) |
2277 | { | ||
2278 | if (!(file->f_flags & O_DSYNC) && !IS_SYNC(file->f_mapping->host)) | ||
2279 | return 0; | ||
2280 | return vfs_fsync_range(file, pos, pos + count - 1, | ||
2281 | (file->f_flags & __O_SYNC) ? 0 : 1); | ||
2282 | } | ||
2277 | extern void emergency_sync(void); | 2283 | extern void emergency_sync(void); |
2278 | extern void emergency_remount(void); | 2284 | extern void emergency_remount(void); |
2279 | #ifdef CONFIG_BLOCK | 2285 | #ifdef CONFIG_BLOCK |
diff --git a/mm/filemap.c b/mm/filemap.c index d56d3c145b9f..7a13f6ac5421 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -2553,8 +2553,8 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2553 | if (ret > 0) { | 2553 | if (ret > 0) { |
2554 | ssize_t err; | 2554 | ssize_t err; |
2555 | 2555 | ||
2556 | err = generic_write_sync(file, pos, ret); | 2556 | err = generic_write_sync(file, iocb->ki_pos - ret, ret); |
2557 | if (err < 0 && ret > 0) | 2557 | if (err < 0) |
2558 | ret = err; | 2558 | ret = err; |
2559 | } | 2559 | } |
2560 | return ret; | 2560 | return ret; |