hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/fs/ocfs2/blockcheck.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* -*- mode: c; c-basic-offset: 8; -*-
23 * vim: noexpandtab sw=8 ts=8 sts=0:
34 *
....@@ -6,15 +7,6 @@
67 * Checksum and ECC codes for the OCFS2 userspace library.
78 *
89 * Copyright (C) 2006, 2008 Oracle. All rights reserved.
9
- *
10
- * This program is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU General Public
12
- * License, version 2, as published by the Free Software Foundation.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- * General Public License for more details.
1810 */
1911
2012 #include <linux/kernel.h>
....@@ -132,7 +124,7 @@
132124 * parity bits that are part of the bit number
133125 * representation. Huh?
134126 *
135
- * <wikipedia href="http://en.wikipedia.org/wiki/Hamming_code">
127
+ * <wikipedia href="https://en.wikipedia.org/wiki/Hamming_code">
136128 * In other words, the parity bit at position 2^k
137129 * checks bits in positions having bit k set in
138130 * their binary representation. Conversely, for
....@@ -239,68 +231,36 @@
239231 }
240232 DEFINE_SIMPLE_ATTRIBUTE(blockcheck_fops, blockcheck_u64_get, NULL, "%llu\n");
241233
242
-static struct dentry *blockcheck_debugfs_create(const char *name,
243
- struct dentry *parent,
244
- u64 *value)
245
-{
246
- return debugfs_create_file(name, S_IFREG | S_IRUSR, parent, value,
247
- &blockcheck_fops);
248
-}
249
-
250234 static void ocfs2_blockcheck_debug_remove(struct ocfs2_blockcheck_stats *stats)
251235 {
252236 if (stats) {
253
- debugfs_remove(stats->b_debug_check);
254
- stats->b_debug_check = NULL;
255
- debugfs_remove(stats->b_debug_failure);
256
- stats->b_debug_failure = NULL;
257
- debugfs_remove(stats->b_debug_recover);
258
- stats->b_debug_recover = NULL;
259
- debugfs_remove(stats->b_debug_dir);
237
+ debugfs_remove_recursive(stats->b_debug_dir);
260238 stats->b_debug_dir = NULL;
261239 }
262240 }
263241
264
-static int ocfs2_blockcheck_debug_install(struct ocfs2_blockcheck_stats *stats,
265
- struct dentry *parent)
242
+static void ocfs2_blockcheck_debug_install(struct ocfs2_blockcheck_stats *stats,
243
+ struct dentry *parent)
266244 {
267
- int rc = -EINVAL;
245
+ struct dentry *dir;
268246
269
- if (!stats)
270
- goto out;
247
+ dir = debugfs_create_dir("blockcheck", parent);
248
+ stats->b_debug_dir = dir;
271249
272
- stats->b_debug_dir = debugfs_create_dir("blockcheck", parent);
273
- if (!stats->b_debug_dir)
274
- goto out;
250
+ debugfs_create_file("blocks_checked", S_IFREG | S_IRUSR, dir,
251
+ &stats->b_check_count, &blockcheck_fops);
275252
276
- stats->b_debug_check =
277
- blockcheck_debugfs_create("blocks_checked",
278
- stats->b_debug_dir,
279
- &stats->b_check_count);
253
+ debugfs_create_file("checksums_failed", S_IFREG | S_IRUSR, dir,
254
+ &stats->b_failure_count, &blockcheck_fops);
280255
281
- stats->b_debug_failure =
282
- blockcheck_debugfs_create("checksums_failed",
283
- stats->b_debug_dir,
284
- &stats->b_failure_count);
256
+ debugfs_create_file("ecc_recoveries", S_IFREG | S_IRUSR, dir,
257
+ &stats->b_recover_count, &blockcheck_fops);
285258
286
- stats->b_debug_recover =
287
- blockcheck_debugfs_create("ecc_recoveries",
288
- stats->b_debug_dir,
289
- &stats->b_recover_count);
290
- if (stats->b_debug_check && stats->b_debug_failure &&
291
- stats->b_debug_recover)
292
- rc = 0;
293
-
294
-out:
295
- if (rc)
296
- ocfs2_blockcheck_debug_remove(stats);
297
- return rc;
298259 }
299260 #else
300
-static inline int ocfs2_blockcheck_debug_install(struct ocfs2_blockcheck_stats *stats,
301
- struct dentry *parent)
261
+static inline void ocfs2_blockcheck_debug_install(struct ocfs2_blockcheck_stats *stats,
262
+ struct dentry *parent)
302263 {
303
- return 0;
304264 }
305265
306266 static inline void ocfs2_blockcheck_debug_remove(struct ocfs2_blockcheck_stats *stats)
....@@ -309,10 +269,10 @@
309269 #endif /* CONFIG_DEBUG_FS */
310270
311271 /* Always-called wrappers for starting and stopping the debugfs files */
312
-int ocfs2_blockcheck_stats_debugfs_install(struct ocfs2_blockcheck_stats *stats,
313
- struct dentry *parent)
272
+void ocfs2_blockcheck_stats_debugfs_install(struct ocfs2_blockcheck_stats *stats,
273
+ struct dentry *parent)
314274 {
315
- return ocfs2_blockcheck_debug_install(stats, parent);
275
+ ocfs2_blockcheck_debug_install(stats, parent);
316276 }
317277
318278 void ocfs2_blockcheck_stats_debugfs_remove(struct ocfs2_blockcheck_stats *stats)