#define LL_COMMITCBD_RUNNING 0x4
struct ll_sb_info {
+ unsigned char ll_sb_uuid[37];
struct lustre_handle ll_mdc_conn;
struct lustre_handle ll_osc_conn;
obd_id ll_rootino; /* number of root inode */
extern void obd_sysctl_init (void);
extern void obd_sysctl_clean (void);
+/* uuid.c */
+/* XXX - should use uuid_t here, but already defined as char[37] */
+typedef unsigned char class_uuid_t[16];
+int class_uuid_parse(char *in, class_uuid_t out);
+void class_uuid_unparse(class_uuid_t in, char *out);
#endif /* __LINUX_CLASS_OBD_H */
oa->o_mode = S_IFREG | 0600;
oa->o_easize = mdc->cl_max_mdsize;
oa->o_valid = OBD_MD_FLMODE | OBD_MD_FLEASIZE;
+ oa->o_id = inode->i_ino;
rc = obd_create(ll_i2obdconn(inode), oa, &lli->lli_smd);
if (rc) {
obdo_free(oa);
#define DEBUG_SUBSYSTEM S_LLITE
#include <linux/module.h>
+#include <linux/random.h>
#include <linux/lustre_lite.h>
#include <linux/lustre_ha.h>
#include <linux/lustre_dlm.h>
__u32 last_xid;
struct ptlrpc_request *request = NULL;
struct ll_inode_md md;
+ class_uuid_t uuid;
ENTRY;
MOD_INC_USE_COUNT;
RETURN(NULL);
}
+ generate_random_uuid(uuid);
+ class_uuid_unparse(uuid, sbi->ll_sb_uuid);
+
sb->u.generic_sbp = sbi;
ll_options(data, &osc, &mdc);
}
#endif
-#warning shaver: might need a cluuid here
- err = obd_connect(&sbi->ll_mdc_conn, obd, NULL);
+ err = obd_connect(&sbi->ll_mdc_conn, obd, sbi->ll_sb_uuid);
if (err) {
CERROR("cannot connect to %s: rc = %d\n", mdc, err);
GOTO(out_free, sb = NULL);
CERROR("OSC %s: not setup or attached\n", osc);
GOTO(out_mdc, sb = NULL);
}
-#warning shaver: might need a cluuid here
- err = obd_connect(&sbi->ll_osc_conn, obd, NULL);
+ err = obd_connect(&sbi->ll_osc_conn, obd, sbi->ll_sb_uuid);
if (err) {
CERROR("cannot connect to %s: rc = %d\n", osc, err);
GOTO(out_mdc, sb = NULL);
oa->o_easize = lov_stripe_md_size(export->exp_obd);
if (!*ea) {
- OBD_ALLOC(*ea, oa->o_easize);
+ OBD_ALLOC(*ea, oa->o_easize);
if (! *ea)
RETURN(-ENOMEM);
}
static int lov_open(struct lustre_handle *conn, struct obdo *oa,
struct lov_stripe_md *md)
{
- int rc = 0, i;
+ int rc = 0, rc2 = 0, i;
struct obdo tmp;
struct obd_export *export = class_conn2export(conn);
struct lov_obd *lov;
rc = obd_open(&lov->tgts[i].conn, &tmp, NULL);
if (rc) {
+ rc2 = rc;
CERROR("Error getattr object %Ld on %d\n",
oa->o_id, i);
}
}
- RETURN(rc);
+ RETURN(rc2);
}
memcpy(desc, lustre_msg_buf(req->rq_repmsg, 0), sizeof(*desc));
*uuids = lustre_msg_buf(req->rq_repmsg, 1);
lov_unpackdesc(desc);
+ mdc->cl_max_mdsize = sizeof(struct lov_stripe_md) +
+ desc->ld_tgt_count * sizeof(struct lov_object_id);
}
- mdc->cl_max_mdsize = sizeof(*desc) +
- desc->ld_tgt_count * sizeof(uuid_t);
EXIT;
out:
RETURN(0);
}
- mds->mds_max_mdsize = sizeof(desc) + tgt_count * sizeof(uuid_t);
+ mds->mds_max_mdsize = sizeof(struct lov_stripe_md) +
+ tgt_count * sizeof(struct lov_object_id);
rc = mds_get_lovtgts(req->rq_obd, tgt_count,
lustre_msg_buf(req->rq_repmsg, 1));
if (rc) {
MODULE = obdclass
modulefs_DATA = obdclass.o
EXTRA_PROGRAMS = obdclass
-obdclass_SOURCES = genops.c proc_lustre.c class_obd.c sysctl.c page.c
+obdclass_SOURCES = genops.c proc_lustre.c class_obd.c sysctl.c page.c uuid.c
page.c:
test -e page.c || ln -sf $(top_srcdir)/lib/page.c
}
case OBD_IOC_CONNECT: {
+ char * cluuid = "OBD_CLASS_UUID";
obd_data2conn(&conn, data);
- err = obd_connect(&conn, obd, NULL);
+ err = obd_connect(&conn, obd, cluuid);
CDEBUG(D_IOCTL, "assigned export %Lx\n", conn.addr);
obd_conn2data(data, &conn);
EXPORT_SYMBOL(class_conn2obd);
EXPORT_SYMBOL(class_disconnect);
EXPORT_SYMBOL(class_disconnect_all);
+EXPORT_SYMBOL(class_uuid_parse);
+EXPORT_SYMBOL(class_uuid_unparse);
//EXPORT_SYMBOL(class_multi_setup);
//EXPORT_SYMBOL(class_multi_cleanup);
--- /dev/null
+/*
+ * Public include file for the UUID library
+ *
+ * Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
+ * Copyright (C) 2002 Cluster File System
+ * - changed for use in lustre
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU
+ * Library General Public License.
+ * %End-Header%
+ */
+#include <linux/ctype.h>
+#include <linux/kernel.h>
+
+#define DEBUG_SUBSYSTEM S_CLASS
+
+#include <linux/obd_support.h>
+#include <linux/obd_class.h>
+#include <linux/smp_lock.h>
+
+struct uuid {
+ __u32 time_low;
+ __u16 time_mid;
+ __u16 time_hi_and_version;
+ __u16 clock_seq;
+ __u8 node[6];
+};
+
+static void uuid_unpack(class_uuid_t in, struct uuid *uu)
+{
+ __u8 *ptr = in;
+ __u32 tmp;
+
+ tmp = *ptr++;
+ tmp = (tmp << 8) | *ptr++;
+ tmp = (tmp << 8) | *ptr++;
+ tmp = (tmp << 8) | *ptr++;
+ uu->time_low = tmp;
+
+ tmp = *ptr++;
+ tmp = (tmp << 8) | *ptr++;
+ uu->time_mid = tmp;
+
+ tmp = *ptr++;
+ tmp = (tmp << 8) | *ptr++;
+ uu->time_hi_and_version = tmp;
+
+ tmp = *ptr++;
+ tmp = (tmp << 8) | *ptr++;
+ uu->clock_seq = tmp;
+
+ memcpy(uu->node, ptr, 6);
+}
+
+static void uuid_pack(struct uuid *uu, class_uuid_t ptr)
+{
+ __u32 tmp;
+ unsigned char *out = ptr;
+
+ tmp = uu->time_low;
+ out[3] = (unsigned char) tmp;
+ tmp >>= 8;
+ out[2] = (unsigned char) tmp;
+ tmp >>= 8;
+ out[1] = (unsigned char) tmp;
+ tmp >>= 8;
+ out[0] = (unsigned char) tmp;
+
+ tmp = uu->time_mid;
+ out[5] = (unsigned char) tmp;
+ tmp >>= 8;
+ out[4] = (unsigned char) tmp;
+
+ tmp = uu->time_hi_and_version;
+ out[7] = (unsigned char) tmp;
+ tmp >>= 8;
+ out[6] = (unsigned char) tmp;
+
+ tmp = uu->clock_seq;
+ out[9] = (unsigned char) tmp;
+ tmp >>= 8;
+ out[8] = (unsigned char) tmp;
+
+ memcpy(out+10, uu->node, 6);
+}
+
+int class_uuid_parse(char *in, class_uuid_t uu)
+{
+ struct uuid uuid;
+ int i;
+ char *cp, buf[3];
+
+ if (strlen(in) != 36)
+ return -1;
+ for (i=0, cp = in; i <= 36; i++,cp++) {
+ if ((i == 8) || (i == 13) || (i == 18) ||
+ (i == 23))
+ if (*cp == '-')
+ continue;
+ if (i== 36)
+ if (*cp == 0)
+ continue;
+ if (!isxdigit(*cp))
+ return -1;
+ }
+ uuid.time_low = simple_strtoul(in, NULL, 16);
+ uuid.time_mid = simple_strtoul(in+9, NULL, 16);
+ uuid.time_hi_and_version = simple_strtoul(in+14, NULL, 16);
+ uuid.clock_seq = simple_strtoul(in+19, NULL, 16);
+ cp = in+24;
+ buf[2] = 0;
+ for (i=0; i < 6; i++) {
+ buf[0] = *cp++;
+ buf[1] = *cp++;
+ uuid.node[i] = simple_strtoul(buf, NULL, 16);
+ }
+
+ uuid_pack(&uuid, uu);
+ return 0;
+}
+
+void class_uuid_unparse(class_uuid_t uu, char *out)
+{
+ struct uuid uuid;
+
+ uuid_unpack(uu, &uuid);
+ sprintf(out,
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ uuid.time_low, uuid.time_mid, uuid.time_hi_and_version,
+ uuid.clock_seq >> 8, uuid.clock_seq & 0xFF,
+ uuid.node[0], uuid.node[1], uuid.node[2],
+ uuid.node[3], uuid.node[4], uuid.node[5]);
+}
-<?xml version="1.0"?>
-<!DOCTYPE lustre SYSTEM "../utils/lustre.dtd">
-
+<?xml version='1.0' encoding='UTF-8'?>
<lustre>
- <node name="localhost" uuid="localhost-UUID">
- <network type='tcp' name='net' uuid="net-UUID" >
- <server>localhost</server>
- <port>2432</port>
+ <ldlm name='ldlm' uuid='ldlm_UUID'/>
+ <node name='localhost' uuid='localhost_UUID'>
+ <profile>
+ <ldlm_ref uuidref='ldlm_UUID'/>
+ <network_ref uuidref='NET_localhost_tcp_UUID'/>
+ <mds_ref uuidref='mds1_UUID'/>
+ <lov_ref uuidref='lov1_UUID'/>
+ <obd_ref uuidref='OBD_localhost_UUID'/>
+ <ost_ref uuidref='OST_localhost_UUID'/>
+ <obd_ref uuidref='OBD_localhost_2_UUID'/>
+ <ost_ref uuidref='OST_localhost_2_UUID'/>
+ <mountpoint_ref uuidref='MNT_localhost_UUID'/>
+ <mdc_ref uuidref='MDC_mds1_UUID'/>
+ </profile>
+ <network name='NET_localhost_tcp' uuid='NET_localhost_tcp_UUID' type='tcp'>
+ <server>uml1</server>
+ <port>888</port>
</network>
- <profile_ref uuidref="local-profile-UUID"/>
</node>
-
- <profile name="local-profile" uuid="local-profile-UUID">
- <service_ref uuidref="net-UUID"/>
- <service_ref uuidref="ldlm-srv-UUID"/>
- <service_ref uuidref="lov1-UUID"/>
- <service_ref uuidref="mtpt1-UUID"/>
- <service_ref uuidref="mdc1-UUID"/>
- <service_ref uuidref="mds-UUID"/>
- <service_ref uuidref="obd1-UUID"/>
- <service_ref uuidref="obd2-UUID"/>
- <service_ref uuidref="ost1-UUID"/>
- <service_ref uuidref="ost2-UUID"/>
- <service_ref uuidref="osc1-UUID"/>
- <service_ref uuidref="osc2-UUID"/>
- </profile>
-
- <ldlm name="ldlm-srv" uuid="ldlm-srv-UUID"/>
-
- <lov name="lov1" uuid="lov1-UUID">
- <mdc_ref uuidref="mdc1-UUID"/>
- <devices stripesize="65536" stripeoffset="0" pattern="0">
- <osc_ref uuidref="osc1-UUID"/>
- <osc_ref uuidref="osc2-UUID"/>
- </devices>
- </lov>
-
- <mdc name="mdc1" uuid="mdc1-UUID">
- <network_ref name='net' uuidref='net-UUID'/>
- <mds_ref uuidref="mds-UUID"/>
- </mdc>
-
- <mds name="mds" uuid="mds-UUID">
- <network_ref name='net-local' uuidref="net-local-UUID"/>
+ <mds name='mds1' uuid='mds1_UUID'>
<fstype>extN</fstype>
- <device size="50000">/tmp/mds</device>
+ <device size='50000'>/tmp/mds1</device>
<autoformat>yes</autoformat>
+ <network_ref uuidref='NET_localhost_tcp_UUID'/>
+ <node_ref uuidref='localhost_UUID'/>
</mds>
-
- <osc name="osc1" uuid="osc1-UUID">
- <network_ref name='net' uuidref='net-UUID'/>
- <obd_ref uuidref="obd1-UUID"/>
- </osc>
-
- <osc name="osc2" uuid="osc2-UUID">
- <network_ref name='net' uuidref='net-UUID'/>
- <obd_ref uuidref="obd2-UUID"/>
- </osc>
-
- <ost name="ost1" uuid="ost1-UUID">
- <network_ref name='net' uuidref='net-UUID'/>
- <obd_ref uuidref='obd1-UUID'/>
- </ost>
-
- <ost name="ost2" uuid="ost2-UUID">
- <network_ref name='net' uuidref='net-UUID'/>
- <obd_ref uuidref='obd2-UUID'/>
- </ost>
-
- <obd name="obd1" uuid="obd1-UUID" type="obdfilter">
+ <mdc name='MDC_mds1' uuid='MDC_mds1_UUID'>
+ <mds_ref uuidref='mds1_UUID'/>
+ </mdc>
+ <lov name='lov1' uuid='lov1_UUID'>
+ <mds_ref uuidref='mds1_UUID'/>
+ <devices stripeoffset='0' stripesize='4096' pattern='0'>
+ <osc_ref uuidref='OSC_localhost_UUID'/>
+ <osc_ref uuidref='OSC_localhost_2_UUID'/>
+ </devices>
+ </lov>
+ <obd uuid='OBD_localhost_UUID' name='OBD_localhost' type='obdfilter'>
<fstype>extN</fstype>
- <device size="100000">/tmp/obd1</device>
+ <device size='100000'>/tmp/ost1</device>
<autoformat>yes</autoformat>
</obd>
-
- <obd name="obd2" uuid="obd2-UUID" type="obdfilter">
+ <osc name='OSC_localhost' uuid='OSC_localhost_UUID'>
+ <ost_ref uuidref='OST_localhost_UUID'/>
+ <obd_ref uuidref='OBD_localhost_UUID'/>
+ </osc>
+ <ost name='OST_localhost' uuid='OST_localhost_UUID'>
+ <network_ref uuidref='NET_localhost_tcp_UUID'/>
+ <obd_ref uuidref='OBD_localhost_UUID'/>
+ </ost>
+ <obd name='OBD_localhost_2' uuid='OBD_localhost_2_UUID' type='obdfilter'>
<fstype>extN</fstype>
- <device size="100000">/tmp/obd2</device>
+ <device size='100000'>/tmp/ost2</device>
<autoformat>yes</autoformat>
</obd>
-
- <mountpoint name="mtpt1" uuid="mtpt1-UUID">
+ <osc name='OSC_localhost_2' uuid='OSC_localhost_2_UUID'>
+ <ost_ref uuidref='OST_localhost_2_UUID'/>
+ <obd_ref uuidref='OBD_localhost_2_UUID'/>
+ </osc>
+ <ost name='OST_localhost_2' uuid='OST_localhost_2_UUID'>
+ <network_ref uuidref='NET_localhost_tcp_UUID'/>
+ <obd_ref uuidref='OBD_localhost_2_UUID'/>
+ </ost>
+ <mountpoint name='MNT_localhost' uuid='MNT_localhost_UUID'>
+ <mdc_ref uuidref='MDC_mds1_UUID'/>
+ <osc_ref uuidref='lov1_UUID'/>
<path>/mnt/lustre</path>
- <mdc_ref uuidref="mdc1-UUID"/>
- <osc_ref uuidref="lov1-UUID"/>
</mountpoint>
-
</lustre>
import xml.dom.minidom
# Global parameters
-TCP_ACCEPTOR = '../..//portals/linux/utils/acceptor'
+TCP_ACCEPTOR = ''
options = {}
#
"""
Initialize close by finding the lctl binary.
"""
- syspath = string.split(os.environ['PATH'], ':')
- syspath.insert(0, "../utils");
- self.lctlcmd = None
- for d in syspath:
- lctl = os.path.join(d,cmd)
- if os.access(lctl, os.X_OK):
- self.lctl = lctl
- break
+ self.lctl = find_prog(cmd)
if not self.lctl:
raise RuntimeError, "unable to find lctl binary."
return ret
+# Determine full path to use for an external command
+# searches dirname(argv[0]) first, then PATH
+def find_prog(cmd):
+ syspath = string.split(os.environ['PATH'], ':')
+ cmdpath = os.path.dirname(sys.argv[0])
+ syspath.insert(0, cmdpath);
+ syspath.insert(0, os.path.join(cmdpath, '../../portals/linux/utils/'))
+ for d in syspath:
+ prog = os.path.join(d,cmd)
+ if os.access(prog, os.X_OK):
+ return prog
+ return ''
+
+
# is the path a block device?
def is_block(path):
s = ()
(ret, out) = run (mkfs, force, dev)
if ret:
panic("Unable to build fs:", dev)
+ # enable hash tree indexing on fs
+ if fstype == 'extN':
+ htree = 'echo "feature FEATURE_C5" | debugfs -w'
+ (ret, out) = run (htree, dev)
+ if ret:
+ panic("Unable to enable htree:", dev)
# some systems use /dev/loopN, some /dev/loop/N
def loop_base():
for child in devs.childNodes:
if child.nodeName == 'osc_ref':
devlist = devlist + child.getAttribute('uuidref') + " "
- strip_cnt = stripe_cnt + 1
+ stripe_cnt = stripe_cnt + 1
self.devlist = devlist
- self.stripe_cnt = strip_cnt
+ self.stripe_cnt = stripe_cnt
def prepare(self):
self.info(self.mdsuuid, self.stripe_cnt, self.stripe_sz, self.stripe_off, self.pattern,
self.stripe_sz, self.stripe_off, self.pattern,
self.devlist)
+ def cleanup(self):
+ pass
+
class MDS(Module):
def __init__(self,node):
Module.__init__(self, 'MDS', node)
#
lctl = LCTLInterface('lctl')
def main():
- global options
+ global options, TCP_ACCEPTOR
+ TCP_ACCEPTOR = find_prog('acceptor')
+ if not TCP_ACCEPTOR:
+ panic('acceptor not found')
args = parse_cmdline(sys.argv[1:])
if len(args) > 0:
if not os.access(args[0], os.R_OK | os.W_OK):
doHost(dom.documentElement, options['hostname'], options.has_key('cleanup') )
if __name__ == "__main__":
- main()
+ try:
+ main()
+ except RuntimeError:
+ pass
+ except CommandError:
+ print '<insert exception data here>'
+ pass
+