diff --git a/SOURCES/0001-backport-of-ccd121cc248d79b749a63d4ad099e6d5f4b8b588.patch b/SOURCES/0001-backport-of-ccd121cc248d79b749a63d4ad099e6d5f4b8b588.patch index 4736c327..18508046 100644 --- a/SOURCES/0001-backport-of-ccd121cc248d79b749a63d4ad099e6d5f4b8b588.patch +++ b/SOURCES/0001-backport-of-ccd121cc248d79b749a63d4ad099e6d5f4b8b588.patch @@ -1,7 +1,7 @@ From ca464c9f43c5e52420b75f37854cf5db826a929c Mon Sep 17 00:00:00 2001 From: Mark Syms Date: Thu, 20 May 2021 17:40:06 +0100 -Subject: [PATCH 01/19] backport of ccd121cc248d79b749a63d4ad099e6d5f4b8b588: +Subject: [PATCH 01/20] backport of ccd121cc248d79b749a63d4ad099e6d5f4b8b588: CA-354692: check for device parameter in create/probe calls Signed-off-by: Mark Syms @@ -87,5 +87,5 @@ index 3311e55..ad28649 100755 def registerSR(SRClass): """Register SR with handler. All SR subclasses should call this in -- -2.30.2 +2.41.0 diff --git a/SOURCES/0002-Update-xs-sm.service-s-description-for-XCP-ng.patch b/SOURCES/0002-Update-xs-sm.service-s-description-for-XCP-ng.patch index 8f854464..7b9f8972 100644 --- a/SOURCES/0002-Update-xs-sm.service-s-description-for-XCP-ng.patch +++ b/SOURCES/0002-Update-xs-sm.service-s-description-for-XCP-ng.patch @@ -1,7 +1,7 @@ From 618d0f65369b2dd5b6243aae937cca516355205c Mon Sep 17 00:00:00 2001 From: Samuel Verschelde Date: Thu, 13 Aug 2020 15:22:17 +0200 -Subject: [PATCH 02/19] Update xs-sm.service's description for XCP-ng +Subject: [PATCH 02/20] Update xs-sm.service's description for XCP-ng This was a patch added to the sm RPM git repo before we had this forked git repo for sm in the xcp-ng github organisation. @@ -21,5 +21,5 @@ index 99cb313..609c6ef 100644 Conflicts=shutdown.target RefuseManualStop=yes -- -2.30.2 +2.41.0 diff --git a/SOURCES/0003-Add-TrueNAS-multipath-config.patch b/SOURCES/0003-Add-TrueNAS-multipath-config.patch index 642c936f..e825887a 100644 --- a/SOURCES/0003-Add-TrueNAS-multipath-config.patch +++ b/SOURCES/0003-Add-TrueNAS-multipath-config.patch @@ -1,7 +1,7 @@ From 37b279a8daca22aae97862bed2a3976132b218bd Mon Sep 17 00:00:00 2001 From: Samuel Verschelde Date: Thu, 13 Aug 2020 15:26:43 +0200 -Subject: [PATCH 03/19] Add TrueNAS multipath config +Subject: [PATCH 03/20] Add TrueNAS multipath config This was a patch added to the sm RPM git repo before we had this forked git repo for sm in the xcp-ng github organisation. @@ -26,5 +26,5 @@ index aaf45e5..1073faa 100644 + } } -- -2.30.2 +2.41.0 diff --git a/SOURCES/0004-feat-drivers-add-CephFS-GlusterFS-and-XFS-drivers.patch b/SOURCES/0004-feat-drivers-add-CephFS-GlusterFS-and-XFS-drivers.patch index c9833fc9..fff5a231 100644 --- a/SOURCES/0004-feat-drivers-add-CephFS-GlusterFS-and-XFS-drivers.patch +++ b/SOURCES/0004-feat-drivers-add-CephFS-GlusterFS-and-XFS-drivers.patch @@ -1,7 +1,7 @@ From 21ad2a6035dca5e2dc889880a90020348be52dd8 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 20 Jul 2020 16:26:42 +0200 -Subject: [PATCH 04/19] feat(drivers): add CephFS, GlusterFS and XFS drivers +Subject: [PATCH 04/20] feat(drivers): add CephFS, GlusterFS and XFS drivers --- Makefile | 3 + @@ -888,5 +888,5 @@ index 97c332c..ad1ee86 100755 if not type in SR.TYPES: raise util.SMException("Unsupported SR type: %s" % type) -- -2.30.2 +2.41.0 diff --git a/SOURCES/0005-feat-drivers-add-ZFS-driver-to-avoid-losing-VDI-meta.patch b/SOURCES/0005-feat-drivers-add-ZFS-driver-to-avoid-losing-VDI-meta.patch index a415c4e2..6d187f5e 100644 --- a/SOURCES/0005-feat-drivers-add-ZFS-driver-to-avoid-losing-VDI-meta.patch +++ b/SOURCES/0005-feat-drivers-add-ZFS-driver-to-avoid-losing-VDI-meta.patch @@ -1,7 +1,7 @@ From 9cb3f6724c62bfda5eaf5a29952c4d0b83dcffdf Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 12 Aug 2020 11:14:33 +0200 -Subject: [PATCH 05/19] feat(drivers): add ZFS driver to avoid losing VDI +Subject: [PATCH 05/20] feat(drivers): add ZFS driver to avoid losing VDI metadata (xcp-ng/xcp#401) --- @@ -201,5 +201,5 @@ index ad1ee86..327103f 100755 type = SR.TYPE_FILE if not type in SR.TYPES: -- -2.30.2 +2.41.0 diff --git a/SOURCES/0006-Re-add-the-ext4-driver-for-users-who-need-to-transit.patch b/SOURCES/0006-Re-add-the-ext4-driver-for-users-who-need-to-transit.patch index 35a3b4c4..d10dd9b9 100644 --- a/SOURCES/0006-Re-add-the-ext4-driver-for-users-who-need-to-transit.patch +++ b/SOURCES/0006-Re-add-the-ext4-driver-for-users-who-need-to-transit.patch @@ -1,7 +1,7 @@ From ece61a8594f7337fb86bb1ea4893d43d8c554fec Mon Sep 17 00:00:00 2001 From: Samuel Verschelde Date: Thu, 13 Aug 2020 17:10:12 +0200 -Subject: [PATCH 06/19] Re-add the ext4 driver for users who need to transition +Subject: [PATCH 06/20] Re-add the ext4 driver for users who need to transition The driver is needed to transition to the ext driver. Users who upgrade from XCP-ng <= 8.0 need a working driver so that they @@ -287,5 +287,5 @@ index 327103f..867c789 100755 type = SR.TYPE_FILE if not type in SR.TYPES: -- -2.30.2 +2.41.0 diff --git a/SOURCES/0007-feat-drivers-add-LinstorSR-driver.patch b/SOURCES/0007-feat-drivers-add-LinstorSR-driver.patch index df60d762..757751f9 100644 --- a/SOURCES/0007-feat-drivers-add-LinstorSR-driver.patch +++ b/SOURCES/0007-feat-drivers-add-LinstorSR-driver.patch @@ -1,7 +1,7 @@ From dec7d21fc5380fc6c2866fbfe8dcece9e937071c Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 16 Mar 2020 15:39:44 +0100 -Subject: [PATCH 07/19] feat(drivers): add LinstorSR driver +Subject: [PATCH 07/20] feat(drivers): add LinstorSR driver Some important points: @@ -5675,5 +5675,5 @@ diff --git a/tests/mocks/linstor/__init__.py b/tests/mocks/linstor/__init__.py new file mode 100644 index 0000000..e69de29 -- -2.30.2 +2.41.0 diff --git a/SOURCES/0008-feat-tests-add-unit-tests-concerning-ZFS-close-xcp-n.patch b/SOURCES/0008-feat-tests-add-unit-tests-concerning-ZFS-close-xcp-n.patch index 159df4aa..5b61fe59 100644 --- a/SOURCES/0008-feat-tests-add-unit-tests-concerning-ZFS-close-xcp-n.patch +++ b/SOURCES/0008-feat-tests-add-unit-tests-concerning-ZFS-close-xcp-n.patch @@ -1,7 +1,7 @@ From 5f4ae6317d4505fcab4ed7e959f11389a4d7a442 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 27 Oct 2020 15:04:36 +0100 -Subject: [PATCH 08/19] feat(tests): add unit tests concerning ZFS (close +Subject: [PATCH 08/20] feat(tests): add unit tests concerning ZFS (close xcp-ng/xcp#425) - Check if "create" doesn't succeed without zfs packages @@ -205,5 +205,5 @@ index 0000000..6f8040d + failed = True + self.assertTrue(failed) -- -2.30.2 +2.41.0 diff --git a/SOURCES/0009-If-no-NFS-ACLs-provided-assume-everyone.patch b/SOURCES/0009-If-no-NFS-ACLs-provided-assume-everyone.patch index 03e968ae..f2f46cb5 100644 --- a/SOURCES/0009-If-no-NFS-ACLs-provided-assume-everyone.patch +++ b/SOURCES/0009-If-no-NFS-ACLs-provided-assume-everyone.patch @@ -1,7 +1,7 @@ From a53beccf65c329a7f1af25c330c20f770252b7fd Mon Sep 17 00:00:00 2001 From: BenjiReis Date: Thu, 25 Feb 2021 09:54:52 +0100 -Subject: [PATCH 09/19] If no NFS ACLs provided, assume everyone: +Subject: [PATCH 09/20] If no NFS ACLs provided, assume everyone: Some QNAP devices do not provide ACL when fetching NFS mounts. In this case the assumed ACL should be: "*". @@ -71,5 +71,5 @@ index 71800ab..cef414f 100644 + self.assertEqual(len(pread2.mock_calls), 1) + pread2.assert_called_with(['/usr/sbin/showmount', '--no-headers', '-e', 'aServer']) -- -2.30.2 +2.41.0 diff --git a/SOURCES/0010-Added-SM-Driver-for-MooseFS.patch b/SOURCES/0010-Added-SM-Driver-for-MooseFS.patch index 312eb537..f1594946 100644 --- a/SOURCES/0010-Added-SM-Driver-for-MooseFS.patch +++ b/SOURCES/0010-Added-SM-Driver-for-MooseFS.patch @@ -1,7 +1,7 @@ From c1483fc0d2394cf297ff304ee09faafd2b2b2143 Mon Sep 17 00:00:00 2001 From: Aleksander Wieliczko Date: Fri, 29 Jan 2021 15:21:23 +0100 -Subject: [PATCH 10/19] Added SM Driver for MooseFS +Subject: [PATCH 10/20] Added SM Driver for MooseFS Co-authored-by: Piotr Robert Konopelko Signed-off-by: Aleksander Wieliczko @@ -386,5 +386,5 @@ index 0000000..5a61cf5 + mfssr.detach('asr_uuid') + self.assertTrue(mfssr.attached) -- -2.30.2 +2.41.0 diff --git a/SOURCES/0011-Avoid-usage-of-umount-in-ISOSR-when-legacy_mode-is-u.patch b/SOURCES/0011-Avoid-usage-of-umount-in-ISOSR-when-legacy_mode-is-u.patch index 41f7925a..978dde3f 100644 --- a/SOURCES/0011-Avoid-usage-of-umount-in-ISOSR-when-legacy_mode-is-u.patch +++ b/SOURCES/0011-Avoid-usage-of-umount-in-ISOSR-when-legacy_mode-is-u.patch @@ -1,7 +1,7 @@ From fc0e53774691db631e3bfadfabe4e8de81d686bd Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 2 Dec 2021 09:28:37 +0100 -Subject: [PATCH 11/19] Avoid usage of `umount` in `ISOSR` when `legacy_mode` +Subject: [PATCH 11/20] Avoid usage of `umount` in `ISOSR` when `legacy_mode` is used `umount` should not be called when `legacy_mode` is enabled, otherwise a mounted dir @@ -103,5 +103,5 @@ index 914b961..a5b3290 100644 class TestISOSR_overNFS(unittest.TestCase): -- -2.30.2 +2.41.0 diff --git a/SOURCES/0012-MooseFS-SR-uses-now-UUID-subdirs-for-each-SR.patch b/SOURCES/0012-MooseFS-SR-uses-now-UUID-subdirs-for-each-SR.patch index 0e71af92..41210c61 100644 --- a/SOURCES/0012-MooseFS-SR-uses-now-UUID-subdirs-for-each-SR.patch +++ b/SOURCES/0012-MooseFS-SR-uses-now-UUID-subdirs-for-each-SR.patch @@ -1,7 +1,7 @@ From 037e7181a8faf00d01cda4813d3c833e81296279 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 18 May 2022 17:28:09 +0200 -Subject: [PATCH 12/19] MooseFS SR uses now UUID subdirs for each SR +Subject: [PATCH 12/20] MooseFS SR uses now UUID subdirs for each SR A sm-config boolean param `subdir` is available to configure where to store the VHDs: - In a subdir with the SR UUID, the new behavior @@ -126,5 +126,5 @@ index be5112c..ab72f4e 100755 self.detach(sr_uuid) if inst.code != errno.ENOENT: -- -2.30.2 +2.41.0 diff --git a/SOURCES/0013-Fix-is_open-call-for-many-drivers-25.patch b/SOURCES/0013-Fix-is_open-call-for-many-drivers-25.patch index 32e65315..7e3c6020 100644 --- a/SOURCES/0013-Fix-is_open-call-for-many-drivers-25.patch +++ b/SOURCES/0013-Fix-is_open-call-for-many-drivers-25.patch @@ -1,7 +1,7 @@ From ad8693df57172278677a61607cecc057efc729a1 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 23 Jun 2022 10:36:36 +0200 -Subject: [PATCH 13/19] Fix is_open call for many drivers (#25) +Subject: [PATCH 13/20] Fix is_open call for many drivers (#25) Ensure all shared drivers are imported in `_is_open` definition to register them in the driver list. Otherwise this function always fails with a SRUnknownType exception. @@ -104,5 +104,5 @@ index 0d60d96..534e6c9 100755 driver = SR.driver(srType) -- -2.30.2 +2.41.0 diff --git a/SOURCES/0014-Remove-SR_CACHING-capability-for-many-SR-types-24.patch b/SOURCES/0014-Remove-SR_CACHING-capability-for-many-SR-types-24.patch index 7d0cc213..a6cc97e1 100644 --- a/SOURCES/0014-Remove-SR_CACHING-capability-for-many-SR-types-24.patch +++ b/SOURCES/0014-Remove-SR_CACHING-capability-for-many-SR-types-24.patch @@ -1,7 +1,7 @@ From 32be9cfcd581a06075c549f68aff3ed709affcad Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 23 Jun 2022 10:37:07 +0200 -Subject: [PATCH 14/19] Remove SR_CACHING capability for many SR types (#24) +Subject: [PATCH 14/20] Remove SR_CACHING capability for many SR types (#24) SR_CACHING offers the capacity to use IntelliCache, but this feature is only available using NFS SR. @@ -56,5 +56,5 @@ index ab72f4e..212f1ad 100755 "VDI_UPDATE", "VDI_CLONE", "VDI_SNAPSHOT", "VDI_RESIZE", "VDI_MIRROR", "VDI_GENERATE_CONFIG", -- -2.30.2 +2.41.0 diff --git a/SOURCES/0015-Remove-SR_PROBE-from-ZFS-capabilities-37.patch b/SOURCES/0015-Remove-SR_PROBE-from-ZFS-capabilities-37.patch index 0ad522ea..67fb32df 100644 --- a/SOURCES/0015-Remove-SR_PROBE-from-ZFS-capabilities-37.patch +++ b/SOURCES/0015-Remove-SR_PROBE-from-ZFS-capabilities-37.patch @@ -1,7 +1,7 @@ From 1167204e6869853c63c9a0daa0b7582bccac0fc4 Mon Sep 17 00:00:00 2001 From: BenjiReis Date: Fri, 4 Aug 2023 12:10:08 +0200 -Subject: [PATCH 15/19] Remove `SR_PROBE` from ZFS capabilities (#37) +Subject: [PATCH 15/20] Remove `SR_PROBE` from ZFS capabilities (#37) The probe method is not implemented so we shouldn't advertise it. @@ -24,5 +24,5 @@ index d375210..b803211 100644 'VDI_CREATE', 'VDI_DELETE', -- -2.30.2 +2.41.0 diff --git a/SOURCES/0016-Fix-vdi-ref-when-static-vdis-are-used.patch b/SOURCES/0016-Fix-vdi-ref-when-static-vdis-are-used.patch index 828bf395..9eae2191 100644 --- a/SOURCES/0016-Fix-vdi-ref-when-static-vdis-are-used.patch +++ b/SOURCES/0016-Fix-vdi-ref-when-static-vdis-are-used.patch @@ -1,7 +1,7 @@ From 3bf41acc381c3d89e0bd0e017fd1653076987ae9 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Wed, 16 Aug 2023 13:42:21 +0200 -Subject: [PATCH 16/19] Fix vdi-ref when static vdis are used +Subject: [PATCH 16/20] Fix vdi-ref when static vdis are used When static vdis are used there is no snapshots and we don't want to call method from XAPI. @@ -32,5 +32,5 @@ index dd8e20b..6ac3f80 100755 if needDeflate: try: -- -2.30.2 +2.41.0 diff --git a/SOURCES/0017-Tell-users-not-to-edit-multipath.conf-directly.patch b/SOURCES/0017-Tell-users-not-to-edit-multipath.conf-directly.patch index f31577c5..6a332180 100644 --- a/SOURCES/0017-Tell-users-not-to-edit-multipath.conf-directly.patch +++ b/SOURCES/0017-Tell-users-not-to-edit-multipath.conf-directly.patch @@ -1,7 +1,7 @@ -From 341ac817e7df747233bc0147a9353f8a308373eb Mon Sep 17 00:00:00 2001 +From c5e94c0e736356026e5680f7193b41c8f0dc81d6 Mon Sep 17 00:00:00 2001 From: Samuel Verschelde Date: Fri, 27 Jan 2023 12:03:15 +0100 -Subject: [PATCH 17/19] Tell users not to edit multipath.conf directly +Subject: [PATCH 17/20] Tell users not to edit multipath.conf directly This file is meant to remain unchanged and regularly updated along with the SM component. Users can create a custom configuration file in @@ -30,5 +30,5 @@ index 1073faa..3de1144 100644 # multipathd. # For information on the syntax refer to `man multipath.conf` and the examples -- -2.30.2 +2.41.0 diff --git a/SOURCES/0018-Add-custom.conf-multipath-configuration-file.patch b/SOURCES/0018-Add-custom.conf-multipath-configuration-file.patch index 464760c4..ad6761a4 100644 --- a/SOURCES/0018-Add-custom.conf-multipath-configuration-file.patch +++ b/SOURCES/0018-Add-custom.conf-multipath-configuration-file.patch @@ -1,7 +1,7 @@ -From c6b87140a83b81e5c40a76fd0633f44fe0cb49ef Mon Sep 17 00:00:00 2001 +From 9404df7d9cdc9072cfa8d138648ab78d8b7ee12e Mon Sep 17 00:00:00 2001 From: Samuel Verschelde Date: Fri, 27 Jan 2023 12:23:13 +0100 -Subject: [PATCH 18/19] Add custom.conf multipath configuration file +Subject: [PATCH 18/20] Add custom.conf multipath configuration file Meant to be installed as /etc/multipath/conf.d/custom.conf for users to have an easy entry point for editing, as well as information on what @@ -27,5 +27,5 @@ index 0000000..3c8583f + +# Refer to "man multipath.conf" -- -2.30.2 +2.41.0 diff --git a/SOURCES/0019-Install-etc-multipath-conf.d-custom.conf.patch b/SOURCES/0019-Install-etc-multipath-conf.d-custom.conf.patch index a5b5d8b1..90b21f82 100644 --- a/SOURCES/0019-Install-etc-multipath-conf.d-custom.conf.patch +++ b/SOURCES/0019-Install-etc-multipath-conf.d-custom.conf.patch @@ -1,7 +1,7 @@ -From b7bc5c6e4debc75067c1c3bac96928385f1daffe Mon Sep 17 00:00:00 2001 +From bcf9493c572bb239a6ffaf9f15f19924080092ae Mon Sep 17 00:00:00 2001 From: Samuel Verschelde Date: Fri, 25 Aug 2023 17:47:34 +0200 -Subject: [PATCH 19/19] Install /etc/multipath/conf.d/custom.conf +Subject: [PATCH 19/20] Install /etc/multipath/conf.d/custom.conf Update Makefile so that the file is installed along with sm. @@ -48,5 +48,5 @@ index ab9a15e..f56f61e 100755 $(SM_STAGING)/$(INIT_DIR) install -m 755 multipath/multipath-root-setup \ -- -2.30.2 +2.41.0 diff --git a/SOURCES/0020-fix-NFSSR-ensure-we-can-attach-SR-during-attach_from.patch b/SOURCES/0020-fix-NFSSR-ensure-we-can-attach-SR-during-attach_from.patch new file mode 100644 index 00000000..a1de94a3 --- /dev/null +++ b/SOURCES/0020-fix-NFSSR-ensure-we-can-attach-SR-during-attach_from.patch @@ -0,0 +1,214 @@ +From 35d8ec27ed4d3c4ac681e2ed4d3329f4c58c42a8 Mon Sep 17 00:00:00 2001 +From: Ronan Abhamon +Date: Wed, 11 Oct 2023 15:14:08 +0200 +Subject: [PATCH 20/20] fix(NFSSR): ensure we can attach SR during + attach_from_config call + +We can get a trace like that if the SR is not attached: +``` +2170:Oct 10 16:02:59 xcp4 SM: [2564] ***** NFSFileVDI.attach_from_config: EXCEPTION , 'NoneType' object has no attribute 'xenapi' +2329-Oct 10 16:02:59 xcp4 SM: [2564] File "/opt/xensource/sm/NFSSR", line 296, in attach_from_config +2427-Oct 10 16:02:59 xcp4 SM: [2564] self.sr.attach(sr_uuid) +2487-Oct 10 16:02:59 xcp4 SM: [2564] File "/opt/xensource/sm/NFSSR", line 148, in attach +2573-Oct 10 16:02:59 xcp4 SM: [2564] self._check_hardlinks() +2633-Oct 10 16:02:59 xcp4 SM: [2564] File "/opt/xensource/sm/FileSR.py", line 1122, in _check_hardlinks +2734-Oct 10 16:02:59 xcp4 SM: [2564] self.session.xenapi.SR.remove_from_sm_config( +2816-Oct 10 16:02:59 xcp4 SM: [2564] +``` + +Because the session is not set during this call. +So instead of using the XenAPI to store hardlink support, use a file on the storage itself. + +Signed-off-by: Ronan Abhamon +--- + drivers/FileSR.py | 67 +++++++++++++++++++++++++++++++++----------- + tests/test_FileSR.py | 30 ++------------------ + 2 files changed, 54 insertions(+), 43 deletions(-) + +diff --git a/drivers/FileSR.py b/drivers/FileSR.py +index 5da02af..da1ef22 100755 +--- a/drivers/FileSR.py ++++ b/drivers/FileSR.py +@@ -413,6 +413,9 @@ class FileSR(SR.SR): + (util.ismount(mount_path) or \ + util.pathexists(self.remotepath) and self._isbind())) + ++ # Override in SharedFileSR. ++ def _check_hardlinks(self): ++ return True + + class FileVDI(VDI.VDI): + PARAM_VHD = "vhd" +@@ -780,11 +783,10 @@ class FileVDI(VDI.VDI): + os.unlink(path) + + def _create_new_parent(self, src, newsrc): +- sr_sm_config = self.session.xenapi.SR.get_sm_config(self.sr.sr_ref) +- if SharedFileSR.NO_HARDLINK_SUPPORT in sr_sm_config: +- self._rename(src, newsrc) +- else: ++ if self.sr._check_hardlinks(): + self._link(src, newsrc) ++ else: ++ self._rename(src, newsrc) + + def __fist_enospace(self): + raise util.CommandException(28, "vhd-util snapshot", reason="No space") +@@ -1102,12 +1104,15 @@ class SharedFileSR(FileSR): + """ + FileSR subclass for SRs that use shared network storage + """ +- NO_HARDLINK_SUPPORT = "no_hardlinks" + + def _raise_hardlink_error(self): + raise OSError(542, "Unknown error 524") + + def _check_hardlinks(self): ++ hardlink_conf = self._read_hardlink_conf() ++ if hardlink_conf is not None: ++ return hardlink_conf ++ + test_name = os.path.join(self.path, str(uuid4())) + open(test_name, 'ab').close() + +@@ -1119,25 +1124,55 @@ class SharedFileSR(FileSR): + self._raise_hardlink_error) + + os.link(test_name, link_name) +- self.session.xenapi.SR.remove_from_sm_config( +- self.sr_ref, SharedFileSR.NO_HARDLINK_SUPPORT) ++ self._write_hardlink_conf(supported=True) ++ return True + except OSError: ++ self._write_hardlink_conf(supported=False) ++ + msg = "File system for SR %s does not support hardlinks, crash " \ + "consistency of snapshots cannot be assured" % self.uuid + util.SMlog(msg, priority=util.LOG_WARNING) +- try: +- self.session.xenapi.SR.add_to_sm_config( +- self.sr_ref, SharedFileSR.NO_HARDLINK_SUPPORT, 'True') +- self.session.xenapi.message.create( +- "sr_does_not_support_hardlinks", 2, "SR", self.uuid, +- msg) +- except XenAPI.Failure: +- # Might already be set and checking has TOCTOU issues +- pass ++ # Note: session can be not set during attach/detach_from_config calls. ++ if self.session: ++ try: ++ self.session.xenapi.message.create( ++ "sr_does_not_support_hardlinks", 2, "SR", self.uuid, ++ msg) ++ except XenAPI.Failure: ++ # Might already be set and checking has TOCTOU issues ++ pass + finally: + util.force_unlink(link_name) + util.force_unlink(test_name) + ++ return False ++ ++ def _get_hardlink_conf_path(self): ++ return os.path.join(self.path, 'sm-hardlink.conf') ++ ++ def _read_hardlink_conf(self): ++ try: ++ with open(self._get_hardlink_conf_path(), 'r') as f: ++ try: ++ return bool(int(f.read())) ++ except Exception as e: ++ # If we can't read, assume the file is empty and test for hardlink support. ++ return None ++ except IOError as e: ++ if e.errno == errno.ENOENT: ++ # If the config file doesn't exist, assume we want to support hardlinks. ++ return None ++ util.SMlog('Failed to read hardlink conf: {}'.format(e)) ++ # Can be caused by a concurrent access, not a major issue. ++ return None ++ ++ def _write_hardlink_conf(self, supported): ++ try: ++ with open(self._get_hardlink_conf_path(), 'w') as f: ++ f.write('1' if supported else '0') ++ except Exception as e: ++ # Can be caused by a concurrent access, not a major issue. ++ util.SMlog('Failed to write hardlink conf: {}'.format(e)) + + if __name__ == '__main__': + SRCommand.run(FileSR, DRIVER_INFO) +diff --git a/tests/test_FileSR.py b/tests/test_FileSR.py +index dd70c8c..ea00db9 100644 +--- a/tests/test_FileSR.py ++++ b/tests/test_FileSR.py +@@ -121,6 +121,8 @@ class FakeSharedFileSR(FileSR.SharedFileSR): + def attach(self, sr_uuid): + self._check_hardlinks() + ++ def _read_hardlink_conf(self): ++ return None + + class TestShareFileSR(unittest.TestCase): + """ +@@ -128,7 +130,6 @@ class TestShareFileSR(unittest.TestCase): + """ + TEST_SR_REF = "test_sr_ref" + ERROR_524 = "Unknown error 524" +- NO_HARDLINKS = "no_hardlinks" + + def setUp(self): + fist_patcher = mock.patch('FileSR.util.FistPoint.is_active', +@@ -182,8 +183,7 @@ class TestShareFileSR(unittest.TestCase): + test_sr.attach(self.sr_uuid) + + # Assert +- self.mock_session.xenapi.SR.remove_from_sm_config.assert_called_with( +- TestShareFileSR.TEST_SR_REF, TestShareFileSR.NO_HARDLINKS) ++ self.assertEqual(0, self.mock_session.xenapi.message.create.call_count) + + def test_attach_link_fail(self): + """ +@@ -198,31 +198,9 @@ class TestShareFileSR(unittest.TestCase): + test_sr.attach(self.sr_uuid) + + # Assert +- self.mock_session.xenapi.SR.add_to_sm_config.assert_called_with( +- TestShareFileSR.TEST_SR_REF, TestShareFileSR.NO_HARDLINKS, 'True') + self.mock_session.xenapi.message.create.assert_called_with( + 'sr_does_not_support_hardlinks', 2, "SR", self.sr_uuid, mock.ANY) + +- def test_attach_link_fail_already_set(self): +- """ +- Attach SR on FS with no hardlinks with config set +- """ +- test_sr = self.create_test_sr() +- +- self.mock_link.side_effect = OSError(524, TestShareFileSR.ERROR_524) +- self.mock_session.xenapi.SR.add_to_sm_config.side_effect = Failure( +- ['MAP_DUPLICATE_KEY', 'SR', 'sm_config', +- 'OpaqueRef:be8cc595-4924-4946-9082-59aef531daae', +- TestShareFileSR.NO_HARDLINKS]) +- +- # Act +- with mock.patch('__builtin__.open'): +- test_sr.attach(self.sr_uuid) +- +- # Assert +- self.mock_session.xenapi.SR.add_to_sm_config.assert_called_with( +- TestShareFileSR.TEST_SR_REF, TestShareFileSR.NO_HARDLINKS, 'True') +- + def test_attach_fist_active(self): + """ + Attach SR with FIST point active to set no hardlinks +@@ -238,7 +216,5 @@ class TestShareFileSR(unittest.TestCase): + test_sr.attach(self.sr_uuid) + + # Assert +- self.mock_session.xenapi.SR.add_to_sm_config.assert_called_with( +- TestShareFileSR.TEST_SR_REF, TestShareFileSR.NO_HARDLINKS, 'True') + self.mock_session.xenapi.message.create.assert_called_with( + 'sr_does_not_support_hardlinks', 2, "SR", self.sr_uuid, mock.ANY) +-- +2.41.0 + diff --git a/SPECS/sm.spec b/SPECS/sm.spec index c96ed339..ed9999a8 100644 --- a/SPECS/sm.spec +++ b/SPECS/sm.spec @@ -9,7 +9,7 @@ Summary: sm - XCP storage managers Name: sm Version: 2.30.8 -Release: %{?xsrel}.3%{?dist} +Release: %{?xsrel}.3.0.1%{?dist} Group: System/Hypervisor License: LGPL URL: https://github.com/xapi-project/sm @@ -91,6 +91,7 @@ Patch1016: 0016-Fix-vdi-ref-when-static-vdis-are-used.patch Patch1017: 0017-Tell-users-not-to-edit-multipath.conf-directly.patch Patch1018: 0018-Add-custom.conf-multipath-configuration-file.patch Patch1019: 0019-Install-etc-multipath-conf.d-custom.conf.patch +Patch1020: 0020-fix-NFSSR-ensure-we-can-attach-SR-during-attach_from.patch %description This package contains storage backends used in XCP @@ -475,6 +476,9 @@ cp -r htmlcov %{buildroot}/htmlcov %{_unitdir}/linstor-monitor.service %changelog +* Thu Oct 12 2023 Ronan Abhamon - 2.30.8-2.3.0.1 +- Add 0020-fix-NFSSR-ensure-we-can-attach-SR-during-attach_from.patch + * Fri Aug 25 2023 Samuel Verschelde - 2.30.8-2.3 - Do not overwrite multipath.conf if users made changes - Add warning to multipath.conf to prevent future modifications