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>
char *mountopts = NULL;
char always_mountopts[512] = "";
char default_mountopts[512] = "";
char *mountopts = NULL;
char always_mountopts[512] = "";
char default_mountopts[512] = "";
int ret = 0;
if ((progname = strrchr(argv[0], '/')) != NULL)
int ret = 0;
if ((progname = strrchr(argv[0], '/')) != NULL)
new ones. */
/* Check whether the disk has already been formatted by mkfs.lustre */
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 "
if (ret == 0) {
fatal();
fprintf(stderr, "Device %s has not been formatted with "
#ifndef TUNEFS /* mkfs.lustre */
/* Check whether the disk has already been formatted by mkfs.lustre */
if (!(mop.mo_flags & MO_FORCEFORMAT)) {
#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 "
if (ret) {
fatal();
fprintf(stderr, "Device %s was previously formatted "
+/* 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)
int osd_prepare_lustre(struct mkfs_opts *mop,
char *default_mountopts, int default_len,
char *always_mountopts, int always_len)
int loop_cleanup(struct mkfs_opts *mop);
/* generic target support */
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 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);
int ldiskfs_prepare_lustre(struct mkfs_opts *mop,
char *default_mountopts, int default_len,
char *always_mountopts, int always_len);
}
/* Check whether the device has already been used with lustre */
}
/* 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: ");
- 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. */
/* 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
/* 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