diff options
Diffstat (limited to 'fs/sync.c')
-rw-r--r-- | fs/sync.c | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/fs.h> | 7 | #include <linux/fs.h> |
8 | #include <linux/slab.h> | 8 | #include <linux/slab.h> |
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/namei.h> | ||
10 | #include <linux/sched.h> | 11 | #include <linux/sched.h> |
11 | #include <linux/writeback.h> | 12 | #include <linux/writeback.h> |
12 | #include <linux/syscalls.h> | 13 | #include <linux/syscalls.h> |
@@ -33,7 +34,7 @@ static int __sync_filesystem(struct super_block *sb, int wait) | |||
33 | * This should be safe, as we require bdi backing to actually | 34 | * This should be safe, as we require bdi backing to actually |
34 | * write out data in the first place | 35 | * write out data in the first place |
35 | */ | 36 | */ |
36 | if (!sb->s_bdi || sb->s_bdi == &noop_backing_dev_info) | 37 | if (sb->s_bdi == &noop_backing_dev_info) |
37 | return 0; | 38 | return 0; |
38 | 39 | ||
39 | if (sb->s_qcop && sb->s_qcop->quota_sync) | 40 | if (sb->s_qcop && sb->s_qcop->quota_sync) |
@@ -79,7 +80,7 @@ EXPORT_SYMBOL_GPL(sync_filesystem); | |||
79 | 80 | ||
80 | static void sync_one_sb(struct super_block *sb, void *arg) | 81 | static void sync_one_sb(struct super_block *sb, void *arg) |
81 | { | 82 | { |
82 | if (!(sb->s_flags & MS_RDONLY) && sb->s_bdi) | 83 | if (!(sb->s_flags & MS_RDONLY)) |
83 | __sync_filesystem(sb, *(int *)arg); | 84 | __sync_filesystem(sb, *(int *)arg); |
84 | } | 85 | } |
85 | /* | 86 | /* |
@@ -128,6 +129,29 @@ void emergency_sync(void) | |||
128 | } | 129 | } |
129 | } | 130 | } |
130 | 131 | ||
132 | /* | ||
133 | * sync a single super | ||
134 | */ | ||
135 | SYSCALL_DEFINE1(syncfs, int, fd) | ||
136 | { | ||
137 | struct file *file; | ||
138 | struct super_block *sb; | ||
139 | int ret; | ||
140 | int fput_needed; | ||
141 | |||
142 | file = fget_light(fd, &fput_needed); | ||
143 | if (!file) | ||
144 | return -EBADF; | ||
145 | sb = file->f_dentry->d_sb; | ||
146 | |||
147 | down_read(&sb->s_umount); | ||
148 | ret = sync_filesystem(sb); | ||
149 | up_read(&sb->s_umount); | ||
150 | |||
151 | fput_light(file, fput_needed); | ||
152 | return ret; | ||
153 | } | ||
154 | |||
131 | /** | 155 | /** |
132 | * vfs_fsync_range - helper to sync a range of data & metadata to disk | 156 | * vfs_fsync_range - helper to sync a range of data & metadata to disk |
133 | * @file: file to sync | 157 | * @file: file to sync |