Expand HAMMER filesystem stubs
authorMichael Neumann <mneumann@ntecs.de>
Mon, 13 Jul 2009 21:40:38 +0000 (23:40 +0200)
committerMichael Neumann <mneumann@ntecs.de>
Mon, 13 Jul 2009 21:40:38 +0000 (23:40 +0200)
sbin/hammer/Makefile
sbin/hammer/cmd_expand.c [new file with mode: 0644]
sbin/hammer/hammer.c
sbin/hammer/hammer.h
sys/conf/files
sys/vfs/hammer/Makefile
sys/vfs/hammer/hammer.h
sys/vfs/hammer/hammer_expand.c [new file with mode: 0644]
sys/vfs/hammer/hammer_ioctl.c
sys/vfs/hammer/hammer_ioctl.h

index 9900c41..32ae468 100644 (file)
@@ -7,7 +7,7 @@ SRCS=   hammer.c ondisk.c blockmap.c cache.c misc.c cycle.c \
        cmd_blockmap.c cmd_reblock.c cmd_rebalance.c \
        cmd_synctid.c cmd_stats.c \
        cmd_pseudofs.c cmd_snapshot.c cmd_mirror.c cmd_status.c \
-       cmd_cleanup.c cmd_info.c cmd_version.c
+       cmd_cleanup.c cmd_info.c cmd_version.c cmd_expand.c
 MAN=   hammer.8
 
 CFLAGS+= -I${.CURDIR}/../../sys -DALIST_NO_DEBUG
diff --git a/sbin/hammer/cmd_expand.c b/sbin/hammer/cmd_expand.c
new file mode 100644 (file)
index 0000000..c642566
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2009 The DragonFly Project.  All rights reserved.
+ *
+ * This code is derived from software contributed to The DragonFly Project
+ * by Michael Neumann <mneumann@ntecs.de>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name of The DragonFly Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific, prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+/*
+ * Expand a HAMMER filesystem.
+ */
+
+#include "hammer.h"
+#include <string.h>
+
+static void expand_usage(int exit_code);
+
+/*
+ * expand <filesystem> <device>
+ */
+void
+hammer_cmd_expand(char **av, int ac)
+{
+       struct hammer_ioc_expand expand;
+       int fd;
+
+       if (ac != 2)
+               expand_usage(1);
+        fd = open(av[0], O_RDONLY);
+       if (fd < 0) {
+               fprintf(stderr, "hammer expand: unable to access %s: %s\n",
+                       av[0], strerror(errno));
+               exit(1);
+       }
+
+       bzero(&expand, sizeof(expand));
+       strncpy(expand.device_name, av[1], MAXPATHLEN);
+
+       if (ioctl(fd, HAMMERIOC_EXPAND, &expand) < 0) {
+               fprintf(stderr, "hammer expand ioctl: %s\n", strerror(errno));
+               exit(1);
+       }
+
+       close(fd);
+}
+
+static
+void
+expand_usage(int exit_code)
+{
+       fprintf(stderr, "hammer expand <filesystem> <device>\n");
+       exit(exit_code);
+}
index 18e3333..17eb81a 100644 (file)
@@ -356,6 +356,10 @@ main(int ac, char **av)
                hammer_cmd_set_version(av + 1, ac - 1);
                exit(0);
        }
+       if (strcmp(av[0], "expand") == 0) {
+               hammer_cmd_expand(av + 1, ac - 1);
+               exit(0);
+       }
 
        uuid_name_lookup(&Hammer_FSType, "DragonFly HAMMER", &status);
        if (status != uuid_s_ok) {
@@ -463,6 +467,7 @@ usage(int exit_code)
                                    " [[user@]host:]<filesystem>\n"
                "hammer version <filesystem>\n"
                "hammer version-upgrade <filesystem> version# [force]\n"
+               "hammer expand <filesystem> <device>\n"
        );
        exit(exit_code);
 }
index 4d05a1c..d055888 100644 (file)
@@ -100,6 +100,7 @@ void hammer_cmd_cleanup(char **av, int ac);
 void hammer_cmd_info(int ac);
 void hammer_cmd_get_version(char **av, int ac);
 void hammer_cmd_set_version(char **av, int ac);
