From 3514e6f03bc08bf7c3e7746a54c8900a65fc0d74 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Wed, 27 Jun 2012 16:08:25 +0400 Subject: [PATCH] LU-1305 lprocfs: osd-ldiskfs to use common helpers introduced with osd-zfs Signed-off-by: Alex Zhuravlev Change-Id: I504fa697f6502ddfbac1e0ebc524337a02a74328 Reviewed-on: http://review.whamcloud.com/3198 Tested-by: Hudson Reviewed-by: Johann Lombardi Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/obdclass/lprocfs_status.c | 6 ++ lustre/osd-ldiskfs/osd_handler.c | 3 + lustre/osd-ldiskfs/osd_lproc.c | 129 ++------------------------------------- 3 files changed, 13 insertions(+), 125 deletions(-) diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 8b6b191..099e6a8 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -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) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 8e4c862..a1243c9 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -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); diff --git a/lustre/osd-ldiskfs/osd_lproc.c b/lustre/osd-ldiskfs/osd_lproc.c index e95e038..e264c34 100644 --- a/lustre/osd-ldiskfs/osd_lproc.c +++ b/lustre/osd-ldiskfs/osd_lproc.c @@ -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)) -- 1.8.3.1