Whamcloud - gitweb
LU-1305 lprocfs: osd-ldiskfs to use common helpers
authorAlex Zhuravlev <bzzz@whamcloud.com>
Wed, 27 Jun 2012 12:08:25 +0000 (16:08 +0400)
committerAndreas Dilger <adilger@whamcloud.com>
Tue, 3 Jul 2012 17:18:47 +0000 (13:18 -0400)
introduced with osd-zfs

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I504fa697f6502ddfbac1e0ebc524337a02a74328
Reviewed-on: http://review.whamcloud.com/3198
Tested-by: Hudson
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/obdclass/lprocfs_status.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_lproc.c

index 8b6b191..099e6a8 100644 (file)
@@ -579,6 +579,7 @@ int lprocfs_osd_rd_blksize(char *page, char **start, off_t off,
        }
        return rc;
 }
+EXPORT_SYMBOL(lprocfs_osd_rd_blksize);
 
 int lprocfs_rd_kbytestotal(char *page, char **start, off_t off, int count,
                            int *eof, void *data)
@@ -619,6 +620,7 @@ int lprocfs_osd_rd_kbytestotal(char *page, char **start, off_t off,
        }
        return rc;
 }
+EXPORT_SYMBOL(lprocfs_osd_rd_kbytestotal);
 
 int lprocfs_rd_kbytesfree(char *page, char **start, off_t off, int count,
                           int *eof, void *data)
@@ -659,6 +661,7 @@ int lprocfs_osd_rd_kbytesfree(char *page, char **start, off_t off,
        }
        return rc;
 }
+EXPORT_SYMBOL(lprocfs_osd_rd_kbytesfree);
 
 int lprocfs_rd_kbytesavail(char *page, char **start, off_t off, int count,
                            int *eof, void *data)
@@ -699,6 +702,7 @@ int lprocfs_osd_rd_kbytesavail(char *page, char **start, off_t off,
        }
        return rc;
 }
+EXPORT_SYMBOL(lprocfs_osd_rd_kbytesavail);
 
 int lprocfs_rd_filestotal(char *page, char **start, off_t off, int count,
                           int *eof, void *data)
@@ -729,6 +733,7 @@ int lprocfs_osd_rd_filestotal(char *page, char **start, off_t off,
 
        return rc;
 }
+EXPORT_SYMBOL(lprocfs_osd_rd_filestotal);
 
 int lprocfs_rd_filesfree(char *page, char **start, off_t off, int count,
                          int *eof, void *data)
@@ -757,6 +762,7 @@ int lprocfs_osd_rd_filesfree(char *page, char **start, off_t off,
        }
        return rc;
 }
+EXPORT_SYMBOL(lprocfs_osd_rd_filesfree);
 
 int lprocfs_rd_server_uuid(char *page, char **start, off_t off, int count,
                            int *eof, void *data)
