Whamcloud - gitweb
Branch b1_4_newconfig2
authornathan <nathan>
Fri, 15 Jul 2005 20:00:15 +0000 (20:00 +0000)
committernathan <nathan>
Fri, 15 Jul 2005 20:00:15 +0000 (20:00 +0000)
b=6663
rework mount and mkfs structs to delineate persistent and non-persistent data.

lustre/include/linux/lustre_cfg.h
lustre/include/linux/lustre_disk.h [new file with mode: 0644]
lustre/utils/mkfs_lustre.c
lustre/utils/mount_lustre.c

index 411562f..f2996bc 100644 (file)
@@ -232,23 +232,5 @@ static inline int lustre_cfg_sanity_check(void *buf, int len)
         RETURN(0);
 }
 
-/* Passed by mount */
-#define LMD_FLG_FLOCK  0x0001  /* Enable flock */
-#define LMD_FLG_MNTCNF 0x1000  /* MountConf compat */
-#define LMD_FLG_CLIENT 0x2000  /* Mounting a client only; no real device */
-
-struct lustre_mount_data {
-        uint32_t lmd_magic;
-        uint32_t lmd_flags;         /* mount flags */
-        uint64_t lmd_nid;           /* local nid */
-        char     lmd_mds[64];       /* FIXME to become lmd_mgmt, alt_mgmt */
-        char     lmd_profile[64];   /* FIXME to go away */
-        char     lmd_sv_source[128]; /* server source device */
-/* FIXME below must be determined in the kernel, not passed in from mount */
-        uint32_t lmd_sv_disk_type;  /* server disk type (MDT, OST, MGMT) */
-        char     lmd_sv_fstype[64];    /* server device fs type (ext3, ldiskfs) */
-        char     lmd_sv_fsopts[128];   /* server fs mount opts */
-};
-
 
 #endif // _LUSTRE_CFG_H
