From: Baokun Li <libaokun1@huawei.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Ming Lei <ming.lei@redhat.com>,
Matthew Wilcox <willy@infradead.org>,
<linux-ext4@vger.kernel.org>,
Andreas Dilger <adilger.kernel@dilger.ca>,
<linux-block@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
<linux-fsdevel@vger.kernel.org>, <linux-mm@kvack.org>,
Dave Chinner <dchinner@redhat.com>,
Eric Sandeen <sandeen@redhat.com>, Christoph Hellwig <hch@lst.de>,
Zhang Yi <yi.zhang@redhat.com>, yangerkun <yangerkun@huawei.com>
Subject: Re: [ext4 io hang] buffered write io hang in balance_dirty_pages
Date: Thu, 4 May 2023 11:09:42 +0800 [thread overview]
Message-ID: <60a00a11-46e4-23ed-9c14-5b14dccf41e4@huawei.com> (raw)
In-Reply-To: <ZEtd6qZOgRxYnNq9@mit.edu>
On 2023/4/28 13:47, Theodore Ts'o wrote:
> On Fri, Apr 28, 2023 at 11:47:26AM +0800, Baokun Li wrote:
>> Ext4 just detects I/O Error and remounts it as read-only, it doesn't know
>> if the current disk is dead or not.
>>
>> I asked Yu Kuai and he said that disk_live() can be used to determine
>> whether
>> a disk has been removed based on the status of the inode corresponding to
>> the block device, but this is generally not done in file systems.
> What really needs to happen is that del_gendisk() needs to inform file
> systems that the disk is gone, so that the file system can shutdown
> the file system and tear everything down.
Yes, first of all, we need to be able to sense whether the current disk has
been removed. We're just sensing an I/O error now, so we're just making
the file system read-only.
>
> disk_live() is relatively new; it was added in August 2021. Back in
> 2015, I had added the following in fs/ext4/super.c:
>
> /*
> * The del_gendisk() function uninitializes the disk-specific data
> * structures, including the bdi structure, without telling anyone
> * else. Once this happens, any attempt to call mark_buffer_dirty()
> * (for example, by ext4_commit_super), will cause a kernel OOPS.
> * This is a kludge to prevent these oops until we can put in a proper
> * hook in del_gendisk() to inform the VFS and file system layers.
> */
> static int block_device_ejected(struct super_block *sb)
> {
> struct inode *bd_inode = sb->s_bdev->bd_inode;
> struct backing_dev_info *bdi = inode_to_bdi(bd_inode);
>
> return bdi->dev == NULL;
> }
>
> As the comment states, it's rather awkward to have the file system
> check to see if the block device is dead in various places; the real
> problem is that the block device shouldn't just *vanish*, with the
> block device structures egetting partially de-initialized, without the
> block layer being polite enough to let the file system know.
I didn't notice the block_device_ejected() function, and it's really
awkward
for the file system to detect whether the current disk has been removed.
>> Those dirty pages that are already there are piling up and can't be
>> written back, which I think is a real problem. Can the block layer
>> clear those dirty pages when it detects that the disk is deleted?
> Well, the dirty pages belong to the file system, and so it needs to be
> up to the file system to clear out the dirty pages. But I'll also
> what the right thing to do when a disk gets removed is not necessarily
> obvious.
Yes, I know that! If the block layer can find and clear these dirty
pages in a
unified manner, there is no need to do this for each file system.
The subsequent solution is to declare the interface at the VFS layer,
which is
implemented by each file system. When the block layer detects that the disk
is deleted, the block layer invokes the common interface at the VFS layer.
This also sounds good.
>
> For example, suppose some process has a file mmap'ed into its address
> space, and that file is on the disk which the user has rudely yanked
> out from their laptop; what is the right thing to do? Do we kill the
> process? Do we let the process write to the mmap'ed region, and
> silently let the modified data go *poof* when the process exits? What
> if there is an executable file on the removable disk, and there are
> one or more processes running that executable when the device
> disappears? Do we kill the process? Do we let the process run unti
> it tries to access a page which hasn't been paged in and then kill the
> process?
>
> We should design a proper solution for What Should Happen when a
> removable disk gets removed unceremoniously without unmounting the
> file system first. It's not just a matter of making some tests go
> green....
>
> - Ted
>
>
Yes, we need to consider a variety of scenarios, which is not a simple
matter.
Thank you very much for your detailed explanation.
--
With Best Regards,
Baokun Li
.
next prev parent reply other threads:[~2023-05-04 3:09 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-27 2:20 Ming Lei
2023-04-27 3:58 ` Matthew Wilcox
2023-04-27 4:50 ` Ming Lei
2023-04-27 6:36 ` Baokun Li
2023-04-27 7:33 ` Baokun Li
2023-04-27 10:01 ` Ming Lei
2023-04-27 11:19 ` Baokun Li
2023-04-27 11:27 ` Ming Lei
2023-04-28 1:41 ` Ming Lei
2023-04-28 3:47 ` Baokun Li
2023-04-28 5:47 ` Theodore Ts'o
2023-04-29 3:16 ` Ming Lei
2023-04-29 4:40 ` Christoph Hellwig
2023-04-29 5:10 ` Ming Lei
2023-05-01 4:47 ` Christoph Hellwig
2023-05-02 0:57 ` Ming Lei
2023-05-02 1:35 ` Dave Chinner
2023-05-02 15:35 ` Darrick J. Wong
2023-05-02 22:33 ` Dave Chinner
2023-05-02 23:27 ` Darrick J. Wong
2023-04-29 4:56 ` Theodore Ts'o
2023-05-01 2:06 ` Dave Chinner
2023-05-04 3:09 ` Baokun Li [this message]
2023-04-27 23:33 ` Dave Chinner
2023-04-28 2:56 ` Matthew Wilcox
2023-04-28 5:24 ` Dave Chinner
2023-05-04 15:59 ` Keith Busch
2023-05-04 16:21 ` Matthew Wilcox
2023-05-05 2:06 ` Ming Lei
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=60a00a11-46e4-23ed-9c14-5b14dccf41e4@huawei.com \
--to=libaokun1@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=akpm@linux-foundation.org \
--cc=dchinner@redhat.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ming.lei@redhat.com \
--cc=sandeen@redhat.com \
--cc=tytso@mit.edu \
--cc=willy@infradead.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@redhat.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