From: Andreas Dilger Date: Thu, 13 Mar 2025 08:07:29 +0000 (-0600) Subject: LU-18803 class: add namelen_max and maxbytes params X-Git-Tag: 2.16.54~64 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=dbaccf19f4bc496b90a8a93db76d32cbe889db46;p=fs%2Flustre-release.git LU-18803 class: add namelen_max and maxbytes params Add parameters for all OSD/OBD devices to print the statfs os_namelen and os_maxbytes values from the respective devices. This allows checking these values more easily from test scripts. Update test_79 to print the values (for functionality) and test that the llite.*.namelen_max matches the value of sbi->ll_statfs. Signed-off-by: Andreas Dilger Change-Id: I613b364e62f729c033a0ece29e18507caa869122 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58397 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Timothy Day Reviewed-by: Arshad Hussain Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index c24cf29..6fd847b 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2563,7 +2563,7 @@ int ll_setattr(struct mnt_idmap *map, struct dentry *de, struct iattr *attr) int ll_statfs_internal(struct ll_sb_info *sbi, struct obd_statfs *osfs, u32 flags) { - struct obd_statfs obd_osfs = { 0 }; + struct obd_statfs ost_osfs = { 0 }; time64_t max_age; int rc; @@ -2585,28 +2585,31 @@ int ll_statfs_internal(struct ll_sb_info *sbi, struct obd_statfs *osfs, if (osfs->os_state & OS_STATFS_SUM) GOTO(out, rc); - rc = obd_statfs(NULL, sbi->ll_dt_exp, &obd_osfs, max_age, flags); + rc = obd_statfs(NULL, sbi->ll_dt_exp, &ost_osfs, max_age, flags); if (rc) /* Possibly a filesystem with no OSTs. Report MDT totals. */ GOTO(out, rc = 0); CDEBUG(D_SUPER, "OSC blocks %llu/%llu objects %llu/%llu\n", - obd_osfs.os_bavail, obd_osfs.os_blocks, obd_osfs.os_ffree, - obd_osfs.os_files); + ost_osfs.os_bavail, ost_osfs.os_blocks, ost_osfs.os_ffree, + ost_osfs.os_files); - osfs->os_bsize = obd_osfs.os_bsize; - osfs->os_blocks = obd_osfs.os_blocks; - osfs->os_bfree = obd_osfs.os_bfree; - osfs->os_bavail = obd_osfs.os_bavail; + osfs->os_bsize = ost_osfs.os_bsize; + osfs->os_blocks = ost_osfs.os_blocks; + osfs->os_bfree = ost_osfs.os_bfree; + osfs->os_bavail = ost_osfs.os_bavail; + /* 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; /* 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 * to compensate, so that the "inodes in use" number is correct. * This should be kept in sync with lod_statfs() behaviour. */ - if (obd_osfs.os_files && obd_osfs.os_ffree < osfs->os_ffree) { + if (ost_osfs.os_files && ost_osfs.os_ffree < osfs->os_ffree) { osfs->os_files = (osfs->os_files - osfs->os_ffree) + - obd_osfs.os_ffree; - osfs->os_ffree = obd_osfs.os_ffree; + ost_osfs.os_ffree; + osfs->os_ffree = ost_osfs.os_ffree; } out: diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 9ca56ff..cdc2105 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -267,6 +267,38 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(filesfree); +static ssize_t maxbytes_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kset.kobj); + struct obd_statfs osfs; + int rc; + + rc = ll_statfs_internal(sbi, &osfs, OBD_STATFS_NODELAY); + if (rc) + return rc; + + return scnprintf(buf, PAGE_SIZE, "%llu\n", osfs.os_maxbytes); +} +LUSTRE_RO_ATTR(maxbytes); + +static ssize_t namelen_max_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kset.kobj); + struct obd_statfs osfs; + int rc; + + rc = ll_statfs_internal(sbi, &osfs, OBD_STATFS_NODELAY); + if (rc) + return rc; + + return scnprintf(buf, PAGE_SIZE, "%u\n", osfs.os_namelen); +} +LUSTRE_RO_ATTR(namelen_max); + static ssize_t statfs_state_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -2468,10 +2500,13 @@ static struct attribute *llite_attrs[] = { &lustre_attr_uuid.attr, &lustre_attr_checksums.attr, &lustre_attr_checksum_pages.attr, + &lustre_attr_max_easize.attr, &lustre_attr_max_read_ahead_mb.attr, &lustre_attr_max_read_ahead_per_file_mb.attr, &lustre_attr_max_read_ahead_whole_mb.attr, &lustre_attr_max_read_ahead_async_active.attr, + &lustre_attr_maxbytes.attr, + &lustre_attr_namelen_max.attr, &lustre_attr_read_ahead_async_file_threshold_mb.attr, &lustre_attr_read_ahead_range_kb.attr, &lustre_attr_stat_blocksize.attr, @@ -2491,7 +2526,6 @@ static struct attribute *llite_attrs[] = { &lustre_attr_statfs_max_age.attr, &lustre_attr_statfs_project.attr, &lustre_attr_statfs_state.attr, - &lustre_attr_max_easize.attr, &lustre_attr_default_easize.attr, &lustre_attr_xattr_cache.attr, &lustre_attr_intent_mkdir.attr, diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 2d34110..939ff17 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -1462,6 +1462,10 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, osfs->os_ffree += temp->os_ffree; osfs->os_files += temp->os_files; osfs->os_granted += temp->os_granted; + osfs->os_namelen = min(osfs->os_namelen, + temp->os_namelen); + osfs->os_maxbytes = min(osfs->os_maxbytes, + temp->os_maxbytes); } } /* There is no stats from some MDTs, data incomplete */ diff --git a/lustre/lod/lod_dev.c b/lustre/lod/lod_dev.c index 15e11ec..9359c84 100644 --- a/lustre/lod/lod_dev.c +++ b/lustre/lod/lod_dev.c @@ -1600,6 +1600,8 @@ static int lod_statfs(const struct lu_env *env, struct dt_device *dev, sfs->os_files += ost_sfs.os_files; sfs->os_ffree += ost_sfs.os_ffree; lod_statfs_sum(sfs, &ost_sfs, &bs); + /* only update MDT os_namelen, OSTs do not store filenames */ + sfs->os_namelen = min(sfs->os_namelen, ost_sfs.os_namelen); } lod_putref(lod, &lod->lod_mdt_descs); @@ -1628,8 +1630,10 @@ static int lod_statfs(const struct lu_env *env, struct dt_device *dev, ost_ffree += ost_sfs.os_ffree; ost_sfs.os_bavail += ost_sfs.os_granted; lod_statfs_sum(sfs, &ost_sfs, &bs); - LASSERTF(bs == ost_sfs.os_bsize, "%d != %d\n", - (int)sfs->os_bsize, (int)ost_sfs.os_bsize); + LASSERTF(bs == ost_sfs.os_bsize, "%u != %u\n", + sfs->os_bsize, ost_sfs.os_bsize); + /* only update OST os_maxbytes, DoM files are small */ + sfs->os_maxbytes = min(sfs->os_maxbytes, ost_sfs.os_maxbytes); } lod_putref(lod, &lod->lod_ost_descs); sfs->os_state |= OS_STATFS_SUM; diff --git a/lustre/lov/lov_request.c b/lustre/lov/lov_request.c index 771f5b3..64c3d19 100644 --- a/lustre/lov/lov_request.c +++ b/lustre/lov/lov_request.c @@ -168,7 +168,7 @@ int lov_fini_statfs_set(struct lov_request_set *set) } static void -lov_update_statfs(struct obd_statfs *osfs, struct obd_statfs *lov_sfs, +lov_statfs_update(struct obd_statfs *osfs, struct obd_statfs *lov_sfs, int success) { int shift = 0, quit = 0; @@ -237,6 +237,9 @@ lov_update_statfs(struct obd_statfs *osfs, struct obd_statfs *lov_sfs, U64_MAX : osfs->os_files + lov_sfs->os_files; 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); } } @@ -285,7 +288,7 @@ static int cb_statfs_update(void *cookie, int rc) spin_unlock(&tgtobd->obd_osfs_lock); out_update: - lov_update_statfs(osfs, lov_sfs, success); + lov_statfs_update(osfs, lov_sfs, success); lov_tgts_putref(lovobd); out: RETURN(0); diff --git a/lustre/obdclass/dt_object.c b/lustre/obdclass/dt_object.c index e9dc2fc..eb6f4e5 100644 --- a/lustre/obdclass/dt_object.c +++ b/lustre/obdclass/dt_object.c @@ -1067,7 +1067,7 @@ static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr, if (!lu->ld_obd) return -ENODEV; - return sprintf(buf, "%s\n", lu->ld_obd->obd_uuid.uuid); + return scnprintf(buf, PAGE_SIZE, "%s\n", lu->ld_obd->obd_uuid.uuid); } LUSTRE_RO_ATTR(uuid); @@ -1083,7 +1083,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, if (rc) return rc; - return sprintf(buf, "%u\n", (unsigned) osfs.os_bsize); + return scnprintf(buf, PAGE_SIZE, "%u\n", osfs.os_bsize); } LUSTRE_RO_ATTR(blocksize); @@ -1107,7 +1107,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, while (blk_size >>= 1) result <<= 1; - return sprintf(buf, "%llu\n", result); + return scnprintf(buf, PAGE_SIZE, "%llu\n", result); } LUSTRE_RO_ATTR(kbytestotal); @@ -1131,7 +1131,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, while (blk_size >>= 1) result <<= 1; - return sprintf(buf, "%llu\n", result); + return scnprintf(buf, PAGE_SIZE, "%llu\n", result); } LUSTRE_RO_ATTR(kbytesfree); @@ -1155,7 +1155,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, while (blk_size >>= 1) result <<= 1; - return sprintf(buf, "%llu\n", result); + return scnprintf(buf, PAGE_SIZE, "%llu\n", result); } LUSTRE_RO_ATTR(kbytesavail); @@ -1171,7 +1171,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, if (rc) return rc; - return sprintf(buf, "%llu\n", osfs.os_files); + return scnprintf(buf, PAGE_SIZE, "%llu\n", osfs.os_files); } LUSTRE_RO_ATTR(filestotal); @@ -1187,10 +1187,42 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, if (rc) return rc; - return sprintf(buf, "%llu\n", osfs.os_ffree); + return scnprintf(buf, PAGE_SIZE, "%llu\n", osfs.os_ffree); } LUSTRE_RO_ATTR(filesfree); +static ssize_t maxbytes_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct obd_statfs osfs; + int rc; + + rc = dt_statfs(NULL, dt, &osfs); + if (rc) + return rc; + + return scnprintf(buf, PAGE_SIZE, "%llu\n", osfs.os_maxbytes); +} +LUSTRE_RO_ATTR(maxbytes); + +static ssize_t namelen_max_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct obd_statfs osfs; + int rc; + + rc = dt_statfs(NULL, dt, &osfs); + if (rc) + return rc; + + return scnprintf(buf, PAGE_SIZE, "%u\n", osfs.os_namelen); +} +LUSTRE_RO_ATTR(namelen_max); + static ssize_t statfs_state_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -1209,11 +1241,13 @@ LUSTRE_RO_ATTR(statfs_state); static const struct attribute *dt_def_attrs[] = { &lustre_attr_blocksize.attr, + &lustre_attr_filestotal.attr, + &lustre_attr_filesfree.attr, &lustre_attr_kbytestotal.attr, &lustre_attr_kbytesfree.attr, &lustre_attr_kbytesavail.attr, - &lustre_attr_filestotal.attr, - &lustre_attr_filesfree.attr, + &lustre_attr_maxbytes.attr, + &lustre_attr_namelen_max.attr, &lustre_attr_statfs_state.attr, &lustre_attr_uuid.attr, NULL, diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 5e29a0e..cc582aa 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -276,7 +276,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, while (blk_size >>= 1) result <<= 1; - return sprintf(buf, "%llu\n", result); + return scnprintf(buf, PAGE_SIZE, "%llu\n", result); } return rc; @@ -301,7 +301,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, while (blk_size >>= 1) result <<= 1; - return sprintf(buf, "%llu\n", result); + return scnprintf(buf, PAGE_SIZE, "%llu\n", result); } return rc; @@ -320,7 +320,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, OBD_STATFS_NODELAY); if (!rc) - return sprintf(buf, "%llu\n", osfs.os_files); + return scnprintf(buf, PAGE_SIZE, "%llu\n", osfs.os_files); return rc; } @@ -338,12 +338,48 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, OBD_STATFS_NODELAY); if (!rc) - return sprintf(buf, "%llu\n", osfs.os_ffree); + return scnprintf(buf, PAGE_SIZE, "%llu\n", osfs.os_ffree); return rc; } LUSTRE_RO_ATTR(filesfree); +static ssize_t maxbytes_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct obd_statfs osfs; + int rc; + + rc = obd_statfs(NULL, obd->obd_self_export, &osfs, + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, + OBD_STATFS_NODELAY); + if (!rc) + return scnprintf(buf, PAGE_SIZE, "%llu\n", osfs.os_maxbytes); + + return rc; +} +LUSTRE_RO_ATTR(maxbytes); + +static ssize_t namelen_max_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct obd_statfs osfs; + int rc; + + rc = obd_statfs(NULL, obd->obd_self_export, &osfs, + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, + OBD_STATFS_NODELAY); + if (!rc) + return scnprintf(buf, PAGE_SIZE, "%u\n", osfs.os_namelen); + + return rc; +} +LUSTRE_RO_ATTR(namelen_max); + ssize_t lprocfs_statfs_state(char *buf, size_t buflen, __u32 state) { size_t off = 0; @@ -1116,6 +1152,8 @@ static const struct attribute *obd_def_attrs[] = { &lustre_attr_kbytestotal.attr, &lustre_attr_kbytesfree.attr, &lustre_attr_kbytesavail.attr, + &lustre_attr_maxbytes.attr, + &lustre_attr_namelen_max.attr, &lustre_attr_statfs_state.attr, &lustre_attr_uuid.attr, NULL, diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index a6484aa..110c002 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -10752,7 +10752,7 @@ test_64h() { save_lustre_params client "osc.*OST0000*.grant_shrink" > $p save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p - stack_trap "restore_lustre_params < $p; rm -f $save" EXIT + stack_trap "restore_lustre_params < $p; rm -f $p" EXIT $LCTL set_param osc.*OST0000*.grant_shrink=1 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10 @@ -12142,12 +12142,28 @@ test_79() { # bug 12743 local dffree=$(($dftotal - $dfused)) local allowance=$((64 * $OSTCOUNT)) + $LFS df $MOUNT + echo ${string[*]} + (( dftotal >= bktotal - allowance && dftotal <= bktotal + allowance)) || error "df total($dftotal) mismatch OST total($bktotal)" (( dffree >= bkfree - allowance && dffree <= bkfree + allowance )) || error "df free($dffree) mismatch OST free($bkfree)" (( dfavail >= bkavail - allowance && dfavail <= bkavail + allowance)) || error "df avail($dfavail) mismatch OST avail($bkavail)" + + $LCTL get_param *.$FSNAME-*.{maxbytes,namelen_max} + (( $MDS1_VERSION < $(version_code 2.16.52-70) )) || + do_nodes $(mdts_nodes) \ + $LCTL get_param *.$FSNAME-*.{maxbytes,namelen_max} + (( $OST1_VERSION < $(version_code 2.16.52-70) )) || + do_nodes $(osts_nodes) \ + $LCTL get_param *.$FSNAME-*.{maxbytes,namelen_max} + local dfnamelen=$(stat -f -c %l $MOUNT) + local lnamelen=($($LCTL get_param -n llite.$FSNAME-*.namelen_max)) + + (( $dfnamelen == $lnamelen )) || + error "df namelen($dfnamelen) != llite namelen($lnamelen)" } run_test 79 "df report consistency check"