if (rc)
RETURN(err_serious(rc));
- if (OBD_FAIL_CHECK(OBD_FAIL_MDS_STATFS_PACK)) {
- rc = err_serious(-ENOMEM);
- } else {
- osfs = req_capsule_server_get(info->mti_pill, &RMF_OBD_STATFS);
- rc = next->md_ops->mdo_statfs(info->mti_env, next, osfs);
- }
+ if (OBD_FAIL_CHECK(OBD_FAIL_MDS_STATFS_PACK))
+ RETURN(err_serious(-ENOMEM));
+
+ osfs = req_capsule_server_get(info->mti_pill, &RMF_OBD_STATFS);
+ if (!osfs)
+ RETURN(-EPROTO);
+
+ /** statfs information are cached in the mdt_device */
+ if (cfs_time_before_64(info->mti_mdt->mdt_osfs_age,
+ cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS))) {
+ /** statfs data is too old, get up-to-date one */
+ rc = next->md_ops->mdo_statfs(info->mti_env, next, osfs);
+ if (rc)
+ RETURN(rc);
+ cfs_spin_lock(&info->mti_mdt->mdt_osfs_lock);
+ info->mti_mdt->mdt_osfs = *osfs;
+ info->mti_mdt->mdt_osfs_age = cfs_time_current_64();
+ cfs_spin_unlock(&info->mti_mdt->mdt_osfs_lock);
+ } else {
+ /** use cached statfs data */
+ cfs_spin_lock(&info->mti_mdt->mdt_osfs_lock);
+ *osfs = info->mti_mdt->mdt_osfs;
+ cfs_spin_unlock(&info->mti_mdt->mdt_osfs_lock);
+ }
if (rc == 0)
mdt_counter_incr(req, LPROC_MDT_STATFS);
unsigned int mdt_capa_conf:1,
mdt_som_conf:1;
+ /* statfs optimization: we cache a bit */
+ struct obd_statfs mdt_osfs;
+ __u64 mdt_osfs_age;
+ cfs_spinlock_t mdt_osfs_lock;
+
/* root squash */
uid_t mdt_squash_uid;
gid_t mdt_squash_gid;
struct obd_uuid uuid[2]; /* for mdt_seq_init_cli() */
char ns_name[48]; /* for mdt_init0() */
struct lustre_cfg_bufs bufs; /* for mdt_stack_fini() */
- cfs_kstatfs_t ksfs; /* for mdt_statfs() */
+ struct obd_statfs osfs; /* for mdt_statfs() */
struct {
/* for mdt_readpage() */
struct lu_rdpg mti_rdpg;