Whamcloud - gitweb
LU-14905 lfsck: linkEA overflow handling fix 69/44469/3
authorVitaly Fertman <c17818@cray.com>
Mon, 2 Aug 2021 17:04:44 +0000 (20:04 +0300)
committerOleg Drokin <green@whamcloud.com>
Sun, 17 Oct 2021 18:11:28 +0000 (18:11 +0000)
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 <vitaly.fertman@hpe.com>
Change-Id: Iba1549045c8c3889adf55c99cdd88756e5643073
Reviewed-on: https://es-gerrit.dev.cray.com/158706
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Alexander Zarochentsev <c17826@cray.com>
Tested-by: Jenkins Build User <nssreleng@cray.com>
Reviewed-on: https://review.whamcloud.com/44469
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alexander Zarochentsev <alexander.zarochentsev@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_linkea.h
lustre/lfsck/lfsck_namespace.c
lustre/obdclass/linkea.c

index 422a17c..f9deb4d 100644 (file)
@@ -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,
index 4c78efa..e954edf 100644 (file)
@@ -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;
index 24cb1eb..2ea560f 100644 (file)
@@ -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
  **/