Skip to content

Commit 47f521b

Browse files
committed
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md
Pull MD update from Shaohua Li: "This update mostly includes bug fixes: - md-cluster now supports raid10 from Guoqing - raid5 PPL fixes from Artur - badblock regression fix from Bo - suspend hang related fixes from Neil - raid5 reshape fixes from Neil - raid1 freeze deadlock fix from Nate - memleak fixes from Zdenek - bitmap related fixes from Me and Tao - other fixes and cleanups" * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md: (33 commits) md: free unused memory after bitmap resize md: release allocated bitset sync_set md/bitmap: clear BITMAP_WRITE_ERROR bit before writing it to sb md: be cautious about using ->curr_resync_completed for ->recovery_offset badblocks: fix wrong return value in badblocks_set if badblocks are disabled md: don't check MD_SB_CHANGE_CLEAN in md_allow_write md-cluster: update document for raid10 md: remove redundant variable q raid1: remove obsolete code in raid1_write_request md-cluster: Use a small window for raid10 resync md-cluster: Suspend writes in RAID10 if within range md-cluster/raid10: set "do_balance = 0" if area is resyncing md: use lockdep_assert_held raid1: prevent freeze_array/wait_all_barriers deadlock md: use TASK_IDLE instead of blocking signals md: remove special meaning of ->quiesce(.., 2) md: allow metadata update while suspending. md: use mddev_suspend/resume instead of ->quiesce() md: move suspend_hi/lo handling into core md code md: don't call bitmap_create() while array is quiesced. ...
2 parents b91593f + 0868b99 commit 47f521b

24 files changed

Lines changed: 409 additions & 223 deletions

Documentation/md/md-cluster.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
The cluster MD is a shared-device RAID for a cluster.
1+
The cluster MD is a shared-device RAID for a cluster, it supports
2+
two levels: raid1 and raid10 (limited support).
23

34

45
1. On-disk format

MAINTAINERS

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4103,6 +4103,8 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git
41034103
T: quilt http://people.redhat.com/agk/patches/linux/editing/
41044104
S: Maintained
41054105
F: Documentation/device-mapper/
4106+
F: drivers/md/Makefile
4107+
F: drivers/md/Kconfig
41064108
F: drivers/md/dm*
41074109
F: drivers/md/persistent-data/
41084110
F: include/linux/device-mapper.h
@@ -12487,7 +12489,10 @@ M: Shaohua Li <shli@kernel.org>
1248712489
L: linux-raid@vger.kernel.org
1248812490
T: git git://git.kernel.org/pub/scm/linux/kernel/git/shli/md.git
1248912491
S: Supported
12490-
F: drivers/md/
12492+
F: drivers/md/Makefile
12493+
F: drivers/md/Kconfig
12494+
F: drivers/md/md*
12495+
F: drivers/md/raid*
1249112496
F: include/linux/raid/
1249212497
F: include/uapi/linux/raid/
1249312498

