Whamcloud - gitweb
LU-14762 lmv: compare space to mkdir on parent MDT 97/43997/5
authorLai Siyao <lai.siyao@whamcloud.com>
Mon, 14 Jun 2021 07:26:47 +0000 (15:26 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 8 Jul 2021 02:05:49 +0000 (02:05 +0000)
In QOS subdirectory creation, subdirectories are kept on parent MDT
if it is less full than average, however it checks weight other than
free space, while "weight = free space - penalty", if MDTs have
different penalties, the result is not accurate, therefore this may
not work.

Check free space instead, and loosen the critirion to allow the
free space within the range of QOS threshold.

Fixes: 3f6fc483013d ("LU-13439 lmv: qos stay on current MDT if less full")
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: Id34cf8f3f58fee9d329f0d05c2f7a6463b67dfe1
Reviewed-on: https://review.whamcloud.com/43997
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/include/lu_object.h
lustre/lmv/lmv_obd.c
lustre/obdclass/lu_tgt_descs.c

index 4081923..fe35671 100644 (file)
@@ -1567,7 +1567,7 @@ struct lu_svr_qos {
        struct obd_uuid          lsq_uuid;      /* ptlrpc's c_remote_uuid */
        struct list_head         lsq_svr_list;  /* link to lq_svr_list */
        __u64                    lsq_bavail;    /* total bytes avail on svr */
-       __u64                    lsq_iavail;    /* tital inode avail on svr */
+       __u64                    lsq_iavail;    /* total inode avail on svr */
        __u64                    lsq_penalty;   /* current penalty */
        __u64                    lsq_penalty_per_obj; /* penalty decrease
                                                       * every obj*/
@@ -1582,6 +1582,7 @@ struct lu_tgt_qos {
        __u64                    ltq_penalty;   /* current penalty */
        __u64                    ltq_penalty_per_obj; /* penalty decrease
                                                       * every obj*/
+       __u64                    ltq_avail;     /* bytes/inode avail */
        __u64                    ltq_weight;    /* net weighting */
        time64_t                 ltq_used;      /* last used time, seconds */
        bool                     ltq_usable:1;  /* usable for striping */
index 9560c16..ba1b656 100644 (file)
@@ -1462,6 +1462,7 @@ static int lmv_close(struct obd_export *exp, struct md_op_data *op_data,
 static struct lu_tgt_desc *lmv_locate_tgt_qos(struct lmv_obd *lmv, __u32 *mdt)
 {
        struct lu_tgt_desc *tgt, *cur = NULL;
+       __u64 total_avail = 0;
        __u64 total_weight = 0;
        __u64 cur_weight = 0;
        int total_usable = 0;
@@ -1490,22 +1491,24 @@ static struct lu_tgt_desc *lmv_locate_tgt_qos(struct lmv_obd *lmv, __u32 *mdt)
 
                tgt->ltd_qos.ltq_usable = 1;
                lu_tgt_qos_weight_calc(tgt);
-               if (tgt->ltd_index == *mdt) {
+               if (tgt->ltd_index == *mdt)
                        cur = tgt;
-                       cur_weight = tgt->ltd_qos.ltq_weight;
-               }
+               total_avail += tgt->ltd_qos.ltq_avail;
                total_weight += tgt->ltd_qos.ltq_weight;
                total_usable++;
        }
 
-       /* if current MDT has higher-than-average space, stay on same MDT */
-       rand = total_weight / total_usable;
-       if (cur_weight >= rand) {
+       /* if current MDT has above-average space, within range of the QOS
+        * threshold, stay on the same MDT to avoid creating needless remote
+        * MDT directories.
+        */
+       rand = total_avail * (256 - lmv->lmv_qos.lq_threshold_rr) /
+               (total_usable * 256);
+       if (cur && cur->ltd_qos.ltq_avail >= rand) {
                tgt = cur;
                GOTO(unlock, rc = 0);
        }
 
-       cur_weight = 0;
        rand = lu_prandom_u64_max(total_weight);
 
        lmv_foreach_connected_tgt(lmv, tgt) {
index 1e84857..d872db4 100644 (file)
@@ -228,14 +228,15 @@ static inline __u64 tgt_statfs_iavail(struct lu_tgt_desc *tgt)
 void lu_tgt_qos_weight_calc(struct lu_tgt_desc *tgt)
 {
        struct lu_tgt_qos *ltq = &tgt->ltd_qos;
-       __u64 temp, temp2;
+       __u64 penalty;
 
-       temp = (tgt_statfs_bavail(tgt) >> 16) * (tgt_statfs_iavail(tgt) >> 8);
-       temp2 = ltq->ltq_penalty + ltq->ltq_svr->lsq_penalty;
-       if (temp < temp2)
+       ltq->ltq_avail = (tgt_statfs_bavail(tgt) >> 16) *
+                        (tgt_statfs_iavail(tgt) >> 8);
+       penalty = ltq->ltq_penalty + ltq->ltq_svr->lsq_penalty;
+       if (ltq->ltq_avail < penalty)
                ltq->ltq_weight = 0;
        else
-               ltq->ltq_weight = temp - temp2;
+               ltq->ltq_weight = ltq->ltq_avail - penalty;
 }
 EXPORT_SYMBOL(lu_tgt_qos_weight_calc);