1 /* Kernel compatibility routines
3 * This file contains definitions to provide compatibility between different
4 * versions of the Linux kernel. It is an ifdef maze, but the idea is that
5 * by concentrating the horror here, the rest of the tree may remaing a
9 #ifndef AFS_LINUX_OSI_COMPAT_H
10 #define AFS_LINUX_OSI_COMPAT_H
14 do_sync_read(struct file *fp, char *buf, size_t count, loff_t *offp) {
15 return generic_file_read(fp, buf, count, offp);
19 do_sync_write(struct file *fp, char *buf, size_t count, loff_t *offp) {
20 return generic_file_write(fp, buf, count, offp);
23 #endif /* DO_SYNC_READ */
26 afs_posix_lock_file(struct file *fp, struct file_lock *flp) {
27 #ifdef POSIX_LOCK_FILE_WAIT_ARG
28 return posix_lock_file(fp, flp, NULL);
30 flp->fl_flags &=~ FL_SLEEP;
31 return posix_lock_file(fp, flp);
36 afs_posix_test_lock(struct file *fp, struct file_lock *flp) {
37 #if defined(POSIX_TEST_LOCK_CONFLICT_ARG)
38 struct file_lock conflict;
39 if (posix_test_lock(fp, flp, &conflict)) {
40 locks_copy_lock(flp, &conflict);
41 flp->fl_type = F_UNLCK;
43 #elif defined(POSIX_TEST_LOCK_RETURNS_CONFLICT)
44 struct file_lock *conflict;
45 if (conflict = posix_test_lock(fp, flp)) {
46 locks_copy_lock(flp, conflict);
47 flp->fl_type = F_UNLCK;
50 posix_test_lock(fp, flp);
54 #ifdef DCACHE_NFSFS_RENAMED
56 afs_linux_clear_nfsfs_renamed(struct dentry *dp) {
57 spin_lock(&dp->d_lock);
58 dp->d_flags &= ~DCACHE_NFSFS_RENAMED;
59 spin_unlock(&dp->d_lock);
63 afs_linux_set_nfsfs_renamed(struct dentry *dp) {
64 spin_lock(&dp->d_lock);
65 dp->d_flags |= DCACHE_NFSFS_RENAMED;
66 spin_unlock(&dp->d_lock);
69 static inline void afs_linux_clear_nfsfs_renamed(void) { return; }
70 static inline void afs_linux_set_nfsfs_renamed(void) { return; }
73 #ifndef HAVE_KERNEL_HLIST_UNHASHED
75 hlist_unhashed(const struct hlist_node *h) {
76 return (!h->pprev == NULL);
80 #if defined(WRITEPAGE_ACTIVATE)
81 #define AOP_WRITEPAGE_ACTIVATE WRITEPAGE_ACTIVATE
84 #if defined(HAVE_WRITE_BEGIN) && !defined(HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN)
85 static inline struct page *
86 grab_cache_page_write_begin(struct address_space *mapping, pgoff_t index,
88 return __grab_cache_page(mapping, index);
92 #if defined(HAVE_KMEM_CACHE_T)
93 #define afs_kmem_cache_t kmem_cache_t
95 #define afs_kmem_cache_t struct kmem_cache
98 extern void init_once(void *);
99 #if defined(HAVE_KMEM_CACHE_T)
101 init_once_func(void * foo, kmem_cache_t * cachep, unsigned long flags) {
102 #if defined(SLAB_CTOR_VERIFY)
103 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
104 SLAB_CTOR_CONSTRUCTOR)
108 #elif defined(KMEM_CACHE_INIT)
110 init_once_func(struct kmem_cache * cachep, void * foo) {
113 #elif !defined(KMEM_CACHE_CTOR_TAKES_VOID)
115 init_once_func(void * foo, struct kmem_cache * cachep, unsigned long flags) {
116 #if defined(SLAB_CTOR_VERIFY)
117 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
118 SLAB_CTOR_CONSTRUCTOR)
124 init_once_func(void * foo) {
129 #ifndef SLAB_RECLAIM_ACCOUNT
130 #define SLAB_RECLAIM_ACCOUNT 0
133 #if defined(SLAB_KERNEL)
134 #define KALLOC_TYPE SLAB_KERNEL
136 #define KALLOC_TYPE GFP_KERNEL