diff mbox series

[v3,04/12] ubifs: Add missing iput if do_tmpfile() failed in rename whiteout

Message ID 20211112121758.2208727-5-chengzhihao1@huawei.com
State Superseded
Headers show
Series Some bugfixs for ubi/ubifs | expand

Commit Message

Zhihao Cheng Nov. 12, 2021, 12:17 p.m. UTC
whiteout inode should be put when do_tmpfile() failed if inode has been
initialized. Otherwise we will get following warning during umount:
  UBIFS error (ubi0:0 pid 1494): ubifs_assert_failed [ubifs]: UBIFS
  assert failed: c->bi.dd_growth == 0, in fs/ubifs/super.c:1930
  VFS: Busy inodes after unmount of ubifs. Self-destruct in 5 seconds.

Fixes: 9e0a1fff8db56ea ("ubifs: Implement RENAME_WHITEOUT")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
 fs/ubifs/dir.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Sascha Hauer Nov. 15, 2021, 8:24 a.m. UTC | #1
On Fri, Nov 12, 2021 at 08:17:50PM +0800, Zhihao Cheng wrote:
> whiteout inode should be put when do_tmpfile() failed if inode has been
> initialized. Otherwise we will get following warning during umount:
>   UBIFS error (ubi0:0 pid 1494): ubifs_assert_failed [ubifs]: UBIFS
>   assert failed: c->bi.dd_growth == 0, in fs/ubifs/super.c:1930
>   VFS: Busy inodes after unmount of ubifs. Self-destruct in 5 seconds.
> 
> Fixes: 9e0a1fff8db56ea ("ubifs: Implement RENAME_WHITEOUT")
> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
> ---
>  fs/ubifs/dir.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 2735ad1affed..6503e6857f6e 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -1334,6 +1334,8 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>  
>  		err = do_tmpfile(old_dir, old_dentry, S_IFCHR | WHITEOUT_MODE, &whiteout);
>  		if (err) {
> +			if (whiteout)
> +				iput(whiteout);

Should this rather be done in do_tmpfile() directly?

Sascha
Zhihao Cheng Nov. 15, 2021, 9:03 a.m. UTC | #2
在 2021/11/15 16:24, Sascha Hauer 写道:
Hi, Sascha
> On Fri, Nov 12, 2021 at 08:17:50PM +0800, Zhihao Cheng wrote:
>> whiteout inode should be put when do_tmpfile() failed if inode has been
>> initialized. Otherwise we will get following warning during umount:
>>    UBIFS error (ubi0:0 pid 1494): ubifs_assert_failed [ubifs]: UBIFS
>>    assert failed: c->bi.dd_growth == 0, in fs/ubifs/super.c:1930
>>    VFS: Busy inodes after unmount of ubifs. Self-destruct in 5 seconds.
>>
>> Fixes: 9e0a1fff8db56ea ("ubifs: Implement RENAME_WHITEOUT")
>> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
>> ---
>>   fs/ubifs/dir.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
>> index 2735ad1affed..6503e6857f6e 100644
>> --- a/fs/ubifs/dir.c
>> +++ b/fs/ubifs/dir.c
>> @@ -1334,6 +1334,8 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>>   
>>   		err = do_tmpfile(old_dir, old_dentry, S_IFCHR | WHITEOUT_MODE, &whiteout);
>>   		if (err) {
>> +			if (whiteout)
>> +				iput(whiteout);
> Should this rather be done in do_tmpfile() directly?
Yes, I should have done it. Although next patch reconstructs do_rename() 
which makes this ugly judgement disappered. I will fix it along with 
other suggestions from other patches in next iteration. Thanks.
> Sascha
>
Zhihao Cheng Nov. 15, 2021, 9:20 a.m. UTC | #3
在 2021/11/15 16:24, Sascha Hauer 写道:
Hi Sascha,
>> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
>> index 2735ad1affed..6503e6857f6e 100644
>> --- a/fs/ubifs/dir.c
>> +++ b/fs/ubifs/dir.c
>> @@ -1334,6 +1334,8 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>>   
>>   		err = do_tmpfile(old_dir, old_dentry, S_IFCHR | WHITEOUT_MODE, &whiteout);
>>   		if (err) {
>> +			if (whiteout)
>> +				iput(whiteout);
> 
> Should this rather be done in do_tmpfile() directly?
Yes, I should have done it. Although next patch reconstructs do_rename() 
which makes this ugly judgement disappered. I will fix it along with 
other suggestions from other patches in next iteration. Thanks.
> Sascha
>
diff mbox series

Patch

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 2735ad1affed..6503e6857f6e 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1334,6 +1334,8 @@  static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 
 		err = do_tmpfile(old_dir, old_dentry, S_IFCHR | WHITEOUT_MODE, &whiteout);
 		if (err) {
+			if (whiteout)
+				iput(whiteout);
 			kfree(dev);
 			goto out_release;
 		}