diff mbox series

[5.10,050/530] md: md_open returns -EBUSY when entering racing area

Message ID 20210512144821.386618889@linuxfoundation.org
State Superseded
Headers show
Series None | expand

Commit Message

Greg KH May 12, 2021, 2:42 p.m. UTC
From: Zhao Heming <heming.zhao@suse.com>

commit 6a4db2a60306eb65bfb14ccc9fde035b74a4b4e7 upstream.

commit d3374825ce57 ("md: make devices disappear when they are no longer
needed.") introduced protection between mddev creating & removing. The
md_open shouldn't create mddev when all_mddevs list doesn't contain
mddev. With currently code logic, there will be very easy to trigger
soft lockup in non-preempt env.

This patch changes md_open returning from -ERESTARTSYS to -EBUSY, which
will break the infinitely retry when md_open enter racing area.

This patch is partly fix soft lockup issue, full fix needs mddev_find
is split into two functions: mddev_find & mddev_find_or_alloc. And
md_open should call new mddev_find (it only does searching job).

For more detail, please refer with Christoph's "split mddev_find" patch
in later commits.

---
 drivers/md/md.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Pavel Machek May 13, 2021, 7:59 a.m. UTC | #1
Hi!

> commit 6a4db2a60306eb65bfb14ccc9fde035b74a4b4e7 upstream.
> 
> commit d3374825ce57 ("md: make devices disappear when they are no longer
> needed.") introduced protection between mddev creating & removing. The
> md_open shouldn't create mddev when all_mddevs list doesn't contain
> mddev. With currently code logic, there will be very easy to trigger
> soft lockup in non-preempt env.
> 
> This patch changes md_open returning from -ERESTARTSYS to -EBUSY, which
> will break the infinitely retry when md_open enter racing area.
> 
> This patch is partly fix soft lockup issue, full fix needs mddev_find
> is split into two functions: mddev_find & mddev_find_or_alloc. And
> md_open should call new mddev_find (it only does searching job).
> 
> For more detail, please refer with Christoph's "split mddev_find" patch
> in later commits.

Something went wrong here; changelog is truncated, in particular it
does not contain required sign-offs.

Best regards,
								Pavel

> +++ b/drivers/md/md.c
> @@ -7857,8 +7857,7 @@ static int md_open(struct block_device *
>  		/* Wait until bdev->bd_disk is definitely gone */
>  		if (work_pending(&mddev->del_work))
>  			flush_workqueue(md_misc_wq);
> -		/* Then retry the open from the top */
> -		return -ERESTARTSYS;
> +		return -EBUSY;
>  	}
>  	BUG_ON(mddev != bdev->bd_disk->private_data);
Greg KH May 13, 2021, 9:48 a.m. UTC | #2
On Thu, May 13, 2021 at 11:47:15AM +0200, Greg Kroah-Hartman wrote:
> On Thu, May 13, 2021 at 09:59:41AM +0200, Pavel Machek wrote:
> > Hi!
> > 
> > > commit 6a4db2a60306eb65bfb14ccc9fde035b74a4b4e7 upstream.
> > > 
> > > commit d3374825ce57 ("md: make devices disappear when they are no longer
> > > needed.") introduced protection between mddev creating & removing. The
> > > md_open shouldn't create mddev when all_mddevs list doesn't contain
> > > mddev. With currently code logic, there will be very easy to trigger
> > > soft lockup in non-preempt env.
> > > 
> > > This patch changes md_open returning from -ERESTARTSYS to -EBUSY, which
> > > will break the infinitely retry when md_open enter racing area.
> > > 
> > > This patch is partly fix soft lockup issue, full fix needs mddev_find
> > > is split into two functions: mddev_find & mddev_find_or_alloc. And
> > > md_open should call new mddev_find (it only does searching job).
> > > 
> > > For more detail, please refer with Christoph's "split mddev_find" patch
> > > in later commits.
> > 
> > Something went wrong here; changelog is truncated, in particular it
> > does not contain required sign-offs.
> 
> That's really odd, let me figure out what went wrong there, might be a
> quilt thing...

Yup, it's a bug in quilt, the header is just dropped for some reason.
Will dig further, thanks for pointing this out.

greg k-h
diff mbox series

Patch

--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7857,8 +7857,7 @@  static int md_open(struct block_device *
 		/* Wait until bdev->bd_disk is definitely gone */
 		if (work_pending(&mddev->del_work))
 			flush_workqueue(md_misc_wq);
-		/* Then retry the open from the top */
-		return -ERESTARTSYS;
+		return -EBUSY;
 	}
 	BUG_ON(mddev != bdev->bd_disk->private_data);