Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 177751
b: refs/heads/master
c: 7a0ad10
h: refs/heads/master
i:
  177749: 4e82bf0
  177747: 21cfbfb
  177743: 38d20c4
v: v3
  • Loading branch information
Christoph Hellwig authored and Al Viro committed Dec 17, 2009
1 parent 6fc910f commit 286115b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 41 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 76b7e0058d09f8104387980a690001681c04cc0a
refs/heads/master: 7a0ad10c367ab57c899d340372f37880cbe6ab52
59 changes: 23 additions & 36 deletions trunk/fs/sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes,
{
int ret;
struct file *file;
struct address_space *mapping;
loff_t endbyte; /* inclusive */
int fput_needed;
umode_t i_mode;
Expand Down Expand Up @@ -405,7 +406,28 @@ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes,
!S_ISLNK(i_mode))
goto out_put;

ret = do_sync_mapping_range(file->f_mapping, offset, endbyte, flags);
mapping = file->f_mapping;
if (!mapping) {
ret = -EINVAL;
goto out_put;
}

ret = 0;
if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) {
ret = filemap_fdatawait_range(mapping, offset, endbyte);
if (ret < 0)
goto out_put;
}

if (flags & SYNC_FILE_RANGE_WRITE) {
ret = filemap_fdatawrite_range(mapping, offset, endbyte);
if (ret < 0)
goto out_put;
}

if (flags & SYNC_FILE_RANGE_WAIT_AFTER)
ret = filemap_fdatawait_range(mapping, offset, endbyte);

out_put:
fput_light(file, fput_needed);
out:
Expand Down Expand Up @@ -437,38 +459,3 @@ asmlinkage long SyS_sync_file_range2(long fd, long flags,
}
SYSCALL_ALIAS(sys_sync_file_range2, SyS_sync_file_range2);
#endif

/*
* `endbyte' is inclusive
*/
int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
loff_t endbyte, unsigned int flags)
{
int ret;

if (!mapping) {
ret = -EINVAL;
goto out;
}

ret = 0;
if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) {
ret = filemap_fdatawait_range(mapping, offset, endbyte);
if (ret < 0)
goto out;
}

if (flags & SYNC_FILE_RANGE_WRITE) {
ret = __filemap_fdatawrite_range(mapping, offset, endbyte,
WB_SYNC_ALL);
if (ret < 0)
goto out;
}

if (flags & SYNC_FILE_RANGE_WAIT_AFTER) {
ret = filemap_fdatawait_range(mapping, offset, endbyte);
}
out:
return ret;
}
EXPORT_SYMBOL_GPL(do_sync_mapping_range);
4 changes: 0 additions & 4 deletions trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1095,10 +1095,6 @@ struct file_lock {

extern void send_sigio(struct fown_struct *fown, int fd, int band);

/* fs/sync.c */
extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
loff_t endbyte, unsigned int flags);

#ifdef CONFIG_FILE_LOCKING
extern int fcntl_getlk(struct file *, struct flock __user *);
extern int fcntl_setlk(unsigned int, struct file *, unsigned int,
Expand Down

0 comments on commit 286115b

Please sign in to comment.