From 4883eb606e69f4e44a9ecd0b729d255d2ede4b63 Mon Sep 17 00:00:00 2001 From: yangsheng Date: Fri, 2 Jul 2010 19:30:37 +0800 Subject: [PATCH] b=20065 Add 1S statfs caching and cleanup CFS_HZ usage. i=adilger i=bobijam --- lustre/include/obd.h | 3 +++ lustre/liblustre/super.c | 3 ++- lustre/llite/llite_lib.c | 11 ++++++----- lustre/llite/lproc_llite.c | 18 ++++++++++++------ lustre/lmv/lmv_obd.c | 3 ++- lustre/lov/lov_obd.c | 6 ++++-- lustre/mdc/mdc_request.c | 3 ++- lustre/obdclass/lprocfs_status.c | 18 ++++++++++++------ lustre/obdfilter/filter.c | 3 ++- lustre/obdfilter/filter_io.c | 4 ++-- lustre/ost/ost_handler.c | 3 ++- 11 files changed, 49 insertions(+), 26 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index e8d6553..1938cb1 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -627,6 +627,9 @@ struct lov_qos_rr { unsigned long lqr_dirty:1; /* recalc round-robin list */ }; +/* allow statfs data caching for 1 second */ +#define OBD_STATFS_CACHE_SECONDS 1 + struct lov_statfs_data { struct obd_info lsd_oi; struct obd_statfs lsd_statfs; diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 4279fec..31987ac 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -1140,7 +1140,8 @@ static int llu_statfs(struct llu_sb_info *sbi, struct statfs *sfs) /* For now we will always get up-to-date statfs values, but in the * future we may allow some amount of caching on the client (e.g. * from QOS or lprocfs updates). */ - rc = llu_statfs_internal(sbi, &osfs, cfs_time_current_64() - CFS_HZ); + rc = llu_statfs_internal(sbi, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS)); if (rc) return rc; diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 6da620f..4a9bc4b 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -254,7 +254,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) GOTO(out_md, err); } - err = obd_statfs(obd, &osfs, cfs_time_current_64() - CFS_HZ, 0); + err = obd_statfs(obd, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), 0); if (err) GOTO(out_md_fid, err); @@ -1372,10 +1373,10 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs) CDEBUG(D_VFSTRACE, "VFS Op: at "LPU64" jiffies\n", get_jiffies_64()); ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_STAFS, 1); - /* For now we will always get up-to-date statfs values, but in the - * future we may allow some amount of caching on the client (e.g. - * from QOS or lprocfs updates). */ - rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - 1, 0); + /* Some amount of caching on the client is allowed */ + rc = ll_statfs_internal(sb, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + 0); if (rc) return rc; diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index a9623a0..73e60d8 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -60,7 +60,8 @@ static int ll_rd_blksize(char *page, char **start, off_t off, int count, int rc; LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - CFS_HZ, + rc = ll_statfs_internal(sb, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { *eof = 1; @@ -78,7 +79,8 @@ static int ll_rd_kbytestotal(char *page, char **start, off_t off, int count, int rc; LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - CFS_HZ, + rc = ll_statfs_internal(sb, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; @@ -102,7 +104,8 @@ static int ll_rd_kbytesfree(char *page, char **start, off_t off, int count, int rc; LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - CFS_HZ, + rc = ll_statfs_internal(sb, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; @@ -125,7 +128,8 @@ static int ll_rd_kbytesavail(char *page, char **start, off_t off, int count, int rc; LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - CFS_HZ, + rc = ll_statfs_internal(sb, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; @@ -148,7 +152,8 @@ static int ll_rd_filestotal(char *page, char **start, off_t off, int count, int rc; LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - CFS_HZ, + rc = ll_statfs_internal(sb, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { *eof = 1; @@ -165,7 +170,8 @@ static int ll_rd_filesfree(char *page, char **start, off_t off, int count, int rc; LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, cfs_time_current_64() - CFS_HZ, + rc = ll_statfs_internal(sb, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { *eof = 1; diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 031458b..e0aa6a8 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -754,7 +754,8 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, RETURN(-EFAULT); rc = obd_statfs(mdc_obd, &stat_buf, - cfs_time_current_64() - CFS_HZ, 0); + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + 0); if (rc) RETURN(rc); if (cfs_copy_to_user(data->ioc_pbuf1, &stat_buf, diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 8ecfd4d..919e698 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1129,7 +1129,8 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa, * later in alloc_qos(), we will wait for those rpcs to complete if * the osfs age is older than 2 * qos_maxage */ qos_statfs_update(exp->exp_obd, - cfs_time_shift_64(-lov->desc.ld_qos_maxage) + CFS_HZ, + cfs_time_shift_64(-lov->desc.ld_qos_maxage + + OBD_STATFS_CACHE_SECONDS), 0); rc = lov_prep_create_set(exp, &oinfo, ea, src_oa, oti, &set); @@ -2007,7 +2008,8 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, /* got statfs data */ rc = obd_statfs(osc_obd, &stat_buf, - cfs_time_current_64() - CFS_HZ, 0); + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + 0); if (rc) RETURN(rc); if (cfs_copy_to_user(data->ioc_pbuf1, &stat_buf, diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 20e61cc..6e688fd 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1402,7 +1402,8 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO(out, rc = -EFAULT); rc = mdc_statfs(obd, &stat_buf, - cfs_time_current_64() - CFS_HZ, 0); + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + 0); if (rc != 0) GOTO(out, rc); diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index da3410f..e134215 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -521,7 +521,8 @@ int lprocfs_rd_blksize(char *page, char **start, off_t off, int count, int *eof, void *data) { struct obd_statfs osfs; - int rc = obd_statfs(data, &osfs, cfs_time_current_64() - CFS_HZ, + int rc = obd_statfs(data, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { *eof = 1; @@ -534,7 +535,8 @@ int lprocfs_rd_kbytestotal(char *page, char **start, off_t off, int count, int *eof, void *data) { struct obd_statfs osfs; - int rc = obd_statfs(data, &osfs, cfs_time_current_64() - CFS_HZ, + int rc = obd_statfs(data, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; @@ -553,7 +555,8 @@ int lprocfs_rd_kbytesfree(char *page, char **start, off_t off, int count, int *eof, void *data) { struct obd_statfs osfs; - int rc = obd_statfs(data, &osfs, cfs_time_current_64() - CFS_HZ, + int rc = obd_statfs(data, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; @@ -572,7 +575,8 @@ int lprocfs_rd_kbytesavail(char *page, char **start, off_t off, int count, int *eof, void *data) { struct obd_statfs osfs; - int rc = obd_statfs(data, &osfs, cfs_time_current_64() - CFS_HZ, + int rc = obd_statfs(data, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; @@ -591,7 +595,8 @@ int lprocfs_rd_filestotal(char *page, char **start, off_t off, int count, int *eof, void *data) { struct obd_statfs osfs; - int rc = obd_statfs(data, &osfs, cfs_time_current_64() - CFS_HZ, + int rc = obd_statfs(data, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { *eof = 1; @@ -605,7 +610,8 @@ int lprocfs_rd_filesfree(char *page, char **start, off_t off, int count, int *eof, void *data) { struct obd_statfs osfs; - int rc = obd_statfs(data, &osfs, cfs_time_current_64() - CFS_HZ, + int rc = obd_statfs(data, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { *eof = 1; diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 5ce5a27..56d7b83 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -3758,7 +3758,8 @@ static int filter_precreate(struct obd_device *obd, struct obdo *oa, OBD_ALLOC(osfs, sizeof(*osfs)); if (osfs == NULL) RETURN(-ENOMEM); - rc = filter_statfs(obd, osfs, cfs_time_current_64() - CFS_HZ, + rc = filter_statfs(obd, osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), 0); if (rc == 0 && osfs->os_bavail < (osfs->os_blocks >> 10)) { CDEBUG(D_RPCTRACE,"%s: not enough space for create " diff --git a/lustre/obdfilter/filter_io.c b/lustre/obdfilter/filter_io.c index 71d7e28..979e403 100644 --- a/lustre/obdfilter/filter_io.c +++ b/lustre/obdfilter/filter_io.c @@ -153,10 +153,10 @@ obd_size filter_grant_space_left(struct obd_export *exp) LASSERT_SPIN_LOCKED(&obd->obd_osfs_lock); if (cfs_time_before_64(obd->obd_osfs_age, - cfs_time_current_64() - CFS_HZ)) { + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS))) { restat: rc = fsfilt_statfs(obd, obd->u.obt.obt_sb, - cfs_time_current_64() + CFS_HZ); + cfs_time_shift_64(OBD_STATFS_CACHE_SECONDS)); if (rc) /* N.B. statfs can't really fail */ RETURN(0); statfs_done = 1; diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index 4bbf6c5..47254d3 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -303,7 +303,8 @@ static int ost_statfs(struct ptlrpc_request *req) osfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS); req->rq_status = obd_statfs(req->rq_export->exp_obd, osfs, - cfs_time_current_64() - CFS_HZ, 0); + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + 0); if (req->rq_status != 0) CERROR("ost: statfs failed: rc %d\n", req->rq_status); -- 1.8.3.1