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 | |
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>
-rw-r--r-- | drivers/block/loop.c | 4 | ||||
-rw-r--r-- | drivers/md/bitmap.c | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/storage_common.c | 2 | ||||
-rw-r--r-- | fs/ceph/file.c | 3 | ||||
-rw-r--r-- | fs/coda/file.c | 2 | ||||
-rw-r--r-- | fs/ecryptfs/file.c | 4 | ||||
-rw-r--r-- | fs/nfsd/nfs4recover.c | 6 | ||||
-rw-r--r-- | fs/nfsd/vfs.c | 5 | ||||
-rw-r--r-- | fs/sync.c | 42 | ||||
-rw-r--r-- | include/linux/fs.h | 6 | ||||
-rw-r--r-- | mm/msync.c | 2 |
11 files changed, 24 insertions, 54 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index a90e83c9be96..6120922f459f 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -485,7 +485,7 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio) | |||
485 | goto out; | 485 | goto out; |
486 | } | 486 | } |
487 | 487 | ||
488 | ret = vfs_fsync(file, file->f_path.dentry, 0); | 488 | ret = vfs_fsync(file, 0); |
489 | if (unlikely(ret)) { | 489 | if (unlikely(ret)) { |
490 | ret = -EIO; | 490 | ret = -EIO; |
491 | goto out; | 491 | goto out; |
@@ -495,7 +495,7 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio) | |||
495 | ret = lo_send(lo, bio, pos); | 495 | ret = lo_send(lo, bio, pos); |
496 | 496 | ||
497 | if (barrier && !ret) { | 497 | if (barrier && !ret) { |
498 | ret = vfs_fsync(file, file->f_path.dentry, 0); | 498 | ret = vfs_fsync(file, 0); |
499 | if (unlikely(ret)) | 499 | if (unlikely(ret)) |
500 | ret = -EIO; | 500 | ret = -EIO; |
501 | } | 501 | } |
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index f084249295d9..53e8bea295e2 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -1692,7 +1692,7 @@ int bitmap_create(mddev_t *mddev) | |||
1692 | * and bypass the page cache, we must sync the file | 1692 | * and bypass the page cache, we must sync the file |
1693 | * first. | 1693 | * first. |
1694 | */ | 1694 | */ |
1695 | vfs_fsync(file, file->f_dentry, 1); | 1695 | vfs_fsync(file, 1); |
1696 | } | 1696 | } |
1697 | /* read superblock from bitmap file (this sets mddev->bitmap_info.chunksize) */ | 1697 | /* read superblock from bitmap file (this sets mddev->bitmap_info.chunksize) */ |
1698 | if (!mddev->bitmap_info.external) | 1698 | if (!mddev->bitmap_info.external) |
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 868d8ee86756..04c462ff0ea6 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c | |||
@@ -654,7 +654,7 @@ static int fsg_lun_fsync_sub(struct fsg_lun *curlun) | |||
654 | 654 | ||
655 | if (curlun->ro || !filp) | 655 | if (curlun->ro || !filp) |
656 | return 0; | 656 | return 0; |
657 | return vfs_fsync(filp, filp->f_path.dentry, 1); | 657 | return vfs_fsync(filp, 1); |
658 | } | 658 | } |
659 | 659 | ||
660 | static void store_cdrom_address(u8 *dest, int msf, u32 addr) | 660 | static void store_cdrom_address(u8 *dest, int msf, u32 addr) |
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index ed6f19721d6e..7d634938edc9 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
@@ -844,8 +844,7 @@ retry_snap: | |||
844 | if ((ret >= 0 || ret == -EIOCBQUEUED) && | 844 | if ((ret >= 0 || ret == -EIOCBQUEUED) && |
845 | ((file->f_flags & O_SYNC) || IS_SYNC(file->f_mapping->host) | 845 | ((file->f_flags & O_SYNC) || IS_SYNC(file->f_mapping->host) |
846 | || ceph_osdmap_flag(osdc->osdmap, CEPH_OSDMAP_NEARFULL))) { | 846 | || ceph_osdmap_flag(osdc->osdmap, CEPH_OSDMAP_NEARFULL))) { |
847 | err = vfs_fsync_range(file, file->f_path.dentry, | 847 | err = vfs_fsync_range(file, pos, pos + ret - 1, 1); |
848 | pos, pos + ret - 1, 1); | ||
849 | if (err < 0) | 848 | if (err < 0) |
850 | ret = err; | 849 | ret = err; |
851 | } | 850 | } |
diff --git a/fs/coda/file.c b/fs/coda/file.c index 4c813f2cdc52..7196077b1688 100644 --- a/fs/coda/file.c +++ b/fs/coda/file.c | |||
@@ -217,7 +217,7 @@ int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync) | |||
217 | BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); | 217 | BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); |
218 | host_file = cfi->cfi_container; | 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 | if ( !err && !datasync ) { | 221 | if ( !err && !datasync ) { |
222 | lock_kernel(); | 222 | lock_kernel(); |
223 | err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode)); | 223 | err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode)); |
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index e7440a6f5ebf..3bdddbcc785f 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
@@ -276,9 +276,7 @@ static int ecryptfs_release(struct inode *inode, struct file *file) | |||
276 | static int | 276 | static int |
277 | ecryptfs_fsync(struct file *file, struct dentry *dentry, int datasync) | 277 | ecryptfs_fsync(struct file *file, struct dentry *dentry, int datasync) |
278 | { | 278 | { |
279 | return vfs_fsync(ecryptfs_file_to_lower(file), | 279 | return vfs_fsync(ecryptfs_file_to_lower(file), datasync); |
280 | ecryptfs_dentry_to_lower(dentry), | ||
281 | datasync); | ||
282 | } | 280 | } |
283 | 281 | ||
284 | static int ecryptfs_fasync(int fd, struct file *file, int flag) | 282 | static int ecryptfs_fasync(int fd, struct file *file, int flag) |
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index dada03f2c13b..7e26caab2a26 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c | |||
@@ -158,7 +158,7 @@ out_unlock: | |||
158 | mutex_unlock(&dir->d_inode->i_mutex); | 158 | mutex_unlock(&dir->d_inode->i_mutex); |
159 | if (status == 0) { | 159 | if (status == 0) { |
160 | clp->cl_firststate = 1; | 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 | nfs4_reset_creds(original_cred); | 163 | nfs4_reset_creds(original_cred); |
164 | dprintk("NFSD: nfsd4_create_clid_dir returns %d\n", status); | 164 | dprintk("NFSD: nfsd4_create_clid_dir returns %d\n", status); |
@@ -288,7 +288,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp) | |||
288 | status = nfsd4_unlink_clid_dir(clp->cl_recdir, HEXDIR_LEN-1); | 288 | status = nfsd4_unlink_clid_dir(clp->cl_recdir, HEXDIR_LEN-1); |
289 | nfs4_reset_creds(original_cred); | 289 | nfs4_reset_creds(original_cred); |
290 | if (status == 0) | 290 | if (status == 0) |
291 | vfs_fsync(rec_file, rec_file->f_path.dentry, 0); | 291 | vfs_fsync(rec_file, 0); |
292 | mnt_drop_write(rec_file->f_path.mnt); | 292 | mnt_drop_write(rec_file->f_path.mnt); |
293 | out: | 293 | out: |
294 | if (status) | 294 | if (status) |
@@ -325,7 +325,7 @@ nfsd4_recdir_purge_old(void) { | |||
325 | goto out; | 325 | goto out; |
326 | status = nfsd4_list_rec_dir(rec_file->f_path.dentry, purge_old); | 326 | status = nfsd4_list_rec_dir(rec_file->f_path.dentry, purge_old); |
327 | if (status == 0) | 327 | if (status == 0) |
328 | vfs_fsync(rec_file, rec_file->f_path.dentry, 0); | 328 | vfs_fsync(rec_file, 0); |
329 | mnt_drop_write(rec_file->f_path.mnt); | 329 | mnt_drop_write(rec_file->f_path.mnt); |
330 | out: | 330 | out: |
331 | if (status) | 331 | if (status) |
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 23c06f77f4ca..ebbf3b6b2457 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -999,7 +999,7 @@ static int wait_for_concurrent_writes(struct file *file) | |||
999 | 999 | ||
1000 | if (inode->i_state & I_DIRTY) { | 1000 | if (inode->i_state & I_DIRTY) { |
1001 | dprintk("nfsd: write sync %d\n", task_pid_nr(current)); | 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 | last_ino = inode->i_ino; | 1004 | last_ino = inode->i_ino; |
1005 | last_dev = inode->i_sb->s_dev; | 1005 | last_dev = inode->i_sb->s_dev; |
@@ -1175,8 +1175,7 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1175 | if (err) | 1175 | if (err) |
1176 | goto out; | 1176 | goto out; |
1177 | if (EX_ISSYNC(fhp->fh_export)) { | 1177 | if (EX_ISSYNC(fhp->fh_export)) { |
1178 | int err2 = vfs_fsync_range(file, file->f_path.dentry, | 1178 | int err2 = vfs_fsync_range(file, offset, end, 0); |
1179 | offset, end, 0); | ||
1180 | 1179 | ||
1181 | if (err2 != -EINVAL) | 1180 | if (err2 != -EINVAL) |
1182 | err = nfserrno(err2); | 1181 | err = nfserrno(err2); |
@@ -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); |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 6660db898c41..f3e108314c93 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -2084,9 +2084,9 @@ extern int __filemap_fdatawrite_range(struct address_space *mapping, | |||
2084 | extern int filemap_fdatawrite_range(struct address_space *mapping, | 2084 | extern int filemap_fdatawrite_range(struct address_space *mapping, |
2085 | loff_t start, loff_t end); | 2085 | loff_t start, loff_t end); |
2086 | 2086 | ||
2087 | extern int vfs_fsync_range(struct file *file, struct dentry *dentry, | 2087 | extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end, |
2088 | loff_t start, loff_t end, int datasync); | 2088 | int datasync); |
2089 | extern int vfs_fsync(struct file *file, struct dentry *dentry, int datasync); | 2089 | extern int vfs_fsync(struct file *file, int datasync); |
2090 | extern int generic_write_sync(struct file *file, loff_t pos, loff_t count); | 2090 | extern int generic_write_sync(struct file *file, loff_t pos, loff_t count); |
2091 | extern void sync_supers(void); | 2091 | extern void sync_supers(void); |
2092 | extern void emergency_sync(void); | 2092 | extern void emergency_sync(void); |
diff --git a/mm/msync.c b/mm/msync.c index 4083209b7f02..632df4527c01 100644 --- a/mm/msync.c +++ b/mm/msync.c | |||
@@ -82,7 +82,7 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags) | |||
82 | (vma->vm_flags & VM_SHARED)) { | 82 | (vma->vm_flags & VM_SHARED)) { |
83 | get_file(file); | 83 | get_file(file); |
84 | up_read(&mm->mmap_sem); | 84 | up_read(&mm->mmap_sem); |
85 | error = vfs_fsync(file, file->f_path.dentry, 0); | 85 | error = vfs_fsync(file, 0); |
86 | fput(file); | 86 | fput(file); |
87 | if (error || start >= end) | 87 | if (error || start >= end) |
88 | goto out; | 88 | goto out; |