Skip to content

Commit 8018ab0

Browse files
Christoph HellwigAl Viro
Christoph Hellwig
authored and
Al Viro
committed
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>
1 parent e970a57 commit 8018ab0

File tree

11 files changed

+24
-54
lines changed

11 files changed

+24
-54
lines changed

drivers/block/loop.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio)
485485
goto out;
486486
}
487487

488-
ret = vfs_fsync(file, file->f_path.dentry, 0);
488+
ret = vfs_fsync(file, 0);
489489
if (unlikely(ret)) {
490490
ret = -EIO;
491491
goto out;
@@ -495,7 +495,7 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio)
495495
ret = lo_send(lo, bio, pos);
496496

497497
if (barrier && !ret) {
498-
ret = vfs_fsync(file, file->f_path.dentry, 0);
498+
ret = vfs_fsync(file, 0);
499499
if (unlikely(ret))
500500
ret = -EIO;
501501
}

drivers/md/bitmap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ int bitmap_create(mddev_t *mddev)
16921692
* and bypass the page cache, we must sync the file
16931693
* first.
16941694
*/
1695-
vfs_fsync(file, file->f_dentry, 1);
1695+
vfs_fsync(file, 1);
16961696
}
16971697
/* read superblock from bitmap file (this sets mddev->bitmap_info.chunksize) */
16981698
if (!mddev->bitmap_info.external)

drivers/usb/gadget/storage_common.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ static int fsg_lun_fsync_sub(struct fsg_lun *curlun)
654654

655655
if (curlun->ro || !filp)
656656
return 0;
657-
return vfs_fsync(filp, filp->f_path.dentry, 1);
657+
return vfs_fsync(filp, 1);
658658
}
659659

660660
static void store_cdrom_address(u8 *dest, int msf, u32 addr)

fs/ceph/file.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,7 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
844844
if ((ret >= 0 || ret == -EIOCBQUEUED) &&
845845
((file->f_flags & O_SYNC) || IS_SYNC(file->f_mapping->host)
846846
|| 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);
849848
if (err < 0)
850849
ret = err;
851850
}

fs/coda/file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync)
217217
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
218218
host_file = cfi->cfi_container;
219219

220-
err = vfs_fsync(host_file, host_file->f_path.dentry, datasync);
220+
err = vfs_fsync(host_file, datasync);
221221
if ( !err && !datasync ) {
222222
lock_kernel();
223223
err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode));

fs/ecryptfs/file.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ static int ecryptfs_release(struct inode *inode, struct file *file)
276276
static int
277277
ecryptfs_fsync(struct file *file, struct dentry *dentry, int datasync)
278278
{
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);
282280
}
283281

284282
static int ecryptfs_fasync(int fd, struct file *file, int flag)

fs/nfsd/nfs4recover.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
158158
mutex_unlock(&dir->d_inode->i_mutex);
159159
if (status == 0) {
160160
clp->cl_firststate = 1;
161-
vfs_fsync(rec_file, rec_file->f_path.dentry, 0);
161+
vfs_fsync(rec_file, 0);
162162
}
163163
nfs4_reset_creds(original_cred);
164164
dprintk("NFSD: nfsd4_create_clid_dir returns %d\n", status);
@@ -288,7 +288,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp)
288288
status = nfsd4_unlink_clid_dir(clp->cl_recdir, HEXDIR_LEN-1);
289289
nfs4_reset_creds(original_cred);
290290
if (status == 0)
291-
vfs_fsync(rec_file, rec_file->f_path.dentry, 0);
291+
vfs_fsync(rec_file, 0);
292292
mnt_drop_write(rec_file->f_path.mnt);
293293
out:
294294
if (status)
@@ -325,7 +325,7 @@ nfsd4_recdir_purge_old(void) {
325325
goto out;
326326
status = nfsd4_list_rec_dir(rec_file->f_path.dentry, purge_old);
327327
if (status == 0)
328-
vfs_fsync(rec_file, rec_file->f_path.dentry, 0);
328+
vfs_fsync(rec_file, 0);
329329
mnt_drop_write(rec_file->f_path.mnt);
330330
out:
331331
if (status)

fs/nfsd/vfs.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ static int wait_for_concurrent_writes(struct file *file)
999999

10001000
if (inode->i_state & I_DIRTY) {
10011001
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);
10031003
}
10041004
last_ino = inode->i_ino;
10051005
last_dev = inode->i_sb->s_dev;
@@ -1175,8 +1175,7 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,
11751175
if (err)
11761176
goto out;
11771177
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);
11801179

