sort out the inter-module dependencies.
lvfs had a loop with obdclass, so moved mount there
(((x)->lmd_flags & LMD_FLG_CLIENT) || \
(!((x)->lmd_flags & LMD_FLG_MNTCNF)))
-
/****************** mkfs command *********************/
#define MO_IS_LOOP 0x01
# 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
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);
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);
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);
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);
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;
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;
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 */
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;
}
LBUG();
return NULL;
}
+
+EXPORT_SYMBOL(ll_fill_super);
+EXPORT_SYMBOL(ll_put_super);
+EXPORT_SYMBOL(ll_remount_fs);
+EXPORT_SYMBOL(ll_umount_begin);
+
.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 = {
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);
.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 = {
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);
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
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
#include <linux/obd_class.h>
#include <lustre/lustre_user.h>
+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)
{
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);
{
//.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))
RETURN(0);
}
-#if 0
-FIXME
/* Get the log "profile" from a remote MGMT and process it.
FIXME If remote doesn't exist, try local
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, };
rc = err;
RETURN(rc);
-}
#endif
+}
/* Process all local logs.
FIXME clients and servers should use the same fn. No need to have MDS
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);
}
/* 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);
}
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 ": "",
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;
#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
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);
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)
{
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);
}