2 * Copyright (C) 2005-2013 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;
38 /* since we define pr_fmt, call printk directly */
39 #define pr(str) printk(KERN_WARNING AUFS_NAME ": " str)
42 printk(KERN_WARNING "si=%lx\n", sysaufs_si_id(sbinfo));
48 au_dpri_dentry(sb->s_root);
50 au_dpri_inode(sb->s_root->d_inode);
55 int err, i, j, ndentry;
56 struct au_dcsub_pages dpages;
57 struct au_dpage *dpage;
59 err = au_dpages_init(&dpages, GFP_ATOMIC);
62 err = au_dcsub_pages(&dpages, sb->s_root, NULL, NULL);
64 for (i = 0; i < dpages.ndpage; i++) {
65 dpage = dpages.dpages + i;
66 ndentry = dpage->ndentry;
67 for (j = 0; j < ndentry; j++)
68 au_dpri_dentry(dpage->dentries[j]);
70 au_dpages_free(&dpages);
77 pr("isolated inode\n");
78 spin_lock(&inode_sb_list_lock);
79 list_for_each_entry(i, &sb->s_inodes, i_sb_list) {
80 spin_lock(&i->i_lock);
81 if (1 || list_empty(&i->i_dentry))
83 spin_unlock(&i->i_lock);
85 spin_unlock(&inode_sb_list_lock);
89 lg_global_lock(files_lglock);
90 do_file_list_for_each_entry(sb, file) {
92 mode = file->f_dentry->d_inode->i_mode;
93 if (!special_file(mode) || au_special_file(mode))
95 } while_file_list_for_each_entry;
96 lg_global_unlock(files_lglock);
103 /* ---------------------------------------------------------------------- */
105 /* module parameter */
106 static char *aufs_sysrq_key = "a";
107 module_param_named(sysrq, aufs_sysrq_key, charp, S_IRUGO);
108 MODULE_PARM_DESC(sysrq, "MagicSysRq key for " AUFS_NAME);
110 static void au_sysrq(int key __maybe_unused)
112 struct au_sbinfo *sbinfo;
116 list_for_each_entry(sbinfo, &au_sbilist.head, si_list)
117 sysrq_sb(sbinfo->si_sb);
122 static struct sysrq_key_op au_sysrq_op = {
125 .action_msg = "Aufs",
126 .enable_mask = SYSRQ_ENABLE_DUMP
129 /* ---------------------------------------------------------------------- */
131 int __init au_sysrq_init(void)
137 key = *aufs_sysrq_key;
138 if ('a' <= key && key <= 'z')
139 err = register_sysrq_key(key, &au_sysrq_op);
141 pr_err("err %d, sysrq=%c\n", err, key);
145 void au_sysrq_fin(void)
148 err = unregister_sysrq_key(*aufs_sysrq_key, &au_sysrq_op);
150 pr_err("err %d (ignored)\n", err);