Whamcloud - gitweb
LU-8025 llite: make vvp_io_write_start lockless for newer kernels 40/19840/22
authorJames Simmons <uja.ornl@yahoo.com>
Wed, 24 Aug 2016 00:59:19 +0000 (20:59 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 2 Sep 2016 02:22:48 +0000 (02:22 +0000)
When support for newer kernels was backported from the
upstream kernel it lacked any of the enhancements done
for newer version of lustre. This work makes the newer
kernel support lockless writes like the rest of the
lustre llite code.

Change-Id: I6ea32dbb3097aea3e2031e1121e238e549bccc9b
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Signed-off-by: Ben Evans <bevans@cray.com>
Reviewed-on: http://review.whamcloud.com/19840
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Patrick Farrell <paf@cray.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/autoconf/lustre-core.m4
lustre/llite/llite_internal.h
lustre/llite/vvp_io.c

index f47d26c..77e0059 100644 (file)
@@ -1377,6 +1377,22 @@ bio_end_sector, [
 ]) # LC_HAVE_BIO_END_SECTOR
 
 #
 ]) # LC_HAVE_BIO_END_SECTOR
 
 #
+# 3.9 created is_sxid
+#
+AC_DEFUN([LC_HAVE_IS_SXID], [
+LB_CHECK_COMPILE([if 'is_sxid' is defined],
+is_sxid, [
+       #include <linux/fs.h>
+],[
+       struct inode inode;
+
+       is_sxid(inode.i_mode);
+],[
+       AC_DEFINE(HAVE_IS_SXID, 1, [is_sxid is defined])
+])
+]) # LC_HAVE_IS_SXID
+
+#
 # LC_HAVE_REMOVE_PROC_SUBTREE
 #
 # 3.10 introduced remove_proc_subtree
 # LC_HAVE_REMOVE_PROC_SUBTREE
 #
 # 3.10 introduced remove_proc_subtree
@@ -2288,6 +2304,7 @@ AC_DEFUN([LC_PROG_LINUX], [
        # 3.9
        LC_HAVE_HLIST_FOR_EACH_3ARG
        LC_HAVE_BIO_END_SECTOR
        # 3.9
        LC_HAVE_HLIST_FOR_EACH_3ARG
        LC_HAVE_BIO_END_SECTOR
+       LC_HAVE_IS_SXID
 
        # 3.10
        LC_BLKDEV_RELEASE_RETURN_INT
 
        # 3.10
        LC_BLKDEV_RELEASE_RETURN_INT
index 655eb9c..b87da82 100644 (file)
@@ -1449,6 +1449,17 @@ static inline void iov_iter_truncate(struct iov_iter *i, u64 count)
 }
 #endif
 
 }
 #endif
 
+#ifndef HAVE_IS_SXID
+static inline bool is_sxid(umode_t mode)
+{
+       return (mode & S_ISUID) || ((mode & S_ISGID) && (mode & S_IXGRP));
+}
+#endif
+
+#ifndef IS_NOSEC
+#define IS_NOSEC(inode)        (!is_sxid(inode->i_mode))
+#endif
+
 #ifndef HAVE_FILE_OPERATIONS_READ_WRITE_ITER
 static inline void iov_iter_reexpand(struct iov_iter *i, size_t count)
 {
 #ifndef HAVE_FILE_OPERATIONS_READ_WRITE_ITER
 static inline void iov_iter_reexpand(struct iov_iter *i, size_t count)
 {
@@ -1497,7 +1508,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
 }
 
 static inline ssize_t
 }
 
 static inline ssize_t
-generic_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
+__generic_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
 {
        struct iovec iov;
        struct iov_iter i;
 {
        struct iovec iov;
        struct iov_iter i;
index 625cb82..2f10ea7 100644 (file)
@@ -1025,7 +1025,15 @@ static int vvp_io_write_start(const struct lu_env *env,
                 * consistency, proper locking to protect against writes,
                 * trucates, etc. is handled in the higher layers of lustre.
                 */
                 * consistency, proper locking to protect against writes,
                 * trucates, etc. is handled in the higher layers of lustre.
                 */
-               result = generic_file_write_iter(vio->vui_iocb, vio->vui_iter);
+               bool lock_node = !IS_NOSEC(inode);
+
+               if (lock_node)
+                       inode_lock(inode);
+               result = __generic_file_write_iter(vio->vui_iocb,
+                                                  vio->vui_iter);
+               if (lock_node)
+                       inode_unlock(inode);
+
                if (result > 0 || result == -EIOCBQUEUED) {
                        ssize_t err;
 
                if (result > 0 || result == -EIOCBQUEUED) {
                        ssize_t err;