#define LDD_SV_TYPE_OST 0x0002
#define LDD_SV_TYPE_MGMT 0x0004
-enum {
+enum ldd_mount_type {
LDD_MT_EXT3 = 0,
LDD_MT_LDISKFS,
LDD_MT_SMFS,
- LDD_MT_REISERFS
+ LDD_MT_REISERFS,
+ LDD_MT_LAST
};
-static char mount_type_string[4][] = {
- "ext3",
- "ldiskfs",
- "smfs",
- "reiserfs"
+static inline char *mt_str(enum ldd_mount_type mt)
+{
+ static char *mount_type_string[] = {
+ "ext3",
+ "ldiskfs",
+ "smfs",
+ "reiserfs",
+ };
+ //LASSERT(mt < LDD_MT_LAST);
+ return mount_type_string[mt];
}
+struct host_desc {
+ ptl_nid_t primary;
+ ptl_nid_t backup;
+};
+
struct lustre_disk_data {
__u32 ldd_magic;
- __u32 ldd_flags;
+ __u32 ldd_flags; /* LDD_SV_TYPE */
struct host_desc ldd_mgmtnid; /* mgmt nid; lmd can override */
char ldd_fsname[64]; /* filesystem this server is part of */
char ldd_svname[64]; /* this server's name (lustre-mdt0001) */
- __u8 ldd_mount_type; /* target fs type LDD_FS_TYPE_* */
+ enum ldd_mount_type ldd_mount_type; /* target fs type LDD_MT_* */
char ldd_mount_opts[128]; /* target fs mount opts */
};
#define IS_MDT(data) ((data)->ldd_flags & LDD_SV_TYPE_MDT)
#define IS_OST(data) ((data)->ldd_flags & LDD_SV_TYPE_OST)
#define IS_MGMT(data) ((data)->ldd_flags & LDD_SV_TYPE_MGMT)
-#define MT_STR(data) mount_type_string[(data)->ldd_mount_type]
+#define MT_STR(data) mt_str((data)->ldd_mount_type)
/****************** mount command *********************/
-struct host_desc {
- ptl_nid_t primary;
- ptl_nid_t backup;
-};
-
/* Passed by mount - no persistent info here */
struct lustre_mount_data {
__u32 lmd_magic;
_device_ mount options) */
};
-#define LMD_FLG_FLOCK 0x0001 /* Enable flock */
-#define LMD_FLG_MNTCNF 0x1000 /* MountConf compat */
-#define LMD_FLG_CLIENT 0x2000 /* Mounting a client only; no real device */
+#define LMD_FLG_FLOCK 0x0001 /* Enable flock */
+#define LMD_FLG_RECOVER 0x0002 /* Allow recovery */
+#define LMD_FLG_MNTCNF 0x1000 /* MountConf compat */
+#define LMD_FLG_CLIENT 0x2000 /* Mounting a client only; no real device */
+/* 2nd half is for old clients */
#define lmd_is_client(x) \
- (((x)->lmd_flags & LMD_FLG_CLIENT) || (!((x)->lmd_flags & LMD_FLG_MNTCNF)))
+ (((x)->lmd_flags & LMD_FLG_CLIENT) || \
+ (!((x)->lmd_flags & LMD_FLG_MNTCNF)))
/****************** mkfs command *********************/
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);
+
+struct ll_sb_info *lustre_init_sbi(struct super_block *sb);
+void lustre_free_sbi(struct super_block *sb);
+void lustre_manual_cleanup(struct ll_sb_info *sbi);
+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 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);
/* corresponds to one of the obd's */
struct obd_device {
- struct obd_type *obd_type;
+ struct obd_type *obd_type;
/* common and UUID name of this device */
- char *obd_name;
- struct obd_uuid obd_uuid;
+ char *obd_name;
+ struct obd_uuid obd_uuid;
+ struct obd_uuid obd_grp_uuid; /* for manual cleanup */
- int obd_minor;
+ int obd_minor;
unsigned int obd_attached:1, obd_set_up:1, obd_recovering:1,
obd_abort_recovery:1, obd_replayable:1, obd_no_transno:1,
obd_no_recov:1, obd_stopping:1, obd_starting:1,
obd_force:1, obd_fail:1;
- atomic_t obd_refcount;
- wait_queue_head_t obd_refcount_waitq;
- struct proc_dir_entry *obd_proc_entry;
- struct list_head obd_exports;
- int obd_num_exports;
- struct ldlm_namespace *obd_namespace;
- struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
+ atomic_t obd_refcount;
+ wait_queue_head_t obd_refcount_waitq;
+ struct proc_dir_entry *obd_proc_entry;
+ struct list_head obd_exports;
+ int obd_num_exports;
+ struct ldlm_namespace *obd_namespace;
+ struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
/* a spinlock is OK for what we do now, may need a semaphore later */
- spinlock_t obd_dev_lock;
- __u64 obd_last_committed;
+ spinlock_t obd_dev_lock;
+ __u64 obd_last_committed;
struct fsfilt_operations *obd_fsops;
spinlock_t obd_osfs_lock;
struct obd_statfs obd_osfs;
- unsigned long obd_osfs_age; /* jiffies */
+ unsigned long obd_osfs_age; /* jiffies */
struct lvfs_run_ctxt obd_lvfs_ctxt;
- struct llog_ctxt *obd_llog_ctxt[LLOG_MAX_CTXTS];
- struct obd_device *obd_observer;
- struct obd_export *obd_self_export;
+ struct llog_ctxt *obd_llog_ctxt[LLOG_MAX_CTXTS];
+ struct obd_device *obd_observer;
+ struct obd_export *obd_self_export;
struct list_head obd_exports_timed; /* for ping evictor */
time_t obd_eviction_timer; /* for ping evictor */
#define LL_FILE_GROUP_LOCKED 0x00000002
#define LL_FILE_READAHEAD 0x00000004
#define LL_UMOUNT_FORCE 0x00000010
-#define LL_UMOUNT_FAIL 0x00000020
+#define LL_UMOUNT_FAILOVER 0x00000020
#define LOV_USER_MAGIC_V1 0x0BD10BD0
#define LOV_USER_MAGIC LOV_USER_MAGIC_V1
struct proc_dir_entry* ll_proc_root;
obd_id ll_rootino; /* number of root inode */
- struct lustre_mount_data *ll_lmd;
+ struct lvfs_run_ctxt ll_ctxt; /* mount context */
+ struct lustre_mount_data *ll_lmd; /* mount command info */
+ struct lustre_disk_data *ll_ldd; /* mount info on-disk */
+ struct fsfilt_operations *ll_fsops;
int ll_flags;
struct list_head ll_conn_chain; /* per-conn chain of SBs */
void ll_options(char *options, char **ost, char **mds, int *flags);
void ll_lli_init(struct ll_inode_info *lli);
int ll_fill_super(struct super_block *sb, void *data, int silent);
-int client_fill_super(struct super_block *sb, void *data);
+int client_fill_super(struct super_block *sb);
void client_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_iocontrol(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg);
void ll_umount_begin(struct super_block *sb);
-int lustre_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);
RETURN(err);
} /* ll_read_super */
-int client_fill_super(struct super_block *sb,
- struct lustre_mount_data * lmd)
+int client_fill_super(struct super_block *sb)
{
struct lustre_profile *lprof;
struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct lustre_mount_data *lmd = sbi->ll_lmd;
char * osc = NULL;
char * mdc = NULL;
char ll_instance[sizeof(sb) * 2 + 1];
#include <linux/lustre_user.h>
-/* requires a mounted device */
-int parse_last_rcvd(struct obd_device *obd, char *uuid, int *first_mount)
+int parse_mount_data(struct lvfs_run_ctxt *mount_ctxt,
+ struct lustre_disk_data *ldd)
+{
+ struct lvfs_run_ctxt saved;
+ struct file *file;
+ loff_t off = 0;
+ unsigned long len;
+
+ push_ctxt(&saved, mount_ctxt, NULL);
+
+ file = filp_open(MOUNT_DATA_FILE, O_RDONLY, 0644);
+ if (IS_ERR(file)) {
+ rc = PTR_ERR(file);
+ CERROR("cannot open %s: rc = %d\n", MOUNT_DATA_FILE, rc);
+ goto out;
+ }
+
+ len = file->f_dentry->d_inode->i_size;
+ CERROR("Have last_rcvd, size %lu\n", len);
+
+ rc = lustre_fread(file, ldd, len, &off);
+ if (rc) {
+ CERROR("OBD filter: error reading %s: rc %d\n",
+ MOUNT_DATA_FILE, rc);
+ goto out_close;
+ }
+ if (ldd->ldd_magic != LDD_MAGIC) {
+ CERROR("Bad magic in %s: %x!=%x\n", MOUNT_DATA_FILE,
+ ldd->ldd_magic, LDD_MAGIC);
+ rc = -EINVAL;
+ }
+
+out_close:
+ filp_close(file, 0);
+out:
+ pop_ctxt(&saved, mount_ctxt, NULL);
+ return(rc);
+}
+
+int parse_last_rcvd(struct ll_sb_info *sbi,
+ char *uuid, int *first_mount)
{
struct lvfs_run_ctxt saved;
struct file *file;
- /* FIXME filter_server_data and mds_server_data are identical?? should merge*/
struct lr_server_data *lsd;
loff_t off = 0;
int rc;
if (!lsd)
return -ENOMEM;
- /*setup llog ctxt*/
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ /* requires a mounted device */
+ LASSERT(sbi->ll_ctxt.pwdmnt);
+ push_ctxt(&saved, &sbi->ll_ctxt, NULL);
/* open and test the last rcvd file */
file = filp_open(LAST_RCVD, O_RDONLY, 0644);
CERROR("Have last_rcvd, size %lu\n",
(unsigned long)file->f_dentry->d_inode->i_size);
- rc = fsfilt_read_record(obd, file, lsd, sizeof(*lsd), &off);
+ LASSERT(sbi->ll_fsops);
+ rc = sbi->ll_fsops->fs_read_record(file, lsd, sizeof(*lsd), &off);
+ //rc = fsfilt_read_record(obd, file, lsd, sizeof(*lsd), &off);
if (rc) {
CERROR("OBD filter: error reading %s: rc %d\n", LAST_RCVD, rc);
goto out_close;
out_close:
filp_close(file, 0);
out:
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ pop_ctxt(&saved, &sbi->ll_ctxt, NULL);
OBD_FREE(lsd, sizeof(*lsd));
return(rc);
}
return(rc);
}
-static void lustre_manual_cleanup(struct ll_sb_info *sbi)
+void lustre_manual_cleanup(struct ll_sb_info *sbi)
{
while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL)
class_manual_cleanup(obd, NULL);
spin_lock(&ll_sb_lock);
list_del(&sbi->ll_list);
spin_unlock(&ll_sb_lock);
+ if (sbi->ll_ldd != NULL)
+ OBD_FREE(sbi->ll_ldd, sizeof(*sbi->ll_ldd));
OBD_FREE(sbi, sizeof(*sbi));
}
ll_s2sbi_nocast(sb) = NULL;
struct ll_sb_info *sbi = ll_s2sbi(sb);
struct l_linux_dirent *dirent, *n;
struct obd_device *obd;
- struct conf_obd *confobd;
+ struct mgmtcli_obd *mcobd;
char logname[LOG_NAME_MAX];
char flags[2] = "";
int err;
+ //FIXME create MGC
+
CERROR("server put_super uuid %s\n", sbi->ll_sb_uuid.uuid);
obd = class_uuid2obd(&sbi->ll_sb_uuid);
if (!obd) {
- CERROR("Can't get confobd %s\n", sbi->ll_sb_uuid.uuid);
+ CERROR("Can't get mcobd %s\n", sbi->ll_sb_uuid.uuid);
return;
}
- confobd = &obd->u.confobd;
+ mcobd = &obd->u.mgmtcli;
- if (confobd->cfobd_logs_info.ost_number > 0) {
+ if (mcobd->cfobd_logs_info.ost_number > 0) {
struct obd_ioctl_data ioc_data = { 0 };
CERROR("update new logs.\n");
err = obd_iocontrol(OBD_IOC_UPDATE_LOG, obd->obd_self_export,
}
/* Find all the logs in the LOGS directory */
- err = dentry_readdir(obd, confobd->cfobd_logs_dir,
- confobd->cfobd_lvfs_ctxt->loc_mnt,
+ err = dentry_readdir(obd, mcobd->cfobd_logs_dir,
+ mcobd->cfobd_lvfs_ctxt->loc_mnt,
&dentry_list);
if (err)
CERROR("Can't read LOGS dir, %d\n", err);
if (sbi->ll_flags & LL_UMOUNT_FORCE)
strcat(flags, "A");
- if (sbi->ll_flags & LL_UMOUNT_FAIL)
+ if (sbi->ll_flags & LL_UMOUNT_FAILOVER)
strcat(flags, "F");
/* Clean up all the -conf obd's in the LOGS directory.
FIXME this may not be complete / reasonable.
Really, we should have a list of every obd we started,
maybe an additional field to obd_device for group_uuid, then
- just use lustre_manual_cleanup.
+ just use lustre_manual_cleanup.
CRAY_MDS:
client client-clean mdsA mdsA-clean mdsA-conf
CRAY_OST:
if (obd)
class_manual_cleanup(obd, flags);
- /* Cleanup the confobd itself */
+ /* Cleanup the mcobd itself */
if (sbi->ll_lmd != NULL) {
lustre_manual_cleanup(sbi);
OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
- OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance) + 1);
}
+
+ //FIXME cleanup does the mntput; we have to make sure MGS is done with
+ //it as well - we should probably do it here.
lustre_free_sbi(sb);
}
struct ll_sb_info *sbi = ll_s2sbi(sb);
CERROR("Umount -f\n");
+ // FIXME decide FORCE or FAILOVER based on mount option -o umount=failover
sbi->ll_flags |= LL_UMOUNT_FORCE;
}
sb->s_blocksize = 4096;
sb->s_blocksize_bits = log2(sb->s_blocksize);
- sb->s_magic = LL_SUPER_MAGIC; /* FIXME different magic? */
+ sb->s_magic = LL_SUPER_MAGIC;
sb->s_maxbytes = PAGE_CACHE_MAXBYTES;
sb->s_flags |= MS_RDONLY;
sb->s_op = &server_ops;
}
/* Get the log "profile" from a remote MGMT and process it.
- FIXME If remote doesn't exists, try local
+ FIXME If remote doesn't exist, try local
This func should work for both clients and servers */
int lustre_get_process_log(struct lustre_mount_data *lmd, char * profile,
- struct config_llog_instance *cfg, int allow_recov)
+ struct config_llog_instance *cfg)
{
char * peer = "MDS_PEER_UUID";
struct obd_device *obd;
class_uuid_t uuid;
struct obd_uuid mdc_uuid;
struct llog_ctxt *ctxt;
- int rc = 0;
- int err;
+ int allow_recov = (lmd->lmd_flags & LMD_FLG_RECOVER) > 0;
+ int err, rc = 0;
ENTRY;
- if (lmd_bad_magic(lmd))
- RETURN(-EINVAL);
-
LASSERT(lmd->lmd_mgmtnid.primary != PTL_NID_ANY);
lustre_generate_random_uuid(uuid);
/* Process all local logs.
FIXME clients and servers should use the same fn. No need to have MDS
-do client and confobd do servers. */
+do client and confobd do servers. MGC should do both. */
int lustre_process_logs(struct lustre_mount_data *lmd,
struct config_llog_instance *cfg, int allow_recov)
{
struct list_head dentry_list;
struct l_linux_dirent *dirent, *n;
struct obd_device *obd;
- struct conf_obd *confobd;
+ struct mgmtcli_obd *mcobd;
char lr_uuid[40];
char logname[LOG_NAME_MAX];
- char confname[40];
+ char mcname[40];
int is_first_mount = 0;
int err;
- if (lmd_bad_magic(lmd))
- return(-EINVAL);
-
- if (lmd_is_client(lmd)) {
- return(lustre_get_process_log(lmd, lmd->lmd_dev,
- cfg, allow_recov));
- }
- /* We're a server, set up a confobd to process the logs */
- sprintf(confname, "CONF%s ", lmd->lmd_fsname);
- err = do_lcfg(LCFG_ATTACH, confname, LUSTRE_CONFOBD_NAME,
+ /* We're a server, set up a mcobd to process the logs */
+ sprintf(mcname, "CONF%s ", lmd->lmd_dev);
+ err = do_lcfg(LCFG_ATTACH, mcname, LUSTRE_CONFOBD_NAME,
cfg->cfg_uuid.uuid, 0, 0);
if (err)
return(err);
/* Apparently servers mount the fs on top of the confobd mount,
so our confobd mount options must be the same as the server?? */
- err = do_lcfg(LCFG_SETUP, confname, lmd->u.srv.lmd_source,
+ err = do_lcfg(LCFG_SETUP, mcname, lmd->u.srv.lmd_source,
lmd->u.srv.lmd_fstype, lmd->u.srv.lmd_fsopts, 0);
if (err) {
- CERROR("confobd setup error %d\n", err);
- do_lcfg(LCFG_DETACH, confname, 0, 0, 0, 0);
+ CERROR("mcobd setup error %d\n", err);
+ do_lcfg(LCFG_DETACH, mcname, 0, 0, 0, 0);
return(err);
}
- obd = class_name2obd(confname);
+ obd = class_name2obd(mcname);
if (!obd) {
- CERROR("Can't find confobd %s\n", confname);
+ CERROR("Can't find mcobd %s\n", mcname);
return(-ENOTCONN);
}
- confobd = &obd->u.confobd;
+ mcobd = &obd->u.mgmtcli;
err = parse_last_rcvd(obd, lr_uuid, &is_first_mount);
if (err) {
CERROR("Can't read %s\n", STRIPE_FILE);
return(err);
}
- confobd_start_accept(obd, lmd, lr_uuid, stripe_size);
+ mcobd_start_accept(obd, lmd, lr_uuid, stripe_size);
#endif
}
/* Find all the logs in the LOGS directory */
- err = dentry_readdir(obd, confobd->cfobd_logs_dir,
- confobd->cfobd_lvfs_ctxt->loc_mnt,
+ err = dentry_readdir(obd, mcobd->cfobd_logs_dir,
+ mcobd->cfobd_lvfs_ctxt->loc_mnt,
&dentry_list);
if (err) {
CERROR("Can't read LOGS dir\n");
return(err);
}
-static int lustre_kern_mount(struct lustre_mount_data *lmd)
+/* Kernel mount using mount options in MOUNT_DATA_FILE */
+static int lustre_kern_mount(struct ll_sb_info *sbi)
{
+ struct lvfs_run_ctxt mount_ctxt;
+ struct lvfs_run_ctxt saved;
struct lustre_disk_data *ldd;
+ struct lustre_mount_data *lmd = sbi->ll_lmd;
char *options = NULL;
struct vfsmount *mnt;
unsigned long page;
+ int rc;
OBD_ALLOC(ldd, sizeof(*ldd));
if (!ldd)
return(-ENOMEM);
-
- //FIXME read MOUNT_DATA_FILE
- page = __get_free_page(GFP_KERNEL);
- if (!page)
- return(-ENOMEM);
+ /* Pre-mount ext3 with no options to read the MOUNT_DATA_FILE */
+ CERROR("Pre-mount ext3 %s\n", lmd->lmd_dev);
+ mnt = do_kern_mount("ext3", 0, lmd->lmd_dev, 0);
+ if (IS_ERR(mnt)) {
+ rc = PTR_ERR(mnt);
+ CERROR("premount failed: rc = %d\n", rc);
+ goto out_free;
+ }
+
+ OBD_SET_CTXT_MAGIC(&mount_ctxt);
+ mount_ctxt.pwdmnt = mnt;
+ mount_ctxt.pwd = mnt->mnt_root;
+ mount_ctxt.fs = get_ds();
+ //mount_ctxt.cb_ops = mds_lvfs_ops;
+
+ rc = parse_mount_data(&mount_ctxt, ldd);
+ //unlock_kernel();
+ mntput(mnt);
+ //lock_kernel();
+
+ if (rc) {
+ CERROR("premount parse options failed: rc = %d\n", rc);
+ goto out_free;
+ }
+
+ /* Done with our pre-mount, now do the real mount. */
+ /* Glom up mount options */
+ page = __get_free_page(GFP_KERNEL);
+ if (!page) {
+ rc = -ENOMEM;
+ goto out_free;
+ }
options = (char *)page;
memset(options, 0, PAGE_SIZE);
+ strcpy(options, ldd->ldd_mount_opts);
+ if (strlen(lmd->lmd_opts)) {
+ if (strlen(options))
+ strcat(options, ",");
+ strcat(options, ldd->ldd_mount_opts);
+ }
- /* lctl_setup 1:/dev/loop/0 2:ext3 3:mdsA 4:errors=remount-ro,iopen_nopriv*/
- if (LUSTRE_CFG_BUFLEN(lcfg, 4) > 0 && lustre_cfg_buf(lcfg, 4))
- sprintf(options + strlen(options), ",%s",
- lustre_cfg_string(lcfg, 4));
+ CERROR("kern_mount: %s %s %s\n", MT_STR(ldd), lmd->lmd_dev, options);
- mnt = do_kern_mount(MT_STR(ldd), 0,
- lmd->lmd_dev,
- (void *)ldd->ldd_mount_opts);
+ mnt = do_kern_mount(MT_STR(ldd), 0, lmd->lmd_dev, (void *)options);
free_page(page);
if (IS_ERR(mnt)) {
rc = PTR_ERR(mnt);
CERROR("do_kern_mount failed: rc = %d\n", rc);
- GOTO(err_ops, rc);
+ goto out_free;
}
- CDEBUG(D_SUPER, "%s: mnt = %p\n", lustre_cfg_string(lcfg, 1), mnt);
+ /* ldd freed at sbi cleanup */
+ sbi->ll_ldd = ldd;
+ sbi->ll_ctxt.pwdmnt = mnt;
+ sbi->ll_ctxt.pwd = mnt->mnt_root;
+ sbi->ll_ctxt.fs = get_ds();
+ sbi->ll_fsops = fsfilt_get_ops(MT_STR(ldd));
+
+ CDEBUG(D_SUPER, "%s: mnt = %p\n", lmd->lmd_dev, mnt);
+ return(0);
+
+out_free:
+ OBD_FREE(ldd, sizeof(*ldd));
+ return(rc);
}
+/* Common mount */
int lustre_fill_super(struct super_block *sb, void *data, int silent)
{
struct lustre_mount_data * lmd = data;
sprintf(ll_instance, "%p", sb);
cfg.cfg_instance = ll_instance;
cfg.cfg_uuid = sbi->ll_sb_uuid;
-
- if (!lmd_is_client(lmd)) {
- err = lustre_kern_mount(lmd);
- if (err) {
- CERROR("Unable to mount device %s: %d\n",
- lmd->lmd_dev, err);
- GOTO(out_free, err);
- }
- }
+
+ /*FIXME mgc = create_mgc(sbi);
+ name "fsname-mgc"? or 1 mgc per node?
+ */
- /* sets up all obd devices (server or client) */
- err = lustre_process_logs(lmd, &cfg, 0);
- if (err < 0) {
- CERROR("Unable to process log: %d\n", err);
- GOTO(out_free, err);
- }
-
if (lmd_is_client(lmd)) {
+ err = lustre_get_process_log(lmd,
+ lmd->lmd_dev/* FIXME or "client"?*/,
+ &cfg)
+ if (err < 0) {
+ CERROR("Unable to process log: %d\n", err);
+ GOTO(out_free, err);
+ }
/* Connect and start */
- err = client_fill_super(sb, lmd);
+ err = client_fill_super(sb);
if (err < 0) {
CERROR("Unable to mount client: %s\n",
lmd->u.cli.lmd_profile);
GOTO(out_free, err);
}
+
} else {
+ /* Server, so mount to read server info */
+ err = lustre_kern_mount(sbi);
+ if (err) {
+ CERROR("Unable to mount device %s: %d\n",
+ lmd->lmd_dev, err);
+ GOTO(out_free, err);
+ }
+ CERROR("Found service %s for fs %s on device %s\n",
+ sbi->ll_ldd->ldd_svname, sbi->ll_ldd->ldd_fsname,
+ lmd->lmd_dev);
+
+ /* Set up all obd devices for service */
+ err = lustre_process_logs(lmd, &cfg, 0);
+ if (err < 0) {
+ CERROR("Unable to process log: %d\n", err);
+ GOTO(out_free, err);
+ }
+
+ /* Finally, put something at the mount point. */
CERROR("Mounting server\n");
err = server_fill_super(sb);
- // FIXME overmount client here
+ /* 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! */
}
RETURN(err);
RETURN(err);
} /* lustre_fill_super */
+/* Common umount */
+void lustre_put_super(struct super_block *sb)
+{
+ struct ll_sb_info *sbi = ll_s2sbi(sb);
+ if (sbi->ll_lmd && !lmd_is_client(sbi->ll_lmd) {
+ // FIXME unmount overmounted client first
+ return server_put_super(sb);
+ } else {
+ return client_put_super(sb);
+ }
+}
-
+/* Common remount */
int lustre_remount_fs(struct super_block *sb, int *flags, char *data)
{
struct ll_sb_info *sbi = ll_s2sbi(sb);
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 (sbi->ll_lmd && !lmd_is_client(sbi->ll_lmd) {
+ CERROR("Remount server RO %d\n", read_only);
+ } else {
+ 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)
}
+EXPORT_SYMBOL(lustre_init_sbi);
+EXPORT_SYMBOL(lustre_free_sbi);
+EXPORT_SYMBOL(lustre_fill_super);
+EXPORT_SYMBOL(lustre_put_super);
+EXPORT_SYMBOL(lustre_manual_cleanup);
+EXPORT_SYMBOL(lustre_remount_fs);
int rc = 0;
ENTRY;
+ /* setup 1:/dev/loop/0 2:ext3 3:mdsA 4:errors=remount-ro,iopen_nopriv*/
+
if (lcfg->lcfg_bufcount < 3)
RETURN(rc = -EINVAL);
sprintf(options + strlen(options), ",%s",
lustre_cfg_string(lcfg, 4));
+ //FIXME mount was already done in lustre_fill_super,
+ //we just need to access it
mnt = do_kern_mount(lustre_cfg_string(lcfg, 2), 0,
lustre_cfg_string(lcfg, 1), (void *)options);
free_page(page);
#include <linux/lustre_log.h>
#include <linux/lustre_commit_confd.h>
#include <libcfs/list.h>
+#include <linux/lustre_disk.h>
#include <linux/lustre_quota.h>
#include "filter_internal.h"
/* we don't allocate new transnos for replayed requests */
if (oti->oti_transno == 0) {
spin_lock(&filter->fo_translock);
- last_rcvd = le64_to_cpu(filter->fo_fsd->fsd_last_transno) + 1;
- filter->fo_fsd->fsd_last_transno = cpu_to_le64(last_rcvd);
+ last_rcvd = le64_to_cpu(filter->fo_fsd->lsd_last_transno) + 1;
+ filter->fo_fsd->lsd_last_transno = cpu_to_le64(last_rcvd);
spin_unlock(&filter->fo_translock);
oti->oti_transno = last_rcvd;
} else {
spin_lock(&filter->fo_translock);
last_rcvd = oti->oti_transno;
- if (last_rcvd > le64_to_cpu(filter->fo_fsd->fsd_last_transno))
- filter->fo_fsd->fsd_last_transno =
+ if (last_rcvd > le64_to_cpu(filter->fo_fsd->lsd_last_transno))
+ filter->fo_fsd->lsd_last_transno =
cpu_to_le64(last_rcvd);
spin_unlock(&filter->fo_translock);
}
}
fed->fed_lr_idx = cl_idx;
- fed->fed_lr_off = le32_to_cpu(filter->fo_fsd->fsd_client_start) +
- cl_idx * le16_to_cpu(filter->fo_fsd->fsd_client_size);
+ fed->fed_lr_off = le32_to_cpu(filter->fo_fsd->lsd_client_start) +
+ cl_idx * le16_to_cpu(filter->fo_fsd->lsd_client_size);
LASSERTF(fed->fed_lr_off > 0, "fed_lr_off = %llu\n", fed->fed_lr_off);
CDEBUG(D_INFO, "client at index %d (%llu) with UUID '%s' added\n",
/* assumes caller is already in kernel ctxt */
int filter_update_server_data(struct obd_device *obd, struct file *filp,
- struct filter_server_data *fsd, int force_sync)
+ struct lr_server_data *fsd, int force_sync)
{
loff_t off = 0;
int rc;
ENTRY;
- CDEBUG(D_INODE, "server uuid : %s\n", fsd->fsd_uuid);
+ CDEBUG(D_INODE, "server uuid : %s\n", fsd->lsd_uuid);
CDEBUG(D_INODE, "server last_rcvd : "LPU64"\n",
- le64_to_cpu(fsd->fsd_last_transno));
+ le64_to_cpu(fsd->lsd_last_transno));
CDEBUG(D_INODE, "server last_mount: "LPU64"\n",
- le64_to_cpu(fsd->fsd_mount_count));
+ le64_to_cpu(fsd->lsd_mount_count));
rc = fsfilt_write_record(obd, filp, fsd, sizeof(*fsd), &off,force_sync);
if (rc)
- CERROR("error writing filter_server_data: rc = %d\n", rc);
+ CERROR("error writing lr_server_data: rc = %d\n", rc);
RETURN(rc);
}
static int filter_init_server_data(struct obd_device *obd, struct file * filp)
{
struct filter_obd *filter = &obd->u.filter;
- struct filter_server_data *fsd;
+ struct lr_server_data *fsd;
struct filter_client_data *fcd = NULL;
struct inode *inode = filp->f_dentry->d_inode;
unsigned long last_rcvd_size = inode->i_size;
int rc;
/* ensure padding in the struct is the correct size */
- LASSERT (offsetof(struct filter_server_data, fsd_padding) +
- sizeof(fsd->fsd_padding) == FILTER_LR_SERVER_SIZE);
+ LASSERT (offsetof(struct lr_server_data, lsd_padding) +
+ sizeof(fsd->lsd_padding) == FILTER_LR_SERVER_SIZE);
LASSERT (offsetof(struct filter_client_data, fcd_padding) +
sizeof(fcd->fcd_padding) == FILTER_LR_CLIENT_SIZE);
if (last_rcvd_size == 0) {
CWARN("%s: initializing new %s\n", obd->obd_name, LAST_RCVD);
- memcpy(fsd->fsd_uuid, obd->obd_uuid.uuid,sizeof(fsd->fsd_uuid));
- fsd->fsd_last_transno = 0;
- mount_count = fsd->fsd_mount_count = 0;
- fsd->fsd_server_size = cpu_to_le32(FILTER_LR_SERVER_SIZE);
- fsd->fsd_client_start = cpu_to_le32(FILTER_LR_CLIENT_START);
- fsd->fsd_client_size = cpu_to_le16(FILTER_LR_CLIENT_SIZE);
- fsd->fsd_subdir_count = cpu_to_le16(FILTER_SUBDIR_COUNT);
+ memcpy(fsd->lsd_uuid, obd->obd_uuid.uuid,sizeof(fsd->lsd_uuid));
+ fsd->lsd_last_transno = 0;
+ mount_count = fsd->lsd_mount_count = 0;
+ fsd->lsd_server_size = cpu_to_le32(FILTER_LR_SERVER_SIZE);
+ fsd->lsd_client_start = cpu_to_le32(FILTER_LR_CLIENT_START);
+ fsd->lsd_client_size = cpu_to_le16(FILTER_LR_CLIENT_SIZE);
+ fsd->lsd_subdir_count = cpu_to_le16(FILTER_SUBDIR_COUNT);
filter->fo_subdir_count = FILTER_SUBDIR_COUNT;
} else {
rc = fsfilt_read_record(obd, filp, fsd, sizeof(*fsd), &off);
LAST_RCVD, rc);
GOTO(err_fsd, rc);
}
- if (strcmp(fsd->fsd_uuid, obd->obd_uuid.uuid) != 0) {
+ if (strcmp(fsd->lsd_uuid, obd->obd_uuid.uuid) != 0) {
CERROR("OBD UUID %s does not match last_rcvd UUID %s\n",
- obd->obd_uuid.uuid, fsd->fsd_uuid);
+ obd->obd_uuid.uuid, fsd->lsd_uuid);
GOTO(err_fsd, rc = -EINVAL);
}
- mount_count = le64_to_cpu(fsd->fsd_mount_count);
- filter->fo_subdir_count = le16_to_cpu(fsd->fsd_subdir_count);
+ mount_count = le64_to_cpu(fsd->lsd_mount_count);
+ filter->fo_subdir_count = le16_to_cpu(fsd->lsd_subdir_count);
}
- if (fsd->fsd_feature_incompat & ~cpu_to_le32(FILTER_INCOMPAT_SUPP)) {
+ if (fsd->lsd_feature_incompat & ~cpu_to_le32(FILTER_INCOMPAT_SUPP)) {
CERROR("unsupported feature %x\n",
- le32_to_cpu(fsd->fsd_feature_incompat) &
+ le32_to_cpu(fsd->lsd_feature_incompat) &
~FILTER_INCOMPAT_SUPP);
GOTO(err_fsd, rc = -EINVAL);
}
- if (fsd->fsd_feature_rocompat & ~cpu_to_le32(FILTER_ROCOMPAT_SUPP)) {
+ if (fsd->lsd_feature_rocompat & ~cpu_to_le32(FILTER_ROCOMPAT_SUPP)) {
CERROR("read-only feature %x\n",
- le32_to_cpu(fsd->fsd_feature_rocompat) &
+ le32_to_cpu(fsd->lsd_feature_rocompat) &
~FILTER_ROCOMPAT_SUPP);
/* Do something like remount filesystem read-only */
GOTO(err_fsd, rc = -EINVAL);
}
CDEBUG(D_INODE, "%s: server last_rcvd : "LPU64"\n",
- obd->obd_name, le64_to_cpu(fsd->fsd_last_transno));
+ obd->obd_name, le64_to_cpu(fsd->lsd_last_transno));
CDEBUG(D_INODE, "%s: server mount_count: "LPU64"\n",
obd->obd_name, mount_count + 1);
CDEBUG(D_INODE, "%s: server data size: %u\n",
- obd->obd_name, le32_to_cpu(fsd->fsd_server_size));
+ obd->obd_name, le32_to_cpu(fsd->lsd_server_size));
CDEBUG(D_INODE, "%s: per-client data start: %u\n",
- obd->obd_name, le32_to_cpu(fsd->fsd_client_start));
+ obd->obd_name, le32_to_cpu(fsd->lsd_client_start));
CDEBUG(D_INODE, "%s: per-client data size: %u\n",
- obd->obd_name, le32_to_cpu(fsd->fsd_client_size));
+ obd->obd_name, le32_to_cpu(fsd->lsd_client_size));
CDEBUG(D_INODE, "%s: server subdir_count: %u\n",
- obd->obd_name, le16_to_cpu(fsd->fsd_subdir_count));
+ obd->obd_name, le16_to_cpu(fsd->lsd_subdir_count));
CDEBUG(D_INODE, "%s: last_rcvd clients: %lu\n", obd->obd_name,
- last_rcvd_size <= le32_to_cpu(fsd->fsd_client_start) ? 0 :
- (last_rcvd_size - le32_to_cpu(fsd->fsd_client_start)) /
- le16_to_cpu(fsd->fsd_client_size));
+ last_rcvd_size <= le32_to_cpu(fsd->lsd_client_start) ? 0 :
+ (last_rcvd_size - le32_to_cpu(fsd->lsd_client_start)) /
+ le16_to_cpu(fsd->lsd_client_size));
if (!obd->obd_replayable) {
CWARN("%s: recovery support OFF\n", obd->obd_name);
GOTO(out, rc = 0);
}
- for (cl_idx = 0, off = le32_to_cpu(fsd->fsd_client_start);
+ for (cl_idx = 0, off = le32_to_cpu(fsd->lsd_client_start);
off < last_rcvd_size; cl_idx++) {
__u64 last_rcvd;
struct obd_export *exp;
/* Don't assume off is incremented properly by
* fsfilt_read_record(), in case sizeof(*fcd)
- * isn't the same as fsd->fsd_client_size. */
- off = le32_to_cpu(fsd->fsd_client_start) +
- cl_idx * le16_to_cpu(fsd->fsd_client_size);
+ * isn't the same as fsd->lsd_client_size. */
+ off = le32_to_cpu(fsd->lsd_client_start) +
+ cl_idx * le16_to_cpu(fsd->lsd_client_size);
rc = fsfilt_read_record(obd, filp, fcd, sizeof(*fcd), &off);
if (rc) {
CERROR("error reading FILT %s idx %d off %llu: rc %d\n",
exp = class_new_export(obd);
CDEBUG(D_HA, "RCVRNG CLIENT uuid: %s idx: %d lr: "LPU64
" srv lr: "LPU64"\n", fcd->fcd_uuid, cl_idx,
- last_rcvd, le64_to_cpu(fsd->fsd_last_transno));
+ last_rcvd, le64_to_cpu(fsd->lsd_last_transno));
if (exp == NULL)
GOTO(err_client, rc = -ENOMEM);
CDEBUG(D_OTHER, "client at idx %d has last_rcvd = "LPU64"\n",
cl_idx, last_rcvd);
- if (last_rcvd > le64_to_cpu(fsd->fsd_last_transno))
- fsd->fsd_last_transno = cpu_to_le64(last_rcvd);
+ if (last_rcvd > le64_to_cpu(fsd->lsd_last_transno))
+ fsd->lsd_last_transno = cpu_to_le64(last_rcvd);
}
if (fcd)
OBD_FREE(fcd, sizeof(*fcd));
- obd->obd_last_committed = le64_to_cpu(fsd->fsd_last_transno);
+ obd->obd_last_committed = le64_to_cpu(fsd->lsd_last_transno);
if (obd->obd_recoverable_clients) {
CWARN("RECOVERY: service %s, %d recoverable clients, "
"last_rcvd "LPU64"\n", obd->obd_name,
obd->obd_recoverable_clients,
- le64_to_cpu(fsd->fsd_last_transno));
+ le64_to_cpu(fsd->lsd_last_transno));
obd->obd_next_recovery_transno = obd->obd_last_committed + 1;
obd->obd_recovering = 1;
obd->obd_recovery_start = CURRENT_SECONDS;
out:
filter->fo_mount_count = mount_count + 1;
- fsd->fsd_mount_count = cpu_to_le64(filter->fo_mount_count);
+ fsd->lsd_mount_count = cpu_to_le64(filter->fo_mount_count);
/* save it, so mount count and last_transno is current */
rc = filter_update_server_data(obd, filp, filter->fo_fsd, 1);
CERROR("error renaming O/R to O/0: rc %d\n", rc);
GOTO(cleanup_O0, rc);
}
- filter->fo_fsd->fsd_feature_incompat |=
+ filter->fo_fsd->lsd_feature_incompat |=
cpu_to_le32(FILTER_INCOMPAT_GROUPS);
rc = filter_update_server_data(obd, filter->fo_rcvd_filp,
filter->fo_fsd, 1);
filter->fo_last_objid_files[i] = filp;
if (filp->f_dentry->d_inode->i_size == 0) {
- if (i == 0 && filter->fo_fsd->fsd_unused != 0) {
+ if (i == 0 && filter->fo_fsd->lsd_unused != 0) {
/* OST conversion, remove sometime post 1.0 */
filter->fo_last_objids[0] =
- le64_to_cpu(filter->fo_fsd->fsd_unused);
+ le64_to_cpu(filter->fo_fsd->lsd_unused);
CWARN("saving old objid "LPU64" to LAST_ID\n",
filter->fo_last_objids[0]);
} else {
#define FILTER_GRANT_CHUNK (2ULL*1024*1024)
-/* Data stored per server at the head of the last_rcvd file. In le32 order.
- * Try to keep this the same as mds_server_data so we might one day merge. */
-struct filter_server_data {
- __u8 fsd_uuid[40]; /* server UUID */
- __u64 fsd_unused; /* was fsd_last_objid - don't use for now */
- __u64 fsd_last_transno; /* last completed transaction ID */
- __u64 fsd_mount_count; /* FILTER incarnation number */
- __u32 fsd_feature_compat; /* compatible feature flags */
- __u32 fsd_feature_rocompat;/* read-only compatible feature flags */
- __u32 fsd_feature_incompat;/* incompatible feature flags */
- __u32 fsd_server_size; /* size of server data area */
- __u32 fsd_client_start; /* start of per-client data area */
- __u16 fsd_client_size; /* size of per-client data area */
- __u16 fsd_subdir_count; /* number of subdirectories for objects */
- __u64 fsd_catalog_oid; /* recovery catalog object id */
- __u32 fsd_catalog_ogen; /* recovery catalog inode generation */
- __u8 fsd_peeruuid[40]; /* UUID of MDS associated with this OST */
- __u8 fsd_padding[FILTER_LR_SERVER_SIZE - 140];
-};
-
/* Data stored per client in the last_rcvd file. In le32 order. */
struct filter_client_data {
__u8 fcd_uuid[40]; /* client UUID */
__u64 filter_next_id(struct filter_obd *, struct obdo *);
__u64 filter_last_id(struct filter_obd *, struct obdo *);
int filter_update_server_data(struct obd_device *, struct file *,
- struct filter_server_data *, int force_sync);
+ struct lr_server_data *, int force_sync);
int filter_update_last_objid(struct obd_device *, obd_gr, int force_sync);
int filter_common_setup(struct obd_device *, obd_count len, void *buf,
void *option);
struct obd_ioobj *, int niocount, struct niobuf_local *,
struct obd_trans_info *, int rc);
int filter_brw(int cmd, struct obd_export *, struct obdo *,
- struct lov_stripe_md *, obd_count oa_bufs, struct brw_page *,
- struct obd_trans_info *);
+ struct lov_stripe_md *, obd_count oa_bufs, struct brw_page *,
+ struct obd_trans_info *);
void flip_into_page_cache(struct inode *inode, struct page *new_page);
void filter_free_dio_pages(int objcount, struct obd_ioobj *obj,
int niocount, struct niobuf_local *res);
LIBPTLCTL := $(top_builddir)/portals/utils/libptlctl.a
sbin_scripts = lconf lmc llanalyze llstat.pl llobdstat.pl lactive \
- load_ldap.sh lrun lwizard mount.lustre mkfs.lustre
+ load_ldap.sh lrun lwizard
bin_scripts = lfind lstripe llog_reader
if UTILS
-rootsbin_SCRIPTS = mount.lustre mkfs.lustre
-sbin_PROGRAMS = lctl obdio obdbarrier lload wirecheck wiretest mount.lustre mkfs.lustre
+rootsbin_SCRIPTS =
+sbin_PROGRAMS = lctl obdio obdbarrier lload wirecheck wiretest mount_lustre mount.lustre mkfs_lustre mkfs.lustre
bin_PROGRAMS = lfs llog_reader
lib_LIBRARIES = liblustreapi.a
sbin_SCRIPTS = $(sbin_scripts)
bin_SCRIPTS = $(bin_scripts)
endif # UTILS
-lctl_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
-lctl_DEPENDENCIES := $(LIBPTLCTL)
-
-lfs_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL)
-lfs_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
-
-lload_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
-lload_DEPENDENCIES := $(LIBPTLCTL)
-
-llog_reader_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
-llog_reader_DEPENDENCIES := $(LIBPTLCTL)
-
liblustreapi_a_SOURCES = liblustreapi.c
wirecheck_SOURCES = wirecheck.c
wirecheck_CPPFLAGS = -DCC="\"$(CC)\""
wiretest_SOURCES = wiretest.c
+lctl_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
+lctl_DEPENDENCIES := $(LIBPTLCTL)
lctl_SOURCES = parser.c obd.c lustre_cfg.c lctl.c parser.h obdctl.h
+lload_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
+lload_DEPENDENCIES := $(LIBPTLCTL)
lload_SOURCES = lload.c
+
obdio_SOURCES = obdio.c obdiolib.c obdiolib.h
obdbarrier_SOURCES = obdbarrier.c obdiolib.c obdiolib.h
+
+lfs_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL)
+lfs_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
lfs_SOURCES = lfs.c parser.c obd.c
-mount_lustre_LDADD = $(LIBREADLINE) $(LIBPTLCTL)
+llog_reader_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
+llog_reader_DEPENDENCIES := $(LIBPTLCTL)
+llog_reader_SOURCES = llog_reader.c
+
+mount_lustre_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
mount_lustre_DEPENDENCIES := $(LIBPTLCTL)
mount_lustre_SOURCES = mount_lustre.c
-mkfs_lustre_LDADD = $(LIBREADLINE) $(LIBPTLCTL)
+mkfs_lustre_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
mkfs_lustre_DEPENDENCIES := $(LIBPTLCTL)
-mkfs_lustre_SOURCES = mkfs_lustre.c lustre_cfg.c obd.c obdctl.h
-
-llog_reader_SOURCES = llog_reader.c
+mkfs_lustre_SOURCES = parser.c obd.c lustre_cfg.c mkfs_lustre.c parser.h obdctl.h
EXTRA_DIST = $(bin_scripts) $(sbin_scripts)
#include <sys/types.h>
#include <sys/stat.h>
-
#include <string.h>
#include <getopt.h>
"\t\t--configdev=<altdevice|file>: store configuration info\n"
"\t\t\tfor this device on an alternate device\n"
"\t\t--failover=<failover-address>\n"
+ "\t\t--backfstype=<fstype>: backing fs type (ext3, ldiskfs)\n"
"\t\t--device_size=#N(KB):device size \n"
"\t\t--stripe_count=#N:number of stripe\n"
"\t\t--stripe_size=#N(KB):stripe size\n"
"\t\t--index=#N:target index\n"
- "\t\t--mountopts=<opts>: permanent mount options\n"
- "\t\t--smfsopts=<opts>: smfs format options\n"
- "\t\t--ext3opts=<opts>: ext3 format options\n"
+ "\t\t--mountfsoptions=<opts>: permanent mount options\n"
+ "\t\t--mkfsoptions=<opts>: format options\n"
"\t\t--timeout=<secs>: system timeout period\n"
- "\t\t--maxwait=<secs>: time to wait for other servers to join\n"
- "\t\t--forceformat: overwrite an existing disk\n"
+ "\t\t--startupwait=<secs>: time to wait for other servers to join\n"
+ "\t\t--reformat: overwrite an existing disk\n"
"\t\t--verbose\n");
exit(out != stdout);
}
lsd.lsd_index = mop->mo_index;
fwrite(&lsd, sizeof(lsd), 1, filep);
ret = 0;
-
-out_close:
fclose(filep);
out_umnt:
sprintf(cmd, "umount %s", mntpt);
if (mop->mo_device_sz != 0) {
if (mop->mo_device_sz < 8096){
fprintf(stderr, "size of filesystem must be larger "
- "than 8MB, but is set to %dKB\n",
+ "than 8MB, but is set to %ldKB\n",
mop->mo_device_sz);
return EINVAL;
}
if (journal_sz > 400)
journal_sz = 400;
if (journal_sz) {
- sprintf(buf, " -J size=%d", journal_sz);
+ sprintf(buf, " -J size=%ld", journal_sz);
strcat(mop->mo_mkfsopts, buf);
}
}
else if ((IS_OST(&mop->mo_ldd) && (device_sz > 1000000)))
inode_sz = 16384;
if (inode_sz > 0) {
- sprintf(buf, " -i %d", inode_sz);
+ sprintf(buf, " -i %ld", inode_sz);
strcat(mop->mo_mkfsopts, buf);
}
}
} else if (mop->mo_ldd.ldd_mount_type == LDD_MT_REISERFS) {
long journal_sz = 0;
if (journal_sz > 0) { /* FIXME */
- sprintf(buf, " --journal_size %d", journal_sz);
+ sprintf(buf, " --journal_size %ld", journal_sz);
strcat(mop->mo_mkfsopts, buf);
}
sprintf(mkfs_cmd, "mkreiserfs -ff ");
} else {
fprintf(stderr,"unsupported fs type: %d (%s)\n",
mop->mo_ldd.ldd_mount_type,
- MT_STR(mop->mo_ldd));
+ MT_STR(&mop->mo_ldd));
return EINVAL;
}
init_loop_base();
- sprintf(cmd, "dd if=/dev/zero bs=1k count=0 seek=%d of=%s",
+ sprintf(cmd, "dd if=/dev/zero bs=1k count=0 seek=%ld of=%s",
mop->mo_device_sz, mop->mo_device);
ret = run_command(cmd, cmd_out);
if (ret != 0){
mop->mo_hostnid.primary = libcfs_str2nid(hostname);
}
-static inline badopt(char opt, char *type)
+static inline void badopt(char opt, char *type)
{
fprintf(stderr, "%s: '%c' only valid for %s\n",
progname, opt, type);
{
struct mkfs_opts mop;
static struct option long_opt[] = {
+ {"backfstype", 1, 0, 'b'},
{"configdev", 1, 0, 'C'},
{"device_size", 1, 0, 'd'},
- {"ext3opts", 1, 0, 'e'},
{"fsname",1, 0, 'n'},
{"failover", 1, 0, 'f'},
- {"forceformat", 0, 0, 'F'},
{"help", 0, 0, 'h'},
{"index", 1, 0, 'I'},
- {"maxwait", 1, 0, 'w'},
{"mdt", 0, 0, 'M'},
{"mgmt", 0, 0, 'G'},
{"mgmtnode", 1, 0, 'm'},
- {"mountopts", 1, 0, 'o'},
+ {"mkfsoptions", 1, 0, 'k'},
+ {"mountfsoptions", 1, 0, 'o'},
{"ost", 0, 0, 'O'},
- {"smfsopts", 1, 0, 'S'},
+ {"reformat", 0, 0, 'r'},
+ {"startupwait", 1, 0, 'w'},
{"stripe_count", 1, 0, 'c'},
{"stripe_size", 1, 0, 's'},
{"stripe_index", 1, 0, 'i'},
{"verbose", 0, 0, 'v'},
{0, 0, 0, 0}
};
- char *optstring = "C:d:e:n:f:FhI:w:MGm:o:OS:c:s:i:t:v";
+ char *optstring = "b:C:d:n:f:hI:MGm:k:o:Orw:c:s:i:t:v";
char opt;
char *mountopts = NULL;
int ret = 0;
while ((opt = getopt_long(argc,argv,optstring,long_opt,NULL)) != EOF) {
switch (opt) {
+ case 'b': {
+ int i = 0;
+ while (i < LDD_MT_LAST) {
+ if (strcmp(optarg, mt_str(i)) == 0) {
+ mop.mo_ldd.ldd_mount_type = i;
+ break;
+ }
+ i++;
+ }
+ break;
+ }
case 'C':
//FIXME
exit(2);
case 'd':
mop.mo_device_sz = atol(optarg);
break;
- case 'e':
- if ((mop.mo_ldd.ldd_mount_type == LDD_MT_LDISKFS) ||
- (mop.mo_ldd.ldd_mount_type == LDD_MT_EXT3))
- strncpy(mop.mo_mkfsopts, optarg,
- sizeof(mop.mo_mkfsopts) - 1);
- else
- badopt(opt, "ext3,ldiskfs");
+ case 'k':
+ strncpy(mop.mo_mkfsopts, optarg,
+ sizeof(mop.mo_mkfsopts) - 1);
break;
case 'f':
mop.mo_hostnid.backup = libcfs_str2nid(optarg);
break;
- case 'F':
- mop.mo_flags |= MO_FORCEFORMAT;
- break;
case 'G':
mop.mo_ldd.ldd_flags |= LDD_SV_TYPE_MGMT;
break;
case 'O':
mop.mo_ldd.ldd_flags |= LDD_SV_TYPE_OST;
break;
+ case 'r':
+ mop.mo_flags |= MO_FORCEFORMAT;
+ break;
case 's':
if (IS_MDT(&mop.mo_ldd))
mop.mo_stripe_sz = atol(optarg) * 1024;
else
badopt(opt, "MDT");
break;
- case 'S':
- mop.mo_ldd.ldd_mount_type = LDD_MT_SMFS;
- strncpy(mop.mo_mkfsopts, optarg, sizeof(mop.mo_mkfsopts) - 1);
- break;
case 't':
mop.mo_timeout = atol(optarg);
break;
int
print_options(struct lustre_mount_data *lmd)
{
- printf("mgmt primary nid: %x\n", /*libcfs_nid2str*/(lmd->lmd_mgmtnid.primary));
- printf("mgmt backup nid: %x\n", /*libcfs_nid2str*/(lmd->lmd_mgmtnid.backup));
+ printf("mgmt primary nid: %s\n",
+ libcfs_nid2str(lmd->lmd_mgmtnid.primary));
+ printf("mgmt backup nid: %s\n",
+ libcfs_nid2str(lmd->lmd_mgmtnid.backup));
printf("device: %s\n", lmd->lmd_dev);
printf("mount point: %s\n", lmd->lmd_mtpt);
printf("options: %s\n", lmd->lmd_opts);