From eaf3378f537935f6b9843886b43d8b6d38a91a92 Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Wed, 11 Aug 2010 18:20:59 -0400 Subject: [PATCH] Linux: adapt to truncate sequence changes 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 Change-Id: I2f5e8a0b660b48453d0152b6c4db64e57539f91a Reviewed-on: http://gerrit.openafs.org/2543 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- acinclude.m4 | 3 +++ src/afs/LINUX/osi_compat.h | 18 ++++++++++++++++++ src/afs/LINUX/osi_file.c | 12 ++---------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 2e76651..08a36a8 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -827,6 +827,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) AC_CHECK_LINUX_FUNC([i_size_read], [#include ], [i_size_read(NULL);]) + AC_CHECK_LINUX_FUNC([inode_setattr], + [#include ], + [inode_setattr(NULL, NULL);]) AC_CHECK_LINUX_FUNC([kernel_setsockopt], [#include ], [kernel_setsockopt(NULL, 0, 0, NULL, 0);]) diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h index 342cdb8..730147e 100644 --- a/src/afs/LINUX/osi_compat.h +++ b/src/afs/LINUX/osi_compat.h @@ -360,3 +360,21 @@ afs_linux_unlock_inode(struct inode *ip) { up(&ip->i_sem); #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 (inode->i_op && inode->i_op->setattr) + code = inode->i_op->setattr(afile->filp->f_dentry, newattrs); + else + code = inode_setattr(inode, newattrs); +#else + inode_setattr(inode, newattrs); +#endif + return code; +} diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index 13eb59d..aed713e 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -183,16 +183,8 @@ osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) /* avoid notify_change() since it wants to update dentry->d_parent */ code = inode_change_ok(inode, &newattrs); - if (!code) { -#ifdef INODE_SETATTR_NOT_VOID - if (inode->i_op && inode->i_op->setattr) - code = inode->i_op->setattr(afile->filp->f_dentry, &newattrs); - else - code = inode_setattr(inode, &newattrs); -#else - inode_setattr(inode, &newattrs); -#endif - } + if (!code) + code = afs_inode_setattr(afile, &newattrs); if (!code) truncate_inode_pages(&inode->i_data, asize); code = -code; -- 1.9.4