diff options
author | Christoph Hellwig <hch@lst.de> | 2009-12-17 08:24:40 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-17 11:03:25 -0500 |
commit | 7a0ad10c367ab57c899d340372f37880cbe6ab52 (patch) | |
tree | 7e21f078c03cbeb350d964c23a2c49f7016f5ef7 /fs/sync.c | |
parent | 76b7e0058d09f8104387980a690001681c04cc0a (diff) |
fold do_sync_file_range into sys_sync_file_range
We recently go rid of all callers of do_sync_file_range as they're better
served with vfs_fsync or the filemap_write_and_wait. Now that
do_sync_file_range is down to a single caller fold it into it so that people
don't start using it again accidentally. While at it also switch it from
using __filemap_fdatawrite_range(..., WB_SYNC_ALL) to the more clear
filemap_fdatawrite_range().
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/sync.c')
-rw-r--r-- | fs/sync.c | 59 |
1 files changed, 23 insertions, 36 deletions
@@ -355,6 +355,7 @@ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes, | |||
355 | { | 355 | { |
356 | int ret; | 356 | int ret; |
357 | struct file *file; | 357 | struct file *file; |
358 | struct address_space *mapping; | ||
358 | loff_t endbyte; /* inclusive */ | 359 | loff_t endbyte; /* inclusive */ |
359 | int fput_needed; | 360 | int fput_needed; |
360 | umode_t i_mode; | 361 | umode_t i_mode; |
@@ -405,7 +406,28 @@ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes, | |||
405 | !S_ISLNK(i_mode)) | 406 | !S_ISLNK(i_mode)) |
406 | goto out_put; | 407 | goto out_put; |
407 | 408 | ||
408 | ret = do_sync_mapping_range(file->f_mapping, offset, endbyte, flags); | 409 | mapping = file->f_mapping; |
410 | if (!mapping) { | ||
411 | ret = -EINVAL; | ||
412 | goto out_put; | ||
413 | } | ||
414 | |||
415 | ret = 0; | ||
416 | if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) { | ||
417 | ret = filemap_fdatawait_range(mapping, offset, endbyte); | ||
418 | if (ret < 0) | ||
419 | goto out_put; | ||
420 | } | ||
421 | |||
422 | if (flags & SYNC_FILE_RANGE_WRITE) { | ||
423 | ret = filemap_fdatawrite_range(mapping, offset, endbyte); | ||
424 | if (ret < 0) | ||
425 | goto out_put; | ||
426 | } | ||
427 | |||
428 | if (flags & SYNC_FILE_RANGE_WAIT_AFTER) | ||
429 | ret = filemap_fdatawait_range(mapping, offset, endbyte); | ||
430 | |||
409 | out_put: | 431 | out_put: |
410 | fput_light(file, fput_needed); | 432 | fput_light(file, fput_needed); |
411 | out: | 433 | out: |
@@ -437,38 +459,3 @@ asmlinkage long SyS_sync_file_range2(long fd, long flags, | |||
437 | } | 459 | } |
438 | SYSCALL_ALIAS(sys_sync_file_range2, SyS_sync_file_range2); | 460 | SYSCALL_ALIAS(sys_sync_file_range2, SyS_sync_file_range2); |
439 | #endif | 461 | #endif |
440 | |||
441 | /* | ||
442 | * `endbyte' is inclusive | ||
443 | */ | ||
444 | int do_sync_mapping_range(struct address_space *mapping, loff_t offset, | ||
445 | loff_t endbyte, unsigned int flags) | ||
446 | { | ||
447 | int ret; | ||
448 | |||
449 | if (!mapping) { | ||
450 | ret = -EINVAL; | ||
451 | goto out; | ||
452 | } | ||
453 | |||
454 | ret = 0; | ||
455 | if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) { | ||
456 | ret = filemap_fdatawait_range(mapping, offset, endbyte); | ||
457 | if (ret < 0) | ||
458 | goto out; | ||
459 | } | ||
460 | |||
461 | if (flags & SYNC_FILE_RANGE_WRITE) { | ||
462 | ret = __filemap_fdatawrite_range(mapping, offset, endbyte, | ||
463 | WB_SYNC_ALL); | ||
464 | if (ret < 0) | ||
465 | goto out; | ||
466 | } | ||
467 | |||
468 | if (flags & SYNC_FILE_RANGE_WAIT_AFTER) { | ||
469 | ret = filemap_fdatawait_range(mapping, offset, endbyte); | ||
470 | } | ||
471 | out: | ||
472 | return ret; | ||
473 | } | ||
474 | EXPORT_SYMBOL_GPL(do_sync_mapping_range); | ||