Whamcloud - gitweb
LU-1305 obdclass: lprocfs helpers
authorAlex Zhuravlev <bzzz@whamcloud.com>
Tue, 12 Jun 2012 06:51:47 +0000 (10:51 +0400)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 21 Jun 2012 06:45:55 +0000 (02:45 -0400)
few lprocfs helpers to dump statfs data via OSD API

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: If90c410c9155f480baa8d344a670cc1a48077f07
Reviewed-on: http://review.whamcloud.com/3089
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/lprocfs_status.h
lustre/obdclass/lprocfs_status.c

index 3844583..8a2a73d 100644 (file)
@@ -608,6 +608,19 @@ extern int lprocfs_rd_filesfree(char *page, char **start, off_t off,
                                 int count, int *eof, void *data);
 extern int lprocfs_rd_filegroups(char *page, char **start, off_t off,
                                  int count, int *eof, void *data);
+extern int lprocfs_osd_rd_blksize(char *page, char **start, off_t off,
+                               int count, int *eof, void *data);
+extern int lprocfs_osd_rd_kbytesfree(char *page, char **start, off_t off,
+                               int count, int *eof, void *data);
+extern int lprocfs_osd_rd_kbytesavail(char *page, char **start, off_t off,
+                               int count, int *eof, void *data);
+extern int lprocfs_osd_rd_filestotal(char *page, char **start, off_t off,
+                               int count, int *eof, void *data);
+extern int lprocfs_osd_rd_filesfree(char *page, char **start, off_t off,
+                               int count, int *eof, void *data);
+extern int lprocfs_osd_rd_kbytestotal(char *page, char **start, off_t off,
+                               int count, int *eof, void *data);
+
 
 extern int lprocfs_write_helper(const char *buffer, unsigned long count,
                                 int *val);
index b8b6a38..3b5e5ee 100644 (file)
@@ -49,6 +49,7 @@
 #include <lustre_fsfilt.h>
 #include <lustre_log.h>
 #include <lustre/lustre_idl.h>
+#include <dt_object.h>
 
 #if defined(LPROCFS)
 
@@ -565,6 +566,20 @@ int lprocfs_rd_blksize(char *page, char **start, off_t off, int count,
         return rc;
 }
 
+int lprocfs_osd_rd_blksize(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       struct dt_device *dt = data;
+       struct obd_statfs osfs;
+       int rc = dt_statfs(NULL, dt, &osfs);
+       if (!rc) {
+               *eof = 1;
+               rc = snprintf(page, count, "%d\n",
+                               (unsigned) osfs.os_bsize);
+       }
+       return rc;
+}
+
 int lprocfs_rd_kbytestotal(char *page, char **start, off_t off, int count,
                            int *eof, void *data)
 {
@@ -586,6 +601,25 @@ int lprocfs_rd_kbytestotal(char *page, char **start, off_t off, int count,
         return rc;
 }
 
+int lprocfs_osd_rd_kbytestotal(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       struct dt_device *dt = data;
+       struct obd_statfs osfs;
+       int rc = dt_statfs(NULL, dt, &osfs);
+       if (!rc) {
+               __u32 blk_size = osfs.os_bsize >> 10;
+               __u64 result = osfs.os_blocks;
+
+               while (blk_size >>= 1)
+                       result <<= 1;
+
+               *eof = 1;
+               rc = snprintf(page, count, LPU64"\n", result);
+       }
+       return rc;
+}
+
 int lprocfs_rd_kbytesfree(char *page, char **start, off_t off, int count,
                           int *eof, void *data)
 {
@@ -607,6 +641,25 @@ int lprocfs_rd_kbytesfree(char *page, char **start, off_t off, int count,
         return rc;
 }
 
+int lprocfs_osd_rd_kbytesfree(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       struct dt_device *dt = data;
+       struct obd_statfs osfs;
+       int rc = dt_statfs(NULL, dt, &osfs);
+       if (!rc) {
+               __u32 blk_size = osfs.os_bsize >> 10;
+               __u64 result = osfs.os_bfree;
+
+               while (blk_size >>= 1)
+                       result <<= 1;
+
+               *eof = 1;
+               rc = snprintf(page, count, LPU64"\n", result);
+       }
+       return rc;
+}
+
 int lprocfs_rd_kbytesavail(char *page, char **start, off_t off, int count,
                            int *eof, void *data)
 {
@@ -628,6 +681,25 @@ int lprocfs_rd_kbytesavail(char *page, char **start, off_t off, int count,
         return rc;
 }
 
+int lprocfs_osd_rd_kbytesavail(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       struct dt_device *dt = data;
+       struct obd_statfs osfs;
+       int rc = dt_statfs(NULL, dt, &osfs);
+       if (!rc) {
+               __u32 blk_size = osfs.os_bsize >> 10;
+               __u64 result = osfs.os_bavail;
+
+               while (blk_size >>= 1)
+                       result <<= 1;
+
+               *eof = 1;
+               rc = snprintf(page, count, LPU64"\n", result);
+       }
+       return rc;
+}
+
 int lprocfs_rd_filestotal(char *page, char **start, off_t off, int count,
                           int *eof, void *data)
 {
@@ -644,6 +716,20 @@ int lprocfs_rd_filestotal(char *page, char **start, off_t off, int count,
         return rc;
 }
 
+int lprocfs_osd_rd_filestotal(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       struct dt_device *dt = data;
+       struct obd_statfs osfs;
+       int rc = dt_statfs(NULL, dt, &osfs);
+       if (!rc) {
+               *eof = 1;
+               rc = snprintf(page, count, LPU64"\n", osfs.os_files);
+       }
+
+       return rc;
+}
+
 int lprocfs_rd_filesfree(char *page, char **start, off_t off, int count,
                          int *eof, void *data)
 {
@@ -659,6 +745,19 @@ int lprocfs_rd_filesfree(char *page, char **start, off_t off, int count,
         return rc;
 }
 
+int lprocfs_osd_rd_filesfree(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       struct dt_device *dt = data;
+       struct obd_statfs osfs;
+       int rc = dt_statfs(NULL, dt, &osfs);
+       if (!rc) {
+               *eof = 1;
+               rc = snprintf(page, count, LPU64"\n", osfs.os_ffree);
+       }
+       return rc;
+}
+
 int lprocfs_rd_server_uuid(char *page, char **start, off_t off, int count,
                            int *eof, void *data)
 {