Commit b5ff2686 authored by Yu Kuai's avatar Yu Kuai Committed by Wentao Guan
Browse files

md/md-bitmap: remove the last parameter for bimtap_ops->endwrite()

stable inclusion
from stable-v6.6.79
commit 3e41ab9aef120ed172b8bada50839894341f1d7d
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBXANC

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=3e41ab9aef120ed172b8bada50839894341f1d7d



--------------------------------

commit 4f0e7d0e03b7b80af84759a9e7cfb0f81ac4adae upstream.

For the case that IO failed for one rdev, the bit will be mark as NEEDED
in following cases:

1) If badblocks is set and rdev is not faulty;
2) If rdev is faulty;

Case 1) is useless because synchronize data to badblocks make no sense.
Case 2) can be replaced with mddev->degraded.

Also remove R1BIO_Degraded, R10BIO_Degraded and STRIPE_DEGRADED since
case 2) no longer use them.

Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20250109015145.158868-3-yukuai1@huaweicloud.com


Signed-off-by: default avatarSong Liu <song@kernel.org>
[ Resolve minor conflicts ]
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 3e41ab9aef120ed172b8bada50839894341f1d7d)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent a5298969
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -1520,7 +1520,7 @@ int md_bitmap_startwrite(struct bitmap *bitmap, sector_t offset,
EXPORT_SYMBOL_GPL(md_bitmap_startwrite);

void md_bitmap_endwrite(struct bitmap *bitmap, sector_t offset,
			unsigned long sectors, int success)
			unsigned long sectors)
{
	if (!bitmap)
		return;
@@ -1537,15 +1537,16 @@ void md_bitmap_endwrite(struct bitmap *bitmap, sector_t offset,
			return;
		}

		if (success && !bitmap->mddev->degraded &&
		    bitmap->events_cleared < bitmap->mddev->events) {
		if (!bitmap->mddev->degraded) {
			if (bitmap->events_cleared < bitmap->mddev->events) {
				bitmap->events_cleared = bitmap->mddev->events;
				bitmap->need_sync = 1;
			sysfs_notify_dirent_safe(bitmap->sysfs_can_clear);
				sysfs_notify_dirent_safe(
						bitmap->sysfs_can_clear);
			}

		if (!success && !NEEDED(*bmc))
		} else if (!NEEDED(*bmc)) {
			*bmc |= NEEDED_MASK;
		}

		if (COUNTER(*bmc) == COUNTER_MAX)
			wake_up(&bitmap->overflow_wait);
+1 −1
Original line number Diff line number Diff line
@@ -255,7 +255,7 @@ void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long
int md_bitmap_startwrite(struct bitmap *bitmap, sector_t offset,
			 unsigned long sectors);
void md_bitmap_endwrite(struct bitmap *bitmap, sector_t offset,
			unsigned long sectors, int success);
			unsigned long sectors);
void md_bitmap_start_behind_write(struct mddev *mddev);
void md_bitmap_end_behind_write(struct mddev *mddev);
int md_bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int degraded);
+3 −24
Original line number Diff line number Diff line
@@ -424,8 +424,7 @@ static void close_write(struct r1bio *r1_bio)
		md_bitmap_end_behind_write(r1_bio->mddev);
	/* clear the bitmap if all writes complete successfully */
	md_bitmap_endwrite(r1_bio->mddev->bitmap, r1_bio->sector,
			   r1_bio->sectors,
			   !test_bit(R1BIO_Degraded, &r1_bio->state));
			   r1_bio->sectors);
	md_write_end(r1_bio->mddev);
}

@@ -482,8 +481,6 @@ static void raid1_end_write_request(struct bio *bio)
		if (!test_bit(Faulty, &rdev->flags))
			set_bit(R1BIO_WriteError, &r1_bio->state);
		else {
			/* Fail the request */
			set_bit(R1BIO_Degraded, &r1_bio->state);
			/* Finished with this branch */
			r1_bio->bios[mirror] = NULL;
			to_put = bio;
@@ -1410,11 +1407,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
			break;
		}
		r1_bio->bios[i] = NULL;
		if (!rdev || test_bit(Faulty, &rdev->flags)) {
			if (i < conf->raid_disks)
				set_bit(R1BIO_Degraded, &r1_bio->state);
		if (!rdev || test_bit(Faulty, &rdev->flags))
			continue;
		}

		atomic_inc(&rdev->nr_pending);
		if (test_bit(WriteErrorSeen, &rdev->flags)) {
@@ -1440,16 +1434,6 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
					 */
					max_sectors = bad_sectors;
				rdev_dec_pending(rdev, mddev);
				/* We don't set R1BIO_Degraded as that
				 * only applies if the disk is
				 * missing, so it might be re-added,
				 * and we want to know to recover this
				 * chunk.
				 * In this case the device is here,
				 * and the fact that this chunk is not
				 * in-sync is recorded in the bad
				 * block log
				 */
				continue;
			}
			if (is_bad) {
@@ -2464,12 +2448,9 @@ static void handle_write_finished(struct r1conf *conf, struct r1bio *r1_bio)
			 * errors.
			 */
			fail = true;
			if (!narrow_write_error(r1_bio, m)) {
			if (!narrow_write_error(r1_bio, m))
				md_error(conf->mddev,
					 conf->mirrors[m].rdev);
				/* an I/O failed, we can't clear the bitmap */
				set_bit(R1BIO_Degraded, &r1_bio->state);
			}
			rdev_dec_pending(conf->mirrors[m].rdev,
					 conf->mddev);
		}
