aboutsummaryrefslogtreecommitdiff
blob: fe32411428900035968fc6637a984a68fa9e7c69 (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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
From b262846027fbf96a5a80b81cfe86da53ce6e6f9f Mon Sep 17 00:00:00 2001
From: James Simmons <uja.ornl@gmail.com>
Date: Fri, 3 Jan 2014 09:58:53 -0500
Subject: [PATCH 04/13] LU-3319 procfs: move mgs proc handling to seq_files

With 3.10 linux kernel and above proc handling now only
uses struct seq_files. This patch migrates the mgs
layer proc entries over to using seq_files.

Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: I1a12dd9b1fc8f139116a8f3a684956a5ba88f055
---
 lustre/mgs/lproc_mgs.c    | 202 +++++++++++++++++++++++-----------------------
 lustre/mgs/mgs_handler.c  |   5 +-
 lustre/mgs/mgs_internal.h |  13 +--
 lustre/mgs/mgs_nids.c     |  11 ++-
 4 files changed, 110 insertions(+), 121 deletions(-)

diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c
index ffa2d0d..f0ea956 100644
--- a/lustre/mgs/lproc_mgs.c
+++ b/lustre/mgs/lproc_mgs.c
@@ -126,19 +126,110 @@ static int mgsself_srpc_seq_show(struct seq_file *seq, void *v)
 
         return 0;
 }
-
 LPROC_SEQ_FOPS_RO(mgsself_srpc);
 
+static int mgs_live_seq_show(struct seq_file *seq, void *v)
+{
+	struct fs_db             *fsdb = seq->private;
+	struct mgs_tgt_srpc_conf *srpc_tgt;
+	int i;
+
+	mutex_lock(&fsdb->fsdb_mutex);
+
+	seq_printf(seq, "fsname: %s\n", fsdb->fsdb_name);
+	seq_printf(seq, "flags: %#lx     gen: %d\n",
+		   fsdb->fsdb_flags, fsdb->fsdb_gen);
+	for (i = 0; i < INDEX_MAP_SIZE * 8; i++)
+		if (test_bit(i, fsdb->fsdb_mdt_index_map))
+			 seq_printf(seq, "%s-MDT%04x\n", fsdb->fsdb_name, i);
+	for (i = 0; i < INDEX_MAP_SIZE * 8; i++)
+		if (test_bit(i, fsdb->fsdb_ost_index_map))
+			 seq_printf(seq, "%s-OST%04x\n", fsdb->fsdb_name, i);
+
+	seq_printf(seq, "\nSecure RPC Config Rules:\n");
+#if 0
+	seq_printf(seq, "%s.%s=%s\n", fsdb->fsdb_name,
+		   PARAM_SRPC_UDESC, fsdb->fsdb_srpc_fl_udesc ? "yes" : "no");
+#endif
+	for (srpc_tgt = fsdb->fsdb_srpc_tgt; srpc_tgt;
+	     srpc_tgt = srpc_tgt->mtsc_next) {
+		seq_show_srpc_rules(seq, srpc_tgt->mtsc_tgt,
+				    &srpc_tgt->mtsc_rset);
+	}
+	seq_show_srpc_rules(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen);
+
+	lprocfs_rd_ir_state(seq, fsdb);
+
+	mutex_unlock(&fsdb->fsdb_mutex);
+	return 0;
+}
+
+static ssize_t mgs_live_seq_write(struct file *file, const char *buf,
+				  size_t len, loff_t *off)
+{
+	struct seq_file *seq  = file->private_data;
+	struct fs_db    *fsdb = seq->private;
+	ssize_t rc;
+
+	rc = lprocfs_wr_ir_state(file, buf, len, fsdb);
+	if (rc >= 0)
+		rc = len;
+	return rc;
+}
+LPROC_SEQ_FOPS(mgs_live);
+
+int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb)
+{
+	int rc;
+
+	if (!mgs->mgs_proc_live)
+		return 0;
+	rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0644,
+				&mgs_live_fops, fsdb);
+
+	return 0;
+}
+
+int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb)
+{
+	if (!mgs->mgs_proc_live)
+		return 0;
+
+	/* didn't create the proc file for MGSSELF_NAME */
+	if (!test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags))
+		lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live);
+	return 0;
+}
+
+LPROC_SEQ_FOPS_RO_TYPE(mgs, uuid);
+LPROC_SEQ_FOPS_RO_TYPE(mgs, num_exports);
+LPROC_SEQ_FOPS_RO_TYPE(mgs, hash);
+LPROC_SEQ_FOPS_WO_TYPE(mgs, evict_client);
+LPROC_SEQ_FOPS_RW_TYPE(mgs, ir_timeout);
+
+struct lprocfs_seq_vars lprocfs_mgs_obd_vars[] = {
+	{ .name	=	"uuid",
+	  .fops	=	&mgs_uuid_fops		},
+	{ .name	=	"num_exports",
+	  .fops	=	&mgs_num_exports_fops	},
+	{ .name	=	"hash_stats",
+	  .fops	=	&mgs_hash_fops		},
+	{ .name	=	"evict_client",
+	  .fops	=	&mgs_evict_client_fops	},
+	{ .name	=	"ir_timeout",
+	  .fops	=	&mgs_ir_timeout_fops	},
+	{ 0 }
+};
+
 int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name)
 {
 	struct obd_device *obd = mgs->mgs_obd;
 	struct obd_device *osd_obd = mgs->mgs_bottom->dd_lu_dev.ld_obd;
 	int		   osd_len = strlen(osd_name) - strlen("-osd");
 	int		   rc;
-	struct lprocfs_static_vars lvars;
 
-	lprocfs_mgs_init_vars(&lvars);
-	rc = lprocfs_obd_setup(obd, lvars.obd_vars);
+	obd->obd_vars = lprocfs_mgs_obd_vars;
+	rc = lprocfs_seq_obd_setup(obd);
 	if (rc != 0)
 		GOTO(out, rc);
 
@@ -152,17 +243,17 @@ int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name)
 	if (rc != 0)
 		GOTO(out, rc);
 