+void hammer_cmd_expand(char **av, int ac);
 
 void hammer_get_cycle(hammer_base_elm_t base, hammer_tid_t *tidp);
 void hammer_set_cycle(hammer_base_elm_t base, hammer_tid_t tid);
index fcda4c5..b972bc0 100644 (file)
@@ -1380,6 +1380,7 @@ vfs/userfs/userfs_elms.c  optional userfs
 vfs/hammer/hammer_blockmap.c   optional hammer
 vfs/hammer/hammer_btree.c      optional hammer
 vfs/hammer/hammer_cursor.c     optional hammer
+vfs/hammer/hammer_expand.c     optional hammer
 vfs/hammer/hammer_flusher.c    optional hammer
 vfs/hammer/hammer_freemap.c    optional hammer
 vfs/hammer/hammer_inode.c      optional hammer
index b687619..f40e0dc 100644 (file)
@@ -9,7 +9,7 @@ SRCS=   hammer_vfsops.c hammer_vnops.c hammer_inode.c \
        hammer_blockmap.c hammer_freemap.c hammer_undo.c \
        hammer_reblock.c hammer_rebalance.c \
        hammer_flusher.c hammer_mirror.c \
-       hammer_pfs.c hammer_prune.c
+       hammer_pfs.c hammer_prune.c hammer_expand.c
 SRCS+= opt_ktr.h
 
 .include <bsd.kmod.mk>
index 0092fbc..1c6c441 100644 (file)
@@ -1209,6 +1209,8 @@ int hammer_ioc_upgrade_pseudofs(hammer_transaction_t trans, hammer_inode_t ip,
                         struct hammer_ioc_pseudofs_rw *pfs);
 int hammer_ioc_wait_pseudofs(hammer_transaction_t trans, hammer_inode_t ip,
                         struct hammer_ioc_pseudofs_rw *pfs);
+int hammer_ioc_expand(hammer_transaction_t trans, hammer_inode_t ip,
+                        struct hammer_ioc_expand *expand);
 
 int hammer_signal_check(hammer_mount_t hmp);
 
diff --git a/sys/vfs/hammer/hammer_expand.c b/sys/vfs/hammer/hammer_expand.c
new file mode 100644 (file)
index 0000000..10adf05
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2009 The DragonFly Project.  All rights reserved.
+ *
+ * This code is derived from software contributed to The DragonFly Project
+ * by Michael Neumann <mneumann@ntecs.de>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name of The DragonFly Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific, prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include "hammer.h"
+
+int
+hammer_ioc_expand(hammer_transaction_t trans, hammer_inode_t ip,
+               struct hammer_ioc_expand *expand)
+{
+       kprintf("hammer expand, device: %s\n", expand->device_name);
+       return 0;
+}
index 91ef547..db8c060 100644 (file)
@@ -149,6 +149,13 @@ hammer_ioctl(hammer_inode_t ip, u_long com, caddr_t data, int fflag,
                                            (struct hammer_ioc_version *)data);
                }
                break;
+       case HAMMERIOC_EXPAND:
+               if (error == 0) {
+                       error = hammer_ioc_expand(&trans, ip,
+                                           (struct hammer_ioc_expand *)data);
+               }
+               break;
+
        default:
                error = EOPNOTSUPP;
                break;
index 1bb8fb3..9d5867d 100644 (file)
@@ -335,6 +335,11 @@ struct hammer_ioc_version {
        char                    description[64];
 };
 
+struct hammer_ioc_expand {
+       struct hammer_ioc_head head;
+       char                    device_name[MAXPATHLEN];
+};
+
 union hammer_ioc_mrecord_any {
        struct hammer_ioc_mrecord_head  head;
        struct hammer_ioc_mrecord_rec   rec;
@@ -400,6 +405,7 @@ typedef union hammer_ioc_mrecord_any *hammer_ioc_mrecord_any_t;
 #define HAMMERIOC_SET_VERSION  _IOWR('h',14,struct hammer_ioc_version)
 #define HAMMERIOC_REBALANCE    _IOWR('h',15,struct hammer_ioc_rebalance)
 #define HAMMERIOC_GET_INFO     _IOR('h',16,struct hammer_ioc_info)
+#define HAMMERIOC_EXPAND       _IOWR('h',17,struct hammer_ioc_expand)
 
 #endif