Skip to content

Commit

Permalink
Linux 3.5 compatibility: miscellaneous changes
Browse files Browse the repository at this point in the history
torvalds/linux@b0b0382 changed
export_operations->encode_fn() to use struct inode * instead of struct
dentry *

torvalds/linux@dbd5768 renamed
end_writeback() to clear_inode()

torvalds/linux@17cf28a removed
inode_operations->truncate_range(). The file hole punching functionality
is provided by inode_operations->fallocate()

Closes openzfs#784

Signed-off-by: Richard Yao <[email protected]>
  • Loading branch information
ryao committed Jul 12, 2012
1 parent 42d3b99 commit 12e5cad
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 1 deletion.
13 changes: 13 additions & 0 deletions config/kernel-clear-inode.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dnl #
dnl # 3.5.0 API change
dnl # torvalds/linux@90324cc1b11a211e37eabd8cb863e1a1561d6b1d renamed
dnl # end_writeback() to clear_inode().
dnl #
AC_DEFUN([ZFS_AC_KERNEL_CLEAR_INODE], [
ZFS_CHECK_SYMBOL_EXPORT(
[clear_inode],
[fs/inode.c],
[AC_DEFINE(HAVE_CLEAR_INODE, 1,
[clear_inode() is available])],
[])
])
23 changes: 23 additions & 0 deletions config/kernel-encode_fh-inode.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
dnl #
dnl # 3.5.0 API change #
dnl # torvalds/linux@b0b0382bb4904965a9e9fca77ad87514dfda0d1c changed the header
dnl # to use struct inode * instead of struct dentry *
dnl #
AC_DEFUN([ZFS_AC_KERNEL_EXPORT_ENCODE_FH_WITH_INODE_PARAMETER], [
AC_MSG_CHECKING([export_operations->encodefh()])
ZFS_LINUX_TRY_COMPILE([
#include <linux/exportfs.h>
],[
int (*encode_fh)(struct inode *, __u32 *fh, int *, struct inode *) = NULL;
struct export_operations export_ops = {
.encode_fh = encode_fh,
};
export_ops.encode_fh(0, 0, 0, 0);
],[
AC_MSG_RESULT(uses struct inode * as first parameter)
AC_DEFINE(HAVE_EXPORT_ENCODE_FH_WITH_INODE_PARAMETER, 1,
[fhfn() uses struct inode *])
],[
AC_MSG_RESULT(does not use struct inode * as first parameter)
])
])
26 changes: 26 additions & 0 deletions config/kernel-truncate-range.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
dnl #
dnl # 3.5.0 API change #
dnl # torvalds/linux@17cf28afea2a1112f240a3a2da8af883be024811 removed
dnl # truncate_range(). The file hole punching functionality is provided by
dnl # fallocate()
dnl #
AC_DEFUN([ZFS_AC_KERNEL_INODE_TRUNCATE_RANGE], [
AC_MSG_CHECKING([inode_operations->truncate_range() exists])
ZFS_LINUX_TRY_COMPILE([
#include <linux/fs.h>
],[
void (*tr)(struct inode *, loff_t, loff_t) = NULL;
struct inode_operations inode_ops = {
.truncate_range = tr,
};
inode_ops.truncate_range(0, 0, 0);
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
[inode_operations->truncate_range() exists])
],[
AC_MSG_RESULT(no)
])
])
3 changes: 3 additions & 0 deletions config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
ZFS_AC_KERNEL_BDI
ZFS_AC_KERNEL_BDI_SETUP_AND_REGISTER
ZFS_AC_KERNEL_SET_NLINK
ZFS_AC_KERNEL_EXPORT_ENCODE_FH_WITH_INODE_PARAMETER
ZFS_AC_KERNEL_INODE_TRUNCATE_RANGE
ZFS_AC_KERNEL_CLEAR_INODE
AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
Expand Down
7 changes: 6 additions & 1 deletion module/zfs/zpl_export.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@


static int
#ifdef HAVE_EXPORT_ENCODE_FH_WITH_INODE_PARAMETER
zpl_encode_fh(struct inode *ip, __u32 *fh, int *max_len, struct inode *parent)
{
#else
zpl_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len, int connectable)
{
fid_t *fid = (fid_t *)fh;
struct inode *ip = dentry->d_inode;
#endif
fid_t *fid = (fid_t *)fh;
int len_bytes, rc;

len_bytes = *max_len * sizeof (__u32);
Expand Down
4 changes: 4 additions & 0 deletions module/zfs/zpl_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ zpl_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
return (error);
}

#ifdef HAVE_INODE_TRUNCATE_RANGE
static void
zpl_truncate_range(struct inode* ip, loff_t start, loff_t end)
{
Expand All @@ -355,6 +356,7 @@ zpl_truncate_range(struct inode* ip, loff_t start, loff_t end)

crfree(cr);
}
#endif

#ifdef HAVE_INODE_FALLOCATE
static long
Expand All @@ -380,7 +382,9 @@ const struct inode_operations zpl_inode_operations = {
.getxattr = generic_getxattr,
.removexattr = generic_removexattr,
.listxattr = zpl_xattr_list,
#ifdef HAVE_INODE_TRUNCATE_RANGE
.truncate_range = zpl_truncate_range,
#endif /* HAVE_INODE_TRUNCATE_RANGE */
#ifdef HAVE_INODE_FALLOCATE
.fallocate = zpl_fallocate,
#endif /* HAVE_INODE_FALLOCATE */
Expand Down
5 changes: 5 additions & 0 deletions module/zfs/zpl_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ static void
zpl_evict_inode(struct inode *ip)
{
truncate_setsize(ip, 0);
#ifdef HAVE_CLEAR_INODE
clear_inode(ip);
#else
end_writeback(ip);

#endif
zfs_inactive(ip);
}

Expand Down

0 comments on commit 12e5cad

Please sign in to comment.