diff --git a/lustre/include/linux/lustre_disk.h b/lustre/include/linux/lustre_disk.h
new file mode 100644 (file)
index 0000000..e4d7d78
--- /dev/null
@@ -0,0 +1,139 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
+ *   Author: Nathan Rutman <nathan@clusterfs.com>
+ *   Author: Lin Song Tao <lincent@clusterfs.com>
+ *
+ *   This file is part of Lustre, http://www.lustre.org.
+ *
+ *   Lustre is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2 of the GNU General Public
+ *   License as published by the Free Software Foundation.
+ *
+ *   Lustre is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with Lustre; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ * Lustre disk format definitions.
+ */
+
+#ifndef _LUSTRE_DISK_H
+#define _LUSTRE_DISK_H
+
+#include <linux/types.h>
+
+/****************** last_rcvd file *********************/
+
+#define LAST_RCVD "last_rcvd"
+#define LR_SERVER_SIZE    512
+
+/* Data stored per server at the head of the last_rcvd file.  In le32 order.
+   This should be common to filter_internal.h, lustre_mds.h */
+struct lr_server_data {
+        __u8  lsd_uuid[40];        /* server UUID */
+        __u64 lsd_unused;          /* was lsd_last_objid - don't use for now */
+        __u64 lsd_last_transno;    /* last completed transaction ID */
+        __u64 lsd_mount_count;     /* FILTER incarnation number */
+        __u32 lsd_feature_compat;  /* compatible feature flags */
+        __u32 lsd_feature_rocompat;/* read-only compatible feature flags */
+        __u32 lsd_feature_incompat;/* incompatible feature flags */
+        __u32 lsd_server_size;     /* size of server data area */
+        __u32 lsd_client_start;    /* start of per-client data area */
+        __u16 lsd_client_size;     /* size of per-client data area */
+        __u16 lsd_subdir_count;    /* number of subdirectories for objects */
+        __u64 lsd_catalog_oid;     /* recovery catalog object id */
+        __u32 lsd_catalog_ogen;    /* recovery catalog inode generation */
+        __u8  lsd_peeruuid[40];    /* UUID of MDS associated with this OST */
+        __u32 lsd_index;           /* stripe index */
+        __u8  lsd_padding[LR_SERVER_SIZE - 144];
+};
+
+
+/****************** mount command *********************/
+
+struct host_desc {
+        ptl_nid_t primary; 
+        ptl_nid_t backup;
+};
+
+/* Passed by mount - no persistent info here */
+struct lustre_mount_data {
+        __u32     lmd_magic;
+        __u32     lmd_flags;          /* lustre mount flags */
+        host_desc lmd_mgmt;           /* mgmt nid */
+        char      lmd_dev[128];       /* device or file system name */
+        char      lmd_mtpt[128];      /* mount point (for client overmount) */
+        char      lmd_opts[256];      /* lustre mount options (as opposed to 
+                                         _device_ mount options) */
+};
+
+#define LMD_FLG_FLOCK  0x0001  /* Enable flock */
+#define LMD_FLG_MNTCNF 0x1000  /* MountConf compat */
+#define LMD_FLG_CLIENT 0x2000  /* Mounting a client only; no real device */
+
+#define lmd_is_client(x) \ 
+        ((x->lmd_flags & LMD_FLG_CLIENT) || (!(x->lmd_flags & LMD_FLG_MNTCNF)) 
+
+
+/****************** persistent mount data *********************/
+
+/* Persistent mount data are stored on the disk in this file.
+   Used before the setup llog can be read. */
+#define MOUNT_DATA_FILE "CONFIGS/mountdata"
+
+#define LDD_MAGIC 0xbabb0001
+
+#define LDD_SV_TYPE_MDT 0x0001
+#define LDD_SV_TYPE_OST 0x0002
+#define LDD_SV_TYPE_MGT 0x0004
+
+#define LDD_FS_TYPE_EXT3     1
+#define LDD_FS_TYPE_LDISKFS  2
+#define LDD_FS_TYPE_SMFS     3
+#define LDD_FS_TYPE_REISERFS 4
+        
+struct lustre_disk_data {
+        __u32     ldd_magic;
+        __u32     ldd_flags;
+        host_desc ldd_mgmt;            /* mgmt nid; lmd can override */
+        char      ldd_fsname[64];      /* filesystem this server is part of */
+        char      ldd_svname[64];      /* this server's name (lustre-mdt0001) */
+        __u8      ldd_mount_type;      /* target fs type LDD_FS_TYPE_* */
+        char      ldd_mount_opts[128]; /* target fs mount opts */
+};
+        
+#define IS_MDT(data)  ((data)->ldd_flags & LDD_SV_TYPE_MDT)
+#define IS_OST(data)  ((data)->ldd_flags & LDD_SV_TYPE_OST)
+#define IS_MGT(data)  ((data)->ldd_flags & LDD_SV_TYPE_MGT)
+
+
+/****************** mkfs command *********************/
+
+#define MO_IS_LOOP 0x01
+
+/* used to describe the options to format the lustre disk, not persistent */
+struct mkfs_opts {
+        struct lustre_disk_data mo_ldd; /* to be written in MOUNT_DATA_FILE */
+        int   mo_flags; 
+        int   mo_device_sz;
+        int   mo_journal_sz;
+        int   mo_inode_sz;
+        char  mo_mount_type_string[20]; /* "ext3", "ldiskfs", ... */
+        char  mo_device[128];           /* disk device name */
+        char  mo_mkfsopts[128];         /* options to the backing-store mkfs */
+        int   mo_stripe_sz;
+        int   mo_stripe_count;
+        int   mo_stripe_pattern;
+        /* stripe index will be in lr_server_data for ost's */
+};
+
+
+
+#endif // _LUSTRE_DISK_H
index 669b8a1..2f8ffdd 100644 (file)
@@ -287,7 +287,7 @@ int write_local_files(struct lustre_disk_data *data)
                 return errno;
         }
 
