!137 sync master

From: @wangzengliang1 
Reviewed-by: @liuqinfei 
Signed-off-by: @liuqinfei
This commit is contained in:
wangzengliang 2022-11-17 01:34:55 +00:00 committed by openeuler-ci-bot
parent 582a4eb140
commit 3d00ba56bc
7 changed files with 2247 additions and 6 deletions

View File

@ -0,0 +1,57 @@
From a13d33c47c0e713429f7cfbd6106a497838f6396 Mon Sep 17 00:00:00 2001
From: wangzengliang <wangzengliang1@huawei.com>
Date: Fri, 8 Apr 2022 11:35:38 +0800
Subject: [PATCH] cmake: add support python 3.10
---
cmake/modules/BuildBoost.cmake | 2 +-
cmake/modules/FindPython/Support.cmake | 2 +-
src/boost/libs/python/src/exec.cpp | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/cmake/modules/BuildBoost.cmake b/cmake/modules/BuildBoost.cmake
index 468ae419c..320c2dcd5 100644
--- a/cmake/modules/BuildBoost.cmake
+++ b/cmake/modules/BuildBoost.cmake
@@ -70,7 +70,7 @@ function(do_build_boost version)
if(c MATCHES "^python([0-9])\$")
set(with_python_version "${CMAKE_MATCH_1}")
list(APPEND boost_with_libs "python")
- elseif(c MATCHES "^python([0-9])\\.?([0-9])\$")
+ elseif(c MATCHES "^python([0-9])\\.?([0-9]+)\$")
set(with_python_version "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
list(APPEND boost_with_libs "python")
else()
diff --git a/cmake/modules/FindPython/Support.cmake b/cmake/modules/FindPython/Support.cmake
index c05bbe330..fb362bfe2 100644
--- a/cmake/modules/FindPython/Support.cmake
+++ b/cmake/modules/FindPython/Support.cmake
@@ -17,7 +17,7 @@ if (NOT DEFINED _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
message (FATAL_ERROR "FindPython: INTERNAL ERROR")
endif()
if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL 3)
- set(_${_PYTHON_PREFIX}_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
+ set(_${_PYTHON_PREFIX}_VERSIONS 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
elseif (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL 2)
set(_${_PYTHON_PREFIX}_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
else()
diff --git a/src/boost/libs/python/src/exec.cpp b/src/boost/libs/python/src/exec.cpp
index 171c6f418..caa7d0864 100644
--- a/src/boost/libs/python/src/exec.cpp
+++ b/src/boost/libs/python/src/exec.cpp
@@ -106,10 +106,10 @@ object BOOST_PYTHON_DECL exec_file(char const *filename, object global, object l
char *f = const_cast<char *>(filename);
// Let python open the file to avoid potential binary incompatibilities.
#if PY_VERSION_HEX >= 0x03040000
- FILE *fs = _Py_fopen(f, "r");
+ FILE *fs = fopen(f, "r");
#elif PY_VERSION_HEX >= 0x03000000
PyObject *fo = Py_BuildValue("s", f);
- FILE *fs = _Py_fopen(fo, "r");
+ FILE *fs = fopen(fo, "r");
Py_DECREF(fo);
#else
PyObject *pyfile = PyFile_FromString(f, const_cast<char*>("r"));
--
2.30.0

View File

@ -0,0 +1,40 @@
From 9780d28028a40ecbfc327dab779e8a37c9aaed51 Mon Sep 17 00:00:00 2001
From: Guillaume Abrioux <gabrioux@redhat.com>
Date: Mon, 8 Mar 2021 09:59:26 +0100
Subject: [PATCH] ceph-volume: `get_first_*()` refactor
As indicated by commit 17957d9beb42a04b8f180ccb7ba07d43179a41d3 those
fuctions were meant to avoid writing something like following:
```
lvs = get_lvs()
if len(lvs) >= 1:
lvs = lv[0]
```
Those functions should return `None` if 0 or more than 1 item is returned.
The current name of these functions are confusing and can lead to thinking that
we just want the first item returned, even though it returns more than 1
item, let's rename them to `get_single_pv()`, `get_single_vg()` and
`get_single_lv()`
Closes: https://tracker.ceph.com/issues/49643
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit a5e4216b49704783c55fb83b3ae6dde35b0082ad)
---
src/ceph-volume/ceph_volume/api/lvm.py | 54 +++--
diff --git a/src/ceph-volume/ceph_volume/api/lvm.py b/src/ceph-volume/ceph_volume/api/lvm.py
index e5551206e16..bbafa06831b 100644
--- a/src/ceph-volume/ceph_volume/api/lvm.py
+++ b/src/ceph-volume/ceph_volume/api/lvm.py
@@ -1144,7 +1144,7 @@ def get_lv_by_fullname(full_name):
"""
try:
vg_name, lv_name = full_name.split('/')
- res_lv = get_first_lv(filters={'lv_name': lv_name,
+ res_lv = get_single_lv(filters={'lv_name': lv_name,
'vg_name': vg_name})
except ValueError:
res_lv = None

View File

@ -0,0 +1,66 @@
From 1a38ea3b96dbe8fd2f2fca8ee9a501ef1423027f Mon Sep 17 00:00:00 2001
From: Guillaume Abrioux <gabrioux@redhat.com>
Date: Mon, 20 Jun 2022 13:43:43 +0200
Subject: [PATCH] ceph-volume: decrease number of `pvs` calls in `lvm list`
current implementation of `List.create_report()` implies a lot of calls
to `pvs` process. This could be avoided.
current implementation:
```
>>> import timeit
>>> from ceph_volume.devices.lvm.listing import List
>>> timeit.timeit(List([]).main, number=1000)
...
93.03700458299136
```
new implementation:
```
>>> import timeit
>>> from ceph_volume.devices.lvm.listing import List
>>> timeit.timeit(List([]).main, number=1000)
...
62.16391600697534
```
In this example, it improves performance by ~30%
Fixes: https://tracker.ceph.com/issues/56127
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
---
src/ceph-volume/ceph_volume/devices/lvm/listing.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/ceph-volume/ceph_volume/devices/lvm/listing.py b/src/ceph-volume/ceph_volume/devices/lvm/listing.py
index 44d5063ce37..c16afdaa767 100644
--- a/src/ceph-volume/ceph_volume/devices/lvm/listing.py
+++ b/src/ceph-volume/ceph_volume/devices/lvm/listing.py
@@ -101,6 +101,8 @@ class List(object):
report = {}
+ pvs = api.get_pvs()
+
for lv in lvs:
if not api.is_ceph_device(lv):
continue
@@ -109,8 +111,7 @@ class List(object):
report.setdefault(osd_id, [])
lv_report = lv.as_dict()
- pvs = api.get_pvs(filters={'lv_uuid': lv.lv_uuid})
- lv_report['devices'] = [pv.name for pv in pvs] if pvs else []
+ lv_report['devices'] = [pv.name for pv in pvs if pv.lv_uuid == lv.lv_uuid] if pvs else []
report[osd_id].append(lv_report)
phys_devs = self.create_report_non_lv_device(lv)
--
2.33.0

View File

@ -0,0 +1,43 @@
From 7672ceb4f09c81ee7a2d5e8672e2c402c3206b4e Mon Sep 17 00:00:00 2001
From: luo rixin <luorixin@huawei.com>
Date: Wed, 14 Sep 2022 19:50:01 +0800
Subject: [PATCH] os/bluestore: use direct write in
BlueStore::_write_bdev_label
On AArch64 with kernel page size 64K, it occurs occasionally
"OSD::init(): unable to read osd superblock" when deploying osd.
As bluestore use direct write to write the superblock at 0x2000~1000
and BlueStore::_write_bdev_label use buffer write to write label at
0x0~1000, The OS flush the buffer write algined to page size, it will
overwrite the superblock(0x2000~1000). Use driect write to avoid
overwriting the superblock.
Fixes: https://tracker.ceph.com/issues/57537
Signed-off-by: luo rixin <luorixin@huawei.com>
---
src/os/bluestore/BlueStore.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc
index 8b893be79d1..534fe780f27 100644
--- a/src/os/bluestore/BlueStore.cc
+++ b/src/os/bluestore/BlueStore.cc
@@ -5104,13 +5104,14 @@ int BlueStore::_write_bdev_label(CephContext *cct,
z.zero();
bl.append(std::move(z));
- int fd = TEMP_FAILURE_RETRY(::open(path.c_str(), O_WRONLY|O_CLOEXEC));
+ int fd = TEMP_FAILURE_RETRY(::open(path.c_str(), O_WRONLY|O_CLOEXEC|O_DIRECT));
if (fd < 0) {
fd = -errno;
derr << __func__ << " failed to open " << path << ": " << cpp_strerror(fd)
<< dendl;
return fd;
}
+ bl.rebuild_aligned_size_and_memory(BDEV_LABEL_BLOCK_SIZE, BDEV_LABEL_BLOCK_SIZE, IOV_MAX);
int r = bl.write_fd(fd);
if (r < 0) {
derr << __func__ << " failed to write to " << path
--
2.20.1.windows.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,146 @@
From dc4d69d6d10cf1748bbdf971cd118db334991697 Mon Sep 17 00:00:00 2001
From: Kotresh HR <khiremat@redhat.com>
Date: Sat, 8 Oct 2022 14:56:08 +0800
Subject: [PATCH] fix CVE-2022-0670
Fixes the subvolume discover to use the correct
metadata file after an upgrade from legacy subvolume
to v1. The fix makes sure, it doesn't use the
handcrafted metadata file placed in the subvolume
root of legacy subvolume.
Co-authored-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@cern.ch>
Co-authored-by: Dan van der Ster <daniel.vanderster@cern.ch>
Co-authored-by: Ramana Raja <rraja@redhat.com>
Signed-off-by: Kotresh HR <khiremat@redhat.com>
(cherry picked from commit 7eba9cab6cfb9a13a84062177d7a0fa228311e13)
(cherry picked from commit f8c04135150a7fb3c43607b43a8214e0d57547bc)
Signed-off-by: Kotresh HR <khiremat@redhat.com>
(cherry picked from commit 5bb46ee690591411d4890b613c6380fced9d04b4)
---
.../operations/versions/metadata_manager.py | 17 +++++++++++---
.../fs/operations/versions/subvolume_base.py | 23 +++++++++++++++++--
.../fs/operations/versions/subvolume_v1.py | 2 +-
3 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/src/pybind/mgr/volumes/fs/operations/versions/metadata_manager.py b/src/pybind/mgr/volumes/fs/operations/versions/metadata_manager.py
index 1b6c43278..cb3059e56 100644
--- a/src/pybind/mgr/volumes/fs/operations/versions/metadata_manager.py
+++ b/src/pybind/mgr/volumes/fs/operations/versions/metadata_manager.py
@@ -40,16 +40,17 @@ class MetadataManager(object):
def refresh(self):
fd = None
conf_data = StringIO()
+ log.debug("opening config {0}".format(self.config_path))
try:
- log.debug("opening config {0}".format(self.config_path))
fd = self.fs.open(self.config_path, os.O_RDONLY)
while True:
data = self.fs.read(fd, -1, MetadataManager.MAX_IO_BYTES)
if not len(data):
break
conf_data.write(data.decode('utf-8'))
- conf_data.seek(0)
- self.config.readfp(conf_data)
+ except UnicodeDecodeError:
+ raise MetadataMgrException(-errno.EINVAL,
+ "failed to decode, erroneous metadata config '{0}'".format(self.config_path))
except cephfs.ObjectNotFound:
raise MetadataMgrException(-errno.ENOENT, "metadata config '{0}' not found".format(self.config_path))
except cephfs.Error as e:
@@ -58,6 +59,16 @@ class MetadataManager(object):
if fd is not None:
self.fs.close(fd)
+ conf_data.seek(0)
+ try:
+ if sys.version_info >= (3, 2):
+ self.config.read_file(conf_data)
+ else:
+ self.config.readfp(conf_data)
+ except configparser.Error:
+ raise MetadataMgrException(-errno.EINVAL, "failed to parse, erroneous metadata config "
+ "'{0}'".format(self.config_path))
+
def flush(self):
# cull empty sections
for section in list(self.config.sections()):
diff --git a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py
index 2840a9f2e..0d183e612 100644
--- a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py
+++ b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py
@@ -5,6 +5,7 @@ import errno
import logging
from hashlib import md5
from typing import Dict, Union
+from pathlib import Path
import cephfs
@@ -16,6 +17,7 @@ from ...fs_util import get_ancestor_xattr
from ...exception import MetadataMgrException, VolumeException
from .op_sm import SubvolumeOpSm
from .auth_metadata import AuthMetadataManager
+from .subvolume_attrs import SubvolumeStates
log = logging.getLogger(__name__)
@@ -111,7 +113,7 @@ class SubvolumeBase(object):
@property
def state(self):
""" Subvolume state, one of SubvolumeStates """
- raise NotImplementedError
+ raise SubvolumeStates.from_value(self.metadata_mgr.get_global_option(MetadataManager.GLOBAL_META_KEY_STATE))
@property
def subvol_type(self):
@@ -123,6 +125,15 @@ class SubvolumeBase(object):
raise NotImplementedError
def load_config(self):
+ try:
+ self.fs.stat(self.legacy_config_path)
+ self.legacy_mode = True
+ except cephfs.Error as e:
+ pass
+
+ log.debug("loding config "
+ "'{0}' [mode: {1}]".format(self.subvolname, "legacy"
+ if self.legacy_mode else "new"))
if self.legacy_mode:
self.metadata_mgr = MetadataManager(self.fs, self.legacy_config_path, 0o640)
else:
@@ -271,8 +282,16 @@ class SubvolumeBase(object):
self.fs.stat(self.base_path)
self.metadata_mgr.refresh()
log.debug("loaded subvolume '{0}'".format(self.subvolname))
+ subvolpath = self.metadata_mgr.get_global_option(MetadataManager.GLOBAL_META_KEY_PATH)
+ # subvolume with retained snapshots has enpty path, don't mistake it for
+ # fabricated metadata.
+ if (not self.legacy_mode and self.state != SubvolumeStates.STATE_RETAINED and
+ self.base_path.decode('utf-8') !=(Path(subvolpath).parent)):
+ raise MetadataMgrException(-errno.ENOENT, 'fabricated .meta')
except MetadataMgrException as me:
- if me.errno == -errno.ENOENT and not self.legacy_mode:
+ if me.errno in (-errno.ENOENT, -errno.EINVAL) and not self.legacy_mode:
+ log.warn("subvolume '{0}', {1}, "
+ "assuming legacy_mode".format(self.subvolname, me.error_str))
self.legacy_mode = True
self.load_config()
self.discover()
diff --git a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v1.py b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v1.py
index d62effd99..39f256638 100644
--- a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v1.py
+++ b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v1.py
@@ -666,7 +666,7 @@ class SubvolumeV1(SubvolumeBase, SubvolumeTemplate):
@property
def state(self):
- return SubvolumeStates.from_value(self.metadata_mgr.get_global_option(MetadataManager.GLOBAL_META_KEY_STATE))
+ return super(SubvolumeV1, self).state
@state.setter
def state(self, val):
--
2.27.0

View File

@ -125,7 +125,7 @@
#################################################################################
Name: ceph
Version: 16.2.7
Release: 2
Release: 10
%if 0%{?fedora} || 0%{?rhel} || 0%{?openEuler}
Epoch: 2
%endif
@ -146,6 +146,12 @@ Source0: %{?_remote_tarball_prefix}ceph-16.2.7.tar.gz
Patch1: 0001-fix-error-transform-is-not-a-member-of-std.patch
Patch2: 0002-enable-install-deps-in-openEuler.patch
Patch3: 0003-isa-l-update.patch
Patch4: 0004-cmake-add-support-python-3.10.patch
Patch5: 0005-ceph-volume-lvm-api-function-no-undefined.patch
Patch6: 0006-ceph-volume-decrease-number-of-pvs-calls-in-lvm-list.patch
Patch7: 0007-bluestore-use-direct-write-for-bdevlabel.patch
Patch8: 0008-enable-sw64-architecture.patch
Patch9: 0009-fix-CVE-2022-0670.patch
%if 0%{?suse_version}
# _insert_obs_source_lines_here
ExclusiveArch: x86_64 aarch64 ppc64le s390x
@ -193,9 +199,8 @@ BuildRequires: libblkid-devel >= 2.17
BuildRequires: cryptsetup-devel
BuildRequires: libcurl-devel
BuildRequires: libcap-ng-devel
BuildRequires: fmt-devel
#BuildRequires: pkgconfig(libudev)
BuildRequires: libudev-devel
BuildRequires: fmt-devel >= 5.2.1
BuildRequires: pkgconfig(libudev)
BuildRequires: libnl3-devel
BuildRequires: liboath-devel
BuildRequires: libtool
@ -1205,6 +1210,9 @@ This package provides Ceph default alerts for Prometheus.
#################################################################################
%prep
%autosetup -p1 -n ceph-16.2.7
%ifnarch sw_64
%patch8 -R -p1
%endif
%build
# LTO can be enabled as soon as the following GCC bug is fixed:
@ -1240,7 +1248,7 @@ export CXXFLAGS=$(echo $RPM_OPT_FLAGS | sed -e 's/-Wp,-D_FORTIFY_SOURCE=2//g')
%endif
# Parallel build settings ...
CEPH_MFLAGS_JOBS="-j20"
CEPH_MFLAGS_JOBS="-j16"
CEPH_SMP_NCPUS=$(echo "$CEPH_MFLAGS_JOBS" | sed 's/-j//')
%if 0%{?__isa_bits} == 32
# 32-bit builds can use 3G memory max, which is not enough even for -j2
@ -2484,6 +2492,30 @@ exit 0
%config %{_sysconfdir}/prometheus/ceph/ceph_default_alerts.yml
%changelog
* Tue Nov 15 2022 wangzengliang <wangzengliang1@huawei.com> - 2:16.2.7-10
- keep the ceph.spec align with native community
* Mon Nov 14 2022 wangzengliang <wangzengliang1@huawei.com> - 2:16.2.7-9
- fix CVE-2022-0670
* Thu Nov 10 2022 wangzengliang <wangzengliang1@huawei.com> - 2:16.2.7-8
- rename sw64 patch and reduce compilation threads
* Wed Oct 26 2022 wuzx<wuzx1226@qq.com> - 2:16.2.7-7
- Add sw64 architecture
* Wed Sep 28 2022 luo rixin <luorixin@huawei.com> - 2:16.2.7-6
- fix osd read superblock error
* Thu Aug 25 2022 yangxiaoliang <yangxiaoliang07@163.com> - 2:16.2.7-5
- fix ceph-volume lvm list calls many times pvs
* Mon Jul 18 2022 yangxiaoliang <yangxiaoliang07@163.com> - 2:16.2.7-4
- fix ceph-volume lvm api function undefined error
* Fri Mar 11 2022 wangzengliang <wangzengliang1@huawei.com> - 2:16.2.7-3
- cmake: add support python 3.10
* Fri Mar 11 2022 wangzengliang <wangzengliang1@huawei.com> - 1:16.2.7-2
- fix * recognition error when install
@ -2491,7 +2523,7 @@ exit 0
- isa-l: update isa-l to fix aarch64 text relocation error
* Thu Dec 30 2021 liuqinfei <18138800392@163.com> - 1:16.2.7-0
- update to 16.2.7
- update to 16.2.7 test
* Fri Nov 5 2021 Dai Zhiwei <daizhiwei3@huawei.com> - 1:14.2.15-7
- fix aarch64 crc32c unittest error