block/badblocks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ int badblocks_set(struct badblocks *bb, sector_t s, int sectors,
178178

179179
if (bb->shift < 0)
180180
/* badblocks are disabled */
181-
return 0;
181+
return 1;
182182

183183
if (bb->shift) {
184184
/* round the start down, and the end up */

drivers/md/Kconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ config MD_FAULTY
178178

179179

180180
config MD_CLUSTER
181-
tristate "Cluster Support for MD (EXPERIMENTAL)"
181+
tristate "Cluster Support for MD"
182182
depends on BLK_DEV_MD
183183
depends on DLM
184184
default n
@@ -188,7 +188,8 @@ config MD_CLUSTER
188188
nodes in the cluster can access the MD devices simultaneously.
189189

190190
This brings the redundancy (and uptime) of RAID levels across the
191-
nodes of the cluster.
191+
nodes of the cluster. Currently, it can work with raid1 and raid10
192+
(limited support).
192193

193194
If unsure, say N.
194195

drivers/md/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ dm-cache-y += dm-cache-target.o dm-cache-metadata.o dm-cache-policy.o \
1919
dm-cache-smq-y += dm-cache-policy-smq.o
2020
dm-era-y += dm-era-target.o
2121
dm-verity-y += dm-verity-target.o
22-
md-mod-y += md.o bitmap.o
22+
md-mod-y += md.o md-bitmap.o
2323
raid456-y += raid5.o raid5-cache.o raid5-ppl.o
2424
dm-zoned-y += dm-zoned-target.o dm-zoned-metadata.o dm-zoned-reclaim.o
25+
linear-y += md-linear.o
26+
multipath-y += md-multipath.o
27+
faulty-y += md-faulty.o
2528

2629
# Note: link order is important. All raid personalities
2730
# and must come before md.o, as they each initialise

drivers/md/dm-raid.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "raid1.h"
1313
#include "raid5.h"
1414
#include "raid10.h"
15-
#include "bitmap.h"
15+
#include "md-bitmap.h"
1616

1717
#include <linux/device-mapper.h>
1818

@@ -3630,8 +3630,11 @@ static void raid_postsuspend(struct dm_target *ti)
36303630
{
36313631
struct raid_set *rs = ti->private;
36323632

3633-
if (!test_and_set_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags))
3633+
if (!test_and_set_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags)) {
3634+
mddev_lock_nointr(&rs->md);
36343635
mddev_suspend(&rs->md);
3636+
mddev_unlock(&rs->md);
3637+
}
36353638

36363639
rs->md.ro = 1;
36373640
}
@@ -3888,8 +3891,11 @@ static void raid_resume(struct dm_target *ti)
38883891
if (!(rs->ctr_flags & RESUME_STAY_FROZEN_FLAGS))
38893892
clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
38903893

3891-
if (test_and_clear_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags))
3894+
if (test_and_clear_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags)) {
3895+
mddev_lock_nointr(mddev);
38923896
mddev_resume(mddev);
3897+
mddev_unlock(mddev);
3898+
}
38933899
}
38943900

38953901
static struct target_type raid_target = {
Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <linux/seq_file.h>
3030
#include <trace/events/block.h>
3131
#include "md.h"
32-
#include "bitmap.h"
32+
#include "md-bitmap.h"
3333

3434
static inline char *bmname(struct bitmap *bitmap)
3535
{
@@ -459,7 +459,11 @@ void bitmap_update_sb(struct bitmap *bitmap)
459459
/* rocking back to read-only */
460460
bitmap->events_cleared = bitmap->mddev->events;
461461
sb->events_cleared = cpu_to_le64(bitmap->events_cleared);
462-
sb->state = cpu_to_le32(bitmap->flags);
462+
/*
463+
* clear BITMAP_WRITE_ERROR bit to protect against the case that
464+
* a bitmap write error occurred but the later writes succeeded.
465+
*/
466+
sb->state = cpu_to_le32(bitmap->flags & ~BIT(BITMAP_WRITE_ERROR));
463467
/* Just in case these have been changed via sysfs: */
464468
sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ);
465469
sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind);
@@ -625,7 +629,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
625629
err = read_sb_page(bitmap->mddev,
626630
offset,
627631
sb_page,
628-
0, PAGE_SIZE);
632+
0, sizeof(bitmap_super_t));
629633
}
630634
if (err)
631635
return err;
@@ -1816,6 +1820,12 @@ struct bitmap *bitmap_create(struct mddev *mddev, int slot)
18161820

18171821
BUG_ON(file && mddev->bitmap_info.offset);
18181822

