Whamcloud - gitweb
LU-12495 obdclass: generate random u64 max correctly
[fs/lustre-release.git] / lustre / lmv / lmv_qos.c
index 77e95d3..1708c00 100644 (file)
@@ -372,30 +372,7 @@ struct lu_tgt_desc *lmv_locate_tgt_qos(struct lmv_obd *lmv, __u32 *mdt)
                total_weight += tgt->ltd_qos.ltq_weight;
        }
 
-       if (total_weight) {
-#if BITS_PER_LONG == 32
-               rand = prandom_u32_max((u32)total_weight);
-               /*
-                * If total_weight > 32-bit, first generate the high
-                * 32 bits of the random number, then add in the low
-                * 32 bits (truncated to the upper limit, if needed)
-                */
-               if (total_weight > 0xffffffffULL)
-                       rand = prandom_u32_max((u32)(total_weight >> 32)) << 32;
-               else
-                       rand = 0;
-
-               if (rand == (total_weight & 0xffffffff00000000ULL))
-                       rand |= prandom_u32_max((u32)total_weight);
-               else
-                       rand |= prandom_u32();
-
-#else
-               rand = prandom_u32() | prandom_u32_max((u32)total_weight);
-#endif
-       } else {
-               rand = 0;
-       }
+       rand = lu_prandom_u64_max(total_weight);
 
        for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
                tgt = lmv->tgts[i];