sysfs.c (bb272221e9db79f13d454e1f3fb6b05013be985e) sysfs.c (dc6b20551044a05cd4d8ad2356a6bd888570f52a)
1/*
2 * f2fs sysfs interface
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 * Copyright (c) 2017 Chao Yu <chao@kernel.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <linux/proc_fs.h>
13#include <linux/f2fs_fs.h>
1/*
2 * f2fs sysfs interface
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 * Copyright (c) 2017 Chao Yu <chao@kernel.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <linux/proc_fs.h>
13#include <linux/f2fs_fs.h>
14#include <linux/seq_file.h>
14
15#include "f2fs.h"
16#include "segment.h"
17#include "gc.h"
18
19static struct proc_dir_entry *f2fs_proc_root;
20static struct kset *f2fs_kset;
21

--- 276 unchanged lines hidden (view full) ---

298 .read = seq_read, \
299 .llseek = seq_lseek, \
300 .release = single_release, \
301};
302
303F2FS_PROC_FILE_DEF(segment_info);
304F2FS_PROC_FILE_DEF(segment_bits);
305
15
16#include "f2fs.h"
17#include "segment.h"
18#include "gc.h"
19
20static struct proc_dir_entry *f2fs_proc_root;
21static struct kset *f2fs_kset;
22

--- 276 unchanged lines hidden (view full) ---

299 .read = seq_read, \
300 .llseek = seq_lseek, \
301 .release = single_release, \
302};
303
304F2FS_PROC_FILE_DEF(segment_info);
305F2FS_PROC_FILE_DEF(segment_bits);
306
306int __init f2fs_register_sysfs(void)
307int __init f2fs_init_sysfs(void)
307{
308 f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
309
310 f2fs_kset = kset_create_and_add("f2fs", NULL, fs_kobj);
311 if (!f2fs_kset)
312 return -ENOMEM;
313 return 0;
314}
315
308{
309 f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
310
311 f2fs_kset = kset_create_and_add("f2fs", NULL, fs_kobj);
312 if (!f2fs_kset)
313 return -ENOMEM;
314 return 0;
315}
316
316void f2fs_unregister_sysfs(void)
317void f2fs_exit_sysfs(void)
317{
318 kset_unregister(f2fs_kset);
319 remove_proc_entry("fs/f2fs", NULL);
320}
321
318{
319 kset_unregister(f2fs_kset);
320 remove_proc_entry("fs/f2fs", NULL);
321}
322
322int f2fs_init_sysfs(struct f2fs_sb_info *sbi)
323int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
323{
324 struct super_block *sb = sbi->sb;
325 int err;
326
327 if (f2fs_proc_root)
328 sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root);
329
330 if (sbi->s_proc) {

--- 14 unchanged lines hidden (view full) ---

345 if (sbi->s_proc) {
346 remove_proc_entry("segment_info", sbi->s_proc);
347 remove_proc_entry("segment_bits", sbi->s_proc);
348 remove_proc_entry(sb->s_id, f2fs_proc_root);
349 }
350 return err;
351}
352
324{
325 struct super_block *sb = sbi->sb;
326 int err;
327
328 if (f2fs_proc_root)
329 sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root);
330
331 if (sbi->s_proc) {

--- 14 unchanged lines hidden (view full) ---

346 if (sbi->s_proc) {
347 remove_proc_entry("segment_info", sbi->s_proc);
348 remove_proc_entry("segment_bits", sbi->s_proc);
349 remove_proc_entry(sb->s_id, f2fs_proc_root);
350 }
351 return err;
352}
353
353void f2fs_exit_sysfs(struct f2fs_sb_info *sbi)
354void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
354{
355 kobject_del(&sbi->s_kobj);
356 kobject_put(&sbi->s_kobj);
357 wait_for_completion(&sbi->s_kobj_unregister);
358
359 if (sbi->s_proc) {
360 remove_proc_entry("segment_info", sbi->s_proc);
361 remove_proc_entry("segment_bits", sbi->s_proc);
362 remove_proc_entry(sbi->sb->s_id, f2fs_proc_root);
363 }
364}
355{
356 kobject_del(&sbi->s_kobj);
357 kobject_put(&sbi->s_kobj);
358 wait_for_completion(&sbi->s_kobj_unregister);
359
360 if (sbi->s_proc) {
361 remove_proc_entry("segment_info", sbi->s_proc);
362 remove_proc_entry("segment_bits", sbi->s_proc);
363 remove_proc_entry(sbi->sb->s_id, f2fs_proc_root);
364 }
365}