#include "mdd_internal.h"
-const char *mdd_lov_objid_name = "lov_objid";
+static const char mdd_lov_objid_name[] = "lov_objid";
-static int mdd_lov_read_objids(const struct lu_context *ctxt,
+static int mdd_lov_read_objids(const struct lu_context *ctxt,
struct mdd_device *mdd)
{
struct mdd_lov_info *lov_info = &mdd->mdd_lov_info;
LASSERT(!lov_info->mdd_lov_objids_size);
LASSERT(!lov_info->mdd_lov_objids_dirty);
-
- /* Read everything in the file, even if our current lov desc
- has fewer targets. Old targets not in the lov descriptor
+
+ /* Read everything in the file, even if our current lov desc
+ has fewer targets. Old targets not in the lov descriptor
during mds setup may still have valid objids. */
-
+
rc = obj_ids->do_ops->do_attr_get(ctxt, obj_ids, lu_attr);
if (rc)
GOTO(out, rc);
lov_info->mdd_lov_objids_size = lu_attr->la_size;
#if 0
- rc = obj_ids->do_body_ops->dbo_read(ctxt, obj_ids, ids,
+ rc = obj_ids->do_body_ops->dbo_read(ctxt, obj_ids, ids,
lu_attr->la_size, &off);
if (rc < 0) {
CERROR("Error reading objids %d\n", rc);
RETURN(rc);
}
-#endif
+#endif
lov_info->mdd_lov_objids_in_file = lu_attr->la_size / sizeof(*ids);
for (i = 0; i < lov_info->mdd_lov_objids_in_file; i++) {
}
/* Update the lov desc for a new size lov. */
-static int mdd_lov_update_desc(const struct lu_context *ctxt,
+static int mdd_lov_update_desc(const struct lu_context *ctxt,
struct mdd_device *mdd)
{
struct mdd_lov_info *lov_info = &mdd->mdd_lov_info;
ENTRY;
ld = &mdd_ctx_info(ctxt)->mti_ld;
-
- rc = obd_get_info(lov_obd->obd_self_export, strlen(KEY_LOVDESC) + 1,
+
+ rc = obd_get_info(lov_obd->obd_self_export, strlen(KEY_LOVDESC) + 1,
KEY_LOVDESC, &valsize, ld);
if (rc)
GOTO(out, rc);
/* The size of the LOV target table may have increased. */
size = ld->ld_tgt_count * sizeof(obd_id);
- if ((lov_info->mdd_lov_objids_size == 0) ||
+ if ((lov_info->mdd_lov_objids_size == 0) ||
(size > lov_info->mdd_lov_objids_size)) {
obd_id *ids;
RETURN(rc);
}
-int mdd_lov_write_objids(const struct lu_context *ctxt,
+int mdd_lov_write_objids(const struct lu_context *ctxt,
struct mdd_lov_info *lov_info)
{
int i, rc = 0, tgts;
if (!lov_info->mdd_lov_objids_dirty)
RETURN(0);
- tgts = max(lov_info->mdd_lov_desc.ld_tgt_count,
+ tgts = max(lov_info->mdd_lov_desc.ld_tgt_count,
lov_info->mdd_lov_objids_in_file);
if (!tgts)
RETURN(0);
RETURN(rc);
}
-static int mdd_lov_connect(const struct lu_context *ctxt,
+static int mdd_lov_connect(const struct lu_context *ctxt,
struct mdd_device *mdd, char *lov_name)
{
struct mdd_lov_info *lov_info = &mdd->mdd_lov_info;
lov_info->mdd_lov_obd = ERR_PTR(rc);
RETURN(rc);
}
-
+
/* open and test the lov objd file */
rc = mdd_lov_read_objids(ctxt, mdd);
#endif
/* If we're mounting this code for the first time on an existing FS,
* we need to populate the objids array from the real OST values */
- if (lov_info->mdd_lov_desc.ld_tgt_count >
+ if (lov_info->mdd_lov_desc.ld_tgt_count >
lov_info->mdd_lov_objids_in_file) {
int size = sizeof(obd_id) * lov_info->mdd_lov_desc.ld_tgt_count;
int i;
- rc = obd_get_info(lov_info->mdd_lov_obd->obd_self_export,
- strlen("last_id"), "last_id", &size,
+ rc = obd_get_info(lov_info->mdd_lov_obd->obd_self_export,
+ strlen("last_id"), "last_id", &size,
lov_info->mdd_lov_objids);
if (!rc) {
for (i = 0; i < lov_info->mdd_lov_desc.ld_tgt_count; i++)
int mdd_lov_fini(const struct lu_context *ctxt, struct mdd_device *mdd)
{
struct mdd_lov_info *lov_info = &mdd->mdd_lov_info;
-
+
dt_object_fini(lov_info->mdd_lov_objid_obj);
return 0;
}
char *lov_name = NULL, *srv = NULL;
int rc = 0;
ENTRY;
-
+
if (IS_ERR(lov_info->mdd_lov_obd))
RETURN(PTR_ERR(lov_info->mdd_lov_obd));
&lov_info->mdd_lov_objid_fid);
if (IS_ERR(obj_id)){
rc = PTR_ERR(obj_id);
- RETURN(rc);
+ RETURN(rc);
}
LASSERT(obj_id != NULL);
GOTO(out, rc);
}
EXIT;
-out:
+out:
if (rc)
mdd_lov_fini(ctxt, mdd);
return rc;
LASSERT(lov_info->mdd_lov_objids != NULL);
- rc = obd_set_info_async(lov_info->mdd_lov_obd->obd_self_export,
+ rc = obd_set_info_async(lov_info->mdd_lov_obd->obd_self_export,
strlen(KEY_NEXT_ID), KEY_NEXT_ID,
lov_info->mdd_lov_desc.ld_tgt_count,
lov_info->mdd_lov_objids, NULL);
- if (rc)
+ if (rc)
CERROR ("mdd_lov_set_nextid failed (%d)\n", rc);
RETURN(rc);
/* Inform MDS about new/updated target */
static int mdd_lov_update_mds(struct lu_context *ctxt,
struct lu_device *ld,
- struct obd_device *watched,
+ struct obd_device *watched,
__u32 idx)
{
struct mdd_device *mdd = lu2mdd_dev(ld);
if (rc)
RETURN(rc);
- /*
- * idx is set as data from lov_notify.
+ /*
+ * idx is set as data from lov_notify.
* XXX did not consider recovery here
*/
if (idx != MDSLOV_NO_INDEX) {
if (idx >= lov_info->mdd_lov_desc.ld_tgt_count) {
- CERROR("index %d > count %d!\n", idx,
+ CERROR("index %d > count %d!\n", idx,
lov_info->mdd_lov_desc.ld_tgt_count);
RETURN(-EINVAL);
}
-
+
if (idx >= lov_info->mdd_lov_objids_in_file) {
/* We never read this lastid; ask the osc */
obd_id lastid;
__u32 size = sizeof(lastid);
rc = obd_get_info(watched->obd_self_export,
- strlen("last_id"),
+ strlen("last_id"),
"last_id", &size, &lastid);
if (rc)
RETURN(rc);
mdd_lov_write_objids(ctxt, lov_info);
} else {
/* We have read this lastid from disk; tell the osc.
- Don't call this during recovery. */
+ Don't call this during recovery. */
rc = mdd_lov_set_nextid(mdd);
}
-
+
CDEBUG(D_CONFIG, "last object "LPU64" from OST %d\n",
lov_info->mdd_lov_objids[idx], idx);
}
RETURN(rc);
}
-static int mdd_lov_clear_orphans(struct mdd_lov_info *mli,
+static int mdd_lov_clear_orphans(struct mdd_lov_info *mli,
struct obd_uuid *ost_uuid)
{
int rc;
memcpy(&oa.o_inline, ost_uuid, sizeof(*ost_uuid));
oa.o_valid |= OBD_MD_FLINLINE;
}
- rc = obd_create(mli->mdd_lov_obd->obd_self_export, &oa,
+ rc = obd_create(mli->mdd_lov_obd->obd_self_export, &oa,
&empty_ea, &oti);
RETURN(rc);
}
/* We only sync one osc at a time, so that we don't have to hold
- any kind of lock on the whole mds_lov_desc, which may change
+ any kind of lock on the whole mds_lov_desc, which may change
(grow) as a result of mds_lov_add_ost. This also avoids any
- kind of mismatch between the lov_desc and the mds_lov_desc,
+ kind of mismatch between the lov_desc and the mds_lov_desc,
which are not in lock-step during lov_add_obd */
static int __mdd_lov_synchronize(void *data)
{
rc = mdd_lov_update_mds(ctxt, ld, watched, idx);
if (rc != 0)
GOTO(out, rc);
-
+
rc = obd_set_info_async(mdd->mdd_lov_info.mdd_lov_obd->obd_self_export,
- strlen(KEY_MDS_CONN), KEY_MDS_CONN, 0, uuid,
+ strlen(KEY_MDS_CONN), KEY_MDS_CONN, 0, uuid,
NULL);
if (rc != 0) {
CERROR("failed at obd_set_info_async: %d\n", rc);
GOTO(out, rc);
}
-
+
rc = mdd_lov_clear_orphans(&mdd->mdd_lov_info, uuid);
if (rc != 0) {
CERROR("failed at mds_lov_clear_orphans: %d\n", rc);
RETURN(__mdd_lov_synchronize(data));
}
-int mdd_lov_start_synchronize(const struct lu_context *ctxt,
+int mdd_lov_start_synchronize(const struct lu_context *ctxt,
struct lu_device *ld,
struct obd_device *watched,
void *data, int nonblock)
disconnect the LOV. This of course means a cleanup won't
finish for as long as the sync is blocking. */
lu_device_get(ld);
-#if 0
+#if 0
if (nonblock) {
/* Synchronize in the background */
rc = cfs_kernel_thread(mdd_lov_synchronize, mlsi,
CERROR("error starting mdd_lov_synchronize: %d\n", rc);
lu_device_put(ld);
} else {
- CDEBUG(D_HA, "mdd_lov_synchronize idx=%d thread=%d\n",
+ CDEBUG(D_HA, "mdd_lov_synchronize idx=%d thread=%d\n",
mlsi->mlsi_index, rc);
rc = 0;
}
int lmm_size;
next = mdd_object_child(md2mdd_obj(obj));
- rc = next->do_ops->do_xattr_get(ctxt, next, md, *md_size,
+ rc = next->do_ops->do_xattr_get(ctxt, next, md, *md_size,
MDS_LOV_MD_NAME);
if (rc < 0) {
CERROR("Error %d reading eadata \n", rc);
} else {
*md_size = 0;
}
-
+
RETURN (rc);
}
rc = obd_create(mli->mdd_lov_obd->obd_self_export, oa, &lsm, NULL);
if (rc)
GOTO(out_oa, rc);
-
+
rc = obd_packmd(mli->mdd_lov_obd->obd_self_export, &lmm, lsm);
if (rc < 0) {
CERROR("cannot pack lsm, err = %d\n", rc);
GOTO(out_oa, rc);
}
lmm_size = rc;
-
- rc = mdd_xattr_set(ctxt, &child->mod_obj, lmm, lmm_size,
+
+ rc = mdd_xattr_set(ctxt, &child->mod_obj, lmm, lmm_size,
MDS_LOV_MD_NAME);
out_oa:
obdo_free(oa);
- RETURN(rc);
+ RETURN(rc);
}