From ca161aa1fccdd0ef4da6fc7ba464dbf9dbcdebd7 Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Thu, 11 Jan 2024 17:44:18 +0800 Subject: [PATCH] EX-8038 csdc: store compression info in FID EA Store compression information in OST-object's FID EA, and lfsck could use it to recover the MDT-object layout EA from orphan OST-object(s). 2.15 Lustre may embed PFID and layout stripe info in LMA EA, this patch would clear them from LMA EA and store them with compression info directly into FID EA thereafter. Signed-off-by: Bobi Jam Change-Id: Iacac04601b73f85d9bc057b8dd34a5004248dac4 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53649 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Sebastien Buisson Reviewed-by: Andreas Dilger --- lustre/include/uapi/linux/lustre/lustre_user.h | 8 ++- lustre/osd-ldiskfs/osd_handler.c | 95 +++++++++----------------- 2 files changed, 38 insertions(+), 65 deletions(-) diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 57f4772..70e7edb 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -485,7 +485,13 @@ struct lustre_ost_attrs { * 5 * sizeof(__u64)) to be accessable by old Lustre. If the flag * LMAC_STRIPE_INFO is set, then loa_parent_fid and loa_stripe_size * are valid; if the flag LMAC_COMP_INFO is set, then the next three - * loa_comp_* elements are valid. */ + * loa_comp_* elements are valid. + * + * Lustre 2.15 could embed following PFID info in LMA EA, since + * filter_fid has expanded to include compression info, we'd store + * OST-object's PFID + component info + compression info in PFID EA + * directly. + */ struct lu_fid loa_parent_fid; __u32 loa_stripe_size; __u32 loa_comp_id; diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index a06cc4d..0902890 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -4895,7 +4895,6 @@ static int osd_xattr_set_pfid(const struct lu_env *env, struct osd_object *obj, struct lustre_mdt_attrs *lma = &loa->loa_lma; struct inode *inode = obj->oo_inode; struct filter_fid *ff = buf->lb_buf; - struct ost_layout *ol = &ff->ff_layout; int flags = XATTR_REPLACE; int rc; @@ -4907,77 +4906,43 @@ static int osd_xattr_set_pfid(const struct lu_env *env, struct osd_object *obj, RETURN(-EINVAL); rc = osd_get_lma(info, inode, dentry, loa); + if (rc && rc != -ENODATA) + RETURN(rc); + if (rc == -ENODATA) { /* Usually for upgarding from old device */ lustre_loa_init(loa, lu_object_fid(&obj->oo_dt.do_lu), LMAC_FID_ON_OST, 0); flags = XATTR_CREATE; - } else if (rc) { - RETURN(rc); } - if (!rc && lma->lma_compat & LMAC_STRIPE_INFO) { + /* clear PFID info from LMA */ + if (lma->lma_compat & LMAC_STRIPE_INFO) { if ((fl & LU_XATTR_CREATE) && !(fl & LU_XATTR_REPLACE)) RETURN(-EEXIST); - if (LDISKFS_INODE_SIZE(inode->i_sb) > 256) { - /* Separate PFID EA from LMA */ - lma->lma_compat &= ~(LMAC_STRIPE_INFO | LMAC_COMP_INFO); - lustre_lma_swab(lma); - rc = __osd_xattr_set(info, inode, XATTR_NAME_LMA, lma, - sizeof(*lma), XATTR_REPLACE); - if (!rc) { - obj->oo_pfid_in_lma = 0; - rc = LU_XATTR_CREATE; - } - - RETURN(rc); - } - } else { - if (LDISKFS_INODE_SIZE(inode->i_sb) > 256) - RETURN(fl); - - /* - * Old client does not send stripe information, - * then store the PFID EA on disk separatedly. - */ - if (unlikely(buf->lb_len == sizeof(struct lu_fid) || - ol->ol_stripe_size == 0)) - RETURN(fl); - - /* Remove old PFID EA entry firstly. */ - dquot_initialize(inode); - rc = ll_vfs_removexattr(dentry, inode, XATTR_NAME_FID); - if (rc == -ENODATA) { - if ((fl & LU_XATTR_REPLACE) && !(fl & LU_XATTR_CREATE)) - RETURN(rc); - } else if (rc) { - RETURN(rc); - } - } - - fid_le_to_cpu(&loa->loa_parent_fid, &ff->ff_parent); - if (likely(ol->ol_stripe_size != 0)) { - loa->loa_parent_fid.f_ver |= le32_to_cpu(ol->ol_stripe_count) << - PFID_STRIPE_IDX_BITS; - loa->loa_stripe_size = le32_to_cpu(ol->ol_stripe_size); - lma->lma_compat |= LMAC_STRIPE_INFO; - if (ol->ol_comp_id != 0) { - loa->loa_comp_id = le32_to_cpu(ol->ol_comp_id); - loa->loa_comp_start = le64_to_cpu(ol->ol_comp_start); - loa->loa_comp_end = le64_to_cpu(ol->ol_comp_end); - lma->lma_compat |= LMAC_COMP_INFO; - } + /* Clear PFID EA from LMA */ + lma->lma_compat &= ~(LMAC_STRIPE_INFO | LMAC_COMP_INFO); + /* we'd create the PFID EA afterwards */ + fl = LU_XATTR_CREATE; } + lustre_lma_swab(lma); + rc = __osd_xattr_set(info, inode, XATTR_NAME_LMA, lma, sizeof(*lma), + flags); + if (rc) + RETURN(rc); - lustre_loa_swab(loa, false); + obj->oo_pfid_in_lma = 0; - /* Store the PFID EA inside LMA. */ - rc = __osd_xattr_set(info, inode, XATTR_NAME_LMA, loa, sizeof(*loa), - flags); - if (!rc) - obj->oo_pfid_in_lma = 1; + /* store the PFID EA */ + flags = 0; + if (fl & LU_XATTR_REPLACE) + flags |= XATTR_REPLACE; + if (fl & LU_XATTR_CREATE) + flags |= XATTR_CREATE; + rc = __osd_xattr_set(info, inode, XATTR_NAME_FID, buf->lb_buf, + buf->lb_len, flags); RETURN(rc); } @@ -5112,18 +5077,20 @@ static int osd_xattr_set(const struct lu_env *env, struct dt_object *dt, osd_trans_exec_op(env, handle, OSD_OT_XATTR_SET); /* - * For the OST device with 256 bytes inode size by default, + * For 2.15 OST device with 256 bytes inode size by default, * the PFID EA will be stored together with LMA EA to avoid * performance trouble. Otherwise the PFID EA can be stored * independently. LU-8998 + * + * Now Store PFID EA separately from LMA Ea, so need to clear PFID + * info from LMA EA. */ - if (strcmp(name, XATTR_NAME_FID) == 0 && osd->od_is_ost && - (LDISKFS_INODE_SIZE(inode->i_sb) <= 256 || obj->oo_pfid_in_lma)) { + if (strcmp(name, XATTR_NAME_FID) == 0 && obj->oo_pfid_in_lma) { LASSERT(buf->lb_buf); - fl = osd_xattr_set_pfid(env, obj, buf, fl, handle); - if (fl <= 0) - RETURN(fl); + rc = osd_xattr_set_pfid(env, obj, buf, fl, handle); + if (rc <= 0) + RETURN(rc); } else if (strcmp(name, XATTR_NAME_LMV) == 0) { struct lustre_ost_attrs *loa = &info->oti_ost_attrs; struct lustre_mdt_attrs *lma = &loa->loa_lma; -- 1.8.3.1