LASSERT(mdd->mdd_capa);
+ /* XXX: Since we use the 'mdd_capa' as fake llog object here, we
+ * have to set the parameter 'size' as INT_MAX or 0 to inform
+ * OSD that this record write is for a llog write or catalog
+ * header update, and osd declare function will reserve less
+ * credits for optimization purpose.
+ *
+ * Reserve 6 blocks for a llog write, since the llog file is
+ * usually small, reserve 2 blocks for catalog header update,
+ * because we know for sure that catalog header is already
+ * allocated.
+ *
+ * This hack should be removed in 2.3.
+ */
+
/* record itself */
- rc = dt_declare_record_write(env, mdd->mdd_capa, reclen, 0, handle);
+ rc = dt_declare_record_write(env, mdd->mdd_capa,
+ DECLARE_LLOG_WRITE, 0, handle);
if (rc)
return rc;
/* header will be updated as well */
- rc = dt_declare_record_write(env, mdd->mdd_capa, LLOG_CHUNK_SIZE,
- 0, handle);
+ rc = dt_declare_record_write(env, mdd->mdd_capa,
+ DECLARE_LLOG_WRITE, 0, handle);
if (rc)
return rc;
/* new record referencing new plain llog */
rc = dt_declare_record_write(env, mdd->mdd_capa,
- sizeof(struct llog_logid_rec), 0, handle);
+ DECLARE_LLOG_WRITE, 0, handle);
if (rc)
return rc;
/* catalog's header will be updated as well */
- rc = dt_declare_record_write(env, mdd->mdd_capa, LLOG_CHUNK_SIZE,
- 0, handle);
+ rc = dt_declare_record_write(env, mdd->mdd_capa,
+ DECLARE_LLOG_REWRITE, 0, handle);
return rc;
}
struct thandle *handle)
{
struct osd_thandle *oh;
+ int credits;
LASSERT(handle != NULL);
oh = container_of0(handle, struct osd_thandle, ot_super);
LASSERT(oh->ot_handle == NULL);
+ /* XXX: size == 0 or INT_MAX indicating a catalog header update or
+ * llog write, see comment in mdd_declare_llog_record().
+ *
+ * This hack should be removed in 2.3
+ */
+ if (size == DECLARE_LLOG_REWRITE)
+ credits = 2;
+ else if (size == DECLARE_LLOG_WRITE)
+ credits = 6;
+ else
+ credits = osd_dto_credits_noquota[DTO_WRITE_BLOCK];
+
OSD_DECLARE_OP(oh, write);
- oh->ot_credits += osd_dto_credits_noquota[DTO_WRITE_BLOCK];
+ oh->ot_credits += credits;
if (osd_dt_obj(dt)->oo_inode == NULL)
return 0;