All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Jan Kara <jack@suse.cz>, linux-ext4@vger.kernel.org
Subject: Re: [PATCH 3/5] ext4: Speedup ext4 orphan inode handling
Date: Fri, 13 Aug 2021 14:34:34 +0200	[thread overview]
Message-ID: <20210813123434.GB11955@quack2.suse.cz> (raw)
In-Reply-To: <YRU3zjcP5hukrsyt@mit.edu>

On Thu 12-08-21 11:01:34, Theodore Ts'o wrote:
> On Wed, Aug 11, 2021 at 12:19:13PM +0200, Jan Kara wrote:
> > +static int ext4_orphan_file_del(handle_t *handle, struct inode *inode)
> > +{
> > +	struct ext4_orphan_info *oi = &EXT4_SB(inode->i_sb)->s_orphan_info;
> > +	__le32 *bdata;
> > +	int blk, off;
> > +	int inodes_per_ob = ext4_inodes_per_orphan_block(inode->i_sb);
> > +	int ret = 0;
> > +
> > +	if (!handle)
> > +		goto out;
> > +	blk = EXT4_I(inode)->i_orphan_idx / inodes_per_ob;
> > +	off = EXT4_I(inode)->i_orphan_idx % inodes_per_ob;
> > +	if (WARN_ON_ONCE(blk >= oi->of_blocks))
> > +		goto out;
> > +
> > +	ret = ext4_journal_get_write_access(handle, inode->i_sb,
> > +				oi->of_binfo[blk].ob_bh, EXT4_JTR_ORPHAN_FILE);
> > +	if (ret)
> > +		goto out;
> 
> If ext4_journal_get_write_access() fails, we effectively drop the
> inode from the orphan list (as far as the in-memory inode is
> concerned), although the inode will still be listed in the orphan
> file.  This can be really unfortunate since if the inode gets
> reallocated for some other purpose, since its inode number is left in
> the orphan block, on the next remount, this could lead to data loss.
> 
> In the orphan list code, we leave the inode on the linked list, which
> is not great, since that will prevent the inode from being freed, but
> at least we're keeping the in-memory and on-disk state in sync and we
> avoid the data loss scenario when the inode gets reused.

Actually, in the orphan list code, we leave the inode in the on-disk list
but remove it from the in-memory list - see how
list_del_init(&ei->i_orphan) is called very early in ext4_orphan_del(). The
reason for this unconditional deletion is that if we do not remove the
inode from the in-memory orphan list, the filesystem will complain and
corrupt memory on unmount.

Also note that leaving inode in the on-disk orphan list actually does no
serious harm. Because the orphan cleanup code just checks i_nlink and
i_disksize and truncates inode down to current i_disksize and removes inode
completely if i_nlink is 0. So even if an inode on the orphan list gets
reused, orphan cleanup will just do nothing for it. So the worst problem
that will likely happen is that on-disk orphan linked list becomes
corrupted but there's no data loss AFAICT.

Is it clearer now or am I missing something?

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2021-08-13 12:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11 10:19 [PATCH 0/5 v5] ext4: Speedup orphan file handling Jan Kara
2021-08-11 10:19 ` [PATCH 1/5] ext4: Support for checksumming from journal triggers Jan Kara
2021-08-11 10:19 ` [PATCH 2/5] ext4: Move orphan inode handling into a separate file Jan Kara
2021-08-11 10:19 ` [PATCH 3/5] ext4: Speedup ext4 orphan inode handling Jan Kara
2021-08-12 15:01   ` Theodore Ts'o
2021-08-13 12:34     ` Jan Kara [this message]
2021-08-13 15:26       ` Theodore Ts'o
2021-08-16  9:23         ` Jan Kara
2021-08-11 10:19 ` [PATCH 4/5] ext4: Orphan file documentation Jan Kara
2021-08-12 15:02   ` Theodore Ts'o
2021-08-11 10:19 ` [PATCH 5/5] ext4: Improve scalability of ext4 orphan file handling Jan Kara
2021-08-11 18:19   ` kernel test robot
2021-08-12 12:59     ` Jan Kara
2021-08-12 16:48   ` Theodore Ts'o
  -- strict thread matches above, loose matches on Subject: below --
2021-08-16  9:57 [PATCH 0/5 v7] ext4: Speedup " Jan Kara
2021-08-16  9:57 ` [PATCH 3/5] ext4: Speedup ext4 orphan inode handling Jan Kara
2021-08-16  9:22 [PATCH 0/5 v6] ext4: Speedup orphan file handling Jan Kara
2021-08-16  9:23 ` [PATCH 3/5] ext4: Speedup ext4 orphan inode handling Jan Kara
2021-07-12 15:40 [PATCH 0/5 v4] ext4: Speedup orphan file handling Jan Kara
2021-07-12 15:40 ` [PATCH 3/5] ext4: Speedup ext4 orphan inode handling Jan Kara

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=20210813123434.GB11955@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --subject='Re: [PATCH 3/5] ext4: Speedup ext4 orphan inode handling' \
    /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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.