diff options
author | Brian Behlendorf <[email protected]> | 2011-01-10 12:35:22 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2011-01-11 12:14:48 -0800 |
commit | 6bf4d76f4782a13f3ed378d77a0bc17967c3642a (patch) | |
tree | 40cfcdd4731fe98617b298df391f59e14a40e99c | |
parent | b7dc3138375ed4c73f55183371b48db4e6e25d79 (diff) |
Linux Compat: inode->i_mutex/i_sem
Create spl_inode_lock/spl_inode_unlock compability macros to simply
access to the inode mutex/sem. This avoids the need to have to ugly
up the code with the required #define's at every call site. At the
moment the SPL only uses this in one place but higher layers can
benefit from the macro.
-rw-r--r-- | include/linux/file_compat.h | 12 | ||||
-rw-r--r-- | module/spl/spl-vnode.c | 13 |
2 files changed, 14 insertions, 11 deletions
diff --git a/include/linux/file_compat.h b/include/linux/file_compat.h index 77d5a27c3..0bef014ab 100644 --- a/include/linux/file_compat.h +++ b/include/linux/file_compat.h @@ -51,11 +51,21 @@ spl_filp_open(const char *name, int flags, int mode, int *err) #define spl_filp_write(fp, b, s, p) (fp)->f_op->write((fp), (b), (s), p) #ifdef HAVE_3ARGS_FILE_FSYNC -#define spl_filp_fsync(fp, sync) (fp)->f_op->fsync((fp), \ +#define spl_filp_fsync(fp, sync) (fp)->f_op->fsync((fp), \ (fp)->f_dentry, sync) #else #define spl_filp_fsync(fp, sync) (fp)->f_op->fsync((fp), sync) #endif +#ifdef HAVE_INODE_I_MUTEX +#define spl_inode_lock(ip) (mutex_lock(&(ip)->i_mutex)) +#define spl_inode_lock_nested(ip, type) (mutex_lock_nested((&(ip)->i_mutex), \ + (type))) +#define spl_inode_unlock(ip) (mutex_unlock(&(ip)->i_mutex)) +#else +#define spl_inode_lock(ip) (down(&(ip)->i_sem)) +#define spl_inode_unlock(ip) (up(&(ip)->i_sem)) +#endif /* HAVE_INODE_I_MUTEX */ + #endif /* SPL_FILE_COMPAT_H */ diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c index 5c64f05fb..1847c7794 100644 --- a/module/spl/spl-vnode.c +++ b/module/spl/spl-vnode.c @@ -295,11 +295,7 @@ vn_remove(const char *path, uio_seg_t seg, int flags) if (nd.last_type != LAST_NORM) SGOTO(exit1, rc); -#ifdef HAVE_INODE_I_MUTEX - mutex_lock_nested(&nd.nd_dentry->d_inode->i_mutex, I_MUTEX_PARENT); -#else - down(&nd.nd_dentry->d_inode->i_sem); -#endif /* HAVE_INODE_I_MUTEX */ + spl_inode_lock_nested(nd.nd_dentry->d_inode, I_MUTEX_PARENT); dentry = vn_lookup_hash(&nd); rc = PTR_ERR(dentry); if (!IS_ERR(dentry)) { @@ -318,11 +314,8 @@ vn_remove(const char *path, uio_seg_t seg, int flags) exit2: dput(dentry); } -#ifdef HAVE_INODE_I_MUTEX - mutex_unlock(&nd.nd_dentry->d_inode->i_mutex); -#else - up(&nd.nd_dentry->d_inode->i_sem); -#endif /* HAVE_INODE_I_MUTEX */ + + spl_inode_unlock(nd.nd_dentry->d_inode); if (inode) iput(inode); /* truncate the inode here */ exit1: |