Whamcloud - gitweb
EX-3002 lipe: use ALR_READ and ALR_WRITE to index a{h,r}_heat
authorJohn L. Hammond <jhammond@whamcloud.com>
Wed, 27 Oct 2021 13:45:41 +0000 (08:45 -0500)
committerJohn L. Hammond <jhammond@whamcloud.com>
Tue, 18 Jan 2022 14:43:03 +0000 (14:43 +0000)
sed -E -i \
  -e 's/\b(READ|WRITE)\b/ALR_\1/g' \
  -e 's/\b(ah_heat|ah_iosize|ar_heat|ar_iosize)\[0\]/\1[ALR_READ]/g' \
  -e 's/\b(ah_heat|ah_iosize|ar_heat|ar_iosize)\[1\]/\1[ALR_WRITE]/g' \
 lipe/src/lamigo*.[ch]

Signed-off-by: John L. Hammond <jhammond@whamcloud.com>
Test-Parameters: trivial testlist=hot-pools
Change-Id: I640d5a56b2b923f67f3aa3c57d34385d28dfb24d
Reviewed-on: https://review.whamcloud.com/45374
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/46118

lipe/src/lamigo.c
lipe/src/lamigo.h
lipe/src/lamigo_alr.c

index b61b26d..9e60d49 100644 (file)
@@ -3258,7 +3258,7 @@ static int lamigo_check_hot_one(struct alr_heat *ht)
 
        LX_DEBUG("check hot "DFID": H: %Lu/%Lu, P: %Lu/%Lu, L %d, I %d %s\n",
                 PFID(&ht->ah_fid),
-                ht->ah_heat[0], ht->ah_heat[1], ht->ah_pools[ALR_FAST],
+                ht->ah_heat[ALR_READ], ht->ah_heat[ALR_WRITE], ht->ah_pools[ALR_FAST],
                 ht->ah_pools[ALR_SLOW], ht->ah_livetime, ht->ah_idle,
                 ht->ah_mark ? "M" : "");
        if (ht->ah_mark & ALR_TAG_PROCESSED) {
@@ -3273,7 +3273,7 @@ static int lamigo_check_hot_one(struct alr_heat *ht)
         * try to mirror it to the hot pool and make that
         * replica preferred
         */
-       if (ht->ah_heat[0] && ht->ah_heat[1] == 0 &&
+       if (ht->ah_heat[ALR_READ] && ht->ah_heat[ALR_WRITE] == 0 &&
            ht->ah_pools[ALR_FAST] == 0 && ht->ah_pools[ALR_SLOW]) {
                sync = lamigo_is_in_sync(&ht->ah_fid, slow_pools, fast_pools, &mo);
                LX_DEBUG("try to replicate RO "DFID": %d\n",
@@ -3292,7 +3292,7 @@ static int lamigo_check_hot_one(struct alr_heat *ht)
         * XXX: we can track OPEN/CLOSE events to skip this
         *      try if it's still open
         */
-       if (ht->ah_idle > 0 && ht->ah_heat[1] &&
+       if (ht->ah_idle > 0 && ht->ah_heat[ALR_WRITE] &&
            ht->ah_pools[ALR_FAST] == 0 && ht->ah_pools[ALR_SLOW]) {
                sync = lamigo_is_in_sync(&ht->ah_fid, slow_pools, fast_pools, &mo);
                LX_DEBUG("try to replicate RW "DFID": %d\n",
@@ -3317,7 +3317,7 @@ static void lamigo_check_hot_on_cold(struct alr_heat *ht)
 
        /* the file stored on cold pool was hat,
         * now it's idling, try to move it to hot pool */
-       if (ht->ah_idle > 0 && ht->ah_heat[1] &&
+       if (ht->ah_idle > 0 && ht->ah_heat[ALR_WRITE] &&
            ht->ah_pools[ALR_SLOW] == 0 && ht->ah_pools[ALR_FAST]) {
                sync = lamigo_is_in_sync(&ht->ah_fid, fast_pools,
                                         slow_pools, &mo);
index fcaf646..7441334 100644 (file)
@@ -31,8 +31,8 @@ struct pool_list {
 };
 
 enum alr_rw {
-       READ = 0,
-       WRITE = 1
+       ALR_READ = 0,
+       ALR_WRITE = 1
 };
 
 enum alr_tag {
index 95ecc1f..81c2007 100644 (file)
@@ -199,7 +199,7 @@ void lamigo_alr_parse_one(const char *line)
        } else if (lamigo_lookup_ost(slow_pools, idx)) {
                pool = ALR_SLOW;
        }
-       lamigo_alr_update_one(&fid, rw == 'w' ? WRITE : READ,
+       lamigo_alr_update_one(&fid, rw == 'w' ? ALR_WRITE : ALR_READ,
                              count, iosize, end, pool);
 }
 
@@ -438,17 +438,17 @@ static bool lamigo_alr_hot_filter(struct alr_rec *f, __u64 max)
 {
        max = max * (100 - opt.o_alr_hot_fraction) / 100;
 
-       if ((f->ar_heat[READ] + f->ar_heat[WRITE]) < max)
+       if ((f->ar_heat[ALR_READ] + f->ar_heat[ALR_WRITE]) < max)
                return false;
 
        /* now filter out using predefined constraints */
        /* XXX: add absolut low limit, few IO/sec on idling system
         *      should not make file hot */
 
-       if (opt.o_alr_ignore_reads && f->ar_heat[WRITE] < max)
+       if (opt.o_alr_ignore_reads && f->ar_heat[ALR_WRITE] < max)
                return false;
 
-       if (opt.o_alr_ignore_writes && f->ar_heat[READ] < max)
+       if (opt.o_alr_ignore_writes && f->ar_heat[ALR_READ] < max)
                return false;
 
        /* ignore files with large IO size */
@@ -456,12 +456,12 @@ static bool lamigo_alr_hot_filter(struct alr_rec *f, __u64 max)
                __u64 iosize = 0, ios = 0;
 
                if (opt.o_alr_ignore_reads == 0) {
-                       iosize += f->ar_iosize[READ];
-                       ios += f->ar_total_ops[READ];
+                       iosize += f->ar_iosize[ALR_READ];
+                       ios += f->ar_total_ops[ALR_READ];
                }
                if (opt.o_alr_ignore_writes == 0) {
-                       iosize += f->ar_iosize[WRITE];
-                       ios += f->ar_total_ops[WRITE];
+                       iosize += f->ar_iosize[ALR_WRITE];
+                       ios += f->ar_total_ops[ALR_WRITE];
                }
                if (ios == 0 || iosize / ios >= opt.o_alr_large_io)
                        return false;
@@ -510,7 +510,7 @@ static void lamigo_alr_update_heat_all(void)
        i = 0;
        lipe_list_for_each_entry(f, &p->alp_list, ar_link) {
                assert(i < nr);
-               sa[i].ase_val = f->ar_heat[0] + f->ar_heat[1];
+               sa[i].ase_val = f->ar_heat[ALR_READ] + f->ar_heat[ALR_WRITE];
                sa[i].ase_ptr = f;
                i++;
        }
@@ -522,8 +522,8 @@ static void lamigo_alr_update_heat_all(void)
        }
        /* heat of the center */
        i = nr / 2;
-       p->alp_mid[0] = sa[i].ase_ptr->ar_heat[0];
-       p->alp_mid[1] = sa[i].ase_ptr->ar_heat[1];
+       p->alp_mid[0] = sa[i].ase_ptr->ar_heat[ALR_READ];
+       p->alp_mid[1] = sa[i].ase_ptr->ar_heat[ALR_WRITE];
        max = sa[0].ase_val;
        free(sa);
 
@@ -543,16 +543,16 @@ static void lamigo_alr_update_heat_all(void)
        i = 0;
        asum[0] = (__u64)1 << 63;
        lipe_list_for_each_entry(f, &p->alp_list, ar_link) {
-               unsigned t = f->ar_heat[0] + f->ar_heat[1];
+               unsigned t = f->ar_heat[ALR_READ] + f->ar_heat[ALR_WRITE];
                assert(t <= asum[0]);
                asum[0] = t;
                if (i++ >= 8)
                        continue;
                LX_DEBUG(DFID" H: %d/%d O: %llu IO: %llu/%llu P: %llu/%llu i: %d\n",
-                        PFID(&f->ar_fh.fh_fid), (int)f->ar_heat[0], (int)f->ar_heat[1],
+                        PFID(&f->ar_fh.fh_fid), (int)f->ar_heat[ALR_READ], (int)f->ar_heat[ALR_WRITE],
                         f->ar_maxoff[0] > f->ar_maxoff[1] ? f->ar_maxoff[0] : f->ar_maxoff[1],
-                        f->ar_total_ops[0] > 0 ?  f->ar_iosize[0] / f->ar_total_ops[0] : 0,
-                        f->ar_total_ops[1] > 0 ?  f->ar_iosize[1] / f->ar_total_ops[1] : 0,
+                        f->ar_total_ops[0] > 0 ?  f->ar_iosize[ALR_READ] / f->ar_total_ops[0] : 0,
+                        f->ar_total_ops[1] > 0 ?  f->ar_iosize[ALR_WRITE] / f->ar_total_ops[1] : 0,
                         f->ar_pools[ALR_FAST], f->ar_pools[ALR_SLOW],
                         (int)alr_head.alh_lidx - f->ar_idx);
        }
@@ -690,14 +690,14 @@ static void *lamigo_alr_heat_thread(void *arg)
 static void lamigo_alr_fill_ht(struct alr_heat *ah, struct alr_rec *f)
 {
        ah->ah_fid = f->ar_fh.fh_fid;
-       ah->ah_heat[0] = f->ar_heat[0];
-       ah->ah_heat[1] = f->ar_heat[1];
+       ah->ah_heat[ALR_READ] = f->ar_heat[ALR_READ];
+       ah->ah_heat[ALR_WRITE] = f->ar_heat[ALR_WRITE];
        ah->ah_pools[ALR_FAST] = f->ar_pools[ALR_FAST];
        ah->ah_pools[ALR_SLOW] = f->ar_pools[ALR_SLOW];
        ah->ah_maxoff = f->ar_maxoff[0] > f->ar_maxoff[1] ?
                f->ar_maxoff[0] : f->ar_maxoff[1];
-       ah->ah_iosize[0] = f->ar_iosize[0];
-       ah->ah_iosize[1] = f->ar_iosize[1];
+       ah->ah_iosize[ALR_READ] = f->ar_iosize[ALR_READ];
+       ah->ah_iosize[ALR_WRITE] = f->ar_iosize[ALR_WRITE];
        /* XXX: position is not calculated yet */
        ah->ah_position = 0;
        /* can be on the last processed list or on the pending one
@@ -737,7 +737,7 @@ int lamigo_alr_check_is_hot(struct lu_fid *fid, struct alr_heat *ah)
        fid_hash_unlock(&alr_head.alh_hash, fh);
 
        LX_DEBUG("ALR: "DFID" heat: %d/%d, idle %d, live %d\n",
-                PFID(fid), (int)ah->ah_heat[0], (int)ah->ah_heat[1],
+                PFID(fid), (int)ah->ah_heat[ALR_READ], (int)ah->ah_heat[ALR_WRITE],
                 (int)ah->ah_idle, (int)ah->ah_livetime);
 
        return 1;
@@ -901,9 +901,9 @@ static void lamigo_alr_dump_one(FILE *file, struct alr_rec *f)
        __u64 maxoff;
        int idle = 0;
 
-       maxoff = f->ar_maxoff[READ];
-       if (f->ar_maxoff[WRITE] > maxoff)
-               maxoff = f->ar_maxoff[WRITE];
+       maxoff = f->ar_maxoff[ALR_READ];
+       if (f->ar_maxoff[ALR_WRITE] > maxoff)
+               maxoff = f->ar_maxoff[ALR_WRITE];
        if (alr_head.alh_lidx != f->ar_idx) {
                idle = (int)alr_head.alh_lidx - f->ar_idx - 1;
                if (idle < 0)
@@ -912,13 +912,13 @@ static void lamigo_alr_dump_one(FILE *file, struct alr_rec *f)
        if (idle)
                lamigo_alr_update_heat_one(f);
        fprintf(file, DFID" hr=%Lu hw=%Lu off=%Lu ior=%Lu iow=%Lu ops=%Lu",
-               PFID(&f->ar_fh.fh_fid), f->ar_heat[READ],
-               f->ar_heat[WRITE], maxoff,
-               f->ar_total_ops[READ] == 0 ? 0 :
-                       f->ar_iosize[READ] / f->ar_total_ops[READ],
-               f->ar_total_ops[WRITE] == 0 ? 0 :
-                       f->ar_iosize[WRITE] / f->ar_total_ops[WRITE],
-               f->ar_total_ops[READ] + f->ar_total_ops[WRITE]);
+               PFID(&f->ar_fh.fh_fid), f->ar_heat[ALR_READ],
+               f->ar_heat[ALR_WRITE], maxoff,
+               f->ar_total_ops[ALR_READ] == 0 ? 0 :
+                       f->ar_iosize[ALR_READ] / f->ar_total_ops[ALR_READ],
+               f->ar_total_ops[ALR_WRITE] == 0 ? 0 :
+                       f->ar_iosize[ALR_WRITE] / f->ar_total_ops[ALR_WRITE],
+               f->ar_total_ops[ALR_READ] + f->ar_total_ops[ALR_WRITE]);
        if (idle)
                fprintf(file, " idle=%d", idle);
        if (f->ar_hot)