From 0f39a623e875804015caf8e91979aeccc129d3b1 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Thu, 9 Jun 2022 07:40:42 -0400 Subject: [PATCH] LU-15850 llite: pass dmv inherit depth instead of dir depth In directory creation, once it's ancestor has default LMV, pass the inherit depth, otherwise pass the directory depth to ROOT. This depth will be used in QoS allocation. Lustre-change: https://review.whamcloud.com/47577 Lustre-commit: c23c68a52a04369101db2bd3b1d3da23025fcf48 Signed-off-by: Lai Siyao Change-Id: Id480f32c1718e9f62314c2dfe8905be5db94d1f2 Reviewed-on: https://review.whamcloud.com/47870 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/include/lustre_lmv.h | 23 +++++++++++++++++++-- lustre/llite/dir.c | 3 ++- lustre/llite/llite_internal.h | 4 ++++ lustre/llite/llite_lib.c | 48 ++++++++++++++++++++++++++++++++++++++++--- lustre/llite/namei.c | 2 +- lustre/lod/lod_internal.h | 21 ------------------- 6 files changed, 73 insertions(+), 28 deletions(-) diff --git a/lustre/include/lustre_lmv.h b/lustre/include/lustre_lmv.h index e538d5a..7702831 100644 --- a/lustre/include/lustre_lmv.h +++ b/lustre/include/lustre_lmv.h @@ -50,8 +50,6 @@ struct lmv_stripe_md { __u32 lsm_md_layout_version; __u32 lsm_md_migrate_offset; __u32 lsm_md_migrate_hash; - __u32 lsm_md_default_count; - __u32 lsm_md_default_index; char lsm_md_pool_name[LOV_MAXPOOLNAME + 1]; struct lmv_oinfo lsm_md_oinfo[0]; }; @@ -505,4 +503,25 @@ static inline bool lmv_is_fixed(const struct lmv_mds_md_v1 *lmv) return cpu_to_le32(lmv->lmv_hash_type) & LMV_HASH_FLAG_FIXED; } +static inline __u8 lmv_inherit_next(__u8 inherit) +{ + if (inherit == LMV_INHERIT_END || inherit == LMV_INHERIT_NONE) + return LMV_INHERIT_NONE; + + if (inherit == LMV_INHERIT_UNLIMITED || inherit > LMV_INHERIT_MAX) + return inherit; + + return inherit - 1; +} + +static inline __u8 lmv_inherit_rr_next(__u8 inherit_rr) +{ + if (inherit_rr == LMV_INHERIT_RR_NONE || + inherit_rr == LMV_INHERIT_RR_UNLIMITED || + inherit_rr > LMV_INHERIT_RR_MAX) + return inherit_rr; + + return inherit_rr - 1; +} + #endif diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 4f8c5e9..7a87b9f 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -515,7 +515,8 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump, if (IS_ERR(op_data)) RETURN(PTR_ERR(op_data)); - op_data->op_dir_depth = ll_i2info(parent)->lli_dir_depth; + op_data->op_dir_depth = ll_i2info(parent)->lli_inherit_depth ?: + ll_i2info(parent)->lli_dir_depth; if (ll_sbi_has_encrypt(sbi) && (IS_ENCRYPTED(parent) || diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index bd264d3..2f2be4e 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -171,6 +171,10 @@ struct ll_inode_info { pid_t lli_opendir_pid; /* directory depth to ROOT */ unsigned short lli_dir_depth; + /* directory depth to ancestor whose default LMV is + * inherited. + */ + unsigned short lli_inherit_depth; /* stat will try to access statahead entries or start * statahead if this flag is set, and this flag will be * set upon dir open, and cleared when dir is closed, diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 75a3998..d9cac0e 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1580,6 +1580,7 @@ static void ll_update_default_lsm_md(struct inode *inode, struct lustre_md *md) lmv_free_memmd(lli->lli_default_lsm_md); lli->lli_default_lsm_md = NULL; } + lli->lli_inherit_depth = 0; up_write(&lli->lli_lsm_sem); } RETURN_EXIT; @@ -2656,9 +2657,34 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md) return 0; } +/* child default LMV is inherited from parent */ +static inline bool ll_default_lmv_inherited(struct lmv_stripe_md *pdmv, + struct lmv_stripe_md *cdmv) +{ + if (!pdmv || !cdmv) + return false; + + if (pdmv->lsm_md_magic != cdmv->lsm_md_magic || + pdmv->lsm_md_stripe_count != cdmv->lsm_md_stripe_count || + pdmv->lsm_md_master_mdt_index != cdmv->lsm_md_master_mdt_index || + pdmv->lsm_md_hash_type != cdmv->lsm_md_hash_type) + return false; + + if (cdmv->lsm_md_max_inherit != + lmv_inherit_next(pdmv->lsm_md_max_inherit)) + return false; + + if (cdmv->lsm_md_max_inherit_rr != + lmv_inherit_rr_next(pdmv->lsm_md_max_inherit_rr)) + return false; + + return true; +} + /* update directory depth to ROOT, called after LOOKUP lock is fetched. */ void ll_update_dir_depth(struct inode *dir, struct inode *inode) { + struct ll_inode_info *plli; struct ll_inode_info *lli; if (!S_ISDIR(inode->i_mode)) @@ -2667,10 +2693,26 @@ void ll_update_dir_depth(struct inode *dir, struct inode *inode) if (inode == dir) return; + plli = ll_i2info(dir); lli = ll_i2info(inode); - lli->lli_dir_depth = ll_i2info(dir)->lli_dir_depth + 1; - CDEBUG(D_INODE, DFID" depth %hu\n", - PFID(&lli->lli_fid), lli->lli_dir_depth); + lli->lli_dir_depth = plli->lli_dir_depth + 1; + if (plli->lli_default_lsm_md && lli->lli_default_lsm_md) { + down_read(&plli->lli_lsm_sem); + down_read(&lli->lli_lsm_sem); + if (ll_default_lmv_inherited(plli->lli_default_lsm_md, + lli->lli_default_lsm_md)) + lli->lli_inherit_depth = + plli->lli_inherit_depth + 1; + else + lli->lli_inherit_depth = 0; + up_read(&lli->lli_lsm_sem); + up_read(&plli->lli_lsm_sem); + } else { + lli->lli_inherit_depth = 0; + } + + CDEBUG(D_INODE, DFID" depth %hu default LMV depth %hu\n", + PFID(&lli->lli_fid), lli->lli_dir_depth, lli->lli_inherit_depth); } void ll_truncate_inode_pages_final(struct inode *inode) diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 25a0536..53345cd 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -1628,7 +1628,7 @@ static void ll_qos_mkdir_prep(struct md_op_data *op_data, struct inode *dir) struct ll_inode_info *lli = ll_i2info(dir); struct lmv_stripe_md *lsm; - op_data->op_dir_depth = lli->lli_dir_depth; + op_data->op_dir_depth = lli->lli_inherit_depth ?: lli->lli_dir_depth; /* parent directory is striped */ if (unlikely(lli->lli_lsm_md)) diff --git a/lustre/lod/lod_internal.h b/lustre/lod/lod_internal.h index 7402e2c..ddfdbd3 100644 --- a/lustre/lod/lod_internal.h +++ b/lustre/lod/lod_internal.h @@ -218,27 +218,6 @@ struct lod_default_striping { lds_dir_def_striping_set:1; }; -static inline __u8 lmv_inherit_next(__u8 inherit) -{ - if (inherit == LMV_INHERIT_END || inherit == LMV_INHERIT_NONE) - return LMV_INHERIT_NONE; - - if (inherit == LMV_INHERIT_UNLIMITED || inherit > LMV_INHERIT_MAX) - return inherit; - - return inherit - 1; -} - -static inline __u8 lmv_inherit_rr_next(__u8 inherit_rr) -{ - if (inherit_rr == LMV_INHERIT_RR_NONE || - inherit_rr == LMV_INHERIT_RR_UNLIMITED || - inherit_rr > LMV_INHERIT_RR_MAX) - return inherit_rr; - - return inherit_rr - 1; -} - enum layout_verify_flags { LVF_ALL_STALE = BIT(0), /* check not all stale mirrors */ }; -- 1.8.3.1