Whamcloud - gitweb
LU-6565 llog: Do not update the whole llog header 78/14678/8
authorwang di <di.wang@intel.com>
Tue, 5 May 2015 04:15:37 +0000 (21:15 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 28 May 2015 17:05:22 +0000 (17:05 +0000)
During adding llog record ( see llog_osd_write_rec()),
do not update the whole llog header, but only update
the byte where the bit locates and the counter.

So cross-MDT operation, which needs to write all of
updates of the operation in the llog record, does not
have to write the whole llog header(8K bytes) into
the update record, instead only writing a few bytes.
It will save a lot space for update logs and
ptlrpc request, and help to pack more updates into
the update log.

Signed-off-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Signed-off-by: wang di <di.wang@intel.com>
Change-Id: I777afbb111da6c1bc291735f9c4f105c48b3966b
Reviewed-on: http://review.whamcloud.com/14678
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/obdclass/llog_osd.c

index 5d3e246..b4ef51a 100644 (file)
@@ -347,7 +347,6 @@ static int llog_osd_write_rec(const struct lu_env *env,
        struct llog_rec_tail    *lrt;
        struct dt_object        *o;
        size_t                   left;
        struct llog_rec_tail    *lrt;
        struct dt_object        *o;
        size_t                   left;
-       bool                     header_is_updated = false;
 
        ENTRY;
 
 
        ENTRY;
 
@@ -518,14 +517,46 @@ static int llog_osd_write_rec(const struct lu_env *env,
        llh->llh_count++;
        spin_unlock(&loghandle->lgh_hdr_lock);
 
        llh->llh_count++;
        spin_unlock(&loghandle->lgh_hdr_lock);
 
-       lgi->lgi_off = 0;
-       lgi->lgi_buf.lb_len = llh->llh_hdr.lrh_len;
-       lgi->lgi_buf.lb_buf = &llh->llh_hdr;
-       rc = dt_record_write(env, o, &lgi->lgi_buf, &lgi->lgi_off, th);
-       if (rc)
-               GOTO(out, rc);
+       if (lgi->lgi_attr.la_size == 0) {
+               lgi->lgi_off = 0;
+               lgi->lgi_buf.lb_len = llh->llh_hdr.lrh_len;
+               lgi->lgi_buf.lb_buf = &llh->llh_hdr;
+               rc = dt_record_write(env, o, &lgi->lgi_buf, &lgi->lgi_off, th);
+               if (rc != 0)
+                       GOTO(out, rc);
+       } else {
+               /* Note: If this is not initialization (size == 0), then do not
+                * write the whole header (8k bytes), only update header/tail
+                * and bits needs to be updated. Because this update might be
+                * part of cross-MDT operation, which needs to write these
+                * updates into the update log(32KB limit) and also pack inside
+                * the RPC (1MB limit), if we write 8K for each operation, which
+                * will cost a lot space, and keep us adding more updates to one
+                * update log.*/
+               lgi->lgi_off = offsetof(typeof(*llh), llh_count);
+               lgi->lgi_buf.lb_len = sizeof(llh->llh_count);
+               lgi->lgi_buf.lb_buf = &llh->llh_count;
+               rc = dt_record_write(env, o, &lgi->lgi_buf, &lgi->lgi_off, th);
+               if (rc != 0)
+                       GOTO(out, rc);
+
+               lgi->lgi_off = offsetof(typeof(*llh),
+                       llh_bitmap[index / (sizeof(*llh->llh_bitmap) * 8)]);
+               lgi->lgi_buf.lb_len = sizeof(*llh->llh_bitmap);
+               lgi->lgi_buf.lb_buf =
+                       &llh->llh_bitmap[index/(sizeof(*llh->llh_bitmap)*8)];
+               rc = dt_record_write(env, o, &lgi->lgi_buf, &lgi->lgi_off, th);
+               if (rc != 0)
+                       GOTO(out, rc);
+
+               lgi->lgi_off = offsetof(typeof(*llh), llh_tail);
+               lgi->lgi_buf.lb_len = sizeof(llh->llh_tail);
+               lgi->lgi_buf.lb_buf = &llh->llh_tail;
+               rc = dt_record_write(env, o, &lgi->lgi_buf, &lgi->lgi_off, th);
+               if (rc != 0)
+                       GOTO(out, rc);
+       }
 
 
-       header_is_updated = true;
        rc = dt_attr_get(env, o, &lgi->lgi_attr);
        if (rc)
                GOTO(out, rc);
        rc = dt_attr_get(env, o, &lgi->lgi_attr);
        if (rc)
                GOTO(out, rc);
@@ -564,14 +595,6 @@ out:
        loghandle->lgh_last_idx--;
        llh->llh_tail.lrt_index = loghandle->lgh_last_idx;
 
        loghandle->lgh_last_idx--;
        llh->llh_tail.lrt_index = loghandle->lgh_last_idx;
 
-       /* restore the header on disk if it was written */
-       if (header_is_updated) {
-               lgi->lgi_off = 0;
-               lgi->lgi_buf.lb_len = llh->llh_hdr.lrh_len;
-               lgi->lgi_buf.lb_buf = &llh->llh_hdr;
-               dt_record_write(env, o, &lgi->lgi_buf, &lgi->lgi_off, th);
-       }
-
        RETURN(rc);
 }
 
        RETURN(rc);
 }