diff options
Diffstat (limited to 'fs/sync.c')
-rw-r--r-- | fs/sync.c | 33 |
1 files changed, 14 insertions, 19 deletions
@@ -148,21 +148,19 @@ void emergency_sync(void) | |||
148 | */ | 148 | */ |
149 | SYSCALL_DEFINE1(syncfs, int, fd) | 149 | SYSCALL_DEFINE1(syncfs, int, fd) |
150 | { | 150 | { |
151 | struct file *file; | 151 | struct fd f = fdget(fd); |
152 | struct super_block *sb; | 152 | struct super_block *sb; |
153 | int ret; | 153 | int ret; |
154 | int fput_needed; | ||
155 | 154 | ||
156 | file = fget_light(fd, &fput_needed); | 155 | if (!f.file) |
157 | if (!file) | ||
158 | return -EBADF; | 156 | return -EBADF; |
159 | sb = file->f_dentry->d_sb; | 157 | sb = f.file->f_dentry->d_sb; |
160 | 158 | ||
161 | down_read(&sb->s_umount); | 159 | down_read(&sb->s_umount); |
162 | ret = sync_filesystem(sb); | 160 | ret = sync_filesystem(sb); |
163 | up_read(&sb->s_umount); | 161 | up_read(&sb->s_umount); |
164 | 162 | ||
165 | fput_light(file, fput_needed); | 163 | fdput(f); |
166 | return ret; | 164 | return ret; |
167 | } | 165 | } |
168 | 166 | ||
@@ -201,14 +199,12 @@ EXPORT_SYMBOL(vfs_fsync); | |||
201 | 199 | ||
202 | static int do_fsync(unsigned int fd, int datasync) | 200 | static int do_fsync(unsigned int fd, int datasync) |
203 | { | 201 | { |
204 | struct file *file; | 202 | struct fd f = fdget(fd); |
205 | int ret = -EBADF; | 203 | int ret = -EBADF; |
206 | int fput_needed; | ||
207 | 204 | ||
208 | file = fget_light(fd, &fput_needed); | 205 | if (f.file) { |
209 | if (file) { | 206 | ret = vfs_fsync(f.file, datasync); |
210 | ret = vfs_fsync(file, datasync); | 207 | fdput(f); |
211 | fput_light(file, fput_needed); | ||
212 | } | 208 | } |
213 | return ret; | 209 | return ret; |
214 | } | 210 | } |
@@ -291,10 +287,9 @@ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes, | |||
291 | unsigned int flags) | 287 | unsigned int flags) |
292 | { | 288 | { |
293 | int ret; | 289 | int ret; |
294 | struct file *file; | 290 | struct fd f; |
295 | struct address_space *mapping; | 291 | struct address_space *mapping; |
296 | loff_t endbyte; /* inclusive */ | 292 | loff_t endbyte; /* inclusive */ |
297 | int fput_needed; | ||
298 | umode_t i_mode; | 293 | umode_t i_mode; |
299 | 294 | ||
300 | ret = -EINVAL; | 295 | ret = -EINVAL; |
@@ -333,17 +328,17 @@ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes, | |||
333 | endbyte--; /* inclusive */ | 328 | endbyte--; /* inclusive */ |
334 | 329 | ||
335 | ret = -EBADF; | 330 | ret = -EBADF; |
336 | file = fget_light(fd, &fput_needed); | 331 | f = fdget(fd); |
337 | if (!file) | 332 | if (!f.file) |
338 | goto out; | 333 | goto out; |
339 | 334 | ||
340 | i_mode = file->f_path.dentry->d_inode->i_mode; | 335 | i_mode = f.file->f_path.dentry->d_inode->i_mode; |
341 | ret = -ESPIPE; | 336 | ret = -ESPIPE; |
342 | if (!S_ISREG(i_mode) && !S_ISBLK(i_mode) && !S_ISDIR(i_mode) && | 337 | if (!S_ISREG(i_mode) && !S_ISBLK(i_mode) && !S_ISDIR(i_mode) && |
343 | !S_ISLNK(i_mode)) | 338 | !S_ISLNK(i_mode)) |
344 | goto out_put; | 339 | goto out_put; |
345 | 340 | ||
346 | mapping = file->f_mapping; | 341 | mapping = f.file->f_mapping; |
347 | if (!mapping) { | 342 | if (!mapping) { |
348 | ret = -EINVAL; | 343 | ret = -EINVAL; |
349 | goto out_put; | 344 | goto out_put; |
@@ -366,7 +361,7 @@ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes, | |||
366 | ret = filemap_fdatawait_range(mapping, offset, endbyte); | 361 | ret = filemap_fdatawait_range(mapping, offset, endbyte); |
367 | 362 | ||
368 | out_put: | 363 | out_put: |
369 | fput_light(file, fput_needed); | 364 | fdput(f); |
370 | out: | 365 | out: |
371 | return ret; | 366 | return ret; |
372 | } | 367 | } |