aboutsummaryrefslogtreecommitdiff
blob: a93c92a15a1fd93dd1cfeda86934a9eb64879612 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
From c05c0be01814527d8d3762963c7a6d4c28189d2d Mon Sep 17 00:00:00 2001
From: James Simmons <uja.ornl@gmail.com>
Date: Fri, 3 Jan 2014 09:55:26 -0500
Subject: [PATCH 03/13] LU-3319 procfs: update zfs proc handling to seq_files

Migrate all zfs proc handling to using strictly seq_files.

Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: I6dc7e65c3e74e7934a17939815ec3c334fac58c7
---
 lustre/osd-zfs/osd_handler.c  | 13 ++++---
 lustre/osd-zfs/osd_internal.h |  3 --
 lustre/osd-zfs/osd_lproc.c    | 88 ++++++++++++++++++++++++-------------------
 3 files changed, 57 insertions(+), 47 deletions(-)

diff --git a/lustre/osd-zfs/osd_handler.c b/lustre/osd-zfs/osd_handler.c
index d4193cd..36bf6a4 100644
--- a/lustre/osd-zfs/osd_handler.c
+++ b/lustre/osd-zfs/osd_handler.c
@@ -745,6 +745,7 @@ static int osd_device_init(const struct lu_env *env, struct lu_device *d,
 static int osd_process_config(const struct lu_env *env,
 			      struct lu_device *d, struct lustre_cfg *cfg)
 {
+	struct obd_device	*obd = d->ld_obd;
 	struct osd_device	*o = osd_dev(d);
 	int			rc;
 	ENTRY;
@@ -758,12 +759,12 @@ static int osd_process_config(const struct lu_env *env,
 		break;
 	case LCFG_PARAM: {
 		LASSERT(&o->od_dt_dev);
-		rc = class_process_proc_param(PARAM_OSD, lprocfs_osd_obd_vars,
-					      cfg, &o->od_dt_dev);
+		rc = class_process_proc_seq_param(PARAM_OSD, obd->obd_vars,
+						  cfg, &o->od_dt_dev);
 		if (rc > 0 || rc == -ENOSYS)
-			rc = class_process_proc_param(PARAM_OST,
-						      lprocfs_osd_obd_vars,
-						      cfg, &o->od_dt_dev);
+			rc = class_process_proc_seq_param(PARAM_OST,
+							  obd->obd_vars, cfg,
+							  &o->od_dt_dev);
 		break;
 	}
 	default:
@@ -911,7 +912,7 @@ int __init osd_init(void)
 
 	rc = class_register_type(&osd_obd_device_ops, NULL, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
-				lprocfs_osd_module_vars,
+				NULL,
 #endif
 				LUSTRE_OSD_ZFS_NAME, &osd_device_type);
 	if (rc)
diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h
index bc51cb1..77b118f 100644
--- a/lustre/osd-zfs/osd_internal.h
+++ b/lustre/osd-zfs/osd_internal.h
@@ -402,9 +402,6 @@ enum {
 };
 
 /* osd_lproc.c */
-extern struct lprocfs_vars lprocfs_osd_obd_vars[];
-extern struct lprocfs_vars lprocfs_osd_module_vars[];
-
 int osd_procfs_init(struct osd_device *osd, const char *name);
 int osd_procfs_fini(struct osd_device *osd);
 
diff --git a/lustre/osd-zfs/osd_lproc.c b/lustre/osd-zfs/osd_lproc.c
index 0854ce6..a7ce60d 100644
--- a/lustre/osd-zfs/osd_lproc.c
+++ b/lustre/osd-zfs/osd_lproc.c
@@ -107,27 +107,26 @@ out:
 	RETURN(result);
 }
 
-static int lprocfs_osd_rd_fstype(char *page, char **start, off_t off,
-				int count, int *eof, void *data)
+static int zfs_osd_fstype_seq_show(struct seq_file *m, void *data)
 {
-	return snprintf(page, count, "zfs\n");
+	return seq_printf(m, "zfs\n");
 }
+LPROC_SEQ_FOPS_RO(zfs_osd_fstype);
 
-static int lprocfs_osd_rd_mntdev(char *page, char **start, off_t off, int count,
-				int *eof, void *data)
+static int zfs_osd_mntdev_seq_show(struct seq_file *m, void *data)
 {
-	struct osd_device *osd = osd_dt_dev((struct dt_device *)data);
+	struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private);
 
 	LASSERT(osd != NULL);
-	*eof = 1;
-
-	return snprintf(page, count, "%s\n", osd->od_mntdev);
+	return seq_printf(m, "%s\n", osd->od_mntdev);
 }
+LPROC_SEQ_FOPS_RO(zfs_osd_mntdev);
 
-static int lprocfs_osd_wr_force_sync(struct file *file, const char *buffer,
-					unsigned long count, void *data)
+static ssize_t
+lprocfs_osd_force_sync_seq_write(struct file *file, const char *buffer,
+				size_t count, loff_t *off)
 {
-	struct dt_device  *dt = data;
+	struct dt_device  *dt = ((struct seq_file *)file->private_data)->private;
 	struct lu_env      env;
 	int rc;
 
@@ -139,20 +138,21 @@ static int lprocfs_osd_wr_force_sync(struct file *file, const char *buffer,
 
 	return rc == 0 ? count : rc;
 }
+LPROC_SEQ_FOPS_WO_TYPE(zfs, osd_force_sync);
 
-static int lprocfs_osd_rd_iused_est(char *page, char **start, off_t off, int count,
-					int *eof, void *data)
+static int zfs_osd_iused_est_seq_show(struct seq_file *m, void *data)
 {
-	struct osd_device *osd = osd_dt_dev((struct dt_device *)data);
+	struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private);
 	LASSERT(osd != NULL);
 
-	return snprintf(page, count, "%d\n", osd->od_quota_iused_est);
+	return seq_printf(m, "%d\n", osd->od_quota_iused_est);
 }
 
-static int lprocfs_osd_wr_iused_est(struct file *file, const char *buffer,
-					unsigned long count, void *data)
+static ssize_t zfs_osd_iused_est_seq_write(struct file *file, const char *buffer,
+						size_t count, loff_t *off)
 {
-	struct osd_device *osd = osd_dt_dev((struct dt_device *)data);
+	struct dt_device  *dt = ((struct seq_file *)file->private_data)->private;
+	struct osd_device *osd = osd_dt_dev(dt);
 	int                rc, val;
 
 	LASSERT(osd != NULL);
@@ -165,24 +165,36 @@ static int lprocfs_osd_wr_iused_est(struct file *file, const char *buffer,
 
 	return count;
 }
-
-struct lprocfs_vars lprocfs_osd_obd_vars[] = {
-	{ "blocksize",		lprocfs_dt_rd_blksize,	0, 0 },
-	{ "kbytestotal",	lprocfs_dt_rd_kbytestotal,	0, 0 },
-	{ "kbytesfree",		lprocfs_dt_rd_kbytesfree,	0, 0 },
-	{ "kbytesavail",	lprocfs_dt_rd_kbytesavail,	0, 0 },
-	{ "filestotal",		lprocfs_dt_rd_filestotal,	0, 0 },
-	{ "filesfree",		lprocfs_dt_rd_filesfree,	0, 0 },
-	{ "fstype",          lprocfs_osd_rd_fstype,      0, 0 },
-	{ "mntdev",          lprocfs_osd_rd_mntdev,      0, 0 },
-	{ "force_sync",      0, lprocfs_osd_wr_force_sync     },
-	{ "quota_iused_estimate",  lprocfs_osd_rd_iused_est,
-		lprocfs_osd_wr_iused_est,   0, 0 },
-	{ 0 }
-};
-
-struct lprocfs_vars lprocfs_osd_module_vars[] = {
-	{ "num_refs",        lprocfs_rd_numrefs,         0, 0 },
+LPROC_SEQ_FOPS(zfs_osd_iused_est);
+
+LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_blksize);
+LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_kbytestotal);
+LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_kbytesfree);
+LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_kbytesavail);
+LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_filestotal);
+LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_filesfree);
+
+struct lprocfs_seq_vars lprocfs_osd_obd_vars[] = {
+	{ .name	=	"blocksize",
+	  .fops	=	&zfs_dt_blksize_fops		},
+	{ .name	=	"kbytestotal",
+	  .fops	=	&zfs_dt_kbytestotal_fops	},
+	{ .name	=	"kbytesfree",
+	  .fops	=	&zfs_dt_kbytesfree_fops		},
+	{ .name	=	"kbytesavail",
+	  .fops	=	&zfs_dt_kbytesavail_fops	},
+	{ .name	=	"filestotal",
+	  .fops	=	&zfs_dt_filestotal_fops		},
+	{ .name	=	"filesfree",
+	  .fops	=	&zfs_dt_filesfree_fops		},
+	{ .name	=	"fstype",
+	  .fops	=	&zfs_osd_fstype_fops		},
+	{ .name	=	"mntdev",
+	  .fops	=	&zfs_osd_mntdev_fops		},
+	{ .name	=	"force_sync",
+	  .fops	=	&zfs_osd_force_sync_fops	},
+	{ .name	=	"quota_iused_estimate",
+	  .fops	=	&zfs_osd_iused_est_fops		},
 	{ 0 }
 };
 
@@ -202,7 +214,7 @@ int osd_procfs_init(struct osd_device *osd, const char *name)
 	LASSERT(name != NULL);
 	LASSERT(type != NULL);
 
-	osd->od_proc_entry = lprocfs_register(name, type->typ_procroot,
+	osd->od_proc_entry = lprocfs_seq_register(name, type->typ_procroot,
 			lprocfs_osd_obd_vars, &osd->od_dt_dev);
 	if (IS_ERR(osd->od_proc_entry)) {
 		rc = PTR_ERR(osd->od_proc_entry);
-- 
1.8.5.3