From cc86909db9945799bb97fa3a47bc49d44072bd11 Mon Sep 17 00:00:00 2001 From: rread Date: Fri, 16 Aug 2002 09:30:29 +0000 Subject: [PATCH] - fix mount by adding UUIDs requested by Mike - add HTREE to lconf - fix various brainos in lov --- lustre/include/linux/lustre_lite.h | 1 + lustre/include/linux/obd_class.h | 5 ++ lustre/llite/file.c | 1 + lustre/llite/super.c | 11 +-- lustre/lov/lov_obd.c | 7 +- lustre/mdc/mdc_request.c | 4 +- lustre/mds/handler.c | 3 +- lustre/obdclass/Makefile.am | 2 +- lustre/obdclass/class_obd.c | 5 +- lustre/obdclass/uuid.c | 134 +++++++++++++++++++++++++++++++++++++ lustre/tests/lov.xml | 128 +++++++++++++++-------------------- lustre/utils/lconf | 52 ++++++++++---- 12 files changed, 255 insertions(+), 98 deletions(-) create mode 100644 lustre/obdclass/uuid.c diff --git a/lustre/include/linux/lustre_lite.h b/lustre/include/linux/lustre_lite.h index 02b4c6e..0685699 100644 --- a/lustre/include/linux/lustre_lite.h +++ b/lustre/include/linux/lustre_lite.h @@ -55,6 +55,7 @@ struct ll_inode_info { #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 */ diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index e631078..66b7713 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -725,4 +725,9 @@ extern void (*class_signal_client_failure)(struct ptlrpc_client *); 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 */ diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 7d14d45f..a87dfde 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -63,6 +63,7 @@ static int ll_file_open(struct inode *inode, struct file *file) 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); diff --git a/lustre/llite/super.c b/lustre/llite/super.c index 665ca1d..7d2ac6e 100644 --- a/lustre/llite/super.c +++ b/lustre/llite/super.c @@ -12,6 +12,7 @@ #define DEBUG_SUBSYSTEM S_LLITE #include +#include #include #include #include @@ -90,6 +91,7 @@ static struct super_block * ll_read_super(struct super_block *sb, __u32 last_xid; struct ptlrpc_request *request = NULL; struct ll_inode_md md; + class_uuid_t uuid; ENTRY; MOD_INC_USE_COUNT; @@ -100,6 +102,9 @@ static struct super_block * ll_read_super(struct super_block *sb, RETURN(NULL); } + generate_random_uuid(uuid); + class_uuid_unparse(uuid, sbi->ll_sb_uuid); + sb->u.generic_sbp = sbi; ll_options(data, &osc, &mdc); @@ -128,8 +133,7 @@ static struct super_block * ll_read_super(struct super_block *sb, } #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); @@ -141,8 +145,7 @@ static struct super_block * ll_read_super(struct super_block *sb, 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); diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index ebb225c..296b470 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -208,7 +208,7 @@ static int lov_create(struct lustre_handle *conn, struct obdo *oa, struct lov_st 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); } @@ -357,7 +357,7 @@ static int lov_setattr(struct lustre_handle *conn, struct obdo *oa, 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; @@ -379,11 +379,12 @@ static int lov_open(struct lustre_handle *conn, struct obdo *oa, 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); } diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index ccbfac9..d303a83 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -127,9 +127,9 @@ int mdc_getlovinfo(struct obd_device *obd, struct lustre_handle *mdc_connh, 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: diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index e4448e7..f6b1b15 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -393,7 +393,8 @@ static int mds_getlovinfo(struct ptlrpc_request *req) 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) { diff --git a/lustre/obdclass/Makefile.am b/lustre/obdclass/Makefile.am index 5bf7ba5..bfb8e15 100644 --- a/lustre/obdclass/Makefile.am +++ b/lustre/obdclass/Makefile.am @@ -2,7 +2,7 @@ DEFS= 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 diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 0cd05d3..9da3866 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -399,9 +399,10 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, } 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); @@ -585,6 +586,8 @@ EXPORT_SYMBOL(class_rconn2export); 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); diff --git a/lustre/obdclass/uuid.c b/lustre/obdclass/uuid.c new file mode 100644 index 0000000..bf0da7d --- /dev/null +++ b/lustre/obdclass/uuid.c @@ -0,0 +1,134 @@ +/* + * 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 +#include + +#define DEBUG_SUBSYSTEM S_CLASS + +#include +#include +#include + +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]); +} diff --git a/lustre/tests/lov.xml b/lustre/tests/lov.xml index f636d69..25916ce 100644 --- a/lustre/tests/lov.xml +++ b/lustre/tests/lov.xml @@ -1,88 +1,70 @@ - - - + - - - localhost - 2432 + + + + + + + + + + + + + + + + uml1 + 888 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + extN - /tmp/mds + /tmp/mds1 yes + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + extN - /tmp/obd1 + /tmp/ost1 yes - - + + + + + + + + + extN - /tmp/obd2 + /tmp/ost2 yes - - + + + + + + + + + + + /mnt/lustre - - - diff --git a/lustre/utils/lconf b/lustre/utils/lconf index 1cd2fff..1463b3c 100755 --- a/lustre/utils/lconf +++ b/lustre/utils/lconf @@ -31,7 +31,7 @@ import re, exceptions import xml.dom.minidom # Global parameters -TCP_ACCEPTOR = '../..//portals/linux/utils/acceptor' +TCP_ACCEPTOR = '' options = {} # @@ -108,14 +108,7 @@ class LCTLInterface: """ 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." @@ -247,6 +240,20 @@ def run_daemon(*args): 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 = () @@ -270,6 +277,12 @@ def mkfs(fstype, dev): (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(): @@ -415,9 +428,9 @@ class LOV(Module): 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, @@ -426,6 +439,9 @@ class LOV(Module): 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) @@ -791,7 +807,10 @@ def fetch(url): # 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): @@ -814,4 +833,11 @@ def main(): doHost(dom.documentElement, options['hostname'], options.has_key('cleanup') ) if __name__ == "__main__": - main() + try: + main() + except RuntimeError: + pass + except CommandError: + print '' + pass + -- 1.8.3.1