Skip to content

Commit 8e3f727

Browse files
author
CKI KWF Bot
committed
Merge: RHEL10.2 Update MD RAID to upstream 2nd release
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1681 JIRA: https://issues.redhat.com/browse/RHEL-123668 BREW: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=69335300 Upstream Status: Commits are found in Linus's git tree Signed-off-by: Nigel Croxon <ncroxon@redhat.com> Approved-by: Phil Auld <pauld@redhat.com> Approved-by: Xiao Ni <xni@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents bb84d75 + 432db83 commit 8e3f727

File tree

27 files changed

+578
-401
lines changed

27 files changed

+578
-401
lines changed

crypto/async_tx/async_pq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ do_sync_gen_syndrome(struct page **blocks, unsigned int *offsets, int disks,
119119
for (i = 0; i < disks; i++) {
120120
if (blocks[i] == NULL) {
121121
BUG_ON(i > disks - 3); /* P or Q can't be zero */
122-
srcs[i] = (void*)raid6_empty_zero_page;
122+
srcs[i] = raid6_get_zero_page();
123123
} else {
124124
srcs[i] = page_address(blocks[i]) + offsets[i];
125125

crypto/async_tx/async_raid6_recov.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ async_raid6_2data_recov(int disks, size_t bytes, int faila, int failb,
414414
async_tx_quiesce(&submit->depend_tx);
415415
for (i = 0; i < disks; i++)
416416
if (blocks[i] == NULL)
417-
ptrs[i] = (void *) raid6_empty_zero_page;
417+
ptrs[i] = raid6_get_zero_page();
418418
else
419419
ptrs[i] = page_address(blocks[i]) + offs[i];
420420

@@ -497,7 +497,7 @@ async_raid6_datap_recov(int disks, size_t bytes, int faila,
497497
async_tx_quiesce(&submit->depend_tx);
498498
for (i = 0; i < disks; i++)
499499
if (blocks[i] == NULL)
500-
ptrs[i] = (void*)raid6_empty_zero_page;
500+
ptrs[i] = raid6_get_zero_page();
501501
else
502502
ptrs[i] = page_address(blocks[i]) + offs[i];
503503

drivers/md/dm-raid.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static bool rs_is_reshapable(struct raid_set *rs)
438438
/* Return true, if raid set in @rs is recovering */
439439
static bool rs_is_recovering(struct raid_set *rs)
440440
{
441-
return rs->md.recovery_cp < rs->md.dev_sectors;
441+
return rs->md.resync_offset < rs->md.dev_sectors;
442442
}
443443

444444
/* Return true, if raid set in @rs is reshaping */
@@ -768,7 +768,7 @@ static struct raid_set *raid_set_alloc(struct dm_target *ti, struct raid_type *r
768768
rs->md.layout = raid_type->algorithm;
769769
rs->md.new_layout = rs->md.layout;
770770
rs->md.delta_disks = 0;
771-
rs->md.recovery_cp = MaxSector;
771+
rs->md.resync_offset = MaxSector;
772772

773773
for (i = 0; i < raid_devs; i++)
774774
md_rdev_init(&rs->dev[i].rdev);
@@ -912,7 +912,7 @@ static int parse_dev_params(struct raid_set *rs, struct dm_arg_set *as)
912912
rs->md.external = 0;
913913
rs->md.persistent = 1;
914914
rs->md.major_version = 2;
915-
} else if (rebuild && !rs->md.recovery_cp) {
915+
} else if (rebuild && !rs->md.resync_offset) {
916916
/*
917917
* Without metadata, we will not be able to tell if the array
918918
* is in-sync or not - we must assume it is not. Therefore,
@@ -1695,20 +1695,20 @@ static void rs_setup_recovery(struct raid_set *rs, sector_t dev_sectors)
16951695
{
16961696
/* raid0 does not recover */
16971697
if (rs_is_raid0(rs))
1698-
rs->md.recovery_cp = MaxSector;
1698+
rs->md.resync_offset = MaxSector;
16991699
/*
17001700
* A raid6 set has to be recovered either
17011701
* completely or for the grown part to
17021702
* ensure proper parity and Q-Syndrome
17031703
*/
17041704
else if (rs_is_raid6(rs))
1705-
rs->md.recovery_cp = dev_sectors;
1705+
rs->md.resync_offset = dev_sectors;
17061706
/*
17071707
* Other raid set types may skip recovery
17081708
* depending on the 'nosync' flag.
17091709
*/
17101710
else
1711-
rs->md.recovery_cp = test_bit(__CTR_FLAG_NOSYNC, &rs->ctr_flags)
1711+
rs->md.resync_offset = test_bit(__CTR_FLAG_NOSYNC, &rs->ctr_flags)
17121712
? MaxSector : dev_sectors;
17131713
}
17141714

@@ -2143,7 +2143,7 @@ static void super_sync(struct mddev *mddev, struct md_rdev *rdev)
21432143
sb->events = cpu_to_le64(mddev->events);
21442144

21452145
sb->disk_recovery_offset = cpu_to_le64(rdev->recovery_offset);
2146-
sb->array_resync_offset = cpu_to_le64(mddev->recovery_cp);
2146+
sb->array_resync_offset = cpu_to_le64(mddev->resync_offset);
21472147

21482148
sb->level = cpu_to_le32(mddev->level);
21492149
sb->layout = cpu_to_le32(mddev->layout);
@@ -2334,18 +2334,18 @@ static int super_init_validation(struct raid_set *rs, struct md_rdev *rdev)
23342334
}
23352335

23362336
if (!test_bit(__CTR_FLAG_NOSYNC, &rs->ctr_flags))
2337-
mddev->recovery_cp = le64_to_cpu(sb->array_resync_offset);
2337+
mddev->resync_offset = le64_to_cpu(sb->array_resync_offset);
23382338

23392339
/*
23402340
* During load, we set FirstUse if a new superblock was written.
23412341
* There are two reasons we might not have a superblock:
23422342
* 1) The raid set is brand new - in which case, all of the
23432343
* devices must have their In_sync bit set. Also,
2344-
* recovery_cp must be 0, unless forced.
2344+
* resync_offset must be 0, unless forced.
23452345
* 2) This is a new device being added to an old raid set
23462346
* and the new device needs to be rebuilt - in which
23472347
* case the In_sync bit will /not/ be set and
2348-
* recovery_cp must be MaxSector.
2348+
* resync_offset must be MaxSector.
23492349
* 3) This is/are a new device(s) being added to an old
23502350
* raid set during takeover to a higher raid level
23512351
* to provide capacity for redundancy or during reshape
@@ -2390,8 +2390,8 @@ static int super_init_validation(struct raid_set *rs, struct md_rdev *rdev)
23902390
new_devs > 1 ? "s" : "");
23912391
return -EINVAL;
23922392
} else if (!test_bit(__CTR_FLAG_REBUILD, &rs->ctr_flags) && rs_is_recovering(rs)) {
2393-
DMERR("'rebuild' specified while raid set is not in-sync (recovery_cp=%llu)",
2394-
(unsigned long long) mddev->recovery_cp);
2393+
DMERR("'rebuild' specified while raid set is not in-sync (resync_offset=%llu)",
2394+
(unsigned long long) mddev->resync_offset);
23952395
return -EINVAL;
23962396
} else if (rs_is_reshaping(rs)) {
23972397
DMERR("'rebuild' specified while raid set is being reshaped (reshape_position=%llu)",
@@ -2700,11 +2700,11 @@ static int rs_adjust_data_offsets(struct raid_set *rs)
27002700
}
27012701
out:
27022702
/*
2703-
* Raise recovery_cp in case data_offset != 0 to
2703+
* Raise resync_offset in case data_offset != 0 to
27042704
* avoid false recovery positives in the constructor.
27052705
*/
2706-
if (rs->md.recovery_cp < rs->md.dev_sectors)
2707-
rs->md.recovery_cp += rs->dev[0].rdev.data_offset;
2706+
if (rs->md.resync_offset < rs->md.dev_sectors)
2707+
rs->md.resync_offset += rs->dev[0].rdev.data_offset;
27082708

27092709
/* Adjust data offsets on all rdevs but on any raid4/5/6 journal device */
27102710
rdev_for_each(rdev, &rs->md) {
@@ -2759,15 +2759,15 @@ static int rs_setup_takeover(struct raid_set *rs)
27592759
}
27602760

27612761
clear_bit(MD_ARRAY_FIRST_USE, &mddev->flags);
2762-
mddev->recovery_cp = MaxSector;
2762+
mddev->resync_offset = MaxSector;
27632763

27642764
while (d--) {
27652765
rdev = &rs->dev[d].rdev;
27662766

27672767
if (test_bit(d, (void *) rs->rebuild_disks)) {
27682768
clear_bit(In_sync, &rdev->flags);
27692769
clear_bit(Faulty, &rdev->flags);
2770-
mddev->recovery_cp = rdev->recovery_offset = 0;
2770+
mddev->resync_offset = rdev->recovery_offset = 0;
27712771
/* Bitmap has to be created when we do an "up" takeover */
27722772
set_bit(MD_ARRAY_FIRST_USE, &mddev->flags);
27732773
}
@@ -3225,7 +3225,7 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
32253225
if (r)
32263226
goto bad;
32273227

3228-
rs_setup_recovery(rs, rs->md.recovery_cp < rs->md.dev_sectors ? rs->md.recovery_cp : rs->md.dev_sectors);
3228+
rs_setup_recovery(rs, rs->md.resync_offset < rs->md.dev_sectors ? rs->md.resync_offset : rs->md.dev_sectors);
32293229
} else {
32303230
/* This is no size change or it is shrinking, update size and record in superblocks */
32313231
r = rs_set_dev_and_array_sectors(rs, rs->ti->len, false);
@@ -3449,7 +3449,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery,
34493449

34503450
} else {
34513451
if (state == st_idle && !test_bit(MD_RECOVERY_INTR, &recovery))
3452-
r = mddev->recovery_cp;
3452+
r = mddev->resync_offset;
34533453
else
34543454
r = mddev->curr_resync_completed;
34553455

@@ -4073,15 +4073,15 @@ static int raid_preresume(struct dm_target *ti)
40734073
int chunksize = to_bytes(rs->requested_bitmap_chunk_sectors) ?: mddev->bitmap_info.chunksize;
40744074

40754075
r = mddev->bitmap_ops->resize(mddev, mddev->dev_sectors,
4076-
chunksize, false);
4076+
chunksize);
40774077
if (r)
40784078
DMERR("Failed to resize bitmap");
40794079
}
40804080

40814081
/* Check for any resize/reshape on @rs and adjust/initiate */
4082-
if (mddev->recovery_cp && mddev->recovery_cp < MaxSector) {
4082+
if (mddev->resync_offset && mddev->resync_offset < MaxSector) {
40834083
set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
4084-
mddev->resync_min = mddev->recovery_cp;
4084+
mddev->resync_min = mddev->resync_offset;
40854085
if (test_bit(RT_FLAG_RS_GROW, &rs->runtime_flags))
40864086
mddev->resync_max_sectors = mddev->dev_sectors;
40874087
}

drivers/md/md-bitmap.c

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -232,20 +232,19 @@ static inline char *bmname(struct bitmap *bitmap)
232232
return bitmap->mddev ? mdname(bitmap->mddev) : "mdX";
233233
}
234234

235-
static bool __bitmap_enabled(struct bitmap *bitmap)
235+
static bool bitmap_enabled(void *data, bool flush)
236236
{
237-
return bitmap->storage.filemap &&
238-
!test_bit(BITMAP_STALE, &bitmap->flags);
239-
}
240-
241-
static bool bitmap_enabled(struct mddev *mddev)
242-
{
243-
struct bitmap *bitmap = mddev->bitmap;
237+
struct bitmap *bitmap = data;
244238

245-
if (!bitmap)
246-
return false;
239+
if (!flush)
240+
return true;
247241

248-
return __bitmap_enabled(bitmap);
242+
/*
243+
* If caller want to flush bitmap pages to underlying disks, check if
244+
* there are cached pages in filemap.
245+
*/
246+
return !test_bit(BITMAP_STALE, &bitmap->flags) &&
247+
bitmap->storage.filemap != NULL;
249248
}
250249

251250
/*
@@ -484,7 +483,8 @@ static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap,
484483
return -EINVAL;
485484
}
486485

487-
md_super_write(mddev, rdev, sboff + ps, (int)min(size, bitmap_limit), page);
486+
md_write_metadata(mddev, rdev, sboff + ps, (int)min(size, bitmap_limit),
487+
page, 0);
488488
return 0;
489489
}
490490

@@ -1244,7 +1244,7 @@ static void __bitmap_unplug(struct bitmap *bitmap)
12441244
int dirty, need_write;
12451245
int writing = 0;
12461246

1247-
if (!__bitmap_enabled(bitmap))
1247+
if (!bitmap_enabled(bitmap, true))
12481248
return;
12491249

12501250
/* look at each page to see if there are any set bits that need to be
@@ -1788,15 +1788,9 @@ static bool __bitmap_start_sync(struct bitmap *bitmap, sector_t offset,
17881788
sector_t *blocks, bool degraded)
17891789
{
17901790
bitmap_counter_t *bmc;
1791-
bool rv;
1791+
bool rv = false;
17921792

1793-
if (bitmap == NULL) {/* FIXME or bitmap set as 'failed' */
1794-
*blocks = 1024;
1795-
return true; /* always resync if no bitmap */
1796-
}
17971793
spin_lock_irq(&bitmap->counts.lock);
1798-
1799-
rv = false;
18001794
bmc = md_bitmap_get_counter(&bitmap->counts, offset, blocks, 0);
18011795
if (bmc) {
18021796
/* locked */
@@ -1845,10 +1839,6 @@ static void __bitmap_end_sync(struct bitmap *bitmap, sector_t offset,
18451839
bitmap_counter_t *bmc;
18461840
unsigned long flags;
18471841

1848-
if (bitmap == NULL) {
1849-
*blocks = 1024;
1850-
return;
1851-
}
18521842
spin_lock_irqsave(&bitmap->counts.lock, flags);
18531843
bmc = md_bitmap_get_counter(&bitmap->counts, offset, blocks, 0);
18541844
if (bmc == NULL)
@@ -1987,12 +1977,12 @@ static void bitmap_dirty_bits(struct mddev *mddev, unsigned long s,
19871977

19881978
md_bitmap_set_memory_bits(bitmap, sec, 1);
19891979
md_bitmap_file_set_bit(bitmap, sec);
1990-
if (sec < bitmap->mddev->recovery_cp)
1980+
if (sec < bitmap->mddev->resync_offset)
19911981
/* We are asserting that the array is dirty,
1992-
* so move the recovery_cp address back so
1982+
* so move the resync_offset address back so
19931983
* that it is obvious that it is dirty
19941984
*/
1995-
bitmap->mddev->recovery_cp = sec;
1985+
bitmap->mddev->resync_offset = sec;
19961986
}
19971987
}
19981988

@@ -2060,9 +2050,6 @@ static void bitmap_start_behind_write(struct mddev *mddev)
20602050
struct bitmap *bitmap = mddev->bitmap;
20612051
int bw;
20622052

2063-
if (!bitmap)
2064-
return;
2065-
20662053
atomic_inc(&bitmap->behind_writes);
20672054
bw = atomic_read(&bitmap->behind_writes);
20682055
if (bw > bitmap->behind_writes_used)
@@ -2076,9 +2063,6 @@ static void bitmap_end_behind_write(struct mddev *mddev)
20762063
{
20772064
struct bitmap *bitmap = mddev->bitmap;
20782065

2079-
if (!bitmap)
2080-
return;
2081-
20822066
if (atomic_dec_and_test(&bitmap->behind_writes))
20832067
wake_up(&bitmap->behind_wait);
20842068
pr_debug("dec write-behind count %d/%lu\n",
@@ -2258,7 +2242,7 @@ static int bitmap_load(struct mddev *mddev)
22582242
|| bitmap->events_cleared == mddev->events)
22592243
/* no need to keep dirty bits to optimise a
22602244
* re-add of a missing device */
2261-
start = mddev->recovery_cp;
2245+
start = mddev->resync_offset;
22622246

22632247
mutex_lock(&mddev->bitmap_info.mutex);
22642248
err = md_bitmap_init_from_disk(bitmap, start);
@@ -2593,15 +2577,14 @@ static int __bitmap_resize(struct bitmap *bitmap, sector_t blocks,
25932577
return ret;
25942578
}
25952579

2596-
static int bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
2597-
bool init)
2580+
static int bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize)
25982581
{
25992582
struct bitmap *bitmap = mddev->bitmap;
26002583

26012584
if (!bitmap)
26022585
return 0;
26032586

2604-
return __bitmap_resize(bitmap, blocks, chunksize, init);
2587+
return __bitmap_resize(bitmap, blocks, chunksize, false);
26052588
}
26062589

26072590
static ssize_t
@@ -2990,7 +2973,8 @@ static struct attribute *md_bitmap_attrs[] = {
29902973
&max_backlog_used.attr,
29912974
NULL
29922975
};
2993-
const struct attribute_group md_bitmap_group = {
2976+
2977+
static struct attribute_group md_bitmap_group = {
29942978
.name = "bitmap",
29952979
.attrs = md_bitmap_attrs,
29962980
};
@@ -3026,6 +3010,8 @@ static struct bitmap_operations bitmap_ops = {
30263010
.copy_from_slot = bitmap_copy_from_slot,
30273011
.set_pages = bitmap_set_pages,
30283012
.free = md_bitmap_free,
3013+
3014+
.group = &md_bitmap_group,
30293015
};
30303016

30313017
void mddev_set_bitmap_ops(struct mddev *mddev)

0 commit comments

Comments
 (0)