Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1551688
| From | "zhangyi (F)" <yi.zhang@huawei.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy |
| Date | 2017-01-05 08:30 +0100 |
| Message-ID | <sWaEO-85U-11@gated-at.bofh.it> (permalink) |
| References | <sSCJk-4Nn-25@gated-at.bofh.it> <sUAN4-vE-9@gated-at.bofh.it> <sVPAl-2hI-3@gated-at.bofh.it> <sW1UR-2ik-3@gated-at.bofh.it> <sW3jY-37n-39@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 2017/1/5 7:35, Theodore Ts'o wrote:
>
> So how exactly how did we get into this state? When we read the inode
> into memory, if i_nlink is zero, we declare the file system as
> corrupted immediately.
>
> So I assume this is happening the on-disk i_links_count (which is read
> into inode->i_nlink) was too low. So I think the way we should be
> handling this is in unlink and rename, before we let i_nlink drop to
> zero, we need to check to see if there are other dcache entries
> pointing at the inode. If so, we need to call ext4_error(), and in
> the errors=continue case, return EFSCORRUPTED (aka EUCLEAN).
>
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3662,6 +3662,11 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
}
if (new.inode) {
+ if (new.inode->i_nlink == 0) {
+ ext4_warning_inode(new.inode, "Removing file '%.*s' with no links",
+ new.dentry->d_name.len, new.dentry->d_name.name);
+ set_nlink(new.inode, 1);
+ }
ext4_dec_count(handle, new.inode);
new.inode->i_ctime = ext4_current_time(new.inode);
}
Because the filesystem have many errors, and the reason of i_nlink becomes zero is unknown,
the on-disk i_links_count was too low may be one reason. I think we can add i_nlink check in
ext4_rename just like ext4_unlink did, it can avoid inversion under any case.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy "zhangyi (F)" <yi.zhang@huawei.com> - 2017-01-04 10:00 +0100
Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy Andreas Dilger <adilger@dilger.ca> - 2017-01-04 23:10 +0100
Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy "Darrick J. Wong" <darrick.wong@oracle.com> - 2017-01-05 00:00 +0100
Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy Theodore Ts'o <tytso@mit.edu> - 2017-01-05 00:40 +0100
Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy "zhangyi (F)" <yi.zhang@huawei.com> - 2017-01-05 08:30 +0100
Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy "Darrick J. Wong" <darrick.wong@oracle.com> - 2017-01-05 19:50 +0100
Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy "zhangyi (F)" <yi.zhang@huawei.com> - 2017-01-11 10:10 +0100
Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy Theodore Ts'o <tytso@mit.edu> - 2017-01-11 16:40 +0100
Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy "zhangyi (F)" <yi.zhang@huawei.com> - 2017-01-12 09:10 +0100
Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy Theodore Ts'o <tytso@mit.edu> - 2017-01-12 18:10 +0100
Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy Al Viro <viro@ZenIV.linux.org.uk> - 2017-01-13 04:50 +0100
Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy Theodore Ts'o <tytso@mit.edu> - 2017-01-13 15:30 +0100
Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy "zhangyi (F)" <yi.zhang@huawei.com> - 2017-01-16 04:30 +0100
csiph-web