Skip to content

Commit

Permalink
LVM COW in progress
Browse files Browse the repository at this point in the history
Signed-off-by: Ronan Abhamon <[email protected]>
  • Loading branch information
Wescoeur committed Jan 23, 2025
1 parent 7a992dc commit cd7c836
Show file tree
Hide file tree
Showing 29 changed files with 797 additions and 741 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ SM_LIBS += vhdutil
SM_LIBS += linstorjournaler
SM_LIBS += linstorvhdutil
SM_LIBS += linstorvolumemanager
SM_LIBS += lvhdutil # TODO: Split
SM_LIBS += lvmcowutil
SM_LIBS += cifutils
SM_LIBS += xs_errors
SM_LIBS += nfs
Expand Down
4 changes: 2 additions & 2 deletions drivers/02-vhdcleanup
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
. /etc/init.d/functions

CLEANUP_SCRIPT="/opt/xensource/sm/cleanup.py"
LVHD_UTIL_SCRIPT="/opt/xensource/sm/lvhdutil.py"
LVM_COW_UTIL_SCRIPT="/opt/xensource/sm/lvmcowutil.py"

start() {
echo -n $"Fixing refcounts on new master: "
Expand All @@ -31,7 +31,7 @@ start() {
srUuids=`xe sr-list type=$type params=uuid --minimal | sed "s/,/ /g"`
for uuid in $srUuids; do
echo -n "Fixing $type"
python $LVHD_UTIL_SCRIPT fixrefcounts $uuid
python $LVM_COW_UTIL_SCRIPT fixrefcounts $uuid
done
done
echo -n $"OK"
Expand Down
2 changes: 1 addition & 1 deletion drivers/FileSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ def create(self, sr_uuid, vdi_uuid, size) -> str:
if util.ioretry(lambda: util.pathexists(self.path)):
raise xs_errors.XenError('VDIExists')

self.cowutil = getCowUtil(self.vdi_type)
if VdiType.isCowImage(self.vdi_type):
self.cowutil = getCowUtil(self.vdi_type)
try:
size = self.cowutil.validateAndRoundImageSize(int(size))
util.ioretry(lambda: self._create(size, self.path))
Expand Down
377 changes: 193 additions & 184 deletions drivers/LVMSR.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion drivers/LVMoHBASR.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

DRIVER_INFO = {
'name': 'LVM over FC',
'description': 'SR plugin which represents disks as VHDs on Logical Volumes within a Volume Group created on an HBA LUN, e.g. hardware-based iSCSI or FC support',
'description': 'SR plugin which represents disks as VHDs and QCOW2s on Logical Volumes within a Volume Group created on an HBA LUN, e.g. hardware-based iSCSI or FC support',
'vendor': 'Citrix Systems Inc',
'copyright': '(C) 2008 Citrix Systems Inc',
'driver_version': '1.0',
Expand Down
2 changes: 1 addition & 1 deletion drivers/LinstorSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,7 @@ def _create_snapshot(self, snap_uuid, snap_of_uuid=None):
# 2. Write the snapshot content.
is_raw = (self.vdi_type == VdiType.RAW)
self._cowutil.snapshot(
snap_path, self.path, is_raw, self.MAX_METADATA_VIRT_SIZE
snap_path, self.path, is_raw, max(self.size, cowutil.getDefaultPreallocationSizeVirt())
)

# 3. Get snapshot parent.
Expand Down
1 change: 0 additions & 1 deletion drivers/VDI.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import xmlrpc.client
import xs_errors
import util
import vhdutil
import cbtutil
import os
import base64
Expand Down
8 changes: 4 additions & 4 deletions drivers/blktap2.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
import scsiutil
from syslog import openlog, syslog
from stat import * # S_ISBLK(), ...
from lvmcowutil import NS_PREFIX_LVM
from vditype import VdiType
import nfs

import resetvdis
import lvhdutil

import VDI as sm

Expand Down Expand Up @@ -1117,7 +1117,7 @@ def __str__(self) -> str:

VDI_PLUG_TYPE = {'phy': 'phy', # for NETAPP
'raw': 'phy',
'aio': 'tap', # for LVHD raw nodes
'aio': 'tap', # for LVM raw nodes
'iso': 'tap', # for ISOSR
'file': 'tap',
'vhd': 'tap',
Expand Down Expand Up @@ -1672,7 +1672,7 @@ def _activate_locked(self, sr_uuid, vdi_uuid, options):
if hasattr(self.target.vdi.sr, 'DRIVER_TYPE') and \
self.target.vdi.sr.DRIVER_TYPE == 'lvhd' and \
VdiType.isCowImage(vdi_type):
lock = Lock("lvchange-p", lvhdutil.NS_PREFIX_LVM + sr_uuid)
lock = Lock("lvchange-p", NS_PREFIX_LVM + sr_uuid)
lock.acquire()

# When we attach a static VDI for HA, we cannot communicate with
Expand Down Expand Up @@ -1975,7 +1975,7 @@ def _setup_cache(self, session, sr_uuid, vdi_uuid, local_sr_uuid,
os.unlink(local_leaf_path)
try:
self._cowutil.snapshot(local_leaf_path, read_cache_path, False,
msize=leaf_size // 1024 // 1024, checkEmpty=False)
msize=leaf_size, checkEmpty=False)
except util.CommandException as e:
util.SMlog("Error creating leaf cache: %s" % e)
self.alert_no_cache(session, vdi_uuid, local_sr_uuid, e.code)
Expand Down
2 changes: 1 addition & 1 deletion drivers/cbtutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Helper functions pertaining to VHD operations
# Helper functions pertaining to COW image operations
#

import util
Expand Down
Loading

0 comments on commit cd7c836

Please sign in to comment.