From d6732e0ebe3e94e3d768d501ab1a9d6aead5992a Mon Sep 17 00:00:00 2001 From: Vitaly Fertman Date: Mon, 2 Aug 2021 20:04:44 +0300 Subject: [PATCH] LU-14905 lfsck: linkEA overflow handling fix An absent link in EA is not an issue and not to be fixed if EA is overflowed. lfsck should not report it is an issue if there is no space for this link, and should not report it is fixed whereas it is not (linkea_add_buf() returns 0 if so without having a new entry added into EA and lfsck_namespace_assistant_handler_p1() later reports it is repaired). HPE-bug-id: LUS-8810 Signed-off-by: Vitaly Fertman Change-Id: Iba1549045c8c3889adf55c99cdd88756e5643073 Reviewed-on: https://es-gerrit.dev.cray.com/158706 Reviewed-by: Alexander Boyko Reviewed-by: Alexander Zarochentsev Tested-by: Jenkins Build User Reviewed-on: https://review.whamcloud.com/44469 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Alexander Zarochentsev Reviewed-by: Oleg Drokin --- lustre/include/lustre_linkea.h | 2 ++ lustre/lfsck/lfsck_namespace.c | 11 +++++++++++ lustre/obdclass/linkea.c | 12 ++++++++++++ 3 files changed, 25 insertions(+) diff --git a/lustre/include/lustre_linkea.h b/lustre/include/lustre_linkea.h index 422a17c..f9deb4d 100644 --- a/lustre/include/lustre_linkea.h +++ b/lustre/include/lustre_linkea.h @@ -60,6 +60,8 @@ void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen, struct lu_name *lname, struct lu_fid *pfid); int linkea_entry_pack(struct link_ea_entry *lee, const struct lu_name *lname, const struct lu_fid *pfid); +bool linkea_will_overflow(struct linkea_data *ldata, + const struct lu_name *lname); int linkea_add_buf(struct linkea_data *ldata, const struct lu_name *lname, const struct lu_fid *pfid, bool err_on_overflow); void linkea_del_buf(struct linkea_data *ldata, const struct lu_name *lname, diff --git a/lustre/lfsck/lfsck_namespace.c b/lustre/lfsck/lfsck_namespace.c index 4c78efa..e954edf 100644 --- a/lustre/lfsck/lfsck_namespace.c +++ b/lustre/lfsck/lfsck_namespace.c @@ -5828,6 +5828,17 @@ again: newdata = true; nodata: + if (rc == -ENOENT && + linkea_will_overflow(&ldata, cname)) { + CDEBUG(D_INODE, "No enough space to hold linkea entry '" + DFID": %.*s' at %u\n", PFID(pfid), + cname->ln_namelen, cname->ln_name, + ldata.ld_leh->leh_overflow_time); + log = true; + rc = 0; + goto stop; + } + if (bk->lb_param & LPF_DRYRUN) { if (rc == -ENODATA) ns->ln_flags |= LF_UPGRADE; diff --git a/lustre/obdclass/linkea.c b/lustre/obdclass/linkea.c index 24cb1eb..2ea560f 100644 --- a/lustre/obdclass/linkea.c +++ b/lustre/obdclass/linkea.c @@ -126,6 +126,18 @@ void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen, } EXPORT_SYMBOL(linkea_entry_unpack); +bool linkea_will_overflow(struct linkea_data *ldata, + const struct lu_name *lname) +{ + struct link_ea_header *leh = ldata->ld_leh; + int reclen = lname->ln_namelen + sizeof(struct link_ea_entry); + + if (unlikely(leh->leh_len + reclen > MAX_LINKEA_SIZE)) + return true; + return false; +} +EXPORT_SYMBOL(linkea_will_overflow); + /** * Add a record to the end of link ea buf **/ -- 1.8.3.1