OSD API and users to use struct obd_statfs.
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I6bd98a632db9cd9f6ee4309c29d878a61bd7a228
Reviewed-on: http://review.whamcloud.com/1837
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
}
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;
* 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.
*/
}
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);
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,
* 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;
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)
* 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;
}
* 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;
/**
/** 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;
#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,
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;
}
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;
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;
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;
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;
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;
}