mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 05:27:44 +00:00
Linux 4.5: don't access i_mutex directly
Linux commit 5955102c, in preparation for future work, introduced wrapper functions to lock/unlock inode mutexes. This is to prepare for converting it to a read-write semaphore, so that lookup can be done with only the shared lock held. Adopt the afs_linux_*lock_inode() functions accordingly, and convert afs_linux_fsync() to using those wrappers, since the FOP_FSYNC_TAKES_RANGE case appears to be the current case. Amusingly, afs_linux_*lock_inode() already have a branch to handle the case when inode serialization is protected by a semaphore; it seems that this is going to come full-circle. Change-Id: Ia5a194acc559de21808655ef066151a0a3826364 Reviewed-on: https://gerrit.openafs.org/12268 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Joe Gorse <jhgorse@gmail.com> Tested-by: Joe Gorse <jhgorse@gmail.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
This commit is contained in:
parent
2ef27ea1bb
commit
360f4ef53c
@ -1098,6 +1098,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
|
|||||||
AC_CHECK_LINUX_FUNC([inode_nohighmem],
|
AC_CHECK_LINUX_FUNC([inode_nohighmem],
|
||||||
[#include <linux/fs.h>],
|
[#include <linux/fs.h>],
|
||||||
[inode_nohighmem(NULL);])
|
[inode_nohighmem(NULL);])
|
||||||
|
AC_CHECK_LINUX_FUNC([inode_lock],
|
||||||
|
[#include <linux/fs.h>],
|
||||||
|
[inode_lock(NULL);])
|
||||||
|
|
||||||
dnl Consequences - things which get set as a result of the
|
dnl Consequences - things which get set as a result of the
|
||||||
dnl above tests
|
dnl above tests
|
||||||
|
@ -445,7 +445,9 @@ afs_init_sb_export_ops(struct super_block *sb) {
|
|||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
afs_linux_lock_inode(struct inode *ip) {
|
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);
|
mutex_lock(&ip->i_mutex);
|
||||||
#else
|
#else
|
||||||
down(&ip->i_sem);
|
down(&ip->i_sem);
|
||||||
@ -454,7 +456,9 @@ afs_linux_lock_inode(struct inode *ip) {
|
|||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
afs_linux_unlock_inode(struct inode *ip) {
|
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);
|
mutex_unlock(&ip->i_mutex);
|
||||||
#else
|
#else
|
||||||
up(&ip->i_sem);
|
up(&ip->i_sem);
|
||||||
|
@ -583,13 +583,13 @@ afs_linux_fsync(struct file *fp, int datasync)
|
|||||||
cred_t *credp = crref();
|
cred_t *credp = crref();
|
||||||
|
|
||||||
#if defined(FOP_FSYNC_TAKES_RANGE)
|
#if defined(FOP_FSYNC_TAKES_RANGE)
|
||||||
mutex_lock(&ip->i_mutex);
|
afs_linux_lock_inode(ip);
|
||||||
#endif
|
#endif
|
||||||
AFS_GLOCK();
|
AFS_GLOCK();
|
||||||
code = afs_fsync(VTOAFS(ip), credp);
|
code = afs_fsync(VTOAFS(ip), credp);
|
||||||
AFS_GUNLOCK();
|
AFS_GUNLOCK();
|
||||||
#if defined(FOP_FSYNC_TAKES_RANGE)
|
#if defined(FOP_FSYNC_TAKES_RANGE)
|
||||||
mutex_unlock(&ip->i_mutex);
|
afs_linux_unlock_inode(ip);
|
||||||
#endif
|
#endif
|
||||||
crfree(credp);
|
crfree(credp);
|
||||||
return afs_convert_code(code);
|
return afs_convert_code(code);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user