char *name, int idx, int count,
struct llog_catid *idarray);
+int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
+ char *name, int idx, int count, struct llog_catid *idarray);
+
struct llog_ctxt {
int loc_idx; /* my index the obd array of ctxt's */
struct llog_gen loc_gen;
{
cfs_waitq_init(&olg->olg_waitq);
spin_lock_init(&olg->olg_lock);
+ sema_init(&olg->olg_cat_processing, 1);
olg->olg_group = group;
}
spinlock_t olg_lock;
struct obd_export *olg_exp;
int olg_initializing;
+ struct semaphore olg_cat_processing;
};
/* corresponds to one of the obd's */
/* Don't change the mds_lov_desc until the objids size matches the
count (paranoia) */
mds->mds_lov_desc = *ld;
- CDEBUG(D_CONFIG, "updated lov_desc, tgt_count: %d\n",
- mds->mds_lov_desc.ld_tgt_count);
+ CDEBUG(D_CONFIG, "updated lov_desc, tgt_count: %d - idx %d / uuid %s\n",
+ mds->mds_lov_desc.ld_tgt_count, idx, uuid->uuid);
stripes = min_t(__u32, LOV_MAX_STRIPE_COUNT,
mds->mds_lov_desc.ld_tgt_count);
*
* Assumes caller has already pushed us into the kernel context and is locking.
*/
-static struct llog_handle *llog_cat_new_log(struct llog_handle *cathandle)
+static struct llog_handle *llog_cat_new_log(struct llog_handle *cathandle,
+ struct llog_logid *lid)
{
struct llog_handle *loghandle;
struct llog_log_hdr *llh;
if (OBD_FAIL_CHECK(OBD_FAIL_MDS_LLOG_CREATE_FAILED))
RETURN(ERR_PTR(-ENOSPC));
-
- rc = llog_create(cathandle->lgh_ctxt, &loghandle, NULL, NULL);
- if (rc)
+
+ if (lid != NULL && lid->lgl_oid == 0)
+ lid = NULL;
+
+ rc = llog_create(cathandle->lgh_ctxt, &loghandle, lid, NULL);
+ if (rc)
RETURN(ERR_PTR(rc));
-
+
rc = llog_init_handle(loghandle,
LLOG_F_IS_PLAIN | LLOG_F_ZAP_WHEN_EMPTY,
&cathandle->lgh_hdr->llh_tgtuuid);
LASSERT(list_empty(&loghandle->u.phd.phd_entry));
list_add_tail(&loghandle->u.phd.phd_entry, &cathandle->u.chd.chd_head);
- out_destroy:
+out_destroy:
if (rc < 0)
llog_destroy(loghandle);
RETURN(loghandle);
}
-EXPORT_SYMBOL(llog_cat_new_log);
/* Open an existent log handle and add it to the open list.
* This log handle will be closed when all of the records in it are removed.
* NOTE: loghandle is write-locked upon successful return
*/
static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle,
+ struct llog_logid *lid,
int create)
{
struct llog_handle *loghandle = NULL;
up_read(&cathandle->lgh_lock);
RETURN(loghandle);
} else {
+ lid = NULL;
up_write(&loghandle->lgh_lock);
}
}
up_write(&cathandle->lgh_lock);
RETURN(loghandle);
} else {
+ lid = NULL;
up_write(&loghandle->lgh_lock);
}
}
CDEBUG(D_INODE, "creating new log\n");
- loghandle = llog_cat_new_log(cathandle);
+ loghandle = llog_cat_new_log(cathandle, lid);
if (!IS_ERR(loghandle))
down_write(&loghandle->lgh_lock);
up_write(&cathandle->lgh_lock);
ENTRY;
LASSERT(rec->lrh_len <= LLOG_CHUNK_SIZE);
- loghandle = llog_cat_current_log(cathandle, 1);
+ loghandle = llog_cat_current_log(cathandle, &reccookie->lgc_lgl, 1);
if (IS_ERR(loghandle))
RETURN(PTR_ERR(loghandle));
/* loghandle is already locked by llog_cat_current_log() for us */
up_write(&loghandle->lgh_lock);
if (rc == -ENOSPC) {
/* to create a new plain log */
- loghandle = llog_cat_current_log(cathandle, 1);
+ loghandle = llog_cat_current_log(cathandle, &reccookie->lgc_lgl, 1);
if (IS_ERR(loghandle))
RETURN(PTR_ERR(loghandle));
rc = llog_write_rec(loghandle, rec, reccookie, 1, buf, -1);
if (!idarray)
RETURN(-ENOMEM);
+ mutex_down(&obd->obd_olg.olg_cat_processing);
rc = llog_get_cat_list(obd, obd, name, 0, count, idarray);
- if (rc) {
- OBD_FREE(idarray, size);
- RETURN(rc);
- }
+ if (rc)
+ GOTO(out, rc);
out = data->ioc_bulk;
remains = data->ioc_inllen1;
break;
}
}
+out:
+ /* release semaphore */
+ mutex_up(&obd->obd_olg.olg_cat_processing);
+
OBD_VFREE(idarray, size);
- RETURN(0);
+ RETURN(rc);
}
EXPORT_SYMBOL(llog_catalog_list);
loff_t off = idx * sizeof(*idarray);
if (!count)
- return (0);
+ GOTO(out1, rc = 0);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700);
GOTO(out, rc);
}
- out:
+out:
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
if (file && !IS_ERR(file))
rc1 = filp_close(file, 0);
if (rc == 0)
rc = rc1;
+out1:
RETURN(rc);
}
+EXPORT_SYMBOL(llog_put_cat_list);
struct llog_operations llog_lvfs_ops = {
lop_write_rec: llog_lvfs_write_rec,
int rc;
ENTRY;
+ mutex_down(&olg->olg_cat_processing);
rc = llog_get_cat_list(obd, obd, name, idx, 1, &idarray);
if (rc) {
CERROR("rc: %d\n", rc);
GOTO(out, rc);
}
+ CDEBUG(D_INFO, "init llog for %s/%d - catid "LPX64"/"LPX64"/%x\n",
+ uuid->uuid, idx, idarray.lci_logid.lgl_oid,
+ idarray.lci_logid.lgl_ogr, idarray.lci_logid.lgl_ogen);
+
rc = obd_llog_init(obd, olg, obd, 1, &idarray, uuid);
if (rc) {
CERROR("rc: %d\n", rc);
}
out:
+ mutex_up(&olg->olg_cat_processing);
+
RETURN(rc);
}
EXPORT_SYMBOL(llog_cat_initialize);
if (!idarray)
GOTO(release_ctxt, rc = -ENOMEM);
+ mutex_down(&obd->obd_olg.olg_cat_processing);
rc = llog_get_cat_list(obd, obd, name, 0, count, idarray);
if (rc)
GOTO(out_free, rc);
out_pop:
pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL);
out_free:
+ /* release semphore */
+ mutex_up(&obd->obd_olg.olg_cat_processing);
+
OBD_VFREE(idarray, size);
release_ctxt:
llog_ctxt_put(ctxt);