@@ -158,40 +158,20 @@ EXPORT_SYMBOL(file_fsync);
158
158
/**
159
159
* vfs_fsync_range - helper to sync a range of data & metadata to disk
160
160
* @file: file to sync
161
- * @dentry: dentry of @file
162
161
* @start: offset in bytes of the beginning of data range to sync
163
162
* @end: offset in bytes of the end of data range (inclusive)
164
163
* @datasync: perform only datasync
165
164
*
166
165
* Write back data in range @start..@end and metadata for @file to disk. If
167
166
* @datasync is set only metadata needed to access modified file data is
168
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 ,
175
- loff_t end , int datasync )
169
+ int vfs_fsync_range (struct file * file , loff_t start , loff_t end , int datasync )
176
170
{
177
- const struct file_operations * fop ;
178
- struct address_space * mapping ;
171
+ struct address_space * mapping = file -> f_mapping ;
179
172
int err , ret ;
180
173
181
- /*
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 ) {
174
+ if (!file -> f_op || !file -> f_op -> fsync ) {
195
175
ret = - EINVAL ;
196
176
goto out ;
197
177
}
@@ -203,7 +183,7 @@ int vfs_fsync_range(struct file *file, struct dentry *dentry, loff_t start,
203
183
* livelocks in fsync_buffers_list().
204
184
*/
205
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
187
if (!ret )
208
188
ret = err ;
209
189
mutex_unlock (& mapping -> host -> i_mutex );
@@ -216,19 +196,14 @@ EXPORT_SYMBOL(vfs_fsync_range);
216
196
/**
217
197
* vfs_fsync - perform a fsync or fdatasync on a file
218
198
* @file: file to sync
219
- * @dentry: dentry of @file
220
199
* @datasync: only perform a fdatasync operation
221
200
*
222
201
* Write back data and metadata for @file to disk. If @datasync is
223
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
208
EXPORT_SYMBOL (vfs_fsync );
234
209
@@ -239,7 +214,7 @@ static int do_fsync(unsigned int fd, int datasync)
239
214
240
215
file = fget (fd );
241
216
if (file ) {
242
- ret = vfs_fsync (file , file -> f_path . dentry , datasync );
217
+ ret = vfs_fsync (file , datasync );
243
218
fput (file );
244
219
}
245
220
return ret ;
@@ -267,8 +242,7 @@ int generic_write_sync(struct file *file, loff_t pos, loff_t count)
267
242
{
268
243
if (!(file -> f_flags & O_DSYNC ) && !IS_SYNC (file -> f_mapping -> host ))
269
244
return 0 ;
270
- return vfs_fsync_range (file , file -> f_path .dentry , pos ,
271
- pos + count - 1 ,
245
+ return vfs_fsync_range (file , pos , pos + count - 1 ,
272
246
(file -> f_flags & __O_SYNC ) ? 0 : 1 );
273
247
}
274
248
EXPORT_SYMBOL (generic_write_sync );
0 commit comments