diff options
author | Chunwei Chen <[email protected]> | 2016-05-18 11:28:46 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-05-20 11:00:14 -0700 |
commit | fdbc1ba99d1f4d3958189079eee9b6c957e0264b (patch) | |
tree | dedfad932799dcfed78070207d66e8d231d0854f /include | |
parent | 39cd90ef08bb6817dd57ac08e9de5c87af2681ed (diff) |
Linux 4.7 compat: inode_lock() and friends
Linux 4.7 changes i_mutex to i_rwsem, and we should used inode_lock and
inode_lock_shared to do exclusive and shared lock respectively.
We use spl_inode_lock{,_shared}() to hide the difference. Note that on older
kernel you'll always take an exclusive lock.
We also add all other inode_lock friends. And nested users now should
explicitly call spl_inode_lock_nested with correct subclass.
Signed-off-by: Chunwei Chen <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue zfsonlinux/zfs#4665
Closes #549
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/file_compat.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/include/linux/file_compat.h b/include/linux/file_compat.h index c58bb8156..916514566 100644 --- a/include/linux/file_compat.h +++ b/include/linux/file_compat.h @@ -76,8 +76,25 @@ spl_filp_fallocate(struct file *fp, int mode, loff_t offset, loff_t len) #define spl_filp_fsync(fp, sync) vfs_fsync(fp, (fp)->f_dentry, sync) #endif /* HAVE_2ARGS_VFS_FSYNC */ -#define spl_inode_lock(ip) mutex_lock_nested(&(ip)->i_mutex, I_MUTEX_PARENT) +#ifdef HAVE_INODE_LOCK_SHARED +#define spl_inode_lock(ip) inode_lock(ip) +#define spl_inode_unlock(ip) inode_unlock(ip) +#define spl_inode_lock_shared(ip) inode_lock_shared(ip) +#define spl_inode_unlock_shared(ip) inode_unlock_shared(ip) +#define spl_inode_trylock(ip) inode_trylock(ip) +#define spl_inode_trylock_shared(ip) inode_trylock_shared(ip) +#define spl_inode_is_locked(ip) inode_is_locked(ip) +#define spl_inode_lock_nested(ip, s) inode_lock_nested(ip, s) +#else +#define spl_inode_lock(ip) mutex_lock(&(ip)->i_mutex) #define spl_inode_unlock(ip) mutex_unlock(&(ip)->i_mutex) +#define spl_inode_lock_shared(ip) mutex_lock(&(ip)->i_mutex) +#define spl_inode_unlock_shared(ip) mutex_unlock(&(ip)->i_mutex) +#define spl_inode_trylock(ip) mutex_trylock(&(ip)->i_mutex) +#define spl_inode_trylock_shared(ip) mutex_trylock(&(ip)->i_mutex) +#define spl_inode_is_locked(ip) mutex_is_locked(&(ip)->i_mutex) +#define spl_inode_lock_nested(ip, s) mutex_lock_nested(&(ip)->i_mutex, s) +#endif #endif /* SPL_FILE_COMPAT_H */ |