From 2ce909bfc5c2dd71172ab9220927bc41b070e01e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 9 Nov 2018 05:28:26 +0000 Subject: [PATCH] Merge r7779:7801 from trunk git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.3.x@7802 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- Makefile | 10 ++++--- nightly/conf/nightly.conf | 11 ++++---- scripts/generate-kernel-patch | 4 ++- scripts/update-version | 2 +- scst/include/backport.h | 44 ++++++++++++++++++++++++++++++- scst/src/dev_handlers/scst_user.c | 17 ++++++------ scst/src/scst_event.c | 13 ++++----- scst/src/scst_main.c | 11 ++++++-- 8 files changed, 85 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index f34290161..377516aea 100644 --- a/Makefile +++ b/Makefile @@ -483,11 +483,15 @@ debian/changelog: debian/changelog.in sed 's/%{scst_version}/$(VERSION)-$(DEBIAN_REVISION)/' \ debian/changelog +../scst_$(VERSION).orig.tar.gz: debian/changelog Makefile + $(call make-scst-dist,z,gz,$(VERSION),cat) && \ + mv "scst-$(VERSION).tar.gz" "$@" + ../scst_$(VERSION).orig.tar.xz: debian/changelog Makefile $(call make-scst-dist,J,xz,$(VERSION),cat) && \ mv "scst-$(VERSION).tar.xz" "$@" -dpkg: ../scst_$(VERSION).orig.tar.xz +dpkg: ../scst_$(VERSION).orig.tar.gz @if [ -z "$$DEBEMAIL" ]; then \ echo "Error: \$$DEBEMAIL has not been set"; \ false; \ @@ -501,7 +505,7 @@ dpkg: ../scst_$(VERSION).orig.tar.xz output_files=( \ ../*_$(VERSION)-$(DEBIAN_REVISION)_*.deb \ ../*_$(VERSION)-$(DEBIAN_REVISION)_*.ddeb \ - ../scst_$(VERSION)-$(DEBIAN_REVISION).debian.tar.xz \ + ../scst_$(VERSION)-$(DEBIAN_REVISION).debian.tar.[gx]z \ ../scst_$(VERSION)-$(DEBIAN_REVISION).dsc \ ../scst_$(VERSION)-$(DEBIAN_REVISION)_amd64.build \ ../scst_$(VERSION)-$(DEBIAN_REVISION)_amd64.buildinfo \ @@ -524,7 +528,7 @@ dpkg: ../scst_$(VERSION).orig.tar.xz debuild "$${buildopts[@]}" --lintian-opts --profile debian; \ fi && \ mkdir -p dpkg && \ - for f in "$${output_files[@]}" ../scst_$(VERSION).orig.tar.xz; do\ + for f in "$${output_files[@]}" ../scst_$(VERSION).orig.tar.[gx]z; do\ mv $$f dpkg || true; \ done && \ echo "Output files:" && \ diff --git a/nightly/conf/nightly.conf b/nightly/conf/nightly.conf index 17aea84f5..38b260159 100644 --- a/nightly/conf/nightly.conf +++ b/nightly/conf/nightly.conf @@ -3,21 +3,22 @@ ABT_DETAILS="x86_64" ABT_JOBS=5 ABT_KERNELS=" \ -4.18.14 \ +4.19.1 \ +4.18.16-nc \ 4.17.18-nc \ 4.16.18-nc \ 4.15.18-nc \ -4.14.76-nc \ +4.14.78-nc \ 4.13.16-nc \ 4.12.14-nc \ 4.11.12-nc \ 4.10.17-nc \ -4.9.133-nc \ +4.9.135-nc \ 4.8.17-nc \ 4.7.10-nc \ 4.6.7-nc \ 4.5.7-nc \ -4.4.161-nc \ +4.4.162-nc \ 4.3.6-nc \ 4.2.8-nc \ 4.1.52-nc \ @@ -25,7 +26,7 @@ ABT_KERNELS=" \ 3.19.8-nc \ 3.18.124-nc \ 3.17.8-nc \ -3.16.57-nc \ +3.16.60-nc \ 3.15.10-nc \ 3.14.79-nc \ 3.13.11-nc \ diff --git a/scripts/generate-kernel-patch b/scripts/generate-kernel-patch index 2ff3ca1e3..829c9e236 100755 --- a/scripts/generate-kernel-patch +++ b/scripts/generate-kernel-patch @@ -395,7 +395,9 @@ EOF done { - add_file "scst/README_in-tree" "Documentation/scst/README.scst" + if [ -e scst/README_in-tree ]; then + add_file "scst/README_in-tree" "Documentation/scst/README.scst" + fi add_file "scst/SysfsRules" "Documentation/scst/SysfsRules" } | process_patch "scst_11_core_doc.diff" diff --git a/scripts/update-version b/scripts/update-version index a17fe0e06..7735be978 100755 --- a/scripts/update-version +++ b/scripts/update-version @@ -17,7 +17,7 @@ suffix=$4 fv=$major.$minor.$release$suffix reldate=$(date "+%d %B %Y") -sed -i "s,^\(#define[[:blank:]]*\(FT_VERSION\|ISCSI_VERSION_STRING\|Q2T_VERSION_STRING\|SCST_LOCAL_VERSION\|SCST_VERSION_NAME\|DRV_VERSION\|VERSION_STR\)[[:blank:]]*\)\"[^\"]*\",\1\"$major.$minor.$release$suffix\"," scst_local/scst_local.c srpt/src/ib_srpt.c fcst/fcst.h iscsi-scst/include/iscsi_scst_ver.h qla2x00t/qla2x00-target/qla2x00t.h scst/include/scst_const.h +sed -i "s,^\(#define[[:blank:]]*\(FT_VERSION\|ISCSI_VERSION_STRING\|Q2T_VERSION_STRING\|SCST_LOCAL_VERSION\|SCST_VERSION_NAME\|DRV_VERSION\|VERSION_STR\)[[:blank:]]*\)\"[^\"]*\",\1\"$major.$minor.$release$suffix\"," scst_local/scst_local.c srpt/src/ib_srpt.c fcst/fcst.h iscsi-scst/include/iscsi_scst_ver.h qla2x00t/qla2x00-target/qla2x00t.h scst/include/scst_const.h usr/include/version.h sed -i "s,^\(Version[[:blank:]]*\)[^[:blank:]]*\(\),\1$fv\2," doc/scst_user_spec.sgml sed -i "s/^Version .*/Version $fv, $reldate/" iscsi-scst/README qla2x00t/qla2x00-target/README scst/README usr/fileio/README sed -i "s/^\(\(static const char \*scst_local_version_date\|#define[[:blank:]]*DRV_RELDATE\)[[:blank:]]*\)\"[^\"]*\"/\1\"$reldate\"/" scst_local/scst_local.c srpt/src/ib_srpt.c diff --git a/scst/include/backport.h b/scst/include/backport.h index b5929aed0..b0e091486 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -27,6 +27,7 @@ #endif #include /* struct scatterlist */ #include /* kmalloc() */ +#include /* sizeof_field() */ #include #include #include @@ -297,6 +298,34 @@ enum { }; #endif +/* */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0) +/* + * See also commit 65aaf87b3aa2 ("add EPOLLNVAL, annotate EPOLL... and + * event_poll->event"). + */ +typedef unsigned int __poll_t; +#define EPOLLNVAL POLLNVAL +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) +/* + * See also commit 7e040726850a ("eventpoll.h: add missing epoll event masks"). + */ +#define EPOLLIN POLLIN +#define EPOLLPRI POLLPRI +#define EPOLLOUT POLLOUT +#define EPOLLERR POLLERR +#define EPOLLHUP POLLHUP +#define EPOLLRDNORM POLLRDNORM +#define EPOLLRDBAND POLLRDBAND +#define EPOLLWRNORM POLLWRNORM +#define EPOLLWRBAND POLLWRBAND +#define EPOLLMSG POLLMSG +#define EPOLLRDHUP POLLRDHUP +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0) && \ @@ -327,6 +356,11 @@ static inline int vfs_fsync_backport(struct file *file, int datasync) #define vfs_fsync vfs_fsync_backport #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0) +/* See also commit dde0c2e79848 ("fs: add IOCB_SYNC and IOCB_DSYNC") */ +#define IOCB_DSYNC 0 +#endif + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) && \ LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) /* @@ -474,7 +508,9 @@ static inline int __must_check kref_get_unless_zero(struct kref *kref) /* */ /* See also commit 207205a2ba26 */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && \ + (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 6 || \ + RHEL_MAJOR -0 == 6 && RHEL_MINOR -0 < 9) #define kthread_create_on_node(threadfn, data, node, namefmt, arg...)\ kthread_create((threadfn), (data), (namefmt), ##arg) #endif @@ -817,6 +853,12 @@ struct t10_pi_tuple { }; #endif +/* */ + +#ifndef sizeof_field +#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) +#endif + /* */ /* diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 911796c3a..628e1c0b4 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -188,7 +189,7 @@ static int __dev_user_set_opt(struct scst_user_dev *dev, static int dev_user_set_opt(struct file *file, const struct scst_user_opt *opt); static int dev_user_get_opt(struct file *file, void __user *arg); -static unsigned int dev_user_poll(struct file *filp, poll_table *wait); +static __poll_t dev_user_poll(struct file *filp, poll_table *wait); static long dev_user_ioctl(struct file *file, unsigned int cmd, unsigned long arg); static int dev_user_release(struct inode *inode, struct file *file); @@ -2586,23 +2587,23 @@ out: return res; } -static unsigned int dev_user_poll(struct file *file, poll_table *wait) +static __poll_t dev_user_poll(struct file *file, poll_table *wait) { - int res = 0; + __poll_t res; struct scst_user_dev *dev; TRACE_ENTRY(); + res = EPOLLNVAL; dev = file->private_data; - res = dev_user_check_reg(dev); - if (unlikely(res != 0)) + if (unlikely(dev_user_check_reg(dev) != 0)) goto out; spin_lock_irq(&dev->udev_cmd_threads.cmd_list_lock); if (!list_empty(&dev->ready_cmd_list) || !list_empty(&dev->udev_cmd_threads.active_cmd_list)) { - res |= POLLIN | POLLRDNORM; + res = EPOLLIN | EPOLLRDNORM; goto out_unlock; } @@ -2616,7 +2617,7 @@ static unsigned int dev_user_poll(struct file *file, poll_table *wait) if (!list_empty(&dev->ready_cmd_list) || !list_empty(&dev->udev_cmd_threads.active_cmd_list)) { - res |= POLLIN | POLLRDNORM; + res = EPOLLIN | EPOLLRDNORM; goto out_unlock; } @@ -2624,7 +2625,7 @@ out_unlock: spin_unlock_irq(&dev->udev_cmd_threads.cmd_list_lock); out: - TRACE_EXIT_HRES(res); + TRACE_EXIT_HRES((__force unsigned int)res); return res; } diff --git a/scst/src/scst_event.c b/scst/src/scst_event.c index 310ec1073..7e7a7b52b 100644 --- a/scst/src/scst_event.c +++ b/scst/src/scst_event.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -965,9 +966,9 @@ out_unlock: return res; } -static unsigned int scst_event_poll(struct file *file, poll_table *wait) +static __poll_t scst_event_poll(struct file *file, poll_table *wait) { - int res = 0; + __poll_t res = 0; struct scst_event_priv *priv; TRACE_ENTRY(); @@ -977,12 +978,12 @@ static unsigned int scst_event_poll(struct file *file, poll_table *wait) priv = file->private_data; if (unlikely(priv == NULL)) { PRINT_ERROR("At least one allowed event must be set"); - res = -EINVAL; + res = EPOLLNVAL; goto out_unlock; } if (!list_empty(&priv->queued_events_list)) { - res |= POLLIN | POLLRDNORM; + res = EPOLLIN | EPOLLRDNORM; goto out_unlock; } @@ -995,14 +996,14 @@ static unsigned int scst_event_poll(struct file *file, poll_table *wait) mutex_lock(&scst_event_mutex); if (!list_empty(&priv->queued_events_list)) { - res |= POLLIN | POLLRDNORM; + res = EPOLLIN | EPOLLRDNORM; goto out_unlock; } out_unlock: mutex_unlock(&scst_event_mutex); - TRACE_EXIT_HRES(res); + TRACE_EXIT_HRES((__force unsigned int)res); return res; } diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 7660e288a..f604aca6a 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -2579,6 +2579,13 @@ static int __init init_scst(void) (p); \ }) +#define INIT_CACHEP_USERCOPY(p, s, f) ({ \ + (p) = KMEM_CACHE_USERCOPY(s, SCST_SLAB_FLAGS, f); \ + TRACE_MEM("Slab create: %s at %p size %zd", #s, (p), \ + sizeof(struct s)); \ + (p); \ + }) + /* Used for structures with fast path write access */ #define INIT_CACHEP_ALIGN(p, s) ({ \ (p) = KMEM_CACHE(s, SCST_SLAB_FLAGS|SLAB_HWCACHE_ALIGN);\ @@ -2603,12 +2610,12 @@ static int __init init_scst(void) goto out_destroy_mgmt_stub_cache; { struct scst_sense { uint8_t s[SCST_SENSE_BUFFERSIZE]; }; - if (!INIT_CACHEP(scst_sense_cachep, scst_sense)) + if (!INIT_CACHEP_USERCOPY(scst_sense_cachep, scst_sense, s)) goto out_destroy_ua_cache; } if (!INIT_CACHEP(scst_aen_cachep, scst_aen)) /* read-mostly */ goto out_destroy_sense_cache; - if (!INIT_CACHEP_ALIGN_USERCOPY(scst_cmd_cachep, scst_cmd, cdb)) + if (!INIT_CACHEP_ALIGN_USERCOPY(scst_cmd_cachep, scst_cmd, cdb_buf)) goto out_destroy_aen_cache; /* Big enough with read-mostly head and tail */ if (!INIT_CACHEP(scst_sess_cachep, scst_session))