From 9a7dc69e7fe13bea07e99b534e7f3b42bee81d05 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 4 Nov 2021 11:12:57 -0500 Subject: [PATCH] EX-4189 lov: include FID in some lov asserts Include the file FID in the assertions in lov_entry() and lov_mirror_entry(). Use these two functions more consistently in the lov layer. Signed-off-by: John L. Hammond Change-Id: I65978fe409842289c158021fb1b8042916d90e23 Reviewed-on: https://review.whamcloud.com/46093 Tested-by: jenkins Reviewed-by: Andreas Dilger --- lustre/lov/lov_cl_internal.h | 25 +++++++++++++++---------- lustre/lov/lov_io.c | 9 ++++----- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lustre/lov/lov_cl_internal.h b/lustre/lov/lov_cl_internal.h index 577e70f..8740d12 100644 --- a/lustre/lov/lov_cl_internal.h +++ b/lustre/lov/lov_cl_internal.h @@ -345,14 +345,9 @@ struct lov_object { struct task_struct *lo_owner; }; -static inline struct lov_layout_raid0 *lov_r0(struct lov_object *lov, int i) +static inline const struct lu_fid *lov_object_fid(const struct lov_object *lov) { - LASSERT(lov->lo_type == LLT_COMP); - LASSERTF(i < lov->u.composite.lo_entry_count, - "entry %d entry_count %d\n", i, - lov->u.composite.lo_entry_count); - - return &lov->u.composite.lo_entries[i].lle_raid0; + return lu_object_fid(&lov->lo_cl.co_lu); } static inline struct lov_stripe_md_entry *lov_lse(struct lov_object *lov, int i) @@ -380,12 +375,18 @@ static inline struct lov_layout_entry *lov_entry(struct lov_object *lov, int i) { LASSERT(lov->lo_type == LLT_COMP); LASSERTF(i < lov->u.composite.lo_entry_count, - "entry %d entry_count %d\n", i, - lov->u.composite.lo_entry_count); + DFID" entry %d, entry_count %d\n", + PFID(lov_object_fid(lov)), + i, lov->u.composite.lo_entry_count); return &lov->u.composite.lo_entries[i]; } +static inline struct lov_layout_raid0 *lov_r0(struct lov_object *lov, int i) +{ + return &lov_entry(lov, i)->lle_raid0; +} + #define lov_for_layout_entry(lov, entry, start, end) \ for (entry = lov_entry(lov, start); \ entry <= lov_entry(lov, end); entry++) @@ -400,7 +401,11 @@ static inline struct lov_layout_entry *lov_entry(struct lov_object *lov, int i) static inline struct lov_mirror_entry * lov_mirror_entry(struct lov_object *lov, int i) { - LASSERT(i < lov->u.composite.lo_mirror_count); + LASSERTF(i < lov->u.composite.lo_mirror_count, + DFID" entry %d, mirror_count %d\n", + PFID(lov_object_fid(lov)), + i, lov->u.composite.lo_mirror_count); + return &lov->u.composite.lo_mirrors[i]; } diff --git a/lustre/lov/lov_io.c b/lustre/lov/lov_io.c index cd2757b..46b751f 100644 --- a/lustre/lov/lov_io.c +++ b/lustre/lov/lov_io.c @@ -92,8 +92,7 @@ static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio, static inline bool is_index_within_mirror(struct lov_object *lov, int index, int mirror_index) { - struct lov_layout_composite *comp = &lov->u.composite; - struct lov_mirror_entry *lre = &comp->lo_mirrors[mirror_index]; + struct lov_mirror_entry *lre = lov_mirror_entry(lov, mirror_index); return (index >= lre->lre_start && index <= lre->lre_end); } @@ -254,7 +253,7 @@ static int lov_io_mirror_write_intent(struct lov_io *lio, * need to iterate all components to see if there are * multiple components covering the writing component */ - primary = &comp->lo_mirrors[comp->lo_preferred_mirror]; + primary = lov_mirror_entry(obj, comp->lo_preferred_mirror); LASSERT(!primary->lre_stale); lov_foreach_mirror_layout_entry(obj, lle, primary) { LASSERT(lle->lle_valid); @@ -405,7 +404,7 @@ static int lov_io_mirror_init(struct lov_io *lio, struct lov_object *obj, struct lov_layout_entry *lle; bool found = false; - lre = &comp->lo_mirrors[(index + i) % comp->lo_mirror_count]; + lre = lov_mirror_entry(obj, (index + i) % comp->lo_mirror_count); if (!lre->lre_valid) continue; @@ -1935,7 +1934,7 @@ int lov_io_layout_at(struct lov_io *lio, __u64 offset) LASSERT(lio->lis_mirror_index >= 0); - lre = &comp->lo_mirrors[lio->lis_mirror_index]; + lre = lov_mirror_entry(lov, lio->lis_mirror_index); start_index = lre->lre_start; end_index = lre->lre_end; } -- 1.8.3.1