Permalink
Browse files

STOR-26 Storage configuration with many disks should create sane RAID…

… groups

STOR-72 storage configuration for log and cache devices
STOR-99 setup must support intelligent pool layout
OS-1467 illumos-live manifest changes are ignored on incremental
  • Loading branch information...
wesolows committed Aug 9, 2012
1 parent ffae024 commit b80860d4174864354648e474ded9cf8a7f2295cf
Showing with 1,406 additions and 17 deletions.
  1. +2 −0 .gitignore
  2. +1 −1 Makefile
  3. +25 −3 src/Makefile
  4. +97 −0 src/disklayout.js
  5. +7 −9 src/img/sbin/imgadm
  6. +6 −1 src/manifest
  7. +39 −0 src/mkzpool.js
  8. +380 −0 src/node_modules/disklayout.js
  9. +304 −0 src/node_modules/getopt.js
  10. +541 −0 src/node_modules/zfs.js
  11. +4 −3 src/vm/node_modules/VM.js
View
@@ -44,6 +44,8 @@ man/man/man1m/imgadm.1m
man/man/man1m/vmadm.1m
man/man/man1m/vmadmd.1m
src/diskinfo
+src/disklayout
+src/mkzpool
src/node-sqlite3/build/
src/node-zsock/.lock-wscript
src/node-zsock/build/
View
@@ -60,7 +60,7 @@ manifest: $(MANIFEST)
$(MPROTO):
mkdir -p $(MPROTO)
-$(MPROTO)/live.manifest: $(MPROTO)
+$(MPROTO)/live.manifest: $(MPROTO) src/manifest
gmake DESTDIR=$(MPROTO) DESTNAME=live.manifest \
-C src manifest
View
@@ -17,6 +17,8 @@ CSTYLE = $(ROOT)/tools/cstyle
#
JSSTYLE_OPTS = -o indent=4,strict-indent=1,doxygen,unparenthesized-return=0,continuation-at-front=1,leading-right-paren-ok=1
+JSSTYLE_OLDSKOOL_OPTS =
+
#
# Installation configuration. Note that DESTDIR in particular is also
# assumed to contain various build tools, headers, libraries, and other
@@ -64,6 +66,11 @@ JS_CHECK_TARGETS=\
img/node_modules/*.js \
img/sbin/imgadm
+JS_CHECK_OLDSKOOL_TARGETS = \
+ disklayout.js \
+ mkzpool.js \
+ node_modules/disklayout.js
+
# These files will get run through cstyle on 'make check'
C_CHECK_TARGETS=\
qemu-exec.c \
@@ -237,8 +244,10 @@ $(ZUTIL_BINDINGS.NODE) : LIBS += -lzonecfg
TARGETS = \
bootparams \
diskinfo \
+ disklayout \
disklist \
disk_size \
+ mkzpool \
removable_disk \
vmunbundle \
zfs_recv \
@@ -326,14 +335,19 @@ check: $(JSLINT)
@printf "\nC files ok!\n"
@printf "\n==> Running JavaScriptLint...\n"
@$(JSLINT) --nologo --conf=$(ROOT)/tools/jsl.node.conf \
- $(JS_CHECK_TARGETS)
+ $(JS_CHECK_TARGETS) $(JS_CHECK_OLDSKOOL_TARGETS)
@printf "\n==> Running jsstyle...\n"
@# jsstyle doesn't echo as it goes so we add an echo to each line below
- @(for file in $(JS_CHECK_TARGETS); do \
+ (for file in $(JS_CHECK_TARGETS); do \
echo $(PWD)/$$file; \
$(JSSTYLE) $(JSSTYLE_OPTS) $$file; \
[[ $$? == "0" ]] || exit 1; \
done)
+ (for file in $(JS_CHECK_OLDSKOOL_TARGETS); do \
+ echo $(PWD)/$$file; \
+ $(JSSTYLE) $(JSSTYLE_OLDSKOOL_OPTS) $$file; \
+ [[ $$? == "0" ]] || exit 1; \
+ done)
@printf "\nJS style ok!\n"
.PHONY: manifest
@@ -358,10 +372,18 @@ include Makefile.targ
# Custom rules for building our various real targets follow. Generic rules
# belong in Makefile.targ.
#
-disklist:
+disklayout: disklayout.js
+ cp disklayout.js disklayout
+ chmod 0755 disklayout
+
+disklist: disklist.sh
cp disklist.sh disklist
chmod 0755 disklist
+mkzpool: mkzpool.js
+ cp mkzpool.js mkzpool
+ chmod 0755 mkzpool
+
sysinfo:
touch sysinfo
View
@@ -0,0 +1,97 @@
+#! /usr/node/0.8/bin/node
+
+/*
+ * Copyright 2012 Joyent, Inc. All rights reserved.
+ */
+
+var fs = require('fs');
+var zfs = require('/usr/node/node_modules/zfs');
+var getopt = require('/usr/node/node_modules/getopt');
+var disklayout = require('/usr/node/node_modules/disklayout');
+
+function
+fatal(msg)
+{
+ console.log('fatal error: ' + msg);
+ process.exit(-1);
+}
+
+function
+usage()
+{
+ console.log('usage: ' + process.argv[0] + ' [-f file] <layout>');
+ console.log('supported layouts:\n\t' +
+ disklayout.list_supported().join('\n\t'));
+ process.exit(-1);
+}
+
+function
+dolayout(disks, layout)
+{
+ var config;
+ var mnttab = fs.readFileSync('/etc/mnttab', 'utf8');
+
+ disks = disks.filter(function (disk) {
+ if (mnttab.search(disk.name) != -1)
+ return (false);
+ return (true);
+ });
+
+ config = disklayout.compute(disks, layout);
+ console.log(JSON.stringify(config, null, '\t'));
+}
+
+var g_layout;
+var opt_f;
+var option;
+var parser = new getopt.BasicParser('f:', process.argv);
+
+while ((option = parser.getopt()) !== undefined && !option.error) {
+ switch (option.option) {
+ case 'f':
+ opt_f = option.optarg;
+ break;
+ default:
+ usage();
+ break;
+ }
+}
+
+if (option && option.error)
+ usage();
+
+g_layout = process.argv[parser.optind()];
+
+if (opt_f) {
+ fs.readFile(opt_f, 'utf8', function (err, data) {
+ var lines;
+ var disks = [];
+
+ if (err)
+ fatal('unable to read ' + opt_f + ': ' + err);
+
+ lines = data.trim().split('\n');
+ lines.forEach(function (line) {
+ if (line) {
+ var row = line.split('\t');
+ disks.push({
+ type: row[0],
+ name: row[1],
+ vid: row[2],
+ pid: row[3],
+ size: row[4],
+ removable: (row[5] === 'yes'),
+ solid_state: (row[6] === 'yes')
+ });
+ }
+ });
+ dolayout(disks, g_layout);
+ });
+} else {
+ zfs.zpool.listDisks(function (err, disks) {
+ if (err) {
+ fatal(err);
+ }
+ dolayout(disks, g_layout);
+ });
+}
View
@@ -85,24 +85,22 @@ var _stdout = function () {
console.log(msg);
};
-_fatal = function() {
+var _fatal = function () {
var args;
var err = arguments[0];
if (err instanceof Error) {
- args = [err.message + '\n' + "stack:\n" + err.stack + '\n'];
- }
- else if (Array.isArray(err)) {
- args = [ "\n" + err.join("\n") ];
- }
- else {
+ args = [err.message + '\nstack:\n' + err.stack + '\n'];
+ } else if (Array.isArray(err)) {
+ args = [ '\n' + err.join('\n') ];
+ } else {
args = Array.prototype.slice.apply(arguments, [ 0 ]);
}
- var msg = "Error: " + sprintf.apply(null, args) + '\n';
+ var msg = 'Error: ' + sprintf.apply(null, args) + '\n';
process.stderr.write(msg);
process.exit(1);
-}
+};
var _isUuid = function (obj) {
var uuidReg =
View
@@ -124,14 +124,18 @@ f smartdc/bin/qemu-exec 0555 root bin
f usr/bin/sysinfo 0555 root bin
f usr/bin/bootparams 0555 root bin
f usr/bin/diskinfo 0555 root bin
+f usr/bin/disklayout 0555 root bin
f usr/bin/disklist 0555 root bin
-f usr/bin/removable_disk 0555 root bin
f usr/bin/disk_size 0555 root bin
+f usr/bin/removable_disk 0555 root bin
+f usr/bin/mkzpool 0555 root bin
s usr/sbin/vmadm=../vm/sbin/vmadm
d usr/node 0555 root bin
d usr/node/0.8 0555 root bin
d usr/node/0.8/node_modules 0555 root bin
f usr/node/0.8/node_modules/async.js 0444 root bin
+f usr/node/0.8/node_modules/disklayout.js 0444 root bin
+f usr/node/0.8/node_modules/getopt.js 0444 root bin
f usr/node/0.8/node_modules/kstat.node 0444 root bin
f usr/node/0.8/node_modules/onlyif.js 0444 root bin
f usr/node/0.8/node_modules/sprintf.js 0444 root bin
@@ -140,6 +144,7 @@ f usr/node/0.8/node_modules/sqlite3_trace.js 0444 root bin
f usr/node/0.8/node_modules/node_sqlite3.node 0444 root bin
f usr/node/0.8/node_modules/syslog.node 0444 root bin
f usr/node/0.8/node_modules/system.js 0444 root bin
+f usr/node/0.8/node_modules/zfs.js 0444 root bin
d usr/node/0.8/node_modules/log4js 0555 root bin
f usr/node/0.8/node_modules/log4js/package.json 0444 root bin
d usr/node/0.8/node_modules/log4js/lib 0555 root bin
View
@@ -0,0 +1,39 @@
+#! /usr/node/0.8/bin/node
+
+/*
+ * Copyright 2012 Joyent, Inc. All rights reserved.
+ */
+
+var fs = require('fs');
+var zfs = require('/usr/node/node_modules/zfs');
+
+function
+fatal(msg)
+{
+ console.log('fatal error: ' + msg);
+ process.exit(-1);
+}
+
+function
+usage()
+{
+ console.log('usage: ' + process.argv[0] + ' <pool> <file.json>');
+ process.exit(-1);
+}
+
+var json;
+var config;
+var pool;
+
+if (!process.argv[2] || !process.argv[3])
+ usage();
+
+pool = process.argv[2];
+json = fs.readFileSync(process.argv[3], 'utf8');
+config = JSON.parse(json);
+
+zfs.zpool.createExtended(pool, config, function (err) {
+ if (err) {
+ fatal('pool creation failed: ' + err);
+ }
+});
Oops, something went wrong.

0 comments on commit b80860d

Please sign in to comment.