aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 12:27:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 12:27:40 -0400
commite57f146b2837d6a2d04a8ca86cb703f509b00e98 (patch)
tree0ebde713fc9bae7a0bcf626a5a66219899acd0b3 /fs/ubifs
parent7e61b3ff50f59f134054aaf43096c761fafecf0c (diff)
parent5a1f36c90c9b21a7aa31c29a1926b376dd6a11cf (diff)
Merge tag 'upstream-3.4-rc1' of git://git.infradead.org/linux-ubifs
Pull UBIFS changes from Artem Bityutskiy: - Improve error messages - Clean-up i_nlink management - Minor clean-ups * tag 'upstream-3.4-rc1' of git://git.infradead.org/linux-ubifs: UBIFS: improve error messages UBIFS: kill CUR_MAX_KEY_LEN macro UBIFS: do not use inc_link when i_nlink is zero UBIFS: make the dbg_lock spinlock static UBIFS: increase dumps loglevel UBIFS: amend recovery debugging message
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/debug.c410
-rw-r--r--fs/ubifs/debug.h3
-rw-r--r--fs/ubifs/dir.c18
-rw-r--r--fs/ubifs/recovery.c3
-rw-r--r--fs/ubifs/sb.c19
-rw-r--r--fs/ubifs/ubifs.h11
6 files changed, 234 insertions, 230 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index f922cbacdb96..1934084e2088 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -36,7 +36,7 @@
36 36
37#ifdef CONFIG_UBIFS_FS_DEBUG 37#ifdef CONFIG_UBIFS_FS_DEBUG
38 38
39DEFINE_SPINLOCK(dbg_lock); 39static DEFINE_SPINLOCK(dbg_lock);
40 40
41static const char *get_key_fmt(int fmt) 41static const char *get_key_fmt(int fmt)
42{ 42{
@@ -221,15 +221,15 @@ const char *dbg_jhead(int jhead)
221 221
222static void dump_ch(const struct ubifs_ch *ch) 222static void dump_ch(const struct ubifs_ch *ch)
223{ 223{
224 printk(KERN_DEBUG "\tmagic %#x\n", le32_to_cpu(ch->magic)); 224 printk(KERN_ERR "\tmagic %#x\n", le32_to_cpu(ch->magic));
225 printk(KERN_DEBUG "\tcrc %#x\n", le32_to_cpu(ch->crc)); 225 printk(KERN_ERR "\tcrc %#x\n", le32_to_cpu(ch->crc));
226 printk(KERN_DEBUG "\tnode_type %d (%s)\n", ch->node_type, 226 printk(KERN_ERR "\tnode_type %d (%s)\n", ch->node_type,
227 dbg_ntype(ch->node_type)); 227 dbg_ntype(ch->node_type));
228 printk(KERN_DEBUG "\tgroup_type %d (%s)\n", ch->group_type, 228 printk(KERN_ERR "\tgroup_type %d (%s)\n", ch->group_type,
229 dbg_gtype(ch->group_type)); 229 dbg_gtype(ch->group_type));
230 printk(KERN_DEBUG "\tsqnum %llu\n", 230 printk(KERN_ERR "\tsqnum %llu\n",
231 (unsigned long long)le64_to_cpu(ch->sqnum)); 231 (unsigned long long)le64_to_cpu(ch->sqnum));
232 printk(KERN_DEBUG "\tlen %u\n", le32_to_cpu(ch->len)); 232 printk(KERN_ERR "\tlen %u\n", le32_to_cpu(ch->len));
233} 233}
234 234
235void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode) 235void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode)
@@ -240,43 +240,43 @@ void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode)
240 struct ubifs_dent_node *dent, *pdent = NULL; 240 struct ubifs_dent_node *dent, *pdent = NULL;
241 int count = 2; 241 int count = 2;
242 242
243 printk(KERN_DEBUG "Dump in-memory inode:"); 243 printk(KERN_ERR "Dump in-memory inode:");
244 printk(KERN_DEBUG "\tinode %lu\n", inode->i_ino); 244 printk(KERN_ERR "\tinode %lu\n", inode->i_ino);
245 printk(KERN_DEBUG "\tsize %llu\n", 245 printk(KERN_ERR "\tsize %llu\n",
246 (unsigned long long)i_size_read(inode)); 246 (unsigned long long)i_size_read(inode));
247 printk(KERN_DEBUG "\tnlink %u\n", inode->i_nlink); 247 printk(KERN_ERR "\tnlink %u\n", inode->i_nlink);
248 printk(KERN_DEBUG "\tuid %u\n", (unsigned int)inode->i_uid); 248 printk(KERN_ERR "\tuid %u\n", (unsigned int)inode->i_uid);
249 printk(KERN_DEBUG "\tgid %u\n", (unsigned int)inode->i_gid); 249 printk(KERN_ERR "\tgid %u\n", (unsigned int)inode->i_gid);
250 printk(KERN_DEBUG "\tatime %u.%u\n", 250 printk(KERN_ERR "\tatime %u.%u\n",
251 (unsigned int)inode->i_atime.tv_sec, 251 (unsigned int)inode->i_atime.tv_sec,
252 (unsigned int)inode->i_atime.tv_nsec); 252 (unsigned int)inode->i_atime.tv_nsec);
253 printk(KERN_DEBUG "\tmtime %u.%u\n", 253 printk(KERN_ERR "\tmtime %u.%u\n",
254 (unsigned int)inode->i_mtime.tv_sec, 254 (unsigned int)inode->i_mtime.tv_sec,
255 (unsigned int)inode->i_mtime.tv_nsec); 255 (unsigned int)inode->i_mtime.tv_nsec);
256 printk(KERN_DEBUG "\tctime %u.%u\n", 256 printk(KERN_ERR "\tctime %u.%u\n",
257 (unsigned int)inode->i_ctime.tv_sec, 257 (unsigned int)inode->i_ctime.tv_sec,
258 (unsigned int)inode->i_ctime.tv_nsec); 258 (unsigned int)inode->i_ctime.tv_nsec);
259 printk(KERN_DEBUG "\tcreat_sqnum %llu\n", ui->creat_sqnum); 259 printk(KERN_ERR "\tcreat_sqnum %llu\n", ui->creat_sqnum);
260 printk(KERN_DEBUG "\txattr_size %u\n", ui->xattr_size); 260 printk(KERN_ERR "\txattr_size %u\n", ui->xattr_size);
261 printk(KERN_DEBUG "\txattr_cnt %u\n", ui->xattr_cnt); 261 printk(KERN_ERR "\txattr_cnt %u\n", ui->xattr_cnt);
262 printk(KERN_DEBUG "\txattr_names %u\n", ui->xattr_names); 262 printk(KERN_ERR "\txattr_names %u\n", ui->xattr_names);
263 printk(KERN_DEBUG "\tdirty %u\n", ui->dirty); 263 printk(KERN_ERR "\tdirty %u\n", ui->dirty);
264 printk(KERN_DEBUG "\txattr %u\n", ui->xattr); 264 printk(KERN_ERR "\txattr %u\n", ui->xattr);
265 printk(KERN_DEBUG "\tbulk_read %u\n", ui->xattr); 265 printk(KERN_ERR "\tbulk_read %u\n", ui->xattr);
266 printk(KERN_DEBUG "\tsynced_i_size %llu\n", 266 printk(KERN_ERR "\tsynced_i_size %llu\n",
267 (unsigned long long)ui->synced_i_size); 267 (unsigned long long)ui->synced_i_size);
268 printk(KERN_DEBUG "\tui_size %llu\n", 268 printk(KERN_ERR "\tui_size %llu\n",
269 (unsigned long long)ui->ui_size); 269 (unsigned long long)ui->ui_size);
270 printk(KERN_DEBUG "\tflags %d\n", ui->flags); 270 printk(KERN_ERR "\tflags %d\n", ui->flags);
271 printk(KERN_DEBUG "\tcompr_type %d\n", ui->compr_type); 271 printk(KERN_ERR "\tcompr_type %d\n", ui->compr_type);
272 printk(KERN_DEBUG "\tlast_page_read %lu\n", ui->last_page_read); 272 printk(KERN_ERR "\tlast_page_read %lu\n", ui->last_page_read);
273 printk(KERN_DEBUG "\tread_in_a_row %lu\n", ui->read_in_a_row); 273 printk(KERN_ERR "\tread_in_a_row %lu\n", ui->read_in_a_row);
274 printk(KERN_DEBUG "\tdata_len %d\n", ui->data_len); 274 printk(KERN_ERR "\tdata_len %d\n", ui->data_len);
275 275
276 if (!S_ISDIR(inode->i_mode)) 276 if (!S_ISDIR(inode->i_mode))
277 return; 277 return;
278 278
279 printk(KERN_DEBUG "List of directory entries:\n"); 279 printk(KERN_ERR "List of directory entries:\n");
280 ubifs_assert(!mutex_is_locked(&c->tnc_mutex)); 280 ubifs_assert(!mutex_is_locked(&c->tnc_mutex));
281 281
282 lowest_dent_key(c, &key, inode->i_ino); 282 lowest_dent_key(c, &key, inode->i_ino);
@@ -284,11 +284,11 @@ void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode)
284 dent = ubifs_tnc_next_ent(c, &key, &nm); 284 dent = ubifs_tnc_next_ent(c, &key, &nm);
285 if (IS_ERR(dent)) { 285 if (IS_ERR(dent)) {
286 if (PTR_ERR(dent) != -ENOENT) 286 if (PTR_ERR(dent) != -ENOENT)
287 printk(KERN_DEBUG "error %ld\n", PTR_ERR(dent)); 287 printk(KERN_ERR "error %ld\n", PTR_ERR(dent));
288 break; 288 break;
289 } 289 }
290 290
291 printk(KERN_DEBUG "\t%d: %s (%s)\n", 291 printk(KERN_ERR "\t%d: %s (%s)\n",
292 count++, dent->name, get_dent_type(dent->type)); 292 count++, dent->name, get_dent_type(dent->type));
293 293
294 nm.name = dent->name; 294 nm.name = dent->name;
@@ -312,8 +312,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
312 312
313 /* If the magic is incorrect, just hexdump the first bytes */ 313 /* If the magic is incorrect, just hexdump the first bytes */
314 if (le32_to_cpu(ch->magic) != UBIFS_NODE_MAGIC) { 314 if (le32_to_cpu(ch->magic) != UBIFS_NODE_MAGIC) {
315 printk(KERN_DEBUG "Not a node, first %zu bytes:", UBIFS_CH_SZ); 315 printk(KERN_ERR "Not a node, first %zu bytes:", UBIFS_CH_SZ);
316 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, 316 print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 32, 1,
317 (void *)node, UBIFS_CH_SZ, 1); 317 (void *)node, UBIFS_CH_SZ, 1);
318 return; 318 return;
319 } 319 }
@@ -326,7 +326,7 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
326 { 326 {
327 const struct ubifs_pad_node *pad = node; 327 const struct ubifs_pad_node *pad = node;
328 328
329 printk(KERN_DEBUG "\tpad_len %u\n", 329 printk(KERN_ERR "\tpad_len %u\n",
330 le32_to_cpu(pad->pad_len)); 330 le32_to_cpu(pad->pad_len));
331 break; 331 break;
332 } 332 }
@@ -335,50 +335,50 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
335 const struct ubifs_sb_node *sup = node; 335 const struct ubifs_sb_node *sup = node;
336 unsigned int sup_flags = le32_to_cpu(sup->flags); 336 unsigned int sup_flags = le32_to_cpu(sup->flags);
337 337
338 printk(KERN_DEBUG "\tkey_hash %d (%s)\n", 338 printk(KERN_ERR "\tkey_hash %d (%s)\n",
339 (int)sup->key_hash, get_key_hash(sup->key_hash)); 339 (int)sup->key_hash, get_key_hash(sup->key_hash));
340 printk(KERN_DEBUG "\tkey_fmt %d (%s)\n", 340 printk(KERN_ERR "\tkey_fmt %d (%s)\n",
341 (int)sup->key_fmt, get_key_fmt(sup->key_fmt)); 341 (int)sup->key_fmt, get_key_fmt(sup->key_fmt));
342 printk(KERN_DEBUG "\tflags %#x\n", sup_flags); 342 printk(KERN_ERR "\tflags %#x\n", sup_flags);
343 printk(KERN_DEBUG "\t big_lpt %u\n", 343 printk(KERN_ERR "\t big_lpt %u\n",
344 !!(sup_flags & UBIFS_FLG_BIGLPT)); 344 !!(sup_flags & UBIFS_FLG_BIGLPT));
345 printk(KERN_DEBUG "\t space_fixup %u\n", 345 printk(KERN_ERR "\t space_fixup %u\n",
346 !!(sup_flags & UBIFS_FLG_SPACE_FIXUP)); 346 !!(sup_flags & UBIFS_FLG_SPACE_FIXUP));
347 printk(KERN_DEBUG "\tmin_io_size %u\n", 347 printk(KERN_ERR "\tmin_io_size %u\n",
348 le32_to_cpu(sup->min_io_size)); 348 le32_to_cpu(sup->min_io_size));
349 printk(KERN_DEBUG "\tleb_size %u\n", 349 printk(KERN_ERR "\tleb_size %u\n",
350 le32_to_cpu(sup->leb_size)); 350 le32_to_cpu(sup->leb_size));
351 printk(KERN_DEBUG "\tleb_cnt %u\n", 351 printk(KERN_ERR "\tleb_cnt %u\n",
352 le32_to_cpu(sup->leb_cnt)); 352 le32_to_cpu(sup->leb_cnt));
353 printk(KERN_DEBUG "\tmax_leb_cnt %u\n", 353 printk(KERN_ERR "\tmax_leb_cnt %u\n",
354 le32_to_cpu(sup->max_leb_cnt)); 354 le32_to_cpu(sup->max_leb_cnt));
355 printk(KERN_DEBUG "\tmax_bud_bytes %llu\n", 355 printk(KERN_ERR "\tmax_bud_bytes %llu\n",
356 (unsigned long long)le64_to_cpu(sup->max_bud_bytes)); 356 (unsigned long long)le64_to_cpu(sup->max_bud_bytes));
357 printk(KERN_DEBUG "\tlog_lebs %u\n", 357 printk(KERN_ERR "\tlog_lebs %u\n",
358 le32_to_cpu(sup->log_lebs)); 358 le32_to_cpu(sup->log_lebs));
359 printk(KERN_DEBUG "\tlpt_lebs %u\n", 359 printk(KERN_ERR "\tlpt_lebs %u\n",
360 le32_to_cpu(sup->lpt_lebs)); 360 le32_to_cpu(sup->lpt_lebs));
361 printk(KERN_DEBUG "\torph_lebs %u\n", 361 printk(KERN_ERR "\torph_lebs %u\n",
362 le32_to_cpu(sup->orph_lebs)); 362 le32_to_cpu(sup->orph_lebs));
363 printk(KERN_DEBUG "\tjhead_cnt %u\n", 363 printk(KERN_ERR "\tjhead_cnt %u\n",
364 le32_to_cpu(sup->jhead_cnt)); 364 le32_to_cpu(sup->jhead_cnt));
365 printk(KERN_DEBUG "\tfanout %u\n", 365 printk(KERN_ERR "\tfanout %u\n",
366 le32_to_cpu(sup->fanout)); 366 le32_to_cpu(sup->fanout));
367 printk(KERN_DEBUG "\tlsave_cnt %u\n", 367 printk(KERN_ERR "\tlsave_cnt %u\n",
368 le32_to_cpu(sup->lsave_cnt)); 368 le32_to_cpu(sup->lsave_cnt));
369 printk(KERN_DEBUG "\tdefault_compr %u\n", 369 printk(KERN_ERR "\tdefault_compr %u\n",
370 (int)le16_to_cpu(sup->default_compr)); 370 (int)le16_to_cpu(sup->default_compr));
371 printk(KERN_DEBUG "\trp_size %llu\n", 371 printk(KERN_ERR "\trp_size %llu\n",
372 (unsigned long long)le64_to_cpu(sup->rp_size)); 372 (unsigned long long)le64_to_cpu(sup->rp_size));
373 printk(KERN_DEBUG "\trp_uid %u\n", 373 printk(KERN_ERR "\trp_uid %u\n",
374 le32_to_cpu(sup->rp_uid)); 374 le32_to_cpu(sup->rp_uid));
375 printk(KERN_DEBUG "\trp_gid %u\n", 375 printk(KERN_ERR "\trp_gid %u\n",
376 le32_to_cpu(sup->rp_gid)); 376 le32_to_cpu(sup->rp_gid));
377 printk(KERN_DEBUG "\tfmt_version %u\n", 377 printk(KERN_ERR "\tfmt_version %u\n",
378 le32_to_cpu(sup->fmt_version)); 378 le32_to_cpu(sup->fmt_version));
379 printk(KERN_DEBUG "\ttime_gran %u\n", 379 printk(KERN_ERR "\ttime_gran %u\n",
380 le32_to_cpu(sup->time_gran)); 380 le32_to_cpu(sup->time_gran));
381 printk(KERN_DEBUG "\tUUID %pUB\n", 381 printk(KERN_ERR "\tUUID %pUB\n",
382 sup->uuid); 382 sup->uuid);
383 break; 383 break;
384 } 384 }
@@ -386,61 +386,61 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
386 { 386 {
387 const struct ubifs_mst_node *mst = node; 387 const struct ubifs_mst_node *mst = node;
388 388
389 printk(KERN_DEBUG "\thighest_inum %llu\n", 389 printk(KERN_ERR "\thighest_inum %llu\n",
390 (unsigned long long)le64_to_cpu(mst->highest_inum)); 390 (unsigned long long)le64_to_cpu(mst->highest_inum));
391 printk(KERN_DEBUG "\tcommit number %llu\n", 391 printk(KERN_ERR "\tcommit number %llu\n",
392 (unsigned long long)le64_to_cpu(mst->cmt_no)); 392 (unsigned long long)le64_to_cpu(mst->cmt_no));
393 printk(KERN_DEBUG "\tflags %#x\n", 393 printk(KERN_ERR "\tflags %#x\n",
394 le32_to_cpu(mst->flags)); 394 le32_to_cpu(mst->flags));
395 printk(KERN_DEBUG "\tlog_lnum %u\n", 395 printk(KERN_ERR "\tlog_lnum %u\n",
396 le32_to_cpu(mst->log_lnum)); 396 le32_to_cpu(mst->log_lnum));
397 printk(KERN_DEBUG "\troot_lnum %u\n", 397 printk(KERN_ERR "\troot_lnum %u\n",
398 le32_to_cpu(mst->root_lnum)); 398 le32_to_cpu(mst->root_lnum));
399 printk(KERN_DEBUG "\troot_offs %u\n", 399 printk(KERN_ERR "\troot_offs %u\n",
400 le32_to_cpu(mst->root_offs)); 400 le32_to_cpu(mst->root_offs));
401 printk(KERN_DEBUG "\troot_len %u\n", 401 printk(KERN_ERR "\troot_len %u\n",
402 le32_to_cpu(mst->root_len)); 402 le32_to_cpu(mst->root_len));
403 printk(KERN_DEBUG "\tgc_lnum %u\n", 403 printk(KERN_ERR "\tgc_lnum %u\n",
404 le32_to_cpu(mst->gc_lnum)); 404 le32_to_cpu(mst->gc_lnum));
405 printk(KERN_DEBUG "\tihead_lnum %u\n", 405 printk(KERN_ERR "\tihead_lnum %u\n",
406 le32_to_cpu(mst->ihead_lnum)); 406 le32_to_cpu(mst->ihead_lnum));
407 printk(KERN_DEBUG "\tihead_offs %u\n", 407 printk(KERN_ERR "\tihead_offs %u\n",
408 le32_to_cpu(mst->ihead_offs)); 408 le32_to_cpu(mst->ihead_offs));
409 printk(KERN_DEBUG "\tindex_size %llu\n", 409 printk(KERN_ERR "\tindex_size %llu\n",
410 (unsigned long long)le64_to_cpu(mst->index_size)); 410 (unsigned long long)le64_to_cpu(mst->index_size));
411 printk(KERN_DEBUG "\tlpt_lnum %u\n", 411 printk(KERN_ERR "\tlpt_lnum %u\n",
412 le32_to_cpu(mst->lpt_lnum)); 412 le32_to_cpu(mst->lpt_lnum));
413 printk(KERN_DEBUG "\tlpt_offs %u\n", 413 printk(KERN_ERR "\tlpt_offs %u\n",
414 le32_to_cpu(mst->lpt_offs)); 414 le32_to_cpu(mst->lpt_offs));
415 printk(KERN_DEBUG "\tnhead_lnum %u\n", 415 printk(KERN_ERR "\tnhead_lnum %u\n",
416 le32_to_cpu(mst->nhead_lnum)); 416 le32_to_cpu(mst->nhead_lnum));
417 printk(KERN_DEBUG "\tnhead_offs %u\n", 417 printk(KERN_ERR "\tnhead_offs %u\n",
418 le32_to_cpu(mst->nhead_offs)); 418 le32_to_cpu(mst->nhead_offs));
419 printk(KERN_DEBUG "\tltab_lnum %u\n", 419 printk(KERN_ERR "\tltab_lnum %u\n",
420 le32_to_cpu(mst->ltab_lnum)); 420 le32_to_cpu(mst->ltab_lnum));
421 printk(KERN_DEBUG "\tltab_offs %u\n", 421 printk(KERN_ERR "\tltab_offs %u\n",
422 le32_to_cpu(mst->ltab_offs)); 422 le32_to_cpu(mst->ltab_offs));
423 printk(KERN_DEBUG "\tlsave_lnum %u\n", 423 printk(KERN_ERR "\tlsave_lnum %u\n",
424 le32_to_cpu(mst->lsave_lnum)); 424 le32_to_cpu(mst->lsave_lnum));
425 printk(KERN_DEBUG "\tlsave_offs %u\n", 425 printk(KERN_ERR "\tlsave_offs %u\n",
426 le32_to_cpu(mst->lsave_offs)); 426 le32_to_cpu(mst->lsave_offs));
427 printk(KERN_DEBUG "\tlscan_lnum %u\n", 427 printk(KERN_ERR "\tlscan_lnum %u\n",
428 le32_to_cpu(mst->lscan_lnum)); 428 le32_to_cpu(mst->lscan_lnum));
429 printk(KERN_DEBUG "\tleb_cnt %u\n", 429 printk(KERN_ERR "\tleb_cnt %u\n",
430 le32_to_cpu(mst->leb_cnt)); 430 le32_to_cpu(mst->leb_cnt));
431 printk(KERN_DEBUG "\tempty_lebs %u\n", 431 printk(KERN_ERR "\tempty_lebs %u\n",
432 le32_to_cpu(mst->empty_lebs)); 432 le32_to_cpu(mst->empty_lebs));
433 printk(KERN_DEBUG "\tidx_lebs %u\n", 433 printk(KERN_ERR "\tidx_lebs %u\n",
434 le32_to_cpu(mst->idx_lebs)); 434 le32_to_cpu(mst->idx_lebs));
435 printk(KERN_DEBUG "\ttotal_free %llu\n", 435 printk(KERN_ERR "\ttotal_free %llu\n",
436 (unsigned long long)le64_to_cpu(mst->total_free)); 436 (unsigned long long)le64_to_cpu(mst->total_free));
437 printk(KERN_DEBUG "\ttotal_dirty %llu\n", 437 printk(KERN_ERR "\ttotal_dirty %llu\n",
438 (unsigned long long)le64_to_cpu(mst->total_dirty)); 438 (unsigned long long)le64_to_cpu(mst->total_dirty));
439 printk(KERN_DEBUG "\ttotal_used %llu\n", 439 printk(KERN_ERR "\ttotal_used %llu\n",
440 (unsigned long long)le64_to_cpu(mst->total_used)); 440 (unsigned long long)le64_to_cpu(mst->total_used));
441 printk(KERN_DEBUG "\ttotal_dead %llu\n", 441 printk(KERN_ERR "\ttotal_dead %llu\n",
442 (unsigned long long)le64_to_cpu(mst->total_dead)); 442 (unsigned long long)le64_to_cpu(mst->total_dead));
443 printk(KERN_DEBUG "\ttotal_dark %llu\n", 443 printk(KERN_ERR "\ttotal_dark %llu\n",
444 (unsigned long long)le64_to_cpu(mst->total_dark)); 444 (unsigned long long)le64_to_cpu(mst->total_dark));
445 break; 445 break;
446 } 446 }
@@ -448,11 +448,11 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
448 { 448 {
449 const struct ubifs_ref_node *ref = node; 449 const struct ubifs_ref_node *ref = node;
450 450
451 printk(KERN_DEBUG "\tlnum %u\n", 451 printk(KERN_ERR "\tlnum %u\n",
452 le32_to_cpu(ref->lnum)); 452 le32_to_cpu(ref->lnum));
453 printk(KERN_DEBUG "\toffs %u\n", 453 printk(KERN_ERR "\toffs %u\n",
454 le32_to_cpu(ref->offs)); 454 le32_to_cpu(ref->offs));
455 printk(KERN_DEBUG "\tjhead %u\n", 455 printk(KERN_ERR "\tjhead %u\n",
456 le32_to_cpu(ref->jhead)); 456 le32_to_cpu(ref->jhead));
457 break; 457 break;
458 } 458 }
@@ -461,40 +461,40 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
461 const struct ubifs_ino_node *ino = node; 461 const struct ubifs_ino_node *ino = node;
462 462
463 key_read(c, &ino->key, &key); 463 key_read(c, &ino->key, &key);
464 printk(KERN_DEBUG "\tkey %s\n", 464 printk(KERN_ERR "\tkey %s\n",
465 dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN)); 465 dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));
466 printk(KERN_DEBUG "\tcreat_sqnum %llu\n", 466 printk(KERN_ERR "\tcreat_sqnum %llu\n",
467 (unsigned long long)le64_to_cpu(ino->creat_sqnum)); 467 (unsigned long long)le64_to_cpu(ino->creat_sqnum));
468 printk(KERN_DEBUG "\tsize %llu\n", 468 printk(KERN_ERR "\tsize %llu\n",
469 (unsigned long long)le64_to_cpu(ino->size)); 469 (unsigned long long)le64_to_cpu(ino->size));
470 printk(KERN_DEBUG "\tnlink %u\n", 470 printk(KERN_ERR "\tnlink %u\n",
471 le32_to_cpu(ino->nlink)); 471 le32_to_cpu(ino->nlink));
472 printk(KERN_DEBUG "\tatime %lld.%u\n", 472 printk(KERN_ERR "\tatime %lld.%u\n",
473 (long long)le64_to_cpu(ino->atime_sec), 473 (long long)le64_to_cpu(ino->atime_sec),
474 le32_to_cpu(ino->atime_nsec)); 474 le32_to_cpu(ino->atime_nsec));
475 printk(KERN_DEBUG "\tmtime %lld.%u\n", 475 printk(KERN_ERR "\tmtime %lld.%u\n",
476 (long long)le64_to_cpu(ino->mtime_sec), 476 (long long)le64_to_cpu(ino->mtime_sec),
477 le32_to_cpu(ino->mtime_nsec)); 477 le32_to_cpu(ino->mtime_nsec));
478 printk(KERN_DEBUG "\tctime %lld.%u\n", 478 printk(KERN_ERR "\tctime %lld.%u\n",
479 (long long)le64_to_cpu(ino->ctime_sec), 479 (long long)le64_to_cpu(ino->ctime_sec),
480 le32_to_cpu(ino->ctime_nsec)); 480 le32_to_cpu(ino->ctime_nsec));
481 printk(KERN_DEBUG "\tuid %u\n", 481 printk(KERN_ERR "\tuid %u\n",
482 le32_to_cpu(ino->uid)); 482 le32_to_cpu(ino->uid));
483 printk(KERN_DEBUG "\tgid %u\n", 483 printk(KERN_ERR "\tgid %u\n",
484 le32_to_cpu(ino->gid)); 484 le32_to_cpu(ino->gid));
485 printk(KERN_DEBUG "\tmode %u\n", 485 printk(KERN_ERR "\tmode %u\n",
486 le32_to_cpu(ino->mode)); 486 le32_to_cpu(ino->mode));
487 printk(KERN_DEBUG "\tflags %#x\n", 487 printk(KERN_ERR "\tflags %#x\n",
488 le32_to_cpu(ino->flags)); 488 le32_to_cpu(ino->flags));
489 printk(KERN_DEBUG "\txattr_cnt %u\n", 489 printk(KERN_ERR "\txattr_cnt %u\n",
490 le32_to_cpu(ino->xattr_cnt)); 490 le32_to_cpu(ino->xattr_cnt));
491 printk(KERN_DEBUG "\txattr_size %u\n", 491 printk(KERN_ERR "\txattr_size %u\n",
492 le32_to_cpu(ino->xattr_size)); 492 le32_to_cpu(ino->xattr_size));
493 printk(KERN_DEBUG "\txattr_names %u\n", 493 printk(KERN_ERR "\txattr_names %u\n",
494 le32_to_cpu(ino->xattr_names)); 494 le32_to_cpu(ino->xattr_names));
495 printk(KERN_DEBUG "\tcompr_type %#x\n", 495 printk(KERN_ERR "\tcompr_type %#x\n",
496 (int)le16_to_cpu(ino->compr_type)); 496 (int)le16_to_cpu(ino->compr_type));
497 printk(KERN_DEBUG "\tdata len %u\n", 497 printk(KERN_ERR "\tdata len %u\n",
498 le32_to_cpu(ino->data_len)); 498 le32_to_cpu(ino->data_len));
499 break; 499 break;
500 } 500 }
@@ -505,16 +505,16 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
505 int nlen = le16_to_cpu(dent->nlen); 505 int nlen = le16_to_cpu(dent->nlen);
506 506
507 key_read(c, &dent->key, &key); 507 key_read(c, &dent->key, &key);
508 printk(KERN_DEBUG "\tkey %s\n", 508 printk(KERN_ERR "\tkey %s\n",
509 dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN)); 509 dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));
510 printk(KERN_DEBUG "\tinum %llu\n", 510 printk(KERN_ERR "\tinum %llu\n",
511 (unsigned long long)le64_to_cpu(dent->inum)); 511 (unsigned long long)le64_to_cpu(dent->inum));
512 printk(KERN_DEBUG "\ttype %d\n", (int)dent->type); 512 printk(KERN_ERR "\ttype %d\n", (int)dent->type);
513 printk(KERN_DEBUG "\tnlen %d\n", nlen); 513 printk(KERN_ERR "\tnlen %d\n", nlen);
514 printk(KERN_DEBUG "\tname "); 514 printk(KERN_ERR "\tname ");
515 515
516 if (nlen > UBIFS_MAX_NLEN) 516 if (nlen > UBIFS_MAX_NLEN)
517 printk(KERN_DEBUG "(bad name length, not printing, " 517 printk(KERN_ERR "(bad name length, not printing, "
518 "bad or corrupted node)"); 518 "bad or corrupted node)");
519 else { 519 else {
520 for (i = 0; i < nlen && dent->name[i]; i++) 520 for (i = 0; i < nlen && dent->name[i]; i++)
@@ -530,16 +530,16 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
530 int dlen = le32_to_cpu(ch->len) - UBIFS_DATA_NODE_SZ; 530 int dlen = le32_to_cpu(ch->len) - UBIFS_DATA_NODE_SZ;
531 531
532 key_read(c, &dn->key, &key); 532 key_read(c, &dn->key, &key);
533 printk(KERN_DEBUG "\tkey %s\n", 533 printk(KERN_ERR "\tkey %s\n",
534 dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN)); 534 dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));
535 printk(KERN_DEBUG "\tsize %u\n", 535 printk(KERN_ERR "\tsize %u\n",
536 le32_to_cpu(dn->size)); 536 le32_to_cpu(dn->size));
537 printk(KERN_DEBUG "\tcompr_typ %d\n", 537 printk(KERN_ERR "\tcompr_typ %d\n",
538 (int)le16_to_cpu(dn->compr_type)); 538 (int)le16_to_cpu(dn->compr_type));
539 printk(KERN_DEBUG "\tdata size %d\n", 539 printk(KERN_ERR "\tdata size %d\n",
540 dlen); 540 dlen);
541 printk(KERN_DEBUG "\tdata:\n"); 541 printk(KERN_ERR "\tdata:\n");
542 print_hex_dump(KERN_DEBUG, "\t", DUMP_PREFIX_OFFSET, 32, 1, 542 print_hex_dump(KERN_ERR, "\t", DUMP_PREFIX_OFFSET, 32, 1,
543 (void *)&dn->data, dlen, 0); 543 (void *)&dn->data, dlen, 0);
544 break; 544 break;
545 } 545 }
@@ -547,11 +547,11 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
547 { 547 {
548 const struct ubifs_trun_node *trun = node; 548 const struct ubifs_trun_node *trun = node;
549 549
550 printk(KERN_DEBUG "\tinum %u\n", 550 printk(KERN_ERR "\tinum %u\n",
551 le32_to_cpu(trun->inum)); 551 le32_to_cpu(trun->inum));
552 printk(KERN_DEBUG "\told_size %llu\n", 552 printk(KERN_ERR "\told_size %llu\n",
553 (unsigned long long)le64_to_cpu(trun->old_size)); 553 (unsigned long long)le64_to_cpu(trun->old_size));
554 printk(KERN_DEBUG "\tnew_size %llu\n", 554 printk(KERN_ERR "\tnew_size %llu\n",
555 (unsigned long long)le64_to_cpu(trun->new_size)); 555 (unsigned long long)le64_to_cpu(trun->new_size));
556 break; 556 break;
557 } 557 }
@@ -560,17 +560,17 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
560 const struct ubifs_idx_node *idx = node; 560 const struct ubifs_idx_node *idx = node;
561 561
562 n = le16_to_cpu(idx->child_cnt); 562 n = le16_to_cpu(idx->child_cnt);
563 printk(KERN_DEBUG "\tchild_cnt %d\n", n); 563 printk(KERN_ERR "\tchild_cnt %d\n", n);
564 printk(KERN_DEBUG "\tlevel %d\n", 564 printk(KERN_ERR "\tlevel %d\n",
565 (int)le16_to_cpu(idx->level)); 565 (int)le16_to_cpu(idx->level));
566 printk(KERN_DEBUG "\tBranches:\n"); 566 printk(KERN_ERR "\tBranches:\n");
567 567
568 for (i = 0; i < n && i < c->fanout - 1; i++) { 568 for (i = 0; i < n && i < c->fanout - 1; i++) {
569 const struct ubifs_branch *br; 569 const struct ubifs_branch *br;
570 570
571 br = ubifs_idx_branch(c, idx, i); 571 br = ubifs_idx_branch(c, idx, i);
572 key_read(c, &br->key, &key); 572 key_read(c, &br->key, &key);
573 printk(KERN_DEBUG "\t%d: LEB %d:%d len %d key %s\n", 573 printk(KERN_ERR "\t%d: LEB %d:%d len %d key %s\n",
574 i, le32_to_cpu(br->lnum), le32_to_cpu(br->offs), 574 i, le32_to_cpu(br->lnum), le32_to_cpu(br->offs),
575 le32_to_cpu(br->len), 575 le32_to_cpu(br->len),
576 dbg_snprintf_key(c, &key, key_buf, 576 dbg_snprintf_key(c, &key, key_buf,
@@ -584,20 +584,20 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
584 { 584 {
585 const struct ubifs_orph_node *orph = node; 585 const struct ubifs_orph_node *orph = node;
586 586
587 printk(KERN_DEBUG "\tcommit number %llu\n", 587 printk(KERN_ERR "\tcommit number %llu\n",
588 (unsigned long long) 588 (unsigned long long)
589 le64_to_cpu(orph->cmt_no) & LLONG_MAX); 589 le64_to_cpu(orph->cmt_no) & LLONG_MAX);
590 printk(KERN_DEBUG "\tlast node flag %llu\n", 590 printk(KERN_ERR "\tlast node flag %llu\n",
591 (unsigned long long)(le64_to_cpu(orph->cmt_no)) >> 63); 591 (unsigned long long)(le64_to_cpu(orph->cmt_no)) >> 63);
592 n = (le32_to_cpu(ch->len) - UBIFS_ORPH_NODE_SZ) >> 3; 592 n = (le32_to_cpu(ch->len) - UBIFS_ORPH_NODE_SZ) >> 3;
593 printk(KERN_DEBUG "\t%d orphan inode numbers:\n", n); 593 printk(KERN_ERR "\t%d orphan inode numbers:\n", n);
594 for (i = 0; i < n; i++) 594 for (i = 0; i < n; i++)
595 printk(KERN_DEBUG "\t ino %llu\n", 595 printk(KERN_ERR "\t ino %llu\n",
596 (unsigned long long)le64_to_cpu(orph->inos[i])); 596 (unsigned long long)le64_to_cpu(orph->inos[i]));
597 break; 597 break;
598 } 598 }
599 default: 599 default:
600 printk(KERN_DEBUG "node type %d was not recognized\n", 600 printk(KERN_ERR "node type %d was not recognized\n",
601 (int)ch->node_type); 601 (int)ch->node_type);
602 } 602 }
603 spin_unlock(&dbg_lock); 603 spin_unlock(&dbg_lock);
@@ -606,16 +606,16 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
606void dbg_dump_budget_req(const struct ubifs_budget_req *req) 606void dbg_dump_budget_req(const struct ubifs_budget_req *req)
607{ 607{
608 spin_lock(&dbg_lock); 608 spin_lock(&dbg_lock);
609 printk(KERN_DEBUG "Budgeting request: new_ino %d, dirtied_ino %d\n", 609 printk(KERN_ERR "Budgeting request: new_ino %d, dirtied_ino %d\n",
610 req->new_ino, req->dirtied_ino); 610 req->new_ino, req->dirtied_ino);
611 printk(KERN_DEBUG "\tnew_ino_d %d, dirtied_ino_d %d\n", 611 printk(KERN_ERR "\tnew_ino_d %d, dirtied_ino_d %d\n",
612 req->new_ino_d, req->dirtied_ino_d); 612 req->new_ino_d, req->dirtied_ino_d);
613 printk(KERN_DEBUG "\tnew_page %d, dirtied_page %d\n", 613 printk(KERN_ERR "\tnew_page %d, dirtied_page %d\n",
614 req->new_page, req->dirtied_page); 614 req->new_page, req->dirtied_page);
615 printk(KERN_DEBUG "\tnew_dent %d, mod_dent %d\n", 615 printk(KERN_ERR "\tnew_dent %d, mod_dent %d\n",
616 req->new_dent, req->mod_dent); 616 req->new_dent, req->mod_dent);
617 printk(KERN_DEBUG "\tidx_growth %d\n", req->idx_growth); 617 printk(KERN_ERR "\tidx_growth %d\n", req->idx_growth);
618 printk(KERN_DEBUG "\tdata_growth %d dd_growth %d\n", 618 printk(KERN_ERR "\tdata_growth %d dd_growth %d\n",
619 req->data_growth, req->dd_growth); 619 req->data_growth, req->dd_growth);
620 spin_unlock(&dbg_lock); 620 spin_unlock(&dbg_lock);
621} 621}
@@ -623,12 +623,12 @@ void dbg_dump_budget_req(const struct ubifs_budget_req *req)
623void dbg_dump_lstats(const struct ubifs_lp_stats *lst) 623void dbg_dump_lstats(const struct ubifs_lp_stats *lst)
624{ 624{
625 spin_lock(&dbg_lock); 625 spin_lock(&dbg_lock);
626 printk(KERN_DEBUG "(pid %d) Lprops statistics: empty_lebs %d, " 626 printk(KERN_ERR "(pid %d) Lprops statistics: empty_lebs %d, "
627 "idx_lebs %d\n", current->pid, lst->empty_lebs, lst->idx_lebs); 627 "idx_lebs %d\n", current->pid, lst->empty_lebs, lst->idx_lebs);
628 printk(KERN_DEBUG "\ttaken_empty_lebs %d, total_free %lld, " 628 printk(KERN_ERR "\ttaken_empty_lebs %d, total_free %lld, "
629 "total_dirty %lld\n", lst->taken_empty_lebs, lst->total_free, 629 "total_dirty %lld\n", lst->taken_empty_lebs, lst->total_free,
630 lst->total_dirty); 630 lst->total_dirty);
631 printk(KERN_DEBUG "\ttotal_used %lld, total_dark %lld, " 631 printk(KERN_ERR "\ttotal_used %lld, total_dark %lld, "
632 "total_dead %lld\n", lst->total_used, lst->total_dark, 632 "total_dead %lld\n", lst->total_used, lst->total_dark,
633 lst->total_dead); 633 lst->total_dead);
634 spin_unlock(&dbg_lock); 634 spin_unlock(&dbg_lock);
@@ -644,21 +644,21 @@ void dbg_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi)
644 644
645 spin_lock(&c->space_lock); 645 spin_lock(&c->space_lock);
646 spin_lock(&dbg_lock); 646 spin_lock(&dbg_lock);
647 printk(KERN_DEBUG "(pid %d) Budgeting info: data budget sum %lld, " 647 printk(KERN_ERR "(pid %d) Budgeting info: data budget sum %lld, "
648 "total budget sum %lld\n", current->pid, 648 "total budget sum %lld\n", current->pid,
649 bi->data_growth + bi->dd_growth, 649 bi->data_growth + bi->dd_growth,
650 bi->data_growth + bi->dd_growth + bi->idx_growth); 650 bi->data_growth + bi->dd_growth + bi->idx_growth);
651 printk(KERN_DEBUG "\tbudg_data_growth %lld, budg_dd_growth %lld, " 651 printk(KERN_ERR "\tbudg_data_growth %lld, budg_dd_growth %lld, "
652 "budg_idx_growth %lld\n", bi->data_growth, bi->dd_growth, 652 "budg_idx_growth %lld\n", bi->data_growth, bi->dd_growth,
653 bi->idx_growth); 653 bi->idx_growth);
654 printk(KERN_DEBUG "\tmin_idx_lebs %d, old_idx_sz %llu, " 654 printk(KERN_ERR "\tmin_idx_lebs %d, old_idx_sz %llu, "
655 "uncommitted_idx %lld\n", bi->min_idx_lebs, bi->old_idx_sz, 655 "uncommitted_idx %lld\n", bi->min_idx_lebs, bi->old_idx_sz,
656 bi->uncommitted_idx); 656 bi->uncommitted_idx);
657 printk(KERN_DEBUG "\tpage_budget %d, inode_budget %d, dent_budget %d\n", 657 printk(KERN_ERR "\tpage_budget %d, inode_budget %d, dent_budget %d\n",
658 bi->page_budget, bi->inode_budget, bi->dent_budget); 658 bi->page_budget, bi->inode_budget, bi->dent_budget);
659 printk(KERN_DEBUG "\tnospace %u, nospace_rp %u\n", 659 printk(KERN_ERR "\tnospace %u, nospace_rp %u\n",
660 bi->nospace, bi->nospace_rp); 660 bi->nospace, bi->nospace_rp);
661 printk(KERN_DEBUG "\tdark_wm %d, dead_wm %d, max_idx_node_sz %d\n", 661 printk(KERN_ERR "\tdark_wm %d, dead_wm %d, max_idx_node_sz %d\n",
662 c->dark_wm, c->dead_wm, c->max_idx_node_sz); 662 c->dark_wm, c->dead_wm, c->max_idx_node_sz);
663 663
664 if (bi != &c->bi) 664 if (bi != &c->bi)
@@ -669,38 +669,38 @@ void dbg_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi)
669 */ 669 */
670 goto out_unlock; 670 goto out_unlock;
671 671
672 printk(KERN_DEBUG "\tfreeable_cnt %d, calc_idx_sz %lld, idx_gc_cnt %d\n", 672 printk(KERN_ERR "\tfreeable_cnt %d, calc_idx_sz %lld, idx_gc_cnt %d\n",
673 c->freeable_cnt, c->calc_idx_sz, c->idx_gc_cnt); 673 c->freeable_cnt, c->calc_idx_sz, c->idx_gc_cnt);
674 printk(KERN_DEBUG "\tdirty_pg_cnt %ld, dirty_zn_cnt %ld, " 674 printk(KERN_ERR "\tdirty_pg_cnt %ld, dirty_zn_cnt %ld, "
675 "clean_zn_cnt %ld\n", atomic_long_read(&c->dirty_pg_cnt), 675 "clean_zn_cnt %ld\n", atomic_long_read(&c->dirty_pg_cnt),
676 atomic_long_read(&c->dirty_zn_cnt), 676 atomic_long_read(&c->dirty_zn_cnt),
677 atomic_long_read(&c->clean_zn_cnt)); 677 atomic_long_read(&c->clean_zn_cnt));
678 printk(KERN_DEBUG "\tgc_lnum %d, ihead_lnum %d\n", 678 printk(KERN_ERR "\tgc_lnum %d, ihead_lnum %d\n",
679 c->gc_lnum, c->ihead_lnum); 679 c->gc_lnum, c->ihead_lnum);
680 680
681 /* If we are in R/O mode, journal heads do not exist */ 681 /* If we are in R/O mode, journal heads do not exist */
682 if (c->jheads) 682 if (c->jheads)
683 for (i = 0; i < c->jhead_cnt; i++) 683 for (i = 0; i < c->jhead_cnt; i++)
684 printk(KERN_DEBUG "\tjhead %s\t LEB %d\n", 684 printk(KERN_ERR "\tjhead %s\t LEB %d\n",
685 dbg_jhead(c->jheads[i].wbuf.jhead), 685 dbg_jhead(c->jheads[i].wbuf.jhead),
686 c->jheads[i].wbuf.lnum); 686 c->jheads[i].wbuf.lnum);
687 for (rb = rb_first(&c->buds); rb; rb = rb_next(rb)) { 687 for (rb = rb_first(&c->buds); rb; rb = rb_next(rb)) {
688 bud = rb_entry(rb, struct ubifs_bud, rb); 688 bud = rb_entry(rb, struct ubifs_bud, rb);
689 printk(KERN_DEBUG "\tbud LEB %d\n", bud->lnum); 689 printk(KERN_ERR "\tbud LEB %d\n", bud->lnum);
690 } 690 }
691 list_for_each_entry(bud, &c->old_buds, list) 691 list_for_each_entry(bud, &c->old_buds, list)
692 printk(KERN_DEBUG "\told bud LEB %d\n", bud->lnum); 692 printk(KERN_ERR "\told bud LEB %d\n", bud->lnum);
693 list_for_each_entry(idx_gc, &c->idx_gc, list) 693 list_for_each_entry(idx_gc, &c->idx_gc, list)
694 printk(KERN_DEBUG "\tGC'ed idx LEB %d unmap %d\n", 694 printk(KERN_ERR "\tGC'ed idx LEB %d unmap %d\n",
695 idx_gc->lnum, idx_gc->unmap); 695 idx_gc->lnum, idx_gc->unmap);
696 printk(KERN_DEBUG "\tcommit state %d\n", c->cmt_state); 696 printk(KERN_ERR "\tcommit state %d\n", c->cmt_state);
697 697
698 /* Print budgeting predictions */ 698 /* Print budgeting predictions */
699 available = ubifs_calc_available(c, c->bi.min_idx_lebs); 699 available = ubifs_calc_available(c, c->bi.min_idx_lebs);
700 outstanding = c->bi.data_growth + c->bi.dd_growth; 700 outstanding = c->bi.data_growth + c->bi.dd_growth;
701 free = ubifs_get_free_space_nolock(c); 701 free = ubifs_get_free_space_nolock(c);
702 printk(KERN_DEBUG "Budgeting predictions:\n"); 702 printk(KERN_ERR "Budgeting predictions:\n");
703 printk(KERN_DEBUG "\tavailable: %lld, outstanding %lld, free %lld\n", 703 printk(KERN_ERR "\tavailable: %lld, outstanding %lld, free %lld\n",
704 available, outstanding, free); 704 available, outstanding, free);
705out_unlock: 705out_unlock:
706 spin_unlock(&dbg_lock); 706 spin_unlock(&dbg_lock);
@@ -720,11 +720,11 @@ void dbg_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
720 dark = ubifs_calc_dark(c, spc); 720 dark = ubifs_calc_dark(c, spc);
721 721
722 if (lp->flags & LPROPS_INDEX) 722 if (lp->flags & LPROPS_INDEX)
723 printk(KERN_DEBUG "LEB %-7d free %-8d dirty %-8d used %-8d " 723 printk(KERN_ERR "LEB %-7d free %-8d dirty %-8d used %-8d "
724 "free + dirty %-8d flags %#x (", lp->lnum, lp->free, 724 "free + dirty %-8d flags %#x (", lp->lnum, lp->free,
725 lp->dirty, c->leb_size - spc, spc, lp->flags); 725 lp->dirty, c->leb_size - spc, spc, lp->flags);
726 else 726 else
727 printk(KERN_DEBUG "LEB %-7d free %-8d dirty %-8d used %-8d " 727 printk(KERN_ERR "LEB %-7d free %-8d dirty %-8d used %-8d "
728 "free + dirty %-8d dark %-4d dead %-4d nodes fit %-3d " 728 "free + dirty %-8d dark %-4d dead %-4d nodes fit %-3d "
729 "flags %#-4x (", lp->lnum, lp->free, lp->dirty, 729 "flags %#-4x (", lp->lnum, lp->free, lp->dirty,
730 c->leb_size - spc, spc, dark, dead, 730 c->leb_size - spc, spc, dark, dead,
@@ -807,7 +807,7 @@ void dbg_dump_lprops(struct ubifs_info *c)
807 struct ubifs_lprops lp; 807 struct ubifs_lprops lp;
808 struct ubifs_lp_stats lst; 808 struct ubifs_lp_stats lst;
809 809
810 printk(KERN_DEBUG "(pid %d) start dumping LEB properties\n", 810 printk(KERN_ERR "(pid %d) start dumping LEB properties\n",
811 current->pid); 811 current->pid);
812 ubifs_get_lp_stats(c, &lst); 812 ubifs_get_lp_stats(c, &lst);
813 dbg_dump_lstats(&lst); 813 dbg_dump_lstats(&lst);
@@ -819,7 +819,7 @@ void dbg_dump_lprops(struct ubifs_info *c)
819 819
820 dbg_dump_lprop(c, &lp); 820 dbg_dump_lprop(c, &lp);
821 } 821 }
822 printk(KERN_DEBUG "(pid %d) finish dumping LEB properties\n", 822 printk(KERN_ERR "(pid %d) finish dumping LEB properties\n",
823 current->pid); 823 current->pid);
824} 824}
825 825
@@ -828,35 +828,35 @@ void dbg_dump_lpt_info(struct ubifs_info *c)
828 int i; 828 int i;
829 829
830 spin_lock(&dbg_lock); 830 spin_lock(&dbg_lock);
831 printk(KERN_DEBUG "(pid %d) dumping LPT information\n", current->pid); 831 printk(KERN_ERR "(pid %d) dumping LPT information\n", current->pid);
832 printk(KERN_DEBUG "\tlpt_sz: %lld\n", c->lpt_sz); 832 printk(KERN_ERR "\tlpt_sz: %lld\n", c->lpt_sz);
833 printk(KERN_DEBUG "\tpnode_sz: %d\n", c->pnode_sz); 833 printk(KERN_ERR "\tpnode_sz: %d\n", c->pnode_sz);
834 printk(KERN_DEBUG "\tnnode_sz: %d\n", c->nnode_sz); 834 printk(KERN_ERR "\tnnode_sz: %d\n", c->nnode_sz);
835 printk(KERN_DEBUG "\tltab_sz: %d\n", c->ltab_sz); 835 printk(KERN_ERR "\tltab_sz: %d\n", c->ltab_sz);
836 printk(KERN_DEBUG "\tlsave_sz: %d\n", c->lsave_sz); 836 printk(KERN_ERR "\tlsave_sz: %d\n", c->lsave_sz);
837 printk(KERN_DEBUG "\tbig_lpt: %d\n", c->big_lpt); 837 printk(KERN_ERR "\tbig_lpt: %d\n", c->big_lpt);
838 printk(KERN_DEBUG "\tlpt_hght: %d\n", c->lpt_hght); 838 printk(KERN_ERR "\tlpt_hght: %d\n", c->lpt_hght);
839 printk(KERN_DEBUG "\tpnode_cnt: %d\n", c->pnode_cnt); 839 printk(KERN_ERR "\tpnode_cnt: %d\n", c->pnode_cnt);
840 printk(KERN_DEBUG "\tnnode_cnt: %d\n", c->nnode_cnt); 840 printk(KERN_ERR "\tnnode_cnt: %d\n", c->nnode_cnt);
841 printk(KERN_DEBUG "\tdirty_pn_cnt: %d\n", c->dirty_pn_cnt); 841 printk(KERN_ERR "\tdirty_pn_cnt: %d\n", c->dirty_pn_cnt);
842 printk(KERN_DEBUG "\tdirty_nn_cnt: %d\n", c->dirty_nn_cnt); 842 printk(KERN_ERR "\tdirty_nn_cnt: %d\n", c->dirty_nn_cnt);
843 printk(KERN_DEBUG "\tlsave_cnt: %d\n", c->lsave_cnt); 843 printk(KERN_ERR "\tlsave_cnt: %d\n", c->lsave_cnt);
844 printk(KERN_DEBUG "\tspace_bits: %d\n", c->space_bits); 844 printk(KERN_ERR "\tspace_bits: %d\n", c->space_bits);
845 printk(KERN_DEBUG "\tlpt_lnum_bits: %d\n", c->lpt_lnum_bits); 845 printk(KERN_ERR "\tlpt_lnum_bits: %d\n", c->lpt_lnum_bits);
846 printk(KERN_DEBUG "\tlpt_offs_bits: %d\n", c->lpt_offs_bits); 846 printk(KERN_ERR "\tlpt_offs_bits: %d\n", c->lpt_offs_bits);
847 printk(KERN_DEBUG "\tlpt_spc_bits: %d\n", c->lpt_spc_bits); 847 printk(KERN_ERR "\tlpt_spc_bits: %d\n", c->lpt_spc_bits);
848 printk(KERN_DEBUG "\tpcnt_bits: %d\n", c->pcnt_bits); 848 printk(KERN_ERR "\tpcnt_bits: %d\n", c->pcnt_bits);
849 printk(KERN_DEBUG "\tlnum_bits: %d\n", c->lnum_bits); 849 printk(KERN_ERR "\tlnum_bits: %d\n", c->lnum_bits);
850 printk(KERN_DEBUG "\tLPT root is at %d:%d\n", c->lpt_lnum, c->lpt_offs); 850 printk(KERN_ERR "\tLPT root is at %d:%d\n", c->lpt_lnum, c->lpt_offs);
851 printk(KERN_DEBUG "\tLPT head is at %d:%d\n", 851 printk(KERN_ERR "\tLPT head is at %d:%d\n",
852 c->nhead_lnum, c->nhead_offs); 852 c->nhead_lnum, c->nhead_offs);
853 printk(KERN_DEBUG "\tLPT ltab is at %d:%d\n", 853 printk(KERN_ERR "\tLPT ltab is at %d:%d\n",
854 c->ltab_lnum, c->ltab_offs); 854 c->ltab_lnum, c->ltab_offs);
855 if (c->big_lpt) 855 if (c->big_lpt)
856 printk(KERN_DEBUG "\tLPT lsave is at %d:%d\n", 856 printk(KERN_ERR "\tLPT lsave is at %d:%d\n",
857 c->lsave_lnum, c->lsave_offs); 857 c->lsave_lnum, c->lsave_offs);
858 for (i = 0; i < c->lpt_lebs; i++) 858 for (i = 0; i < c->lpt_lebs; i++)
859 printk(KERN_DEBUG "\tLPT LEB %d free %d dirty %d tgc %d " 859 printk(KERN_ERR "\tLPT LEB %d free %d dirty %d tgc %d "
860 "cmt %d\n", i + c->lpt_first, c->ltab[i].free, 860 "cmt %d\n", i + c->lpt_first, c->ltab[i].free,
861 c->ltab[i].dirty, c->ltab[i].tgc, c->ltab[i].cmt); 861 c->ltab[i].dirty, c->ltab[i].tgc, c->ltab[i].cmt);
862 spin_unlock(&dbg_lock); 862 spin_unlock(&dbg_lock);
@@ -867,12 +867,12 @@ void dbg_dump_sleb(const struct ubifs_info *c,
867{ 867{
868 struct ubifs_scan_node *snod; 868 struct ubifs_scan_node *snod;
869 869
870 printk(KERN_DEBUG "(pid %d) start dumping scanned data from LEB %d:%d\n", 870 printk(KERN_ERR "(pid %d) start dumping scanned data from LEB %d:%d\n",
871 current->pid, sleb->lnum, offs); 871 current->pid, sleb->lnum, offs);
872 872
873 list_for_each_entry(snod, &sleb->nodes, list) { 873 list_for_each_entry(snod, &sleb->nodes, list) {
874 cond_resched(); 874 cond_resched();
875 printk(KERN_DEBUG "Dumping node at LEB %d:%d len %d\n", sleb->lnum, 875 printk(KERN_ERR "Dumping node at LEB %d:%d len %d\n", sleb->lnum,
876 snod->offs, snod->len); 876 snod->offs, snod->len);
877 dbg_dump_node(c, snod->node); 877 dbg_dump_node(c, snod->node);
878 } 878 }
@@ -887,7 +887,7 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum)
887 if (dbg_is_tst_rcvry(c)) 887 if (dbg_is_tst_rcvry(c))
888 return; 888 return;
889 889
890 printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n", 890 printk(KERN_ERR "(pid %d) start dumping LEB %d\n",
891 current->pid, lnum); 891 current->pid, lnum);
892 892
893 buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL); 893 buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
@@ -902,17 +902,17 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum)
902 goto out; 902 goto out;
903 } 903 }
904 904
905 printk(KERN_DEBUG "LEB %d has %d nodes ending at %d\n", lnum, 905 printk(KERN_ERR "LEB %d has %d nodes ending at %d\n", lnum,
906 sleb->nodes_cnt, sleb->endpt); 906 sleb->nodes_cnt, sleb->endpt);
907 907
908 list_for_each_entry(snod, &sleb->nodes, list) { 908 list_for_each_entry(snod, &sleb->nodes, list) {
909 cond_resched(); 909 cond_resched();
910 printk(KERN_DEBUG "Dumping node at LEB %d:%d len %d\n", lnum, 910 printk(KERN_ERR "Dumping node at LEB %d:%d len %d\n", lnum,
911 snod->offs, snod->len); 911 snod->offs, snod->len);
912 dbg_dump_node(c, snod->node); 912 dbg_dump_node(c, snod->node);
913 } 913 }
914 914
915 printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n", 915 printk(KERN_ERR "(pid %d) finish dumping LEB %d\n",
916 current->pid, lnum); 916 current->pid, lnum);
917 ubifs_scan_destroy(sleb); 917 ubifs_scan_destroy(sleb);
918 918
@@ -934,7 +934,7 @@ void dbg_dump_znode(const struct ubifs_info *c,
934 else 934 else
935 zbr = &c->zroot; 935 zbr = &c->zroot;
936 936
937 printk(KERN_DEBUG "znode %p, LEB %d:%d len %d parent %p iip %d level %d" 937 printk(KERN_ERR "znode %p, LEB %d:%d len %d parent %p iip %d level %d"
938 " child_cnt %d flags %lx\n", znode, zbr->lnum, zbr->offs, 938 " child_cnt %d flags %lx\n", znode, zbr->lnum, zbr->offs,
939 zbr->len, znode->parent, znode->iip, znode->level, 939 zbr->len, znode->parent, znode->iip, znode->level,
940 znode->child_cnt, znode->flags); 940 znode->child_cnt, znode->flags);
@@ -944,18 +944,18 @@ void dbg_dump_znode(const struct ubifs_info *c,
944 return; 944 return;
945 } 945 }
946 946
947 printk(KERN_DEBUG "zbranches:\n"); 947 printk(KERN_ERR "zbranches:\n");
948 for (n = 0; n < znode->child_cnt; n++) { 948 for (n = 0; n < znode->child_cnt; n++) {
949 zbr = &znode->zbranch[n]; 949 zbr = &znode->zbranch[n];
950 if (znode->level > 0) 950 if (znode->level > 0)
951 printk(KERN_DEBUG "\t%d: znode %p LEB %d:%d len %d key " 951 printk(KERN_ERR "\t%d: znode %p LEB %d:%d len %d key "
952 "%s\n", n, zbr->znode, zbr->lnum, 952 "%s\n", n, zbr->znode, zbr->lnum,
953 zbr->offs, zbr->len, 953 zbr->offs, zbr->len,
954 dbg_snprintf_key(c, &zbr->key, 954 dbg_snprintf_key(c, &zbr->key,
955 key_buf, 955 key_buf,
956 DBG_KEY_BUF_LEN)); 956 DBG_KEY_BUF_LEN));
957 else 957 else
958 printk(KERN_DEBUG "\t%d: LNC %p LEB %d:%d len %d key " 958 printk(KERN_ERR "\t%d: LNC %p LEB %d:%d len %d key "
959 "%s\n", n, zbr->znode, zbr->lnum, 959 "%s\n", n, zbr->znode, zbr->lnum,
960 zbr->offs, zbr->len, 960 zbr->offs, zbr->len,
961 dbg_snprintf_key(c, &zbr->key, 961 dbg_snprintf_key(c, &zbr->key,
@@ -969,16 +969,16 @@ void dbg_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
969{ 969{
970 int i; 970 int i;
971 971
972 printk(KERN_DEBUG "(pid %d) start dumping heap cat %d (%d elements)\n", 972 printk(KERN_ERR "(pid %d) start dumping heap cat %d (%d elements)\n",
973 current->pid, cat, heap->cnt); 973 current->pid, cat, heap->cnt);
974 for (i = 0; i < heap->cnt; i++) { 974 for (i = 0; i < heap->cnt; i++) {
975 struct ubifs_lprops *lprops = heap->arr[i]; 975 struct ubifs_lprops *lprops = heap->arr[i];
976 976
977 printk(KERN_DEBUG "\t%d. LEB %d hpos %d free %d dirty %d " 977 printk(KERN_ERR "\t%d. LEB %d hpos %d free %d dirty %d "
978 "flags %d\n", i, lprops->lnum, lprops->hpos, 978 "flags %d\n", i, lprops->lnum, lprops->hpos,
979 lprops->free, lprops->dirty, lprops->flags); 979 lprops->free, lprops->dirty, lprops->flags);
980 } 980 }
981 printk(KERN_DEBUG "(pid %d) finish dumping heap\n", current->pid); 981 printk(KERN_ERR "(pid %d) finish dumping heap\n", current->pid);
982} 982}
983 983
984void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, 984void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
@@ -986,15 +986,15 @@ void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
986{ 986{
987 int i; 987 int i;
988 988
989 printk(KERN_DEBUG "(pid %d) dumping pnode:\n", current->pid); 989 printk(KERN_ERR "(pid %d) dumping pnode:\n", current->pid);
990 printk(KERN_DEBUG "\taddress %zx parent %zx cnext %zx\n", 990 printk(KERN_ERR "\taddress %zx parent %zx cnext %zx\n",
991 (size_t)pnode, (size_t)parent, (size_t)pnode->cnext); 991 (size_t)pnode, (size_t)parent, (size_t)pnode->cnext);
992 printk(KERN_DEBUG "\tflags %lu iip %d level %d num %d\n", 992 printk(KERN_ERR "\tflags %lu iip %d level %d num %d\n",
993 pnode->flags, iip, pnode->level, pnode->num); 993 pnode->flags, iip, pnode->level, pnode->num);
994 for (i = 0; i < UBIFS_LPT_FANOUT; i++) { 994 for (i = 0; i < UBIFS_LPT_FANOUT; i++) {
995 struct ubifs_lprops *lp = &pnode->lprops[i]; 995 struct ubifs_lprops *lp = &pnode->lprops[i];
996 996
997 printk(KERN_DEBUG "\t%d: free %d dirty %d flags %d lnum %d\n", 997 printk(KERN_ERR "\t%d: free %d dirty %d flags %d lnum %d\n",
998 i, lp->free, lp->dirty, lp->flags, lp->lnum); 998 i, lp->free, lp->dirty, lp->flags, lp->lnum);
999 } 999 }
1000} 1000}
@@ -1004,20 +1004,20 @@ void dbg_dump_tnc(struct ubifs_info *c)
1004 struct ubifs_znode *znode; 1004 struct ubifs_znode *znode;
1005 int level; 1005 int level;
1006 1006
1007 printk(KERN_DEBUG "\n"); 1007 printk(KERN_ERR "\n");
1008 printk(KERN_DEBUG "(pid %d) start dumping TNC tree\n", current->pid); 1008 printk(KERN_ERR "(pid %d) start dumping TNC tree\n", current->pid);
1009 znode = ubifs_tnc_levelorder_next(c->zroot.znode, NULL); 1009 znode = ubifs_tnc_levelorder_next(c->zroot.znode, NULL);
1010 level = znode->level; 1010 level = znode->level;
1011 printk(KERN_DEBUG "== Level %d ==\n", level); 1011 printk(KERN_ERR "== Level %d ==\n", level);
1012 while (znode) { 1012 while (znode) {
1013 if (level != znode->level) { 1013 if (level != znode->level) {
1014 level = znode->level; 1014 level = znode->level;
1015 printk(KERN_DEBUG "== Level %d ==\n", level); 1015 printk(KERN_ERR "== Level %d ==\n", level);
1016 } 1016 }
1017 dbg_dump_znode(c, znode); 1017 dbg_dump_znode(c, znode);
1018 znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode); 1018 znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode);
1019 } 1019 }
1020 printk(KERN_DEBUG "(pid %d) finish dumping TNC tree\n", current->pid); 1020 printk(KERN_ERR "(pid %d) finish dumping TNC tree\n", current->pid);
1021} 1021}
1022 1022
1023static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode, 1023static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h
index ad1a6fee6010..9f717655df18 100644
--- a/fs/ubifs/debug.h
+++ b/fs/ubifs/debug.h
@@ -164,9 +164,7 @@ struct ubifs_global_debug_info {
164#define dbg_dump_stack() dump_stack() 164#define dbg_dump_stack() dump_stack()
165 165
166#define dbg_err(fmt, ...) do { \ 166#define dbg_err(fmt, ...) do { \
167 spin_lock(&dbg_lock); \
168 ubifs_err(fmt, ##__VA_ARGS__); \ 167 ubifs_err(fmt, ##__VA_ARGS__); \
169 spin_unlock(&dbg_lock); \
170} while (0) 168} while (0)
171 169
172#define ubifs_dbg_msg(type, fmt, ...) \ 170#define ubifs_dbg_msg(type, fmt, ...) \
@@ -217,7 +215,6 @@ struct ubifs_global_debug_info {
217/* Additional recovery messages */ 215/* Additional recovery messages */
218#define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__) 216#define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__)
219 217
220extern spinlock_t dbg_lock;
221extern struct ubifs_global_debug_info ubifs_dbg; 218extern struct ubifs_global_debug_info ubifs_dbg;
222 219
223static inline int dbg_is_chk_gen(const struct ubifs_info *c) 220static inline int dbg_is_chk_gen(const struct ubifs_info *c)
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index d6fe1c79f18b..ec9f1870ab7f 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -566,6 +566,7 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
566 int sz_change = CALC_DENT_SIZE(dentry->d_name.len); 566 int sz_change = CALC_DENT_SIZE(dentry->d_name.len);
567 int err, budgeted = 1; 567 int err, budgeted = 1;
568 struct ubifs_budget_req req = { .mod_dent = 1, .dirtied_ino = 2 }; 568 struct ubifs_budget_req req = { .mod_dent = 1, .dirtied_ino = 2 };
569 unsigned int saved_nlink = inode->i_nlink;
569 570
570 /* 571 /*
571 * Budget request settings: deletion direntry, deletion inode (+1 for 572 * Budget request settings: deletion direntry, deletion inode (+1 for
@@ -613,7 +614,7 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
613out_cancel: 614out_cancel:
614 dir->i_size += sz_change; 615 dir->i_size += sz_change;
615 dir_ui->ui_size = dir->i_size; 616 dir_ui->ui_size = dir->i_size;
616 inc_nlink(inode); 617 set_nlink(inode, saved_nlink);
617 unlock_2_inodes(dir, inode); 618 unlock_2_inodes(dir, inode);
618 if (budgeted) 619 if (budgeted)
619 ubifs_release_budget(c, &req); 620 ubifs_release_budget(c, &req);
@@ -704,8 +705,7 @@ out_cancel:
704 dir->i_size += sz_change; 705 dir->i_size += sz_change;
705 dir_ui->ui_size = dir->i_size; 706 dir_ui->ui_size = dir->i_size;
706 inc_nlink(dir); 707 inc_nlink(dir);
707 inc_nlink(inode); 708 set_nlink(inode, 2);
708 inc_nlink(inode);
709 unlock_2_inodes(dir, inode); 709 unlock_2_inodes(dir, inode);
710 if (budgeted) 710 if (budgeted)
711 ubifs_release_budget(c, &req); 711 ubifs_release_budget(c, &req);
@@ -977,6 +977,7 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
977 struct ubifs_budget_req ino_req = { .dirtied_ino = 1, 977 struct ubifs_budget_req ino_req = { .dirtied_ino = 1,
978 .dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) }; 978 .dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) };
979 struct timespec time; 979 struct timespec time;
980 unsigned int saved_nlink;
980 981
981 /* 982 /*
982 * Budget request settings: deletion direntry, new direntry, removing 983 * Budget request settings: deletion direntry, new direntry, removing
@@ -1059,13 +1060,14 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
1059 if (unlink) { 1060 if (unlink) {
1060 /* 1061 /*
1061 * Directories cannot have hard-links, so if this is a 1062 * Directories cannot have hard-links, so if this is a
1062 * directory, decrement its @i_nlink twice because an empty 1063 * directory, just clear @i_nlink.
1063 * directory has @i_nlink 2.
1064 */ 1064 */
1065 saved_nlink = new_inode->i_nlink;
1065 if (is_dir) 1066 if (is_dir)
1067 clear_nlink(new_inode);
1068 else
1066 drop_nlink(new_inode); 1069 drop_nlink(new_inode);
1067 new_inode->i_ctime = time; 1070 new_inode->i_ctime = time;
1068 drop_nlink(new_inode);
1069 } else { 1071 } else {
1070 new_dir->i_size += new_sz; 1072 new_dir->i_size += new_sz;
1071 ubifs_inode(new_dir)->ui_size = new_dir->i_size; 1073 ubifs_inode(new_dir)->ui_size = new_dir->i_size;
@@ -1102,9 +1104,7 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
1102 1104
1103out_cancel: 1105out_cancel:
1104 if (unlink) { 1106 if (unlink) {
1105 if (is_dir) 1107 set_nlink(new_inode, saved_nlink);
1106 inc_nlink(new_inode);
1107 inc_nlink(new_inode);
1108 } else { 1108 } else {
1109 new_dir->i_size -= new_sz; 1109 new_dir->i_size -= new_sz;
1110 ubifs_inode(new_dir)->ui_size = new_dir->i_size; 1110 ubifs_inode(new_dir)->ui_size = new_dir->i_size;
diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c
index ee4f43f4bb99..2a935b317232 100644
--- a/fs/ubifs/recovery.c
+++ b/fs/ubifs/recovery.c
@@ -679,7 +679,8 @@ struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,
679 ret == SCANNED_GARBAGE || 679 ret == SCANNED_GARBAGE ||
680 ret == SCANNED_A_BAD_PAD_NODE || 680 ret == SCANNED_A_BAD_PAD_NODE ||
681 ret == SCANNED_A_CORRUPT_NODE) { 681 ret == SCANNED_A_CORRUPT_NODE) {
682 dbg_rcvry("found corruption - %d", ret); 682 dbg_rcvry("found corruption (%d) at %d:%d",
683 ret, lnum, offs);
683 break; 684 break;
684 } else { 685 } else {
685 dbg_err("unexpected return value %d", ret); 686 dbg_err("unexpected return value %d", ret);
diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c
index 6094c5a5d7a8..771f7fb6ce92 100644
--- a/fs/ubifs/sb.c
+++ b/fs/ubifs/sb.c
@@ -410,13 +410,23 @@ static int validate_sb(struct ubifs_info *c, struct ubifs_sb_node *sup)
410 } 410 }
411 411
412 if (c->main_lebs < UBIFS_MIN_MAIN_LEBS) { 412 if (c->main_lebs < UBIFS_MIN_MAIN_LEBS) {
413 err = 7; 413 ubifs_err("too few main LEBs count %d, must be at least %d",
414 c->main_lebs, UBIFS_MIN_MAIN_LEBS);
414 goto failed; 415 goto failed;
415 } 416 }
416 417
417 if (c->max_bud_bytes < (long long)c->leb_size * UBIFS_MIN_BUD_LEBS || 418 max_bytes = (long long)c->leb_size * UBIFS_MIN_BUD_LEBS;
418 c->max_bud_bytes > (long long)c->leb_size * c->main_lebs) { 419 if (c->max_bud_bytes < max_bytes) {
419 err = 8; 420 ubifs_err("too small journal (%lld bytes), must be at least "
421 "%lld bytes", c->max_bud_bytes, max_bytes);
422 goto failed;
423 }
424
425 max_bytes = (long long)c->leb_size * c->main_lebs;
426 if (c->max_bud_bytes > max_bytes) {
427 ubifs_err("too large journal size (%lld bytes), only %lld bytes"
428 "available in the main area",
429 c->max_bud_bytes, max_bytes);
420 goto failed; 430 goto failed;
421 } 431 }
422 432
@@ -450,7 +460,6 @@ static int validate_sb(struct ubifs_info *c, struct ubifs_sb_node *sup)
450 goto failed; 460 goto failed;
451 } 461 }
452 462
453 max_bytes = c->main_lebs * (long long)c->leb_size;
454 if (c->rp_size < 0 || max_bytes < c->rp_size) { 463 if (c->rp_size < 0 || max_bytes < c->rp_size) {
455 err = 14; 464 err = 14;
456 goto failed; 465 goto failed;
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 12e94774aa88..93d59aceaaef 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -84,9 +84,6 @@
84#define INUM_WARN_WATERMARK 0xFFF00000 84#define INUM_WARN_WATERMARK 0xFFF00000
85#define INUM_WATERMARK 0xFFFFFF00 85#define INUM_WATERMARK 0xFFFFFF00
86 86
87/* Largest key size supported in this implementation */
88#define CUR_MAX_KEY_LEN UBIFS_SK_LEN
89
90/* Maximum number of entries in each LPT (LEB category) heap */ 87/* Maximum number of entries in each LPT (LEB category) heap */
91#define LPT_HEAP_SZ 256 88#define LPT_HEAP_SZ 256
92 89
@@ -277,10 +274,10 @@ struct ubifs_old_idx {
277 274
278/* The below union makes it easier to deal with keys */ 275/* The below union makes it easier to deal with keys */
279union ubifs_key { 276union ubifs_key {
280 uint8_t u8[CUR_MAX_KEY_LEN]; 277 uint8_t u8[UBIFS_SK_LEN];
281 uint32_t u32[CUR_MAX_KEY_LEN/4]; 278 uint32_t u32[UBIFS_SK_LEN/4];
282 uint64_t u64[CUR_MAX_KEY_LEN/8]; 279 uint64_t u64[UBIFS_SK_LEN/8];
283 __le32 j32[CUR_MAX_KEY_LEN/4]; 280 __le32 j32[UBIFS_SK_LEN/4];
284}; 281};
285 282
286/** 283/**