Whamcloud - gitweb
LU-1581 utils: introduce osd_is_lustre() wrapper
authorAlex Zhuravlev <bzzz@whamcloud.com>
Tue, 5 Jun 2012 07:55:36 +0000 (11:55 +0400)
committerAndreas Dilger <adilger@whamcloud.com>
Wed, 4 Jul 2012 05:15:15 +0000 (01:15 -0400)
the purpose of that is to verify whether underlying device
can be used for lustre and identify backend filesystem

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: Ie95cf8b88811be12feb4af67e15ff26ecae9a447
Reviewed-on: http://review.whamcloud.com/3220
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 27fdad3..a333ac6 100644 (file)
@@ -500,6 +500,7 @@ int main(int argc, char *const argv[])
         char *mountopts = NULL;
         char always_mountopts[512] = "";
         char default_mountopts[512] = "";
+       unsigned mount_type;
         int ret = 0;
 
         if ((progname = strrchr(argv[0], '/')) != NULL)
@@ -523,7 +524,7 @@ int main(int argc, char *const argv[])
            new ones. */
 
         /* Check whether the disk has already been formatted by mkfs.lustre */
-        ret = is_lustre_target(&mop);
+       ret = osd_is_lustre(mop.mo_device, &mount_type);
         if (ret == 0) {
                 fatal();
                 fprintf(stderr, "Device %s has not been formatted with "
@@ -665,7 +666,7 @@ int main(int argc, char *const argv[])
 #ifndef TUNEFS /* mkfs.lustre */
         /* Check whether the disk has already been formatted by mkfs.lustre */
         if (!(mop.mo_flags & MO_FORCEFORMAT)) {
-                ret = is_lustre_target(&mop);
+               ret = osd_is_lustre(mop.mo_device, &mount_type);
                 if (ret) {
                         fatal();
                         fprintf(stderr, "Device %s was previously formatted "
index 4d9c93c..84e0da3 100644 (file)
@@ -376,6 +376,20 @@ int loop_format(struct mkfs_opts *mop)
        return 0;
 }
 
+/* Was this device formatted for Lustre */
+int osd_is_lustre(char *dev, unsigned *mount_type)
+{
+       vprint("checking for existing Lustre data: ");
+
+       if (ldiskfs_is_lustre(dev, mount_type)) {
+               vprint("found\n");
+               return 1;
+       }
+
+       vprint("not found\n");
+       return 0;
+}
+
 int osd_prepare_lustre(struct mkfs_opts *mop,
                char *default_mountopts, int default_len,
                char *always_mountopts, int always_len)
index 9d732c3..cd74d89 100644 (file)
@@ -98,10 +98,12 @@ int loop_setup(struct mkfs_opts *mop);
 int loop_cleanup(struct mkfs_opts *mop);
 
 /* generic target support */
+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_is_lustre(char *dev, unsigned *mount_type);
 int ldiskfs_prepare_lustre(struct mkfs_opts *mop,
                           char *default_mountopts, int default_len,
                           char *always_mountopts, int always_len);
index 86f9ef5..097e08e 100644 (file)
@@ -277,31 +277,26 @@ static int file_in_dev(char *file_name, char *dev_name)
 }
 
 /* Check whether the device has already been used with lustre */
-int is_lustre_target(struct mkfs_opts *mop)
+int ldiskfs_is_lustre(char *dev, unsigned *mount_type)
 {
-       int rc;
-
-       vprint("checking for existing Lustre data: ");
+       int ret;
 
-       if ((rc = file_in_dev(MOUNT_DATA_FILE, mop->mo_device))) {
-               vprint("found %s\n",
-                      (rc == 1) ? MOUNT_DATA_FILE : "extents");
-               /* in the -1 case, 'extents' means this really IS a lustre
-                  target */
-               return rc;
+       ret = file_in_dev(MOUNT_DATA_FILE, dev);
+       if (ret) {
+               /* in the -1 case, 'extents' means IS a lustre target */
+               *mount_type = LDD_MT_LDISKFS;
+               return 1;
        }
 
-       if ((rc = file_in_dev(LAST_RCVD, mop->mo_device))) {
-               vprint("found %s\n", LAST_RCVD);
-               return rc;
+       ret = file_in_dev(LAST_RCVD, dev);
+       if (ret) {
+               *mount_type = LDD_MT_LDISKFS;
+               return 1;
        }
 
-       vprint("not found\n");
-       return 0; /* The device is not a lustre target. */
+       return 0;
 }
 
-
-
 /* Check if a certain feature is supported by e2fsprogs.
  * Firstly we try to use "debugfs supported_features" command to check if
  * the feature is supported. If this fails we try to set this feature with