Oof, the patches must be in `git am` format...

...said my own tools...

Change-Id: I08067b1fca16424bc390190c9ee59d8aa461cc99
diff --git a/patches/openstack/cinder/sep-sp-clone-volume.patch b/patches/openstack/cinder/sep-sp-clone-volume.patch
index cbf209e..2c25551 100644
--- a/patches/openstack/cinder/sep-sp-clone-volume.patch
+++ b/patches/openstack/cinder/sep-sp-clone-volume.patch
@@ -1,7 +1,7 @@
-From 9565e7e32bee1e613f1e09a8989e1bad7f90fa08 Mon Sep 17 00:00:00 2001
+From 110d748871ed078eff42bd370bcdfb643614e6f5 Mon Sep 17 00:00:00 2001
 From: Peter Penchev <openstack-dev@storpool.com>
 Date: Wed, 20 Apr 2022 15:47:39 +0300
-Subject: [PATCH 7/7] StorPool: create_cloned_volume() improvements
+Subject: [PATCH 3/3] StorPool: create_cloned_volume() improvements
 
 If the source and destination volumes are in the same StorPool template
 (as defined by either the volume type or the global config setting),
@@ -29,6 +29,8 @@
  4 files changed, 208 insertions(+), 34 deletions(-)
  create mode 100644 releasenotes/notes/storpool-clone-better-dca90f40c9273de9.yaml
 
+diff --git a/cinder/tests/unit/volume/drivers/test_storpool.py b/cinder/tests/unit/volume/drivers/test_storpool.py
+index 24715fa29..95a1ffffd 100644
 --- a/cinder/tests/unit/volume/drivers/test_storpool.py
 +++ b/cinder/tests/unit/volume/drivers/test_storpool.py
 @@ -14,6 +14,7 @@
@@ -39,7 +41,7 @@
  import re
  import sys
  from unittest import mock
-@@ -110,13 +111,33 @@
+@@ -110,13 +111,33 @@ class MockAPI(object):
      def snapshotCreate(self, vname, snap):
          snapshots[snap['name']] = dict(volumes[vname])
  
@@ -75,7 +77,7 @@
  
      def volumeDelete(self, name):
          del volumes[name]
-@@ -174,6 +195,23 @@
+@@ -174,6 +195,23 @@ fakeStorPool.spopenstack.AttachDB = MockAttachDB
  fakeStorPool.sptypes.VolumeUpdateDesc = MockVolumeUpdateDesc
  
  
@@ -99,7 +101,7 @@
  @ddt.ddt
  class StorPoolTestCase(test.TestCase):
  
-@@ -265,6 +303,11 @@
+@@ -265,6 +303,11 @@ class StorPoolTestCase(test.TestCase):
          self.assertListEqual(sorted([volumeName(n) for n in names]),
                               sorted(data['name'] for data in volumes.values()))
  
@@ -111,7 +113,7 @@
      @mock_volume_types
      def test_create_delete_volume(self):
          self.assertVolumeNames([])
-@@ -277,7 +320,7 @@
+@@ -277,7 +320,7 @@ class StorPoolTestCase(test.TestCase):
          self.assertVolumeNames(('1',))
          v = volumes[volumeName('1')]
          self.assertEqual(1 * units.Gi, v['size'])
@@ -120,7 +122,7 @@
          self.assertEqual(3, v['replication'])
  
          caught = False
-@@ -297,7 +340,7 @@
+@@ -297,7 +340,7 @@ class StorPoolTestCase(test.TestCase):
          self.assertVolumeNames(('1',))
          v = volumes[volumeName('1')]
          self.assertEqual(2 * units.Gi, v['size'])
