mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: Yu Kuai <yukuai1@huaweicloud.com>, Mikulas Patocka <mpatocka@redhat.com>
Cc: heinzm@redhat.com, xni@redhat.com, agk@redhat.com,
	snitzer@kernel.org, dm-devel@lists.linux.dev, song@kernel.org,
	jbrassow@f14.redhat.com, neilb@suse.de, shli@fb.com,
	akpm@osdl.org, linux-kernel@vger.kernel.org,
	linux-raid@vger.kernel.org, yi.zhang@huawei.com,
	yangerkun@huawei.com, "yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH RFC v4 13/14] dm: wait for IO completion before removing dm device
Date: Wed, 31 Jan 2024 09:35:22 +0800	[thread overview]
Message-ID: <b3c80659-8879-6e7c-e732-5fb690b7bc97@huaweicloud.com> (raw)
In-Reply-To: <bdeac016-f57d-f917-d605-342fe9856ccf@huaweicloud.com>

Hi,

在 2024/01/30 21:05, Yu Kuai 写道:
> Hi,
> 
> 在 2024/01/30 19:46, Mikulas Patocka 写道:
>>
>>
>> On Tue, 30 Jan 2024, Yu Kuai wrote:
>>
>>> From: Yu Kuai <yukuai3@huawei.com>
>>>
>>> __dm_destroy() guarantee that device openers is zero, and then
>>> only call 'presuspend' and 'postsuspend' for the target. For
>>> request-based dm, 'md->holders' will be grabbed for each rq and
>>> __dm_destroy() will wait for 'md->holders' to be zero. However, for
>>> bio-based device, __dm_destroy() doesn't wait for all bios to be done.
>>>
>>> Fix this problem by calling dm_wait_for_completion() to wail for all
>>> inflight IO to be done, like what dm_suspend() does.
>>
>> If the number of openers is zero, it is guaranteed that there are no bios
>> in flight. Therefore, we don't have to wait for them.
>>
>> If there are bios in flight, it is a bug in the code that issues the 
>> bios.
>> You can put WARN_ON(dm_in_flight_bios(md)) there.
> 
> I add this patch because while testing, there is a problem that is
> hard to reporduce, as I mentioned in the other thread. I'll add BUG_ON()
> and try if I can still reporduce this problem without triggering it.
> 
> Thanks,
> Kuai
> 
> [12504.959682] BUG bio-296 (Not tainted): Object already free
> [12504.960239] 
> ----------------------------------------------------------------------------- 
> 
> [12504.960239]
> [12504.961209] Allocated in mempool_alloc+0xe8/0x270 age=30 cpu=1 
> pid=203288
> [12504.961905]  kmem_cache_alloc+0x36a/0x3b0
> [12504.962324]  mempool_alloc+0xe8/0x270
> [12504.962712]  bio_alloc_bioset+0x3b5/0x920
> [12504.963129]  bio_alloc_clone+0x3e/0x160
> [12504.963533]  alloc_io+0x3d/0x1f0
> [12504.963876]  dm_submit_bio+0x12f/0xa30
> [12504.964267]  __submit_bio+0x9c/0xe0
> [12504.964639]  submit_bio_noacct_nocheck+0x25a/0x570
> [12504.965136]  submit_bio_wait+0xc2/0x160
> [12504.965535]  blkdev_issue_zeroout+0x19b/0x2e0
> [12504.965991]  ext4_init_inode_table+0x246/0x560
> [12504.966462]  ext4_lazyinit_thread+0x750/0xbe0
> [12504.966922]  kthread+0x1b4/0x1f0

After adding the BUG_ON(), I can still reporducing this BUG, this really
looks like a BUG, and I don't think this is related to dm-raid. Perhaps
you guys can take a look?

Thanks,
Kuai

