aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/f2fs/f2fs.h1
-rw-r--r--fs/f2fs/super.c46
2 files changed, 47 insertions, 0 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 467d42d65c48..c7620b973073 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -350,6 +350,7 @@ enum page_type {
350 350
351struct f2fs_sb_info { 351struct f2fs_sb_info {
352 struct super_block *sb; /* pointer to VFS super block */ 352 struct super_block *sb; /* pointer to VFS super block */
353 struct proc_dir_entry *s_proc; /* proc entry */
353 struct buffer_head *raw_super_buf; /* buffer head of raw sb */ 354 struct buffer_head *raw_super_buf; /* buffer head of raw sb */
354 struct f2fs_super_block *raw_super; /* raw super block pointer */ 355 struct f2fs_super_block *raw_super; /* raw super block pointer */
355 int s_dirty; /* dirty flag for checkpoint */ 356 int s_dirty; /* dirty flag for checkpoint */
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 75c7dc363e92..70dbb313a7ca 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -18,6 +18,7 @@
18#include <linux/parser.h> 18#include <linux/parser.h>
19#include <linux/mount.h> 19#include <linux/mount.h>
20#include <linux/seq_file.h> 20#include <linux/seq_file.h>
21#include <linux/proc_fs.h>
21#include <linux/random.h> 22#include <linux/random.h>
22#include <linux/exportfs.h> 23#include <linux/exportfs.h>
23#include <linux/blkdev.h> 24#include <linux/blkdev.h>
@@ -31,6 +32,7 @@
31#define CREATE_TRACE_POINTS 32#define CREATE_TRACE_POINTS
32#include <trace/events/f2fs.h> 33#include <trace/events/f2fs.h>
33 34
35static struct proc_dir_entry *f2fs_proc_root;
34static struct kmem_cache *f2fs_inode_cachep; 36static struct kmem_cache *f2fs_inode_cachep;
35 37
36enum { 38enum {
@@ -223,6 +225,11 @@ static void f2fs_put_super(struct super_block *sb)
223{ 225{
224 struct f2fs_sb_info *sbi = F2FS_SB(sb); 226 struct f2fs_sb_info *sbi = F2FS_SB(sb);
225 227
228 if (sbi->s_proc) {
229 remove_proc_entry("segment_info", sbi->s_proc);
230 remove_proc_entry(sb->s_id, f2fs_proc_root);
231 }
232
226 f2fs_destroy_stats(sbi); 233 f2fs_destroy_stats(sbi);
227 stop_gc_thread(sbi); 234 stop_gc_thread(sbi);
228 235
@@ -340,6 +347,36 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
340 return 0; 347 return 0;
341} 348}
342 349
350static int segment_info_seq_show(struct seq_file *seq, void *offset)
351{
352 struct super_block *sb = seq->private;
353 struct f2fs_sb_info *sbi = F2FS_SB(sb);
354 unsigned int total_segs = le32_to_cpu(sbi->raw_super->segment_count_main);
355 int i;
356
357 for (i = 0; i < total_segs; i++) {
358 seq_printf(seq, "%u", get_valid_blocks(sbi, i, 1));
359 if (i != 0 && (i % 10) == 0)
360 seq_puts(seq, "\n");
361 else
362 seq_puts(seq, " ");
363 }
364 return 0;
365}
366
367static int segment_info_open_fs(struct inode *inode, struct file *file)
368{
369 return single_open(file, segment_info_seq_show, PDE_DATA(inode));
370}
371
372static const struct file_operations f2fs_seq_segment_info_fops = {
373 .owner = THIS_MODULE,
374 .open = segment_info_open_fs,
375 .read = seq_read,
376 .llseek = seq_lseek,
377 .release = single_release,
378};
379
343static int f2fs_remount(struct super_block *sb, int *flags, char *data) 380static int f2fs_remount(struct super_block *sb, int *flags, char *data)
344{ 381{
345 struct f2fs_sb_info *sbi = F2FS_SB(sb); 382 struct f2fs_sb_info *sbi = F2FS_SB(sb);
@@ -766,6 +803,13 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
766 if (err) 803 if (err)
767 goto fail; 804 goto fail;
768 805
806 if (f2fs_proc_root)
807 sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root);
808
809 if (sbi->s_proc)
810 proc_create_data("segment_info", S_IRUGO, sbi->s_proc,
811 &f2fs_seq_segment_info_fops, sb);
812
769 if (test_opt(sbi, DISCARD)) { 813 if (test_opt(sbi, DISCARD)) {
770 struct request_queue *q = bdev_get_queue(sb->s_bdev); 814 struct request_queue *q = bdev_get_queue(sb->s_bdev);
771 if (!blk_queue_discard(q)) 815 if (!blk_queue_discard(q))
@@ -852,12 +896,14 @@ static int __init init_f2fs_fs(void)
852 if (err) 896 if (err)
853 goto fail; 897 goto fail;
854 f2fs_create_root_stats(); 898 f2fs_create_root_stats();
899 f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
855fail: 900fail:
856 return err; 901 return err;
857} 902}
858 903
859static void __exit exit_f2fs_fs(void) 904static void __exit exit_f2fs_fs(void)
860{ 905{
906 remove_proc_entry("fs/f2fs", NULL);
861 f2fs_destroy_root_stats(); 907 f2fs_destroy_root_stats();
862 unregister_filesystem(&f2fs_fs_type); 908 unregister_filesystem(&f2fs_fs_type);
863 destroy_checkpoint_caches(); 909 destroy_checkpoint_caches();