void lustre_common_put_super(struct super_block *sb);
int class_manual_cleanup(struct obd_device *obd, char *flags);
struct lustre_mount_info *lustre_get_mount(char *name);
-struct lustre_mount_info *lustre_put_mount(char *name);
+int lustre_put_mount(char *name);
#endif
if (lmi) {
lustre_put_mount(obd->obd_name);
} else {
+ /* old method */
unlock_kernel();
mntput(mds->mds_vfsmnt);
lock_kernel();
{
struct mds_obd *mds = &obd->u.mds;
lvfs_sbdev_type save_dev;
+ int must_put = 0;
int must_relock = 0;
ENTRY;
CERROR("%s: mount busy, mnt_count %d != 2\n", obd->obd_name,
atomic_read(&obd->u.mds.mds_vfsmnt->mnt_count));
+ must_put = lustre_put_mount(obd->obd_name);
+
/* We can only unlock kernel if we are in the context of sys_ioctl,
otherwise we never called lock_kernel */
if (kernel_locked()) {
unlock_kernel();
must_relock++;
}
-
- mntput(mds->mds_vfsmnt);
+
+ if (must_put)
+ /* In case we didn't mount with lustre_get_mount -- old method*/
+ mntput(mds->mds_vfsmnt);
mds->mds_sb = NULL;
ldlm_namespace_free(obd->obd_namespace, obd->obd_force);
GOTO(err_reg, rc);
}
+ /* tgt_count may be 0! */
rc = llog_cat_initialize(obd, mds->mds_lov_desc.ld_tgt_count);
if (rc) {
CERROR("failed to initialize catalog %d\n", rc);
#include "mgc_internal.h"
-static int mgc_fs_setup(struct super_block *sb, struct vfsmount *mnt)
+static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb,
+ struct vfsmount *mnt)
{
struct lvfs_run_ctxt saved;
struct lustre_sb_info *sbi = s2sbi(sb);
- struct obd_device *obd = sbi->lsi_mgc;
struct mgc_obd *mgcobd = &obd->u.mgc;
struct dentry *dentry;
int err = 0;
- LASSERT(obd);
+ LASSERT(sbi);
obd->obd_fsops = fsfilt_get_ops(MT_STR(sbi->lsi_ldd));
if (IS_ERR(obd->obd_fsops)) {
}
mgcobd->mgc_vfsmnt = mnt;
- mgcobd->mgc_sb = mnt->mnt_root->d_inode->i_sb; // is this different than sb? */
+ mgcobd->mgc_sb = mnt->mnt_root->d_inode->i_sb;
+ // FIXME which one? - filter_common_setup also
+ CERROR("SB's: fill=%p mnt=%p root=%p\n", sb, mnt->mnt_sb, mnt->mnt_root->d_inode->i_sb);
fsfilt_setup(obd, mgcobd->mgc_sb);
OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
}
- if (mgc->mgc_vfsmnt)
- // FIXME mntput should not be done by real server, only us
- // FIXME or mntcount on sbi?
- mntput(mgc->mgc_vfsmnt);
+ mgc->mgc_vfsmnt = NULL;
mgc->mgc_sb = NULL;
if (obd->obd_fsops)
if (rc != 0)
CERROR("failed to cleanup llogging subsystems\n");
-
- if (mgc->mgc_sb)
- /* if we're a server, eg. something's mounted */
- mgc_fs_cleanup(obd);
-
//lprocfs_obd_cleanup(obd);
//rc = mgc_obd_cleanup(obd);
-
- if (!lustre_put_mount(obd->obd_name))
- CERROR("mount_put failed\n");
+
+ if (mgc->mgc_vfsmnt) {
+ /* if we're a server, eg. something's mounted */
+ mgc_fs_cleanup(obd);
+ if ((rc = lustre_put_mount(obd->obd_name)))
+ CERROR("mount_put failed %d\n", rc);
+ }
ptlrpcd_decref();
static int mgc_setup(struct obd_device *obd, obd_count len, void *buf)
{
struct lustre_mount_info *lmi;
- struct lustre_sb_info *sbi;
struct mgc_obd *mgc = &obd->u.mgc;
//struct lprocfs_static_vars lvars;
int rc;
}
lmi = lustre_get_mount(obd->obd_name);
- if (!lmi) {
- CERROR("No mount registered!");
- mgc_cleanup(obd);
- RETURN(-ENOENT);
- }
-
- sbi = s2sbi(lmi->lmi_sb);
- sbi->lsi_mgc = obd;
-
- rc = mgc_fs_setup(lmi->lmi_sb, lmi->lmi_mnt);
- if (rc) {
- CERROR("fs setup failed %d\n", rc);
- mgc_cleanup(obd);
- RETURN(-ENOENT);
- GOTO(err_rpc_lock, rc);
+ if (lmi) {
+ CERROR("mgc has local disk\n");
+ /* there's a local disk, we must get access */
+ rc = mgc_fs_setup(obd, lmi->lmi_sb, lmi->lmi_mnt);
+ if (rc) {
+ CERROR("fs setup failed %d\n", rc);
+ mgc_cleanup(obd);
+ RETURN(-ENOENT);
+ GOTO(err_rpc_lock, rc);
+ }
+ } else {
+ CERROR("mgc does not have local disk (client only)\n");
}
RETURN(rc);
#endif
/* ORIGinator context */
case OBD_IOC_DUMP_LOG: {
- struct lvfs_run_ctxt saved;
ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
rc = class_config_dump_llog(ctxt, data->ioc_inlbuf1, NULL);
/* setup the directory tree */
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- dentry = simple_mkdir(current->fs->pwd, "CONFIGS", 0777, 1);
+ dentry = simple_mkdir(current->fs->pwd, MOUNT_CONFIGS_DIR, 0777, 1);
if (IS_ERR(dentry))
rc = PTR_ERR(dentry);
- CERROR("cannot create CONFIGS directory: rc = %d\n", rc);
+ CERROR("cannot create %s directory: rc = %d\n",
+ MOUNT_CONFIGS_DIR, rc);
GOTO(err_pop, rc);
}
return ERR_PTR(-ENOMEM);
//FIXME: Need to changing mkfs
// if (fsname)
-// len = snprintf(logname, PATH_MAX, "CONFIGS/%s/%s", fsname, name);
+// len = snprintf(logname, PATH_MAX, "%s/%s/%s", MOUNT_CONFIGS_DIR, fsname, name);
// else
- len = snprintf(logname, PATH_MAX, "CONFIGS/%s", name);
+ len = snprintf(logname, PATH_MAX, "%s/%s",
+ MOUNT_CONFIGS_DIR, name);
if (len >= PATH_MAX - 1) {
filp = ERR_PTR(-ENAMETOOLONG);
} else {
- printk("logname = %s\n", logname);
+ CERROR("logname = %s\n", logname);
filp = l_filp_open(logname, flags, mode);
if (IS_ERR(filp))
CERROR("logfile creation %s: %ld\n", logname,
int size = sizeof(*idarray) * count;
loff_t off = 0;
- LASSERT(count);
+ if (!count) {
+ CERROR("Empty catalog?\n");
+ RETURN(0);
+ }
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700);
int size = sizeof(*idarray) * count;
loff_t off = 0;
- LASSERT(count);
-
+ if (!count) {
+ CERROR("Empty catalog?\n");
+ RETURN(0);
+ }
+
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700);
if (!file || IS_ERR(file)) {
struct lustre_mount_info *lmi;
char *name_cp;
+ CERROR("register %s\n", name);
+
OBD_ALLOC(lmi, sizeof(*lmi));
if (!lmi)
return -ENOMEM;
OBD_FREE(lmi, sizeof(*lmi));
return -ENOMEM;
}
- memcpy(name_cp, name, strlen(name));
+ strcpy(name_cp, name);
down(&lustre_mount_info_lock);
if (lustre_find_mount(name)) {
{
struct lustre_mount_info *lmi;
+ CERROR("deregister %s\n", name);
+
down(&lustre_mount_info_lock);
lmi = lustre_find_mount(name);
if (!lmi) {
return 0;
}
-/* obd's look up a registered mount using their name */
+/* obd's look up a registered mount using their name. This is just
+ for initial setup; should not be called every time you want to mntget */
struct lustre_mount_info *lustre_get_mount(char *name)
{
struct lustre_mount_info *lmi;
return NULL;
}
sbi = s2sbi(lmi->lmi_sb);
+ mntget(lmi->lmi_mnt);
atomic_inc(&sbi->lsi_mounts);
up(&lustre_mount_info_lock);
CERROR("got mount for %s\n", name);
return lmi;
}
-struct lustre_mount_info *lustre_put_mount(char *name)
+static void unlock_mntput(struct vfsmount *mnt)
+{
+ if (kernel_locked()) {
+ unlock_kernel();
+ mntput(mnt);
+ lock_kernel();
+ } else {
+ mntput(mnt);
+ }
+}
+
+/* to be called from obd_cleanup methods */
+int lustre_put_mount(char *name)
{
struct lustre_mount_info *lmi;
struct lustre_sb_info *sbi;
if (!lmi) {
up(&lustre_mount_info_lock);
CERROR("Can't find mount for %s\n", name);
- return NULL;
+ return -ENOENT;
}
sbi = s2sbi(lmi->lmi_sb);
+ unlock_mntput(lmi->lmi_mnt);
if (atomic_dec_and_test(&sbi->lsi_mounts)) {
- CERROR("Last put of mnt %p from %s\n", lmi->lmi_mnt, name);
- if (kernel_locked()) {
- unlock_kernel();
- mntput(lmi->lmi_mnt);
- lock_kernel();
- } else {
- mntput(lmi->lmi_mnt);
- }
+ /* The mntput from lustre_kern_mount */
+ unlock_mntput(lmi->lmi_mnt);
+ CERROR("Last put of mnt %p from %s, mount count %d\n",
+ lmi->lmi_mnt, name,
+ atomic_read(&lmi->lmi_mnt->mnt_count));
}
up(&lustre_mount_info_lock);
- /* any reason why a server might need the mount again? */
+ /* this obd should never need the mount again */
lustre_deregister_mount(name);
- return lmi;
+ return 0;
}
err = -ENOTCONN;
goto out_free;
}
-
+ sbi->lsi_mgc = obd;
+
out_free:
return err;
}
//mount_ctxt.cb_ops = mds_lvfs_ops;
err = parse_mount_data(&mount_ctxt, ldd);
- //unlock_kernel();
- mntput(mnt);
- //lock_kernel();
+ unlock_mntput(mnt);
if (err) {
CERROR("premount parse options failed: err = %d\n", err);
if (IS_ERR(mnt)) {
CERROR("Unable to mount device %s: %d\n",
sbi->lsi_lmd->lmd_dev, err);
- GOTO(out_free, err = PTR_ERR(mnt));
+ GOTO(out, err = PTR_ERR(mnt));
}
LASSERT(sbi->lsi_ldd);
CERROR("Found service %s for fs %s on device %s\n",
/* register a mount for the mgc so it can call mgc_fs_setup() */
err = lustre_register_mount(mgcname, sb, mnt);
if (err)
- GOTO(out_free, err);
+ GOTO(out, err);
err = lustre_start_mgc(mgcname, sb);
//part of mgc_startup err = mgc_fs_setup(sb, mnt);
if (err)
- GOTO(out_free, err);
+ GOTO(out_dereg, err);
/* we also need to register a mount for the real server */
err = lustre_register_mount(sbi->lsi_ldd->ldd_svname, sb, mnt);
if (err)
- GOTO(out_free, err);
+ GOTO(out_dereg, err);
if (sbi->lsi_ldd->ldd_flags & LDD_F_NEED_INDEX) {
err = lustre_process_logs(sb, &cfg, 0);
if (err < 0) {
CERROR("Unable to process log: %d\n", err);
- GOTO(out_free, err);
+ GOTO(out_dereg, err);
}
/* Finally, put something at the mount point. */
CERROR("Mounting server\n");
err = server_fill_super_common(sb);
-
+ if (err)
+ GOTO(out_dereg, err);
+
/* FIXME overmount client here,
or can we just start a client log and client_fill_super on this sb?
have to fix up the s_ops after! */
-out_free:
- //FIXME mntput
- //FIXME manual_cleanup (server_put_super)
- OBD_FREE(mgcname, mgcname_sz);
out:
+ //FIXME mntput
+ if (mgcname)
+ OBD_FREE(mgcname, mgcname_sz);
if (sbi->lsi_ldd)
+ // FIXME ??
class_del_profile(sbi->lsi_ldd->ldd_svname);
RETURN(err);
+out_dereg:
+ lustre_deregister_mount(mgcname);
+ lustre_deregister_mount(sbi->lsi_ldd->ldd_svname);
+ goto out;
}
struct lustre_cfg* lcfg = buf;
struct filter_obd *filter = &obd->u.filter;
struct vfsmount *mnt;
+ struct lustre_mount_info *lmi;
char *str;
char ns_name[48];
int rc = 0;
obd->obd_fsops = fsfilt_get_ops(lustre_cfg_string(lcfg, 2));
if (IS_ERR(obd->obd_fsops))
RETURN(PTR_ERR(obd->obd_fsops));
-
- mnt = do_kern_mount(lustre_cfg_string(lcfg, 2),MS_NOATIME|MS_NODIRATIME,
- lustre_cfg_string(lcfg, 1), option);
+
+ lmi = lustre_get_mount(obd->obd_name);
+ if (lmi) {
+ /* We already mounted in lustre_fill_super */
+ mnt = lmi->lmi_mnt;
+ } else {
+ mnt = do_kern_mount(lustre_cfg_string(lcfg, 2),
+ MS_NOATIME|MS_NODIRATIME,
+ lustre_cfg_string(lcfg, 1), option);
+ }
rc = PTR_ERR(mnt);
if (IS_ERR(mnt))
GOTO(err_ops, rc);
err_post:
filter_post(obd);
err_mntput:
- unlock_kernel();
- mntput(mnt);
+ if (lmi) {
+ lustre_put_mount(obd->obd_name);
+ } else {
+ /* old method */
+ unlock_kernel();
+ mntput(mnt);
+ lock_kernel();
+ }
filter->fo_sb = 0;
- lock_kernel();
err_ops:
fsfilt_put_ops(obd->obd_fsops);
return rc;
{
struct filter_obd *filter = &obd->u.filter;
lvfs_sbdev_type save_dev;
- int must_relock = 0;
+ int must_relock = 0, must_put = 0;
ENTRY;
if (obd->obd_fail)
obd->obd_name, filter->fo_vfsmnt,
atomic_read(&filter->fo_vfsmnt->mnt_count));
+ must_put = lustre_put_mount(obd->obd_name);
+
/* We can only unlock kernel if we are in the context of sys_ioctl,
otherwise we never called lock_kernel */
if (kernel_locked()) {
must_relock++;
}
- mntput(filter->fo_vfsmnt);
+ if (must_put)
+ mntput(filter->fo_vfsmnt);
//destroy_buffers(filter->fo_sb->s_dev);
filter->fo_sb = NULL;
}
if (strstr(mop->mo_mkfsopts, "-J") == NULL) {
+ /* Choose our own default journal size */
long journal_sz = 0;
if (device_sz > 1024 * 1024)
journal_sz = (device_sz / 102400) * 4;
}
}
+ /* Default is block size */
if (strstr(mop->mo_mkfsopts, "-i") == NULL) {
- long inode_sz = 0;
+ long bytes_per_inode = 0;
+
+ if (IS_MDT(&mop->mo_ldd))
+ bytes_per_inode = 4096;
+
+ /* Allocate fewer inodes on large OST devices. Most
+ filesystems can be much more aggressive than even
+ this. */
+ if ((IS_OST(&mop->mo_ldd) && (device_sz > 1000000)))
+ bytes_per_inode = 16384;
- /* The larger the bytes-per-inode ratio, the fewer
- inodes will be created. */
- if (mop->mo_stripe_count > 77)
- inode_sz = 4096;
- else if (mop->mo_stripe_count > 35)
- inode_sz = 2048;
- else if (IS_MDT(&mop->mo_ldd))
- inode_sz = 1024;
- else if ((IS_OST(&mop->mo_ldd) && (device_sz > 1000000)))
- inode_sz = 16384;
- if (inode_sz > 0) {
- sprintf(buf, " -i %ld", inode_sz);
+ if (bytes_per_inode > 0) {
+ sprintf(buf, " -i %ld", bytes_per_inode);
strcat(mop->mo_mkfsopts, buf);
}
}
+
+ /* This is an undocumented mke2fs option. Default is 128. */
+ if (strstr(mop->mo_mkfsopts, "-I") == NULL) {
+ long inode_size = 0;
+ if (IS_MDT(&mop->mo_ldd)) {
+ if (mop->mo_stripe_count > 77)
+ inode_size = 512; /* bz 7241 */
+ else if (mop->mo_stripe_count > 34)
+ inode_size = 2048;
+ else if (mop->mo_stripe_count > 13)
+ inode_size = 1024;
+ else
+ inode_size = 512;
+ }
+
+ if (inode_size > 0) {
+ sprintf(buf, " -I %ld", inode_size);
+ strcat(mop->mo_mkfsopts, buf);
+ }
+
+ }
sprintf(mkfs_cmd, "mkfs.ext2 -j -b 4096 -L %s ",
mop->mo_ldd.ldd_svname);
if ((ret = jt_setup()))
return ret;
+ /* debug info */
+ if (verbose >= 2) {
+ do_jt_noret(jt_dbg_modules, "modules", 0);
+ }
+
dev = mop->mo_device;
if (mop->mo_flags & MO_IS_LOOP) {
ret = loop_setup(mop);
echo Modifying $MODFILE
echo "# Lustre modules added by $0" >> $MODFILE
if [ $KVER -eq 24 ]; then
- echo alias _lustre portals >> $MODFILE
- echo add above _lustre ksocknal $FSFLT >> $MODFILE
- echo add below mds _lustre osc >> $MODFILE
+ echo alias _lustre ksocknal >> $MODFILE
+ echo add above _lustre mgc $FSFLT portals >> $MODFILE
+ echo add below mds _lustre osc lov >> $MODFILE
echo add below ost _lustre >> $MODFILE
- echo add below llite _lustre osc mdc >> $MODFILE
+ echo add below llite _lustre osc mdc lov >> $MODFILE
echo alias lustre llite >> $MODFILE
else
echo "install kptlrouter $MP portals && $MPI kptlrouter" >> $MODFILE
- echo "install _lustre $MP portals && $MP lvfs && $MP obdclass && $MP ptlrpc" >> $MODFILE
+ echo "install _lustre $MP portals && $MP lvfs && $MP obdclass && $MP ptlrpc && $MP mgc" >> $MODFILE
echo "install obdfilter $MP _lustre && $MP ost && $MP ldiskfs && $MP $FSFLT && $MPI obdfilter" >> $MODFILE
echo "install ost $MP _lustre && $MPI ost" >> $MODFILE
- echo "install mds $MP _lustre && $MP osc && $MPI mds" >> $MODFILE
- echo "install llite $MP _lustre && $MP osc && $MP mdc && $MPI llite" >> $MODFILE
+ echo "install mds $MP _lustre && $MP osc && $MP lov && $MPI mds" >> $MODFILE
+ echo "install llite $MP _lustre && $MP osc && $MP mdc && $MP lov && $MPI llite" >> $MODFILE
echo "alias lustre llite" >> $MODFILE
fi
echo "# end Lustre modules" >> $MODFILE
rmmod fsfilt_ldiskfs
rmmod ldiskfs
rmmod mgc
+rmmod mgs
rmmod ost
rmmod mds
rmmod ptlrpc