From: Alex Zhuravlev Date: Tue, 12 Jun 2012 06:51:47 +0000 (+0400) Subject: LU-1305 obdclass: lprocfs helpers X-Git-Tag: 2.2.58~30 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=4997a629a7ccfbd22fca2953cc0643059cbecb95 LU-1305 obdclass: lprocfs helpers few lprocfs helpers to dump statfs data via OSD API Signed-off-by: Alex Zhuravlev Change-Id: If90c410c9155f480baa8d344a670cc1a48077f07 Reviewed-on: http://review.whamcloud.com/3089 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger --- diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 3844583..8a2a73d 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -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); diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index b8b6a38..3b5e5ee 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -49,6 +49,7 @@ #include #include #include +#include #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) {