From 71bc053baa961aa3dbbaa5ae89f9cd4fb5a080e7 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Sun, 17 Jun 2012 11:33:00 +0400 Subject: [PATCH] LU-1581 utils: introduce osd_init() wrapper to load and initialize libraries/modules for different backends Signed-off-by: Alex Zhuravlev Change-Id: Iae4ac1bbf87093731686f9362d7f6a71cc704030 Reviewed-on: http://review.whamcloud.com/3226 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Li Wei Reviewed-by: Andreas Dilger --- lustre/utils/mkfs_lustre.c | 5 +++++ lustre/utils/mount_utils.c | 16 ++++++++++++++++ lustre/utils/mount_utils.h | 4 ++++ lustre/utils/mount_utils_ldiskfs.c | 13 +++++++++++++ 4 files changed, 38 insertions(+) diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 0af4fae..35f222c 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -557,6 +557,10 @@ int main(int argc, char *const argv[]) print_ldd("Read previous values", &(mop.mo_ldd)); #endif + ret = osd_init(); + if (ret) + return ret; + ret = parse_opts(argc, argv, &mop, &mountopts); if (ret) goto out; @@ -706,6 +710,7 @@ int main(int argc, char *const argv[]) out: loop_cleanup(&mop); + osd_fini(); /* Fix any crazy return values from system() */ if (ret && ((ret & 255) == 0)) diff --git a/lustre/utils/mount_utils.c b/lustre/utils/mount_utils.c index ad71af0..048aee5 100644 --- a/lustre/utils/mount_utils.c +++ b/lustre/utils/mount_utils.c @@ -480,6 +480,22 @@ int osd_prepare_lustre(struct mkfs_opts *mop, return ret; } +int osd_init(void) +{ + int ret = 0; + + ret = ldiskfs_init(); + if (ret) + return ret; + + return ret; +} + +void osd_fini(void) +{ + ldiskfs_fini(); +} + __u64 get_device_size(char* device) { int ret, fd; diff --git a/lustre/utils/mount_utils.h b/lustre/utils/mount_utils.h index 6033b58..115003c 100644 --- a/lustre/utils/mount_utils.h +++ b/lustre/utils/mount_utils.h @@ -106,6 +106,8 @@ int osd_make_lustre(struct mkfs_opts *mop); int osd_prepare_lustre(struct mkfs_opts *mop, char *default_mountopts, int default_len, char *always_mountopts, int always_len); +int osd_init(void); +void osd_fini(void); int ldiskfs_write_ldd(struct mkfs_opts *mop); int ldiskfs_read_ldd(char *dev, struct lustre_disk_data *ldd); @@ -114,5 +116,7 @@ int ldiskfs_make_lustre(struct mkfs_opts *mop); int ldiskfs_prepare_lustre(struct mkfs_opts *mop, char *default_mountopts, int default_len, char *always_mountopts, int always_len); +int ldiskfs_init(void); +void ldiskfs_fini(void); #endif diff --git a/lustre/utils/mount_utils_ldiskfs.c b/lustre/utils/mount_utils_ldiskfs.c index e334f58..0159328 100644 --- a/lustre/utils/mount_utils_ldiskfs.c +++ b/lustre/utils/mount_utils_ldiskfs.c @@ -820,3 +820,16 @@ out: return ret; } +int ldiskfs_init(void) +{ + /* Required because full path to DEBUGFS is not specified */ + setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin", 0); + + return 0; +} + +void ldiskfs_fini(void) +{ + return; +} + -- 1.8.3.1