Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 547000da authored by Artem Bityutskiy's avatar Artem Bityutskiy
Browse files

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: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent f7691084
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -543,6 +543,12 @@ int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req)
	int err, idx_growth, data_growth, dd_growth;
	int err, idx_growth, data_growth, dd_growth;
	struct retries_info ri;
	struct retries_info ri;


	ubifs_assert(req->new_page <= 1);
	ubifs_assert(req->dirtied_page <= 1);
	ubifs_assert(req->new_dent <= 1);
	ubifs_assert(req->mod_dent <= 1);
	ubifs_assert(req->new_ino <= 1);
	ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA);
	ubifs_assert(req->dirtied_ino <= 4);
	ubifs_assert(req->dirtied_ino <= 4);
	ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4);
	ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4);


@@ -618,6 +624,12 @@ int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req)
 */
 */
void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req)
void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req)
{
{
	ubifs_assert(req->new_page <= 1);
	ubifs_assert(req->dirtied_page <= 1);
	ubifs_assert(req->new_dent <= 1);
	ubifs_assert(req->mod_dent <= 1);
	ubifs_assert(req->new_ino <= 1);
	ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA);
	ubifs_assert(req->dirtied_ino <= 4);
	ubifs_assert(req->dirtied_ino <= 4);
	ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4);
	ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4);
	if (!req->recalculate) {
	if (!req->recalculate) {
+7 −1
Original line number Original line Diff line number Diff line
@@ -812,17 +812,23 @@ struct ubifs_compressor {
struct ubifs_budget_req {
struct ubifs_budget_req {
	unsigned int fast:1;
	unsigned int fast:1;
	unsigned int recalculate:1;
	unsigned int recalculate:1;
#ifndef UBIFS_DEBUG
	unsigned int new_page:1;
	unsigned int new_page:1;
	unsigned int dirtied_page:1;
	unsigned int dirtied_page:1;
	unsigned int new_dent:1;
	unsigned int new_dent:1;
	unsigned int mod_dent:1;
	unsigned int mod_dent:1;
	unsigned int new_ino:1;
	unsigned int new_ino:1;
	unsigned int new_ino_d:13;
	unsigned int new_ino_d:13;
#ifndef UBIFS_DEBUG
	unsigned int dirtied_ino:4;
	unsigned int dirtied_ino:4;
	unsigned int dirtied_ino_d:15;
	unsigned int dirtied_ino_d:15;
#else
#else
	/* Not bit-fields to check for overflows */
	/* Not bit-fields to check for overflows */
	unsigned int new_page;
	unsigned int dirtied_page;
	unsigned int new_dent;
	unsigned int mod_dent;
	unsigned int new_ino;
	unsigned int new_ino_d;
	unsigned int dirtied_ino;
	unsigned int dirtied_ino;
	unsigned int dirtied_ino_d;
	unsigned int dirtied_ino_d;
#endif
#endif