source: trunk/server/common/patches/openafs-linux-3.8-enablement.patch @ 2401

Last change on this file since 2401 was 2401, checked in by achernya, 9 years ago
Add the openafs 3.8 enablement patch
File size: 20.9 KB
RevLine 
[2401]1From 5a21be491adc6acd3cc01990910c5675393be953 Mon Sep 17 00:00:00 2001
2From: Andrew Deason <adeason@sinenomine.net>
3Date: Wed, 29 Aug 2012 11:34:06 -0500
4Subject: [PATCH] LINUX: Indent osi_machdep.h maze
5
6This one isn't so bad, actually, but it still benefits from some
7indentation.
8
9Reviewed-on: http://gerrit.openafs.org/8018
10Tested-by: BuildBot <buildbot@rampaginggeek.com>
11Reviewed-by: Derrick Brashear <shadow@dementix.org>
12(cherry picked from commit 579048cb1ec24b09a869928ceb521c8db4201a43)
13
14Change-Id: I91bddcafe4141c5e6789b01cc4be1a879b6464d1
15Reviewed-on: http://gerrit.openafs.org/9330
16Tested-by: BuildBot <buildbot@rampaginggeek.com>
17Reviewed-by: Ken Dreyer <ktdreyer@ktdreyer.com>
18Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
19---
20 src/afs/LINUX/osi_machdep.h |  240 +++++++++++++++++++++----------------------
21 1 file changed, 120 insertions(+), 120 deletions(-)
22
23diff --git a/src/afs/LINUX/osi_machdep.h b/src/afs/LINUX/osi_machdep.h
24index a2c16f5..9260733 100644
25--- a/src/afs/LINUX/osi_machdep.h
26+++ b/src/afs/LINUX/osi_machdep.h
27@@ -17,60 +17,60 @@
28 
29 #include <linux/version.h>
30 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
31-#define AFS_LINUX26_ONEGROUP_ENV 1
32+# define AFS_LINUX26_ONEGROUP_ENV 1
33 #endif
34 
35 /* Only needed for xdr.h in glibc 2.1.x */
36 #ifndef quad_t
37-#define quad_t __quad_t
38-#define u_quad_t __u_quad_t
39+# define quad_t __quad_t
40+# define u_quad_t __u_quad_t
41 #endif
42 
43 #undef getuerror
44 
45 #ifdef STRUCT_TASK_STRUCT_HAS_TGID
46-#define getpid() current->tgid
47-#ifdef STRUCT_TASK_STRUCT_HAS_REAL_PARENT
48-#define getppid() current->real_parent->tgid
49-#elif defined(STRUCT_TASK_STRUCT_HAS_PARENT)
50-#define getppid() current->parent->tgid
51-#else
52-#define getppid() current->p_opptr->tgid
53-#endif
54+# define getpid() current->tgid
55+# ifdef STRUCT_TASK_STRUCT_HAS_REAL_PARENT
56+#  define getppid() current->real_parent->tgid
57+# elif defined(STRUCT_TASK_STRUCT_HAS_PARENT)
58+#  define getppid() current->parent->tgid
59+# else
60+#  define getppid() current->p_opptr->tgid
61+# endif
62 #else /* !STRUCT_TASK_STRUCT_HAS_TGID */
63-#define getpid() current->pid
64-#ifdef STRUCT_TASK_STRUCT_HAS_REAL_PARENT
65-#define getppid() current->real_parent->pid
66-#elif defined(STRUCT_TASK_STRUCT_HAS_PARENT)
67-#define getppid() current->parent->pid
68-#else
69-#define getppid() current->p_opptr->pid
70-#endif
71+# define getpid() current->pid
72+# ifdef STRUCT_TASK_STRUCT_HAS_REAL_PARENT
73+#  define getppid() current->real_parent->pid
74+# elif defined(STRUCT_TASK_STRUCT_HAS_PARENT)
75+#  define getppid() current->parent->pid
76+# else
77+#  define getppid() current->p_opptr->pid
78+# endif
79 #endif /* STRUCT_TASK_STRUCT_HAS_TGID */
80 
81 #ifdef RECALC_SIGPENDING_TAKES_VOID
82-#define RECALC_SIGPENDING(X) recalc_sigpending()
83+# define RECALC_SIGPENDING(X) recalc_sigpending()
84 #else
85-#define RECALC_SIGPENDING(X) recalc_sigpending(X)
86+# define RECALC_SIGPENDING(X) recalc_sigpending(X)
87 #endif
88 
89 #if defined (STRUCT_TASK_STRUCT_HAS_SIGMASK_LOCK)
90-#define SIG_LOCK(X) spin_lock_irq(&X->sigmask_lock)
91-#define SIG_UNLOCK(X) spin_unlock_irq(&X->sigmask_lock)
92+# define SIG_LOCK(X) spin_lock_irq(&X->sigmask_lock)
93+# define SIG_UNLOCK(X) spin_unlock_irq(&X->sigmask_lock)
94 #elif defined (STRUCT_TASK_STRUCT_HAS_SIGHAND)
95-#define SIG_LOCK(X) spin_lock_irq(&X->sighand->siglock)
96-#define SIG_UNLOCK(X) spin_unlock_irq(&X->sighand->siglock)
97+# define SIG_LOCK(X) spin_lock_irq(&X->sighand->siglock)
98+# define SIG_UNLOCK(X) spin_unlock_irq(&X->sighand->siglock)
99 #else
100-#define SIG_LOCK(X) spin_lock_irq(&X->sig->siglock)
101-#define SIG_UNLOCK(X) spin_unlock_irq(&X->sig->siglock)
102+# define SIG_LOCK(X) spin_lock_irq(&X->sig->siglock)
103+# define SIG_UNLOCK(X) spin_unlock_irq(&X->sig->siglock)
104 #endif
105 
106 #if defined (STRUCT_TASK_STRUCT_HAS_RLIM)
107-#define TASK_STRUCT_RLIM rlim
108+# define TASK_STRUCT_RLIM rlim
109 #elif defined (STRUCT_TASK_STRUCT_HAS_SIGNAL_RLIM)
110-#define TASK_STRUCT_RLIM signal->rlim
111+# define TASK_STRUCT_RLIM signal->rlim
112 #else
113-#error Not sure what to do about rlim (should be in the Linux task struct somewhere....)
114+# error Not sure what to do about rlim (should be in the Linux task struct somewhere....)
115 #endif
116 
117 
118@@ -83,13 +83,13 @@ static inline time_t osi_Time(void) {
119     return xtime.tv_sec;
120 }
121 #else
122-#define osi_Time() (xtime.tv_sec)
123+# define osi_Time() (xtime.tv_sec)
124 #endif
125 
126 
127 
128 #ifdef AFS_LINUX_64BIT_KERNEL
129-#define osi_GetTime(V)                                 \
130+# define osi_GetTime(V)                                 \
131     do {                                               \
132        struct timeval __afs_tv;                              \
133        do_gettimeofday(&__afs_tv);                           \
134@@ -97,7 +97,7 @@ static inline time_t osi_Time(void) {
135        (V)->tv_usec = (afs_int32)__afs_tv.tv_usec;           \
136     } while (0)
137 #else
138-#define osi_GetTime(V) do_gettimeofday((V))
139+# define osi_GetTime(V) do_gettimeofday((V))
140 #endif
141 
142 #undef gop_lookupname
143@@ -149,12 +149,12 @@ typedef struct task_struct afs_proc_t;
144 typedef struct cred afs_ucred_t;
145 typedef struct cred cred_t;
146 
147-#define afs_cr_uid(cred) ((cred)->fsuid)
148-#define afs_cr_gid(cred) ((cred)->fsgid)
149-#define afs_cr_ruid(cred) ((cred)->uid)
150-#define afs_cr_rgid(cred) ((cred)->gid)
151-#define afs_cr_group_info(cred) ((cred)->group_info)
152-#define crhold(c) (get_cred(c))
153+# define afs_cr_uid(cred) ((cred)->fsuid)
154+# define afs_cr_gid(cred) ((cred)->fsgid)
155+# define afs_cr_ruid(cred) ((cred)->uid)
156+# define afs_cr_rgid(cred) ((cred)->gid)
157+# define afs_cr_group_info(cred) ((cred)->group_info)
158+# define crhold(c) (get_cred(c))
159 static inline void
160 afs_set_cr_uid(cred_t *cred, uid_t uid) {
161     cred->fsuid = uid;
162@@ -176,11 +176,11 @@ afs_set_cr_group_info(cred_t *cred, struct group_info *group_info) {
163     cred->group_info = group_info;
164 }
165 
166-#define current_group_info() (current->cred->group_info)
167-#define task_gid(task) (task->cred->gid)
168-#define task_user(task) (task->cred->user)
169-#define task_session_keyring(task) (task->cred->tgcred->session_keyring)
170-#define current_session_keyring() (current->cred->tgcred->session_keyring)
171+# define current_group_info() (current->cred->group_info)
172+# define task_gid(task) (task->cred->gid)
173+# define task_user(task) (task->cred->user)
174+# define task_session_keyring(task) (task->cred->tgcred->session_keyring)
175+# define current_session_keyring() (current->cred->tgcred->session_keyring)
176 
177 #else
178 
179@@ -194,31 +194,31 @@ typedef struct afs_cred {
180 } cred_t;
181 
182 typedef struct afs_cred afs_ucred_t;
183-#define afs_cr_group_info(cred) ((cred)->cr_group_info)
184+# define afs_cr_group_info(cred) ((cred)->cr_group_info)
185 static inline void
186 afs_set_cr_group_info(cred_t *cred, struct group_info *group_info) {
187     cred->cr_group_info = group_info;
188 }
189 
190-#define current_group_info() (current->group_info)
191-#if !defined(task_gid)
192-#define task_gid(task) (task->gid)
193-#endif
194-#if !defined(task_uid)
195-#define task_uid(task) (task->uid)
196-#endif
197-#define task_user(task) (task->user)
198-#define task_session_keyring(task) (task->signal->session_keyring)
199-#define current_session_keyring() (current->signal->session_keyring)
200-#define crhold(c) atomic_inc(&(c)->cr_ref)
201+# define current_group_info() (current->group_info)
202+# if !defined(task_gid)
203+#  define task_gid(task) (task->gid)
204+# endif
205+# if !defined(task_uid)
206+#  define task_uid(task) (task->uid)
207+# endif
208+# define task_user(task) (task->user)
209+# define task_session_keyring(task) (task->signal->session_keyring)
210+# define current_session_keyring() (current->signal->session_keyring)
211+# define crhold(c) atomic_inc(&(c)->cr_ref)
212 
213 #endif /* defined(STRUCT_TASK_STRUCT_HAS_CRED) */
214 
215 #if !defined(current_cred)
216-#define current_gid() (current->gid)
217-#define current_uid() (current->uid)
218-#define current_fsgid() (current->fsgid)
219-#define current_fsuid() (current->fsuid)
220+# define current_gid() (current->gid)
221+# define current_uid() (current->uid)
222+# define current_fsgid() (current->fsgid)
223+# define current_fsuid() (current->fsuid)
224 #endif
225 
226 /* UIO manipulation */
227@@ -245,7 +245,7 @@ struct uio {
228 #define OSIFILE_INODE(a) FILE_INODE((a)->filp)
229 
230 #if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)
231-#define NEED_IOCTL32
232+# define NEED_IOCTL32
233 #endif
234 
235 #include <linux/version.h>
236@@ -256,8 +256,8 @@ struct uio {
237 extern struct mutex afs_global_lock;
238 #else
239 extern struct semaphore afs_global_lock;
240-#define mutex_lock(lock) down(lock)
241-#define mutex_unlock(lock) up(lock)
242+# define mutex_lock(lock) down(lock)
243+# define mutex_unlock(lock) up(lock)
244 #endif
245 extern int afs_global_owner;
246 
247@@ -285,63 +285,63 @@ do { \
248 #ifdef AFS_AMD64_LINUX20_ENV
249 /* RHEL5 beta's kernel doesn't define these. They aren't gonna change, so... */
250 
251-#ifndef __NR_ia32_afs_syscall
252-#define __NR_ia32_afs_syscall 137
253-#endif
254-#ifndef __NR_ia32_setgroups
255-#define __NR_ia32_setgroups 81
256-#endif
257-#ifndef __NR_ia32_setgroups32
258-#define __NR_ia32_setgroups32 206
259-#endif
260-#ifndef __NR_ia32_close
261-#define __NR_ia32_close 6
262-#endif
263-#ifndef __NR_ia32_chdir
264-#define __NR_ia32_chdir 12
265-#endif
266-#ifndef __NR_ia32_break
267-#define __NR_ia32_break 17
268-#endif
269-#ifndef __NR_ia32_stty
270-#define __NR_ia32_stty 31
271-#endif
272-#ifndef __NR_ia32_gtty
273-#define __NR_ia32_gtty 32
274-#endif
275-#ifndef __NR_ia32_ftime
276-#define __NR_ia32_ftime 35
277-#endif
278-#ifndef __NR_ia32_prof
279-#define __NR_ia32_prof 44
280-#endif
281-#ifndef __NR_ia32_lock
282-#define __NR_ia32_lock 53
283-#endif
284-#ifndef __NR_ia32_mpx
285-#define __NR_ia32_mpx 56
286-#endif
287-#ifndef __NR_ia32_exit
288-#define __NR_ia32_exit 1
289-#endif
290-#ifndef __NR_ia32_mount
291-#define __NR_ia32_mount 21
292-#endif
293-#ifndef __NR_ia32_read
294-#define __NR_ia32_read 3
295-#endif
296-#ifndef __NR_ia32_write
297-#define __NR_ia32_write 4
298-#endif
299-#ifndef __NR_ia32_open
300-#define __NR_ia32_open 5
301-#endif
302-#ifndef __NR_ia32_close
303-#define __NR_ia32_close 6
304-#endif
305-#ifndef __NR_ia32_unlink
306-#define __NR_ia32_unlink 10
307-#endif
308+# ifndef __NR_ia32_afs_syscall
309+#  define __NR_ia32_afs_syscall 137
310+# endif
311+# ifndef __NR_ia32_setgroups
312+#  define __NR_ia32_setgroups 81
313+# endif
314+# ifndef __NR_ia32_setgroups32
315+#  define __NR_ia32_setgroups32 206
316+# endif
317+# ifndef __NR_ia32_close
318+#  define __NR_ia32_close 6
319+# endif
320+# ifndef __NR_ia32_chdir
321+#  define __NR_ia32_chdir 12
322+# endif
323+# ifndef __NR_ia32_break
324+#  define __NR_ia32_break 17
325+# endif
326+# ifndef __NR_ia32_stty
327+#  define __NR_ia32_stty 31
328+# endif
329+# ifndef __NR_ia32_gtty
330+#  define __NR_ia32_gtty 32
331+# endif
332+# ifndef __NR_ia32_ftime
333+#  define __NR_ia32_ftime 35
334+# endif
335+# ifndef __NR_ia32_prof
336+#  define __NR_ia32_prof 44
337+# endif
338+# ifndef __NR_ia32_lock
339+#  define __NR_ia32_lock 53
340+# endif
341+# ifndef __NR_ia32_mpx
342+#  define __NR_ia32_mpx 56
343+# endif
344+# ifndef __NR_ia32_exit
345+#  define __NR_ia32_exit 1
346+# endif
347+# ifndef __NR_ia32_mount
348+#  define __NR_ia32_mount 21
349+# endif
350+# ifndef __NR_ia32_read
351+#  define __NR_ia32_read 3
352+# endif
353+# ifndef __NR_ia32_write
354+#  define __NR_ia32_write 4
355+# endif
356+# ifndef __NR_ia32_open
357+#  define __NR_ia32_open 5
358+# endif
359+# ifndef __NR_ia32_close
360+#  define __NR_ia32_close 6
361+# endif
362+# ifndef __NR_ia32_unlink
363+#  define __NR_ia32_unlink 10
364+# endif
365 #endif
366 
367 #define osi_procname(procname, size) strncpy(procname, current->comm, size)
368--
3691.7.9.6 (Apple Git-31.1)
370
371From 314fcfa35917de0f688374137f0ffa040ea3660d Mon Sep 17 00:00:00 2001
372From: Marc Dionne <marc.c.dionne@gmail.com>
373Date: Wed, 9 Jan 2013 19:26:54 -0500
374Subject: [PATCH] Linux 3.8: session_keyring changes
375
376The session_keyring is now attached directly to the cred structure
377and the thread_group_cred structure (cred->tgcred) no longer exists.
378
379Adapt code that makes use of tgcred, and use the standard rcu based
380mechanism to update session_keyring.
381
382Reviewed-on: http://gerrit.openafs.org/8905
383Reviewed-by: Andrew Deason <adeason@sinenomine.net>
384Tested-by: BuildBot <buildbot@rampaginggeek.com>
385Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
386(cherry picked from commit c6d27e322a8d3b352554650473a048235a9c763a)
387
388Change-Id: If0998ee777ab0d196e19162499eb3ee60c5ff85d
389Reviewed-on: http://gerrit.openafs.org/8941
390Reviewed-by: Ken Dreyer <ktdreyer@ktdreyer.com>
391Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
392Tested-by: BuildBot <buildbot@rampaginggeek.com>
393Reviewed-by: Andrew Deason <adeason@sinenomine.net>
394Reviewed-by: Paul Smeddle <paul.smeddle@gmail.com>
395Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
396---
397 acinclude.m4                |    1 +
398 src/afs/LINUX/osi_compat.h  |   34 ++++++++++++++++++++++++++++++++--
399 src/afs/LINUX/osi_groups.c  |    9 ++-------
400 src/afs/LINUX/osi_machdep.h |    9 +++++++--
401 4 files changed, 42 insertions(+), 11 deletions(-)
402
403diff --git a/acinclude.m4 b/acinclude.m4
404index 8c57779..0a05caa 100644
405--- a/acinclude.m4
406+++ b/acinclude.m4
407@@ -812,6 +812,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
408                                       [write_begin], [fs.h])
409                 AC_CHECK_LINUX_STRUCT([backing_dev_info], [name],
410                                       [backing-dev.h])
411+                AC_CHECK_LINUX_STRUCT([cred], [session_keyring], [cred.h])
412                 AC_CHECK_LINUX_STRUCT([ctl_table], [ctl_name], [sysctl.h])
413                 AC_CHECK_LINUX_STRUCT([dentry_operations], [d_automount], [dcache.h])
414                 AC_CHECK_LINUX_STRUCT([inode], [i_alloc_sem], [fs.h])
415diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h
416index 2dda136..a777542 100644
417--- a/src/afs/LINUX/osi_compat.h
418+++ b/src/afs/LINUX/osi_compat.h
419@@ -186,14 +186,24 @@ afs_linux_key_alloc(struct key_type *type, const char *desc, uid_t uid,
420 }
421 
422 # if defined(STRUCT_TASK_STRUCT_HAS_CRED)
423+static inline struct key *
424+afs_session_keyring(afs_ucred_t *cred)
425+{
426+#  if defined(STRUCT_CRED_HAS_SESSION_KEYRING)
427+    return cred->session_keyring;
428+#  else
429+    return cred->tgcred->session_keyring;
430+#  endif
431+}
432+
433 static inline struct key*
434 afs_linux_search_keyring(afs_ucred_t *cred, struct key_type *type)
435 {
436     key_ref_t key_ref;
437 
438-    if (cred->tgcred->session_keyring) {
439+    if (afs_session_keyring(cred)) {
440        key_ref = keyring_search(
441-                     make_key_ref(cred->tgcred->session_keyring, 1),
442+                     make_key_ref(afs_session_keyring(cred), 1),
443                      type, "_pag");
444        if (IS_ERR(key_ref))
445            return ERR_CAST(key_ref);
446@@ -507,4 +517,24 @@ afs_set_name(afs_name_t aname, char *string) {
447 }
448 #endif
449 
450+static_inline struct key *
451+afs_set_session_keyring(struct key *keyring)
452+{
453+    struct key *old;
454+#if defined(STRUCT_CRED_HAS_SESSION_KEYRING)
455+    struct cred *new_creds;
456+    old = current_session_keyring();
457+    new_creds = prepare_creds();
458+    rcu_assign_pointer(new_creds->session_keyring, keyring);
459+    commit_creds(new_creds);
460+#else
461+    spin_lock_irq(&current->sighand->siglock);
462+    old = task_session_keyring(current);
463+    smp_wmb();
464+    task_session_keyring(current) = keyring;
465+    spin_unlock_irq(&current->sighand->siglock);
466+#endif
467+    return old;
468+}
469+
470 #endif /* AFS_LINUX_OSI_COMPAT_H */
471diff --git a/src/afs/LINUX/osi_groups.c b/src/afs/LINUX/osi_groups.c
472index c2a0308..e351344 100644
473--- a/src/afs/LINUX/osi_groups.c
474+++ b/src/afs/LINUX/osi_groups.c
475@@ -214,14 +214,9 @@ install_session_keyring(struct key *keyring)
476     }
477 
478     /* install the keyring */
479-    spin_lock_irq(&current->sighand->siglock);
480-    old = task_session_keyring(current);
481-    smp_wmb();
482-    task_session_keyring(current) = keyring;
483-    spin_unlock_irq(&current->sighand->siglock);
484-
485+    old = afs_set_session_keyring(keyring);
486     if (old)
487-           key_put(old);
488+       key_put(old);
489 
490 out:
491     return code;
492diff --git a/src/afs/LINUX/osi_machdep.h b/src/afs/LINUX/osi_machdep.h
493index 9260733..0202d0d 100644
494--- a/src/afs/LINUX/osi_machdep.h
495+++ b/src/afs/LINUX/osi_machdep.h
496@@ -179,8 +179,13 @@ afs_set_cr_group_info(cred_t *cred, struct group_info *group_info) {
497 # define current_group_info() (current->cred->group_info)
498 # define task_gid(task) (task->cred->gid)
499 # define task_user(task) (task->cred->user)
500-# define task_session_keyring(task) (task->cred->tgcred->session_keyring)
501-# define current_session_keyring() (current->cred->tgcred->session_keyring)
502+# if defined(STRUCT_CRED_HAS_SESSION_KEYRING)
503+#  define task_session_keyring(task) (task->cred->session_keyring)
504+#  define current_session_keyring() (current->cred->session_keyring)
505+# else
506+#  define task_session_keyring(task) (task->cred->tgcred->session_keyring)
507+#  define current_session_keyring() (current->cred->tgcred->session_keyring)
508+# endif
509 
510 #else
511 
512--
5131.7.9.6 (Apple Git-31.1)
514
515From bf9bcd09e6a54eb40e47c7a6cdc060be43be9495 Mon Sep 17 00:00:00 2001
516From: Marc Dionne <marc.c.dionne@gmail.com>
517Date: Wed, 9 Jan 2013 21:22:27 -0500
518Subject: [PATCH] Linux 3.8: vmtruncate removal
519
520vmtruncate had been deprecated for a while and has now been
521removed.  Do things the new way based on truncate_setsize.
522
523Reviewed-on: http://gerrit.openafs.org/8906
524Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
525Tested-by: BuildBot <buildbot@rampaginggeek.com>
526Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
527(cherry picked from commit d0479bbaf43900d6733c3f7517926ee9813c9610)
528
529Change-Id: Iafc64e19544dec9fcaefad5ad274eac4133f4083
530Reviewed-on: http://gerrit.openafs.org/8942
531Reviewed-by: Ken Dreyer <ktdreyer@ktdreyer.com>
532Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
533Tested-by: BuildBot <buildbot@rampaginggeek.com>
534Reviewed-by: Andrew Deason <adeason@sinenomine.net>
535Reviewed-by: Paul Smeddle <paul.smeddle@gmail.com>
536Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
537---
538 acinclude.m4               |    1 +
539 src/afs/LINUX/osi_compat.h |   14 ++++++++++++++
540 src/afs/LINUX/osi_vm.c     |    5 ++---
541 3 files changed, 17 insertions(+), 3 deletions(-)
542
543diff --git a/acinclude.m4 b/acinclude.m4
544index 0a05caa..4223bb1 100644
545--- a/acinclude.m4
546+++ b/acinclude.m4
547@@ -824,6 +824,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
548                 AC_CHECK_LINUX_STRUCT([file_operations], [sendfile], [fs.h])
549                 AC_CHECK_LINUX_STRUCT([file_system_type], [mount], [fs.h])
550                 AC_CHECK_LINUX_STRUCT([filename], [name], [fs.h])
551+                AC_CHECK_LINUX_STRUCT([inode_operations], [truncate], [fs.h])
552                 AC_CHECK_LINUX_STRUCT([key_type], [preparse], [key-type.h])
553                 AC_CHECK_LINUX_STRUCT([nameidata], [path], [namei.h])
554                 AC_CHECK_LINUX_STRUCT([proc_dir_entry], [owner], [proc_fs.h])
555diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h
556index a777542..e8bf003 100644
557--- a/src/afs/LINUX/osi_compat.h
558+++ b/src/afs/LINUX/osi_compat.h
559@@ -537,4 +537,18 @@ afs_set_session_keyring(struct key *keyring)
560     return old;
561 }
562 
563+static inline int
564+afs_truncate(struct inode *inode, int len)
565+{
566+    int code;
567+#if defined(STRUCT_INODE_OPERATIONS_HAS_TRUNCATE)
568+    code = vmtruncate(inode, len);
569+#else
570+    code = inode_newsize_ok(inode, len);
571+    if (!code)
572+        truncate_setsize(inode, len);
573+#endif
574+    return code;
575+}
576+
577 #endif /* AFS_LINUX_OSI_COMPAT_H */
578diff --git a/src/afs/LINUX/osi_vm.c b/src/afs/LINUX/osi_vm.c
579index 2cd34f9..8bc792e 100644
580--- a/src/afs/LINUX/osi_vm.c
581+++ b/src/afs/LINUX/osi_vm.c
582@@ -51,8 +51,7 @@ osi_VM_FlushVCache(struct vcache *avc, int *slept)
583     if (avc->opens != 0)
584        return EBUSY;
585 
586-    return vmtruncate(ip, 0);
587-    return 0;
588+    return afs_truncate(ip, 0);
589 }
590 
591 /* Try to invalidate pages, for "fs flush" or "fs flushv"; or
592@@ -132,5 +131,5 @@ osi_VM_FlushPages(struct vcache *avc, afs_ucred_t *credp)
593 void
594 osi_VM_Truncate(struct vcache *avc, int alen, afs_ucred_t *acred)
595 {
596-    vmtruncate(AFSTOV(avc), alen);
597+    afs_truncate(AFSTOV(avc), alen);
598 }
599--
6001.7.9.6 (Apple Git-31.1)
601
602From b0a10607f90c4097206bc38cb9bd16e842dbda10 Mon Sep 17 00:00:00 2001
603From: Marc Dionne <marc.c.dionne@gmail.com>
604Date: Fri, 18 Jan 2013 22:40:03 -0500
605Subject: [PATCH] Linux: setpag() may replace credentials
606
607For recent Linux. setpag() may replace the current process' cred
608structure with a new one.  This is not a problem for most callers,
609but in the case of processing a SetTokens2 pioctl with the setpag
610option, the new credentials should be used to determine the target
611for the token.
612
613Reviewed-on: http://gerrit.openafs.org/8924
614Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
615Tested-by: BuildBot <buildbot@rampaginggeek.com>
616Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
617(cherry picked from commit b61eac783e8c092cd4ba9f53a2b5ca7d43e08b1b)
618
619Change-Id: I66b5f171318964ff40fe78be24e75519183c3a82
620Reviewed-on: http://gerrit.openafs.org/8948
621Tested-by: BuildBot <buildbot@rampaginggeek.com>
622Reviewed-by: Andrew Deason <adeason@sinenomine.net>
623Reviewed-by: Paul Smeddle <paul.smeddle@gmail.com>
624Reviewed-by: Ken Dreyer <ktdreyer@ktdreyer.com>
625Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
626---
627 src/afs/afs_pioctl.c |    8 ++++++++
628 1 file changed, 8 insertions(+)
629
630diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c
631index 3c01be5..98919a3 100644
632--- a/src/afs/afs_pioctl.c
633+++ b/src/afs/afs_pioctl.c
634@@ -1859,6 +1859,9 @@ DECL_PIOCTL(PSetTokens)
635     afs_PutCell(tcell, READ_LOCK);
636     if (set_parent_pag) {
637        afs_uint32 pag;
638+#if defined(AFS_LINUX26_ENV)
639+       afs_ucred_t *old_cred = *acred;
640+#endif
641 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
642        char procname[256];
643        osi_procname(procname, 256);
644@@ -1868,6 +1871,11 @@ DECL_PIOCTL(PSetTokens)
645 #else
646        if (!setpag(acred, -1, &pag, 1)) {
647 #endif
648+#if defined(AFS_LINUX26_ENV)
649+           /* setpag() may have changed our credentials */
650+           *acred = crref();
651+           crfree(old_cred);
652+#endif
653            afs_InitReq(&treq, *acred);
654            areq = &treq;
655        }
656--
6571.7.9.6 (Apple Git-31.1)
658
Note: See TracBrowser for help on using the repository browser.