/** * vfs_fsync_range - helper to sync a range of data & metadata to disk * @file: file to sync * @start: offset in bytes of the beginning of data range to sync * @end: offset in bytes of the end of data range (inclusive) * @datasync: perform only datasync * * Write back data in range @start..@end and metadata for @file to disk. If * @datasync is set only metadata needed to access modified file data is * written. */ int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync) { struct address_space *mapping = file->f_mapping; int err, ret; if (!file->f_op || !file->f_op->fsync) { ret = -EINVAL; goto out; } ret = filemap_write_and_wait_range(mapping, start, end); /* * We need to protect against concurrent writers, which could cause * livelocks in fsync_buffers_list(). */ trace_vfs_fsync(file); mutex_lock(&mapping->host->i_mutex); err = file->f_op->fsync(file, datasync); if (!ret) ret = err; mutex_unlock(&mapping->host->i_mutex); trace_vfs_fsync_done(file); out: return ret; }
/** * vfs_fsync_range - helper to sync a range of data & metadata to disk * @file: file to sync * @start: offset in bytes of the beginning of data range to sync * @end: offset in bytes of the end of data range (inclusive) * @datasync: perform only datasync * * Write back data in range @start..@end and metadata for @file to disk. If * @datasync is set only metadata needed to access modified file data is * written. */ int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync) { int err; if (!file->f_op || !file->f_op->fsync) return -EINVAL; trace_vfs_fsync(file); err = file->f_op->fsync(file, start, end, datasync); trace_vfs_fsync_done(file); return err; }