Whamcloud - gitweb
LU-911 osd: use struct obd_statfs instead of kstatfs_t
authorAlex Zhuravlev <bzzz@whamcloud.com>
Mon, 12 Dec 2011 16:49:41 +0000 (19:49 +0300)
committerOleg Drokin <green@whamcloud.com>
Mon, 30 Apr 2012 01:58:01 +0000 (21:58 -0400)
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>
lustre/cmm/cmm_device.c
lustre/include/dt_object.h
lustre/include/md_object.h
lustre/mdd/mdd_device.c
lustre/mdt/mdt_handler.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_lproc.c

index 3aa8b87..37f5c21 100644 (file)
@@ -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;
index 9abb6d9..ea09e46 100644 (file)
@@ -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);
index 68fadcf..7846592 100644 (file)
@@ -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,
index 654824e..d4be706 100644 (file)
@@ -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;
index a1aa523..b0a150d 100644 (file)
@@ -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)
index fa77bc9..299b204 100644 (file)
@@ -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;
 }
 
index f616ed0..a9cfda3 100644 (file)
@@ -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,
index 2bc3f37..59dac88 100644 (file)
@@ -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;
 }