Revert "md: Don't clear MD_CLOSING when the raid is about to stop"

This reverts commit bb567cb5cd which is
commit 9674f54e41fffaf06f6a60202e1fa4cc13de3cf5 upstream.

It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.

Bug: 161946584
Change-Id: I4c121821592a6813e9125c7946fc43240c1304e1
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman 2024-05-20 10:42:37 +00:00
parent e2ddf25269
commit 2c7d369ecc

View File

@ -6243,15 +6243,7 @@ static void md_clean(struct mddev *mddev)
mddev->persistent = 0;
mddev->level = LEVEL_NONE;
mddev->clevel[0] = 0;
/*
* Don't clear MD_CLOSING, or mddev can be opened again.
* 'hold_active != 0' means mddev is still in the creation
* process and will be used later.
*/
if (mddev->hold_active)
mddev->flags = 0;
else
mddev->flags &= BIT_ULL_MASK(MD_CLOSING);
mddev->flags = 0;
mddev->sb_flags = 0;
mddev->ro = 0;
mddev->metadata_type[0] = 0;
@ -7570,6 +7562,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
int err = 0;
void __user *argp = (void __user *)arg;
struct mddev *mddev = NULL;
bool did_set_md_closing = false;
if (!md_ioctl_valid(cmd))
return -ENOTTY;
@ -7656,6 +7649,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
err = -EBUSY;
goto out;
}
did_set_md_closing = true;
mutex_unlock(&mddev->open_mutex);
sync_blockdev(bdev);
}
@ -7819,7 +7813,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
mddev->hold_active = 0;
mddev_unlock(mddev);
out:
if (cmd == STOP_ARRAY_RO || (err && cmd == STOP_ARRAY))
if(did_set_md_closing)
clear_bit(MD_CLOSING, &mddev->flags);
return err;
}