-        mgs->mgs_proc_live = lprocfs_register("live", obd->obd_proc_entry,
-                                              NULL, NULL);
+	mgs->mgs_proc_live = lprocfs_seq_register("live", obd->obd_proc_entry,
+						  NULL, NULL);
         if (IS_ERR(mgs->mgs_proc_live)) {
                 rc = PTR_ERR(mgs->mgs_proc_live);
                 mgs->mgs_proc_live = NULL;
 		GOTO(out, rc);
         }
 
-        obd->obd_proc_exports_entry = lprocfs_register("exports",
-                                                       obd->obd_proc_entry,
-                                                       NULL, NULL);
+	obd->obd_proc_exports_entry = lprocfs_seq_register("exports",
+							   obd->obd_proc_entry,
+							   NULL, NULL);
         if (IS_ERR(obd->obd_proc_exports_entry)) {
                 rc = PTR_ERR(obd->obd_proc_exports_entry);
                 obd->obd_proc_exports_entry = NULL;
@@ -215,7 +306,6 @@ void lproc_mgs_cleanup(struct mgs_device *mgs)
 
 	if (mgs->mgs_proc_live != NULL) {
 		/* Should be no live entries */
-		LASSERT(mgs->mgs_proc_live->subdir == NULL);
 		lprocfs_remove(&mgs->mgs_proc_live);
 		mgs->mgs_proc_live = NULL;
 	}
@@ -226,92 +316,6 @@ void lproc_mgs_cleanup(struct mgs_device *mgs)
         lprocfs_free_md_stats(obd);
 }
 
-static int mgs_live_seq_show(struct seq_file *seq, void *v)
-{
-        struct fs_db             *fsdb = seq->private;
-        struct mgs_tgt_srpc_conf *srpc_tgt;
-        int i;
-
-	mutex_lock(&fsdb->fsdb_mutex);
-
-        seq_printf(seq, "fsname: %s\n", fsdb->fsdb_name);
-        seq_printf(seq, "flags: %#lx     gen: %d\n",
-                   fsdb->fsdb_flags, fsdb->fsdb_gen);
-        for (i = 0; i < INDEX_MAP_SIZE * 8; i++)
-		if (test_bit(i, fsdb->fsdb_mdt_index_map))
-                         seq_printf(seq, "%s-MDT%04x\n", fsdb->fsdb_name, i);
-        for (i = 0; i < INDEX_MAP_SIZE * 8; i++)
-		if (test_bit(i, fsdb->fsdb_ost_index_map))
-                         seq_printf(seq, "%s-OST%04x\n", fsdb->fsdb_name, i);
-
-        seq_printf(seq, "\nSecure RPC Config Rules:\n");
-#if 0
-        seq_printf(seq, "%s.%s=%s\n", fsdb->fsdb_name,
-                   PARAM_SRPC_UDESC, fsdb->fsdb_srpc_fl_udesc ? "yes" : "no");
-#endif
-        for (srpc_tgt = fsdb->fsdb_srpc_tgt; srpc_tgt;
-             srpc_tgt = srpc_tgt->mtsc_next) {
-                seq_show_srpc_rules(seq, srpc_tgt->mtsc_tgt,
-                                    &srpc_tgt->mtsc_rset);
-        }
-        seq_show_srpc_rules(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen);
-
-        lprocfs_rd_ir_state(seq, fsdb);
-
-	mutex_unlock(&fsdb->fsdb_mutex);
-        return 0;
-}
-
-static ssize_t mgs_live_seq_write(struct file *file, const char *buf,
-                                  size_t len, loff_t *off)
-{
-        struct seq_file *seq  = file->private_data;
-        struct fs_db    *fsdb = seq->private;
-        ssize_t rc;
-
-        rc = lprocfs_wr_ir_state(file, buf, len, fsdb);
-        if (rc >= 0)
-                rc = len;
-        return rc;
-}
-LPROC_SEQ_FOPS(mgs_live);
-
-int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb)
-{
-        int rc;
-
-        if (!mgs->mgs_proc_live)
-                return 0;
-	rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0644,
-				&mgs_live_fops, fsdb);
-
-        return 0;
-}
-
-int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb)
-{
-        if (!mgs->mgs_proc_live)
-                return 0;
-
-	/* didn't create the proc file for MGSSELF_NAME */
-	if (!test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags))
-		lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live);
-        return 0;
-}
-
-struct lprocfs_vars lprocfs_mgs_obd_vars[] = {
-        { "uuid",            lprocfs_rd_uuid,        0, 0 },
-        { "num_exports",     lprocfs_rd_num_exports, 0, 0 },
-        { "hash_stats",      lprocfs_obd_rd_hash,    0, 0 },
-        { "evict_client",    0, lprocfs_wr_evict_client, 0 },
-        { "ir_timeout",      lprocfs_rd_ir_timeout, lprocfs_wr_ir_timeout, 0 },
-        { 0 }
-};
-
-struct lprocfs_vars lprocfs_mgs_module_vars[] = {
-        { 0 }
-};
-
 void mgs_counter_incr(struct obd_export *exp, int opcode)
 {
         lprocfs_counter_incr(exp->exp_obd->obd_stats, opcode);
@@ -329,10 +333,4 @@ void mgs_stats_counter_init(struct lprocfs_stats *stats)
         lprocfs_counter_init(stats, LPROC_MGS_TARGET_REG, 0, "tgtreg", "reqs");
         lprocfs_counter_init(stats, LPROC_MGS_TARGET_DEL, 0, "tgtdel", "reqs");
 }
