From c1f450270dda4bfa68de185a64b6c3c73ff7a8c5 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Sat, 5 Aug 2017 22:27:24 -0700 Subject: [PATCH] LU-9771 ptlrpc: use lu_extent in layout_intent This way it will be easier to check and print the extent of layout. Test-Parameters: testlist=sanity-flr Signed-off-by: Jinshan Xiong Change-Id: Ie99142388310a8e321899c1795bc16bee97657be Reviewed-on: https://review.whamcloud.com/29087 Reviewed-by: Lai Siyao Reviewed-by: Bobi Jam Tested-by: Jenkins Tested-by: Maloo --- lustre/include/uapi/linux/lustre/lustre_idl.h | 3 +-- lustre/include/uapi/linux/lustre/lustre_user.h | 2 +- lustre/llite/file.c | 4 ++-- lustre/lod/lod_object.c | 12 ++++++++---- lustre/mdt/mdt_handler.c | 13 +++++++------ lustre/ptlrpc/pack_generic.c | 9 +++++++-- lustre/ptlrpc/wiretest.c | 12 ++++-------- lustre/utils/wirecheck.c | 11 +++++------ lustre/utils/wiretest.c | 12 ++++-------- 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/lustre/include/uapi/linux/lustre/lustre_idl.h b/lustre/include/uapi/linux/lustre/lustre_idl.h index 0b44ba4..d8aa186 100644 --- a/lustre/include/uapi/linux/lustre/lustre_idl.h +++ b/lustre/include/uapi/linux/lustre/lustre_idl.h @@ -3218,8 +3218,7 @@ enum { struct layout_intent { __u32 li_opc; /* intent operation for enqueue, read, write etc */ __u32 li_flags; - __u64 li_start; - __u64 li_end; + struct lu_extent li_extent; } __attribute__((packed)); /** diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 314cb97..c400d20 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -524,7 +524,7 @@ struct lu_extent { __u64 e_end; }; -#define DEXT "[ %#llx , %#llx )" +#define DEXT "[%#llx, %#llx)" #define PEXT(ext) (ext)->e_start, (ext)->e_end static inline bool lu_extent_is_overlapped(struct lu_extent *e1, diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 542a026..8b516bb 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -4709,8 +4709,8 @@ int ll_layout_write_intent(struct inode *inode, __u64 start, __u64 end) { struct layout_intent intent = { .li_opc = LAYOUT_INTENT_WRITE, - .li_start = start, - .li_end = end, + .li_extent.e_start = start, + .li_extent.e_end = end, }; int rc; ENTRY; diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index ef65469..7b54498 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -5041,15 +5041,19 @@ static int lod_declare_layout_change(const struct lu_env *env, lod_comp = &lo->ldo_comp_entries[lo->ldo_comp_cnt - 1]; if (lo->ldo_comp_cnt > 1 && lod_comp->llc_extent.e_end != OBD_OBJECT_EOF && - lod_comp->llc_extent.e_end < layout->li_end) { + lod_comp->llc_extent.e_end < layout->li_extent.e_end) { CDEBUG(replay ? D_ERROR : D_LAYOUT, "%s: the defined layout [0, %#llx) does not covers " - "the write range [%#llx, %#llx).\n", + "the write range "DEXT"\n", lod2obd(d)->obd_name, lod_comp->llc_extent.e_end, - layout->li_start, layout->li_end); + PEXT(&layout->li_extent)); GOTO(out, rc = -EINVAL); } + CDEBUG(D_LAYOUT, "%s: "DFID": instantiate components "DEXT"\n", + lod2obd(d)->obd_name, PFID(lu_object_fid(&dt->do_lu)), + PEXT(&layout->li_extent)); + /* * Iterate ld->ldo_comp_entries, find the component whose extent under * the write range and not instantianted. @@ -5057,7 +5061,7 @@ static int lod_declare_layout_change(const struct lu_env *env, for (i = 0; i < lo->ldo_comp_cnt; i++) { lod_comp = &lo->ldo_comp_entries[i]; - if (lod_comp->llc_extent.e_start >= layout->li_end) + if (lod_comp->llc_extent.e_start >= layout->li_extent.e_end) break; if (!replay) { diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 53fd951c..9f34149 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1357,13 +1357,14 @@ static int mdt_layout_change(struct mdt_thread_info *info, ENTRY; CDEBUG(D_INFO, "got layout change request from client: " - "opc:%u flags:%#x extent[%#llx,%#llx)\n", + "opc:%u flags:%#x extent "DEXT"\n", layout->li_opc, layout->li_flags, - layout->li_start, layout->li_end); - if (layout->li_start >= layout->li_end) { - CERROR("Recieved an invalid layout change range [%llu, %llu) " - "for "DFID"\n", layout->li_start, layout->li_end, - PFID(mdt_object_fid(obj))); + PEXT(&layout->li_extent)); + + if (layout->li_extent.e_start >= layout->li_extent.e_end) { + CERROR("Recieved an invalid layout change range "DEXT + "for "DFID"\n", + PEXT(&layout->li_extent), PFID(mdt_object_fid(obj))); RETURN(-EINVAL); } diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 7c80969..2f07e36 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -2630,12 +2630,17 @@ void lustre_swab_hsm_user_item(struct hsm_user_item *hui) lustre_swab_hsm_extent(&hui->hui_extent); } +void lustre_swab_lu_extent(struct lu_extent *le) +{ + __swab64s(&le->e_start); + __swab64s(&le->e_end); +} + void lustre_swab_layout_intent(struct layout_intent *li) { __swab32s(&li->li_opc); __swab32s(&li->li_flags); - __swab64s(&li->li_start); - __swab64s(&li->li_end); + lustre_swab_lu_extent(&li->li_extent); } void lustre_swab_hsm_progress_kernel(struct hsm_progress_kernel *hpk) diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index cdb23de..ec8b4d8 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -4514,14 +4514,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct layout_intent, li_flags)); LASSERTF((int)sizeof(((struct layout_intent *)0)->li_flags) == 4, "found %lld\n", (long long)(int)sizeof(((struct layout_intent *)0)->li_flags)); - LASSERTF((int)offsetof(struct layout_intent, li_start) == 8, "found %lld\n", - (long long)(int)offsetof(struct layout_intent, li_start)); - LASSERTF((int)sizeof(((struct layout_intent *)0)->li_start) == 8, "found %lld\n", - (long long)(int)sizeof(((struct layout_intent *)0)->li_start)); - LASSERTF((int)offsetof(struct layout_intent, li_end) == 16, "found %lld\n", - (long long)(int)offsetof(struct layout_intent, li_end)); - LASSERTF((int)sizeof(((struct layout_intent *)0)->li_end) == 8, "found %lld\n", - (long long)(int)sizeof(((struct layout_intent *)0)->li_end)); + LASSERTF((int)offsetof(struct layout_intent, li_extent) == 8, "found %lld\n", + (long long)(int)offsetof(struct layout_intent, li_extent)); + LASSERTF((int)sizeof(((struct layout_intent *)0)->li_extent) == 16, "found %lld\n", + (long long)(int)sizeof(((struct layout_intent *)0)->li_extent)); LASSERTF(LAYOUT_INTENT_ACCESS == 0, "found %lld\n", (long long)LAYOUT_INTENT_ACCESS); LASSERTF(LAYOUT_INTENT_READ == 1, "found %lld\n", diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index 3c42583..a2e0c10 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -2161,12 +2161,11 @@ check_hsm_copy(void) static void check_layout_intent(void) { - BLANK_LINE(); - CHECK_STRUCT(layout_intent); - CHECK_MEMBER(layout_intent, li_opc); - CHECK_MEMBER(layout_intent, li_flags); - CHECK_MEMBER(layout_intent, li_start); - CHECK_MEMBER(layout_intent, li_end); + BLANK_LINE(); + CHECK_STRUCT(layout_intent); + CHECK_MEMBER(layout_intent, li_opc); + CHECK_MEMBER(layout_intent, li_flags); + CHECK_MEMBER(layout_intent, li_extent); CHECK_VALUE(LAYOUT_INTENT_ACCESS); CHECK_VALUE(LAYOUT_INTENT_READ); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 54fdbf5..0cbe43c 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -4533,14 +4533,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct layout_intent, li_flags)); LASSERTF((int)sizeof(((struct layout_intent *)0)->li_flags) == 4, "found %lld\n", (long long)(int)sizeof(((struct layout_intent *)0)->li_flags)); - LASSERTF((int)offsetof(struct layout_intent, li_start) == 8, "found %lld\n", - (long long)(int)offsetof(struct layout_intent, li_start)); - LASSERTF((int)sizeof(((struct layout_intent *)0)->li_start) == 8, "found %lld\n", - (long long)(int)sizeof(((struct layout_intent *)0)->li_start)); - LASSERTF((int)offsetof(struct layout_intent, li_end) == 16, "found %lld\n", - (long long)(int)offsetof(struct layout_intent, li_end)); - LASSERTF((int)sizeof(((struct layout_intent *)0)->li_end) == 8, "found %lld\n", - (long long)(int)sizeof(((struct layout_intent *)0)->li_end)); + LASSERTF((int)offsetof(struct layout_intent, li_extent) == 8, "found %lld\n", + (long long)(int)offsetof(struct layout_intent, li_extent)); + LASSERTF((int)sizeof(((struct layout_intent *)0)->li_extent) == 16, "found %lld\n", + (long long)(int)sizeof(((struct layout_intent *)0)->li_extent)); LASSERTF(LAYOUT_INTENT_ACCESS == 0, "found %lld\n", (long long)LAYOUT_INTENT_ACCESS); LASSERTF(LAYOUT_INTENT_READ == 1, "found %lld\n", -- 1.8.3.1