diff options
author | Christoph Hellwig <hch@lst.de> | 2010-03-22 12:32:25 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-05-21 18:31:21 -0400 |
commit | 8018ab057480974e7f26a387bf4ce040e9a5f6f1 (patch) | |
tree | 98298180bf60797a028eca4f24234dc67d38a9d4 /fs/sync.c | |
parent | e970a573ce30a3976234dcfb67906c164b0df9ee (diff) |
sanitize vfs_fsync calling conventions
Now that the last user passing a NULL file pointer is gone we can remove
the redundant dentry argument and associated hacks inside vfs_fsynmc_range.
The next step will be removig the dentry argument from ->fsync, but given
the luck with the last round of method prototype changes I'd rather
defer this until after the main merge window.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/sync.c')
-rw-r--r-- | fs/sync.c | 42 |
1 files changed, 8 insertions, 34 deletions
@@ -158,7 +158,6 @@ EXPORT_SYMBOL(file_fsync); | |||
158 | /** | 158 | /** |
159 | * vfs_fsync_range - helper to sync a range of data & metadata to disk | 159 | * vfs_fsync_range - helper to sync a range of data & metadata to disk |
160 | * @file: file to sync | 160 | * @file: file to sync |
161 | * @dentry: dentry of @file | ||
162 | * @start: offset in bytes of the beginning of data range to sync | 161 | * @start: offset in bytes of the beginning of data range to sync |
163 | * @end: offset in bytes of the end of data range (inclusive) | 162 | * @end: offset in bytes of the end of data range (inclusive) |
164 | * @datasync: perform only datasync | 163 | * @datasync: perform only datasync |
@@ -166,32 +165,13 @@ EXPORT_SYMBOL(file_fsync); | |||
166 | * Write back data in range @start..@end and metadata for @file to disk. If | 165 | * Write back data in range @start..@end and metadata for @file to disk. If |
167 | * @datasync is set only metadata needed to access modified file data is | 166 | * @datasync is set only metadata needed to access modified file data is |
168 | * written. | 167 | * written. |
169 | * | ||
170 | * In case this function is called from nfsd @file may be %NULL and | ||
171 | * only @dentry is set. This can only happen when the filesystem | ||
172 | * implements the export_operations API. | ||
173 | */ | 168 | */ |
174 | int vfs_fsync_range(struct file *file, struct dentry *dentry, loff_t start, | 169 | int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync) |
175 | loff_t end, int datasync) | ||
176 | { | 170 | { |
177 | const struct file_operations *fop; | 171 | struct address_space *mapping = file->f_mapping; |
178 | struct address_space *mapping; | ||
179 | int err, ret; | 172 | int err, ret; |
180 | 173 | ||
181 | /* | 174 | if (!file->f_op || !file->f_op->fsync) { |
182 | * Get mapping and operations from the file in case we have | ||
183 | * as file, or get the default values for them in case we | ||
184 | * don't have a struct file available. Damn nfsd.. | ||
185 | */ | ||
186 | if (file) { | ||
187 | mapping = file->f_mapping; | ||
188 | fop = file->f_op; | ||
189 | } else { | ||
190 | mapping = dentry->d_inode->i_mapping; | ||
191 | fop = dentry->d_inode->i_fop; | ||
192 | } | ||
193 | |||
194 | if (!fop || !fop->fsync) { | ||
195 | ret = -EINVAL; | 175 | ret = -EINVAL; |
196 | goto out; | 176 | goto out; |
197 | } | 177 | } |
@@ -203,7 +183,7 @@ int vfs_fsync_range(struct file *file, struct dentry *dentry, loff_t start, | |||
203 | * livelocks in fsync_buffers_list(). | 183 | * livelocks in fsync_buffers_list(). |
204 | */ | 184 | */ |
205 | mutex_lock(&mapping->host->i_mutex); | 185 | mutex_lock(&mapping->host->i_mutex); |
206 | err = fop->fsync(file, dentry, datasync); | 186 | err = file->f_op->fsync(file, file->f_path.dentry, datasync); |
207 | if (!ret) | 187 | if (!ret) |
208 | ret = err; | 188 | ret = err; |
209 | mutex_unlock(&mapping->host->i_mutex); | 189 | mutex_unlock(&mapping->host->i_mutex); |
@@ -216,19 +196,14 @@ EXPORT_SYMBOL(vfs_fsync_range); | |||
216 | /** | 196 | /** |
217 | * vfs_fsync - perform a fsync or fdatasync on a file | 197 | * vfs_fsync - perform a fsync or fdatasync on a file |
218 | * @file: file to sync | 198 | * @file: file to sync |
219 | * @dentry: dentry of @file | ||
220 | * @datasync: only perform a fdatasync operation | 199 | * @datasync: only perform a fdatasync operation |
221 | * | 200 | * |
222 | * Write back data and metadata for @file to disk. If @datasync is | 201 | * Write back data and metadata for @file to disk. If @datasync is |
223 | * set only metadata needed to access modified file data is written. | 202 | * set only metadata needed to access modified file data is written. |
224 | * | ||
225 | * In case this function is called from nfsd @file may be %NULL and | ||
226 | * only @dentry is set. This can only happen when the filesystem | ||
227 | * implements the export_operations API. | ||
228 | */ | 203 | */ |
229 | int vfs_fsync(struct file *file, struct dentry *dentry, int datasync) | 204 | int vfs_fsync(struct file *file, int datasync) |
230 | { | 205 | { |
231 | return vfs_fsync_range(file, dentry, 0, LLONG_MAX, datasync); | 206 | return vfs_fsync_range(file, 0, LLONG_MAX, datasync); |
232 | } | 207 | } |
233 | EXPORT_SYMBOL(vfs_fsync); | 208 | EXPORT_SYMBOL(vfs_fsync); |
234 | 209 | ||
@@ -239,7 +214,7 @@ static int do_fsync(unsigned int fd, int datasync) | |||
239 | 214 | ||
240 | file = fget(fd); | 215 | file = fget(fd); |
241 | if (file) { | 216 | if (file) { |
242 | ret = vfs_fsync(file, file->f_path.dentry, datasync); | 217 | ret = vfs_fsync(file, datasync); |
243 | fput(file); | 218 | fput(file); |
244 | } | 219 | } |
245 | return ret; | 220 | return ret; |
@@ -267,8 +242,7 @@ int generic_write_sync(struct file *file, loff_t pos, loff_t count) | |||
267 | { | 242 | { |
268 | if (!(file->f_flags & O_DSYNC) && !IS_SYNC(file->f_mapping->host)) | 243 | if (!(file->f_flags & O_DSYNC) && !IS_SYNC(file->f_mapping->host)) |
269 | return 0; | 244 | return 0; |
270 | return vfs_fsync_range(file, file->f_path.dentry, pos, | 245 | return vfs_fsync_range(file, pos, pos + count - 1, |
271 | pos + count - 1, | ||
272 | (file->f_flags & __O_SYNC) ? 0 : 1); | 246 | (file->f_flags & __O_SYNC) ? 0 : 1); |
273 | } | 247 | } |
274 | EXPORT_SYMBOL(generic_write_sync); | 248 | EXPORT_SYMBOL(generic_write_sync); |