Timothy Asir has uploaded a new change for review. Change subject: gluster: fix brick devices are created with incorrect data alignment ......................................................................
gluster: fix brick devices are created with incorrect data alignment Removed make partition function and pv create will not create any partition on the given device. Change-Id: I58cc322cb5140de2d2006d59b4c1dceaba2e5968 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1270792 Signed-off-by: Timothy Asir Jeyasingh <tjeya...@redhat.com> --- M vdsm/gluster/storagedev.py 1 file changed, 28 insertions(+), 44 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/59/47959/1 diff --git a/vdsm/gluster/storagedev.py b/vdsm/gluster/storagedev.py index 1e4402c..4da753e 100644 --- a/vdsm/gluster/storagedev.py +++ b/vdsm/gluster/storagedev.py @@ -76,7 +76,7 @@ 'uuid': '', 'createBrick': createBrick} if isinstance(device.size, blivet.size.Size): - info['size'] = '%s' % device.size.convertTo(spec="MiB") + info['size'] = '%s' % device.size.convertTo(blivet.size.MiB) else: info['size'] = '%s' % device.size if not info['bus'] and device.parents: @@ -137,49 +137,24 @@ return [blivetEnv.devicetree.getDeviceByName(devName.split("/")[-1]) for devName in devNameList] - def _makePartition(deviceList): - pvDeviceList = [] - doPartitioning = False - for dev in deviceList: - if dev.type not in ['disk', 'dm-multipath']: - pvDeviceList.append(dev) - else: - blivetEnv.initializeDisk(dev) - part = blivetEnv.newPartition(fmt_type="lvmpv", grow=True, - parents=[dev]) - blivetEnv.createDevice(part) - pvDeviceList.append(part) - doPartitioning = True - - if doPartitioning: - blivet.partitioning.doPartitioning(blivetEnv) - return pvDeviceList - def _createPV(deviceList, alignment=0): - def _createAlignedPV(deviceList, alignment): - for dev in deviceList: - # bz#1178705: Blivet always creates pv with 1MB dataalignment - # Workaround: Till blivet fixes the issue, we use lvm pvcreate + for dev in deviceList: + # bz#1178705: Blivet always creates pv with 1MB dataalignment + # Workaround: Till blivet fixes the issue, we use lvm pvcreate + if alignment: rc, out, err = utils.execCmd([_pvCreateCommandPath.cmd, '--dataalignment', '%sk' % alignment, dev.path]) - if rc: - raise ge.GlusterHostStorageDevicePVCreateFailedException( - dev.path, alignment, rc, out, err) - _reset_blivet(blivetEnv) - return _getDeviceList([dev.name for dev in deviceList]) + else: + rc, out, err = utils.execCmd([_pvCreateCommandPath.cmd, + dev.path]) - if alignment: - blivetEnv.doIt() - return _createAlignedPV(deviceList, alignment) - - for dev in deviceList: - lvmpv = blivet.formats.getFormat("lvmpv", device=dev.path) - blivetEnv.formatDevice(dev, lvmpv) - - blivet.partitioning.doPartitioning(blivetEnv) - return deviceList + if rc: + raise ge.GlusterHostStorageDevicePVCreateFailedException( + dev.path, alignment, rc, out, err) + _reset_blivet(blivetEnv) + return _getDeviceList([dev.name for dev in deviceList]) def _createVG(vgName, deviceList, stripeSize=0): if stripeSize: @@ -204,8 +179,11 @@ if not alignment: # bz#1180228: blivet doesn't handle percentage-based sizes properly # Workaround: Till the bz gets fixed, we take only 99% size from vg + vgSizeByte = (vg.size * 99 / 100).convertTo(blivet.size.B) + # calculate roundSize to avoid 'Size is not a multiple of 512' error pool = LVMThinPoolDevice(poolName, parents=[vg], - size=(vg.size * 99 / 100), + size=blivet.size.Size( + (vgSizeByte - vgSizeByte % 512)), grow=True) blivetEnv.createDevice(pool) return pool @@ -283,8 +261,7 @@ if inUseList: raise ge.GlusterHostStorageDeviceInUseException(inUseList) - pvDeviceList = _makePartition(deviceList) - pvDeviceList = _createPV(pvDeviceList, alignment) + pvDeviceList = _createPV(deviceList, alignment) vg = _createVG(vgName, pvDeviceList, raidParams.get('stripeSize', 0)) # The following calculation is based on the redhat storage performance doc @@ -297,8 +274,8 @@ # and create data LV (poolDataSize) that has a size which is # a multiple of stripe width if alignment: - vgSizeKib = int(vg.size.convertTo(spec="KiB")) - if vg.size.convertTo(spec='MiB') < MIN_VG_SIZE: + vgSizeKib = int(vg.size.convertTo(blivet.size.KiB)) + if vg.size.convertTo(blivet.size.MiB) < MIN_VG_SIZE: metaDataSize = vgSizeKib * MIN_METADATA_PERCENT poolDataSize = vgSizeKib - metaDataSize metaDataSize = (metaDataSize - (metaDataSize % alignment)) @@ -308,8 +285,15 @@ # lvconvert --chunksize alignment --thinpool VOLGROUP/thin_pool # --poolmetadata VOLGROUP/metadata_device_name pool = _createThinPool(poolName, vg, chunkSize, metaDataSize, poolDataSize) + + if alignment: + poolSize = pool.size + else: + # Calculate roundSize to avoid 'Size is not a multiple of 512' error + poolSize = pool.size.convertTo(blivet.size.B)/512 * 512 + thinlv = LVMThinLogicalVolumeDevice(brickName, parents=[pool], - size=pool.size, grow=True) + size=poolSize, grow=True) blivetEnv.createDevice(thinlv) blivetEnv.doIt() -- To view, visit https://gerrit.ovirt.org/47959 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I58cc322cb5140de2d2006d59b4c1dceaba2e5968 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Timothy Asir <tjeya...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches