All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: "Light Hsieh (謝明燈)" <Light.Hsieh@mediatek.com>
Cc: Hillf Danton <hdanton@sina.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-f2fs-devel@lists.sourceforge.net"
	<linux-f2fs-devel@lists.sourceforge.net>
Subject: Re: [f2fs-dev] 回覆: [PATCH] f2fs: avoid the deadlock case when stopping discard thread
Date: Fri, 22 Mar 2024 22:24:32 +0000	[thread overview]
Message-ID: <Zf4FIAkI83GbQYLB@google.com> (raw)
In-Reply-To: <SI2PR03MB52607606AB0D29C8AB123C1484312@SI2PR03MB5260.apcprd03.prod.outlook.com>

On 03/22, Light Hsieh (謝明燈) wrote:
> I don't see my added log in sb_free_unlock() which will invoke percpu_up_write to release the write semaphore.

May I ask more details whether thaw_super() was called or not?

> 
> 
> ________________________________
> 寄件者: Jaegeuk Kim <jaegeuk@kernel.org>
> 寄件日期: 2024年3月22日 上午 08:29
> 收件者: Hillf Danton <hdanton@sina.com>
> 副本: linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; Light Hsieh (謝明燈) <Light.Hsieh@mediatek.com>; linux-f2fs-devel@lists.sourceforge.net <linux-f2fs-devel@lists.sourceforge.net>
> 主旨: Re: [PATCH] f2fs: avoid the deadlock case when stopping discard thread
> 
> 
> External email : Please do not click links or open attachments until you have verified the sender or the content.
> 
> On 03/22, Hillf Danton wrote:
> > On Tue, 19 Mar 2024 17:14:42 -0700 Jaegeuk Kim <jaegeuk@kernel.org>
> > > f2fs_ioc_shutdown(F2FS_GOING_DOWN_NOSYNC)  issue_discard_thread
> > >  - mnt_want_write_file()
> > >    - sb_start_write(SB_FREEZE_WRITE)
> >  __sb_start_write()
> >    percpu_down_read()
> > >                                              - sb_start_intwrite(SB_FREEZE_FS);
> >    __sb_start_write()
> >      percpu_down_read()
> >
> > Given lock acquirers for read on both sides, wtf deadlock are you fixing?
> 
> Damn. I couldn't think _write uses _read sem.
> 
> >
> > >  - f2fs_stop_checkpoint(sbi, false,            : waiting
> > >     STOP_CP_REASON_SHUTDOWN);
> > >  - f2fs_stop_discard_thread(sbi);
> > >    - kthread_stop()
> > >      : waiting
> > >
> > >  - mnt_drop_write_file(filp);
> >
> > More important, feel free to add in spin.
> 
> I posted this patch before Light reported.
> 
> And, in the report, I didn't get this:
> 
> f2fs_ioc_shutdown() --> freeze_bdev() --> freeze_super() --> sb_wait_write(sb, SB_FREEZE_FS) --> ... ->percpu_down_write().
> 
> because f2fs_ioc_shutdown() calls f2fs_stop_discard_thread() after thaw_bdev()
> like this order.
> 
>  -> freeze_bdev()
>  -> thaw_bdev()
>  -> f2fs_stop_discard_thread()
> 
> Am I missing something?
> 
> >
> > Reported-by: "Light Hsieh (謝明燈)" <Light.Hsieh@mediatek.com>
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

WARNING: multiple messages have this Message-ID (diff)
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: "Light Hsieh (謝明燈)" <Light.Hsieh@mediatek.com>
Cc: Hillf Danton <hdanton@sina.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-f2fs-devel@lists.sourceforge.net"
	<linux-f2fs-devel@lists.sourceforge.net>
Subject: Re: 回覆: [PATCH] f2fs: avoid the deadlock case when stopping discard thread
Date: Fri, 22 Mar 2024 22:24:32 +0000	[thread overview]
Message-ID: <Zf4FIAkI83GbQYLB@google.com> (raw)
In-Reply-To: <SI2PR03MB52607606AB0D29C8AB123C1484312@SI2PR03MB5260.apcprd03.prod.outlook.com>

On 03/22, Light Hsieh (謝明燈) wrote:
> I don't see my added log in sb_free_unlock() which will invoke percpu_up_write to release the write semaphore.

May I ask more details whether thaw_super() was called or not?

