Commit 547000da6412c45456ff2ff44a171d01027bd727

Authored by Artem Bityutskiy
1 parent f769108424

UBIFS: improve budgeting checks

Budgeting is a crucial UBIFS subsystem - add more assertions
to improve requests checking. This is not compiled in when
UBIFS debugging is disabled.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

Showing 2 changed files with 19 additions and 1 deletions Side-by-side Diff

... ... @@ -543,6 +543,12 @@
543 543 int err, idx_growth, data_growth, dd_growth;
544 544 struct retries_info ri;
545 545  
  546 + ubifs_assert(req->new_page <= 1);
  547 + ubifs_assert(req->dirtied_page <= 1);
  548 + ubifs_assert(req->new_dent <= 1);
  549 + ubifs_assert(req->mod_dent <= 1);
  550 + ubifs_assert(req->new_ino <= 1);
  551 + ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA);
546 552 ubifs_assert(req->dirtied_ino <= 4);
547 553 ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4);
548 554  
... ... @@ -618,6 +624,12 @@
618 624 */
619 625 void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req)
620 626 {
  627 + ubifs_assert(req->new_page <= 1);
  628 + ubifs_assert(req->dirtied_page <= 1);
  629 + ubifs_assert(req->new_dent <= 1);
  630 + ubifs_assert(req->mod_dent <= 1);
  631 + ubifs_assert(req->new_ino <= 1);
  632 + ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA);
621 633 ubifs_assert(req->dirtied_ino <= 4);
622 634 ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4);
623 635 if (!req->recalculate) {
... ... @@ -812,17 +812,23 @@
812 812 struct ubifs_budget_req {
813 813 unsigned int fast:1;
814 814 unsigned int recalculate:1;
  815 +#ifndef UBIFS_DEBUG
815 816 unsigned int new_page:1;
816 817 unsigned int dirtied_page:1;
817 818 unsigned int new_dent:1;
818 819 unsigned int mod_dent:1;
819 820 unsigned int new_ino:1;
820 821 unsigned int new_ino_d:13;
821   -#ifndef UBIFS_DEBUG
822 822 unsigned int dirtied_ino:4;
823 823 unsigned int dirtied_ino_d:15;
824 824 #else
825 825 /* Not bit-fields to check for overflows */
  826 + unsigned int new_page;
  827 + unsigned int dirtied_page;
  828 + unsigned int new_dent;
  829 + unsigned int mod_dent;
  830 + unsigned int new_ino;
  831 + unsigned int new_ino_d;
826 832 unsigned int dirtied_ino;
827 833 unsigned int dirtied_ino_d;
828 834 #endif