@@ -2560,8 +2541,6 @@ static void raid1d(struct md_thread *thread)
			list_del(&r1_bio->retry_list);
			idx = sector_to_idx(r1_bio->sector);
			atomic_dec(&conf->nr_queued[idx]);
			if (mddev->degraded)
				set_bit(R1BIO_Degraded, &r1_bio->state);
			if (test_bit(R1BIO_WriteError, &r1_bio->state))
				close_write(r1_bio);
			raid_end_bio_io(r1_bio);
+0 −1
Original line number Diff line number Diff line
@@ -187,7 +187,6 @@ struct r1bio {
enum r1bio_state {
	R1BIO_Uptodate,
	R1BIO_IsSync,
	R1BIO_Degraded,
	R1BIO_BehindIO,
/* Set ReadError on bios that experience a readerror so that
 * raid1d knows what to do with them.
+3 −20
Original line number Diff line number Diff line
@@ -431,8 +431,7 @@ static void close_write(struct r10bio *r10_bio)
{
	/* clear the bitmap if all writes complete successfully */
	md_bitmap_endwrite(r10_bio->mddev->bitmap, r10_bio->sector,
			   r10_bio->sectors,
			   !test_bit(R10BIO_Degraded, &r10_bio->state));
			   r10_bio->sectors);
	md_write_end(r10_bio->mddev);
}

@@ -502,7 +501,6 @@ static void raid10_end_write_request(struct bio *bio)
				set_bit(R10BIO_WriteError, &r10_bio->state);
			else {
				/* Fail the request */
				set_bit(R10BIO_Degraded, &r10_bio->state);
				r10_bio->devs[slot].bio = NULL;
				to_put = bio;
				dec_rdev = 1;
@@ -1453,10 +1451,8 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
		r10_bio->devs[i].bio = NULL;
		r10_bio->devs[i].repl_bio = NULL;

		if (!rdev && !rrdev) {
			set_bit(R10BIO_Degraded, &r10_bio->state);
		if (!rdev && !rrdev)
			continue;
		}
		if (rdev && test_bit(WriteErrorSeen, &rdev->flags)) {
			sector_t first_bad;
			sector_t dev_sector = r10_bio->devs[i].addr;
@@ -1473,14 +1469,6 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
					 * to other devices yet
					 */
					max_sectors = bad_sectors;
				/* We don't set R10BIO_Degraded as that
				 * only applies if the disk is missing,
				 * so it might be re-added, and we want to
				 * know to recover this chunk.
				 * In this case the device is here, and the
				 * fact that this chunk is not in-sync is
				 * recorded in the bad block log.
				 */
				continue;
			}
			if (is_bad) {
@@ -2946,11 +2934,8 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
				rdev_dec_pending(rdev, conf->mddev);
			} else if (bio != NULL && bio->bi_status) {
				fail = true;
				if (!narrow_write_error(r10_bio, m)) {
				if (!narrow_write_error(r10_bio, m))
					md_error(conf->mddev, rdev);
					set_bit(R10BIO_Degraded,
						&r10_bio->state);
				}
				rdev_dec_pending(rdev, conf->mddev);
			}
			bio = r10_bio->devs[m].repl_bio;
@@ -3009,8 +2994,6 @@ static void raid10d(struct md_thread *thread)
			r10_bio = list_first_entry(&tmp, struct r10bio,
						   retry_list);
			list_del(&r10_bio->retry_list);
			if (mddev->degraded)
				set_bit(R10BIO_Degraded, &r10_bio->state);

			if (test_bit(R10BIO_WriteError,
				     &r10_bio->state))
Loading