aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-07-24 07:52:45 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-08-13 04:35:16 -0400
commitdab4b4d2f915a65022343012a795f4ae4ae7e83c (patch)
tree13a1ec2c5f6b18781145bccddf2fb63017a1336b /fs
parent547000da6412c45456ff2ff44a171d01027bd727 (diff)
UBIFS: align inode data to eight
UBIFS aligns node lengths to 8, so budgeting has to do the same. Well, direntry, inode, and page budgets are already aligned, but not inode data budget (e.g., data in special devices or symlinks). Do this for inode data as well. Also, add corresponding debugging checks. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ubifs/budget.c10
-rw-r--r--fs/ubifs/dir.c10
-rw-r--r--fs/ubifs/file.c4
-rw-r--r--fs/ubifs/ubifs.h4
-rw-r--r--fs/ubifs/xattr.c4
5 files changed, 23 insertions, 9 deletions
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c
index f5afce5f37bd..a3978ba4215e 100644
--- a/fs/ubifs/budget.c
+++ b/fs/ubifs/budget.c
@@ -551,6 +551,8 @@ int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req)
551 ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA); 551 ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA);
552 ubifs_assert(req->dirtied_ino <= 4); 552 ubifs_assert(req->dirtied_ino <= 4);
553 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));
554 556
555 data_growth = calc_data_growth(c, req); 557 data_growth = calc_data_growth(c, req);
556 dd_growth = calc_dd_growth(c, req); 558 dd_growth = calc_dd_growth(c, req);
@@ -632,6 +634,8 @@ void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req)
632 ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA); 634 ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA);
633 ubifs_assert(req->dirtied_ino <= 4); 635 ubifs_assert(req->dirtied_ino <= 4);
634 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));
635 if (!req->recalculate) { 639 if (!req->recalculate) {
636 ubifs_assert(req->idx_growth >= 0); 640 ubifs_assert(req->idx_growth >= 0);
637 ubifs_assert(req->data_growth >= 0); 641 ubifs_assert(req->data_growth >= 0);
@@ -659,7 +663,11 @@ void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req)
659 663
660 ubifs_assert(c->budg_idx_growth >= 0); 664 ubifs_assert(c->budg_idx_growth >= 0);
661 ubifs_assert(c->budg_data_growth >= 0); 665 ubifs_assert(c->budg_data_growth >= 0);
666 ubifs_assert(c->budg_dd_growth >= 0);
662 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));
663 spin_unlock(&c->space_lock); 671 spin_unlock(&c->space_lock);
664} 672}
665 673
@@ -701,7 +709,7 @@ void ubifs_release_dirty_inode_budget(struct ubifs_info *c,
701 struct ubifs_budget_req req; 709 struct ubifs_budget_req req;
702 710
703 memset(&req, 0, sizeof(struct ubifs_budget_req)); 711 memset(&req, 0, sizeof(struct ubifs_budget_req));
704 req.dd_growth = c->inode_budget + ui->data_len; 712 req.dd_growth = c->inode_budget + ALIGN(ui->data_len, 8);
705 ubifs_release_budget(c, &req); 713 ubifs_release_budget(c, &req);
706} 714}
707 715
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index a79e850fee6d..eba3a8a7c333 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -525,7 +525,7 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
525 struct ubifs_inode *dir_ui = ubifs_inode(dir); 525 struct ubifs_inode *dir_ui = ubifs_inode(dir);
526 int err, sz_change = CALC_DENT_SIZE(dentry->d_name.len); 526 int err, sz_change = CALC_DENT_SIZE(dentry->d_name.len);
527 struct ubifs_budget_req req = { .new_dent = 1, .dirtied_ino = 2, 527 struct ubifs_budget_req req = { .new_dent = 1, .dirtied_ino = 2,
528 .dirtied_ino_d = ui->data_len }; 528 .dirtied_ino_d = ALIGN(ui->data_len, 8) };
529 529
530 /* 530 /*
531 * Budget request settings: new direntry, changing the target inode, 531 * Budget request settings: new direntry, changing the target inode,
@@ -788,7 +788,8 @@ static int ubifs_mknod(struct inode *dir, struct dentry *dentry,
788 int sz_change = CALC_DENT_SIZE(dentry->d_name.len); 788 int sz_change = CALC_DENT_SIZE(dentry->d_name.len);
789 int err, devlen = 0; 789 int err, devlen = 0;
790 struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1, 790 struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
791 .new_ino_d = devlen, .dirtied_ino = 1 }; 791 .new_ino_d = ALIGN(devlen, 8),
792 .dirtied_ino = 1 };
792 793
793 /* 794 /*
794 * Budget request settings: new inode, new direntry and changing parent 795 * Budget request settings: new inode, new direntry and changing parent
@@ -862,7 +863,8 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry,
862 int err, len = strlen(symname); 863 int err, len = strlen(symname);
863 int sz_change = CALC_DENT_SIZE(dentry->d_name.len); 864 int sz_change = CALC_DENT_SIZE(dentry->d_name.len);
864 struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1, 865 struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
865 .new_ino_d = len, .dirtied_ino = 1 }; 866 .new_ino_d = ALIGN(len, 8),
867 .dirtied_ino = 1 };
866 868
867 /* 869 /*
868 * Budget request settings: new inode, new direntry and changing parent 870 * Budget request settings: new inode, new direntry and changing parent
@@ -1011,7 +1013,7 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
1011 struct ubifs_budget_req req = { .new_dent = 1, .mod_dent = 1, 1013 struct ubifs_budget_req req = { .new_dent = 1, .mod_dent = 1,
1012 .dirtied_ino = 3 }; 1014 .dirtied_ino = 3 };
1013 struct ubifs_budget_req ino_req = { .dirtied_ino = 1, 1015 struct ubifs_budget_req ino_req = { .dirtied_ino = 1,
1014 .dirtied_ino_d = old_inode_ui->data_len }; 1016 .dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) };
1015 struct timespec time; 1017 struct timespec time;
1016 1018
1017 /* 1019 /*
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 01598f28020b..9fecab2f30bc 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -890,7 +890,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode,
890 loff_t new_size = attr->ia_size; 890 loff_t new_size = attr->ia_size;
891 struct ubifs_inode *ui = ubifs_inode(inode); 891 struct ubifs_inode *ui = ubifs_inode(inode);
892 struct ubifs_budget_req req = { .dirtied_ino = 1, 892 struct ubifs_budget_req req = { .dirtied_ino = 1,
893 .dirtied_ino_d = ui->data_len }; 893 .dirtied_ino_d = ALIGN(ui->data_len, 8) };
894 894
895 err = ubifs_budget_space(c, &req); 895 err = ubifs_budget_space(c, &req);
896 if (err) 896 if (err)
@@ -1052,7 +1052,7 @@ static int update_mctime(struct ubifs_info *c, struct inode *inode)
1052 if (mctime_update_needed(inode, &now)) { 1052 if (mctime_update_needed(inode, &now)) {
1053 int err, release; 1053 int err, release;
1054 struct ubifs_budget_req req = { .dirtied_ino = 1, 1054 struct ubifs_budget_req req = { .dirtied_ino = 1,
1055 .dirtied_ino_d = ui->data_len }; 1055 .dirtied_ino_d = ALIGN(ui->data_len, 8) };
1056 1056
1057 err = ubifs_budget_space(c, &req); 1057 err = ubifs_budget_space(c, &req);
1058 if (err) 1058 if (err)
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 565dca2ec0bd..73ca8a009798 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -808,6 +808,10 @@ struct ubifs_compressor {
808 * An inode may contain 4KiB of data at max., thus the widths of @new_ino_d 808 * An inode may contain 4KiB of data at max., thus the widths of @new_ino_d
809 * is 13 bits, and @dirtied_ino_d - 15, because up to 4 inodes may be made 809 * is 13 bits, and @dirtied_ino_d - 15, because up to 4 inodes may be made
810 * dirty by the re-name operation. 810 * dirty by the re-name operation.
811 *
812 * Note, UBIFS aligns node lengths to 8-bytes boundary, so the requester has to
813 * make sure the amount of inode data which contribute to @new_ino_d and
814 * @dirtied_ino_d fields are aligned.
811 */ 815 */
812struct ubifs_budget_req { 816struct ubifs_budget_req {
813 unsigned int fast:1; 817 unsigned int fast:1;
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index 1388a078e1a9..39e831d074ce 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -103,8 +103,8 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
103 struct inode *inode; 103 struct inode *inode;
104 struct ubifs_inode *ui, *host_ui = ubifs_inode(host); 104 struct ubifs_inode *ui, *host_ui = ubifs_inode(host);
105 struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1, 105 struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
106 .new_ino_d = size, .dirtied_ino = 1, 106 .new_ino_d = size, .dirtied_ino = 1,
107 .dirtied_ino_d = host_ui->data_len}; 107 .dirtied_ino_d = ALIGN(host_ui->data_len, 8)};
108 108
109 if (host_ui->xattr_cnt >= MAX_XATTRS_PER_INODE) 109 if (host_ui->xattr_cnt >= MAX_XATTRS_PER_INODE)
110 return -ENOSPC; 110 return -ENOSPC;