Gris Ge
2014-09-04 15:48:47 UTC
* Targetd is using LibLVM which do 'size / SECTOR_SIZE'. (SECTOR_SIZE == 512)
This will cause two issue:
1. When less than 512, LibLVM will raise error:
Unable to create LV without size.
2. New volume size is always less or equal to requested.
But LVM definition require new volume size bigger or equal than
requested.
* Just do a 512 round up would workaround this issue.
Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/targetd/targetd.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/plugin/targetd/targetd.py b/plugin/targetd/targetd.py
index 00fcf49..a144685 100644
--- a/plugin/targetd/targetd.py
+++ b/plugin/targetd/targetd.py
@@ -35,6 +35,7 @@ DEFAULT_USER = "admin"
DEFAULT_PORT = 18700
PATH = "/targetrpc"
+LVM_SECTOR_SIZE = 1 << 9
def handle_errors(method):
def target_wrapper(*args, **kwargs):
@@ -334,6 +335,8 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
if provisioning != Volume.PROVISION_DEFAULT:
raise LsmError(ErrorNumber.INVALID_ARGUMENT,
"Unsupported provisioning")
+ if size_bytes % LVM_SECTOR_SIZE:
+ size_bytes += 512
self._jsonrequest("vol_create", dict(pool=pool.id,
name=volume_name,
This will cause two issue:
1. When less than 512, LibLVM will raise error:
Unable to create LV without size.
2. New volume size is always less or equal to requested.
But LVM definition require new volume size bigger or equal than
requested.
* Just do a 512 round up would workaround this issue.
Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/targetd/targetd.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/plugin/targetd/targetd.py b/plugin/targetd/targetd.py
index 00fcf49..a144685 100644
--- a/plugin/targetd/targetd.py
+++ b/plugin/targetd/targetd.py
@@ -35,6 +35,7 @@ DEFAULT_USER = "admin"
DEFAULT_PORT = 18700
PATH = "/targetrpc"
+LVM_SECTOR_SIZE = 1 << 9
def handle_errors(method):
def target_wrapper(*args, **kwargs):
@@ -334,6 +335,8 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
if provisioning != Volume.PROVISION_DEFAULT:
raise LsmError(ErrorNumber.INVALID_ARGUMENT,
"Unsupported provisioning")
+ if size_bytes % LVM_SECTOR_SIZE:
+ size_bytes += 512
self._jsonrequest("vol_create", dict(pool=pool.id,
name=volume_name,
--
1.9.3
1.9.3