From 452841d81853fac892374cdf1f2454fecc01ddda Mon Sep 17 00:00:00 2001 From: yangsheng Date: Tue, 8 Dec 2009 06:25:39 +0000 Subject: [PATCH] Branch b1_8 b=20065 i=adilger, bobijam Add 1-second statfs caching --- lustre/include/obd.h | 3 +++ lustre/liblustre/super.c | 3 ++- lustre/llite/llite_lib.c | 14 ++++++++------ lustre/lov/lov_obd.c | 4 +++- lustre/mds/handler.c | 2 +- lustre/obdclass/lprocfs_status.c | 18 ++++++++++++------ lustre/obdfilter/filter.c | 4 +++- lustre/ost/ost_handler.c | 3 ++- 8 files changed, 34 insertions(+), 17 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 06aed96..c14c51b 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -708,6 +708,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 7a5b29d..df74d5b 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -1248,7 +1248,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() - 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 b58b1df..2338186 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -329,7 +329,8 @@ static int client_common_fill_super(struct super_block *sb, if (err) GOTO(out_mdc, err); - err = obd_statfs(obd, &osfs, cfs_time_current_64() - HZ, 0); + err = obd_statfs(obd, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), 0); if (err) GOTO(out_mdc, err); @@ -1844,10 +1845,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; @@ -2428,7 +2429,8 @@ int ll_obd_statfs(struct inode *inode, void *arg) if (!client_obd) GOTO(out_statfs, rc = -EINVAL); - rc = obd_statfs(client_obd, &stat_buf, cfs_time_current_64() - HZ, 1); + rc = obd_statfs(client_obd, &stat_buf, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), 1); if (rc) GOTO(out_statfs, rc); diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 9da4cd6..571a5bb 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1222,7 +1222,9 @@ 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) + HZ, 0); + 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); if (rc) diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 68e2256..fea6ba9 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -1132,7 +1132,7 @@ static int mds_statfs(struct ptlrpc_request *req) /* We call this so that we can cache a bit - 1 jiffie worth */ rc = mds_obd_statfs(obd, lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, size[REPLY_REC_OFF]), - cfs_time_current_64() - HZ, 0); + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), 0); if (rc) { CERROR("mds_obd_statfs failed: rc %d\n", rc); GOTO(out, rc); diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index a1f3eb1..16ddf73 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -499,7 +499,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() - HZ, + int rc = obd_statfs(data, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { *eof = 1; @@ -512,7 +513,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() - 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; @@ -531,7 +533,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() - 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; @@ -550,7 +553,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() - 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; @@ -569,7 +573,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() - HZ, + int rc = obd_statfs(data, &osfs, + cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { *eof = 1; @@ -583,7 +588,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() - 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 230ec26e..9e64f7d 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -3294,7 +3294,9 @@ 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() - HZ, 0); + 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 " LPU64"\n", obd->obd_name, osfs->os_bavail << diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index b5c6a4d..365074d 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -178,7 +178,8 @@ static int ost_statfs(struct ptlrpc_request *req) osfs = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*osfs)); req->rq_status = obd_statfs(req->rq_export->exp_obd, osfs, - cfs_time_current_64() - 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