Skip to content

Commit a6dab66

Browse files
Zhihao Chengrichardweinberger
authored andcommitted
ubifs: Rectify space amount budget for mkdir/tmpfile operations
UBIFS should make sure the flash has enough space to store dirty (Data that is newer than disk) data (in memory), space budget is exactly designed to do that. If space budget calculates less data than we need, 'make_reservation()' will do more work(return -ENOSPC if no free space lelf, sometimes we can see "cannot reserve xxx bytes in jhead xxx, error -28" in ubifs error messages) with ubifs inodes locked, which may effect other syscalls. A simple way to decide how much space do we need when make a budget: See how much space is needed by 'make_reservation()' in ubifs_jnl_xxx() function according to corresponding operation. It's better to report ENOSPC in ubifs_budget_space(), as early as we can. Fixes: 474b937 ("ubifs: Implement O_TMPFILE") Fixes: 1e51764 ("UBIFS: add new flash file system") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent 60eb3b9 commit a6dab66

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

fs/ubifs/dir.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,15 +428,18 @@ static int ubifs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
428428
{
429429
struct inode *inode;
430430
struct ubifs_info *c = dir->i_sb->s_fs_info;
431-
struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1};
431+
struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
432+
.dirtied_ino = 1};
432433
struct ubifs_budget_req ino_req = { .dirtied_ino = 1 };
433434
struct ubifs_inode *ui;
434435
int err, instantiated = 0;
435436
struct fscrypt_name nm;
436437

437438
/*
438-
* Budget request settings: new dirty inode, new direntry,
439-
* budget for dirtied inode will be released via writeback.
439+
* Budget request settings: new inode, new direntry, changing the
440+
* parent directory inode.
441+
* Allocate budget separately for new dirtied inode, the budget will
442+
* be released via writeback.
440443
*/
441444

442445
dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
@@ -979,7 +982,8 @@ static int ubifs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
979982
struct ubifs_inode *dir_ui = ubifs_inode(dir);
980983
struct ubifs_info *c = dir->i_sb->s_fs_info;
981984
int err, sz_change;
982-
struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1 };
985+
struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
986+
.dirtied_ino = 1};
983987
struct fscrypt_name nm;
984988

985989
/*

0 commit comments

Comments
 (0)