From d06053776094c722562f8564fa7f830ca553d307 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Mon, 17 Mar 2025 02:11:33 -0600 Subject: [PATCH] LU-18803 lmv: add statfs stats to LMV device Enable the statfs stats for LMV to show aggregate stats, including the marged (minimum) os_namelen from all MDTs. Merge os_state together from targets. Merge "downgrade" flags if any target has a problem, mask "upgrade" flags if any target does not have this improvement. Signed-off-by: Andreas Dilger Change-Id: I07451e65b04e5570a025bd9ff2e72f34a00273c7 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58432 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Artem Blagodarenko Reviewed-by: Oleg Drokin --- lustre/include/uapi/linux/lustre/lustre_user.h | 4 ++++ lustre/llite/llite_lib.c | 3 +++ lustre/llite/lproc_llite.c | 1 + lustre/lmv/lmv_obd.c | 3 +++ lustre/lmv/lproc_lmv.c | 2 +- lustre/lov/lov_request.c | 9 +++++++-- 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 09de932..1481235 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -273,6 +273,10 @@ enum obd_statfs_state { OS_STATFS_ENOINO = 0x00000040, /**< not enough inodes */ OS_STATFS_SUM = 0x00000100, /**< aggregated for all tagrets */ OS_STATFS_NONROT = 0x00000200, /**< non-rotational device */ + OS_STATFS_DOWNGRADE = OS_STATFS_DEGRADED | OS_STATFS_READONLY | + OS_STATFS_NOCREATE | OS_STATFS_ENOSPC | + OS_STATFS_ENOINO, + OS_STATFS_UPGRADE = OS_STATFS_NONROT, }; struct obd_statfs_state_name { diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 388f934..32d13f4 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2600,6 +2600,9 @@ int ll_statfs_internal(struct ll_sb_info *sbi, struct obd_statfs *osfs, /* do not update MDT os_namelen, OSTs do not store filenames */ /* only update from OST os_maxbytes, DoM files are small */ osfs->os_maxbytes = ost_osfs.os_maxbytes; + /* OR failure states, AND performance states */ + osfs->os_state |= ost_osfs.os_state & ~OS_STATFS_DOWNGRADE; + osfs->os_state &= ost_osfs.os_state & OS_STATFS_UPGRADE; /* If we have _some_ OSTs, but don't have as many free objects on the * OSTs as inodes on the MDTs, reduce the reported number of inodes diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index cdc2105..4b3d8de 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -288,6 +288,7 @@ static ssize_t namelen_max_show(struct kobject *kobj, struct attribute *attr, { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); + struct obd_statfs osfs; int rc; diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 618926d..17856fd 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -1473,6 +1473,9 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, temp->os_namelen); osfs->os_maxbytes = min(osfs->os_maxbytes, temp->os_maxbytes); + /* OR failure states, AND performance states */ + osfs->os_state |= temp->os_state & ~OS_STATFS_DOWNGRADE; + osfs->os_state &= temp->os_state & OS_STATFS_UPGRADE; } } /* There is no stats from some MDTs, data incomplete */ diff --git a/lustre/lmv/lproc_lmv.c b/lustre/lmv/lproc_lmv.c index b44149c..85acd1f 100644 --- a/lustre/lmv/lproc_lmv.c +++ b/lustre/lmv/lproc_lmv.c @@ -435,7 +435,7 @@ int lmv_tunables_init(struct obd_device *obd) #ifdef CONFIG_PROC_FS obd->obd_vars = lprocfs_lmv_obd_vars; #endif - rc = lprocfs_obd_setup(obd, true); + rc = lprocfs_obd_setup(obd, false); if (rc) goto out_failed; #ifdef CONFIG_PROC_FS diff --git a/lustre/lov/lov_request.c b/lustre/lov/lov_request.c index 64c3d19..7f27bfc 100644 --- a/lustre/lov/lov_request.c +++ b/lustre/lov/lov_request.c @@ -233,13 +233,18 @@ lov_statfs_update(struct obd_statfs *osfs, struct obd_statfs *lov_sfs, * * Currently using the sum capped at U64_MAX. */ - osfs->os_files = osfs->os_files + lov_sfs->os_files < osfs->os_files ? + osfs->os_files = + osfs->os_files + lov_sfs->os_files < osfs->os_files ? U64_MAX : osfs->os_files + lov_sfs->os_files; - osfs->os_ffree = osfs->os_ffree + lov_sfs->os_ffree < osfs->os_ffree ? + osfs->os_ffree = + osfs->os_ffree + lov_sfs->os_ffree < osfs->os_ffree ? U64_MAX : osfs->os_ffree + lov_sfs->os_ffree; osfs->os_namelen = min(osfs->os_namelen, lov_sfs->os_namelen); osfs->os_maxbytes = min(osfs->os_maxbytes, lov_sfs->os_maxbytes); + /* OR failure states, AND performance states */ + osfs->os_state |= lov_sfs->os_state & ~OS_STATFS_DOWNGRADE; + osfs->os_state &= lov_sfs->os_state & OS_STATFS_UPGRADE; } } -- 1.8.3.1