Whamcloud - gitweb
LU-1051 osd: reserve less credits for llog unlink
authorNiu Yawei <niu@whamcloud.com>
Mon, 6 Feb 2012 06:02:07 +0000 (22:02 -0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 23 Feb 2012 00:35:19 +0000 (19:35 -0500)
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>
lustre/include/md_object.h
lustre/mdd/mdd_dir.c
lustre/osd-ldiskfs/osd_handler.c

index cd52a7d..f7b23d9 100644 (file)
 #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;
index 2c1ffec..c7e2486 100644 (file)
@@ -581,14 +581,29 @@ int mdd_declare_llog_record(const struct lu_env *env, struct mdd_device *mdd,
 
         LASSERT(mdd->mdd_capa);
 
 
         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 */
         /* 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 */
         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;
 
         if (rc)
                 return rc;
 
@@ -599,13 +614,13 @@ int mdd_declare_llog_record(const struct lu_env *env, struct mdd_device *mdd,
 
         /* 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);
 
         return rc;
 }
 
         return rc;
 }
index aedf8dd..4f41e1f 100644 (file)
@@ -3052,14 +3052,27 @@ static ssize_t osd_declare_write(const struct lu_env *env, struct dt_object *dt,
                                  struct thandle *handle)
 {
         struct osd_thandle *oh;
                                  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);
 
 
         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;