From fece5616507da3ac1f2489e95f5a4bbf86896cd4 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Thu, 3 Dec 2020 08:09:54 +0000 Subject: [PATCH] import kmod-redhat-oracleasm-2.0.8-5.el8 --- .gitignore | 1 + .kmod-redhat-oracleasm.metadata | 1 + SOURCES/0000-Makefile-config-opts.patch | 9 + ...-make-bio_for_each_segment_all-worki.patch | 30 +++ ...cleasm-copy-rhel8-s-bio_map_user_iov.patch | 130 ++++++++++ SPECS/kmod-redhat-oracleasm.spec | 232 ++++++++++++++++++ 6 files changed, 403 insertions(+) create mode 100644 .gitignore create mode 100644 .kmod-redhat-oracleasm.metadata create mode 100644 SOURCES/0000-Makefile-config-opts.patch create mode 100644 SOURCES/0002-oracleasm-driver-make-bio_for_each_segment_all-worki.patch create mode 100644 SOURCES/0003-oracleasm-copy-rhel8-s-bio_map_user_iov.patch create mode 100644 SPECS/kmod-redhat-oracleasm.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cfc0f71 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/oracleasm-redhat-2.0.8.tar.bz2 diff --git a/.kmod-redhat-oracleasm.metadata b/.kmod-redhat-oracleasm.metadata new file mode 100644 index 0000000..cf0a1a0 --- /dev/null +++ b/.kmod-redhat-oracleasm.metadata @@ -0,0 +1 @@ +3f7008b7f30674a0078edda3e8d32941578dae21 SOURCES/oracleasm-redhat-2.0.8.tar.bz2 diff --git a/SOURCES/0000-Makefile-config-opts.patch b/SOURCES/0000-Makefile-config-opts.patch new file mode 100644 index 0000000..e911cc6 --- /dev/null +++ b/SOURCES/0000-Makefile-config-opts.patch @@ -0,0 +1,9 @@ +Index: src/drivers/block/oracleasm/Makefile +=================================================================== +--- src.orig/drivers/block/oracleasm/Makefile 2019-02-07 00:10:13.442236591 +0100 ++++ src/drivers/block/oracleasm/Makefile 2019-02-07 00:30:59.117388865 +0100 +@@ -1,3 +1,4 @@ ++CONFIG_ORACLEASM = m + + obj-$(CONFIG_ORACLEASM) := oracleasm.o + oracleasm-y += driver.o transaction_file.o diff --git a/SOURCES/0002-oracleasm-driver-make-bio_for_each_segment_all-worki.patch b/SOURCES/0002-oracleasm-driver-make-bio_for_each_segment_all-worki.patch new file mode 100644 index 0000000..57c46f7 --- /dev/null +++ b/SOURCES/0002-oracleasm-driver-make-bio_for_each_segment_all-worki.patch @@ -0,0 +1,30 @@ +From 7035e448d799d95a70a0231c53b03e3e82c242ea Mon Sep 17 00:00:00 2001 +From: Ming Lei +Date: Wed, 16 Sep 2020 12:09:01 +0800 +Subject: [PATCH 2/3] oracleasm: driver: make bio_for_each_segment_all working + on rhel8 + +Signed-off-by: Ming Lei +--- + drivers/block/oracleasm/driver.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/block/oracleasm/driver.c b/drivers/block/oracleasm/driver.c +index 7844036..756d3f9 100644 +--- a/drivers/block/oracleasm/driver.c ++++ b/drivers/block/oracleasm/driver.c +@@ -145,9 +145,9 @@ static inline unsigned int asm_block_size(struct block_device *bdev) + void asm_bio_unmap(struct bio *bio) + { + struct bio_vec *bvec; +- struct bvec_iter_all iter_all; ++ int i; + +- bio_for_each_segment_all(bvec, bio, iter_all) { ++ bio_for_each_segment_all(bvec, bio, i) { + if (bio_data_dir(bio) == READ) + set_page_dirty_lock(bvec->bv_page); + +-- +2.13.6 + diff --git a/SOURCES/0003-oracleasm-copy-rhel8-s-bio_map_user_iov.patch b/SOURCES/0003-oracleasm-copy-rhel8-s-bio_map_user_iov.patch new file mode 100644 index 0000000..8539952 --- /dev/null +++ b/SOURCES/0003-oracleasm-copy-rhel8-s-bio_map_user_iov.patch @@ -0,0 +1,130 @@ +From 29ee0198fc5acc9647f8d9a97f0e07bb8a278aa7 Mon Sep 17 00:00:00 2001 +From: Ming Lei +Date: Wed, 16 Sep 2020 11:08:42 +0800 +Subject: [PATCH 3/3] oracleasm: copy rhel8's bio_map_user_iov + +Signed-off-by: Ming Lei +--- + drivers/block/oracleasm/driver.c | 99 +++++++++++++++++++++++++++++++++++++++- + 1 file changed, 98 insertions(+), 1 deletion(-) + +diff --git a/drivers/block/oracleasm/driver.c b/drivers/block/oracleasm/driver.c +index 756d3f9..c726726 100644 +--- a/drivers/block/oracleasm/driver.c ++++ b/drivers/block/oracleasm/driver.c +@@ -1124,6 +1124,103 @@ static void asm_end_bio_io(struct bio *bio) + } + } /* asm_end_bio_io() */ + ++/** ++ * asm_bio_map_user_iov - map user iovec into bio ++ * @q: the struct request_queue for the bio ++ * @iter: iovec iterator ++ * @gfp_mask: memory allocation flags ++ * ++ * Map the user space address into a bio suitable for io to a block ++ * device. Returns an error pointer in case of error. ++ */ ++static struct bio *asm_bio_map_user_iov(struct request_queue *q, ++ struct iov_iter *iter, ++ gfp_t gfp_mask) ++{ ++ int j; ++ struct bio *bio; ++ int ret; ++ struct bio_vec *bvec; ++ ++ if (!iov_iter_count(iter)) ++ return ERR_PTR(-EINVAL); ++ ++ bio = bio_kmalloc(gfp_mask, iov_iter_npages(iter, BIO_MAX_PAGES)); ++ if (!bio) ++ return ERR_PTR(-ENOMEM); ++ ++ while (iov_iter_count(iter)) { ++ struct page **pages; ++ ssize_t bytes; ++ size_t offs, added = 0; ++ int npages; ++ ++ bytes = iov_iter_get_pages_alloc(iter, &pages, LONG_MAX, &offs); ++ if (unlikely(bytes <= 0)) { ++ ret = bytes ? bytes : -EFAULT; ++ goto out_unmap; ++ } ++ ++ npages = DIV_ROUND_UP(offs + bytes, PAGE_SIZE); ++ ++ if (unlikely(offs & queue_dma_alignment(q))) { ++ ret = -EINVAL; ++ j = 0; ++ } else { ++ for (j = 0; j < npages; j++) { ++ struct page *page = pages[j]; ++ unsigned int n = PAGE_SIZE - offs; ++ unsigned short prev_bi_vcnt = bio->bi_vcnt; ++ ++ if (n > bytes) ++ n = bytes; ++ ++ if (!bio_add_pc_page(q, bio, page, n, offs)) ++ break; ++ ++ /* ++ * check if vector was merged with previous ++ * drop page reference if needed ++ */ ++ if (bio->bi_vcnt == prev_bi_vcnt) ++ put_page(page); ++ ++ added += n; ++ bytes -= n; ++ offs = 0; ++ } ++ iov_iter_advance(iter, added); ++ } ++ /* ++ * release the pages we didn't map into the bio, if any ++ */ ++ while (j < npages) ++ put_page(pages[j++]); ++ kvfree(pages); ++ /* couldn't stuff something into bio? */ ++ if (bytes) ++ break; ++ } ++ ++ bio_set_flag(bio, BIO_USER_MAPPED); ++ ++ /* ++ * subtle -- if asm_bio_map_user_iov() ended up bouncing a bio, ++ * it would normally disappear when its bi_end_io is run. ++ * however, we need it for the unmap, so grab an extra ++ * reference to it ++ */ ++ bio_get(bio); ++ return bio; ++ ++ out_unmap: ++ bio_for_each_segment_all(bvec, bio, j) { ++ put_page(bvec->bv_page); ++ } ++ bio_put(bio); ++ return ERR_PTR(ret); ++} ++ + static int asm_submit_io(struct file *file, + asm_ioc __user *user_iocp, + asm_ioc *ioc) +@@ -1247,7 +1344,7 @@ static int asm_submit_io(struct file *file, + iov.iov_base = (void __user *)ioc->buffer_asm_ioc; + iov.iov_len = r->r_count; + iov_iter_init(&iter, rw, &iov, 1, r->r_count); +- r->r_bio = bio_map_user_iov(bdev_get_queue(bdev), &iter, GFP_KERNEL); ++ r->r_bio = asm_bio_map_user_iov(bdev_get_queue(bdev), &iter, GFP_KERNEL); + + if (IS_ERR(r->r_bio)) { + ret = PTR_ERR(r->r_bio); +-- +2.13.6 + diff --git a/SPECS/kmod-redhat-oracleasm.spec b/SPECS/kmod-redhat-oracleasm.spec new file mode 100644 index 0000000..8466bd0 --- /dev/null +++ b/SPECS/kmod-redhat-oracleasm.spec @@ -0,0 +1,232 @@ +%define kmod_name oracleasm +%define kmod_vendor redhat +%define kmod_rpm_name kmod-redhat-oracleasm +%define kmod_driver_version 2.0.8 +%define kmod_driver_epoch 8 +%define kmod_rpm_release 5 +%define kmod_kernel_version 4.18.0-254.el8 +%define kmod_kernel_version_min 4.18.0-254.el8 +%define kmod_kernel_version_dep 4.18.0 +%define kmod_kbuild_dir drivers/block/oracleasm +%define kmod_install_path extra/kmod-redhat-oracleasm +%define kernel_pkg kernel +%define kernel_devel_pkg kernel-devel +%define kernel_modules_pkg kernel-modules + +%{!?dist: %define dist .el8_4} +%{!?make_build: %define make_build make} + +%if "%{kmod_kernel_version_dep}" == "" +%define kmod_kernel_version_dep %{kmod_kernel_version} +%endif + + +Source0: %{kmod_name}-%{kmod_vendor}-%{kmod_driver_version}.tar.bz2 +# Source code patches +Patch0: 0000-Makefile-config-opts.patch +#Patch1: 0001-oracleasm-driver-replace-fs_context-with-mount_pseud.patch +Patch2: 0002-oracleasm-driver-make-bio_for_each_segment_all-worki.patch +Patch3: 0003-oracleasm-copy-rhel8-s-bio_map_user_iov.patch + +%define findpat %( echo "%""P" ) +%define __find_requires /usr/lib/rpm/redhat/find-requires.ksyms +%define __find_provides /usr/lib/rpm/redhat/find-provides.ksyms %{kmod_name} %{?epoch:%{epoch}:}%{version}-%{release} +%define sbindir %( if [ -d "/sbin" -a \! -h "/sbin" ]; then echo "/sbin"; else echo %{_sbindir}; fi ) +%define dup_state_dir %{_localstatedir}/lib/rpm-state/kmod-dups +%define kver_state_dir %{dup_state_dir}/kver +%define kver_state_file %{kver_state_dir}/%{kmod_kernel_version}.%(arch) +%define dup_module_list %{dup_state_dir}/rpm-kmod-%{kmod_name}-modules + +Name: kmod-redhat-oracleasm +Version: %{kmod_driver_version} +Release: %{kmod_rpm_release}%{?dist} +%if "%{kmod_driver_epoch}" != "" +Epoch: %{kmod_driver_epoch} +%endif +Summary: oracleasm kernel module +Group: System/Kernel +License: GPLv2 +URL: https://github.com/oracle/linux-uek/tree/uek6/master/drivers/block/oracleasm +BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) +BuildRequires: %kernel_devel_pkg = %kmod_kernel_version +BuildRequires: redhat-rpm-config kernel-abi-whitelists elfutils-libelf-devel kernel-rpm-macros kmod +ExclusiveArch: x86_64 +%global kernel_source() /usr/src/kernels/%{kmod_kernel_version}.$(arch) + +%global _use_internal_dependency_generator 0 +Provides: %kernel_modules_pkg >= %{kmod_kernel_version_min}.%{_target_cpu} +Provides: kmod-%{kmod_name} = %{?epoch:%{epoch}:}%{version}-%{release} +Provides: %{kmod_name} = %{?epoch:%{epoch}:}%{version}-%{release} +Provides: %{kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release} +Requires(post): %{sbindir}/weak-modules +Requires(postun): %{sbindir}/weak-modules +Requires: kernel >= 4.18.0-240.el8 +# if there are multiple kmods for the same driver from different vendors, +# they should conflict with each other. +Conflicts: kmod-%{kmod_name} + +%description +oracleasm kernel module + +%post +modules=( $(find /lib/modules/%{kmod_kernel_version}.%(arch)/%{kmod_install_path} | grep '\.ko$') ) +printf '%s\n' "${modules[@]}" | %{sbindir}/weak-modules --add-modules --no-initramfs + +mkdir -p "%{kver_state_dir}" +touch "%{kver_state_file}" + +exit 0 + +%posttrans +# We have to re-implement part of weak-modules here because it doesn't allow +# calling initramfs regeneration separately +if [ -f "%{kver_state_file}" ]; then + kver_base="%{kmod_kernel_version_dep}" + kvers=$(ls -d "/lib/modules/${kver_base%%.*}"*) + + for k_dir in $kvers; do + k="${k_dir#/lib/modules/}" + + tmp_initramfs="/boot/initramfs-$k.tmp" + dst_initramfs="/boot/initramfs-$k.img" + + # The same check as in weak-modules: we assume that the kernel present + # if the symvers file exists. + if [ -e "/boot/symvers-$k.gz" ]; then + /usr/bin/dracut -f "$tmp_initramfs" "$k" || exit 1 + cmp -s "$tmp_initramfs" "$dst_initramfs" + if [ "$?" = 1 ]; then + mv "$tmp_initramfs" "$dst_initramfs" + else + rm -f "$tmp_initramfs" + fi + fi + done + + rm -f "%{kver_state_file}" + rmdir "%{kver_state_dir}" 2> /dev/null +fi + +rmdir "%{dup_state_dir}" 2> /dev/null + +exit 0 + +%preun +if rpm -q --filetriggers kmod 2> /dev/null| grep -q "Trigger for weak-modules call on kmod removal"; then + mkdir -p "%{kver_state_dir}" + touch "%{kver_state_file}" +fi + +mkdir -p "%{dup_state_dir}" +rpm -ql kmod-redhat-oracleasm-%{kmod_driver_version}-%{kmod_rpm_release}%{?dist}.$(arch) | \ + grep '\.ko$' > "%{dup_module_list}" + +%postun +if rpm -q --filetriggers kmod 2> /dev/null| grep -q "Trigger for weak-modules call on kmod removal"; then + initramfs_opt="--no-initramfs" +else + initramfs_opt="" +fi + +modules=( $(cat "%{dup_module_list}") ) +rm -f "%{dup_module_list}" +printf '%s\n' "${modules[@]}" | %{sbindir}/weak-modules --remove-modules $initramfs_opt + +rmdir "%{dup_state_dir}" 2> /dev/null + +exit 0 + +%files +%defattr(644,root,root,755) +/lib/modules/%{kmod_kernel_version}.%(arch) +/etc/depmod.d/%{kmod_name}.conf +%doc /usr/share/doc/%{kmod_rpm_name}/greylist.txt + + + +%prep +%setup -n %{kmod_name}-%{kmod_vendor}-%{kmod_driver_version} + +%patch0 -p1 +#%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +set -- * +mkdir source +mv "$@" source/ +mkdir obj + +%build +rm -rf obj +cp -r source obj + +PWD_PATH="$PWD" +%if "%{workaround_no_pwd_rel_path}" != "1" +PWD_PATH=$(realpath --relative-to="%{kernel_source}" . 2>/dev/null || echo "$PWD") +%endif +%{make_build} -C %{kernel_source} V=1 M="$PWD_PATH/obj/%{kmod_kbuild_dir}" \ + NOSTDINC_FLAGS="-I$PWD_PATH/obj/include -I$PWD_PATH/obj/include/uapi %{nil}" \ + EXTRA_CFLAGS="%{nil}" \ + %{nil} +# mark modules executable so that strip-to-file can strip them +find obj/%{kmod_kbuild_dir} -name "*.ko" -type f -exec chmod u+x '{}' + + +whitelist="/lib/modules/kabi-current/kabi_whitelist_%{_target_cpu}" +for modules in $( find obj/%{kmod_kbuild_dir} -name "*.ko" -type f -printf "%{findpat}\n" | sed 's|\.ko$||' | sort -u ) ; do + # update depmod.conf + module_weak_path=$(echo "$modules" | sed 's/[\/]*[^\/]*$//') + if [ -z "$module_weak_path" ]; then + module_weak_path=%{name} + else + module_weak_path=%{name}/$module_weak_path + fi + echo "override $(echo $modules | sed 's/.*\///')" \ + "$(echo "%{kmod_kernel_version_dep}" | + sed 's/\.[^\.]*$//; + s/\([.+?^$\/\\|()\[]\|\]\)/\\\0/g').*" \ + "weak-updates/$module_weak_path" >> source/depmod.conf + + # update greylist + nm -u obj/%{kmod_kbuild_dir}/$modules.ko | sed 's/.*U //' | sed 's/^\.//' | sort -u | while read -r symbol; do + grep -q "^\s*$symbol\$" $whitelist || echo "$symbol" >> source/greylist + done +done +sort -u source/greylist | uniq > source/greylist.txt + +%install +export INSTALL_MOD_PATH=$RPM_BUILD_ROOT +export INSTALL_MOD_DIR=%{kmod_install_path} +PWD_PATH="$PWD" +%if "%{workaround_no_pwd_rel_path}" != "1" +PWD_PATH=$(realpath --relative-to="%{kernel_source}" . 2>/dev/null || echo "$PWD") +%endif +make -C %{kernel_source} modules_install \ + M=$PWD_PATH/obj/%{kmod_kbuild_dir} +# Cleanup unnecessary kernel-generated module dependency files. +find $INSTALL_MOD_PATH/lib/modules -iname 'modules.*' -exec rm {} \; + +install -m 644 -D source/depmod.conf $RPM_BUILD_ROOT/etc/depmod.d/%{kmod_name}.conf +install -m 644 -D source/greylist.txt $RPM_BUILD_ROOT/usr/share/doc/%{kmod_rpm_name}/greylist.txt + + +%clean +rm -rf $RPM_BUILD_ROOT + +%changelog +* Fri Nov 27 2020 Eugene Syromiatnikov 2.0.8-5 +- Rebuild against kernel-4.18.0-254.el8. + +* Sat Nov 21 2020 Eugene Syromiatnikov 2.0.8-4 +- Rebuild against kernel-4.18.0-252.el8. + +* Fri Oct 30 2020 Eugene Syromiatnikov 2.0.8-3 +- Add "Provides: oracleasm" and "Provides: oracleasm-kmod". +- Dropping "0001-oracleasm-driver-replace-fs_context-with-mount_pseud.patch". + +* Thu Oct 22 2020 Eugene Syromiatnikov 2.0.8-2 +- Revision bump due to brew NVR conflict. + +* Mon Oct 19 2020 Eugene Syromiatnikov 2.0.8-1 +- 19e841b848491d1e14dcd0063d8d681ed1190255 +- oracleasm kernel module +- Resolves: #1827015