diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2008-09-01 06:32:13 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2008-09-01 06:32:13 -0400 |
commit | 9d7548d4ca3c52ecb58f098a32b0756cdf8f96ee (patch) | |
tree | 651f7058bbaa2d8b2855286380d614afcf505118 /fs/ubifs/budget.c | |
parent | 31db6e9ea1dbdcf66b8227b4f7035dee1b1dd8c0 (diff) | |
parent | bef69ea0dcce574a425feb0a5aa4c63dd108b9a6 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'fs/ubifs/budget.c')
-rw-r--r-- | fs/ubifs/budget.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c index d81fb9ed2b8e..154098157473 100644 --- a/fs/ubifs/budget.c +++ b/fs/ubifs/budget.c | |||
@@ -263,8 +263,8 @@ int ubifs_calc_min_idx_lebs(struct ubifs_info *c) | |||
263 | 263 | ||
264 | idx_size = c->old_idx_sz + c->budg_idx_growth + c->budg_uncommitted_idx; | 264 | idx_size = c->old_idx_sz + c->budg_idx_growth + c->budg_uncommitted_idx; |
265 | 265 | ||
266 | /* And make sure we have twice the index size of space reserved */ | 266 | /* And make sure we have thrice the index size of space reserved */ |
267 | idx_size <<= 1; | 267 | idx_size = idx_size + (idx_size << 1); |
268 | 268 | ||
269 | /* | 269 | /* |
270 | * We do not maintain 'old_idx_size' as 'old_idx_lebs'/'old_idx_bytes' | 270 | * We do not maintain 'old_idx_size' as 'old_idx_lebs'/'old_idx_bytes' |
@@ -388,11 +388,11 @@ static int can_use_rp(struct ubifs_info *c) | |||
388 | * This function makes sure UBIFS has enough free eraseblocks for index growth | 388 | * This function makes sure UBIFS has enough free eraseblocks for index growth |
389 | * and data. | 389 | * and data. |
390 | * | 390 | * |
391 | * When budgeting index space, UBIFS reserves twice as more LEBs as the index | 391 | * When budgeting index space, UBIFS reserves thrice as many LEBs as the index |
392 | * would take if it was consolidated and written to the flash. This guarantees | 392 | * would take if it was consolidated and written to the flash. This guarantees |
393 | * that the "in-the-gaps" commit method always succeeds and UBIFS will always | 393 | * that the "in-the-gaps" commit method always succeeds and UBIFS will always |
394 | * be able to commit dirty index. So this function basically adds amount of | 394 | * be able to commit dirty index. So this function basically adds amount of |
395 | * budgeted index space to the size of the current index, multiplies this by 2, | 395 | * budgeted index space to the size of the current index, multiplies this by 3, |
396 | * and makes sure this does not exceed the amount of free eraseblocks. | 396 | * and makes sure this does not exceed the amount of free eraseblocks. |
397 | * | 397 | * |
398 | * Notes about @c->min_idx_lebs and @c->lst.idx_lebs variables: | 398 | * Notes about @c->min_idx_lebs and @c->lst.idx_lebs variables: |
@@ -543,8 +543,16 @@ int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req) | |||
543 | int err, idx_growth, data_growth, dd_growth; | 543 | int err, idx_growth, data_growth, dd_growth; |
544 | struct retries_info ri; | 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 | ubifs_assert(req->dirtied_ino <= 4); | 552 | ubifs_assert(req->dirtied_ino <= 4); |
547 | ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4); | 553 | ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4); |
554 | ubifs_assert(!(req->new_ino_d & 7)); | ||
555 | ubifs_assert(!(req->dirtied_ino_d & 7)); | ||
548 | 556 | ||
549 | data_growth = calc_data_growth(c, req); | 557 | data_growth = calc_data_growth(c, req); |
550 | dd_growth = calc_dd_growth(c, req); | 558 | dd_growth = calc_dd_growth(c, req); |
@@ -618,8 +626,16 @@ again: | |||
618 | */ | 626 | */ |
619 | void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req) | 627 | void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req) |
620 | { | 628 | { |
629 | ubifs_assert(req->new_page <= 1); | ||
630 | ubifs_assert(req->dirtied_page <= 1); | ||
631 | ubifs_assert(req->new_dent <= 1); | ||
632 | ubifs_assert(req->mod_dent <= 1); | ||
633 | ubifs_assert(req->new_ino <= 1); | ||
634 | ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA); | ||
621 | ubifs_assert(req->dirtied_ino <= 4); | 635 | ubifs_assert(req->dirtied_ino <= 4); |
622 | ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4); | 636 | ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4); |
637 | ubifs_assert(!(req->new_ino_d & 7)); | ||
638 | ubifs_assert(!(req->dirtied_ino_d & 7)); | ||
623 | if (!req->recalculate) { | 639 | if (!req->recalculate) { |
624 | ubifs_assert(req->idx_growth >= 0); | 640 | ubifs_assert(req->idx_growth >= 0); |
625 | ubifs_assert(req->data_growth >= 0); | 641 | ubifs_assert(req->data_growth >= 0); |
@@ -647,7 +663,11 @@ void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req) | |||
647 | 663 | ||
648 | ubifs_assert(c->budg_idx_growth >= 0); | 664 | ubifs_assert(c->budg_idx_growth >= 0); |
649 | ubifs_assert(c->budg_data_growth >= 0); | 665 | ubifs_assert(c->budg_data_growth >= 0); |
666 | ubifs_assert(c->budg_dd_growth >= 0); | ||
650 | ubifs_assert(c->min_idx_lebs < c->main_lebs); | 667 | ubifs_assert(c->min_idx_lebs < c->main_lebs); |
668 | ubifs_assert(!(c->budg_idx_growth & 7)); | ||
669 | ubifs_assert(!(c->budg_data_growth & 7)); | ||
670 | ubifs_assert(!(c->budg_dd_growth & 7)); | ||
651 | spin_unlock(&c->space_lock); | 671 | spin_unlock(&c->space_lock); |
652 | } | 672 | } |
653 | 673 | ||
@@ -686,9 +706,10 @@ void ubifs_convert_page_budget(struct ubifs_info *c) | |||
686 | void ubifs_release_dirty_inode_budget(struct ubifs_info *c, | 706 | void ubifs_release_dirty_inode_budget(struct ubifs_info *c, |
687 | struct ubifs_inode *ui) | 707 | struct ubifs_inode *ui) |
688 | { | 708 | { |
689 | struct ubifs_budget_req req = {.dd_growth = c->inode_budget, | 709 | struct ubifs_budget_req req; |
690 | .dirtied_ino_d = ui->data_len}; | ||
691 | 710 | ||
711 | memset(&req, 0, sizeof(struct ubifs_budget_req)); | ||
712 | req.dd_growth = c->inode_budget + ALIGN(ui->data_len, 8); | ||
692 | ubifs_release_budget(c, &req); | 713 | ubifs_release_budget(c, &req); |
693 | } | 714 | } |
694 | 715 | ||