mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +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:
@@ -654,13 +654,15 @@ int vn_space(vnode_t *vp, int cmd, struct flock *bfp, int flag,
|
||||
ASSERT(bfp->l_start >= 0 && bfp->l_len > 0);
|
||||
|
||||
#ifdef FALLOC_FL_PUNCH_HOLE
|
||||
if (vp->v_file->f_op->fallocate) {
|
||||
error = -vp->v_file->f_op->fallocate(vp->v_file,
|
||||
FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE,
|
||||
bfp->l_start, bfp->l_len);
|
||||
if (!error)
|
||||
SRETURN(0);
|
||||
}
|
||||
/*
|
||||
* When supported by the underlying file system preferentially
|
||||
* use the fallocate() callback to preallocate the space.
|
||||
*/
|
||||
error = -spl_filp_fallocate(vp->v_file,
|
||||
FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE,
|
||||
bfp->l_start, bfp->l_len);
|
||||
if (error == 0)
|
||||
SRETURN(0);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_INODE_TRUNCATE_RANGE
|
||||
|
||||
Reference in New Issue
Block a user