11811180
if (err2 != -EINVAL)
11821181
err = nfserrno(err2);

fs/sync.c

+8-34
Original file line numberDiff line numberDiff line change
@@ -158,40 +158,20 @@ EXPORT_SYMBOL(file_fsync);
158158
/**
159159
* vfs_fsync_range - helper to sync a range of data & metadata to disk
160160
* @file: file to sync
161-
* @dentry: dentry of @file
162161
* @start: offset in bytes of the beginning of data range to sync
163162
* @end: offset in bytes of the end of data range (inclusive)
164163
* @datasync: perform only datasync
165164
*
166165
* Write back data in range @start..@end and metadata for @file to disk. If
167166
* @datasync is set only metadata needed to access modified file data is
168167
* 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.
173168
*/
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)
176170
{
177-
const struct file_operations *fop;
178-
struct address_space *mapping;
171+
struct address_space *mapping = file->f_mapping;
179172
int err, ret;
180173

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) {
195175
ret = -EINVAL;
196176
goto out;
197177
}
@@ -203,7 +183,7 @@ int vfs_fsync_range(struct file *file, struct dentry *dentry, loff_t start,
203183
* livelocks in fsync_buffers_list().
204184
*/
205185
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);
207187
if (!ret)
208188
ret = err;
209189
mutex_unlock(&mapping->host->i_mutex);
@@ -216,19 +196,14 @@ EXPORT_SYMBOL(vfs_fsync_range);
216196
/**
217197
* vfs_fsync - perform a fsync or fdatasync on a file
218198
* @file: file to sync
219-
* @dentry: dentry of @file
220199
* @datasync: only perform a fdatasync operation
221200
*
222201
* Write back data and metadata for @file to disk. If @datasync is
223202
* 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.
228203
*/
229-
int vfs_fsync(struct file *file, struct dentry *dentry, int datasync)
204+
int vfs_fsync(struct file *file, int datasync)
230205
{
231-
return vfs_fsync_range(file, dentry, 0, LLONG_MAX, datasync);
206+
return vfs_fsync_range(file, 0, LLONG_MAX, datasync);
232207
}
233208
EXPORT_SYMBOL(vfs_fsync);
234209

@@ -239,7 +214,7 @@ static int do_fsync(unsigned int fd, int datasync)
239214

240215
file = fget(fd);
241216
if (file) {
242-
ret = vfs_fsync(file, file->f_path.dentry, datasync);
217+
ret = vfs_fsync(file, datasync);
243218
fput(file);
244219
}
245220
return ret;
@@ -267,8 +242,7 @@ int generic_write_sync(struct file *file, loff_t pos, loff_t count)
267242
{
268243
if (!(file->f_flags & O_DSYNC) && !IS_SYNC(file->f_mapping->host))
269244
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,
272246
(file->f_flags & __O_SYNC) ? 0 : 1);
273247
}
274248
EXPORT_SYMBOL(generic_write_sync);

include/linux/fs.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -2084,9 +2084,9 @@ extern int __filemap_fdatawrite_range(struct address_space *mapping,
20842084
extern int filemap_fdatawrite_range(struct address_space *mapping,
20852085
loff_t start, loff_t end);
20862086

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);
20902090
extern int generic_write_sync(struct file *file, loff_t pos, loff_t count);
20912091
extern void sync_supers(void);
20922092
extern void emergency_sync(void);

mm/msync.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
8282
(vma->vm_flags & VM_SHARED)) {
8383
get_file(file);
8484
up_read(&mm->mmap_sem);
85-
error = vfs_fsync(file, file->f_path.dentry, 0);
85+
error = vfs_fsync(file, 0);
8686
fput(file);
8787
if (error || start >= end)
8888
goto out;

0 commit comments

Comments
 (0)