@@ -129,7 +131,7 @@
          self.assertEqual(3, v['replication'])
  
          self.driver.create_volume({'id': '2', 'name': 'v2', 'size': 3,
-@@ -305,7 +348,7 @@
+@@ -305,7 +348,7 @@ class StorPoolTestCase(test.TestCase):
          self.assertVolumeNames(('1', '2'))
          v = volumes[volumeName('2')]
          self.assertEqual(3 * units.Gi, v['size'])
@@ -138,7 +140,7 @@
          self.assertEqual(3, v['replication'])
  
          self.driver.create_volume({'id': '3', 'name': 'v2', 'size': 4,
-@@ -327,7 +370,7 @@
+@@ -327,7 +370,7 @@ class StorPoolTestCase(test.TestCase):
          # Make sure the dictionary is not corrupted somehow...
          v = volumes[volumeName('1')]
          self.assertEqual(2 * units.Gi, v['size'])
@@ -147,7 +149,7 @@
          self.assertEqual(3, v['replication'])
  
          for vid in ('1', '2', '3', '4'):
-@@ -395,16 +438,17 @@
+@@ -395,16 +438,17 @@ class StorPoolTestCase(test.TestCase):
          self.driver.extend_volume({'id': '1'}, 2)
          self.assertEqual(2 * units.Gi, volumes[volumeName('1')]['size'])
  
@@ -173,7 +175,7 @@
  
          self.driver.delete_volume({'id': 1})
          self.driver.delete_volume({'id': 2})
-@@ -412,6 +456,78 @@
+@@ -412,6 +456,78 @@ class StorPoolTestCase(test.TestCase):
          self.assertDictEqual({}, volumes)
          self.assertDictEqual({}, snapshots)
  
@@ -252,7 +254,7 @@
      @mock_volume_types
      def test_config_replication(self):
          self.assertVolumeNames([])
-@@ -431,7 +547,7 @@
+@@ -431,7 +547,7 @@ class StorPoolTestCase(test.TestCase):
          self.assertVolumeNames(('cfgrepl1',))
          v = volumes[volumeName('cfgrepl1')]
          self.assertEqual(3, v['replication'])
@@ -261,7 +263,7 @@
          self.driver.delete_volume({'id': 'cfgrepl1'})
  
          self.driver.configuration.storpool_replication = 2
-@@ -445,7 +561,7 @@
+@@ -445,7 +561,7 @@ class StorPoolTestCase(test.TestCase):
          self.assertVolumeNames(('cfgrepl2',))
          v = volumes[volumeName('cfgrepl2')]
          self.assertEqual(2, v['replication'])
@@ -270,7 +272,7 @@
          self.driver.delete_volume({'id': 'cfgrepl2'})
  
          self.driver.create_volume({'id': 'cfgrepl3', 'name': 'v1', 'size': 1,
-@@ -477,7 +593,7 @@
+@@ -477,7 +593,7 @@ class StorPoolTestCase(test.TestCase):
          self.assertVolumeNames(('cfgtempl1',))
          v = volumes[volumeName('cfgtempl1')]
          self.assertEqual(3, v['replication'])
@@ -279,9 +281,11 @@
          self.driver.delete_volume({'id': 'cfgtempl1'})
  
          self.driver.create_volume({'id': 'cfgtempl2', 'name': 'v1', 'size': 1,
+diff --git a/cinder/volume/drivers/storpool.py b/cinder/volume/drivers/storpool.py
+index cb5680d29..5aa30398e 100644
 --- a/cinder/volume/drivers/storpool.py
 +++ b/cinder/volume/drivers/storpool.py
-@@ -19,11 +19,13 @@
+@@ -19,11 +19,13 @@ import platform
  
  from oslo_config import cfg
  from oslo_log import log as logging
@@ -295,7 +299,7 @@
  from cinder import exception
  from cinder.i18n import _
  from cinder import interface
-@@ -197,30 +199,80 @@
+@@ -197,30 +199,80 @@ class StorPoolDriver(driver.VolumeDriver):
  
      def create_cloned_volume(self, volume, src_vref):
          refname = self._attach.volumeName(src_vref['id'])
@@ -354,7 +358,11 @@
 +                    snapname,
 +                    {'template': template},
 +                )
-+            except spapi.ApiError as e:
+             except spapi.ApiError as e:
+-                # ARGH!
+-                LOG.error("Could not delete the temp snapshot %(name)s: "
+-                          "%(msg)s",
+-                          {'name': snapname, 'msg': e})
 +                raise self._backendException(e)
 +
 +            try:
@@ -371,11 +379,7 @@
 +                    snapname,
 +                    {'tags': {'transient': '1.0'}},
 +                )
-             except spapi.ApiError as e:
--                # ARGH!
--                LOG.error("Could not delete the temp snapshot %(name)s: "
--                          "%(msg)s",
--                          {'name': snapname, 'msg': e})
++            except spapi.ApiError as e:
 +                raise self._backendException(e)
 +        except Exception:
 +            with excutils.save_and_reraise_exception():
@@ -392,9 +396,11 @@
  
      def create_export(self, context, volume, connector):
          pass
+diff --git a/driver-requirements.txt b/driver-requirements.txt
+index f501e9fcd..d55fb86c7 100644
 --- a/driver-requirements.txt
 +++ b/driver-requirements.txt
-@@ -41,7 +41,7 @@
+@@ -41,7 +41,7 @@ infi.dtypes.wwn # PSF
  infi.dtypes.iqn # PSF
  
  # Storpool
@@ -403,6 +409,9 @@
  storpool.spopenstack>=2.2.1 # Apache-2.0
  
  # Datera
+diff --git a/releasenotes/notes/storpool-clone-better-dca90f40c9273de9.yaml b/releasenotes/notes/storpool-clone-better-dca90f40c9273de9.yaml
+new file mode 100644
+index 000000000..180427d9e
 --- /dev/null
 +++ b/releasenotes/notes/storpool-clone-better-dca90f40c9273de9.yaml
 @@ -0,0 +1,6 @@
@@ -412,3 +421,6 @@
 +    StorPool driver: improved the way volumes are clonsed into different
 +    StorPool templates (exposed as Cinder storage pools) if requested,
 +    eliminating some data duplication in the underlying StorPool cluster.
+-- 
+2.39.0
+
diff --git a/patches/openstack/cinder/sep-sp-fix-test-rename.patch b/patches/openstack/cinder/sep-sp-fix-test-rename.patch
index 742699f..3899848 100644
--- a/patches/openstack/cinder/sep-sp-fix-test-rename.patch
+++ b/patches/openstack/cinder/sep-sp-fix-test-rename.patch
@@ -1,12 +1,21 @@
-StorPool: fix the "rename volume" unit test emulation
+From 498aa10da848c6d5e75b1d7f0d2c67fd9536f251 Mon Sep 17 00:00:00 2001
+From: Peter Penchev <openstack-dev@storpool.com>
+Date: Tue, 17 Jan 2023 01:20:59 +0200
+Subject: [PATCH 1/3] StorPool: fix the "rename volume" unit test emulation
 
 Also update the "name" field of the actual data structure in
 the fake list of volumes.
 
 Change-Id: Iee9e3feea1af4f3d0acdf05ea1b540ecf59e755b
+---
+ cinder/tests/unit/volume/drivers/test_storpool.py | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/cinder/tests/unit/volume/drivers/test_storpool.py b/cinder/tests/unit/volume/drivers/test_storpool.py
+index 2e6f56526..f878c6d26 100644
 --- a/cinder/tests/unit/volume/drivers/test_storpool.py
 +++ b/cinder/tests/unit/volume/drivers/test_storpool.py
-@@ -135,7 +135,10 @@
+@@ -135,7 +135,10 @@ class MockAPI(object):
              volumes[name]['size'] = data['size']
  
          if 'rename' in data and data['rename'] != name:
@@ -18,7 +27,7 @@
              del volumes[name]
  
  
-@@ -259,6 +262,8 @@
+@@ -259,6 +262,8 @@ class StorPoolTestCase(test.TestCase):
      def assertVolumeNames(self, names):
          self.assertListEqual(sorted([volumeName(n) for n in names]),
                               sorted(volumes.keys()))
@@ -27,3 +36,6 @@
  
      @mock_volume_types
      def test_create_delete_volume(self):
+-- 
+2.39.0
+
diff --git a/patches/openstack/cinder/sep-sp-retype-vol.patch b/patches/openstack/cinder/sep-sp-retype-vol.patch
index 70be672..131dd6a 100644
--- a/patches/openstack/cinder/sep-sp-retype-vol.patch
+++ b/patches/openstack/cinder/sep-sp-retype-vol.patch
@@ -1,16 +1,54 @@
-From 15773fc48d174bd6931eac65cae1b000ab72b1fb Mon Sep 17 00:00:00 2001
+From 767b03274054e1c1e422ef8937769ec9851a4111 Mon Sep 17 00:00:00 2001
 From: Peter Penchev <openstack-dev@storpool.com>
 Date: Wed, 14 Dec 2022 17:55:56 +0200
-Subject: [PATCH 2/2] StorPool: fix the retype volume flow
+Subject: [PATCH 2/3] StorPool: fix the retype volume flow
 
 Change-Id: I786733aae17dea47e3e6f2a393a947bfb46e70a3
+Closes-Bug: #2002995
 ---
- cinder/volume/drivers/storpool.py | 47 ++++++++++++++++++++++++-------
- 1 file changed, 37 insertions(+), 10 deletions(-)
+ .../unit/volume/drivers/test_storpool.py      | 16 ++++---
+ cinder/volume/drivers/storpool.py             | 47 +++++++++++++++----
+ 2 files changed, 47 insertions(+), 16 deletions(-)
 
+diff --git a/cinder/tests/unit/volume/drivers/test_storpool.py b/cinder/tests/unit/volume/drivers/test_storpool.py
+index f878c6d26..24715fa29 100644
+--- a/cinder/tests/unit/volume/drivers/test_storpool.py
++++ b/cinder/tests/unit/volume/drivers/test_storpool.py
+@@ -358,12 +358,6 @@ class StorPoolTestCase(test.TestCase):
+                                                  'available')
+         self.assertDictEqual({'_name_id': '1'}, res)
+ 
+-        # Failure: a volume with the original volume's name already exists
+-        res = self.driver.update_migrated_volume(None, {'id': '1'},
+-                                                 {'id': '2', '_name_id': '1'},
+-                                                 'available')
+-        self.assertDictEqual({'_name_id': '1'}, res)
+-
+         # Success: rename the migrated volume to match the original
+         res = self.driver.update_migrated_volume(None, {'id': '3'},
+                                                  {'id': '2', '_name_id': '3'},
+@@ -374,6 +368,16 @@ class StorPoolTestCase(test.TestCase):
+                              volumes.keys())
+         self.assertVolumeNames(('1', '3',))
+ 
++        # Success: swap volume names with an existing volume
++        res = self.driver.update_migrated_volume(None, {'id': '1'},
++                                                 {'id': '3', '_name_id': '1'},
++                                                 'available')
++        self.assertDictEqual({'_name_id': None}, res)
++        six.assertCountEqual(self,
++                             [volumeName('1'), volumeName('3')],
++                             volumes.keys())
++        self.assertVolumeNames(('1', '3',))
++
+         for vid in ('1', '3'):
+             self.driver.delete_volume({'id': vid})
+         self.assertVolumeNames([])
+diff --git a/cinder/volume/drivers/storpool.py b/cinder/volume/drivers/storpool.py
+index cdaf0043d..cb5680d29 100644
 --- a/cinder/volume/drivers/storpool.py
 +++ b/cinder/volume/drivers/storpool.py
-@@ -353,10 +353,12 @@
+@@ -353,10 +353,12 @@ class StorPoolDriver(driver.VolumeDriver):
                              update['template'] = templ
                          else:
                              update['replication'] = repl
@@ -27,7 +65,7 @@
  
          if update:
              name = self._attach.volumeName(volume['id'])
-@@ -381,21 +383,46 @@
+@@ -381,21 +383,46 @@ class StorPoolDriver(driver.VolumeDriver):
                        'created as part of the migration from '
                        '"%(oid)s".', {'tid': temp_id, 'oid': orig_id})
              return {'_name_id': new_volume['_name_id'] or new_volume['id']}
@@ -80,34 +118,6 @@
 +                      '%(err)s',
 +                      {'tname': temp_name, 'oname': orig_name, 'err': e})
 +            return {'_name_id': new_volume['_name_id'] or new_volume['id']}
---- a/cinder/tests/unit/volume/drivers/test_storpool.py
-+++ b/cinder/tests/unit/volume/drivers/test_storpool.py
-@@ -358,18 +358,22 @@
-                                                  'available')
-         self.assertDictEqual({'_name_id': '1'}, res)
- 
--        # Failure: a volume with the original volume's name already exists
--        res = self.driver.update_migrated_volume(None, {'id': '1'},
--                                                 {'id': '2', '_name_id': '1'},
--                                                 'available')
--        self.assertDictEqual({'_name_id': '1'}, res)
--
-         # Success: rename the migrated volume to match the original
-         res = self.driver.update_migrated_volume(None, {'id': '3'},
-                                                  {'id': '2', '_name_id': '3'},
-                                                  'available')
-         self.assertDictEqual({'_name_id': None}, res)
-         six.assertCountEqual(self,
-+                             [volumeName('1'), volumeName('3')],
-+                             volumes.keys())
-+        self.assertVolumeNames(('1', '3',))
-+
-+        # Success: swap volume names with an existing volume
-+        res = self.driver.update_migrated_volume(None, {'id': '1'},
-+                                                 {'id': '3', '_name_id': '1'},
-+                                                 'available')
-+        self.assertDictEqual({'_name_id': None}, res)
-+        six.assertCountEqual(self,
-                              [volumeName('1'), volumeName('3')],
-                              volumes.keys())
-         self.assertVolumeNames(('1', '3',))
+-- 
+2.39.0
+