diff options
author | Jiaying Zhang <jiayingz@google.com> | 2010-07-20 10:54:43 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2010-07-21 10:05:58 -0400 |
commit | fb5ffb0e160c93c3fe08ab83845eb9a2768af812 (patch) | |
tree | 1f3488ab93f21a30f9a60f612de63adce3ce1599 /fs/quota/quota_tree.c | |
parent | 01971952582068c4eaaef7410f32d16daa178a0d (diff) |
quota: Change quota error message to print out disk and function name
The current quota error message doesn't always print the disk name, so
it is hard to identify the "bad" disk when quota error happens.
This patch changes the standardized quota error message to print out disk name
and function name. It also uses a combination of cpp macro and inline function
to provide better type checking and to lower the text size of the message.
[Jan Kara: Export __quota_error]
Signed-off-by: Jiaying Zhang <jiayingz@google.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota/quota_tree.c')
-rw-r--r-- | fs/quota/quota_tree.c | 85 |
1 files changed, 42 insertions, 43 deletions
diff --git a/fs/quota/quota_tree.c b/fs/quota/quota_tree.c index 24f03407eeb5..9e48874eabcc 100644 --- a/fs/quota/quota_tree.c +++ b/fs/quota/quota_tree.c | |||
@@ -65,8 +65,7 @@ static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf) | |||
65 | ret = sb->s_op->quota_write(sb, info->dqi_type, buf, | 65 | ret = sb->s_op->quota_write(sb, info->dqi_type, buf, |
66 | info->dqi_usable_bs, blk << info->dqi_blocksize_bits); | 66 | info->dqi_usable_bs, blk << info->dqi_blocksize_bits); |
67 | if (ret != info->dqi_usable_bs) { | 67 | if (ret != info->dqi_usable_bs) { |
68 | q_warn(KERN_WARNING "VFS: dquota write failed on " | 68 | quota_error(sb, "dquota write failed"); |
69 | "dev %s\n", sb->s_id); | ||
70 | if (ret >= 0) | 69 | if (ret >= 0) |
71 | ret = -EIO; | 70 | ret = -EIO; |
72 | } | 71 | } |
@@ -160,9 +159,8 @@ static int remove_free_dqentry(struct qtree_mem_dqinfo *info, char *buf, | |||
160 | dh->dqdh_next_free = dh->dqdh_prev_free = cpu_to_le32(0); | 159 | dh->dqdh_next_free = dh->dqdh_prev_free = cpu_to_le32(0); |
161 | /* No matter whether write succeeds block is out of list */ | 160 | /* No matter whether write succeeds block is out of list */ |
162 | if (write_blk(info, blk, buf) < 0) | 161 | if (write_blk(info, blk, buf) < 0) |
163 | q_warn(KERN_ERR | 162 | quota_error(info->dqi_sb, "Can't write block (%u) " |
164 | "VFS: Can't write block (%u) with free entries.\n", | 163 | "with free entries", blk); |
165 | blk); | ||
166 | return 0; | 164 | return 0; |
167 | out_buf: | 165 | out_buf: |
168 | kfree(tmpbuf); | 166 | kfree(tmpbuf); |
@@ -252,9 +250,8 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info, | |||
252 | if (le16_to_cpu(dh->dqdh_entries) + 1 >= qtree_dqstr_in_blk(info)) { | 250 | if (le16_to_cpu(dh->dqdh_entries) + 1 >= qtree_dqstr_in_blk(info)) { |
253 | *err = remove_free_dqentry(info, buf, blk); | 251 | *err = remove_free_dqentry(info, buf, blk); |
254 | if (*err < 0) { | 252 | if (*err < 0) { |
255 | q_warn(KERN_ERR "VFS: find_free_dqentry(): Can't " | 253 | quota_error(dquot->dq_sb, "Can't remove block (%u) " |
256 | "remove block (%u) from entry free list.\n", | 254 | "from entry free list", blk); |
257 | blk); | ||
258 | goto out_buf; | 255 | goto out_buf; |
259 | } | 256 | } |
260 | } | 257 | } |
@@ -268,16 +265,15 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info, | |||
268 | } | 265 | } |
269 | #ifdef __QUOTA_QT_PARANOIA | 266 | #ifdef __QUOTA_QT_PARANOIA |
270 | if (i == qtree_dqstr_in_blk(info)) { | 267 | if (i == qtree_dqstr_in_blk(info)) { |
271 | printk(KERN_ERR "VFS: find_free_dqentry(): Data block full " | 268 | quota_error(dquot->dq_sb, "Data block full but it shouldn't"); |
272 | "but it shouldn't.\n"); | ||
273 | *err = -EIO; | 269 | *err = -EIO; |
274 | goto out_buf; | 270 | goto out_buf; |
275 | } | 271 | } |
276 | #endif | 272 | #endif |
277 | *err = write_blk(info, blk, buf); | 273 | *err = write_blk(info, blk, buf); |
278 | if (*err < 0) { | 274 | if (*err < 0) { |
279 | q_warn(KERN_ERR "VFS: find_free_dqentry(): Can't write quota " | 275 | quota_error(dquot->dq_sb, "Can't write quota data block %u", |
280 | "data block %u.\n", blk); | 276 | blk); |
281 | goto out_buf; | 277 | goto out_buf; |
282 | } | 278 | } |
283 | dquot->dq_off = (blk << info->dqi_blocksize_bits) + | 279 | dquot->dq_off = (blk << info->dqi_blocksize_bits) + |
@@ -311,8 +307,8 @@ static int do_insert_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, | |||
311 | } else { | 307 | } else { |
312 | ret = read_blk(info, *treeblk, buf); | 308 | ret = read_blk(info, *treeblk, buf); |
313 | if (ret < 0) { | 309 | if (ret < 0) { |
314 | q_warn(KERN_ERR "VFS: Can't read tree quota block " | 310 | quota_error(dquot->dq_sb, "Can't read tree quota " |
315 | "%u.\n", *treeblk); | 311 | "block %u", *treeblk); |
316 | goto out_buf; | 312 | goto out_buf; |
317 | } | 313 | } |
318 | } | 314 | } |
@@ -323,9 +319,9 @@ static int do_insert_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, | |||
323 | if (depth == info->dqi_qtree_depth - 1) { | 319 | if (depth == info->dqi_qtree_depth - 1) { |
324 | #ifdef __QUOTA_QT_PARANOIA | 320 | #ifdef __QUOTA_QT_PARANOIA |
325 | if (newblk) { | 321 | if (newblk) { |
326 | printk(KERN_ERR "VFS: Inserting already present quota " | 322 | quota_error(dquot->dq_sb, "Inserting already present " |
327 | "entry (block %u).\n", | 323 | "quota entry (block %u)", |
328 | le32_to_cpu(ref[get_index(info, | 324 | le32_to_cpu(ref[get_index(info, |
329 | dquot->dq_id, depth)])); | 325 | dquot->dq_id, depth)])); |
330 | ret = -EIO; | 326 | ret = -EIO; |
331 | goto out_buf; | 327 | goto out_buf; |
@@ -373,8 +369,8 @@ int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) | |||
373 | if (!dquot->dq_off) { | 369 | if (!dquot->dq_off) { |
374 | ret = dq_insert_tree(info, dquot); | 370 | ret = dq_insert_tree(info, dquot); |
375 | if (ret < 0) { | 371 | if (ret < 0) { |
376 | q_warn(KERN_ERR "VFS: Error %zd occurred while " | 372 | quota_error(sb, "Error %zd occurred while creating " |
377 | "creating quota.\n", ret); | 373 | "quota", ret); |
378 | kfree(ddquot); | 374 | kfree(ddquot); |
379 | return ret; | 375 | return ret; |
380 | } | 376 | } |
@@ -385,8 +381,7 @@ int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) | |||
385 | ret = sb->s_op->quota_write(sb, type, ddquot, info->dqi_entry_size, | 381 | ret = sb->s_op->quota_write(sb, type, ddquot, info->dqi_entry_size, |
386 | dquot->dq_off); | 382 | dquot->dq_off); |
387 | if (ret != info->dqi_entry_size) { | 383 | if (ret != info->dqi_entry_size) { |
388 | q_warn(KERN_WARNING "VFS: dquota write failed on dev %s\n", | 384 | quota_error(sb, "dquota write failed"); |
389 | sb->s_id); | ||
390 | if (ret >= 0) | 385 | if (ret >= 0) |
391 | ret = -ENOSPC; | 386 | ret = -ENOSPC; |
392 | } else { | 387 | } else { |
@@ -410,14 +405,15 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot, | |||
410 | if (!buf) | 405 | if (!buf) |
411 | return -ENOMEM; | 406 | return -ENOMEM; |
412 | if (dquot->dq_off >> info->dqi_blocksize_bits != blk) { | 407 | if (dquot->dq_off >> info->dqi_blocksize_bits != blk) { |
413 | q_warn(KERN_ERR "VFS: Quota structure has offset to other " | 408 | quota_error(dquot->dq_sb, "Quota structure has offset to " |
414 | "block (%u) than it should (%u).\n", blk, | 409 | "other block (%u) than it should (%u)", blk, |
415 | (uint)(dquot->dq_off >> info->dqi_blocksize_bits)); | 410 | (uint)(dquot->dq_off >> info->dqi_blocksize_bits)); |
416 | goto out_buf; | 411 | goto out_buf; |
417 | } | 412 | } |
418 | ret = read_blk(info, blk, buf); | 413 | ret = read_blk(info, blk, buf); |
419 | if (ret < 0) { | 414 | if (ret < 0) { |
420 | q_warn(KERN_ERR "VFS: Can't read quota data block %u\n", blk); | 415 | quota_error(dquot->dq_sb, "Can't read quota data block %u", |
416 | blk); | ||
421 | goto out_buf; | 417 | goto out_buf; |
422 | } | 418 | } |
423 | dh = (struct qt_disk_dqdbheader *)buf; | 419 | dh = (struct qt_disk_dqdbheader *)buf; |
@@ -427,8 +423,8 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot, | |||
427 | if (ret >= 0) | 423 | if (ret >= 0) |
428 | ret = put_free_dqblk(info, buf, blk); | 424 | ret = put_free_dqblk(info, buf, blk); |
429 | if (ret < 0) { | 425 | if (ret < 0) { |
430 | q_warn(KERN_ERR "VFS: Can't move quota data block (%u) " | 426 | quota_error(dquot->dq_sb, "Can't move quota data block " |
431 | "to free list.\n", blk); | 427 | "(%u) to free list", blk); |
432 | goto out_buf; | 428 | goto out_buf; |
433 | } | 429 | } |
434 | } else { | 430 | } else { |
@@ -440,15 +436,15 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot, | |||
440 | /* Insert will write block itself */ | 436 | /* Insert will write block itself */ |
441 | ret = insert_free_dqentry(info, buf, blk); | 437 | ret = insert_free_dqentry(info, buf, blk); |
442 | if (ret < 0) { | 438 | if (ret < 0) { |
443 | q_warn(KERN_ERR "VFS: Can't insert quota data " | 439 | quota_error(dquot->dq_sb, "Can't insert quota " |
444 | "block (%u) to free entry list.\n", blk); | 440 | "data block (%u) to free entry list", blk); |
445 | goto out_buf; | 441 | goto out_buf; |
446 | } | 442 | } |
447 | } else { | 443 | } else { |
448 | ret = write_blk(info, blk, buf); | 444 | ret = write_blk(info, blk, buf); |
449 | if (ret < 0) { | 445 | if (ret < 0) { |
450 | q_warn(KERN_ERR "VFS: Can't write quota data " | 446 | quota_error(dquot->dq_sb, "Can't write quota " |
451 | "block %u\n", blk); | 447 | "data block %u", blk); |
452 | goto out_buf; | 448 | goto out_buf; |
453 | } | 449 | } |
454 | } | 450 | } |
@@ -472,7 +468,8 @@ static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, | |||
472 | return -ENOMEM; | 468 | return -ENOMEM; |
473 | ret = read_blk(info, *blk, buf); | 469 | ret = read_blk(info, *blk, buf); |
474 | if (ret < 0) { | 470 | if (ret < 0) { |
475 | q_warn(KERN_ERR "VFS: Can't read quota data block %u\n", *blk); | 471 | quota_error(dquot->dq_sb, "Can't read quota data " |
472 | "block %u", blk); | ||
476 | goto out_buf; | 473 | goto out_buf; |
477 | } | 474 | } |
478 | newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]); | 475 | newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]); |
@@ -496,8 +493,8 @@ static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, | |||
496 | } else { | 493 | } else { |
497 | ret = write_blk(info, *blk, buf); | 494 | ret = write_blk(info, *blk, buf); |
498 | if (ret < 0) | 495 | if (ret < 0) |
499 | q_warn(KERN_ERR "VFS: Can't write quota tree " | 496 | quota_error(dquot->dq_sb, "Can't write quota " |
500 | "block %u.\n", *blk); | 497 | "tree block %u", blk); |
501 | } | 498 | } |
502 | } | 499 | } |
503 | out_buf: | 500 | out_buf: |
@@ -529,7 +526,8 @@ static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info, | |||
529 | return -ENOMEM; | 526 | return -ENOMEM; |
530 | ret = read_blk(info, blk, buf); | 527 | ret = read_blk(info, blk, buf); |
531 | if (ret < 0) { | 528 | if (ret < 0) { |
532 | q_warn(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk); | 529 | quota_error(dquot->dq_sb, "Can't read quota tree " |
530 | "block %u", blk); | ||
533 | goto out_buf; | 531 | goto out_buf; |
534 | } | 532 | } |
535 | ddquot = buf + sizeof(struct qt_disk_dqdbheader); | 533 | ddquot = buf + sizeof(struct qt_disk_dqdbheader); |
@@ -539,8 +537,8 @@ static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info, | |||
539 | ddquot += info->dqi_entry_size; | 537 | ddquot += info->dqi_entry_size; |
540 | } | 538 | } |
541 | if (i == qtree_dqstr_in_blk(info)) { | 539 | if (i == qtree_dqstr_in_blk(info)) { |
542 | q_warn(KERN_ERR "VFS: Quota for id %u referenced " | 540 | quota_error(dquot->dq_sb, "Quota for id %u referenced " |
543 | "but not present.\n", dquot->dq_id); | 541 | "but not present", dquot->dq_id); |
544 | ret = -EIO; | 542 | ret = -EIO; |
545 | goto out_buf; | 543 | goto out_buf; |
546 | } else { | 544 | } else { |
@@ -564,7 +562,8 @@ static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info, | |||
564 | return -ENOMEM; | 562 | return -ENOMEM; |
565 | ret = read_blk(info, blk, buf); | 563 | ret = read_blk(info, blk, buf); |
566 | if (ret < 0) { | 564 | if (ret < 0) { |
567 | q_warn(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk); | 565 | quota_error(dquot->dq_sb, "Can't read quota tree block %u", |
566 | blk); | ||
568 | goto out_buf; | 567 | goto out_buf; |
569 | } | 568 | } |
570 | ret = 0; | 569 | ret = 0; |
@@ -598,7 +597,7 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) | |||
598 | #ifdef __QUOTA_QT_PARANOIA | 597 | #ifdef __QUOTA_QT_PARANOIA |
599 | /* Invalidated quota? */ | 598 | /* Invalidated quota? */ |
600 | if (!sb_dqopt(dquot->dq_sb)->files[type]) { | 599 | if (!sb_dqopt(dquot->dq_sb)->files[type]) { |
601 | printk(KERN_ERR "VFS: Quota invalidated while reading!\n"); | 600 | quota_error(sb, "Quota invalidated while reading!"); |
602 | return -EIO; | 601 | return -EIO; |
603 | } | 602 | } |
604 | #endif | 603 | #endif |
@@ -607,8 +606,8 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) | |||
607 | offset = find_dqentry(info, dquot); | 606 | offset = find_dqentry(info, dquot); |
608 | if (offset <= 0) { /* Entry not present? */ | 607 | if (offset <= 0) { /* Entry not present? */ |
609 | if (offset < 0) | 608 | if (offset < 0) |
610 | q_warn(KERN_ERR "VFS: Can't read quota " | 609 | quota_error(sb, "Can't read quota structure " |
611 | "structure for id %u.\n", dquot->dq_id); | 610 | "for id %u", dquot->dq_id); |
612 | dquot->dq_off = 0; | 611 | dquot->dq_off = 0; |
613 | set_bit(DQ_FAKE_B, &dquot->dq_flags); | 612 | set_bit(DQ_FAKE_B, &dquot->dq_flags); |
614 | memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk)); | 613 | memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk)); |
@@ -625,8 +624,8 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) | |||
625 | if (ret != info->dqi_entry_size) { | 624 | if (ret != info->dqi_entry_size) { |
626 | if (ret >= 0) | 625 | if (ret >= 0) |
627 | ret = -EIO; | 626 | ret = -EIO; |
628 | q_warn(KERN_ERR "VFS: Error while reading quota " | 627 | quota_error(sb, "Error while reading quota structure for id %u", |
629 | "structure for id %u.\n", dquot->dq_id); | 628 | dquot->dq_id); |
630 | set_bit(DQ_FAKE_B, &dquot->dq_flags); | 629 | set_bit(DQ_FAKE_B, &dquot->dq_flags); |
631 | memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk)); | 630 | memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk)); |
632 | kfree(ddquot); | 631 | kfree(ddquot); |