From be4aab676e899aa9dec80445fb7edb202b4d4748 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Mon, 12 Dec 2011 19:49:41 +0300 Subject: [PATCH] LU-911 osd: use struct obd_statfs instead of kstatfs_t OSD API and users to use struct obd_statfs. Signed-off-by: Alex Zhuravlev Change-Id: I6bd98a632db9cd9f6ee4309c29d878a61bd7a228 Reviewed-on: http://review.whamcloud.com/1837 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/cmm/cmm_device.c | 2 +- lustre/include/dt_object.h | 4 ++-- lustre/include/md_object.h | 2 +- lustre/mdd/mdd_device.c | 2 +- lustre/mdt/mdt_handler.c | 4 +--- lustre/osd-ldiskfs/osd_handler.c | 25 ++++++++++++++++++++----- lustre/osd-ldiskfs/osd_internal.h | 6 ++++-- lustre/osd-ldiskfs/osd_lproc.c | 30 +++++++++++++++--------------- 8 files changed, 45 insertions(+), 30 deletions(-) diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index 3aa8b87..37f5c21 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -86,7 +86,7 @@ int cmm_root_get(const struct lu_env *env, struct md_device *md, } static int cmm_statfs(const struct lu_env *env, struct md_device *md, - cfs_kstatfs_t *sfs) + struct obd_statfs *sfs) { struct cmm_device *cmm_dev = md2cmm_dev(md); int rc; diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index 9abb6d9..ea09e46 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -117,7 +117,7 @@ struct dt_device_operations { * Return device-wide statistics. */ int (*dt_statfs)(const struct lu_env *env, - struct dt_device *dev, cfs_kstatfs_t *osfs); + struct dt_device *dev, struct obd_statfs *osfs); /** * Create transaction, described by \a param. */ @@ -1062,7 +1062,7 @@ static inline int dt_fiemap_get(const struct lu_env *env, struct dt_object *d, } static inline int dt_statfs(const struct lu_env *env, struct dt_device *dev, - cfs_kstatfs_t *osfs) + struct obd_statfs *osfs) { LASSERT(dev); LASSERT(dev->dd_ops); diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index 68fadcf..7846592 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -365,7 +365,7 @@ struct md_device_operations { int *md_size, int *cookie_size); int (*mdo_statfs)(const struct lu_env *env, struct md_device *m, - cfs_kstatfs_t *sfs); + struct obd_statfs *sfs); int (*mdo_init_capa_ctxt)(const struct lu_env *env, struct md_device *m, int mode, unsigned long timeout, __u32 alg, diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index 654824e..d4be706d 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -1140,7 +1140,7 @@ static int mdd_root_get(const struct lu_env *env, * No permission check is needed. */ static int mdd_statfs(const struct lu_env *env, struct md_device *m, - cfs_kstatfs_t *sfs) + struct obd_statfs *sfs) { struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev); int rc; diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index a1aa523..b0a150d 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -366,9 +366,7 @@ static int mdt_statfs(struct mdt_thread_info *info) 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, - &info->mti_u.ksfs); - statfs_pack(osfs, &info->mti_u.ksfs); + rc = next->md_ops->mdo_statfs(info->mti_env, next, osfs); } if (rc == 0) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index fa77bc9..299b204 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -823,24 +823,39 @@ static int osd_object_print(const struct lu_env *env, void *cookie, * Concurrency: shouldn't matter. */ int osd_statfs(const struct lu_env *env, struct dt_device *d, - cfs_kstatfs_t *sfs) + struct obd_statfs *sfs) { - struct osd_device *osd = osd_dt_dev(d); + struct osd_device *osd = osd_dt_dev(d); struct super_block *sb = osd_sb(osd); + struct kstatfs *ksfs; int result = 0; + /* osd_lproc.c call this without env, allocate ksfs for that case */ + if (unlikely(env == NULL)) { + OBD_ALLOC_PTR(ksfs); + if (ksfs == NULL) + return -ENOMEM; + } else { + ksfs = &osd_oti_get(env)->oti_ksfs; + } + cfs_spin_lock(&osd->od_osfs_lock); /* cache 1 second */ if (cfs_time_before_64(osd->od_osfs_age, cfs_time_shift_64(-1))) { - result = ll_do_statfs(sb, &osd->od_kstatfs); - if (likely(result == 0)) /* N.B. statfs can't really fail */ + result = ll_do_statfs(sb, ksfs); + if (likely(result == 0)) { /* N.B. statfs can't really fail */ osd->od_osfs_age = cfs_time_current_64(); + statfs_pack(&osd->od_statfs, ksfs); + } } if (likely(result == 0)) - *sfs = osd->od_kstatfs; + *sfs = osd->od_statfs; cfs_spin_unlock(&osd->od_osfs_lock); + if (unlikely(env == NULL)) + OBD_FREE_PTR(ksfs); + return result; } diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index f616ed0..a9cfda3 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -224,7 +224,7 @@ struct osd_device { * statfs optimization: we cache a bit. */ cfs_time_t od_osfs_age; - cfs_kstatfs_t od_kstatfs; + struct obd_statfs od_statfs; cfs_spinlock_t od_osfs_lock; /** @@ -481,6 +481,8 @@ struct osd_thread_info { /** pre-allocated buffer used by oti_it_ea, size OSD_IT_EA_BUFSIZE */ void *oti_it_ea_buf; + cfs_kstatfs_t oti_ksfs; + /** IAM iterator for index operation. */ struct iam_iterator oti_idx_it; @@ -530,7 +532,7 @@ void osd_brw_stats_update(struct osd_device *osd, struct osd_iobuf *iobuf); #endif int osd_statfs(const struct lu_env *env, struct dt_device *dev, - cfs_kstatfs_t *sfs); + struct obd_statfs *sfs); int osd_object_auth(const struct lu_env *env, struct dt_object *dt, struct lustre_capa *capa, __u64 opc); void osd_declare_qid(struct dt_object *dt, struct osd_thandle *oh, diff --git a/lustre/osd-ldiskfs/osd_lproc.c b/lustre/osd-ldiskfs/osd_lproc.c index 2bc3f37..59dac88 100644 --- a/lustre/osd-ldiskfs/osd_lproc.c +++ b/lustre/osd-ldiskfs/osd_lproc.c @@ -321,10 +321,10 @@ int lprocfs_osd_rd_blksize(char *page, char **start, off_t off, int count, if (unlikely(osd->od_mount == NULL)) return -EINPROGRESS; - rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs); + rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_statfs); if (!rc) { *eof = 1; - rc = snprintf(page, count, "%ld\n", osd->od_kstatfs.f_bsize); + rc = snprintf(page, count, "%u\n", osd->od_statfs.os_bsize); } return rc; } @@ -338,10 +338,10 @@ int lprocfs_osd_rd_kbytestotal(char *page, char **start, off_t off, int count, if (unlikely(osd->od_mount == NULL)) return -EINPROGRESS; - rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs); + rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_statfs); if (!rc) { - __u32 blk_size = osd->od_kstatfs.f_bsize >> 10; - __u64 result = osd->od_kstatfs.f_blocks; + __u32 blk_size = osd->od_statfs.os_bsize >> 10; + __u64 result = osd->od_statfs.os_blocks; while (blk_size >>= 1) result <<= 1; @@ -361,10 +361,10 @@ int lprocfs_osd_rd_kbytesfree(char *page, char **start, off_t off, int count, if (unlikely(osd->od_mount == NULL)) return -EINPROGRESS; - rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs); + rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_statfs); if (!rc) { - __u32 blk_size = osd->od_kstatfs.f_bsize >> 10; - __u64 result = osd->od_kstatfs.f_bfree; + __u32 blk_size = osd->od_statfs.os_bsize >> 10; + __u64 result = osd->od_statfs.os_bfree; while (blk_size >>= 1) result <<= 1; @@ -384,10 +384,10 @@ int lprocfs_osd_rd_kbytesavail(char *page, char **start, off_t off, int count, if (unlikely(osd->od_mount == NULL)) return -EINPROGRESS; - rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs); + rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_statfs); if (!rc) { - __u32 blk_size = osd->od_kstatfs.f_bsize >> 10; - __u64 result = osd->od_kstatfs.f_bavail; + __u32 blk_size = osd->od_statfs.os_bsize >> 10; + __u64 result = osd->od_statfs.os_bavail; while (blk_size >>= 1) result <<= 1; @@ -407,10 +407,10 @@ int lprocfs_osd_rd_filestotal(char *page, char **start, off_t off, int count, if (unlikely(osd->od_mount == NULL)) return -EINPROGRESS; - rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs); + rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_statfs); if (!rc) { *eof = 1; - rc = snprintf(page, count, LPU64"\n", osd->od_kstatfs.f_files); + rc = snprintf(page, count, LPU64"\n", osd->od_statfs.os_files); } return rc; @@ -425,10 +425,10 @@ int lprocfs_osd_rd_filesfree(char *page, char **start, off_t off, int count, if (unlikely(osd->od_mount == NULL)) return -EINPROGRESS; - rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs); + rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_statfs); if (!rc) { *eof = 1; - rc = snprintf(page, count, LPU64"\n", osd->od_kstatfs.f_ffree); + rc = snprintf(page, count, LPU64"\n", osd->od_statfs.os_ffree); } return rc; } -- 1.8.3.1