]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - fs/aufs/sysrq.c
x86/mm: Use WRITE_ONCE() when setting PTEs
[mirror_ubuntu-bionic-kernel.git] / fs / aufs / sysrq.c
CommitLineData
c088e31d
SF
1/*
2 * Copyright (C) 2005-2017 Junjiro R. Okajima
3 *
4 * This program, aufs is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * magic sysrq hanlder
20 */
21
22/* #include <linux/sysrq.h> */
23#include <linux/writeback.h>
24#include "aufs.h"
25
26/* ---------------------------------------------------------------------- */
27
28static void sysrq_sb(struct super_block *sb)
29{
30 char *plevel;
31 struct au_sbinfo *sbinfo;
32 struct file *file;
33 struct hlist_bl_head *files;
34 struct hlist_bl_node *pos;
35 struct au_finfo *finfo;
36
37 plevel = au_plevel;
38 au_plevel = KERN_WARNING;
39
40 /* since we define pr_fmt, call printk directly */
41#define pr(str) printk(KERN_WARNING AUFS_NAME ": " str)
42
43 sbinfo = au_sbi(sb);
44 printk(KERN_WARNING "si=%lx\n", sysaufs_si_id(sbinfo));
45 pr("superblock\n");
46 au_dpri_sb(sb);
47
48#if 0
49 pr("root dentry\n");
50 au_dpri_dentry(sb->s_root);
51 pr("root inode\n");
52 au_dpri_inode(d_inode(sb->s_root));
53#endif
54
55#if 0
56 do {
57 int err, i, j, ndentry;
58 struct au_dcsub_pages dpages;
59 struct au_dpage *dpage;
60
61 err = au_dpages_init(&dpages, GFP_ATOMIC);
62 if (unlikely(err))
63 break;
64 err = au_dcsub_pages(&dpages, sb->s_root, NULL, NULL);
65 if (!err)
66 for (i = 0; i < dpages.ndpage; i++) {
67 dpage = dpages.dpages + i;
68 ndentry = dpage->ndentry;
69 for (j = 0; j < ndentry; j++)
70 au_dpri_dentry(dpage->dentries[j]);
71 }
72 au_dpages_free(&dpages);
73 } while (0);
74#endif
75
76#if 1
77 {
78 struct inode *i;
79
80 pr("isolated inode\n");
81 spin_lock(&sb->s_inode_list_lock);
82 list_for_each_entry(i, &sb->s_inodes, i_sb_list) {
83 spin_lock(&i->i_lock);
84 if (1 || hlist_empty(&i->i_dentry))
85 au_dpri_inode(i);
86 spin_unlock(&i->i_lock);
87 }
88 spin_unlock(&sb->s_inode_list_lock);
89 }
90#endif
91 pr("files\n");
92 files = &au_sbi(sb)->si_files;
93 hlist_bl_lock(files);
94 hlist_bl_for_each_entry(finfo, pos, files, fi_hlist) {
95 umode_t mode;
96
97 file = finfo->fi_file;
98 mode = file_inode(file)->i_mode;
99 if (!special_file(mode))
100 au_dpri_file(file);
101 }
102 hlist_bl_unlock(files);
103 pr("done\n");
104
105#undef pr
106 au_plevel = plevel;
107}
108
109/* ---------------------------------------------------------------------- */
110
111/* module parameter */
112static char *aufs_sysrq_key = "a";
113module_param_named(sysrq, aufs_sysrq_key, charp, S_IRUGO);
114MODULE_PARM_DESC(sysrq, "MagicSysRq key for " AUFS_NAME);
115
116static void au_sysrq(int key __maybe_unused)
117{
118 struct au_sbinfo *sbinfo;
119 struct hlist_bl_node *pos;
120
121 lockdep_off();
122 au_sbilist_lock();
123 hlist_bl_for_each_entry(sbinfo, pos, &au_sbilist, si_list)
124 sysrq_sb(sbinfo->si_sb);
125 au_sbilist_unlock();
126 lockdep_on();
127}
128
129static struct sysrq_key_op au_sysrq_op = {
130 .handler = au_sysrq,
131 .help_msg = "Aufs",
132 .action_msg = "Aufs",
133 .enable_mask = SYSRQ_ENABLE_DUMP
134};
135
136/* ---------------------------------------------------------------------- */
137
138int __init au_sysrq_init(void)
139{
140 int err;
141 char key;
142
143 err = -1;
144 key = *aufs_sysrq_key;
145 if ('a' <= key && key <= 'z')
146 err = register_sysrq_key(key, &au_sysrq_op);
147 if (unlikely(err))
148 pr_err("err %d, sysrq=%c\n", err, key);
149 return err;
150}
151
152void au_sysrq_fin(void)
153{
154 int err;
155
156 err = unregister_sysrq_key(*aufs_sysrq_key, &au_sysrq_op);
157 if (unlikely(err))
158 pr_err("err %d (ignored)\n", err);
159}