index 8e4c862..a1243c9 100644 (file)
@@ -980,6 +980,9 @@ int osd_statfs(const struct lu_env *env, struct dt_device *d,
         struct kstatfs     *ksfs;
         int result = 0;
 
+       if (unlikely(osd->od_mount == NULL))
+               return -EINPROGRESS;
+
         /* osd_lproc.c call this without env, allocate ksfs for that case */
         if (unlikely(env == NULL)) {
                 OBD_ALLOC_PTR(ksfs);
index e95e038..e264c34 100644 (file)
@@ -263,7 +263,7 @@ int osd_procfs_init(struct osd_device *osd, const char *name)
         /* Find the type procroot and add the proc entry for this device */
         lprocfs_osd_init_vars(&lvars);
         osd->od_proc_entry = lprocfs_register(name, type->typ_procroot,
-                                              lvars.obd_vars, osd);
+                                              lvars.obd_vars, &osd->od_dt_dev);
         if (IS_ERR(osd->od_proc_entry)) {
                 rc = PTR_ERR(osd->od_proc_entry);
                 CERROR("Error %d setting up lprocfs for %s\n",
@@ -310,129 +310,8 @@ void osd_lprocfs_time_end(const struct lu_env *env, struct osd_device *osd,
 
 
 
-int lprocfs_osd_rd_blksize(char *page, char **start, off_t off, int count,
-                           int *eof, void *data)
-{
-        struct osd_device *osd = data;
-        int rc;
-
-        if (unlikely(osd->od_mount == NULL))
-                return -EINPROGRESS;
-
-        rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_statfs);
-        if (!rc) {
-                *eof = 1;
-                rc = snprintf(page, count, "%u\n", osd->od_statfs.os_bsize);
-        }
-        return rc;
-}
-
-int lprocfs_osd_rd_kbytestotal(char *page, char **start, off_t off, int count,
-                               int *eof, void *data)
-{
-        struct osd_device *osd = data;
-        int rc;
-
-        if (unlikely(osd->od_mount == NULL))
-                return -EINPROGRESS;
-
-        rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_statfs);
-        if (!rc) {
-                __u32 blk_size = osd->od_statfs.os_bsize >> 10;
-                __u64 result = osd->od_statfs.os_blocks;
-
-                while (blk_size >>= 1)
-                        result <<= 1;
-
-                *eof = 1;
-                rc = snprintf(page, count, LPU64"\n", result);
-        }
-        return rc;
-}
-
-int lprocfs_osd_rd_kbytesfree(char *page, char **start, off_t off, int count,
-                              int *eof, void *data)
-{
-        struct osd_device *osd = data;
-        int rc;
-
-        if (unlikely(osd->od_mount == NULL))
-                return -EINPROGRESS;
-
-        rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_statfs);
-        if (!rc) {
-                __u32 blk_size = osd->od_statfs.os_bsize >> 10;
-                __u64 result = osd->od_statfs.os_bfree;
-
-                while (blk_size >>= 1)
-                        result <<= 1;
-
-                *eof = 1;
-                rc = snprintf(page, count, LPU64"\n", result);
-        }
-        return rc;
-}
-
-int lprocfs_osd_rd_kbytesavail(char *page, char **start, off_t off, int count,
-                               int *eof, void *data)
-{
-        struct osd_device *osd = data;
-        int rc;
-
-        if (unlikely(osd->od_mount == NULL))
-                return -EINPROGRESS;
-
-        rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_statfs);
-        if (!rc) {
-                __u32 blk_size = osd->od_statfs.os_bsize >> 10;
-                __u64 result = osd->od_statfs.os_bavail;
-
-                while (blk_size >>= 1)
-                        result <<= 1;
-
-                *eof = 1;
-                rc = snprintf(page, count, LPU64"\n", result);
-        }
-        return rc;
-}
-
-int lprocfs_osd_rd_filestotal(char *page, char **start, off_t off, int count,
-                              int *eof, void *data)
-{
-        struct osd_device *osd = data;
-        int rc;
-
-        if (unlikely(osd->od_mount == NULL))
-                return -EINPROGRESS;
-
-        rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_statfs);
-        if (!rc) {
-                *eof = 1;
-                rc = snprintf(page, count, LPU64"\n", osd->od_statfs.os_files);
-        }
-
-        return rc;
-}
-
-int lprocfs_osd_rd_filesfree(char *page, char **start, off_t off, int count,
-                             int *eof, void *data)
-{
-        struct osd_device *osd = data;
-        int rc;
-
-        if (unlikely(osd->od_mount == NULL))
-                return -EINPROGRESS;
-
-        rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_statfs);
-        if (!rc) {
-                *eof = 1;
-                rc = snprintf(page, count, LPU64"\n", osd->od_statfs.os_ffree);
-        }
-        return rc;
-}
-
-int lprocfs_osd_rd_fstype(char *page, char **start, off_t off, int count,
-                          int *eof, void *data)
+static int lprocfs_osd_rd_fstype(char *page, char **start, off_t off, int count,
+                                int *eof, void *data)
 {
         struct obd_device *osd = data;
 
@@ -443,7 +322,7 @@ int lprocfs_osd_rd_fstype(char *page, char **start, off_t off, int count,
 static int lprocfs_osd_rd_mntdev(char *page, char **start, off_t off, int count,
                                  int *eof, void *data)
 {
-        struct osd_device *osd = data;
+        struct osd_device *osd = osd_dt_dev(data);
 
         LASSERT(osd != NULL);
         if (unlikely(osd->od_mount == NULL))