Add ext4-printk-throttling patch
[ext4-patch-queue.git] / ext4_fix_printk_checkpatch_issues
blob7a548622cf10de0e7204e5aa4345e3d6ac666451
1 ext4: Add printk priority levels to clean up checkpatch warnings
3 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
5 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
6 index b6cea59..07d0850 100644
7 --- a/fs/ext4/balloc.c
8 +++ b/fs/ext4/balloc.c
9 @@ -379,26 +379,28 @@ restart:
10         bad = 0;
11         prev = NULL;
13 -       printk("Block Allocation Reservation Windows Map (%s):\n", fn);
14 +       printk(KERN_DEBUG "Block Allocation Reservation "
15 +              "Windows Map (%s):\n", fn);
16         while (n) {
17                 rsv = rb_entry(n, struct ext4_reserve_window_node, rsv_node);
18                 if (verbose)
19 -                       printk("reservation window 0x%p "
20 +                       printk(KERN_DEBUG "reservation window 0x%p "
21                                "start:  %llu, end:  %llu\n",
22                                rsv, rsv->rsv_start, rsv->rsv_end);
23                 if (rsv->rsv_start && rsv->rsv_start >= rsv->rsv_end) {
24 -                       printk("Bad reservation %p (start >= end)\n",
25 +                       printk(KERN_DEBUG "Bad reservation %p (start >= end)\n",
26                                rsv);
27                         bad = 1;
28                 }
29                 if (prev && prev->rsv_end >= rsv->rsv_start) {
30 -                       printk("Bad reservation %p (prev->end >= start)\n",
31 -                              rsv);
32 +                       printk(KERN_DEBUG "Bad reservation %p "
33 +                              "(prev->end >= start)\n", rsv);
34                         bad = 1;
35                 }
36                 if (bad) {
37                         if (!verbose) {
38 -                               printk("Restarting reservation walk in verbose mode\n");
39 +                               printk(KERN_DEBUG "Restarting reservation "
40 +                                      "walk in verbose mode\n");
41                                 verbose = 1;
42                                 goto restart;
43                         }
44 @@ -406,7 +408,7 @@ restart:
45                 n = rb_next(n);
46                 prev = rsv;
47         }
48 -       printk("Window map complete.\n");
49 +       printk(KERN_DEBUG "Window map complete.\n");
50         BUG_ON(bad);
51  }
52  #define rsv_window_dump(root, verbose) \
53 @@ -1745,7 +1747,7 @@ ext4_fsblk_t ext4_old_new_blocks(handle_t *handle, struct inode *inode,
54         sb = inode->i_sb;
55         if (!sb) {
56                 *errp = -ENODEV;
57 -               printk("ext4_new_block: nonexistent device");
58 +               printk(KERN_ERR "ext4_new_block: nonexistent superblock");
59                 return 0;
60         }
62 @@ -1932,8 +1934,8 @@ allocated:
63                 for (i = 0; i < num; i++) {
64                         if (ext4_test_bit(grp_alloc_blk+i,
65                                         bh2jh(bitmap_bh)->b_committed_data)) {
66 -                               printk("%s: block was unexpectedly set in "
67 -                                       "b_committed_data\n", __func__);
68 +                               printk(KERN_ERR "%s: block was unexpectedly "
69 +                                      "set in b_committed_data\n", __func__);
70                         }
71                 }
72         }
73 @@ -2144,10 +2146,9 @@ ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb)
74                 bitmap_count += x;
75         }
76         brelse(bitmap_bh);
77 -       printk("ext4_count_free_blocks: stored = %llu"
78 -               ", computed = %llu, %llu\n",
79 -               ext4_free_blocks_count(es),
80 -               desc_count, bitmap_count);
81 +       printk(KERN_DEBUG "ext4_count_free_blocks: stored = %llu"
82 +               ", computed = %llu, %llu\n", ext4_free_blocks_count(es),
83 +              desc_count, bitmap_count);
84         return bitmap_count;
85  #else
86         desc_count = 0;
87 diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
88 index ec8e33b..ac873db 100644
89 --- a/fs/ext4/dir.c
90 +++ b/fs/ext4/dir.c
91 @@ -400,7 +400,8 @@ static int call_filldir(struct file * filp, void * dirent,
92         sb = inode->i_sb;
94         if (!fname) {
95 -               printk("call_filldir: called with null fname?!?\n");
96 +               printk(KERN_ERR "ext4: call_filldir: called with "
97 +                      "null fname?!?\n");
98                 return 0;
99         }
100         curr_pos = hash2pos(fname->hash, fname->minor_hash);
101 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
102 index f0317a9..8614194 100644
103 --- a/fs/ext4/extents.c
104 +++ b/fs/ext4/extents.c
105 @@ -447,9 +447,10 @@ ext4_ext_binsearch_idx(struct inode *inode,
106                 for (k = 0; k < le16_to_cpu(eh->eh_entries); k++, ix++) {
107                   if (k != 0 &&
108                       le32_to_cpu(ix->ei_block) <= le32_to_cpu(ix[-1].ei_block)) {
109 -                               printk("k=%d, ix=0x%p, first=0x%p\n", k,
110 -                                       ix, EXT_FIRST_INDEX(eh));
111 -                               printk("%u <= %u\n",
112 +                               printk(KERN_DEBUG "k=%d, ix=0x%p, "
113 +                                      "first=0x%p\n", k,
114 +                                      ix, EXT_FIRST_INDEX(eh));
115 +                               printk(KERN_DEBUG "%u <= %u\n",
116                                        le32_to_cpu(ix->ei_block),
117                                        le32_to_cpu(ix[-1].ei_block));
118                         }
119 @@ -2281,7 +2282,7 @@ void ext4_ext_init(struct super_block *sb)
120          */
122         if (test_opt(sb, EXTENTS)) {
123 -               printk("EXT4-fs: file extents enabled");
124 +               printk(KERN_INFO "EXT4-fs: file extents enabled");
125  #ifdef AGGRESSIVE_TEST
126                 printk(", aggressive tests");
127  #endif
128 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
129 index f344834..45c66a0 100644
130 --- a/fs/ext4/ialloc.c
131 +++ b/fs/ext4/ialloc.c
132 @@ -170,17 +170,18 @@ void ext4_free_inode (handle_t *handle, struct inode * inode)
133         ext4_group_t flex_group;
135         if (atomic_read(&inode->i_count) > 1) {
136 -               printk ("ext4_free_inode: inode has count=%d\n",
137 -                                       atomic_read(&inode->i_count));
138 +               printk(KERN_ERR "ext4_free_inode: inode has count=%d\n",
139 +                      atomic_read(&inode->i_count));
140                 return;
141         }
142         if (inode->i_nlink) {
143 -               printk ("ext4_free_inode: inode has nlink=%d\n",
144 -                       inode->i_nlink);
145 +               printk(KERN_ERR "ext4_free_inode: inode has nlink=%d\n",
146 +                      inode->i_nlink);
147                 return;
148         }
149         if (!sb) {
150 -               printk("ext4_free_inode: inode on nonexistent device\n");
151 +               printk(KERN_ERR "ext4_free_inode: inode on "
152 +                      "nonexistent device\n");
153                 return;
154         }
155         sbi = EXT4_SB(sb);
156 @@ -989,8 +990,9 @@ unsigned long ext4_count_free_inodes (struct super_block * sb)
157                 bitmap_count += x;
158         }
159         brelse(bitmap_bh);
160 -       printk("ext4_count_free_inodes: stored = %u, computed = %lu, %lu\n",
161 -               le32_to_cpu(es->s_free_inodes_count), desc_count, bitmap_count);
162 +       printk(KERN_DEBUG "ext4_count_free_inodes: "
163 +              "stored = %u, computed = %lu, %lu\n",
164 +              le32_to_cpu(es->s_free_inodes_count), desc_count, bitmap_count);
165         return desc_count;
166  #else
167         desc_count = 0;
168 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
169 index 395282b..2eda913 100644
170 --- a/fs/ext4/mballoc.c
171 +++ b/fs/ext4/mballoc.c
172 @@ -477,9 +477,10 @@ static void mb_cmp_bitmaps(struct ext4_buddy *e4b, void *bitmap)
173                 b2 = (unsigned char *) bitmap;
174                 for (i = 0; i < e4b->bd_sb->s_blocksize; i++) {
175                         if (b1[i] != b2[i]) {
176 -                               printk("corruption in group %lu at byte %u(%u):"
177 -                                      " %x in copy != %x on disk/prealloc\n",
178 -                                       e4b->bd_group, i, i * 8, b1[i], b2[i]);
179 +                               printk(KERN_ERR "corruption in group %lu "
180 +                                      "at byte %u(%u): %x in copy != %x "
181 +                                      "on disk/prealloc\n",
182 +                                      e4b->bd_group, i, i * 8, b1[i], b2[i]);
183                                 BUG();
184                         }
185                 }
186 @@ -2563,7 +2564,7 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
187         ext4_mb_init_per_dev_proc(sb);
188         ext4_mb_history_init(sb);
190 -       printk("EXT4-fs: mballoc enabled\n");
191 +       printk(KERN_INFO "EXT4-fs: mballoc enabled\n");
192         return 0;
195 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
196 index 387ad98..978b57f 100644
197 --- a/fs/ext4/namei.c
198 +++ b/fs/ext4/namei.c
199 @@ -254,12 +254,12 @@ static inline unsigned dx_node_limit (struct inode *dir)
200   * Debug
201   */
202  #ifdef DX_DEBUG
203 -static void dx_show_index (char * label, struct dx_entry *entries)
204 +static void dx_show_index(char * label, struct dx_entry *entries)
206         int i, n = dx_get_count (entries);
207 -       printk("%s index ", label);
208 +       printk(KERN_DEBUG "%s index ", label);
209         for (i = 0; i < n; i++) {
210 -               printk("%x->%lu ", i? dx_get_hash(entries + i) :
211 +               printk("%x->%lu ", i ? dx_get_hash(entries + i) :
212                                 0, (unsigned long)dx_get_block(entries + i));
213         }
214         printk("\n");
215 @@ -328,8 +328,9 @@ struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
216                 brelse (bh);
217         }
218         if (bcount)
219 -               printk("%snames %u, fullness %u (%u%%)\n", levels?"":"   ",
220 -                       names, space/bcount,(space/bcount)*100/blocksize);
221 +               printk(KERN_DEBUG "%snames %u, fullness %u (%u%%)\n", 
222 +                      levels ? "" : "   ", names, space/bcount,
223 +                      (space/bcount)*100/blocksize);
224         return (struct stats) { names, space, bcount};
226  #endif /* DX_DEBUG */
227 @@ -635,8 +636,8 @@ int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
228         int ret, err;
229         __u32 hashval;
231 -       dxtrace(printk("In htree_fill_tree, start hash: %x:%x\n", start_hash,
232 -                      start_minor_hash));
233 +       dxtrace(printk(KERN_DEBUG "In htree_fill_tree, start hash: %x:%x\n", 
234 +                      start_hash, start_minor_hash));
235         dir = dir_file->f_path.dentry->d_inode;
236         if (!(EXT4_I(dir)->i_flags & EXT4_INDEX_FL)) {
237                 hinfo.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
238 @@ -694,8 +695,8 @@ int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
239                         break;
240         }
241         dx_release(frames);
242 -       dxtrace(printk("Fill tree: returned %d entries, next hash: %x\n",
243 -                      count, *next_hash));
244 +       dxtrace(printk(KERN_DEBUG "Fill tree: returned %d entries, "
245 +                      "next hash: %x\n", count, *next_hash));
246         return count;
247  errout:
248         dx_release(frames);
249 @@ -882,7 +883,8 @@ static struct buffer_head * ext4_find_entry (struct dentry *dentry,
250                  */
251                 if (bh || (err != ERR_BAD_DX_DIR))
252                         return bh;
253 -               dxtrace(printk("ext4_find_entry: dx failed, falling back\n"));
254 +               dxtrace(printk(KERN_DEBUG "ext4_find_entry: dx failed, "
255 +                              "falling back\n"));
256         }
257         nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb);
258         start = EXT4_I(dir)->i_dir_start_lookup;
259 @@ -1025,7 +1027,7 @@ static struct buffer_head * ext4_dx_find_entry(struct dentry *dentry,
261         *err = -ENOENT;
262  errout:
263 -       dxtrace(printk("%s not found\n", name));
264 +       dxtrace(printk(KERN_DEBUG "%s not found\n", name));
265         dx_release (frames);
266         return NULL;
268 @@ -1377,7 +1379,7 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
269         struct fake_dirent *fde;
271         blocksize =  dir->i_sb->s_blocksize;
272 -       dxtrace(printk("Creating index\n"));
273 +       dxtrace(printk(KERN_DEBUG "Creating index\n"));
274         retval = ext4_journal_get_write_access(handle, bh);
275         if (retval) {
276                 ext4_std_error(dir->i_sb, retval);
277 @@ -1527,7 +1529,7 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
278         }
280         /* Block full, should compress but for now just split */
281 -       dxtrace(printk("using %u of %u node entries\n",
282 +       dxtrace(printk(KERN_DEBUG "using %u of %u node entries\n",
283                        dx_get_count(entries), dx_get_limit(entries)));
284         /* Need to split index? */
285         if (dx_get_count(entries) == dx_get_limit(entries)) {
286 @@ -1559,7 +1561,8 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
287                 if (levels) {
288                         unsigned icount1 = icount/2, icount2 = icount - icount1;
289                         unsigned hash2 = dx_get_hash(entries + icount1);
290 -                       dxtrace(printk("Split index %i/%i\n", icount1, icount2));
291 +                       dxtrace(printk(KERN_DEBUG "Split index %i/%i\n",
292 +                                      icount1, icount2));
294                         BUFFER_TRACE(frame->bh, "get_write_access"); /* index root */
295                         err = ext4_journal_get_write_access(handle,
296 @@ -1588,7 +1591,8 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
297                                 goto journal_error;
298                         brelse (bh2);
299                 } else {
300 -                       dxtrace(printk("Creating second level index...\n"));
301 +                       dxtrace(printk(KERN_DEBUG
302 +                                      "Creating second level index...\n"));
303                         memcpy((char *) entries2, (char *) entries,
304                                icount * sizeof(struct dx_entry));
305                         dx_set_limit(entries2, dx_node_limit(dir));
306 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
307 index 7402119..b4d47ac 100644
308 --- a/fs/ext4/super.c
309 +++ b/fs/ext4/super.c
310 @@ -982,7 +982,7 @@ static ext4_fsblk_t get_sb_block(void **data)
311         /*todo: use simple_strtoll with >32bit ext4 */
312         sb_block = simple_strtoul(options, &options, 0);
313         if (*options && *options != ',') {
314 -               printk("EXT4-fs: Invalid sb specification: %s\n",
315 +               printk(KERN_ERR "EXT4-fs: Invalid sb specification: %s\n",
316                        (char *) *data);
317                 return 1;
318         }
319 @@ -1083,7 +1083,8 @@ static int parse_options(char *options, struct super_block *sb,
320  #else
321                 case Opt_user_xattr:
322                 case Opt_nouser_xattr:
323 -                       printk("EXT4 (no)user_xattr options not supported\n");
324 +                       printk(KERN_ERR "EXT4 (no)user_xattr options "
325 +                              "not supported\n");
326                         break;
327  #endif
328  #ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
329 @@ -1096,7 +1097,8 @@ static int parse_options(char *options, struct super_block *sb,
330  #else
331                 case Opt_acl:
332                 case Opt_noacl:
333 -                       printk("EXT4 (no)acl options not supported\n");
334 +                       printk(KERN_ERR "EXT4 (no)acl options "
335 +                              "not supported\n");
336                         break;
337  #endif
338                 case Opt_reservation:
339 @@ -1190,8 +1192,8 @@ set_qf_name:
340                              sb_any_quota_suspended(sb)) &&
341                             !sbi->s_qf_names[qtype]) {
342                                 printk(KERN_ERR
343 -                                       "EXT4-fs: Cannot change journaled "
344 -                                       "quota options when quota turned on.\n");
345 +                                      "EXT4-fs: Cannot change journaled "
346 +                                      "quota options when quota turned on.\n");
347                                 return 0;
348                         }
349                         qname = match_strdup(&args[0]);
350 @@ -1474,14 +1476,14 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
351                         EXT4_INODES_PER_GROUP(sb),
352                         sbi->s_mount_opt);
354 -       printk(KERN_INFO "EXT4 FS on %s, ", sb->s_id);
355         if (EXT4_SB(sb)->s_journal->j_inode == NULL) {
356                 char b[BDEVNAME_SIZE];
358 -               printk("external journal on %s\n",
359 -                       bdevname(EXT4_SB(sb)->s_journal->j_dev, b));
360 +               printk(KERN_INFO "EXT4 FS on %s, external journal on %s\n",
361 +                      sb->s_id, bdevname(EXT4_SB(sb)->s_journal->j_dev, b));
362         } else {
363 -               printk("internal journal\n");
364 +               printk(KERN_INFO "EXT4 FS on %s, internal journal\n",
365 +                      sb->s_id);
366         }
367         return res;
369 @@ -2725,6 +2727,11 @@ static int ext4_load_journal(struct super_block *sb,
370                         return -EINVAL;
371         }
373 +       if (journal->j_flags & JBD2_BARRIER)
374 +               printk(KERN_INFO "EXT4-fs: barriers enabled\n");
375 +       else
376 +               printk(KERN_INFO "EXT4-fs: barriers disabled\n");
378         if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) {
379                 err = jbd2_journal_update_format(journal);
380                 if (err)  {