Commit 7a0ad10c367ab57c899d340372f37880cbe6ab52
Committed by
Al Viro
1 parent
76b7e0058d
Exists in
master
and in
4 other branches
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>
Showing 2 changed files with 23 additions and 40 deletions Side-by-side Diff
fs/sync.c
... | ... | @@ -355,6 +355,7 @@ |
355 | 355 | { |
356 | 356 | int ret; |
357 | 357 | struct file *file; |
358 | + struct address_space *mapping; | |
358 | 359 | loff_t endbyte; /* inclusive */ |
359 | 360 | int fput_needed; |
360 | 361 | umode_t i_mode; |
... | ... | @@ -405,7 +406,28 @@ |
405 | 406 | !S_ISLNK(i_mode)) |
406 | 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 | 431 | out_put: |
410 | 432 | fput_light(file, fput_needed); |
411 | 433 | out: |
... | ... | @@ -437,39 +459,4 @@ |
437 | 459 | } |
438 | 460 | SYSCALL_ALIAS(sys_sync_file_range2, SyS_sync_file_range2); |
439 | 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); |
include/linux/fs.h
... | ... | @@ -1095,10 +1095,6 @@ |
1095 | 1095 | |
1096 | 1096 | extern void send_sigio(struct fown_struct *fown, int fd, int band); |
1097 | 1097 | |
1098 | -/* fs/sync.c */ | |
1099 | -extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, | |
1100 | - loff_t endbyte, unsigned int flags); | |
1101 | - | |
1102 | 1098 | #ifdef CONFIG_FILE_LOCKING |
1103 | 1099 | extern int fcntl_getlk(struct file *, struct flock __user *); |
1104 | 1100 | extern int fcntl_setlk(unsigned int, struct file *, unsigned int, |