From f38911bc6a0e472e43b901bcb8ab74fc36c4e1e1 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Tue, 23 Aug 2016 20:59:19 -0400 Subject: [PATCH] LU-8025 llite: make vvp_io_write_start lockless for newer kernels 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 Signed-off-by: Ben Evans Reviewed-on: http://review.whamcloud.com/19840 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Patrick Farrell Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 17 +++++++++++++++++ lustre/llite/llite_internal.h | 13 ++++++++++++- lustre/llite/vvp_io.c | 10 +++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index f47d26c..77e0059 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1377,6 +1377,22 @@ 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 +],[ + 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 @@ -2288,6 +2304,7 @@ AC_DEFUN([LC_PROG_LINUX], [ # 3.9 LC_HAVE_HLIST_FOR_EACH_3ARG LC_HAVE_BIO_END_SECTOR + LC_HAVE_IS_SXID # 3.10 LC_BLKDEV_RELEASE_RETURN_INT diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 655eb9c..b87da82 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -1449,6 +1449,17 @@ static inline void iov_iter_truncate(struct iov_iter *i, u64 count) } #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) { @@ -1497,7 +1508,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) } 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; diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 625cb82..2f10ea7 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -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. */ - 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; -- 1.8.3.1