From 880abcbc317877b8801406f724bc541578bf9669 Mon Sep 17 00:00:00 2001 From: Benjamin Kaduk Date: Mon, 2 Mar 2015 13:45:40 -0500 Subject: [PATCH] Import upstream patches to fix a grave jessie bug The patches in 1.6.9-2+deb8u1 to fix the build after the linux KPI change were incomplete. Import the missing patch (and its dependency) to fix the build. --- debian/changelog | 7 + ...afs-api-to-create-and-free-vrequests.patch | 108 +++++++ ...-code-to-reset-the-root-to-afs-LINUX.patch | 270 ++++++++++++++++++ debian/patches/series | 2 + 4 files changed, 387 insertions(+) create mode 100644 debian/patches/0005-libafs-api-to-create-and-free-vrequests.patch create mode 100644 debian/patches/0006-Linux-Move-code-to-reset-the-root-to-afs-LINUX.patch diff --git a/debian/changelog b/debian/changelog index 40e244e19..a3de89757 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +openafs (1.6.9-2+deb8u2) UNRELEASED; urgency=medium + + * The build fix in 1.6.9-2+deb8u1 was incomplete; import more patches + from upstream to complete the build fix. (Closes: #778196.) + + -- Benjamin Kaduk Mon, 02 Mar 2015 14:02:24 -0500 + openafs (1.6.9-2+deb8u1) testing; urgency=high * Import patches from upstream: diff --git a/debian/patches/0005-libafs-api-to-create-and-free-vrequests.patch b/debian/patches/0005-libafs-api-to-create-and-free-vrequests.patch new file mode 100644 index 000000000..f283fe388 --- /dev/null +++ b/debian/patches/0005-libafs-api-to-create-and-free-vrequests.patch @@ -0,0 +1,108 @@ +From: Michael Meffie +Date: Mon, 14 Apr 2014 16:07:53 -0400 +Subject: libafs: api to create and free vrequests + +Add a pair of functions to allocate and free struct vrequests, which +are to be used to avoid having struct vrequests on the stack. + +Reviewed-on: http://gerrit.openafs.org/11074 +Reviewed-by: D Brashear +Tested-by: D Brashear +(cherry picked from commit 76ad941902c650a4a716168d3cbe68f62aef109f) + +Change-Id: I08932256af58aeba31b2d5c11008658c419cf008 +Reviewed-on: http://gerrit.openafs.org/11164 +Reviewed-by: Perry Ruiter +Reviewed-by: Benjamin Kaduk +Reviewed-by: Gergely Madarasz +Tested-by: BuildBot +Reviewed-by: Andrew Deason +Reviewed-by: Stephan Wiesand +(cherry picked from commit 17bf59ae6e426a7fd86f7edda040edb352729d2e) +--- + src/afs/afs_osi_pag.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ + src/afs/afs_prototypes.h | 2 ++ + 2 files changed, 60 insertions(+) + +diff --git a/src/afs/afs_osi_pag.c b/src/afs/afs_osi_pag.c +index efce229..ea16fe7 100644 +--- a/src/afs/afs_osi_pag.c ++++ b/src/afs/afs_osi_pag.c +@@ -487,6 +487,64 @@ afs_InitReq(struct vrequest *av, afs_ucred_t *acred) + return 0; + } + ++/*! ++ * Allocate and setup a vrequest. ++ * ++ * \note The caller must free the allocated vrequest with ++ * afs_DestroyReq() if this function returns successfully (zero). ++ * ++ * \note The GLOCK must be held on platforms which require the GLOCK ++ * for osi_AllocSmallSpace() and osi_FreeSmallSpace(). ++ * ++ * \param[out] avpp address of the vrequest pointer ++ * \param[in] acred user credentials to setup the vrequest; may be NULL ++ * \return 0 on success ++ */ ++int ++afs_CreateReq(struct vrequest **avpp, afs_ucred_t *acred) ++{ ++ int code; ++ struct vrequest *treq = NULL; ++ ++ if (afs_shuttingdown) { ++ return EIO; ++ } ++ if (!avpp) { ++ return EINVAL; ++ } ++ treq = osi_AllocSmallSpace(sizeof(struct vrequest)); ++ if (!treq) { ++ return ENOMEM; ++ } ++ if (!acred) { ++ memset(treq, 0, sizeof(struct vrequest)); ++ } else { ++ code = afs_InitReq(treq, acred); ++ if (code != 0) { ++ osi_FreeSmallSpace(treq); ++ return code; ++ } ++ } ++ *avpp = treq; ++ return 0; ++} ++ ++/*! ++ * Deallocate a vrequest. ++ * ++ * \note The GLOCK must be held on platforms which require the GLOCK ++ * for osi_FreeSmallSpace(). ++ * ++ * \param[in] av pointer to the vrequest to free; may be NULL ++ */ ++void ++afs_DestroyReq(struct vrequest *av) ++{ ++ if (av) { ++ osi_FreeSmallSpace(av); ++ } ++} ++ + #ifndef AFS_LINUX26_ONEGROUP_ENV + afs_uint32 + afs_get_pag_from_groups(gid_t g0a, gid_t g1a) +diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h +index 3bab010..0b7e180 100644 +--- a/src/afs/afs_prototypes.h ++++ b/src/afs/afs_prototypes.h +@@ -599,6 +599,8 @@ extern int AddPag(afs_proc_t *p, afs_int32 aval, afs_ucred_t **credpp); + extern int AddPag(afs_int32 aval, afs_ucred_t **credpp); + #endif + extern int afs_InitReq(struct vrequest *av, afs_ucred_t *acred); ++extern int afs_CreateReq(struct vrequest **avpp, afs_ucred_t *acred); ++extern void afs_DestroyReq(struct vrequest *av); + extern afs_uint32 afs_get_pag_from_groups(gid_t g0a, gid_t g1a); + extern void afs_get_groups_from_pag(afs_uint32 pag, gid_t * g0p, gid_t * g1p); + extern afs_int32 PagInCred(afs_ucred_t *cred); diff --git a/debian/patches/0006-Linux-Move-code-to-reset-the-root-to-afs-LINUX.patch b/debian/patches/0006-Linux-Move-code-to-reset-the-root-to-afs-LINUX.patch new file mode 100644 index 000000000..80f45f472 --- /dev/null +++ b/debian/patches/0006-Linux-Move-code-to-reset-the-root-to-afs-LINUX.patch @@ -0,0 +1,270 @@ +From: Marc Dionne +Date: Thu, 18 Dec 2014 06:57:22 -0500 +Subject: Linux: Move code to reset the root to afs/LINUX +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Move the Linux specific bit of code to reset the root to +afs/LINUX platform specific files. Things that play with +the Linux vfs internals should not be exposed here. + +No functional change, but this helps cleanup some ifdef +mess. + +Reviewed-on: http://gerrit.openafs.org/11641 +Tested-by: BuildBot +Reviewed-by: Michael Laß +Reviewed-by: Daria Brashear +(cherry picked from commit 6ca324e565c34d9d04f3c553b7d0febe675ae538) + +Change-Id: I82803669dd34d7abeb29040fbb38ec2f000f2601 +Reviewed-on: http://gerrit.openafs.org/11658 +Tested-by: BuildBot +Reviewed-by: Chas Williams - CONTRACTOR +Reviewed-by: Daria Brashear +Reviewed-by: Stephan Wiesand +(cherry picked from commit a6013738362f4d1487ca57282b2428e3ba962720) + +[kaduk@mit.edu: add #include "osi_compat.h" to osi_vcache.c to +fix the build, since commit b3527c80 (Linux 3.18: d_invalidate can +no longer return an error) which added it to upstream is not +present on this branch.] +--- + src/afs/LINUX/osi_prototypes.h | 3 ++ + src/afs/LINUX/osi_vcache.c | 63 ++++++++++++++++++++++++++++++++++++++ + src/afs/LINUX24/osi_prototypes.h | 3 ++ + src/afs/LINUX24/osi_vcache.c | 36 ++++++++++++++++++++++ + src/afs/afs_daemons.c | 66 +++------------------------------------- + 5 files changed, 110 insertions(+), 61 deletions(-) + +diff --git a/src/afs/LINUX/osi_prototypes.h b/src/afs/LINUX/osi_prototypes.h +index 9002882..1d2ca0d 100644 +--- a/src/afs/LINUX/osi_prototypes.h ++++ b/src/afs/LINUX/osi_prototypes.h +@@ -79,6 +79,9 @@ extern void osi_VM_FlushPages(struct vcache *avc, afs_ucred_t *credp); + extern void osi_VM_Truncate(struct vcache *avc, int alen, + afs_ucred_t *acred); + ++/* osi_vcache.c */ ++extern void osi_ResetRootVCache(afs_uint32 volid); ++ + /* osi_vfsops.c */ + extern void vattr2inode(struct inode *ip, struct vattr *vp); + extern int afs_init_inodecache(void); +diff --git a/src/afs/LINUX/osi_vcache.c b/src/afs/LINUX/osi_vcache.c +index 99aab91..4002c58 100644 +--- a/src/afs/LINUX/osi_vcache.c ++++ b/src/afs/LINUX/osi_vcache.c +@@ -13,6 +13,8 @@ + #include "afs/sysincludes.h" /*Standard vendor system headers */ + #include "afsincludes.h" /*AFS-based standard headers */ + ++#include "osi_compat.h" ++ + int + osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) { + int code; +@@ -141,3 +143,64 @@ osi_PostPopulateVCache(struct vcache *avc) { + vSetType(avc, VREG); + } + ++/** ++ * osi_ResetRootVCache - Reset the root vcache ++ * Reset the dentry associated with the afs root. ++ * Called from afs_CheckRootVolume when we notice that ++ * the root volume ID has changed. ++ * ++ * @volid: volume ID for the afs root ++ */ ++void ++osi_ResetRootVCache(afs_uint32 volid) ++{ ++ struct vrequest *treq = NULL; ++ struct vattr vattr; ++ cred_t *credp; ++ struct dentry *dp; ++ struct vcache *vcp; ++ struct inode *root = AFSTOV(afs_globalVp); ++ ++ afs_rootFid.Fid.Volume = volid; ++ afs_rootFid.Fid.Vnode = 1; ++ afs_rootFid.Fid.Unique = 1; ++ ++ credp = crref(); ++ if (afs_CreateReq(&treq, credp)) ++ goto out; ++ vcp = afs_GetVCache(&afs_rootFid, treq, NULL, NULL); ++ if (!vcp) ++ goto out; ++ afs_getattr(vcp, &vattr, credp); ++ afs_fill_inode(AFSTOV(vcp), &vattr); ++ ++ dp = d_find_alias(root); ++ ++#if defined(HAVE_DCACHE_LOCK) ++ spin_lock(&dcache_lock); ++#else ++ spin_lock(&AFSTOV(vcp)->i_lock); ++#endif ++ spin_lock(&dp->d_lock); ++#if defined(D_ALIAS_IS_HLIST) ++ hlist_del_init(&dp->d_alias); ++ hlist_add_head(&dp->d_alias, &(AFSTOV(vcp)->i_dentry)); ++#else ++ list_del_init(&dp->d_alias); ++ list_add(&dp->d_alias, &(AFSTOV(vcp)->i_dentry)); ++#endif ++ dp->d_inode = AFSTOV(vcp); ++ spin_unlock(&dp->d_lock); ++#if defined(HAVE_DCACHE_LOCK) ++ spin_unlock(&dcache_lock); ++#else ++ spin_unlock(&AFSTOV(vcp)->i_lock); ++#endif ++ dput(dp); ++ ++ AFS_RELE(root); ++ afs_globalVp = vcp; ++out: ++ crfree(credp); ++ afs_DestroyReq(treq); ++} +diff --git a/src/afs/LINUX24/osi_prototypes.h b/src/afs/LINUX24/osi_prototypes.h +index ad2522c..39d6402 100644 +--- a/src/afs/LINUX24/osi_prototypes.h ++++ b/src/afs/LINUX24/osi_prototypes.h +@@ -69,6 +69,9 @@ extern void osi_syscall_clean(void); + extern int osi_sysctl_init(void); + extern void osi_sysctl_clean(void); + ++/* osi_vcache.c */ ++extern void osi_ResetRootVCache(afs_uint32 volid); ++ + /* osi_vm.c */ + extern int osi_VM_FlushVCache(struct vcache *avc, int *slept); + extern void osi_VM_TryToSmush(struct vcache *avc, afs_ucred_t *acred, +diff --git a/src/afs/LINUX24/osi_vcache.c b/src/afs/LINUX24/osi_vcache.c +index bbaf5ce..853a357 100644 +--- a/src/afs/LINUX24/osi_vcache.c ++++ b/src/afs/LINUX24/osi_vcache.c +@@ -119,3 +119,39 @@ osi_PostPopulateVCache(struct vcache *avc) { + vSetType(avc, VREG); + } + ++void ++osi_ResetRootVCache(afs_uint32 volid) ++{ ++ struct vrequest *treq = NULL; ++ struct vattr vattr; ++ cred_t *credp; ++ struct dentry *dp; ++ struct vcache *vcp; ++ ++ afs_rootFid.Fid.Volume = volid; ++ afs_rootFid.Fid.Vnode = 1; ++ afs_rootFid.Fid.Unique = 1; ++ ++ credp = crref(); ++ if (afs_CreateReq(&treq, credp)) ++ goto out; ++ vcp = afs_GetVCache(&afs_rootFid, treq, NULL, NULL); ++ if (!vcp) ++ goto out; ++ afs_getattr(vcp, &vattr, credp); ++ afs_fill_inode(AFSTOV(vcp), &vattr); ++ ++ dp = d_find_alias(AFSTOV(afs_globalVp)); ++ spin_lock(&dcache_lock); ++ list_del_init(&dp->d_alias); ++ list_add(&dp->d_alias, &(AFSTOV(vcp)->i_dentry)); ++ dp->d_inode = AFSTOV(vcp); ++ spin_unlock(&dcache_lock); ++ dput(dp); ++ ++ AFS_FAST_RELE(afs_globalVp); ++ afs_globalVp = vcp; ++out: ++ crfree(credp); ++ afs_DestroyReq(treq); ++} +diff --git a/src/afs/afs_daemons.c b/src/afs/afs_daemons.c +index a35f2cb..9f64da0 100644 +--- a/src/afs/afs_daemons.c ++++ b/src/afs/afs_daemons.c +@@ -363,70 +363,14 @@ afs_CheckRootVolume(void) + * count to zero and fs checkv is executed when the current + * directory is /afs. + */ +-#ifdef AFS_LINUX20_ENV +- { +- struct vrequest treq; +- struct vattr vattr; +- cred_t *credp; +- struct dentry *dp; +- struct vcache *vcp; +- +- afs_rootFid.Fid.Volume = volid; +- afs_rootFid.Fid.Vnode = 1; +- afs_rootFid.Fid.Unique = 1; +- +- credp = crref(); +- if (afs_InitReq(&treq, credp)) +- goto out; +- vcp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL); +- if (!vcp) +- goto out; +- afs_getattr(vcp, &vattr, credp); +- afs_fill_inode(AFSTOV(vcp), &vattr); +- +- dp = d_find_alias(AFSTOV(afs_globalVp)); +- +-#if defined(AFS_LINUX24_ENV) +-#if defined(HAVE_DCACHE_LOCK) +- spin_lock(&dcache_lock); +-#else +- spin_lock(&AFSTOV(vcp)->i_lock); +-#endif +-#if defined(AFS_LINUX26_ENV) +- spin_lock(&dp->d_lock); +-#endif +-#endif +-#if defined(D_ALIAS_IS_HLIST) +- hlist_del_init(&dp->d_alias); +- hlist_add_head(&dp->d_alias, &(AFSTOV(vcp)->i_dentry)); +-#else +- list_del_init(&dp->d_alias); +- list_add(&dp->d_alias, &(AFSTOV(vcp)->i_dentry)); +-#endif +- dp->d_inode = AFSTOV(vcp); +-#if defined(AFS_LINUX24_ENV) +-#if defined(AFS_LINUX26_ENV) +- spin_unlock(&dp->d_lock); +-#endif +-#if defined(HAVE_DCACHE_LOCK) +- spin_unlock(&dcache_lock); +-#else +- spin_unlock(&AFSTOV(vcp)->i_lock); +-#endif +-#endif +- dput(dp); +- +- AFS_FAST_RELE(afs_globalVp); +- afs_globalVp = vcp; +- out: +- crfree(credp); +- } ++#ifdef AFS_LINUX22_ENV ++ osi_ResetRootVCache(volid); + #else +-#ifdef AFS_DARWIN80_ENV ++# ifdef AFS_DARWIN80_ENV + afs_PutVCache(afs_globalVp); +-#else ++# else + AFS_FAST_RELE(afs_globalVp); +-#endif ++# endif + afs_globalVp = 0; + #endif + } diff --git a/debian/patches/series b/debian/patches/series index 35f95c006..31d16251c 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -2,3 +2,5 @@ 0002-Linux-3.16-Convert-to-new-write_iter-read_iter-ops.patch 0003-Unix-CM-Avoid-using-stale-DV-in-afs_StoreAllSegments.patch 0004-Linux-d_alias-becomes-d_u.d_alias.patch +0005-libafs-api-to-create-and-free-vrequests.patch +0006-Linux-Move-code-to-reset-the-root-to-afs-LINUX.patch -- 2.39.5