diff mbox series

[13/29] lustre: lmv: reduce struct lmv_obd size

Message ID 1619381316-7719-14-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: Update to OpenSFS tree as of April 25, 2020 | expand

Commit Message

James Simmons April 25, 2021, 8:08 p.m. UTC
From: Andreas Dilger <adilger@whamcloud.com>

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14055
Lustre-commit: e11deeb1e6d11460 ("LU-14055 lmv: reduce struct lmv_obd size")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/41162
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/include/lu_object.h     | 8 ++++----
 fs/lustre/obdclass/lu_tgt_descs.c | 5 ++++-
 2 files changed, 8 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/fs/lustre/include/lu_object.h b/fs/lustre/include/lu_object.h
index 80cd36d..75bb6c3 100644
--- a/fs/lustre/include/lu_object.h
+++ b/fs/lustre/include/lu_object.h
@@ -1473,10 +1473,10 @@  struct lu_tgt_desc {
 			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 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];
@@ -1521,8 +1521,8 @@  struct lu_tgt_descs {
 };
 
 #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);
diff --git a/fs/lustre/obdclass/lu_tgt_descs.c b/fs/lustre/obdclass/lu_tgt_descs.c
index a77ce20..ef30ee3 100644
--- a/fs/lustre/obdclass/lu_tgt_descs.c
+++ b/fs/lustre/obdclass/lu_tgt_descs.c
@@ -298,7 +298,7 @@  void lu_tgt_descs_fini(struct lu_tgt_descs *ltd)
 	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++)
 		kfree(ltd->ltd_tgt_idx[i]);
 	ltd->ltd_tgts_size = 0;
 }
@@ -368,6 +368,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 > TGT_PTRS * TGT_PTRS_PER_BLOCK)
+			return -ENFILE;
+
 		while (newsize < index + 1)
 			newsize = newsize << 1;