Commit 8018ab057480974e7f26a387bf4ce040e9a5f6f1

Authored by Christoph Hellwig
Committed by Al Viro
1 parent e970a573ce

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>

Showing 11 changed files with 24 additions and 54 deletions Side-by-side Diff

drivers/block/loop.c
... ... @@ -485,7 +485,7 @@
485 485 goto out;
486 486 }
487 487  
488   - ret = vfs_fsync(file, file->f_path.dentry, 0);
  488 + ret = vfs_fsync(file, 0);
489 489 if (unlikely(ret)) {
490 490 ret = -EIO;
491 491 goto out;
... ... @@ -495,7 +495,7 @@
495 495 ret = lo_send(lo, bio, pos);
496 496  
497 497 if (barrier && !ret) {
498   - ret = vfs_fsync(file, file->f_path.dentry, 0);
  498 + ret = vfs_fsync(file, 0);
499 499 if (unlikely(ret))
500 500 ret = -EIO;
501 501 }
... ... @@ -1692,7 +1692,7 @@
1692 1692 * and bypass the page cache, we must sync the file
1693 1693 * first.
1694 1694 */
1695   - vfs_fsync(file, file->f_dentry, 1);
  1695 + vfs_fsync(file, 1);
1696 1696 }
1697 1697 /* read superblock from bitmap file (this sets mddev->bitmap_info.chunksize) */
1698 1698 if (!mddev->bitmap_info.external)
drivers/usb/gadget/storage_common.c
... ... @@ -654,7 +654,7 @@
654 654  
655 655 if (curlun->ro || !filp)
656 656 return 0;
657   - return vfs_fsync(filp, filp->f_path.dentry, 1);
  657 + return vfs_fsync(filp, 1);
658 658 }
659 659  
660 660 static void store_cdrom_address(u8 *dest, int msf, u32 addr)
... ... @@ -844,8 +844,7 @@
844 844 if ((ret >= 0 || ret == -EIOCBQUEUED) &&
845 845 ((file->f_flags & O_SYNC) || IS_SYNC(file->f_mapping->host)
846 846 || ceph_osdmap_flag(osdc->osdmap, CEPH_OSDMAP_NEARFULL))) {
847   - err = vfs_fsync_range(file, file->f_path.dentry,
848   - pos, pos + ret - 1, 1);
  847 + err = vfs_fsync_range(file, pos, pos + ret - 1, 1);
849 848 if (err < 0)
850 849 ret = err;
851 850 }
... ... @@ -217,7 +217,7 @@
217 217 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
218 218 host_file = cfi->cfi_container;
219 219  
220   - err = vfs_fsync(host_file, host_file->f_path.dentry, datasync);
  220 + err = vfs_fsync(host_file, datasync);
221 221 if ( !err && !datasync ) {
222 222 lock_kernel();
223 223 err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode));
... ... @@ -276,9 +276,7 @@
276 276 static int
277 277 ecryptfs_fsync(struct file *file, struct dentry *dentry, int datasync)
278 278 {
279   - return vfs_fsync(ecryptfs_file_to_lower(file),
280   - ecryptfs_dentry_to_lower(dentry),
281   - datasync);
  279 + return vfs_fsync(ecryptfs_file_to_lower(file), datasync);
282 280 }
283 281  
284 282 static int ecryptfs_fasync(int fd, struct file *file, int flag)
fs/nfsd/nfs4recover.c
... ... @@ -158,7 +158,7 @@
158 158 mutex_unlock(&dir->d_inode->i_mutex);
159 159 if (status == 0) {
160 160 clp->cl_firststate = 1;
161   - vfs_fsync(rec_file, rec_file->f_path.dentry, 0);
  161 + vfs_fsync(rec_file, 0);
162 162 }
163 163 nfs4_reset_creds(original_cred);
164 164 dprintk("NFSD: nfsd4_create_clid_dir returns %d\n", status);
... ... @@ -288,7 +288,7 @@
288 288 status = nfsd4_unlink_clid_dir(clp->cl_recdir, HEXDIR_LEN-1);
289 289 nfs4_reset_creds(original_cred);
290 290 if (status == 0)
291   - vfs_fsync(rec_file, rec_file->f_path.dentry, 0);
  291 + vfs_fsync(rec_file, 0);
292 292 mnt_drop_write(rec_file->f_path.mnt);
293 293 out:
294 294 if (status)
... ... @@ -325,7 +325,7 @@
325 325 goto out;
326 326 status = nfsd4_list_rec_dir(rec_file->f_path.dentry, purge_old);
327 327 if (status == 0)
328   - vfs_fsync(rec_file, rec_file->f_path.dentry, 0);
  328 + vfs_fsync(rec_file, 0);
329 329 mnt_drop_write(rec_file->f_path.mnt);
330 330 out:
331 331 if (status)
... ... @@ -999,7 +999,7 @@
999 999  
1000 1000 if (inode->i_state & I_DIRTY) {
1001 1001 dprintk("nfsd: write sync %d\n", task_pid_nr(current));
1002   - err = vfs_fsync(file, file->f_path.dentry, 0);
  1002 + err = vfs_fsync(file, 0);
1003 1003 }
1004 1004 last_ino = inode->i_ino;
1005 1005 last_dev = inode->i_sb->s_dev;
... ... @@ -1175,8 +1175,7 @@
1175 1175 if (err)
1176 1176 goto out;
1177 1177 if (EX_ISSYNC(fhp->fh_export)) {
1178   - int err2 = vfs_fsync_range(file, file->f_path.dentry,
1179   - offset, end, 0);
  1178 + int err2 = vfs_fsync_range(file, offset, end, 0);
1180 1179  
1181 1180 if (err2 != -EINVAL)
1182 1181 err = nfserrno(err2);
... ... @@ -158,7 +158,6 @@
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  
167 166  
... ... @@ -166,32 +165,13 @@
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 @@
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);
210 190  
211 191  
212 192  
... ... @@ -216,19 +196,14 @@
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 @@
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 @@
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);
... ... @@ -2084,9 +2084,9 @@
2084 2084 extern int filemap_fdatawrite_range(struct address_space *mapping,
2085 2085 loff_t start, loff_t end);
2086 2086  
2087   -extern int vfs_fsync_range(struct file *file, struct dentry *dentry,
2088   - loff_t start, loff_t end, int datasync);
2089   -extern int vfs_fsync(struct file *file, struct dentry *dentry, int datasync);
  2087 +extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end,
  2088 + int datasync);
  2089 +extern int vfs_fsync(struct file *file, int datasync);
2090 2090 extern int generic_write_sync(struct file *file, loff_t pos, loff_t count);
2091 2091 extern void sync_supers(void);
2092 2092 extern void emergency_sync(void);
... ... @@ -82,7 +82,7 @@
82 82 (vma->vm_flags & VM_SHARED)) {
83 83 get_file(file);
84 84 up_read(&mm->mmap_sem);
85   - error = vfs_fsync(file, file->f_path.dentry, 0);
  85 + error = vfs_fsync(file, 0);
86 86 fput(file);
87 87 if (error || start >= end)
88 88 goto out;