#include <linux/obd.h>
#include <linux/lustre_idl.h>
-#define LOG_NAME_MAX 256 /* 2.4 limit */
#define LOG_NAME_LIMIT(logname, name) \
snprintf(logname, sizeof(logname), "LOGS/%s", name)
#define LLOG_EEMPTY 4711
/* In-memory descriptor for a log object or log catalog */
struct llog_handle {
struct rw_semaphore lgh_lock;
- struct llog_logid lgh_id; /* id of this log */
+ struct llog_logid lgh_id; /* id of this log */
struct llog_log_hdr *lgh_hdr;
- struct mgc_open_llog *lgh_mol;
struct file *lgh_file;
- char *lgh_fsname;
int lgh_last_idx;
struct llog_ctxt *lgh_ctxt;
union {
int (*lop_connect)(struct llog_ctxt *ctxt, int count,
struct llog_logid *logid, struct llog_gen *gen,
struct obd_uuid *uuid);
- int (*lop_update)(struct llog_ctxt *ctxt, struct llog_handle **,
- struct llog_logid *logid, void *data);
+ /* XXX add 2 more: commit callbacks and llog recovery functions */
};
/* llog_lvfs.c */
extern struct llog_operations llog_lvfs_ops;
-int llog_lvfs_write_rec(struct llog_handle *loghandle,
- struct llog_rec_hdr *rec,
- struct llog_cookie *reccookie, int cookiecount,
- void *buf, int idx);
-int llog_lvfs_next_block(struct llog_handle *loghandle, int *cur_idx,
- int next_idx, __u64 *cur_offset, void *buf,
- int len);
-int llog_lvfs_close(struct llog_handle *loghandle);
-int llog_lvfs_destroy(struct llog_handle *loghandle);
-extern struct llog_operations mgs_llog_lvfs_ops;
-
int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
char *name, int count, struct llog_catid *idarray);
return(a.conn_cnt < b.conn_cnt ? 1 : 0);
}
-#define LLOG_GEN_INC(gen) ((gen).conn_cnt) ++
+#define LLOG_GEN_INC(gen) ((gen).conn_cnt ++)
#define LLOG_PROC_BREAK 0x0001
static inline int llog_obd2ops(struct llog_ctxt *ctxt,
struct lvfs_callback_ops {
struct dentry *(*l_fid2dentry)(__u64 id_ino, __u32 gen, __u64 gr, void *data);
- int (*l_open_llog) (__u64 id_ino, struct dentry *dentry, void *data);
};
#define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA
void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
struct lvfs_ucred *cred);
-void pop_ctxt(struct lvfs_run_ctxt *saveu, struct lvfs_run_ctxt *new_ctx,
+void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
struct lvfs_ucred *cred);
#ifdef __KERNEL__
-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_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);
return dchild;
}
-/* Look up an entry by inode number. */
-/* this function ONLY returns valid dget'd dentries with an initialized inode
- or errors */
-static inline struct dentry * ll_fid2dentry(struct dentry *parent,
- __u64 ino, __u32 generation)
-{
- char fid_name[32];
- struct inode *inode;
- struct dentry *result;
-
- if (ino == 0)
- RETURN(ERR_PTR(-ESTALE));
-
- snprintf(fid_name, sizeof(fid_name), "0x%lx", (unsigned long)ino);
-
- /* under ext3 this is neither supposed to return bad inodes
- nor NULL inodes. */
- result = ll_lookup_one_len(fid_name, parent, strlen(fid_name));
- if (IS_ERR(result))
- RETURN(result);
-
- inode = result->d_inode;
- if (!inode)
- RETURN(ERR_PTR(-ENOENT));
-
- if (inode->i_generation == 0 || inode->i_nlink == 0) {
- LCONSOLE_WARN("Found inode with zero generation or link -- this"
- " may indicate disk corruption (inode: %lu, link:"
- " %lu, count: %d)\n", inode->i_ino,
- (unsigned long)inode->i_nlink,
- atomic_read(&inode->i_count));
- dput(result);
- RETURN(ERR_PTR(-ENOENT));
- }
-
- if (generation && inode->i_generation != generation) {
- /* we didn't find the right inode.. */
- CDEBUG(D_INODE, "found wrong generation: inode %lu, link: %lu, "
- "count: %d, generation %u/%u\n", inode->i_ino,
- (unsigned long)inode->i_nlink,
- atomic_read(&inode->i_count), inode->i_generation,
- generation);
- dput(result);
- RETURN(ERR_PTR(-ENOENT));
- }
-
- RETURN(result);
-}
-
static inline void ll_sleep(int t)
{
set_current_state(TASK_INTERRUPTIBLE);
#define LUSTRE_SANOSC_NAME "sanosc"
#define LUSTRE_SANOST_NAME "sanost"
#define LUSTRE_MGS_NAME "mgs"
-#define LUSTRE_MGT_NAME "mgt"
#define LUSTRE_MGC_NAME "mgc"
//lprocfs_obd_cleanup(obd);
+ /* FIXME calls to mgc_fs_setup must take an obd ref to insure there's
+ no fs by the time we get here. */
LASSERT(cli->cl_mgc_vfsmnt == NULL);
rc = obd_llog_finish(obd, 0);
/* send back the whole mti in the reply */
rep_mti = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep_mti));
memcpy(rep_mti, mti, sizeof(*rep_mti));
+ // FIXME rc is redundant, part of the req (target_send_reply)
rep_mti->mti_rc = rc;
RETURN(rc);
}
int rc = 0;
ENTRY;
+ CDEBUG(D_MGS, "db_handler\n");
+
db->sdb_flags &= ~SDB_NO_LLOG;
if (rec->lrh_type == OBD_CFG_REC) {
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- rc = llog_create(llog_get_context(obd, LLOG_CONFIG_REPL_CTXT),
+ rc = llog_create(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT),
&loghandle, NULL, logname);
if (rc)
GOTO(out_pop, rc);
- llog_init_handle(loghandle, 0, NULL);
+ llog_init_handle(loghandle, LLOG_F_IS_PLAIN, NULL);
if (rc)
GOTO(out_close, rc);
int rc = 0;
rc = mgs_find_or_make_db(obd, mti->mti_fsname, &db);
+ if (rc) {
+ CERROR("Can't get db for %s\n", mti->mti_fsname);
+ return rc;
+ }
if (mti->mti_flags & LDD_F_SV_TYPE_OST)
mti->mti_stripe_index =
return rc;
}
-static inline int mgs_do_record(struct obd_device *obd, struct llog_handle *llh,
- struct lustre_cfg *lcfg)
+static int mgs_do_record(struct obd_device *obd, struct llog_handle *llh,
+ struct lustre_cfg *lcfg)
{
struct lvfs_run_ctxt saved;
struct llog_rec_hdr rec;
- int rc;
+ int buflen, rc;
+
+ LASSERT(llh);
+ LASSERT(llh->lgh_ctxt);
+
+ buflen = lustre_cfg_len(lcfg->lcfg_bufcount,
+ lcfg->lcfg_buflens);
+ rec.lrh_len = llog_data_len(buflen);
+ rec.lrh_type = OBD_CFG_REC;
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
/* idx = -1 means append */
rc = llog_write_rec(llh, &rec, NULL, 0, (void *)lcfg, -1);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ if (rc) {
+ CERROR("failed %d\n", rc);
+ }
+ LASSERT(!rc);
return rc;
}
struct lustre_cfg *lcfg;
int rc;
- CDEBUG(D_TRACE|D_WARNING, "lcfg %s %#x %s %s %s %s\n", cfgname,
+ CDEBUG(D_MGS, "lcfg %s %#x %s %s %s %s\n", cfgname,
cmd, s1, s2, s3, s4);
lustre_cfg_bufs_reset(&bufs, cfgname);
lustre_cfg_free(lcfg);
if (rc) {
- CERROR("lcfg %s %#x %s %s %s %s\n", cfgname,
+ CERROR("error %d: lcfg %s %#x %s %s %s %s\n", rc, cfgname,
cmd, s1, s2, s3, s4);
}
return(rc);
struct lustre_cfg *lcfg;
int rc;
+ CDEBUG(D_MGS, "lcfg %s lov_setup\n", device_name);
+
lustre_cfg_bufs_reset(&bufs, device_name);
lustre_cfg_bufs_set(&bufs, 1, desc, sizeof(*desc));
lcfg = lustre_cfg_new(LCFG_SETUP, &bufs);
char *lov_name, char *ost_uuid,
char *index, char *gen)
{
- return record_base(obd,llh,lov_name,0,LCFG_LOV_ADD_OBD,ost_uuid,index,gen,0);
+ return record_base(obd,llh,lov_name,0,LCFG_LOV_ADD_OBD,
+ ost_uuid,index,gen,0);
}
-static inline int record_mount_opt(struct obd_device *obd, struct llog_handle *llh,
- char *profile, char *lov_name, char *mdc_name)
+static inline int record_mount_opt(struct obd_device *obd,
+ struct llog_handle *llh,
+ char *profile, char *lov_name,
+ char *mdc_name)
{
- return record_base(obd,llh,NULL,0,LCFG_MOUNTOPT,profile,lov_name,mdc_name,0);
+ return record_base(obd,llh,NULL,0,LCFG_MOUNTOPT,
+ profile,lov_name,mdc_name,0);
}
static int record_start_log(struct obd_device *obd,
struct lvfs_run_ctxt saved;
int rc = 0;
- if (*llh)
- RETURN(-EBUSY);
+ if (*llh) {
+ GOTO(out, rc = -EBUSY);
+ }
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+out:
if (rc) {
CERROR("Can't start log %s: %d\n", name, rc);
}
RETURN(rc);
}
-static int record_end_log(struct obd_device *obd, struct llog_handle *llh)
+static int record_end_log(struct obd_device *obd, struct llog_handle **llh)
{
struct lvfs_run_ctxt saved;
int rc = 0;
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- rc = llog_close(llh);
+ rc = llog_close(*llh);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-
+ *llh = NULL;
RETURN(rc);
}
static int mgs_write_log_lov(struct obd_device *obd, char *fsname,
char *logname, char *lovname)
{
- struct llog_handle *llh;
+ struct llog_handle *llh = NULL;
struct lov_desc *lovdesc;
char *uuid;
int rc = 0;
/*
#01 L attach 0:lov_mdsA 1:lov 2:71ccb_lov_mdsA_19f961a9e1
#02 L lov_setup 0:lov_mdsA 1:(struct lov_desc)
- uuid=lov1_UUID, stripe count=1, size=1048576, offset=0, pattern=0
+ uuid=lov1_UUID, stripe count=1, size=1048576, offset=0, pattern=0
*/
/* FIXME just make lov_setup accept empty desc (put uuid in buf 2) */
rc = record_start_log(obd, &llh, logname);
rc = record_attach(obd, llh, lovname, "lov", uuid);
rc = record_lov_setup(obd, llh, lovname, lovdesc);
- rc = record_end_log(obd, llh);
RETURN(rc);
}
struct mgmt_target_info *mti)
{
struct system_db *db;
- struct llog_handle *llh;
+ struct llog_handle *llh = NULL;
char *cliname, *mdcname, *lovname, *nodeuuid, *mdsuuid, *mdcuuid;
int rc, first_log = 0;
return(-EINVAL);
}
+ CDEBUG(D_MGS, "writing new mdt %s\n", mti->mti_svname);
+
name_create(mti->mti_fsname, "-mdtlov", &lovname);
/* Append mdt info to mdt log */
if (LOG_IS_EMPTY(db)) {
rc = record_setup(obd,llh,mti->mti_svname,
"dev"/*ignored*/,"type"/*ignored*/,
mti->mti_svname, 0/*options*/);
- rc = record_end_log(obd, llh);
+ rc = record_end_log(obd, &llh);
/* Append mdt info to the client log */
name_create(mti->mti_fsname, "-client", &cliname);
rc = record_setup(obd,llh,mdcname,mdsuuid,nodeuuid,0,0);
/* FIXME add uuid, add_conn for failover mdt's */
rc = record_mount_opt(obd, llh, cliname, lovname, mdcname);
- rc = record_end_log(obd, llh);
+ rc = record_end_log(obd, &llh);
name_destroy(mdcuuid);
name_destroy(mdcname);
int first_log,
char *logname, char *lovname, char *ostuuid)
{
- struct llog_handle *llh;
+ struct llog_handle *llh = NULL;
char *nodeuuid, *oscname, *oscuuid;
char index[5];
int rc;
/*
#03 L add_uuid nid=uml1@tcp(0x20000c0a80201) 0: 1:uml1_UUID
- #04 L attach 0:OSC_uml1_ost1_MNT_client 1:osc 2:89070_lov1_a41dff511a
+ #04 L attach 0:OSC_uml1_ost1_MNT_client 1:osc 2:89070_lov1_a41dff51a
#05 L setup 0:OSC_uml1_ost1_MNT_client 1:ost1_UUID 2:uml1_UUID
#06 L add_uuid nid=uml2@tcp(0x20000c0a80202) 0: 1:uml2_UUID
#07 L add_conn 0:OSC_uml1_ost1_MNT_client 1:uml2_UUID
rc = record_setup(obd, llh, oscname, ostuuid, nodeuuid, 0, 0);
/* FIXME add uuid, add_conn for failover ost's */
snprintf(index, sizeof(index), "%d", mti->mti_stripe_index);
- rc = record_lov_add(obd, llh, lovname, ostuuid, index, "1"/*generation*/);
- rc = record_end_log(obd, llh);
+ rc = record_lov_add(obd,llh, lovname, ostuuid, index,"1"/*generation*/);
+ rc = record_end_log(obd, &llh);
name_destroy(oscuuid);
name_destroy(oscname);
struct mgmt_target_info *mti)
{
struct system_db *db;
- struct llog_handle *llh;
+ struct llog_handle *llh = NULL;
char *logname, *lovname, *ostuuid;
int rc, first_log = 0;
/* First time for all logs for this fs */
first_log++;
+ CDEBUG(D_MGS, "writing new ost %s\n", mti->mti_svname);
+
/* The ost startup log */
/*
attach obdfilter ost1 ost1_UUID
*/
rc = record_start_log(obd, &llh, mti->mti_svname);
name_create(mti->mti_svname, "_UUID", &ostuuid);
- rc = record_attach(obd, llh, mti->mti_svname, "obdfilter"/*LUSTRE_OST_NAME*/, ostuuid);
+ rc = record_attach(obd, llh, mti->mti_svname,
+ "obdfilter"/*LUSTRE_OST_NAME*/, ostuuid);
rc = record_setup(obd,llh,mti->mti_svname,
"dev"/*ignored*/,"type"/*ignored*/,
"f", 0/*options*/);
- rc = record_end_log(obd, llh);
+ rc = record_end_log(obd, &llh);
/* We also have to update the other logs where this osc is part of
the lov */
/* first assign flags to use llog_client_ops */
llh->llh_flags = flags;
rc = llog_read_header(handle);
+ CDEBUG(D_ERROR, "read header rc=%d fl=%d\n", rc, flags);
if (rc == 0) {
flags = llh->llh_flags;
if (uuid)
int saved_index = 0;
ENTRY;
+ LASSERT(llh);
+
OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
if (!buf)
RETURN(-ENOMEM);
RETURN(rc);
}
-int llog_lvfs_write_blob(struct obd_device *obd, struct l_file *file,
+static int llog_lvfs_write_blob(struct obd_device *obd, struct l_file *file,
struct llog_rec_hdr *rec, void *buf, loff_t off)
{
int rc;
RETURN(0);
}
-int llog_lvfs_read_header(struct llog_handle *handle)
+static int llog_lvfs_read_header(struct llog_handle *handle)
{
struct obd_device *obd;
int rc;
/* returns negative in on error; 0 if success && reccookie == 0; 1 otherwise */
/* appends if idx == -1, otherwise overwrites record idx. */
-int llog_lvfs_write_rec(struct llog_handle *loghandle,
+static int llog_lvfs_write_rec(struct llog_handle *loghandle,
struct llog_rec_hdr *rec,
struct llog_cookie *reccookie, int cookiecount,
void *buf, int idx)
* - cur_idx to the log index preceeding cur_offset
* returns -EIO/-EINVAL on error
*/
-int llog_lvfs_next_block(struct llog_handle *loghandle, int *cur_idx,
+static int llog_lvfs_next_block(struct llog_handle *loghandle, int *cur_idx,
int next_idx, __u64 *cur_offset, void *buf,
int len)
{
OBD_ALLOC(logname, PATH_MAX);
if (logname == NULL)
- return ERR_PTR(-ENOMEM);
+ return ERR_PTR(-ENOMEM);
len = snprintf(logname, PATH_MAX, "%s/%s",
MOUNT_CONFIGS_DIR, name);
-
if (len >= PATH_MAX - 1) {
filp = ERR_PTR(-ENAMETOOLONG);
} else {
- CERROR("logname = %s\n", logname);
filp = l_filp_open(logname, flags, mode);
if (IS_ERR(filp))
CERROR("logfile creation %s: %ld\n", logname,
/* This is a callback from the llog_* functions.
* Assumes caller has already pushed us into the kernel context. */
-int llog_lvfs_create(struct llog_ctxt *ctxt, struct llog_handle **res,
+static int llog_lvfs_create(struct llog_ctxt *ctxt, struct llog_handle **res,
struct llog_logid *logid, char *name)
{
struct llog_handle *handle;
} else if (name) {
handle->lgh_file = llog_filp_open(name, open_flags, 0644);
-
if (IS_ERR(handle->lgh_file))
GOTO(cleanup, rc = PTR_ERR(handle->lgh_file));
handle->lgh_file->f_dentry->d_inode->i_ino;
handle->lgh_id.lgl_ogen =
handle->lgh_file->f_dentry->d_inode->i_generation;
-
} else {
oa = obdo_alloc();
if (oa == NULL)
goto finish;
}
-int llog_lvfs_close(struct llog_handle *handle)
+static int llog_lvfs_close(struct llog_handle *handle)
{
int rc;
ENTRY;
RETURN(rc);
}
-int llog_lvfs_destroy(struct llog_handle *handle)
+static int llog_lvfs_destroy(struct llog_handle *handle)
{
struct dentry *fdentry;
struct obdo *oa;
fdentry = handle->lgh_file->f_dentry;
if (strcmp(fdentry->d_parent->d_name.name, MOUNT_CONFIGS_DIR) == 0) {
- /* CONFIGS files aren't really "lustre" objects - special case*/
struct obd_device *obd = handle->lgh_ctxt->loc_exp->exp_obd;
struct inode *inode = fdentry->d_parent->d_inode;
struct lvfs_run_ctxt saved;
int size = sizeof(*idarray) * count;
loff_t off = 0;
- if (!count) {
- CERROR("Empty catalog?\n");
- RETURN(0);
- }
+ LASSERT(count);
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;
- if (!count) {
- CERROR("Empty catalog?\n");
- RETURN(0);
- }
-
+ LASSERT(count);
+
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700);
if (!file || IS_ERR(file)) {
// lop_cancel: llog_lvfs_cancel,
};
-EXPORT_SYMBOL(llog_lvfs_write_rec);
-EXPORT_SYMBOL(llog_lvfs_next_block);
-EXPORT_SYMBOL(llog_lvfs_read_header);
-EXPORT_SYMBOL(llog_lvfs_create);
-EXPORT_SYMBOL(llog_lvfs_destroy);
-EXPORT_SYMBOL(llog_lvfs_close);
EXPORT_SYMBOL(llog_lvfs_ops);
#else /* !__KERNEL__ */
}
static int llog_lvfs_create(struct llog_ctxt *ctxt, struct llog_handle **res,
- struct llog_logid *logid, char *fsname, char *name)
+ struct llog_logid *logid, char *name)
{
LBUG();
return 0;
}
/* Add this target to the fs, get a new index if needed */
-static int server_initial_connect(struct super_block *sb, struct vfsmount *mnt)
+static int server_add_target(struct super_block *sb, struct vfsmount *mnt)
{
struct lustre_sb_info *lsi = s2lsi(sb);
struct obd_device *mgc = lsi->lsi_mgc;
sizeof(mti->mti_svname));
// char mti_nodename[NAME_MAXLEN];
// char mti_uuid[UUID_MAXLEN];
- rc = LNetGetId(1, &id);
+ /* FIXME nid 0 is lo generally, need to send all non-lo nids */
+ rc = LNetGetId(1, &id);
mti->mti_nid = id.nid;
mti->mti_config_ver = 0;
mti->mti_flags = ldd->ldd_flags;
mti->mti_stripe_size = 1024*1024; //FIXME
mti->mti_stripe_offset = 0; //FIXME
- CDEBUG(D_MOUNT, "Initial connect %s, fs=%s, %s, index=%d\n",
+ CDEBUG(D_MOUNT, "Initial connect %s, fs=%s, %s, index=%04x\n",
mti->mti_svname, mti->mti_fsname,
libcfs_nid2str(mti->mti_nid), mti->mti_stripe_index);
rc = obd_set_info(exp,
strlen("add_target"), "add_target",
sizeof(*mti), mti);
+ CDEBUG(D_MOUNT, "disconnect");
obd_disconnect(exp);
if (rc) {
CERROR("add_target failed %d\n", rc);
/* Get a new index if needed */
if (lsi->lsi_ldd->ldd_flags & (LDD_F_NEED_INDEX | LDD_F_NEED_REGISTER)) {
CDEBUG(D_MOUNT, "Need new target index from MGS\n");
- rc = server_initial_connect(sb, mnt);
+ rc = server_add_target(sb, mnt);
if (rc) {
CERROR("Initial connect failed for %s: %d\n",
lsi->lsi_ldd->ldd_svname, rc);
static void server_put_super(struct super_block *sb)
{
struct lustre_sb_info *lsi = s2lsi(sb);
- struct obd_device *obd;
+ struct obd_device *obd;
+ struct vfsmount *mnt = lsi->lsi_srv_mnt;
CDEBUG(D_MOUNT, "server put_super %s\n", lsi->lsi_ldd->ldd_svname);
CERROR("no obd %s\n", lsi->lsi_ldd->ldd_svname);
}
- //class_del_profile(lsi->lsi_ldd->ldd_svname); /* if it exists */
-
server_stop_servers(sb);
/* If they wanted the mgs to stop separately from the mdt, they
/* clean the mgc and sb */
lustre_common_put_super(sb);
- /* drop the kernel mount from server_fill_super */
- unlock_mntput(lsi->lsi_srv_mnt);
+ /* drop the One True Mount */
+ unlock_mntput(mnt);
}
static void server_umount_begin(struct super_block *sb)