diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-08-28 12:52:22 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-09-26 22:20:08 -0400 |
commit | 2903ff019b346ab8d36ebbf54853c3aaf6590608 (patch) | |
tree | 962d94054765bb37bc00e977c3036e65c5fd91fe /mm/fadvise.c | |
parent | a5b470ba06aa3f96999ede5feba178df6bdb134a (diff) |
switch simple cases of fget_light to fdget
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm/fadvise.c')
-rw-r--r-- | mm/fadvise.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/mm/fadvise.c b/mm/fadvise.c index a83245763cf8..a47f0f50c89f 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c | |||
@@ -26,8 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice) | 27 | SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice) |
28 | { | 28 | { |
29 | int fput_needed; | 29 | struct fd f = fdget(fd); |
30 | struct file *file = fget_light(fd, &fput_needed); | ||
31 | struct address_space *mapping; | 30 | struct address_space *mapping; |
32 | struct backing_dev_info *bdi; | 31 | struct backing_dev_info *bdi; |
33 | loff_t endbyte; /* inclusive */ | 32 | loff_t endbyte; /* inclusive */ |
@@ -36,15 +35,15 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice) | |||
36 | unsigned long nrpages; | 35 | unsigned long nrpages; |
37 | int ret = 0; | 36 | int ret = 0; |
38 | 37 | ||
39 | if (!file) | 38 | if (!f.file) |
40 | return -EBADF; | 39 | return -EBADF; |
41 | 40 | ||
42 | if (S_ISFIFO(file->f_path.dentry->d_inode->i_mode)) { | 41 | if (S_ISFIFO(f.file->f_path.dentry->d_inode->i_mode)) { |
43 | ret = -ESPIPE; | 42 | ret = -ESPIPE; |
44 | goto out; | 43 | goto out; |
45 | } | 44 | } |
46 | 45 | ||
47 | mapping = file->f_mapping; | 46 | mapping = f.file->f_mapping; |
48 | if (!mapping || len < 0) { | 47 | if (!mapping || len < 0) { |
49 | ret = -EINVAL; | 48 | ret = -EINVAL; |
50 | goto out; | 49 | goto out; |
@@ -77,21 +76,21 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice) | |||
77 | 76 | ||
78 | switch (advice) { | 77 | switch (advice) { |
79 | case POSIX_FADV_NORMAL: | 78 | case POSIX_FADV_NORMAL: |
80 | file->f_ra.ra_pages = bdi->ra_pages; | 79 | f.file->f_ra.ra_pages = bdi->ra_pages; |
81 | spin_lock(&file->f_lock); | 80 | spin_lock(&f.file->f_lock); |
82 | file->f_mode &= ~FMODE_RANDOM; | 81 | f.file->f_mode &= ~FMODE_RANDOM; |
83 | spin_unlock(&file->f_lock); | 82 | spin_unlock(&f.file->f_lock); |
84 | break; | 83 | break; |
85 | case POSIX_FADV_RANDOM: | 84 | case POSIX_FADV_RANDOM: |
86 | spin_lock(&file->f_lock); | 85 | spin_lock(&f.file->f_lock); |
87 | file->f_mode |= FMODE_RANDOM; | 86 | f.file->f_mode |= FMODE_RANDOM; |
88 | spin_unlock(&file->f_lock); | 87 | spin_unlock(&f.file->f_lock); |
89 | break; | 88 | break; |
90 | case POSIX_FADV_SEQUENTIAL: | 89 | case POSIX_FADV_SEQUENTIAL: |
91 | file->f_ra.ra_pages = bdi->ra_pages * 2; | 90 | f.file->f_ra.ra_pages = bdi->ra_pages * 2; |
92 | spin_lock(&file->f_lock); | 91 | spin_lock(&f.file->f_lock); |
93 | file->f_mode &= ~FMODE_RANDOM; | 92 | f.file->f_mode &= ~FMODE_RANDOM; |
94 | spin_unlock(&file->f_lock); | 93 | spin_unlock(&f.file->f_lock); |
95 | break; | 94 | break; |
96 | case POSIX_FADV_WILLNEED: | 95 | case POSIX_FADV_WILLNEED: |
97 | /* First and last PARTIAL page! */ | 96 | /* First and last PARTIAL page! */ |
@@ -107,7 +106,7 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice) | |||
107 | * Ignore return value because fadvise() shall return | 106 | * Ignore return value because fadvise() shall return |
108 | * success even if filesystem can't retrieve a hint, | 107 | * success even if filesystem can't retrieve a hint, |
109 | */ | 108 | */ |
110 | force_page_cache_readahead(mapping, file, start_index, | 109 | force_page_cache_readahead(mapping, f.file, start_index, |
111 | nrpages); | 110 | nrpages); |
112 | break; | 111 | break; |
113 | case POSIX_FADV_NOREUSE: | 112 | case POSIX_FADV_NOREUSE: |
@@ -129,7 +128,7 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice) | |||
129 | ret = -EINVAL; | 128 | ret = -EINVAL; |
130 | } | 129 | } |
131 | out: | 130 | out: |
132 | fput_light(file, fput_needed); | 131 | fdput(f); |
133 | return ret; | 132 | return ret; |
134 | } | 133 | } |
135 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | 134 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS |