Skip to content

Commit

Permalink
Merge branch 'master' into team/ring0/linux-upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkSymsCtx committed Feb 6, 2019
2 parents bccd99b + 46a8c7a commit 6ac9ef6
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 43 deletions.
47 changes: 17 additions & 30 deletions drivers/FileSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,31 +808,21 @@ def _snapshot(self, snap_type, cbtlog=None, cbt_consistency=None):

# We assume the filehandle has been released
try:
try:
util.ioretry(lambda: os.rename(src,newsrc))
except util.CommandException, inst:
if inst.code != errno.ENOENT:
# failed to rename, simply raise error
util.end_log_entry(self.sr.path, self.path, ["error"])
raise

try:
# Create the snapshot under a temporary name, then rename
# it afterwards. This avoids a small window where it exists
# but is invalid. We do not need to do this for
# snap_type == VDI.SNAPSHOT_DOUBLE because dst never existed
# before so nobody will try to query it.
tmpsrc = "%s.%s" % (src, "new")
util.ioretry(lambda: self._snap(tmpsrc, newsrcname))
util.ioretry(lambda: os.rename(tmpsrc, src))
if snap_type == VDI.SNAPSHOT_DOUBLE:
util.ioretry(lambda: self._snap(dst, newsrcname))
# mark the original file (in this case, its newsrc)
# as hidden so that it does not show up in subsequent scans
util.ioretry(lambda: self._mark_hidden(newsrc))
except util.CommandException, inst:
if inst.code != errno.EIO:
raise
util.ioretry(lambda: os.rename(src,newsrc))

# Create the snapshot under a temporary name, then rename
# it afterwards. This avoids a small window where it exists
# but is invalid. We do not need to do this for
# snap_type == VDI.SNAPSHOT_DOUBLE because dst never existed
# before so nobody will try to query it.
tmpsrc = "%s.%s" % (src, "new")
util.ioretry(lambda: self._snap(tmpsrc, newsrcname))
util.ioretry(lambda: os.rename(tmpsrc, src))
if snap_type == VDI.SNAPSHOT_DOUBLE:
util.ioretry(lambda: self._snap(dst, newsrcname))
# mark the original file (in this case, its newsrc)
# as hidden so that it does not show up in subsequent scans
util.ioretry(lambda: self._mark_hidden(newsrc))

#Verify parent locator field of both children and delete newsrc if unused
introduce_parent = True
Expand Down Expand Up @@ -942,17 +932,14 @@ def _snap(self, child, parent):
text = util.pread(cmd)

def _clonecleanup(self,src,dst,newsrc):
try:
util.ioretry(lambda: os.unlink(src))
except util.CommandException, inst:
pass
try:
if dst:
util.ioretry(lambda: os.unlink(dst))
except util.CommandException, inst:
pass
try:
util.ioretry(lambda: os.rename(newsrc,src))
if util.ioretry(lambda: util.pathexists(newsrc)):
util.ioretry(lambda: os.rename(newsrc,src))
except util.CommandException, inst:
pass

Expand Down
9 changes: 7 additions & 2 deletions drivers/mpathcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
MP_INUSEDIR = "/dev/disk/mpInuse"
mpp_path_update = False
match_bySCSIid = False
mpath_enabled = True

if len(sys.argv) == 3:
match_bySCSIid = True
Expand Down Expand Up @@ -186,8 +187,9 @@ def get_SCSIidlist(devconfig, sm_config):
if get_root_dev_major() != get_dm_major():
hconf = session.xenapi.host.get_other_config(localhost)
assert(hconf['multipathing'] == 'true')
mpath_enabled = True
except:
mpc_exit(session,0)
mpath_enabled = False

# Check root disk if multipathed
try:
Expand Down Expand Up @@ -242,7 +244,10 @@ def add(key, val):
continue
util.SMlog("Matched SCSIid, updating %s" % i)
key = "mpath-" + i
if mpp_path_update:
if not mpath_enabled:
remove(key)
remove('multipathed')
elif mpp_path_update:
util.SMlog("Matched SCSIid, updating entry %s" % str(mpp_entry))
update_config(key, i, mpp_entry, remove, add, mpp_path_update)
else:
Expand Down
7 changes: 5 additions & 2 deletions drivers/nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
DEFAULT_NFSVERSION = '3'

NFS_VERSION = [
'nfsversion', 'for type=nfs, NFS protocol version - 3, 4']
'nfsversion', 'for type=nfs, NFS protocol version - 3, 4, 4.1']

NFS_SERVICE_WAIT = 30
NFS_SERVICE_RETRY = 6
Expand Down Expand Up @@ -111,7 +111,7 @@ def validate_nfsversion(nfsversion):
if not nfsversion:
nfsversion = DEFAULT_NFSVERSION
else:
if nfsversion not in ['3', '4']:
if nfsversion not in ['3', '4', '4.1']:
raise NfsException("Invalid nfsversion.")
return nfsversion

Expand Down Expand Up @@ -143,6 +143,9 @@ def soft_mount(mountpoint, remoteserver, remotepath, transport, useroptions='',
mountcommand = 'mount.nfs'
if nfsversion == '4':
mountcommand = 'mount.nfs4'

if nfsversion == '4.1':
mountcommand = 'mount.nfs4'

options = "soft,proto=%s,vers=%s" % (
transport,
Expand Down
4 changes: 2 additions & 2 deletions drivers/scsiutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def gen_uuid_from_string(str):
return str[0:8]+'-'+str[8:12]+'-'+str[12:16]+'-'+str[16:20]+'-'+str[20:32]

def SCSIid_sanitise(str):
text = re.sub("^\s+","",str)
text = str.strip()
return re.sub("\s+","_",text)

def getSCSIid(path):
Expand All @@ -106,7 +106,7 @@ def getSCSIid(path):

stdout = util.pread2([SCSI_ID_BIN, '-g', '--device', path])

return SCSIid_sanitise(stdout[:-1])
return SCSIid_sanitise(stdout)

def compareSCSIid_2_6_18(SCSIid, path):
serial = getserial(path)
Expand Down
3 changes: 2 additions & 1 deletion drivers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,9 @@ def ioretry(f, errlist=[errno.EIO], maxretry=IORETRY_MAX, period=IORETRY_PERIOD,
return f()
except OSError, inst:
err = int(inst.errno)
inst = CommandException(err, str(f), "OSError")
if not err in errlist:
raise CommandException(err, str(f), "OSError")
raise inst
except CommandException, inst:
if not int(inst.code) in errlist:
raise
Expand Down
4 changes: 2 additions & 2 deletions tests/test_nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_validate_nfsversion_invalid(self):
thenfsversion)

def test_validate_nfsversion_unsupported(self):
for thenfsversion in ['2', '4.1']:
for thenfsversion in ['2']:
self.assertRaises(nfs.NfsException, nfs.validate_nfsversion,
thenfsversion)

Expand All @@ -128,6 +128,6 @@ def test_validate_nfsversion_default(self):
self.assertEquals(nfs.validate_nfsversion(thenfsversion), '3')

def test_validate_nfsversion_valid(self):
for thenfsversion in ['3', '4']:
for thenfsversion in ['3', '4', '4.1']:
self.assertEquals(nfs.validate_nfsversion(thenfsversion),
thenfsversion)
6 changes: 2 additions & 4 deletions udev/40-multipath.rules
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
SUBSYSTEM!="block", GOTO="end_mpath"
KERNEL!="dm-*", GOTO="end_mpath"
KERNEL!="dm-*", GOTO="count_mpath"
ACTION=="add", PROGRAM=="/bin/bash -c '/sbin/dmsetup info -c -o name --noheadings -j %M -m %m | /bin/grep VG_XenStorage'", GOTO="end_mpath"
ACTION=="add", PROGRAM=="/bin/bash -c '/sbin/dmsetup info -c -o name --noheadings -j %M -m %m | /bin/grep XSLocalEXT'", GOTO="end_mpath"
ACTION=="add|change", PROGRAM=="/sbin/dmsetup info -c -o name --noheadings -j %M -m %m", RESULT=="?*", SYMLINK+="disk/by-scsid/%c/mapper"
ACTION=="change", PROGRAM!="/sbin/dmsetup info -c --noheadings -j %M -m %m", GOTO="end_mpath"
PROGRAM!="/sbin/dmsetup info -c -o uuid,name --separator ' ' --noheadings -j %M -m %m", GOTO="end_mpath"
RESULT!="mpath-*", GOTO="end_mpath"
LABEL="count_mpath"
ACTION=="change", RUN+="/opt/xensource/libexec/kickpipe mpathcount"
LABEL="end_mpath"

0 comments on commit 6ac9ef6

Please sign in to comment.