> 
> 
> ________________________________
> 寄件者: Jaegeuk Kim <jaegeuk@kernel.org>
> 寄件日期: 2024年3月22日 上午 08:29
> 收件者: Hillf Danton <hdanton@sina.com>
> 副本: linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; Light Hsieh (謝明燈) <Light.Hsieh@mediatek.com>; linux-f2fs-devel@lists.sourceforge.net <linux-f2fs-devel@lists.sourceforge.net>
> 主旨: Re: [PATCH] f2fs: avoid the deadlock case when stopping discard thread
> 
> 
> External email : Please do not click links or open attachments until you have verified the sender or the content.
> 
> On 03/22, Hillf Danton wrote:
> > On Tue, 19 Mar 2024 17:14:42 -0700 Jaegeuk Kim <jaegeuk@kernel.org>
> > > f2fs_ioc_shutdown(F2FS_GOING_DOWN_NOSYNC)  issue_discard_thread
> > >  - mnt_want_write_file()
> > >    - sb_start_write(SB_FREEZE_WRITE)
> >  __sb_start_write()
> >    percpu_down_read()
> > >                                              - sb_start_intwrite(SB_FREEZE_FS);
> >    __sb_start_write()
> >      percpu_down_read()
> >
> > Given lock acquirers for read on both sides, wtf deadlock are you fixing?
> 
> Damn. I couldn't think _write uses _read sem.
> 
> >
> > >  - f2fs_stop_checkpoint(sbi, false,            : waiting
> > >     STOP_CP_REASON_SHUTDOWN);
> > >  - f2fs_stop_discard_thread(sbi);
> > >    - kthread_stop()
> > >      : waiting
> > >
> > >  - mnt_drop_write_file(filp);
> >
> > More important, feel free to add in spin.
> 
> I posted this patch before Light reported.
> 
> And, in the report, I didn't get this:
> 
> f2fs_ioc_shutdown() --> freeze_bdev() --> freeze_super() --> sb_wait_write(sb, SB_FREEZE_FS) --> ... ->percpu_down_write().
> 
> because f2fs_ioc_shutdown() calls f2fs_stop_discard_thread() after thaw_bdev()
> like this order.
> 
>  -> freeze_bdev()
>  -> thaw_bdev()
>  -> f2fs_stop_discard_thread()
> 
> Am I missing something?
> 
> >
> > Reported-by: "Light Hsieh (謝明燈)" <Light.Hsieh@mediatek.com>
> 

  parent reply	other threads:[~2024-03-22 22:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20  0:14 [f2fs-dev] [PATCH] f2fs: avoid the deadlock case when stopping discard thread Jaegeuk Kim
2024-03-20  0:14 ` Jaegeuk Kim
2024-03-20 15:32 ` [f2fs-dev] " Chao Yu
2024-03-20 15:32   ` Chao Yu
2024-03-21 22:42 ` Hillf Danton
2024-03-21 22:42   ` Hillf Danton
2024-03-22  0:29   ` [f2fs-dev] " Jaegeuk Kim
2024-03-22  0:29     ` Jaegeuk Kim
2024-03-22 11:33     ` [f2fs-dev] " Hillf Danton
2024-03-22 11:33       ` Hillf Danton
     [not found]     ` <SI2PR03MB52607606AB0D29C8AB123C1484312@SI2PR03MB5260.apcprd03.prod.outlook.com>
2024-03-22 22:24       ` Jaegeuk Kim [this message]
2024-03-22 22:24         ` 回覆: " Jaegeuk Kim
2024-03-26 16:52         ` [f2fs-dev] " Jaegeuk Kim
2024-03-26 16:52           ` Jaegeuk Kim
     [not found]           ` <SI2PR03MB526041E42B6BD9C9DA9FBAC184352@SI2PR03MB5260.apcprd03.prod.outlook.com>
2024-04-03  3:39             ` 回覆: " Light Hsieh (謝明燈)
2024-04-04 19:55               ` [f2fs-dev] " Jaegeuk Kim
2024-04-04 19:55                 ` Jaegeuk Kim
2024-04-12  0:18                 ` 回覆: " Light Hsieh (謝明燈)
2024-04-12 20:50                   ` [f2fs-dev] " Jaegeuk Kim
2024-04-12 20:50                     ` Jaegeuk Kim
2024-04-16  1:50                     ` 回覆: " Light Hsieh (謝明燈)

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=Zf4FIAkI83GbQYLB@google.com \
    --to=jaegeuk@kernel.org \
    --cc=Light.Hsieh@mediatek.com \
    --cc=hdanton@sina.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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 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.