Whamcloud - gitweb
LU-14055 lmv: reduce struct lmv_obd size 62/41162/6
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 7 Jan 2021 12:26:28 +0000 (05:26 -0700)
committerOleg Drokin <green@whamcloud.com>
Sat, 10 Apr 2021 17:39:41 +0000 (17:39 +0000)
The lmv_obd struct contains lmv_mdt_descs which is large enough
to reference 512 * 512 = 262144 targets, but there can be only
65536 OSTs or MDTs in a single filesystem today.

Shrink the allocation size to match the current limits, reducing
the size of obd_device.u since this is the largest union member.

This reduces the size of each obd_device from 6752 to 4568 bytes.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I752b021bdb5d02e3ead3bb266121be5dbf3ebbe5
Reviewed-on: https://review.whamcloud.com/41162
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lu_object.h
lustre/lfsck/lfsck_lib.c
lustre/obdclass/lu_tgt_descs.c

index dcde639..bfd9134 100644 (file)
@@ -1584,10 +1584,10 @@ struct lu_tgt_desc {
                           ltd_connecting:1; /* target is connecting */
 };
 
                           ltd_connecting:1; /* target is connecting */
 };
 
-/* number of pointers at 1st level */
-#define TGT_PTRS               (PAGE_SIZE / sizeof(void *))
 /* number of pointers at 2nd level */
 #define TGT_PTRS_PER_BLOCK     (PAGE_SIZE / sizeof(void *))
 /* number of pointers at 2nd level */
 #define TGT_PTRS_PER_BLOCK     (PAGE_SIZE / sizeof(void *))
+/* number of pointers at 1st level - only need as many as max OST/MDT count */
+#define TGT_PTRS               ((LOV_ALL_STRIPES + 1) / TGT_PTRS_PER_BLOCK)
 
 struct lu_tgt_desc_idx {
        struct lu_tgt_desc *ldi_tgt[TGT_PTRS_PER_BLOCK];
 
 struct lu_tgt_desc_idx {
        struct lu_tgt_desc *ldi_tgt[TGT_PTRS_PER_BLOCK];
@@ -1638,8 +1638,8 @@ struct lu_tgt_descs {
 };
 
 #define LTD_TGT(ltd, index)                                            \
 };
 
 #define LTD_TGT(ltd, index)                                            \
-        (ltd)->ltd_tgt_idx[(index) /                                   \
-        TGT_PTRS_PER_BLOCK]->ldi_tgt[(index) % TGT_PTRS_PER_BLOCK]
+        (ltd)->ltd_tgt_idx[(index) / TGT_PTRS_PER_BLOCK]->             \
+               ldi_tgt[(index) % TGT_PTRS_PER_BLOCK]
 
 u64 lu_prandom_u64_max(u64 ep_ro);
 void lu_qos_rr_init(struct lu_qos_rr *lqr);
 
 u64 lu_prandom_u64_max(u64 ep_ro);
 void lu_qos_rr_init(struct lu_qos_rr *lqr);
index 93ca2a2..e3b39d6 100644 (file)
@@ -158,7 +158,7 @@ static void lfsck_tgt_descs_fini(struct lfsck_tgt_descs *ltds)
        LASSERTF(ltds->ltd_tgtnr == 0, "tgt count unmatched: %d\n",
                 ltds->ltd_tgtnr);
 
        LASSERTF(ltds->ltd_tgtnr == 0, "tgt count unmatched: %d\n",
                 ltds->ltd_tgtnr);
 
-       for (idx = 0; idx < TGT_PTRS; idx++) {
+       for (idx = 0; idx < ARRAY_SIZE(ltds->ltd_tgts_idx); idx++) {
                if (ltds->ltd_tgts_idx[idx] != NULL) {
                        OBD_FREE_PTR(ltds->ltd_tgts_idx[idx]);
                        ltds->ltd_tgts_idx[idx] = NULL;
                if (ltds->ltd_tgts_idx[idx] != NULL) {
                        OBD_FREE_PTR(ltds->ltd_tgts_idx[idx]);
                        ltds->ltd_tgts_idx[idx] = NULL;
index cecc6ea..1f1cfae 100644 (file)
@@ -300,7 +300,7 @@ void lu_tgt_descs_fini(struct lu_tgt_descs *ltd)
        int i;
 
        bitmap_free(ltd->ltd_tgt_bitmap);
        int i;
 
        bitmap_free(ltd->ltd_tgt_bitmap);
-       for (i = 0; i < TGT_PTRS; i++) {
+       for (i = 0; i < ARRAY_SIZE(ltd->ltd_tgt_idx); i++) {
                if (ltd->ltd_tgt_idx[i])
                        OBD_FREE_PTR(ltd->ltd_tgt_idx[i]);
        }
                if (ltd->ltd_tgt_idx[i])
                        OBD_FREE_PTR(ltd->ltd_tgt_idx[i]);
        }
@@ -374,6 +374,9 @@ int ltd_add_tgt(struct lu_tgt_descs *ltd, struct lu_tgt_desc *tgt)
        if (index >= ltd->ltd_tgts_size) {
                __u32 newsize = 1;
 
        if (index >= ltd->ltd_tgts_size) {
                __u32 newsize = 1;
 
+               if (index > TGT_PTRS * TGT_PTRS_PER_BLOCK)
+                       RETURN(-ENFILE);
+
                while (newsize < index + 1)
                        newsize = newsize << 1;
 
                while (newsize < index + 1)
                        newsize = newsize << 1;