@@ -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);
@@ -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;