Reserve less credits for the llog write and catalog header udpate.
Since we can't get the llog inode in osd declare function, we use
a temporary solution: hack the 'size' parameter to indicate a llog
write or catalog header udpate.
Signed-off-by: Niu Yawei <niu@whamcloud.com>
Change-Id: Ic5df00a878cdbf64a44b22b684e2c6b2dff83b07
Reviewed-on: http://review.whamcloud.com/2100
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
#include <dt_object.h>
#include <lvfs.h>
#include <dt_object.h>
#include <lvfs.h>
+/* LU-1051, temperary solution to reduce llog credits */
+#define DECLARE_LLOG_REWRITE 0
+#define DECLARE_LLOG_WRITE INT_MAX
+
struct md_device;
struct md_device_operations;
struct md_object;
struct md_device;
struct md_device_operations;
struct md_object;
+ /* 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.
+ */
+
- 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 */
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);
/* new record referencing new plain llog */
rc = dt_declare_record_write(env, mdd->mdd_capa,
/* 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 */
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);
struct thandle *handle)
{
struct osd_thandle *oh;
struct thandle *handle)
{
struct osd_thandle *oh;
LASSERT(handle != NULL);
oh = container_of0(handle, struct osd_thandle, ot_super);
LASSERT(oh->ot_handle == NULL);
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);
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;
if (osd_dt_obj(dt)->oo_inode == NULL)
return 0;