From 8152c20f05b533ac71c7e9a9e9e51a0d4b7c883c Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 1 Aug 2005 23:22:19 +0000 Subject: [PATCH] b=6663 sort out the inter-module dependencies. lvfs had a loop with obdclass, so moved mount there --- lustre/include/linux/lustre_disk.h | 3 +- lustre/include/linux/lvfs.h | 5 -- lustre/include/linux/obd_class.h | 6 ++ lustre/llite/llite_internal.h | 5 +- lustre/llite/llite_lib.c | 41 +++++++---- lustre/llite/super.c | 8 ++- lustre/llite/super25.c | 6 +- lustre/lvfs/Makefile.in | 2 +- lustre/obdclass/Makefile.in | 2 +- lustre/{lvfs/lvfs_mount.c => obdclass/obd_mount.c} | 70 +++++++------------ lustre/utils/mkfs_lustre.c | 79 ++++++++++++++++------ 11 files changed, 134 insertions(+), 93 deletions(-) rename lustre/{lvfs/lvfs_mount.c => obdclass/obd_mount.c} (94%) diff --git a/lustre/include/linux/lustre_disk.h b/lustre/include/linux/lustre_disk.h index ffa3e67..8031674 100644 --- a/lustre/include/linux/lustre_disk.h +++ b/lustre/include/linux/lustre_disk.h @@ -108,7 +108,6 @@ struct lustre_mount_data { (((x)->lmd_flags & LMD_FLG_CLIENT) || \ (!((x)->lmd_flags & LMD_FLG_MNTCNF))) - /****************** mkfs command *********************/ #define MO_IS_LOOP 0x01 @@ -186,6 +185,8 @@ struct lustre_sb_info { # define s2sbi_nocast(sb) ((sb)->u.generic_sbp) #endif +#define get_profile_name(sb) (s2sbi(sb)->lsi_lmd->lmd_dev) + #endif /* __KERNEL__ */ #endif // _LUSTRE_DISK_H diff --git a/lustre/include/linux/lvfs.h b/lustre/include/linux/lvfs.h index 3f29cfc..34abec8 100644 --- a/lustre/include/linux/lvfs.h +++ b/lustre/include/linux/lvfs.h @@ -84,11 +84,6 @@ struct obd_device; struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode, int fix); struct dentry *simple_mknod(struct dentry *dir, char *name, int mode, int fix); -int lustre_fill_super(struct super_block *sb, void *data, int silent); -void lustre_put_super(struct super_block *sb); -int lustre_remount_fs(struct super_block *sb, int *flags, char *data); -int class_manual_cleanup(struct obd_device *obd, char *flags); - int lustre_fread(struct file *file, void *buf, int len, loff_t *off); int lustre_fwrite(struct file *file, const void *buf, int len, loff_t *off); int lustre_fsync(struct file *file); diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index bdf2d27..74415a5 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -91,6 +91,12 @@ void ping_evictor_stop(void); char *obd_export_nid2str(struct obd_export *exp); +/* obd_mount.c */ +int lustre_fill_super(struct super_block *sb, void *data, int silent); +void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb)); +void lustre_common_put_super(struct super_block *sb); +int class_manual_cleanup(struct obd_device *obd, char *flags); + /* config.c */ int class_process_config(struct lustre_cfg *lcfg); int class_attach(struct lustre_cfg *lcfg); diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 34da908..958c9ef 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -334,8 +334,8 @@ char *ll_read_opt(const char *opt, char *data); int ll_set_opt(const char *opt, char *data, int fl); void ll_options(char *options, char **ost, char **mds, int *flags); void ll_lli_init(struct ll_inode_info *lli); -int client_fill_super(struct super_block *sb, char *profilenm); -void client_put_super(struct super_block *sb, char *profilenm); +int ll_fill_super(struct super_block *sb); +void ll_put_super(struct super_block *sb); struct inode *ll_inode_from_lock(struct ldlm_lock *lock); void ll_clear_inode(struct inode *inode); int ll_setattr_raw(struct inode *inode, struct iattr *attr); @@ -349,6 +349,7 @@ void ll_read_inode2(struct inode *inode, void *opaque); int ll_iocontrol(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); void ll_umount_begin(struct super_block *sb); +int ll_remount_fs(struct super_block *sb, int *flags, char *data); int ll_prep_inode(struct obd_export *exp, struct inode **inode, struct ptlrpc_request *req, int offset, struct super_block *); void lustre_dump_dentry(struct dentry *, int recur); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 76282c3..6165247 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -445,13 +445,14 @@ void ll_lli_init(struct ll_inode_info *lli) lli->lli_inode_magic = LLI_INODE_MAGIC; } -int client_fill_super(struct super_block *sb, char *profilenm) +int ll_fill_super(struct super_block *sb) { struct lustre_profile *lprof; struct lustre_sb_info *lsi = s2sbi(sb); struct ll_sb_info *sbi; char *osc; char *mdc; + char *profilenm = get_profile_name(sb); struct config_llog_instance cfg; char ll_instance[sizeof(sb) * 2 + 1]; int err; @@ -518,11 +519,12 @@ out_free: RETURN(err); } -void client_put_super(struct super_block *sb, char *profilenm) +void ll_put_super(struct super_block *sb) { struct obd_device *obd; struct lustre_sb_info *lsi = s2sbi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); + char *profilenm = get_profile_name(sb); char flags[2] = ""; int next = 0; ENTRY; @@ -539,13 +541,14 @@ void client_put_super(struct super_block *sb, char *profilenm) class_manual_cleanup(obd, flags); } - /* client */ if (profilenm) class_del_profile(profilenm); ll_free_sbi(sb); lsi->lsi_llsbi = NULL; + lustre_common_put_super(sb); + EXIT; } /* client_put_super */ @@ -1203,18 +1206,26 @@ void ll_umount_begin(struct super_block *sb) EXIT; } -int ll_remount_fs(struct super_block *sb, __u32 read_only) +int ll_remount_fs(struct super_block *sb, int *flags, char *data) { struct ll_sb_info *sbi = ll_s2sbi(sb); int err; - - err = obd_set_info(sbi->ll_mdc_exp, - strlen("read-only"), "read-only", - sizeof(read_only), &read_only); - if (err) { - CERROR("Failed to change the read-only flag " - "during remount: %d\n", err); - return err; + __u32 read_only; + + if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) { + read_only = *flags & MS_RDONLY; + err = obd_set_info(sbi->ll_mdc_exp, strlen("read-only"), + "read-only", sizeof(read_only), &read_only); + if (err) { + CERROR("Failed to change the read-only flag during " + "remount: %d\n", err); + return err; + } + + if (read_only) + sb->s_flags |= MS_RDONLY; + else + sb->s_flags &= ~MS_RDONLY; } return 0; } @@ -1271,3 +1282,9 @@ struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi, LBUG(); return NULL; } + +EXPORT_SYMBOL(ll_fill_super); +EXPORT_SYMBOL(ll_put_super); +EXPORT_SYMBOL(ll_remount_fs); +EXPORT_SYMBOL(ll_umount_begin); + diff --git a/lustre/llite/super.c b/lustre/llite/super.c index 8922ae6..44b04d7 100644 --- a/lustre/llite/super.c +++ b/lustre/llite/super.c @@ -57,12 +57,12 @@ struct super_operations lustre_super_operations = .read_inode2 = ll_read_inode2, .clear_inode = ll_clear_inode, // .delete_inode = ll_delete_inode, - .put_super = lustre_put_super, + .put_super = ll_put_super, .statfs = ll_statfs, .umount_begin = ll_umount_begin, .fh_to_dentry = ll_fh_to_dentry, .dentry_to_fh = ll_dentry_to_fh, - .remount_fs = lustre_remount_fs, + .remount_fs = ll_remount_fs, }; static struct file_system_type lustre_fs_type = { @@ -87,6 +87,10 @@ static int __init init_lustre_lite(void) if (proc_lustre_root) proc_lustre_fs_root = proc_mkdir("llite", proc_lustre_root); + // FIXME register_filesystem should be in obd_mount init, not here. + // here we just have: + lustre_register_client_fill_super(ll_fill_super); + ll_register_cache(&ll_cache_definition); rc = register_filesystem(&lustre_fs_type); diff --git a/lustre/llite/super25.c b/lustre/llite/super25.c index 46031d3..4a15218 100644 --- a/lustre/llite/super25.c +++ b/lustre/llite/super25.c @@ -96,10 +96,10 @@ struct super_operations lustre_super_operations = .alloc_inode = ll_alloc_inode, .destroy_inode = ll_destroy_inode, .clear_inode = ll_clear_inode, - .put_super = lustre_put_super, + .put_super = ll_put_super, .statfs = ll_statfs, .umount_begin = ll_umount_begin, - .remount_fs = lustre_remount_fs, + .remount_fs = ll_remount_fs, }; struct file_system_type lustre_fs_type = { @@ -129,6 +129,8 @@ static int __init init_lustre_lite(void) proc_lustre_fs_root = proc_lustre_root ? proc_mkdir("llite", proc_lustre_root) : NULL; + lustre_register_client_fill_super(ll_fill_super); + ll_register_cache(&ll_cache_definition); rc = register_filesystem(&lustre_fs_type); diff --git a/lustre/lvfs/Makefile.in b/lustre/lvfs/Makefile.in index 2c48e63..02fb755 100644 --- a/lustre/lvfs/Makefile.in +++ b/lustre/lvfs/Makefile.in @@ -1,7 +1,7 @@ MODULES := lvfs #quotactl_test quotacheck_test @SERVER_TRUE@MODULES += fsfilt_@BACKINGFS@ -lvfs-objs := lvfs_common.o lvfs_linux.o fsfilt.o lvfs_mount.o +lvfs-objs := lvfs_common.o lvfs_linux.o fsfilt.o #quotactl-objs := quotactl_test.o #quotaccheck-objs := quotacheck_test.o diff --git a/lustre/obdclass/Makefile.in b/lustre/obdclass/Makefile.in index f761599..f69c7ea 100644 --- a/lustre/obdclass/Makefile.in +++ b/lustre/obdclass/Makefile.in @@ -4,7 +4,7 @@ obdclass-objs := llog.o llog_cat.o llog_lvfs.o llog_obd.o llog_swab.o obdclass-objs += class_obd.o obdclass-objs += debug.o genops.o sysctl.o uuid.o llog_ioctl.o obdclass-objs += lprocfs_status.o lustre_handles.o lustre_peer.o -obdclass-objs += statfs_pack.o obdo.o obd_config.o +obdclass-objs += statfs_pack.o obdo.o obd_config.o obd_mount.o ifeq ($(PATCHLEVEL),6) llog_test-objs := llog-test.o diff --git a/lustre/lvfs/lvfs_mount.c b/lustre/obdclass/obd_mount.c similarity index 94% rename from lustre/lvfs/lvfs_mount.c rename to lustre/obdclass/obd_mount.c index 235acc1..4433244 100644 --- a/lustre/lvfs/lvfs_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -31,6 +31,8 @@ #include #include +static int (*client_fill_super)(struct super_block *sb) = NULL; + static int dentry_readdir(struct obd_device *obd, struct dentry *dir, struct vfsmount *inmnt, struct list_head *dentry_list) { @@ -325,9 +327,10 @@ static void server_put_super(struct super_block *sb) class_manual_cleanup(obd, flags); class_del_profile(sbi->lsi_ldd->ldd_svname); + lustre_common_put_super(sb); } -static void server_umount_force(struct super_block *sb) +static void server_umount_begin(struct super_block *sb) { struct lustre_sb_info *sbi = s2sbi(sb); @@ -340,7 +343,7 @@ static struct super_operations server_ops = { //.statfs = NULL, .put_super = server_put_super, - .umount_begin = server_umount_force, /* umount -f */ + .umount_begin = server_umount_begin, /* umount -f */ }; #define log2(n) ffz(~(n)) @@ -382,8 +385,6 @@ static int server_fill_super_common(struct super_block *sb) RETURN(0); } -#if 0 -FIXME /* Get the log "profile" from a remote MGMT and process it. FIXME If remote doesn't exist, try local @@ -391,6 +392,8 @@ FIXME int lustre_get_process_log(struct super_block *sb, char * profile, struct config_llog_instance *cfg) { +#if 0 +FIXME char *peer = "MDS_PEER_UUID"; struct obd_device *obd; struct lustre_handle mdc_conn = {0, }; @@ -494,8 +497,8 @@ out: rc = err; RETURN(rc); -} #endif +} /* Process all local logs. FIXME clients and servers should use the same fn. No need to have MDS @@ -794,9 +797,15 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent) lustre_start_mgc(sb); if (lmd_is_client(lmd)) { - CERROR("Mounting client\n"); - /* Connect and start */ - err = client_fill_super(sb, lmd->lmd_dev /*profile */); + if (!client_fill_super) { + CERROR("Nothing registered for client_fill_super!\n" + "Is llite module loaded?\n"); + err = -ENOSYS; + } else { + CERROR("Mounting client\n"); + /* Connect and start */ + err = (*client_fill_super)(sb); + } } else { CERROR("Mounting server\n"); err = server_fill_super(sb); @@ -811,52 +820,23 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent) } /* Common umount */ -void lustre_put_super(struct super_block *sb) +void lustre_common_put_super(struct super_block *sb) { - struct lustre_sb_info *sbi = s2sbi(sb); - struct obd_device *obd; - - LASSERT(sbi->lsi_lmd); - if (!lmd_is_client(sbi->lsi_lmd)) { - // FIXME unmount overmounted client first - //mntput? - server_put_super(sb); - } else { - client_put_super(sb, sbi->lsi_lmd->lmd_dev); - } + CERROR("common put super %p\n", sb); lustre_stop_mgc(sb); lustre_free_sbi(sb); -} +} -/* Common remount */ -int lustre_remount_fs(struct super_block *sb, int *flags, char *data) +void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb)) { - struct lustre_sb_info *sbi = s2sbi(sb); - int ret = 0; - __u32 read_only; - - if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) { - read_only = *flags & MS_RDONLY; - if (sbi->lsi_lmd && !lmd_is_client(sbi->lsi_lmd)) { - // FIXME what does this mean? - CERROR("Remount server %s RO %d\n", - sbi->lsi_ldd->ldd_svname, read_only); - } else { - ret = ll_remount_fs(sb, read_only); - } - if (read_only) - sb->s_flags |= MS_RDONLY; - else - sb->s_flags &= ~MS_RDONLY; - } - return ret; + client_fill_super = cfs; } - EXPORT_SYMBOL(lustre_fill_super); -EXPORT_SYMBOL(lustre_put_super); -EXPORT_SYMBOL(lustre_remount_fs); +EXPORT_SYMBOL(lustre_register_client_fill_super); +EXPORT_SYMBOL(lustre_common_put_super); +EXPORT_SYMBOL(lustre_get_process_log); EXPORT_SYMBOL(class_manual_cleanup); diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 1ad2ffa..a73c9fb 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -297,10 +297,13 @@ int write_local_files(struct mkfs_opts *mop) } if (mop->mo_flags & MO_IS_LOOP) { + /* ext3 can't understand iopen_nopriv, others if (strlen(mop->mo_ldd.ldd_mount_opts)) snprintf(local_mount_opts, sizeof(local_mount_opts), "loop,%s", mop->mo_ldd.ldd_mount_opts); - else sprintf(local_mount_opts, "loop"); + else + */ + sprintf(local_mount_opts, "loop"); } sprintf(cmd, "mount -t ext3 %s%s %s %s", strlen(local_mount_opts) ? "-o ": "", @@ -518,6 +521,39 @@ out: return ret; } +static int load_module(char *module_name) +{ + char buf[256]; + int rc; + + vprint("loading %s\n", module_name); + sprintf(buf, "/sbin/modprobe %s", module_name); + rc = system(buf); + if (rc) { + fprintf(stderr, "%s: failed to modprobe %s (%d)\n", + progname, module_name, rc); + fprintf(stderr, "Check /etc/modules.conf\n"); + } + return rc; +} + +static int load_modules(struct mkfs_opts *mop) +{ + int rc = 0; + + //client: rc = load_module("lustre"); + + if (IS_OST(&mop->mo_ldd)) { + rc = load_module("oss"); + if (rc) return rc; + } + if (IS_MDT(&mop->mo_ldd)) { + rc = load_module("mds"); + if (rc) return rc; + } + return rc; +} + static int jt_setup() { int ret; @@ -582,17 +618,28 @@ static int _do_jt(int (*cmd)(int argc, char **argv), char *cmd_name, ...) #define do_jt(cmd, a...) if ((ret = _do_jt(cmd, #cmd, ## a))) goto out_jt #define do_jt_noret(cmd, a...) _do_jt(cmd, #cmd, ## a) +static int get_local_nids(void) +{ + int ret; + /* Get local nids */ + ret = do_jt_noret(jt_ptl_network, "network", 0); + // FIXME save these + return 0; +} + int lustre_log_setup(struct mkfs_opts *mop) { char confname[] = "llog_writer"; char name[128]; - int ret = 0; + int numnids, ret = 0; vprint("Creating Lustre logs\n"); if ((ret = jt_setup())) return ret; + numnids = get_local_nids(); + /* FIXME can't we just write these log files ourselves? Why do we have to go through an obd at all? jt_ioc_dump()? */ /* FIXME use mgmt server obd to write logs. Can start it by mounting @@ -697,7 +744,11 @@ int lustre_log_setup(struct mkfs_opts *mop) mop->mo_timeout, 0); do_jt(jt_cfg_endrecord, "endrecord", 0); - + if (numnids == 0) { + fprintf(stderr, "%s: Can't figure out local nids, " + "skipping client log creation\n", progname); + goto out_jt; + } /* Write client startup log */ do_jt(jt_cfg_clear_log, "clear_log", "client", 0); do_jt(jt_cfg_record, "record", "client", 0); @@ -752,22 +803,6 @@ out_jt: return ret; } -static int load_module(char *module_name) -{ - char buf[256]; - int rc; - - vprint("loading %s\n", module_name); - sprintf(buf, "/sbin/modprobe %s", module_name); - rc = system(buf); - if (rc) { - fprintf(stderr, "%s: failed to modprobe %s (%d)\n", - progname, module_name, rc); - fprintf(stderr, "Check /etc/modules.conf\n"); - } - return rc; -} - /* Make the mdt/ost server obd name based on the filesystem name */ static void make_sv_name(struct mkfs_opts *mop) { @@ -776,13 +811,13 @@ static void make_sv_name(struct mkfs_opts *mop) So rewrite ost log, last_rcvd, and disk label, or we need to talk to MGMT now to get index # */ - if (IS_MGMT(&mop->mo_ldd)) { - sprintf(mop->mo_ldd.ldd_svname, "MGMT"); - } else { + if (IS_MDT(&mop->mo_ldd) || IS_OST(&mop->mo_ldd)) { sprintf(mop->mo_ldd.ldd_svname, "%.8s-%s%04x", mop->mo_ldd.ldd_fsname, IS_MDT(&mop->mo_ldd) ? "MDT" : "OST", mop->mo_index); + } else { + sprintf(mop->mo_ldd.ldd_svname, "MGMT"); } vprint("Server name: %s\n", mop->mo_ldd.ldd_svname); } -- 1.8.3.1