forked from luck/tmp_suning_uos_patched
ubifs: Rectify space amount budget for mkdir/tmpfile operations
[ Upstream commit a6dab6607d4681d227905d5198710b575dbdb519 ] 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:474b93704f
("ubifs: Implement O_TMPFILE") Fixes:1e51764a3c
("UBIFS: add new flash file system") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
3238bffaf9
commit
2dc49f58a2
|
@ -353,15 +353,18 @@ static int do_tmpfile(struct inode *dir, struct dentry *dentry,
|
||||||
{
|
{
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct ubifs_info *c = dir->i_sb->s_fs_info;
|
struct ubifs_info *c = dir->i_sb->s_fs_info;
|
||||||
struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1};
|
struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
|
||||||
|
.dirtied_ino = 1};
|
||||||
struct ubifs_budget_req ino_req = { .dirtied_ino = 1 };
|
struct ubifs_budget_req ino_req = { .dirtied_ino = 1 };
|
||||||
struct ubifs_inode *ui, *dir_ui = ubifs_inode(dir);
|
struct ubifs_inode *ui, *dir_ui = ubifs_inode(dir);
|
||||||
int err, instantiated = 0;
|
int err, instantiated = 0;
|
||||||
struct fscrypt_name nm;
|
struct fscrypt_name nm;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Budget request settings: new dirty inode, new direntry,
|
* Budget request settings: new inode, new direntry, changing the
|
||||||
* budget for dirtied inode will be released via writeback.
|
* parent directory inode.
|
||||||
|
* Allocate budget separately for new dirtied inode, the budget will
|
||||||
|
* be released via writeback.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
|
dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
|
||||||
|
@ -949,7 +952,8 @@ static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
||||||
struct ubifs_inode *dir_ui = ubifs_inode(dir);
|
struct ubifs_inode *dir_ui = ubifs_inode(dir);
|
||||||
struct ubifs_info *c = dir->i_sb->s_fs_info;
|
struct ubifs_info *c = dir->i_sb->s_fs_info;
|
||||||
int err, sz_change;
|
int err, sz_change;
|
||||||
struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1 };
|
struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
|
||||||
|
.dirtied_ino = 1};
|
||||||
struct fscrypt_name nm;
|
struct fscrypt_name nm;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user