-        if (data->flags & FSFLG_IS_LOOP)
+        if (data->flags & MO_IS_LOOP)
                 sprintf(cmd, "mount -o loop %s %s", data->device, mntpt);
         else
                 sprintf(cmd, "mount -t ext3 %s %s", data->device, mntpt);
@@ -891,7 +891,7 @@ int main(int argc , char *const argv[])
                 return ENOSYS;
 
         if ((data.fs_type == FS_SMFS) || !is_block(data.device)) {
-                data.flags |= FSFLG_IS_LOOP;
+                data.flags |= MO_IS_LOOP;
                 ret = setup_loop_device(&data);
                 if (ret) 
                         return ret;
@@ -916,7 +916,7 @@ int main(int argc , char *const argv[])
         }
 
 out:
-        if (data.flags & FSFLG_IS_LOOP) {
+        if (data.flags & MO_IS_LOOP) {
                 sprintf(cmd, "losetup -d %s", data.device);
                 ret = run_command(cmd, cmd_out);
         }
index 291d29f..5ae3c3b 100644 (file)
@@ -187,28 +187,26 @@ init_options(struct lustre_mount_data *lmd)
         //lmd->lmd_port = 988;    /* XXX define LUSTRE_DEFAULT_PORT */
         //lmd->lmd_nal = SOCKNAL;
         //ptl_parse_ipaddr(&lmd->lmd_ipaddr, lmd->lmd_hostname); 
-        //lmd->u.cli.lmd_async = 0;
         lmd->lmd_magic = LMD_MAGIC;
-        lmd->lmd_nid = PTL_NID_ANY;
+        lmd->lmd_flags = LMD_FLG_MNTCNF;
+        lmd->lmd_mgmt.primary = PTL_NID_ANY;
+        lmd->lmd_mgmt.backup  = PTL_NID_ANY;
         return 0;
 }
 
 int
 print_options(struct lustre_mount_data *lmd)
 {
-        printf("nid:             %s\n", libcfs_nid2str(lmd->lmd_nid));
-        
-        if (lmd_is_client(lmd)) {
+        printf("mgmt primary nid: %s\n", libcfs_nid2str(lmd->lmd_mgmt.primary);
+        printf("mgmt backup nid:  %s\n", libcfs_nid2str(lmd->lmd_mgmt.backup);
+        printf("device:           %s\n", lmd->lmd_dev);
+        printf("mount point:      %s\n", lmd->lmd_mtpt);
+        printf("options:          %s\n", lmd->lmd_opts);
+        printf("flags:            %x\n", lmd->lmd_flags);
+        if (lmd_is_client(lmd)) 
                 printf("CLIENT\n");
-                printf("mds:             %s\n", lmd->u.cli.lmd_mds);
-                printf("profile:         %s\n", lmd->u.cli.lmd_profile);
-        } else {
+        else 
                 printf("SERVER\n");
-                printf("service type:    %x\n", lmd->u.srv.disk_type);
-                printf("device:          %s\n", lmd->u.srv.lmd_source);
-                printf("fs type:         %s\n", lmd->u.srv.lmd_fstype);
-                printf("fs opts:         %s\n", lmd->u.srv.lmd_fsopts);
-        }
 
         return 0;
 }
@@ -294,6 +292,7 @@ int parse_options(char *options, struct lustre_mount_data *lmd, int *flagp)
         return 0;
 }
 
+#if 0
 int read_mount_options(char *source, char *target, 
                        struct lustre_mount_data *lmd)
 {
@@ -349,6 +348,7 @@ out_umnt:
         system(cmd);
         return ret;
 }
+#endif
 
 int
 build_data(char *source, char *target, char *options, 
@@ -356,7 +356,7 @@ build_data(char *source, char *target, char *options,
 {
         char  buf[1024];
         char *nid = NULL;
-        char *mgmt = NULL;
+        char *devname = NULL;
         char *s;
         int   rc;
 
@@ -364,7 +364,7 @@ build_data(char *source, char *target, char *options,
                 return 4;
 
         if (strlen(source) >= sizeof(buf)) {
-                fprintf(stderr, "%s: nid:/fsname argument too long\n",
+                fprintf(stderr, "%s: device name too long\n",
                         progname);
                 return 1;
         }
@@ -374,41 +374,33 @@ build_data(char *source, char *target, char *options,
                 /* Client */
                 if (verbose)
                         printf("CLIENT\n");
-                lmd->lmd_type = 
+                lmd->lmd_flags |= LMD_FLG_CLIENT;
 
+                /* <mgmtnid>[,<alt mgmtnid>]:/fsname[/fsetname[/subdir/]]
+                   nid=mgmtnid, devname=fsname */
                 nid = buf;
                 *s = '\0';
-
-                while (*++s == '/')
-                        ;
-                mgmt = s;
+                while (*++s == '/') ;
+                devname = s;
 
                 rc = parse_options(options, lmd, flagp);
                 if (rc)
                         return rc;
 
-                lmd->lmd_nid = libcfs_str2nid(nid);
-                if (lmd->lmd_nid == PTL_NID_ANY) {
+                if (lmd->lmd_nid != PTL_NID_ANY)
+                        /* In case it was defined as -o mgmtnode= */
+                        lmd->lmd_mgmt.primary = libcfs_str2nid(nid);
+                if (lmd->lmd_mgmt.primary == PTL_NID_ANY) {
                         fprintf(stderr, "%s: can't parse nid '%s'\n",
-                                progname, libcfs_nid2str(lmd->lmd_nid));
+                                progname, nid);
                         return 1;
                 }
-
-                if (strlen(mgmt) + 4 > sizeof(lmd->lmd_mgmt)) {
-                        fprintf(stderr, "%s: mgmt name too long\n", progname);
-                        return(1);
-                }
-                strcpy(lmd->lmd_mds, mgmt);
         } else {
                 /* Server */
                 if (verbose)
                         printf("SERVER\n");
-                lmd->lmd_magic = LMD_SERVER_MAGIC;
 
-                if (strlen(source) + 1 > sizeof(lmd->u.srv.lmd_source)) {
-                        fprintf(stderr, "%s: source name too long\n", progname);
-                        return(1);
-                }
+                devname = source;
 
                 /* We have to keep the loop= option in the mtab file
                    in order for umount to free the loop device. The strtok
@@ -416,17 +408,25 @@ build_data(char *source, char *target, char *options,
                    comma, so we're saving a local copy here. */
                 strcpy(buf, options);
                 rc = parse_options(options, lmd, flagp); 
-                fprintf(stderr, "source = %s \n",lmd->u.srv.lmd_source);
-                print_options(lmd);
                 if (rc)
                         return rc;
                 strcpy(options, buf);
 
-                rc = read_mount_options(source, target, lmd);
-                if (rc)
-                        return rc;
+                // move into lustre: rc = read_mount_options(source, target, lmd);
         }
 
+        if (strlen(devname) + 1 > sizeof(lmd->lmd_dev)) {
+                fprintf(stderr, "%s: device name too long\n", progname);
+                return(1);
+        }
+        strcpy(lmd->lmd_dev, devname);
+
+        if (strlen(target) + 1 > sizeof(lmd->lmd_mtpt)) {
+                fprintf(stderr, "%s: mount point too long\n", progname);
+                return(1);
+        }
+        strcpy(lmd->lmd_mtpt, target);
+        
         if (verbose)
                 print_options(lmd);
         return 0;
@@ -519,11 +519,15 @@ int main(int argc, char *const argv[])
                 return 1;
         }
 
+        /* FIXME remove */
         if ((rc = load_modules(&lmd))) {
                 return rc;
         }
 
         if (!fake)
+                /* flags and target get to lustre_get_sb, but not 
+                   lustre_fill_super.  Lustre ignores the flags, but mount 
+                   does not. */
                 rc = mount(source, target, "lustre", flags, (void *)&lmd);
         if (rc) {
                 fprintf(stderr, "%s: mount(%s, %s) failed: %s\n", source,