5 #include <linux/kernel.h>
8 #include <linux/slab.h>
9 #include <linux/export.h>
11 #include <linux/sched.h>
14 #include <linux/linkage.h>
20 #define VALID_FLAGS (SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| \
21 SYNC_FILE_RANGE_WAIT_AFTER)
37 if (sb->
s_op->sync_fs)
38 sb->
s_op->sync_fs(sb, wait);
63 ret = __sync_filesystem(sb, 0);
66 return __sync_filesystem(sb, 1);
76 static void sync_fs_one_sb(
struct super_block *sb,
void *arg)
79 sb->
s_op->sync_fs(sb, *(
int *)arg);
82 static void fdatawrite_one_bdev(
struct block_device *bdev,
void *arg)
87 static void fdatawait_one_bdev(
struct block_device *bdev,
void *arg)
104 int nowait = 0,
wait = 1;
113 laptop_sync_completion();
131 printk(
"Emergency Sync complete\n");
151 struct fd f = fdget(
fd);
157 sb = f.
file->f_dentry->d_sb;
180 if (!file->
f_op || !file->
f_op->fsync)
182 return file->
f_op->fsync(file, start, end, datasync);
200 static int do_fsync(
unsigned int fd,
int datasync)
202 struct fd
f = fdget(fd);
214 return do_fsync(fd, 0);
219 return do_fsync(fd, 1);
299 endbyte = offset +
nbytes;
303 if ((
s64)endbyte < 0)
305 if (endbyte < offset)
335 i_mode = f.
file->f_path.dentry->d_inode->i_mode;
341 mapping = f.
file->f_mapping;
368 #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
369 asmlinkage long SyS_sync_file_range(
long fd, loff_t offset, loff_t nbytes,
372 return SYSC_sync_file_range((
int) fd, offset, nbytes,
373 (
unsigned int) flags);
385 #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
386 asmlinkage long SyS_sync_file_range2(
long fd,
long flags,
387 loff_t offset, loff_t nbytes)
389 return SYSC_sync_file_range2((
int) fd, (
unsigned int) flags,