From: Chao Yu <chao.yu@oppo.com>
To: yebin <yebin10@huawei.com>
Cc: linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net, jaegeuk@kernel.org
Subject: Re: [f2fs-dev] [PATCH -next v2] ext4:fix file system corrupted when rmdir non empty directory with IO error
Date: Fri, 25 Feb 2022 16:38:28 +0800 [thread overview]
Message-ID: <1c1fe250-09ab-d8f1-40bb-b0ef382b2782@oppo.com> (raw)
In-Reply-To: <621891D5.2070800@huawei.com>
On 2022/2/25 16:22, yebin via Linux-f2fs-devel wrote:
>> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
>> index a0e51937d92e..3de5a1343070 100644
>> --- a/fs/f2fs/dir.c
>> +++ b/fs/f2fs/dir.c
>> @@ -953,7 +953,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
>> f2fs_drop_nlink(dir, inode);
>> }
>> -bool f2fs_empty_dir(struct inode *dir)
>> +int f2fs_empty_dir(struct inode *dir)
>> {
>> unsigned long bidx;
>> struct page *dentry_page;
>> @@ -970,7 +970,7 @@ bool f2fs_empty_dir(struct inode *dir)
>> if (PTR_ERR(dentry_page) == -ENOENT)
>> continue;
>> else
>> - return false;
>> + return PTR_ERR(dentry_page);
>> }
>> dentry_blk = page_address(dentry_page);
>> @@ -985,9 +985,9 @@ bool f2fs_empty_dir(struct inode *dir)
>> f2fs_put_page(dentry_page, 1);
>> if (bit_pos < NR_DENTRY_IN_BLOCK)
>> - return false;
>> + return -ENOTEMPTY;
>> }
>> - return true;
>> + return 0;
>> }
>> int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
>> index 5c30a65467e2..09617d7b37fd 100644
>> --- a/fs/f2fs/f2fs.h
>> +++ b/fs/f2fs/f2fs.h
>> @@ -3465,7 +3465,7 @@ int f2fs_do_add_link(struct inode *dir, const struct qstr *name,
>> void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
>> struct inode *dir, struct inode *inode);
>> int f2fs_do_tmpfile(struct inode *inode, struct inode *dir);
>> -bool f2fs_empty_dir(struct inode *dir);
>> +int f2fs_empty_dir(struct inode *dir);
>> static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
>> {
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index cfdc41f87f5d..a3b60d6a58f7 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -1846,10 +1846,13 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
>> return -EPERM;
>> if ((iflags ^ masked_flags) & F2FS_CASEFOLD_FL) {
>> + int ret;
>> +
>> if (!f2fs_sb_has_casefold(F2FS_I_SB(inode)))
>> return -EOPNOTSUPP;
>> - if (!f2fs_empty_dir(inode))
>> - return -ENOTEMPTY;
>> + ret = f2fs_empty_dir(inode);
>> + if (ret)
>> + return ret;
>> }
>> if (iflags & (F2FS_COMPR_FL | F2FS_NOCOMP_FL)) {
>> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
>> index 13a0ffc39fa4..e4d1821b707b 100644
>> --- a/fs/f2fs/namei.c
>> +++ b/fs/f2fs/namei.c
>> @@ -786,10 +786,10 @@ static int f2fs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
>> static int f2fs_rmdir(struct inode *dir, struct dentry *dentry)
>> {
>> struct inode *inode = d_inode(dentry);
>> + int ret;
>> - if (f2fs_empty_dir(inode))
>> - return f2fs_unlink(dir, dentry);
>> - return -ENOTEMPTY;
>> + ret = f2fs_empty_dir(inode);
>> + return ret ? : f2fs_unlink(dir, dentry);
>> }
>> static int f2fs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
>> @@ -1001,9 +1001,7 @@ static int f2fs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
>> }
>> if (new_inode) {
>> -
>> - err = -ENOTEMPTY;
>> - if (old_dir_entry && !f2fs_empty_dir(new_inode))
>> + if (old_dir_entry && (err = f2fs_empty_dir(new_inode)))
>> goto out_dir;
>> err = -ENOENT;
Could you please move f2fs part to a separated patch?
Thanks,
next prev parent reply other threads:[~2022-02-25 8:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-11 9:35 Ye Bin
2022-02-25 8:22 ` yebin
2022-02-25 8:38 ` Chao Yu [this message]
2022-02-26 2:23 ` Theodore Ts'o
2022-02-26 2:56 ` yebin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1c1fe250-09ab-d8f1-40bb-b0ef382b2782@oppo.com \
--to=chao.yu@oppo.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=yebin10@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®