Linux: adapt to truncate sequence changes
authorMarc Dionne <marc.c.dionne@gmail.com>
Wed, 11 Aug 2010 22:20:59 +0000 (18:20 -0400)
committerDerrick Brashear <shadow@dementia.org>
Wed, 15 Dec 2010 09:43:53 +0000 (01:43 -0800)
As part of changes to the truncate sequence, inode_setattr() no
longer exists, and all filesystems have to define the setattr op
so we can assume that it is not NULL.

Introduce a compat inline function afs_inode_setattr that hides
the tests and the different versions from the main code.

Note that the existing test for the inode_setattr() return type
will fail, but the value is no longer used in that case.

This is required for 2.6.36

Reviewed-on: http://gerrit.openafs.org/2543
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

(cherry-picked from commit eaf3378f537935f6b9843886b43d)

Reviewed-on: http://gerrit.openafs.org/2550
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit 58e56d080b8d19117b60f04ecb37af0c6dcafc1a)

Change-Id: I4cfdd191c60d7672c80aa3b3789e52c3e5e87666
Reviewed-on: http://gerrit.openafs.org/3519
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

acinclude.m4
src/afs/LINUX/osi_compat.h
src/afs/LINUX/osi_file.c
src/cf/linux-test4.m4

index dcf099c..d31d1c2 100644 (file)
@@ -818,6 +818,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
                 LINUX_STRUCT_CTL_TABLE_HAS_CTL_NAME
                 LINUX_HAVE_IGET
                 LINUX_HAVE_I_SIZE_READ
+                LINUX_HAVE_INODE_SETATTR
                 LINUX_FS_STRUCT_NAMEIDATA_HAS_PATH
                 LINUX_EXPORTS_INIT_MM
                  LINUX_EXPORTS_SYS_CHDIR
index bcbb42a..df88751 100644 (file)
@@ -137,3 +137,23 @@ init_once_func(void * foo) {
 #endif
 
 #endif
+
+static inline int
+afs_inode_setattr(struct osi_file *afile, struct iattr *newattrs) {
+
+    int code = 0;
+    struct inode *inode = OSIFILE_INODE(afile);
+#if !defined(HAVE_LINUX_INODE_SETATTR)
+    code = inode->i_op->setattr(afile->filp->f_dentry, newattrs);
+#elif defined(INODE_SETATTR_NOT_VOID)
+#if defined(AFS_LINUX26_ENV)
+    if (inode->i_op && inode->i_op->setattr)
+       code = inode->i_op->setattr(afile->filp->f_dentry, newattrs);
+    else
+#endif
+       code = inode_setattr(inode, newattrs);
+#else
+    inode_setattr(inode, newattrs);
+#endif
+    return code;
+}
index 1f9e8cf..2abcea3 100644 (file)
@@ -21,6 +21,7 @@
 #if !defined(HAVE_IGET)
 #include "h/exportfs.h"
 #endif
+#include "osi_compat.h"
 
 int afs_osicred_initialized = 0;
 struct AFS_UCRED afs_osi_cred;
@@ -237,16 +238,7 @@ osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
     lock_kernel();
     code = inode_change_ok(inode, &newattrs);
     if (!code)
-#ifdef INODE_SETATTR_NOT_VOID
-#if defined(AFS_LINUX26_ENV)
-       if (inode->i_op && inode->i_op->setattr)
-           code = inode->i_op->setattr(afile->filp->f_dentry, &newattrs);
-       else
-#endif
-           code = inode_setattr(inode, &newattrs);
-#else
-        inode_setattr(inode, &newattrs);
-#endif
+       code = afs_inode_setattr(afile, &newattrs);
     unlock_kernel();
     if (!code)
        truncate_inode_pages(&inode->i_data, asize);
index 894593c..6d14b2f 100644 (file)
@@ -1274,3 +1274,19 @@ _bdi.name = NULL;],
   if test "x$ac_cv_linux_struct_bdi_has_name" = "xyes"; then
     AC_DEFINE([STRUCT_BDI_HAS_NAME], 1, [define if struct backing_dev_info has a name member])
   fi])
+
+AC_DEFUN([LINUX_HAVE_INODE_SETATTR], [
+  AC_MSG_CHECKING([for linux inode_setattr()])
+  AC_CACHE_VAL([ac_cv_linux_inode_setattr], [
+    save_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
+    AC_TRY_KBUILD(
+[#include <linux/fs.h>],
+[inode_setattr(NULL);],
+      ac_cv_linux_inode_setattr=yes,
+      ac_cv_linux_inode_setattr=no)
+    CPPFLAGS="$save_CPPFLAGS"])
+  AC_MSG_RESULT($ac_cv_linux_inode_setattr)
+  if test "x$ac_cv_linux_inode_setattr" = "xyes"; then
+    AC_DEFINE([HAVE_LINUX_INODE_SETATTR], 1, [define if your kernel has inode_setattr()])
+  fi])