>>
>> Mikulas
>>
>>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>>> ---
>>>   drivers/md/dm.c | 3 +++
>>>   1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
>>> index 8dcabf84d866..2c0eae67d0f1 100644
>>> --- a/drivers/md/dm.c
>>> +++ b/drivers/md/dm.c
>>> @@ -58,6 +58,7 @@ static DEFINE_IDR(_minor_idr);
>>>   static DEFINE_SPINLOCK(_minor_lock);
>>>   static void do_deferred_remove(struct work_struct *w);
>>> +static int dm_wait_for_completion(struct mapped_device *md, unsigned 
>>> int task_state);
>>>   static DECLARE_WORK(deferred_remove_work, do_deferred_remove);
>>> @@ -2495,6 +2496,8 @@ static void __dm_destroy(struct mapped_device 
>>> *md, bool wait)
>>>       if (!dm_suspended_md(md)) {
>>>           dm_table_presuspend_targets(map);
>>>           set_bit(DMF_SUSPENDED, &md->flags);
>>> +        if (wait)
>>> +            dm_wait_for_completion(md, TASK_UNINTERRUPTIBLE);
>>>           set_bit(DMF_POST_SUSPENDING, &md->flags);
>>>           dm_table_postsuspend_targets(map);
>>>       }
>>> -- 
>>> 2.39.2
>>>
>>
>> .
>>
> 
> .
> 


  reply	other threads:[~2024-01-31  1:35 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30  2:18 [PATCH v4 00/14] dm-raid: fix v6.7 regressions Yu Kuai
2024-01-30  2:18 ` [PATCH v4 01/14] md: don't ignore suspended array in md_check_recovery() Yu Kuai
2024-01-30  2:18 ` [PATCH v4 02/14] md: don't ignore read-only " Yu Kuai
2024-01-30  2:18 ` [PATCH v4 03/14] md: make sure md_do_sync() will set MD_RECOVERY_DONE Yu Kuai
2024-01-30  2:18 ` [PATCH v4 04/14] md: don't register sync_thread for reshape directly Yu Kuai
2024-01-30  2:18 ` [PATCH v4 05/14] md: export helpers to stop sync_thread Yu Kuai
2024-01-30  2:18 ` [PATCH v4 06/14] dm-raid: really frozen sync_thread during suspend Yu Kuai
2024-01-30  2:18 ` [PATCH v4 07/14] md/dm-raid: don't call md_reap_sync_thread() directly Yu Kuai
2024-01-30  2:18 ` [PATCH v4 08/14] dm-raid: add a new helper prepare_suspend() in md_personality Yu Kuai
2024-01-30  2:18 ` [PATCH v4 09/14] md: export helper md_is_rdwr() Yu Kuai
2024-01-30  2:18 ` [PATCH v4 10/14] md: don't suspend the array for interrupted reshape Yu Kuai
2024-01-30  2:18 ` [PATCH v4 11/14] md/raid456: fix a deadlock for dm-raid456 while io concurrent with reshape Yu Kuai
2024-01-30  2:18 ` [PATCH v4 12/14] dm-raid: fix lockdep waring in "pers->hot_add_disk" Yu Kuai
2024-01-30  2:18 ` [PATCH RFC v4 13/14] dm: wait for IO completion before removing dm device Yu Kuai
2024-01-30 11:46   ` Mikulas Patocka
2024-01-30 13:05     ` Yu Kuai
2024-01-31  1:35       ` Yu Kuai [this message]
2024-01-30  2:18 ` [PATCH v4 RFC 14/14] dm-raid: remove mddev_suspend/resume() Yu Kuai
2024-01-31  2:51   ` Yu Kuai
2024-01-30  9:08 ` [PATCH v4 00/14] dm-raid: fix v6.7 regressions Song Liu
2024-01-31  0:29 ` Xiao Ni
2024-01-31  1:25   ` Yu Kuai
2024-01-31  1:28     ` Xiao Ni
2024-01-31  2:52       ` Yu Kuai
2024-01-31  7:06         ` Yu Kuai

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=b3c80659-8879-6e7c-e732-5fb690b7bc97@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=agk@redhat.com \
    --cc=akpm@osdl.org \
    --cc=dm-devel@lists.linux.dev \
    --cc=heinzm@redhat.com \
    --cc=jbrassow@f14.redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=neilb@suse.de \
    --cc=shli@fb.com \
    --cc=snitzer@kernel.org \
    --cc=song@kernel.org \
    --cc=xni@redhat.com \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@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®