-
-void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars)
-{
-    lvars->module_vars  = lprocfs_mgs_module_vars;
-    lvars->obd_vars     = lprocfs_mgs_obd_vars;
-}
 #endif
diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c
index 5be9040..4bb842c 100644
--- a/lustre/mgs/mgs_handler.c
+++ b/lustre/mgs/mgs_handler.c
@@ -1434,12 +1434,9 @@ static struct obd_ops mgs_obd_device_ops = {
 
 static int __init mgs_init(void)
 {
-	struct lprocfs_static_vars lvars;
-
-	lprocfs_mgs_init_vars(&lvars);
 	return class_register_type(&mgs_obd_device_ops, NULL, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
-					lvars.module_vars,
+					NULL,
 #endif
 					LUSTRE_MGS_NAME, &mgs_device_type);
 }
diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h
index ca2846e..d3baacd 100644
--- a/lustre/mgs/mgs_internal.h
+++ b/lustre/mgs/mgs_internal.h
@@ -229,10 +229,10 @@ int  mgs_get_ir_logs(struct ptlrpc_request *req);
 int  lprocfs_wr_ir_state(struct file *file, const char *buffer,
                            unsigned long count, void *data);
 int  lprocfs_rd_ir_state(struct seq_file *seq, void *data);
-int  lprocfs_wr_ir_timeout(struct file *file, const char *buffer,
-                           unsigned long count, void *data);
-int  lprocfs_rd_ir_timeout(char *page, char **start, off_t off, int count,
-                           int *eof, void *data);
+ssize_t
+lprocfs_ir_timeout_seq_write(struct file *file, const char *buffer,
+			     size_t count, loff_t *off);
+int  lprocfs_ir_timeout_seq_show(struct seq_file *seq, void *data);
 void mgs_fsc_cleanup(struct obd_export *exp);
 void mgs_fsc_cleanup_by_fsdb(struct fs_db *fsdb);
 int  mgs_fsc_attach(const struct lu_env *env, struct obd_export *exp,
@@ -250,7 +250,6 @@ int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name);
 void lproc_mgs_cleanup(struct mgs_device *mgs);
 int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb);
 int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb);
-void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars);
 #else
 static inline int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name)
 {return 0;}
@@ -260,10 +259,6 @@ static inline int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb)
 {return 0;}
 static inline int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb)
 {return 0;}
-static void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars)
-{
-        memset(lvars, 0, sizeof(*lvars));
-}
 #endif
 
 /* mgs/lproc_mgs.c */
diff --git a/lustre/mgs/mgs_nids.c b/lustre/mgs/mgs_nids.c
index a2bae59..3248387 100644
--- a/lustre/mgs/mgs_nids.c
+++ b/lustre/mgs/mgs_nids.c
@@ -838,15 +838,14 @@ int lprocfs_rd_ir_state(struct seq_file *seq, void *data)
         return 0;
 }
 
-int lprocfs_rd_ir_timeout(char *page, char **start, off_t off, int count,
-                          int *eof, void *data)
+int lprocfs_ir_timeout_seq_show(struct seq_file *m, void *data)
 {
-        *eof = 1;
-        return snprintf(page, count, "%d\n", ir_timeout);
+	return lprocfs_uint_seq_show(m, &ir_timeout);
 }
 
-int lprocfs_wr_ir_timeout(struct file *file, const char *buffer,
-                          unsigned long count, void *data)
+ssize_t
+lprocfs_ir_timeout_seq_write(struct file *file, const char *buffer,
+			     size_t count, loff_t *off)
 {
         return lprocfs_wr_uint(file, buffer, count, &ir_timeout);
 }
-- 
1.8.5.3