mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
RHEL 6.4 compat, fallocate()
In the upstream kernel the FALLOC_FL_PUNCH_HOLE #define was introduced after the fallocate() function was moved from the inode_operations to the file_operations structure. Therefore, the SPL code assumed that if FALLOC_FL_PUNCH_HOLE was defined it was safe to use f_ops->fallocate(). Unfortunately, the RHEL6.4 kernel has only backported the FALLOC_FL_PUNCH_HOLE #define and not the fallocate() change. To address this compatibility issue the spl_filp_fallocate() helper function was added to properly detect which interface is available. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
@@ -50,6 +50,26 @@ spl_filp_open(const char *name, int flags, int mode, int *err)
|
||||
#define spl_filp_poff(f) (&(f)->f_pos)
|
||||
#define spl_filp_write(fp, b, s, p) (fp)->f_op->write((fp), (b), (s), p)
|
||||
|
||||
static inline int
|
||||
spl_filp_fallocate(struct file *fp, int mode, loff_t offset, loff_t len)
|
||||
{
|
||||
int error = -EOPNOTSUPP;
|
||||
|
||||
#ifdef HAVE_FILE_FALLOCATE
|
||||
if (fp->f_op->fallocate)
|
||||
error = fp->f_op->fallocate(fp, mode, offset, len);
|
||||
#else
|
||||
# ifdef HAVE_INODE_FALLOCATE
|
||||
if (fp->f_dentry && fp->f_dentry->d_inode &&
|
||||
fp->f_dentry->d_inode->i_op->fallocate)
|
||||
error = fp->f_dentry->d_inode->i_op->fallocate(
|
||||
fp->f_dentry->d_inode, mode, offset, len);
|
||||
# endif /* HAVE_INODE_FALLOCATE */
|
||||
#endif /*HAVE_FILE_FALLOCATE */
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifdef HAVE_VFS_FSYNC
|
||||
# ifdef HAVE_2ARGS_VFS_FSYNC
|
||||
# define spl_filp_fsync(fp, sync) vfs_fsync(fp, sync)
|
||||
|
||||
Reference in New Issue
Block a user