2 * Copyright (C) 2005-2012 Junjiro R. Okajima
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.
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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 /* #include <linux/sysrq.h> */
24 #include <linux/writeback.h>
27 /* ---------------------------------------------------------------------- */
29 static void sysrq_sb(struct super_block *sb)
32 struct au_sbinfo *sbinfo;
36 au_plevel = KERN_WARNING;
39 /* since we define pr_fmt, call printk directly */
40 printk(KERN_WARNING "si=%lx\n", sysaufs_si_id(sbinfo));
41 printk(KERN_WARNING AUFS_NAME ": superblock\n");
45 printk(KERN_WARNING AUFS_NAME ": root dentry\n");
46 au_dpri_dentry(sb->s_root);
47 printk(KERN_WARNING AUFS_NAME ": root inode\n");
48 au_dpri_inode(sb->s_root->d_inode);
53 int err, i, j, ndentry;
54 struct au_dcsub_pages dpages;
55 struct au_dpage *dpage;
57 err = au_dpages_init(&dpages, GFP_ATOMIC);
60 err = au_dcsub_pages(&dpages, sb->s_root, NULL, NULL);
62 for (i = 0; i < dpages.ndpage; i++) {
63 dpage = dpages.dpages + i;
64 ndentry = dpage->ndentry;
65 for (j = 0; j < ndentry; j++)
66 au_dpri_dentry(dpage->dentries[j]);
68 au_dpages_free(&dpages);
75 printk(KERN_WARNING AUFS_NAME ": isolated inode\n");
76 spin_lock(&inode_sb_list_lock);
77 list_for_each_entry(i, &sb->s_inodes, i_sb_list) {
78 spin_lock(&i->i_lock);
79 if (1 || list_empty(&i->i_dentry))
81 spin_unlock(&i->i_lock);
83 spin_unlock(&inode_sb_list_lock);
86 printk(KERN_WARNING AUFS_NAME ": files\n");
87 lg_global_lock(files_lglock);
88 do_file_list_for_each_entry(sb, file) {
90 mode = file->f_dentry->d_inode->i_mode;
91 if (!special_file(mode) || au_special_file(mode))
93 } while_file_list_for_each_entry;
94 lg_global_unlock(files_lglock);
95 printk(KERN_WARNING AUFS_NAME ": done\n");
100 /* ---------------------------------------------------------------------- */
102 /* module parameter */
103 static char *aufs_sysrq_key = "a";
104 module_param_named(sysrq, aufs_sysrq_key, charp, S_IRUGO);
105 MODULE_PARM_DESC(sysrq, "MagicSysRq key for " AUFS_NAME);
107 static void au_sysrq(int key __maybe_unused)
109 struct au_sbinfo *sbinfo;
113 list_for_each_entry(sbinfo, &au_sbilist.head, si_list)
114 sysrq_sb(sbinfo->si_sb);
119 static struct sysrq_key_op au_sysrq_op = {
122 .action_msg = "Aufs",
123 .enable_mask = SYSRQ_ENABLE_DUMP
126 /* ---------------------------------------------------------------------- */
128 int __init au_sysrq_init(void)
134 key = *aufs_sysrq_key;
135 if ('a' <= key && key <= 'z')
136 err = register_sysrq_key(key, &au_sysrq_op);
138 pr_err("err %d, sysrq=%c\n", err, key);
142 void au_sysrq_fin(void)
145 err = unregister_sysrq_key(*aufs_sysrq_key, &au_sysrq_op);
147 pr_err("err %d (ignored)\n", err);