1823+
if (test_bit(MD_HAS_JOURNAL, &mddev->flags)) {
1824+
pr_notice("md/raid:%s: array with journal cannot have bitmap\n",
1825+
mdname(mddev));
1826+
return ERR_PTR(-EBUSY);
1827+
}
1828+
18191829
bitmap = kzalloc(sizeof(*bitmap), GFP_KERNEL);
18201830
if (!bitmap)
18211831
return ERR_PTR(-ENOMEM);
@@ -2123,7 +2133,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
21232133
if (store.sb_page && bitmap->storage.sb_page)
21242134
memcpy(page_address(store.sb_page),
21252135
page_address(bitmap->storage.sb_page),
2126-
PAGE_SIZE);
2136+
sizeof(bitmap_super_t));
21272137
bitmap_file_unmap(&bitmap->storage);
21282138
bitmap->storage = store;
21292139

@@ -2152,6 +2162,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
21522162
for (k = 0; k < page; k++) {
21532163
kfree(new_bp[k].map);
21542164
}
2165+
kfree(new_bp);
21552166

21562167
/* restore some fields from old_counts */
21572168
bitmap->counts.bp = old_counts.bp;
@@ -2202,6 +2213,14 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
22022213
block += old_blocks;
22032214
}
22042215

2216+
if (bitmap->counts.bp != old_counts.bp) {
2217+
unsigned long k;
2218+
for (k = 0; k < old_counts.pages; k++)
2219+
if (!old_counts.bp[k].hijacked)
2220+
kfree(old_counts.bp[k].map);
2221+
kfree(old_counts.bp);
2222+
}
2223+
22052224
if (!init) {
22062225
int i;
22072226
while (block < (chunks << chunkshift)) {

drivers/md/md-cluster.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <linux/sched.h>
1616
#include <linux/raid/md_p.h>
1717
#include "md.h"
18-
#include "bitmap.h"
18+
#include "md-bitmap.h"
1919
#include "md-cluster.h"
2020

2121
#define LVB_SIZE 64
@@ -442,10 +442,11 @@ static void __remove_suspend_info(struct md_cluster_info *cinfo, int slot)
442442
static void remove_suspend_info(struct mddev *mddev, int slot)
443443
{
444444
struct md_cluster_info *cinfo = mddev->cluster_info;
445+
mddev->pers->quiesce(mddev, 1);
445446
spin_lock_irq(&cinfo->suspend_lock);
446447
__remove_suspend_info(cinfo, slot);
447448
spin_unlock_irq(&cinfo->suspend_lock);
448-
mddev->pers->quiesce(mddev, 2);
449+
mddev->pers->quiesce(mddev, 0);
449450
}
450451

451452

@@ -492,13 +493,12 @@ static void process_suspend_info(struct mddev *mddev,
492493
s->lo = lo;
493494
s->hi = hi;
494495
mddev->pers->quiesce(mddev, 1);
495-
mddev->pers->quiesce(mddev, 0);
496496
spin_lock_irq(&cinfo->suspend_lock);
497497
/* Remove existing entry (if exists) before adding */
498498
__remove_suspend_info(cinfo, slot);
499499
list_add(&s->list, &cinfo->suspend_list);
500500
spin_unlock_irq(&cinfo->suspend_lock);
501-
mddev->pers->quiesce(mddev, 2);
501+
mddev->pers->quiesce(mddev, 0);
502502
}
503503

504504
static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
@@ -1094,7 +1094,7 @@ static void metadata_update_cancel(struct mddev *mddev)
10941094
/*
10951095
* return 0 if all the bitmaps have the same sync_size
10961096
*/
1097-
int cluster_check_sync_size(struct mddev *mddev)
1097+
static int cluster_check_sync_size(struct mddev *mddev)
10981098
{
10991099
int i, rv;
11001100
bitmap_super_t *sb;
@@ -1478,7 +1478,7 @@ static struct md_cluster_operations cluster_ops = {
14781478

14791479
static int __init cluster_init(void)
14801480
{
1481-
pr_warn("md-cluster: EXPERIMENTAL. Use with caution\n");
1481+
pr_warn("md-cluster: support raid1 and raid10 (limited support)\n");
14821482
pr_info("Registering Cluster MD functions\n");
14831483
register_md_cluster_operations(&cluster_ops, THIS_MODULE);
14841484
return 0;

0 commit comments

Comments
 (0)