source: trunk/server/common/patches/openafs-d_u.d_alias.patch @ 2659

Last change on this file since 2659 was 2659, checked in by andersk, 9 years ago
OpenAFS: upgrade to 1.6.11pre1, plus patch for d_alias change
File size: 9.4 KB
RevLine 
[2659]1From 2c9bc3ec349ae550bf60d0c46f15bdabe2b0fd9e Mon Sep 17 00:00:00 2001
2From: Marc Dionne <marc.dionne@your-file-system.com>
3Date: Thu, 18 Dec 2014 06:57:22 -0500
4Subject: [PATCH 1/2] Linux: Move code to reset the root to afs/LINUX
5
6Move the Linux specific bit of code to reset the root to
7afs/LINUX platform specific files.  Things that play with
8the Linux vfs internals should not be exposed here.
9
10No functional change, but this helps cleanup some ifdef
11mess.
12
13Change-Id: Ia27fca3d8052ead45783cb2332c04fe6e99e5d9f
14---
15 src/afs/LINUX/osi_prototypes.h   |  3 ++
16 src/afs/LINUX/osi_vcache.c       | 61 ++++++++++++++++++++++++++++++++++++
17 src/afs/LINUX24/osi_prototypes.h |  3 ++
18 src/afs/LINUX24/osi_vcache.c     | 36 +++++++++++++++++++++
19 src/afs/afs_daemons.c            | 67 +++-------------------------------------
20 5 files changed, 108 insertions(+), 62 deletions(-)
21
22diff --git a/src/afs/LINUX/osi_prototypes.h b/src/afs/LINUX/osi_prototypes.h
23index 277b50a..5002af1 100644
24--- a/src/afs/LINUX/osi_prototypes.h
25+++ b/src/afs/LINUX/osi_prototypes.h
26@@ -82,6 +82,9 @@ extern void osi_VM_FlushPages(struct vcache *avc, afs_ucred_t *credp);
27 extern void osi_VM_Truncate(struct vcache *avc, int alen,
28                            afs_ucred_t *acred);
29 
30+/* osi_vcache.c */
31+extern void osi_ResetRootVCache(afs_uint32 volid);
32+
33 /* osi_vfsops.c */
34 extern void vattr2inode(struct inode *ip, struct vattr *vp);
35 extern int afs_init_inodecache(void);
36diff --git a/src/afs/LINUX/osi_vcache.c b/src/afs/LINUX/osi_vcache.c
37index 1d0db82..391e7d4 100644
38--- a/src/afs/LINUX/osi_vcache.c
39+++ b/src/afs/LINUX/osi_vcache.c
40@@ -143,3 +143,64 @@ osi_PostPopulateVCache(struct vcache *avc) {
41     vSetType(avc, VREG);
42 }
43 
44+/**
45+ * osi_ResetRootVCache - Reset the root vcache
46+ * Reset the dentry associated with the afs root.
47+ * Called from afs_CheckRootVolume when we notice that
48+ * the root volume ID has changed.
49+ *
50+ * @volid: volume ID for the afs root
51+ */
52+void
53+osi_ResetRootVCache(afs_uint32 volid)
54+{
55+    struct vrequest *treq = NULL;
56+    struct vattr vattr;
57+    cred_t *credp;
58+    struct dentry *dp;
59+    struct vcache *vcp;
60+    struct inode *root = AFSTOV(afs_globalVp);
61+
62+    afs_rootFid.Fid.Volume = volid;
63+    afs_rootFid.Fid.Vnode = 1;
64+    afs_rootFid.Fid.Unique = 1;
65+
66+    credp = crref();
67+    if (afs_CreateReq(&treq, credp))
68+       goto out;
69+    vcp = afs_GetVCache(&afs_rootFid, treq, NULL, NULL);
70+    if (!vcp)
71+       goto out;
72+    afs_getattr(vcp, &vattr, credp);
73+    afs_fill_inode(AFSTOV(vcp), &vattr);
74+
75+    dp = d_find_alias(root);
76+
77+#if defined(HAVE_DCACHE_LOCK)
78+    spin_lock(&dcache_lock);
79+#else
80+    spin_lock(&AFSTOV(vcp)->i_lock);
81+#endif
82+    spin_lock(&dp->d_lock);
83+#if defined(D_ALIAS_IS_HLIST)
84+    hlist_del_init(&dp->d_alias);
85+    hlist_add_head(&dp->d_alias, &(AFSTOV(vcp)->i_dentry));
86+#else
87+    list_del_init(&dp->d_alias);
88+    list_add(&dp->d_alias, &(AFSTOV(vcp)->i_dentry));
89+#endif
90+    dp->d_inode = AFSTOV(vcp);
91+    spin_unlock(&dp->d_lock);
92+#if defined(HAVE_DCACHE_LOCK)
93+    spin_unlock(&dcache_lock);
94+#else
95+    spin_unlock(&AFSTOV(vcp)->i_lock);
96+#endif
97+    dput(dp);
98+
99+    AFS_RELE(root);
100+    afs_globalVp = vcp;
101+out:
102+    crfree(credp);
103+    afs_DestroyReq(treq);
104+}
105diff --git a/src/afs/LINUX24/osi_prototypes.h b/src/afs/LINUX24/osi_prototypes.h
106index cb4bee1..cd748f1 100644
107--- a/src/afs/LINUX24/osi_prototypes.h
108+++ b/src/afs/LINUX24/osi_prototypes.h
109@@ -69,6 +69,9 @@ extern void osi_syscall_clean(void);
110 extern int osi_sysctl_init(void);
111 extern void osi_sysctl_clean(void);
112 
113+/* osi_vcache.c */
114+extern void osi_ResetRootVCache(afs_uint32 volid);
115+
116 /* osi_vm.c */
117 extern int osi_VM_FlushVCache(struct vcache *avc);
118 extern void osi_VM_TryToSmush(struct vcache *avc, afs_ucred_t *acred,
119diff --git a/src/afs/LINUX24/osi_vcache.c b/src/afs/LINUX24/osi_vcache.c
120index bbaf5ce..853a357 100644
121--- a/src/afs/LINUX24/osi_vcache.c
122+++ b/src/afs/LINUX24/osi_vcache.c
123@@ -119,3 +119,39 @@ osi_PostPopulateVCache(struct vcache *avc) {
124     vSetType(avc, VREG);
125 }
126 
127+void
128+osi_ResetRootVCache(afs_uint32 volid)
129+{
130+    struct vrequest *treq = NULL;
131+    struct vattr vattr;
132+    cred_t *credp;
133+    struct dentry *dp;
134+    struct vcache *vcp;
135+
136+    afs_rootFid.Fid.Volume = volid;
137+    afs_rootFid.Fid.Vnode = 1;
138+    afs_rootFid.Fid.Unique = 1;
139+
140+    credp = crref();
141+    if (afs_CreateReq(&treq, credp))
142+       goto out;
143+    vcp = afs_GetVCache(&afs_rootFid, treq, NULL, NULL);
144+    if (!vcp)
145+       goto out;
146+    afs_getattr(vcp, &vattr, credp);
147+    afs_fill_inode(AFSTOV(vcp), &vattr);
148+
149+    dp = d_find_alias(AFSTOV(afs_globalVp));
150+    spin_lock(&dcache_lock);
151+    list_del_init(&dp->d_alias);
152+    list_add(&dp->d_alias, &(AFSTOV(vcp)->i_dentry));
153+    dp->d_inode = AFSTOV(vcp);
154+    spin_unlock(&dcache_lock);
155+    dput(dp);
156+
157+    AFS_FAST_RELE(afs_globalVp);
158+    afs_globalVp = vcp;
159+out:
160+    crfree(credp);
161+    afs_DestroyReq(treq);
162+}
163diff --git a/src/afs/afs_daemons.c b/src/afs/afs_daemons.c
164index a78aaaa..dd943a7 100644
165--- a/src/afs/afs_daemons.c
166+++ b/src/afs/afs_daemons.c
167@@ -351,71 +351,14 @@ afs_CheckRootVolume(void)
168                 * count to zero and fs checkv is executed when the current
169                 * directory is /afs.
170                 */
171-#ifdef AFS_LINUX20_ENV
172-               {
173-                   struct vrequest *treq = NULL;
174-                   struct vattr vattr;
175-                   cred_t *credp;
176-                   struct dentry *dp;
177-                   struct vcache *vcp;
178-
179-                   afs_rootFid.Fid.Volume = volid;
180-                   afs_rootFid.Fid.Vnode = 1;
181-                   afs_rootFid.Fid.Unique = 1;
182-
183-                   credp = crref();
184-                   if (afs_CreateReq(&treq, credp))
185-                       goto out;
186-                   vcp = afs_GetVCache(&afs_rootFid, treq, NULL, NULL);
187-                   if (!vcp)
188-                       goto out;
189-                   afs_getattr(vcp, &vattr, credp);
190-                   afs_fill_inode(AFSTOV(vcp), &vattr);
191-
192-                   dp = d_find_alias(AFSTOV(afs_globalVp));
193-
194-#if defined(AFS_LINUX24_ENV)
195-#if defined(HAVE_DCACHE_LOCK)
196-                   spin_lock(&dcache_lock);
197-#else
198-                   spin_lock(&AFSTOV(vcp)->i_lock);
199-#endif
200-#if defined(AFS_LINUX26_ENV)
201-                   spin_lock(&dp->d_lock);
202-#endif
203-#endif
204-#if defined(D_ALIAS_IS_HLIST)
205-                   hlist_del_init(&dp->d_alias);
206-                   hlist_add_head(&dp->d_alias, &(AFSTOV(vcp)->i_dentry));
207-#else
208-                   list_del_init(&dp->d_alias);
209-                   list_add(&dp->d_alias, &(AFSTOV(vcp)->i_dentry));
210-#endif
211-                   dp->d_inode = AFSTOV(vcp);
212-#if defined(AFS_LINUX24_ENV)
213-#if defined(AFS_LINUX26_ENV)
214-                   spin_unlock(&dp->d_lock);
215-#endif
216-#if defined(HAVE_DCACHE_LOCK)
217-                   spin_unlock(&dcache_lock);
218-#else
219-                   spin_unlock(&AFSTOV(vcp)->i_lock);
220-#endif
221-#endif
222-                   dput(dp);
223-
224-                   AFS_FAST_RELE(afs_globalVp);
225-                   afs_globalVp = vcp;
226-               out:
227-                   crfree(credp);
228-                   afs_DestroyReq(treq);
229-               }
230+#ifdef AFS_LINUX22_ENV
231+               osi_ResetRootVCache(volid);
232 #else
233-#ifdef AFS_DARWIN80_ENV
234+# ifdef AFS_DARWIN80_ENV
235                afs_PutVCache(afs_globalVp);
236-#else
237+# else
238                AFS_FAST_RELE(afs_globalVp);
239-#endif
240+# endif
241                afs_globalVp = 0;
242 #endif
243            }
244--
2452.2.1
246
247
248From 4ba5cbd90e96edd63bd0178df8ce615c1efe1b2c Mon Sep 17 00:00:00 2001
249From: Marc Dionne <marc.dionne@your-file-system.com>
250Date: Thu, 18 Dec 2014 07:13:46 -0500
251Subject: [PATCH 2/2] Linux: d_alias becomes d_u.d_alias
252
253The fields in struct dentry are re-arranged so that d_alias
254shares space wth d_rcu inside the d_u union.  Some references
255need to change from d_alias to d_u.d_alias.
256
257The kernel change was introduced for 3.19 but was also backported
258to the 3.18 stable series in 3.18.1, so this commit is required
259for 3.19 and current 3.18 kernels.
260
261Change-Id: I711a5a3a89af6e0055381dfd4474ddca2868bb9c
262---
263 acinclude.m4               | 1 +
264 src/afs/LINUX/osi_compat.h | 4 ++++
265 src/cf/linux-test4.m4      | 9 ++++++++-
266 3 files changed, 13 insertions(+), 1 deletion(-)
267
268diff --git a/acinclude.m4 b/acinclude.m4
269index 96adde0..e8e238b 100644
270--- a/acinclude.m4
271+++ b/acinclude.m4
272@@ -899,6 +899,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
273                                       [backing-dev.h])
274                 AC_CHECK_LINUX_STRUCT([cred], [session_keyring], [cred.h])
275                 AC_CHECK_LINUX_STRUCT([ctl_table], [ctl_name], [sysctl.h])
276+                AC_CHECK_LINUX_STRUCT([dentry], [d_u.d_alias], [dcache.h])
277                 AC_CHECK_LINUX_STRUCT([dentry_operations], [d_automount], [dcache.h])
278                 AC_CHECK_LINUX_STRUCT([inode], [i_alloc_sem], [fs.h])
279                 AC_CHECK_LINUX_STRUCT([inode], [i_blkbits], [fs.h])
280diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h
281index 57f6ea7..497b1ef 100644
282--- a/src/afs/LINUX/osi_compat.h
283+++ b/src/afs/LINUX/osi_compat.h
284@@ -37,6 +37,10 @@ typedef struct vfs_path afs_linux_path_t;
285 typedef struct path afs_linux_path_t;
286 #endif
287 
288+#if defined(STRUCT_DENTRY_HAS_D_U_D_ALIAS)
289+# define d_alias d_u.d_alias
290+#endif
291+
292 #ifndef HAVE_LINUX_DO_SYNC_READ
293 static inline int
294 do_sync_read(struct file *fp, char *buf, size_t count, loff_t *offp) {
295diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4
296index f0269b3..9dd55b3 100644
297--- a/src/cf/linux-test4.m4
298+++ b/src/cf/linux-test4.m4
299@@ -713,7 +713,11 @@ AC_DEFUN([LINUX_D_ALIAS_IS_HLIST], [
300                        [#include <linux/fs.h>],
301                        [struct dentry *d = NULL;
302                        struct hlist_node *hn = NULL;
303-                       d->d_alias = *hn;],
304+                       #if defined(STRUCT_DENTRY_HAS_D_U_D_ALIAS)
305+                       d->d_u.d_alias = *hn;
306+                       #else
307+                       d->d_alias = *hn;
308+                       #endif],
309                        [D_ALIAS_IS_HLIST],
310                        [define if dentry->d_alias is an hlist],
311                        [])
312@@ -727,6 +731,9 @@ AC_DEFUN([LINUX_HLIST_ITERATOR_NO_NODE], [
313                        #include <linux/fs.h>],
314                        [struct dentry *d = NULL, *cur;
315                        struct inode *ip;
316+                       #if defined(STRUCT_DENTRY_HAS_D_U_D_ALIAS)
317+                       # define d_alias d_u.d_alias
318+                       #endif
319                        hlist_for_each_entry(cur, &ip->i_dentry, d_alias) { }
320                        ],
321                        [HLIST_ITERATOR_NO_NODE],
322--
3232.2.1
324
Note: See TracBrowser for help on using the repository browser.