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;
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:
}
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)
{
&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,
&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,
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 */
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);
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;
}
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;
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);
}
}
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);
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);
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);
while (blk_size >>= 1)
result <<= 1;
- return sprintf(buf, "%llu\n", result);
+ return scnprintf(buf, PAGE_SIZE, "%llu\n", result);
}
LUSTRE_RO_ATTR(kbytestotal);
while (blk_size >>= 1)
result <<= 1;
- return sprintf(buf, "%llu\n", result);
+ return scnprintf(buf, PAGE_SIZE, "%llu\n", result);
}
LUSTRE_RO_ATTR(kbytesfree);
while (blk_size >>= 1)
result <<= 1;
- return sprintf(buf, "%llu\n", result);
+ return scnprintf(buf, PAGE_SIZE, "%llu\n", result);
}
LUSTRE_RO_ATTR(kbytesavail);
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);
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)
{
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,
while (blk_size >>= 1)
result <<= 1;
- return sprintf(buf, "%llu\n", result);
+ return scnprintf(buf, PAGE_SIZE, "%llu\n", result);
}
return rc;
while (blk_size >>= 1)
result <<= 1;
- return sprintf(buf, "%llu\n", result);
+ return scnprintf(buf, PAGE_SIZE, "%llu\n", result);
}
return rc;
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;
}
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;
&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,
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
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"