Whamcloud - gitweb
LU-1581 utils: osd_read_ldd() wrapper
authorAlex Zhuravlev <bzzz@whamcloud.com>
Tue, 5 Jun 2012 08:40:22 +0000 (12:40 +0400)
committerAndreas Dilger <adilger@whamcloud.com>
Wed, 4 Jul 2012 18:19:39 +0000 (14:19 -0400)
used to fetch mountdata from backend

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I785c43ff95ae3e8faecf9231495529e0d2da8246
Reviewed-on: http://review.whamcloud.com/3221
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Li Wei <liwei@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/utils/mkfs_lustre.c
lustre/utils/mount_utils.c
lustre/utils/mount_utils.h
lustre/utils/mount_utils_ldiskfs.c

index a333ac6..070cb20 100644 (file)
@@ -533,7 +533,7 @@ int main(int argc, char *const argv[])
                 goto out;
         }
 
-        ret = read_local_files(&mop);
+       ret = osd_read_ldd(mop.mo_device, &mop.mo_ldd);
         if (ret) {
                 fatal();
                 fprintf(stderr, "Failed to read previous Lustre data from %s "
index 84e0da3..4fb5ee0 100644 (file)
@@ -376,6 +376,27 @@ int loop_format(struct mkfs_opts *mop)
        return 0;
 }
 
+/* Read the server config files */
+int osd_read_ldd(char *dev, struct lustre_disk_data *ldd)
+{
+       int ret;
+
+       switch (ldd->ldd_mount_type) {
+       case LDD_MT_LDISKFS:
+       case LDD_MT_LDISKFS2:
+               ret = ldiskfs_read_ldd(dev, ldd);
+               break;
+       default:
+               fatal();
+               fprintf(stderr, "unknown fs type %d '%s'\n",
+                       ldd->ldd_mount_type, MT_STR(ldd));
+               ret = EINVAL;
+               break;
+       }
+
+       return ret;
+}
+
 /* Was this device formatted for Lustre */
 int osd_is_lustre(char *dev, unsigned *mount_type)
 {
index cd74d89..498d3ee 100644 (file)
@@ -98,11 +98,13 @@ int loop_setup(struct mkfs_opts *mop);
 int loop_cleanup(struct mkfs_opts *mop);
 
 /* generic target support */
+int osd_read_ldd(char *dev, struct lustre_disk_data *ldd);
 int osd_is_lustre(char *dev, unsigned *mount_type);
 int osd_prepare_lustre(struct mkfs_opts *mop,
                       char *default_mountopts, int default_len,
                       char *always_mountopts, int always_len);
 
+int ldiskfs_read_ldd(char *dev, struct lustre_disk_data *ldd);
 int ldiskfs_is_lustre(char *dev, unsigned *mount_type);
 int ldiskfs_prepare_lustre(struct mkfs_opts *mop,
                           char *default_mountopts, int default_len,
index 097e08e..4321bcb 100644 (file)
@@ -156,12 +156,11 @@ out_rmdir:
        return ret;
 }
 
-int read_local_files(struct mkfs_opts *mop)
+int ldiskfs_read_ldd(char *dev, struct lustre_disk_data *mo_ldd)
 {
        char tmpdir[] = "/tmp/dirXXXXXX";
        char cmd[PATH_MAX];
        char filepnm[128];
-       char *dev;
        FILE *filep;
        int ret = 0;
        int cmdsz = sizeof(cmd);
@@ -173,8 +172,6 @@ int read_local_files(struct mkfs_opts *mop)
                return errno;
        }
 
-       dev = mop->mo_device;
-
        /* TODO: it's worth observing the get_mountdata() function that is
           in mount_utils.c for getting the mountdata out of the
           filesystem */
@@ -193,7 +190,7 @@ int read_local_files(struct mkfs_opts *mop)
        if (filep) {
                size_t num_read;
                vprint("Reading %s\n", MOUNT_DATA_FILE);
-               num_read = fread(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
+               num_read = fread(mo_ldd, sizeof(*mo_ldd), 1, filep);
                if (num_read < 1 && ferror(filep)) {
                        fprintf(stderr, "%s: Unable to read from file %s: %s\n",
                                progname, filepnm, strerror(errno));