linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: "zhangyi (F)" <yi.zhang@huawei.com>,
	Valdis.Kletnieks@vt.edu, linux-ext4@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	adilger.kernel@dilger.ca
Subject: Re: [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy
Date: Wed, 4 Jan 2017 18:35:50 -0500	[thread overview]
Message-ID: <20170104233550.oy7nzc3rxppmejbk@thunk.org> (raw)
In-Reply-To: <20170104215424.GB14021@birch.djwong.org>

On Wed, Jan 04, 2017 at 01:54:24PM -0800, Darrick J. Wong wrote:
> 
> if (inode->i_nlink == 0) {
> 	ext4_warning_inode(inode, "nlink is already 0");
> 	return;
> }

We can't do that because the place where Zhangyi is proposing to
change is in fs/inode.c:drop_nlink(), so we can't add a call to
ext4_error() or ext4_warning().

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).

    		    	  	 	      - Ted

  parent reply	other threads:[~2017-01-04 23:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-26 12:34 [RFC PATCH] ext4: increase the protection of drop nlink and ext4 inode destroy yi zhang
2016-12-26 18:32 ` Andreas Dilger
2016-12-31 22:59 ` Valdis.Kletnieks
2017-01-04  8:29   ` zhangyi (F)
2017-01-04 21:54     ` Darrick J. Wong
2017-01-04 22:00       ` Andreas Dilger
2017-01-04 23:35       ` Theodore Ts'o [this message]
2017-01-05  7:24         ` zhangyi (F)
2017-01-05 17:38           ` Darrick J. Wong
2017-01-11  9:07         ` zhangyi (F)
2017-01-11 15:34           ` Theodore Ts'o
2017-01-12  8:00             ` zhangyi (F)
2017-01-12 17:03               ` Theodore Ts'o
2017-01-13  3:42                 ` Al Viro
2017-01-13 14:26                   ` Theodore Ts'o
2017-01-16  3:24             ` zhangyi (F)

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=20170104233550.oy7nzc3rxppmejbk@thunk.org \
    --to=tytso@mit.edu \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=adilger.kernel@dilger.ca \
    --cc=darrick.wong@oracle.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yi.zhang@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;
as well as URLs for NNTP newsgroup(s).