From cebc79b5ac3c09f1f7b75263203f9bd36a04fcc5 Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Thu, 6 Apr 2017 08:04:04 +0800 Subject: [PATCH] LU-8054 lfsck: enhance lfsck notify API Originally, the lfsck_in_notify() contains too much functionalities, including both the remote LFSCK control and local LFSCK notification. These LFSCK requirements/callers share the structure "lfsck_request" to transfer kinds of data, as to it is very difficult to enhance the "lfsck_request" for more local LFSCK requirements. Because enlarging or adjusting the "lfsck_request" fields will affect the LFSCK RPC on wire protocol and cause interoperability issues. The patch splits the local LFSCK notifications from lfsck_in_notify(), and introduce new LFSCK API lfsck_in_notify_local() for them. Then even if we have more local LFSCK requirements in the future, we can enhance such API freely without affecting LFSCK RPC protocol. Reviewed-on: https://review.whamcloud.com/24881 Signed-off-by: Fan Yong Change-Id: I8f285c6680de66a73050e167dc3874a4f6bf4ad0 Reviewed-by: Niu Yawei Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger --- lustre/include/lu_target.h | 7 ++- lustre/include/lustre/lustre_fid.h | 16 ++++++ lustre/include/lustre/lustre_idl.h | 3 +- lustre/include/lustre/lustre_ostid.h | 1 - lustre/include/lustre_lfsck.h | 32 +++++++++--- lustre/lfsck/lfsck_internal.h | 8 ++- lustre/lfsck/lfsck_layout.c | 81 +++++++++++++++++------------ lustre/lfsck/lfsck_lib.c | 34 +++++++++++-- lustre/lfsck/lfsck_namespace.c | 17 +++---- lustre/mdd/mdd_internal.h | 2 +- lustre/ofd/lproc_ofd.c | 4 ++ lustre/ofd/ofd_internal.h | 4 +- lustre/ofd/ofd_io.c | 98 ++++++++++++++++++------------------ lustre/ofd/ofd_objects.c | 54 +++++++------------- lustre/ptlrpc/wiretest.c | 2 - lustre/target/out_handler.c | 9 ++-- lustre/target/tgt_handler.c | 22 ++++++-- lustre/target/tgt_internal.h | 10 ++-- lustre/utils/wirecheck.c | 1 - lustre/utils/wiretest.c | 2 - 20 files changed, 238 insertions(+), 169 deletions(-) diff --git a/lustre/include/lu_target.h b/lustre/include/lu_target.h index 295902b..4464c74 100644 --- a/lustre/include/lu_target.h +++ b/lustre/include/lu_target.h @@ -402,10 +402,13 @@ void tgt_brw_unlock(struct obd_ioobj *obj, struct niobuf_remote *niob, int tgt_brw_read(struct tgt_session_info *tsi); int tgt_brw_write(struct tgt_session_info *tsi); int tgt_hpreq_handler(struct ptlrpc_request *req); +void tgt_register_lfsck_in_notify_local(int (*notify)(const struct lu_env *, + struct dt_device *, + struct lfsck_req_local *, + struct thandle *)); void tgt_register_lfsck_in_notify(int (*notify)(const struct lu_env *, struct dt_device *, - struct lfsck_request *, - struct thandle *)); + struct lfsck_request *)); void tgt_register_lfsck_query(int (*query)(const struct lu_env *, struct dt_device *, struct lfsck_request *, diff --git a/lustre/include/lustre/lustre_fid.h b/lustre/include/lustre/lustre_fid.h index cb6afa5..1180140 100644 --- a/lustre/include/lustre/lustre_fid.h +++ b/lustre/include/lustre/lustre_fid.h @@ -324,6 +324,22 @@ static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src) dst->f_ver = __be32_to_cpu(fid_ver(src)); } +static inline void filter_fid_cpu_to_le(struct filter_fid *dst, + const struct filter_fid *src, int size) +{ + fid_cpu_to_le(&dst->ff_parent, &src->ff_parent); + + /* XXX: Add more if filter_fid is enlarged in the future. */ +} + +static inline void filter_fid_le_to_cpu(struct filter_fid *dst, + const struct filter_fid *src, int size) +{ + fid_le_to_cpu(&dst->ff_parent, &src->ff_parent); + + /* XXX: Add more if filter_fid is enlarged in the future. */ +} + static inline bool fid_is_sane(const struct lu_fid *fid) { return fid && ((fid_seq(fid) >= FID_SEQ_START && !fid_ver(fid)) || diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index bc3b762d..53e9629 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -2869,7 +2869,6 @@ struct lfsck_request { union { __u32 lr_speed; __u32 lr_status; - __u32 lr_type; }; __u16 lr_version; __u16 lr_active; @@ -2897,7 +2896,7 @@ enum lfsck_events { LE_START = 5, LE_STOP = 6, LE_QUERY = 7, - LE_FID_ACCESSED = 8, + /* LE_FID_ACCESSED = 8, moved to lfsck_events_local */ LE_PEER_EXIT = 9, LE_CONDITIONAL_DESTROY = 10, LE_PAIRS_VERIFY = 11, diff --git a/lustre/include/lustre/lustre_ostid.h b/lustre/include/lustre/lustre_ostid.h index 4e1122d..9652987 100644 --- a/lustre/include/lustre/lustre_ostid.h +++ b/lustre/include/lustre/lustre_ostid.h @@ -36,7 +36,6 @@ #include #include -#include static inline __u64 lmm_oi_id(const struct ost_id *oi) { diff --git a/lustre/include/lustre_lfsck.h b/lustre/include/lustre_lfsck.h index 3246a57..43faaad 100644 --- a/lustre/include/lustre_lfsck.h +++ b/lustre/include/lustre_lfsck.h @@ -51,6 +51,22 @@ enum lfsck_pv_status { LPVS_INCONSISTENT_TOFIX = 2, }; +enum lfsck_events_local { + LEL_FID_ACCESSED = 1, + LEL_PAIRS_VERIFY_LOCAL = 2, +}; + +struct lfsck_req_local { + __u32 lrl_event; + __u32 lrl_status; + __u16 lrl_active; + __u16 lrl_padding0; + __u32 lrl_padding1; + struct lu_fid lrl_fid; + struct lu_fid lrl_fid2; + struct lu_fid lrl_fid3; +}; + typedef int (*lfsck_out_notify)(const struct lu_env *env, void *data, enum lfsck_events event); @@ -71,8 +87,10 @@ int lfsck_start(const struct lu_env *env, struct dt_device *key, struct lfsck_start_param *lsp); int lfsck_stop(const struct lu_env *env, struct dt_device *key, struct lfsck_stop *stop); +int lfsck_in_notify_local(const struct lu_env *env, struct dt_device *key, + struct lfsck_req_local *lrl, struct thandle *th); int lfsck_in_notify(const struct lu_env *env, struct dt_device *key, - struct lfsck_request *lr, struct thandle *th); + struct lfsck_request *lr); int lfsck_query(const struct lu_env *env, struct dt_device *key, struct lfsck_request *req, struct lfsck_reply *rep, struct lfsck_query *que); @@ -84,14 +102,14 @@ int lfsck_set_windows(struct dt_device *key, int val); int lfsck_dump(struct seq_file *m, struct dt_device *key, enum lfsck_type type); -static inline void lfsck_pack_rfa(struct lfsck_request *lr, +static inline void lfsck_pack_rfa(struct lfsck_req_local *lrl, const struct lu_fid *fid, - __u32 event, __u16 com) + enum lfsck_events_local event, __u16 com) { - memset(lr, 0, sizeof(*lr)); - lr->lr_fid = *fid; - lr->lr_event = event; - lr->lr_active = com; + memset(lrl, 0, sizeof(*lrl)); + lrl->lrl_fid = *fid; + lrl->lrl_event = event; + lrl->lrl_active = com; } static inline bool lovea_slot_is_dummy(const struct lov_ost_data_v1 *obj) diff --git a/lustre/lfsck/lfsck_internal.h b/lustre/lfsck/lfsck_internal.h index d54b25f..313407f 100644 --- a/lustre/lfsck/lfsck_internal.h +++ b/lustre/lfsck/lfsck_internal.h @@ -432,10 +432,14 @@ struct lfsck_operations { void (*lfsck_quit)(const struct lu_env *env, struct lfsck_component *com); + int (*lfsck_in_notify_local)(const struct lu_env *env, + struct lfsck_component *com, + struct lfsck_req_local *lrl, + struct thandle *th); + int (*lfsck_in_notify)(const struct lu_env *env, struct lfsck_component *com, - struct lfsck_request *lr, - struct thandle *th); + struct lfsck_request *lr); int (*lfsck_query)(const struct lu_env *env, struct lfsck_component *com, diff --git a/lustre/lfsck/lfsck_layout.c b/lustre/lfsck/lfsck_layout.c index 70c0214..b4bb877 100644 --- a/lustre/lfsck/lfsck_layout.c +++ b/lustre/lfsck/lfsck_layout.c @@ -4267,13 +4267,13 @@ out: static int lfsck_layout_slave_repair_pfid(const struct lu_env *env, struct lfsck_component *com, - struct lfsck_request *lr) + struct lfsck_req_local *lrl) { struct dt_object *obj; int rc = 0; ENTRY; - obj = lfsck_object_find_bottom(env, com->lc_lfsck, &lr->lr_fid); + obj = lfsck_object_find_bottom(env, com->lc_lfsck, &lrl->lrl_fid); if (IS_ERR(obj)) GOTO(log, rc = PTR_ERR(obj)); @@ -4282,8 +4282,8 @@ static int lfsck_layout_slave_repair_pfid(const struct lu_env *env, lfsck_is_dead_obj(obj))) GOTO(unlock, rc = 0); - rc = __lfsck_layout_update_pfid(env, obj, &lr->lr_fid2, - lr->lr_fid2.f_ver); + rc = __lfsck_layout_update_pfid(env, obj, &lrl->lrl_fid2, + lrl->lrl_fid2.f_ver); GOTO(unlock, rc); @@ -4294,7 +4294,7 @@ unlock: log: CDEBUG(D_LFSCK, "%s: layout LFSCK slave repaired pfid for "DFID ", parent "DFID": rc = %d\n", lfsck_lfsck2name(com->lc_lfsck), - PFID(&lr->lr_fid), PFID(&lr->lr_fid2), rc); + PFID(&lrl->lrl_fid), PFID(&lrl->lrl_fid2), rc); return rc; } @@ -5578,8 +5578,7 @@ static void lfsck_layout_slave_quit(const struct lu_env *env, static int lfsck_layout_master_in_notify(const struct lu_env *env, struct lfsck_component *com, - struct lfsck_request *lr, - struct thandle *th) + struct lfsck_request *lr) { struct lfsck_instance *lfsck = com->lc_lfsck; struct lfsck_layout *lo = com->lc_file_ram; @@ -5690,41 +5689,36 @@ static int lfsck_layout_master_in_notify(const struct lu_env *env, RETURN(0); } -static int lfsck_layout_slave_in_notify(const struct lu_env *env, - struct lfsck_component *com, - struct lfsck_request *lr, - struct thandle *th) +static int lfsck_layout_slave_in_notify_local(const struct lu_env *env, + struct lfsck_component *com, + struct lfsck_req_local *lrl, + struct thandle *th) { - struct lfsck_instance *lfsck = com->lc_lfsck; - struct lfsck_layout_slave_data *llsd = com->lc_data; - struct lfsck_layout_slave_target *llst; - int rc; ENTRY; - switch (lr->lr_event) { - case LE_FID_ACCESSED: - lfsck_rbtree_update_bitmap(env, com, &lr->lr_fid, true); + switch (lrl->lrl_event) { + case LEL_FID_ACCESSED: + lfsck_rbtree_update_bitmap(env, com, &lrl->lrl_fid, true); RETURN(0); - case LE_CONDITIONAL_DESTROY: - rc = lfsck_layout_slave_conditional_destroy(env, com, lr); - RETURN(rc); - case LE_PAIRS_VERIFY: { - lr->lr_status = LPVS_INIT; + case LEL_PAIRS_VERIFY_LOCAL: { + int rc; + + lrl->lrl_status = LPVS_INIT; /* Firstly, if the MDT-object which is claimed via OST-object * local stored PFID xattr recognizes the OST-object, then it * must be that the client given PFID is wrong. */ - rc = lfsck_layout_slave_check_pairs(env, com, &lr->lr_fid, - &lr->lr_fid3); + rc = lfsck_layout_slave_check_pairs(env, com, &lrl->lrl_fid, + &lrl->lrl_fid3); if (rc <= 0) RETURN(0); - lr->lr_status = LPVS_INCONSISTENT; + lrl->lrl_status = LPVS_INCONSISTENT; /* The OST-object local stored PFID xattr is stale. We need to * check whether the MDT-object that is claimed via the client * given PFID information recognizes the OST-object or not. If * matches, then need to update the OST-object's PFID xattr. */ - rc = lfsck_layout_slave_check_pairs(env, com, &lr->lr_fid, - &lr->lr_fid2); + rc = lfsck_layout_slave_check_pairs(env, com, &lrl->lrl_fid, + &lrl->lrl_fid2); /* For rc < 0 case: * We are not sure whether the client given PFID information * is correct or not, do nothing to avoid improper fixing. @@ -5733,14 +5727,34 @@ static int lfsck_layout_slave_in_notify(const struct lu_env *env, * The client given PFID information is also invalid, we can * NOT fix the OST-object inconsistency. */ - if (rc != 0) - RETURN(rc); - - lr->lr_status = LPVS_INCONSISTENT_TOFIX; - rc = lfsck_layout_slave_repair_pfid(env, com, lr); + if (!rc) { + lrl->lrl_status = LPVS_INCONSISTENT_TOFIX; + rc = lfsck_layout_slave_repair_pfid(env, com, lrl); + } RETURN(rc); } + default: + break; + } + + RETURN(-EOPNOTSUPP); +} + +static int lfsck_layout_slave_in_notify(const struct lu_env *env, + struct lfsck_component *com, + struct lfsck_request *lr) +{ + struct lfsck_instance *lfsck = com->lc_lfsck; + struct lfsck_layout_slave_data *llsd = com->lc_data; + struct lfsck_layout_slave_target *llst; + int rc; + ENTRY; + + switch (lr->lr_event) { + case LE_CONDITIONAL_DESTROY: + rc = lfsck_layout_slave_conditional_destroy(env, com, lr); + RETURN(rc); case LE_PHASE1_DONE: { if (lr->lr_flags2 & LF_INCOMPLETE) { struct lfsck_layout *lo = com->lc_file_ram; @@ -5940,6 +5954,7 @@ static struct lfsck_operations lfsck_layout_slave_ops = { .lfsck_double_scan = lfsck_layout_slave_double_scan, .lfsck_data_release = lfsck_layout_slave_data_release, .lfsck_quit = lfsck_layout_slave_quit, + .lfsck_in_notify_local = lfsck_layout_slave_in_notify_local, .lfsck_in_notify = lfsck_layout_slave_in_notify, .lfsck_query = lfsck_layout_query, .lfsck_join = lfsck_layout_slave_join, diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c index 6bf6e68..f1b9349 100644 --- a/lustre/lfsck/lfsck_lib.c +++ b/lustre/lfsck/lfsck_lib.c @@ -3388,8 +3388,32 @@ out: } EXPORT_SYMBOL(lfsck_stop); +int lfsck_in_notify_local(const struct lu_env *env, struct dt_device *key, + struct lfsck_req_local *lrl, struct thandle *th) +{ + struct lfsck_instance *lfsck; + struct lfsck_component *com; + int rc = -EOPNOTSUPP; + ENTRY; + + lfsck = lfsck_instance_find(key, true, false); + if (unlikely(!lfsck)) + RETURN(-ENXIO); + + com = lfsck_component_find(lfsck, lrl->lrl_active); + if (likely(com && com->lc_ops->lfsck_in_notify_local)) { + rc = com->lc_ops->lfsck_in_notify_local(env, com, lrl, th); + lfsck_component_put(env, com); + } + + lfsck_instance_put(env, lfsck); + + RETURN(rc); +} +EXPORT_SYMBOL(lfsck_in_notify_local); + int lfsck_in_notify(const struct lu_env *env, struct dt_device *key, - struct lfsck_request *lr, struct thandle *th) + struct lfsck_request *lr) { int rc = -EOPNOTSUPP; ENTRY; @@ -3424,7 +3448,6 @@ int lfsck_in_notify(const struct lu_env *env, struct dt_device *key, } case LE_PHASE1_DONE: case LE_PHASE2_DONE: - case LE_FID_ACCESSED: case LE_PEER_EXIT: case LE_CONDITIONAL_DESTROY: case LE_SET_LMV_MASTER: @@ -3438,8 +3461,8 @@ int lfsck_in_notify(const struct lu_env *env, struct dt_device *key, RETURN(-ENXIO); com = lfsck_component_find(lfsck, lr->lr_active); - if (likely(com != NULL)) { - rc = com->lc_ops->lfsck_in_notify(env, com, lr, th); + if (likely(com)) { + rc = com->lc_ops->lfsck_in_notify(env, com, lr); lfsck_component_put(env, com); } @@ -3889,7 +3912,8 @@ static int __init lfsck_init(void) INIT_LIST_HEAD(&lfsck_mdt_orphan_list); lfsck_key_init_generic(&lfsck_thread_key, NULL); rc = lu_context_key_register(&lfsck_thread_key); - if (rc == 0) { + if (!rc) { + tgt_register_lfsck_in_notify_local(lfsck_in_notify_local); tgt_register_lfsck_in_notify(lfsck_in_notify); tgt_register_lfsck_query(lfsck_query); } diff --git a/lustre/lfsck/lfsck_namespace.c b/lustre/lfsck/lfsck_namespace.c index 7140ef0..91a82bc 100644 --- a/lustre/lfsck/lfsck_namespace.c +++ b/lustre/lfsck/lfsck_namespace.c @@ -4653,16 +4653,15 @@ static void lfsck_namespace_quit(const struct lu_env *env, static int lfsck_namespace_in_notify(const struct lu_env *env, struct lfsck_component *com, - struct lfsck_request *lr, - struct thandle *th) + struct lfsck_request *lr) { - struct lfsck_instance *lfsck = com->lc_lfsck; - struct lfsck_namespace *ns = com->lc_file_ram; - struct lfsck_assistant_data *lad = com->lc_data; - struct lfsck_tgt_descs *ltds = &lfsck->li_mdt_descs; - struct lfsck_tgt_desc *ltd; - int rc = 0; - bool fail = false; + struct lfsck_instance *lfsck = com->lc_lfsck; + struct lfsck_namespace *ns = com->lc_file_ram; + struct lfsck_assistant_data *lad = com->lc_data; + struct lfsck_tgt_descs *ltds = &lfsck->li_mdt_descs; + struct lfsck_tgt_desc *ltd; + int rc = 0; + bool fail = false; ENTRY; switch (lr->lr_event) { diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index 37f644b..a9044a3 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -156,7 +156,7 @@ struct mdd_thread_info { struct linkea_data mti_link_data; struct md_op_spec mti_spec; struct dt_insert_rec mti_dt_rec; - struct lfsck_request mti_lr; + struct lfsck_req_local mti_lrl; struct lu_seq_range mti_range; }; diff --git a/lustre/ofd/lproc_ofd.c b/lustre/ofd/lproc_ofd.c index 417d9e6..19abd74 100644 --- a/lustre/ofd/lproc_ofd.c +++ b/lustre/ofd/lproc_ofd.c @@ -872,6 +872,10 @@ ofd_lfsck_verify_pfid_seq_write(struct file *file, const char __user *buffer, return rc; ofd->ofd_lfsck_verify_pfid = !!val; + if (!ofd->ofd_lfsck_verify_pfid) { + ofd->ofd_inconsistency_self_detected = 0; + ofd->ofd_inconsistency_self_repaired = 0; + } return count; } diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index 041d7e8..db15b4f 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -216,7 +216,7 @@ static inline char *ofd_name(struct ofd_device *ofd) struct ofd_object { struct lu_object_header ofo_header; struct dt_object ofo_obj; - struct lu_fid ofo_pfid; + struct filter_fid ofo_ff; unsigned int ofo_pfid_checking:1, ofo_pfid_verified:1; }; @@ -319,7 +319,7 @@ struct ofd_thread_info { unsigned long fti_used; struct ost_lvb fti_lvb; union { - struct lfsck_request fti_lr; + struct lfsck_req_local fti_lrl; struct obd_connect_data fti_ocd; }; }; diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index bcb41db..0a8cf2e 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -46,7 +46,7 @@ struct ofd_inconsistency_item { struct list_head oii_list; struct ofd_object *oii_obj; - struct lu_fid oii_pfid; + struct filter_fid oii_ff; }; /** @@ -60,27 +60,28 @@ struct ofd_inconsistency_item { * \param[in] env execution environment * \param[in] ofd OFD device * \param[in] oii object-related local data - * \param[in] lr LFSCK request data + * \param[in] lrl LFSCK request data */ static void ofd_inconsistency_verify_one(const struct lu_env *env, struct ofd_device *ofd, struct ofd_inconsistency_item *oii, - struct lfsck_request *lr) + struct lfsck_req_local *lrl) { - struct ofd_object *fo = oii->oii_obj; - struct lu_fid *pfid = &fo->ofo_pfid; - int rc; + struct ofd_object *fo = oii->oii_obj; + struct filter_fid *client_ff = &oii->oii_ff; + struct filter_fid *local_ff = &fo->ofo_ff; + int rc; LASSERT(fo->ofo_pfid_checking); LASSERT(!fo->ofo_pfid_verified); - lr->lr_fid = fo->ofo_header.loh_fid; /* OST-object itself FID. */ - lr->lr_fid2 = oii->oii_pfid; /* client given PFID. */ - lr->lr_fid3 = *pfid; /* OST local stored PFID. */ + lrl->lrl_fid = fo->ofo_header.loh_fid; /* OST-object itself FID. */ + lrl->lrl_fid2 = client_ff->ff_parent; /* client given PFID. */ + lrl->lrl_fid3 = local_ff->ff_parent; /* OST local stored PFID. */ - rc = lfsck_in_notify(env, ofd->ofd_osd, lr, NULL); + rc = lfsck_in_notify_local(env, ofd->ofd_osd, lrl, NULL); ofd_write_lock(env, fo); - switch (lr->lr_status) { + switch (lrl->lrl_status) { case LPVS_INIT: LASSERT(rc <= 0); @@ -89,7 +90,8 @@ static void ofd_inconsistency_verify_one(const struct lu_env *env, "PFID xattr for "DFID", the client given PFID " DFID", OST local stored PFID "DFID": rc = %d\n", ofd_name(ofd), PFID(&fo->ofo_header.loh_fid), - PFID(&oii->oii_pfid), PFID(pfid), rc); + PFID(&client_ff->ff_parent), + PFID(&local_ff->ff_parent), rc); else fo->ofo_pfid_verified = 1; break; @@ -102,14 +104,16 @@ static void ofd_inconsistency_verify_one(const struct lu_env *env, "PFID for "DFID", the client given PFID "DFID ", local stored PFID "DFID": rc = %d\n", ofd_name(ofd), PFID(&fo->ofo_header.loh_fid), - PFID(&oii->oii_pfid), PFID(pfid), rc); + PFID(&client_ff->ff_parent), + PFID(&local_ff->ff_parent), rc); else CDEBUG(D_LFSCK, "%s: both the client given PFID and " "the OST local stored PFID are stale for the " "OST-object "DFID", client given PFID is "DFID ", local stored PFID is "DFID"\n", ofd_name(ofd), PFID(&fo->ofo_header.loh_fid), - PFID(&oii->oii_pfid), PFID(pfid)); + PFID(&client_ff->ff_parent), + PFID(&local_ff->ff_parent)); break; case LPVS_INCONSISTENT_TOFIX: ofd->ofd_inconsistency_self_detected++; @@ -119,15 +123,17 @@ static void ofd_inconsistency_verify_one(const struct lu_env *env, "for "DFID", with the client given PFID "DFID ", the old stored PFID "DFID"\n", ofd_name(ofd), PFID(&fo->ofo_header.loh_fid), - PFID(&oii->oii_pfid), PFID(pfid)); + PFID(&client_ff->ff_parent), + PFID(&local_ff->ff_parent)); } else if (rc < 0) { CDEBUG(D_LFSCK, "%s: fail to fix the OST PFID xattr " "for "DFID", client given PFID "DFID", local " "stored PFID "DFID": rc = %d\n", ofd_name(ofd), PFID(&fo->ofo_header.loh_fid), - PFID(&oii->oii_pfid), PFID(pfid), rc); + PFID(&client_ff->ff_parent), + PFID(&local_ff->ff_parent), rc); } - *pfid = oii->oii_pfid; + local_ff->ff_parent = client_ff->ff_parent; fo->ofo_pfid_verified = 1; break; default: @@ -153,29 +159,29 @@ static void ofd_inconsistency_verify_one(const struct lu_env *env, */ static int ofd_inconsistency_verification_main(void *args) { - struct lu_env env; - struct ofd_device *ofd = args; - struct ptlrpc_thread *thread = &ofd->ofd_inconsistency_thread; + struct lu_env env; + struct ofd_device *ofd = args; + struct ptlrpc_thread *thread = &ofd->ofd_inconsistency_thread; struct ofd_inconsistency_item *oii; - struct lfsck_request *lr = NULL; - struct l_wait_info lwi = { 0 }; - int rc; + struct lfsck_req_local *lrl = NULL; + struct l_wait_info lwi = { 0 }; + int rc; ENTRY; rc = lu_env_init(&env, LCT_DT_THREAD); spin_lock(&ofd->ofd_inconsistency_lock); - thread_set_flags(thread, rc != 0 ? SVC_STOPPED : SVC_RUNNING); + thread_set_flags(thread, rc ? SVC_STOPPED : SVC_RUNNING); wake_up_all(&thread->t_ctl_waitq); spin_unlock(&ofd->ofd_inconsistency_lock); - if (rc != 0) + if (rc) RETURN(rc); - OBD_ALLOC_PTR(lr); - if (unlikely(lr == NULL)) + OBD_ALLOC_PTR(lrl); + if (unlikely(!lrl)) GOTO(out_unlocked, rc = -ENOMEM); - lr->lr_event = LE_PAIRS_VERIFY; - lr->lr_active = LFSCK_TYPE_LAYOUT; + lrl->lrl_event = LEL_PAIRS_VERIFY_LOCAL; + lrl->lrl_active = LFSCK_TYPE_LAYOUT; spin_lock(&ofd->ofd_inconsistency_lock); while (1) { @@ -188,7 +194,7 @@ static int ofd_inconsistency_verification_main(void *args) oii_list); list_del_init(&oii->oii_list); spin_unlock(&ofd->ofd_inconsistency_lock); - ofd_inconsistency_verify_one(&env, ofd, oii, lr); + ofd_inconsistency_verify_one(&env, ofd, oii, lrl); spin_lock(&ofd->ofd_inconsistency_lock); } @@ -219,7 +225,7 @@ static int ofd_inconsistency_verification_main(void *args) spin_lock(&ofd->ofd_inconsistency_lock); } - OBD_FREE_PTR(lr); + OBD_FREE_PTR(lrl); GOTO(out, rc = 0); @@ -320,9 +326,10 @@ int ofd_stop_inconsistency_verification_thread(struct ofd_device *ofd) static void ofd_add_inconsistency_item(const struct lu_env *env, struct ofd_object *fo, struct obdo *oa) { - struct ofd_device *ofd = ofd_obj2dev(fo); - struct ofd_inconsistency_item *oii; - bool wakeup = false; + struct ofd_device *ofd = ofd_obj2dev(fo); + struct ofd_inconsistency_item *oii; + struct filter_fid *ff; + bool wakeup = false; OBD_ALLOC_PTR(oii); if (oii == NULL) @@ -331,9 +338,10 @@ static void ofd_add_inconsistency_item(const struct lu_env *env, INIT_LIST_HEAD(&oii->oii_list); lu_object_get(&fo->ofo_obj.do_lu); oii->oii_obj = fo; - oii->oii_pfid.f_seq = oa->o_parent_seq; - oii->oii_pfid.f_oid = oa->o_parent_oid; - oii->oii_pfid.f_stripe_idx = oa->o_stripe_idx; + ff = &oii->oii_ff; + ff->ff_parent.f_seq = oa->o_parent_seq; + ff->ff_parent.f_oid = oa->o_parent_oid; + ff->ff_parent.f_stripe_idx = oa->o_stripe_idx; spin_lock(&ofd->ofd_inconsistency_lock); if (fo->ofo_pfid_checking || fo->ofo_pfid_verified) { @@ -378,8 +386,8 @@ static void ofd_add_inconsistency_item(const struct lu_env *env, int ofd_verify_ff(const struct lu_env *env, struct ofd_object *fo, struct obdo *oa) { - struct lu_fid *pfid = &fo->ofo_pfid; - int rc = 0; + struct lu_fid *pfid = &fo->ofo_ff.ff_parent; + int rc = 0; ENTRY; if (fid_is_sane(pfid)) { @@ -887,16 +895,8 @@ ofd_write_attr_set(const struct lu_env *env, struct ofd_device *ofd, rc = dt_xattr_set(env, dt_obj, &info->fti_buf, XATTR_NAME_FID, 0, th); - if (rc == 0) { - ofd_obj->ofo_pfid.f_seq = le64_to_cpu(ff->ff_parent.f_seq); - ofd_obj->ofo_pfid.f_oid = le32_to_cpu(ff->ff_parent.f_oid); - /* Currently, the filter_fid::ff_parent::f_ver is not - * the real parent MDT-object's FID::f_ver, instead it - * is the OST-object index in its parent MDT-object's - * layout EA. */ - ofd_obj->ofo_pfid.f_stripe_idx = - le32_to_cpu(ff->ff_parent.f_stripe_idx); - } + if (!rc) + filter_fid_le_to_cpu(&ofd_obj->ofo_ff, ff, sizeof(*ff)); } GOTO(out_tx, rc); diff --git a/lustre/ofd/ofd_objects.c b/lustre/ofd/ofd_objects.c index 9b8af65..342d136 100644 --- a/lustre/ofd/ofd_objects.c +++ b/lustre/ofd/ofd_objects.c @@ -121,7 +121,7 @@ struct ofd_object *ofd_object_find(const struct lu_env *env, * Get FID of parent MDT object. * * This function reads extended attribute XATTR_NAME_FID of OFD object which - * contains the MDT parent object FID and saves it in ofd_object::ofo_pfid. + * contains the MDT parent object FID and saves it in ofd_object::ofo_ff. * * The filter_fid::ff_parent::f_ver field currently holds * the OST-object index in the parent MDT-object's layout EA, @@ -137,13 +137,12 @@ struct ofd_object *ofd_object_find(const struct lu_env *env, */ int ofd_object_ff_load(const struct lu_env *env, struct ofd_object *fo) { - struct ofd_thread_info *info = ofd_info(env); - struct filter_fid_old *ff = &info->fti_mds_fid_old; - struct lu_buf *buf = &info->fti_buf; - struct lu_fid *pfid = &fo->ofo_pfid; - int rc = 0; + struct ofd_thread_info *info = ofd_info(env); + struct filter_fid *ff = &fo->ofo_ff; + struct lu_buf *buf = &info->fti_buf; + int rc = 0; - if (fid_is_sane(pfid)) + if (fid_is_sane(&ff->ff_parent)) return 0; buf->lb_buf = ff; @@ -152,15 +151,13 @@ int ofd_object_ff_load(const struct lu_env *env, struct ofd_object *fo) if (rc < 0) return rc; - if (rc < sizeof(struct lu_fid)) { - fid_zero(pfid); + if (unlikely(rc < sizeof(struct lu_fid))) { + fid_zero(&ff->ff_parent); return -ENODATA; } - pfid->f_seq = le64_to_cpu(ff->ff_parent.f_seq); - pfid->f_oid = le32_to_cpu(ff->ff_parent.f_oid); - pfid->f_stripe_idx = le32_to_cpu(ff->ff_parent.f_stripe_idx); + filter_fid_le_to_cpu(ff, ff, rc); return 0; } @@ -339,12 +336,11 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd, /* Only the new created objects need to be recorded. */ if (ofd->ofd_osd->dd_record_fid_accessed) { - struct lfsck_request *lr = &ofd_info(env)->fti_lr; + struct lfsck_req_local *lrl = &ofd_info(env)->fti_lrl; - lfsck_pack_rfa(lr, lu_object_fid(&fo->ofo_obj.do_lu), - LE_FID_ACCESSED, - LFSCK_TYPE_LAYOUT); - lfsck_in_notify(env, ofd->ofd_osd, lr, NULL); + lfsck_pack_rfa(lrl, lu_object_fid(&fo->ofo_obj.do_lu), + LEL_FID_ACCESSED, LFSCK_TYPE_LAYOUT); + lfsck_in_notify_local(env, ofd->ofd_osd, lrl, NULL); } if (likely(!ofd_object_exists(fo) && @@ -552,16 +548,8 @@ int ofd_attr_set(const struct lu_env *env, struct ofd_object *fo, if (ff_needed) { rc = dt_xattr_set(env, ofd_object_child(fo), &info->fti_buf, XATTR_NAME_FID, 0, th); - if (rc == 0) { - fo->ofo_pfid.f_seq = le64_to_cpu(ff->ff_parent.f_seq); - fo->ofo_pfid.f_oid = le32_to_cpu(ff->ff_parent.f_oid); - /* Currently, the filter_fid::ff_parent::f_ver is not - * the real parent MDT-object's FID::f_ver, instead it - * is the OST-object index in its parent MDT-object's - * layout EA. */ - fo->ofo_pfid.f_stripe_idx = - le32_to_cpu(ff->ff_parent.f_stripe_idx); - } + if (!rc) + filter_fid_le_to_cpu(&fo->ofo_ff, ff, sizeof(*ff)); } GOTO(stop, rc); @@ -686,16 +674,8 @@ int ofd_object_punch(const struct lu_env *env, struct ofd_object *fo, if (ff_needed) { rc = dt_xattr_set(env, ofd_object_child(fo), &info->fti_buf, XATTR_NAME_FID, 0, th); - if (rc == 0) { - fo->ofo_pfid.f_seq = le64_to_cpu(ff->ff_parent.f_seq); - fo->ofo_pfid.f_oid = le32_to_cpu(ff->ff_parent.f_oid); - /* Currently, the filter_fid::ff_parent::f_ver is not - * the real parent MDT-object's FID::f_ver, instead it - * is the OST-object index in its parent MDT-object's - * layout EA. */ - fo->ofo_pfid.f_stripe_idx = - le32_to_cpu(ff->ff_parent.f_stripe_idx); - } + if (!rc) + filter_fid_le_to_cpu(&fo->ofo_ff, ff, sizeof(*ff)); } GOTO(stop, rc); diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index 1149787..abdec07 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -5040,8 +5040,6 @@ void lustre_assert_wire_constants(void) (long long)LE_STOP); LASSERTF(LE_QUERY == 7, "found %lld\n", (long long)LE_QUERY); - LASSERTF(LE_FID_ACCESSED == 8, "found %lld\n", - (long long)LE_FID_ACCESSED); LASSERTF(LE_PEER_EXIT == 9, "found %lld\n", (long long)LE_PEER_EXIT); LASSERTF(LE_CONDITIONAL_DESTROY == 10, "found %lld\n", diff --git a/lustre/target/out_handler.c b/lustre/target/out_handler.c index 4f77ae6..e10e75a 100644 --- a/lustre/target/out_handler.c +++ b/lustre/target/out_handler.c @@ -1082,12 +1082,13 @@ int out_handle(struct tgt_session_info *tsi) GOTO(out, rc = PTR_ERR(dt_obj)); if (dt->dd_record_fid_accessed) { - lfsck_pack_rfa(&tti->tti_lr, + struct lfsck_req_local *lrl = &tti->tti_lrl; + + lfsck_pack_rfa(lrl, lu_object_fid(&dt_obj->do_lu), - LE_FID_ACCESSED, + LEL_FID_ACCESSED, LFSCK_TYPE_LAYOUT); - tgt_lfsck_in_notify(env, dt, &tti->tti_lr, - NULL); + tgt_lfsck_in_notify_local(env, dt, lrl, NULL); } tti->tti_u.update.tti_dt_object = dt_obj; diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index 259c758..c6ff5ef 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -1433,15 +1433,27 @@ TGT_SEC_HDL_VAR(0, SEC_CTX_FINI, tgt_sec_ctx_handle), }; EXPORT_SYMBOL(tgt_sec_ctx_handlers); +int (*tgt_lfsck_in_notify_local)(const struct lu_env *env, + struct dt_device *key, + struct lfsck_req_local *lrl, + struct thandle *th) = NULL; + +void tgt_register_lfsck_in_notify_local(int (*notify)(const struct lu_env *, + struct dt_device *, + struct lfsck_req_local *, + struct thandle *)) +{ + tgt_lfsck_in_notify_local = notify; +} +EXPORT_SYMBOL(tgt_register_lfsck_in_notify_local); + int (*tgt_lfsck_in_notify)(const struct lu_env *env, struct dt_device *key, - struct lfsck_request *lr, - struct thandle *th) = NULL; + struct lfsck_request *lr) = NULL; void tgt_register_lfsck_in_notify(int (*notify)(const struct lu_env *, struct dt_device *, - struct lfsck_request *, - struct thandle *)) + struct lfsck_request *)) { tgt_lfsck_in_notify = notify; } @@ -1476,7 +1488,7 @@ static int tgt_handle_lfsck_notify(struct tgt_session_info *tsi) if (lr == NULL) RETURN(-EPROTO); - rc = tgt_lfsck_in_notify(env, key, lr, NULL); + rc = tgt_lfsck_in_notify(env, key, lr); RETURN(rc); } diff --git a/lustre/target/tgt_internal.h b/lustre/target/tgt_internal.h index bc9cbbc..ea19560 100644 --- a/lustre/target/tgt_internal.h +++ b/lustre/target/tgt_internal.h @@ -43,10 +43,10 @@ #include #include -extern int (*tgt_lfsck_in_notify)(const struct lu_env *env, - struct dt_device *key, - struct lfsck_request *lr, - struct thandle *th); +extern int (*tgt_lfsck_in_notify_local)(const struct lu_env *env, + struct dt_device *key, + struct lfsck_req_local *lrl, + struct thandle *th); /** * Common data shared by tg-level handlers. This is allocated per-thread to * reduce stack consumption. @@ -86,7 +86,7 @@ struct tgt_thread_info { struct l_wait_info tti_wait_info; } update; } tti_u; - struct lfsck_request tti_lr; + struct lfsck_req_local tti_lrl; struct dt_insert_rec tti_rec; }; diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index d151011..58faa39 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -2356,7 +2356,6 @@ static void check_lfsck_request(void) CHECK_VALUE(LE_START); CHECK_VALUE(LE_STOP); CHECK_VALUE(LE_QUERY); - CHECK_VALUE(LE_FID_ACCESSED); CHECK_VALUE(LE_PEER_EXIT); CHECK_VALUE(LE_CONDITIONAL_DESTROY); CHECK_VALUE(LE_PAIRS_VERIFY); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 1a30582..508fd18 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -5060,8 +5060,6 @@ void lustre_assert_wire_constants(void) (long long)LE_STOP); LASSERTF(LE_QUERY == 7, "found %lld\n", (long long)LE_QUERY); - LASSERTF(LE_FID_ACCESSED == 8, "found %lld\n", - (long long)LE_FID_ACCESSED); LASSERTF(LE_PEER_EXIT == 9, "found %lld\n", (long long)LE_PEER_EXIT); LASSERTF(LE_CONDITIONAL_DESTROY == 10, "found %lld\n", -- 1.8.3.1