.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* -*- mode: c; c-basic-offset: 8; -*- |
---|
2 | 3 | * vim: noexpandtab sw=8 ts=8 sts=0: |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * Checksum and ECC codes for the OCFS2 userspace library. |
---|
7 | 8 | * |
---|
8 | 9 | * 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. |
---|
18 | 10 | */ |
---|
19 | 11 | |
---|
20 | 12 | #include <linux/kernel.h> |
---|
.. | .. |
---|
132 | 124 | * parity bits that are part of the bit number |
---|
133 | 125 | * representation. Huh? |
---|
134 | 126 | * |
---|
135 | | - * <wikipedia href="http://en.wikipedia.org/wiki/Hamming_code"> |
---|
| 127 | + * <wikipedia href="https://en.wikipedia.org/wiki/Hamming_code"> |
---|
136 | 128 | * In other words, the parity bit at position 2^k |
---|
137 | 129 | * checks bits in positions having bit k set in |
---|
138 | 130 | * their binary representation. Conversely, for |
---|
.. | .. |
---|
239 | 231 | } |
---|
240 | 232 | DEFINE_SIMPLE_ATTRIBUTE(blockcheck_fops, blockcheck_u64_get, NULL, "%llu\n"); |
---|
241 | 233 | |
---|
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 | | - |
---|
250 | 234 | static void ocfs2_blockcheck_debug_remove(struct ocfs2_blockcheck_stats *stats) |
---|
251 | 235 | { |
---|
252 | 236 | 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); |
---|
260 | 238 | stats->b_debug_dir = NULL; |
---|
261 | 239 | } |
---|
262 | 240 | } |
---|
263 | 241 | |
---|
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) |
---|
266 | 244 | { |
---|
267 | | - int rc = -EINVAL; |
---|
| 245 | + struct dentry *dir; |
---|
268 | 246 | |
---|
269 | | - if (!stats) |
---|
270 | | - goto out; |
---|
| 247 | + dir = debugfs_create_dir("blockcheck", parent); |
---|
| 248 | + stats->b_debug_dir = dir; |
---|
271 | 249 | |
---|
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); |
---|
275 | 252 | |
---|
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); |
---|
280 | 255 | |
---|
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); |
---|
285 | 258 | |
---|
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; |
---|
298 | 259 | } |
---|
299 | 260 | #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) |
---|
302 | 263 | { |
---|
303 | | - return 0; |
---|
304 | 264 | } |
---|
305 | 265 | |
---|
306 | 266 | static inline void ocfs2_blockcheck_debug_remove(struct ocfs2_blockcheck_stats *stats) |
---|
.. | .. |
---|
309 | 269 | #endif /* CONFIG_DEBUG_FS */ |
---|
310 | 270 | |
---|
311 | 271 | /* 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) |
---|
314 | 274 | { |
---|
315 | | - return ocfs2_blockcheck_debug_install(stats, parent); |
---|
| 275 | + ocfs2_blockcheck_debug_install(stats, parent); |
---|
316 | 276 | } |
---|
317 | 277 | |
---|
318 | 278 | void ocfs2_blockcheck_stats_debugfs_remove(struct ocfs2_blockcheck_stats *stats) |
---|