summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fsset.py9
-rw-r--r--isys/isys.c33
-rw-r--r--isys/isys.py13
-rw-r--r--lvm.py34
4 files changed, 88 insertions, 1 deletions
diff --git a/fsset.py b/fsset.py
index 082365b2b..884aeb461 100644
--- a/fsset.py
+++ b/fsset.py
@@ -1907,6 +1907,7 @@ class VolumeGroupDevice(Device):
# now make the device into a real physical volume
# XXX I don't really belong here. should
# there be a PhysicalVolumeDevice(PartitionDevice) ?
+ lvm.writeForceConf()
rc = iutil.execWithRedirect("lvm",
["lvm", "pvcreate", "-ff", "-y",
"-v", node],
@@ -1915,11 +1916,15 @@ class VolumeGroupDevice(Device):
searchPath = 1)
if rc:
raise SystemError, "pvcreate failed for %s" % (volume,)
+ lvm.unlinkConf()
+
+ lvm.wipeOtherMetadataFromPV(node)
nodes.append(node)
if not self.isSetup:
# rescan now that we've recreated pvs. ugh.
+ lvm.writeForceConf()
lvm.vgscan()
args = [ "lvm", "vgcreate", "-v", "-An",
@@ -1934,6 +1939,7 @@ class VolumeGroupDevice(Device):
if rc:
raise SystemError, "vgcreate failed for %s" %(self.name,)
+ lvm.unlinkConf()
self.isSetup = 1
else:
lvm.vgscan()
@@ -1964,6 +1970,7 @@ class LogicalVolumeDevice(Device):
def setupDevice(self, chroot="/", devPrefix='/tmp'):
if not self.isSetup:
+ lvm.writeForceConf()
rc = iutil.execWithRedirect("lvm",
["lvm", "lvcreate", "-L",
"%dM" % (self.size,),
@@ -1974,7 +1981,7 @@ class LogicalVolumeDevice(Device):
searchPath = 1)
if rc:
raise SystemError, "lvcreate failed for %s" %(self.name,)
-
+ lvm.unlinkConf()
self.isSetup = 1
return "/dev/%s" % (self.getDevice(),)
diff --git a/isys/isys.c b/isys/isys.c
index 164e5ea2e..c7aa46ebd 100644
--- a/isys/isys.c
+++ b/isys/isys.c
@@ -75,6 +75,7 @@ static PyObject * doLoSetup(PyObject * s, PyObject * args);
static PyObject * doUnLoSetup(PyObject * s, PyObject * args);
static PyObject * doLoChangeFd(PyObject * s, PyObject * args);
static PyObject * doDdFile(PyObject * s, PyObject * args);
+static PyObject * doWipeRaidSuperblock(PyObject * s, PyObject * args);
static PyObject * doGetRaidSuperblock(PyObject * s, PyObject * args);
static PyObject * doGetRaidChunkSize(PyObject * s, PyObject * args);
static PyObject * doDevSpaceFree(PyObject * s, PyObject * args);
@@ -124,6 +125,7 @@ static PyMethodDef isysModuleMethods[] = {
{ "raidstop", (PyCFunction) doRaidStop, METH_VARARGS, NULL },
{ "raidstart", (PyCFunction) doRaidStart, METH_VARARGS, NULL },
{ "getraidsb", (PyCFunction) doGetRaidSuperblock, METH_VARARGS, NULL },
+ { "wiperaidsb", (PyCFunction) doWipeRaidSuperblock, METH_VARARGS, NULL },
{ "getraidchunk", (PyCFunction) doGetRaidChunkSize, METH_VARARGS, NULL },
{ "lochangefd", (PyCFunction) doLoChangeFd, METH_VARARGS, NULL },
{ "losetup", (PyCFunction) doLoSetup, METH_VARARGS, NULL },
@@ -782,6 +784,37 @@ static PyObject * doFbconProbe (PyObject * s, PyObject * args) {
return Py_BuildValue("(iiss)", size, 0, "", "");
}
+static PyObject * doWipeRaidSuperblock(PyObject * s, PyObject * args) {
+ int fd;
+ unsigned long size;
+ struct md_superblock_s * sb;
+
+ if (!PyArg_ParseTuple(args, "i", &fd)) return NULL;
+
+ if (ioctl(fd, BLKGETSIZE, &size)) {
+ PyErr_SetFromErrno(PyExc_SystemError);
+ return NULL;
+ }
+
+ /* put the size in 1k blocks */
+ size >>= 1;
+
+ if (lseek64(fd, ((off64_t) 1024) * (off64_t) MD_NEW_SIZE_BLOCKS(size), SEEK_SET) < 0) {
+ PyErr_SetFromErrno(PyExc_SystemError);
+ return NULL;
+ }
+
+ sb = malloc(sizeof(struct md_superblock_s));
+ sb = memset(sb, '\0', sizeof(struct md_superblock_s));
+
+ if (write(fd, sb, sizeof(sb)) != sizeof(sb)) {
+ PyErr_SetFromErrno(PyExc_SystemError);
+ return NULL;
+ }
+
+ return Py_None;
+}
+
static PyObject * doGetRaidSuperblock(PyObject * s, PyObject * args) {
int fd;
unsigned long size;
diff --git a/isys/isys.py b/isys/isys.py
index 8190359a1..8c09ebf48 100644
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -78,6 +78,19 @@ def raidstart(mdDevice, aMember):
os.close(fd)
os.remove("/tmp/member")
+def wipeRaidSB(device):
+ try:
+ fd = os.open(device, O_WRONLY)
+ except OSError, e:
+ log("error wiping raid device superblock for %s: %s", device, e)
+ return
+
+ try:
+ _isys.wiperaidsb(fd)
+ finally:
+ os.close(fd)
+ return
+
def raidsb(mdDevice):
makeDevInode(mdDevice, "/tmp/md")
return raidsbFromDevice("/tmp/md")
diff --git a/lvm.py b/lvm.py
index 211f7a3e0..f6479b86c 100644
--- a/lvm.py
+++ b/lvm.py
@@ -15,6 +15,7 @@ import iutil
import os,sys
import string
import math
+import isys
from flags import flags
from rhpl.log import log
@@ -226,6 +227,39 @@ def vglist():
return vgs
+# FIXME: this is a hack. we really need to have a --force option.
+def unlinkConf():
+ if os.path.exists("%s/lvm.conf" %(lvmroot,)):
+ os.unlink("%s/lvm.conf" %(lvmroot,))
+
+def writeForceConf():
+ """Write out an /etc/lvm/lvm.conf that doesn't do much (any?) filtering"""
+
+ lvmroot = "/etc/lvm"
+ if not os.path.isdir(lvmroot):
+ os.mkdir(lvmroot)
+
+ unlinkConf()
+
+ f = open("%s/lvm.conf", "w+")
+ f.write("""
+# anaconda hacked lvm.conf to avoid filtering breaking things
+devices = {
+ sysfs_scan = 0
+ md_component_detection = 0
+}
+""")
+
+# FIXME: another hack. we need to wipe the raid metadata since pvcreate
+# doesn't
+def wipeOtherMetadataFromPV(node):
+ try:
+ isys.wipeRaidSB(node)
+ except Exception, e:
+ log("error wiping raidsb from %s: %s", node, e)
+
+
+
def getPossiblePhysicalExtents(floor=0):
"""Returns a list of integers representing the possible values for
the physical extent of a volume group. Value is in KB.