From 06c067eb25fafd8d18de204a3df430e114fc8871 Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Mon, 8 Mar 2021 09:22:04 -0700 Subject: [PATCH 10/11] Linux: Create wrapper for setattr_prepare Move call to setattr_prepare/inode_change_ok into an osi_compat.h wrapper called 'afs_setattr_prepare'. This moves some of the #if logic out of the mainline code. Reviewed-on: https://gerrit.openafs.org/14548 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk (cherry picked from commit 12ae2beeeb172cebdfa24d5ea149f73fd85541f8) Change-Id: I1c7806893daf2404a8b3ac1b5c88ca04e6409226 Reviewed-on: https://gerrit.openafs.org/14564 Tested-by: BuildBot Reviewed-by: Cheyenne Wills Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- src/afs/LINUX/osi_compat.h | 10 ++++++++++ src/afs/LINUX/osi_file.c | 6 +----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h index a1e7f21fb..3ac4d798d 100644 --- a/src/afs/LINUX/osi_compat.h +++ b/src/afs/LINUX/osi_compat.h @@ -748,4 +748,14 @@ afs_d_path(struct dentry *dp, struct vfsmount *mnt, char *buf, int buflen) #endif } +static inline int +afs_setattr_prepare(struct dentry *dp, struct iattr *newattrs) +{ +#if defined(HAVE_LINUX_SETATTR_PREPARE) + return setattr_prepare(dp, newattrs); +#else + return inode_change_ok(dp->d_inode, newattrs); +#endif +} + #endif /* AFS_LINUX_OSI_COMPAT_H */ diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index 5b0a0c01d..982cf47e7 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -205,11 +205,7 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize) AFS_CURRENT_TIME(&newattrs.ia_ctime); /* avoid notify_change() since it wants to update dentry->d_parent */ -#ifdef HAVE_LINUX_SETATTR_PREPARE - code = setattr_prepare(file_dentry(afile->filp), &newattrs); -#else - code = inode_change_ok(inode, &newattrs); -#endif + code = afs_setattr_prepare(file_dentry(afile->filp), &newattrs); if (!code) code = afs_inode_setattr(afile, &newattrs); if (!code) -- 2.31.1