X-Git-Url: http://git.openafs.org/?p=openafs.git;a=blobdiff_plain;f=src%2Fafs%2FLINUX%2Fosi_compat.h;h=d236081431d613999fc6222344785245329fb97a;hp=5b3f12b8d8189d2d0d8773d6bbe8900a9729abc2;hb=02d82275c17284d04629282aa374bb39f511c989;hpb=58d82226a555d3781a5cb45e5cc177727628ebd8 diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h index 5b3f12b..d236081 100644 --- a/src/afs/LINUX/osi_compat.h +++ b/src/afs/LINUX/osi_compat.h @@ -47,6 +47,10 @@ typedef struct path afs_linux_path_t; # endif #endif +#ifndef HAVE_LINUX_FILE_DENTRY +#define file_dentry(file) ((file)->f_dentry) +#endif + #if defined(HAVE_LINUX_LOCKS_LOCK_FILE_WAIT) # define flock_lock_file_wait locks_lock_file_wait #endif @@ -190,7 +194,9 @@ static inline struct key * afs_linux_key_alloc(struct key_type *type, const char *desc, afs_kuid_t uid, afs_kgid_t gid, key_perm_t perm, unsigned long flags) { -# if defined(KEY_ALLOC_NEEDS_STRUCT_TASK) +# if defined(KEY_ALLOC_BYPASS_RESTRICTION) + return key_alloc(type, desc, uid, gid, current_cred(), perm, flags, NULL); +# elif defined(KEY_ALLOC_NEEDS_STRUCT_TASK) return key_alloc(type, desc, uid, gid, current, perm, flags); # elif defined(KEY_ALLOC_NEEDS_CRED) return key_alloc(type, desc, uid, gid, current_cred(), perm, flags); @@ -216,9 +222,15 @@ afs_linux_search_keyring(afs_ucred_t *cred, struct key_type *type) key_ref_t key_ref; if (afs_session_keyring(cred)) { +# if defined(KEYRING_SEARCH_TAKES_RECURSE) + key_ref = keyring_search( + make_key_ref(afs_session_keyring(cred), 1), + type, "_pag", 1); +# else key_ref = keyring_search( make_key_ref(afs_session_keyring(cred), 1), type, "_pag"); +# endif if (IS_ERR(key_ref)) return ERR_CAST(key_ref); @@ -274,7 +286,7 @@ afs_linux_cred_is_current(afs_ucred_t *cred) static inline loff_t page_offset(struct page *pp) { - return (((loff_t) pp->index) << PAGE_CACHE_SHIFT); + return (((loff_t) pp->index) << PAGE_SHIFT); } #endif @@ -445,7 +457,9 @@ afs_init_sb_export_ops(struct super_block *sb) { static inline void afs_linux_lock_inode(struct inode *ip) { -#ifdef STRUCT_INODE_HAS_I_MUTEX +#if defined(HAVE_LINUX_INODE_LOCK) + inode_lock(ip); +#elif defined(STRUCT_INODE_HAS_I_MUTEX) mutex_lock(&ip->i_mutex); #else down(&ip->i_sem); @@ -454,13 +468,42 @@ afs_linux_lock_inode(struct inode *ip) { static inline void afs_linux_unlock_inode(struct inode *ip) { -#ifdef STRUCT_INODE_HAS_I_MUTEX +#if defined(HAVE_LINUX_INODE_LOCK) + inode_unlock(ip); +#elif defined(STRUCT_INODE_HAS_I_MUTEX) mutex_unlock(&ip->i_mutex); #else up(&ip->i_sem); #endif } +/* Use these to lock or unlock an inode for processing + * its dentry aliases en masse. + */ +#if defined(HAVE_DCACHE_LOCK) +#define afs_d_alias_lock(ip) spin_lock(&dcache_lock) +#define afs_d_alias_unlock(ip) spin_unlock(&dcache_lock) +#else +#define afs_d_alias_lock(ip) spin_lock(&(ip)->i_lock) +#define afs_d_alias_unlock(ip) spin_unlock(&(ip)->i_lock) +#endif + + +/* Use this instead of dget for dentry operations + * that occur under a higher lock (e.g. alias processing). + * Requires that the higher lock (e.g. dcache_lock or + * inode->i_lock) is already held. + */ +static inline void +afs_linux_dget(struct dentry *dp) { +#if defined(HAVE_DCACHE_LOCK) + dget_locked(dp); +#else + dget(dp); +#endif +} + + static inline int afs_inode_setattr(struct osi_file *afile, struct iattr *newattrs) { @@ -635,11 +678,25 @@ afs_d_invalidate(struct dentry *dp) #endif } +#if defined(HAVE_LINUX___VFS_WRITE) +# define AFS_FILE_NEEDS_SET_FS 1 +#elif defined(HAVE_LINUX_KERNEL_WRITE) +/* #undef AFS_FILE_NEEDS_SET_FS */ +#else +# define AFS_FILE_NEEDS_SET_FS 1 +#endif + static inline int afs_file_read(struct file *filp, char __user *buf, size_t len, loff_t *pos) { -#if defined(HAVE_LINUX___VFS_READ) +#if defined(HAVE_LINUX___VFS_WRITE) return __vfs_read(filp, buf, len, pos); +#elif defined(HAVE_LINUX_KERNEL_WRITE) +# if defined(KERNEL_READ_OFFSET_IS_LAST) + return kernel_read(filp, buf, len, pos); +# else + return kernel_read(filp, *pos, buf, len); +# endif #else return filp->f_op->read(filp, buf, len, pos); #endif @@ -648,8 +705,14 @@ afs_file_read(struct file *filp, char __user *buf, size_t len, loff_t *pos) static inline int afs_file_write(struct file *filp, char __user *buf, size_t len, loff_t *pos) { -#if defined(HAVE_LINUX___VFS_READ) +#if defined(HAVE_LINUX___VFS_WRITE) return __vfs_write(filp, buf, len, pos); +#elif defined(HAVE_LINUX_KERNEL_WRITE) +# if defined(KERNEL_READ_OFFSET_IS_LAST) + return kernel_write(filp, buf, len, pos); +# else + return kernel_write(filp, buf, len, *pos); +# endif #else return filp->f_op->write(filp, buf, len, pos); #endif