]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Linux 4.5: don't access i_mutex directly
authorBenjamin Kaduk <kaduk@mit.edu>
Sun, 1 May 2016 23:48:40 +0000 (19:48 -0400)
committerStephan Wiesand <stephan.wiesand@desy.de>
Tue, 21 Jun 2016 13:44:56 +0000 (09:44 -0400)
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.

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>
(cherry picked from commit 360f4ef53c454494cd5212a5ea46c658bdb2879c)

Change-Id: I52f29cdb6f0bf85bcbb6624ed62e071b1f3807c9
Reviewed-on: https://gerrit.openafs.org/12302
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>
acinclude.m4
src/afs/LINUX/osi_compat.h
src/afs/LINUX/osi_vnodeops.c

index aca1316846a326202be8323762fef602d26d576f..aa682eae9f61d2deab287fc6401f35d561a05b6a 100644 (file)
@@ -1041,6 +1041,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
                 AC_CHECK_LINUX_FUNC([inode_nohighmem],
                                     [#include <linux/fs.h>],
                                     [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                above tests
index 4d484c17d720ccec89563bc968827167a7c3bd3f..5268e7ebc733ed798d478c885476dd0bfed1cfc9 100644 (file)
@@ -427,7 +427,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);
@@ -436,7 +438,9 @@ 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);
index 00b41ef94a1774ffcef64ac89a6addde90712088..2696b48065bdb2e806a5163a63e500aa86d9b3cc 100644 (file)
@@ -571,13 +571,13 @@ afs_linux_fsync(struct file *fp, int datasync)
     cred_t *credp = crref();
 
 #if defined(FOP_FSYNC_TAKES_RANGE)
-    mutex_lock(&ip->i_mutex);
+    afs_linux_lock_inode(ip);
 #endif
     AFS_GLOCK();
     code = afs_fsync(VTOAFS(ip), credp);
     AFS_GUNLOCK();
 #if defined(FOP_FSYNC_TAKES_RANGE)
-    mutex_unlock(&ip->i_mutex);
+    afs_linux_unlock_inode(ip);
 #endif
     crfree(credp);
     return afs_convert_code(code);