Skip to content

Commit 7e36e03

Browse files
committed
Merge tag 'md-7.1-20260428' of https://git.kernel.org/pub/scm/linux/kernel/git/mdraid/linux into block-7.1
Pull MD fixes from Yu Kuai: "Bug Fixes: - Fix a raid5 UAF on IO across the reshape position. - Avoid failing RAID1/RAID10 devices for invalid IO errors. - Fix RAID10 divide-by-zero when far_copies is zero. - Restore bitmap grow through sysfs. Cleanups: - Use mddev_is_dm() instead of open-coding gendisk checks. - Use ATTRIBUTE_GROUPS() for md default sysfs attributes. - Replace open-coded wait loops with wait_event helpers." * tag 'md-7.1-20260428' of https://git.kernel.org/pub/scm/linux/kernel/git/mdraid/linux: md: use ATTRIBUTE_GROUPS() for md default sysfs attributes md: use mddev_is_dm() instead of open-coding gendisk checks md/raid1: replace wait loop with wait_event_idle() in raid1_write_request() md/md-bitmap: add a none backend for bitmap grow md/md-bitmap: split bitmap sysfs groups md: factor bitmap creation away from sysfs handling md: use mddev_lock_nointr() in mddev_suspend_and_lock_nointr() md: replace wait loop with wait_event() in md_handle_request() md/raid10: fix divide-by-zero in setup_geo() with zero far_copies md/raid1,raid10: don't fail devices for invalid IO errors MAINTAINERS: Add Xiao Ni as md/raid reviewer md/raid5: Fix UAF on IO across the reshape position
2 parents 0898a81 + 3b2f70e commit 7e36e03

10 files changed

Lines changed: 251 additions & 109 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24764,6 +24764,7 @@ SOFTWARE RAID (Multiple Disks) SUPPORT
2476424764
M: Song Liu <song@kernel.org>
2476524765
M: Yu Kuai <yukuai@fnnas.com>
2476624766
R: Li Nan <linan122@huawei.com>
24767+
R: Xiao Ni <xiao@kernel.org>
2476724768
L: linux-raid@vger.kernel.org
2476824769
S: Supported
2476924770
Q: https://patchwork.kernel.org/project/linux-raid/list/

drivers/md/md-bitmap.c

Lines changed: 119 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ struct bitmap {
216216
};
217217

218218
static struct workqueue_struct *md_bitmap_wq;
219+
static struct attribute_group md_bitmap_internal_group;
219220

220221
static int __bitmap_resize(struct bitmap *bitmap, sector_t blocks,
221222
int chunksize, bool init);
@@ -2580,6 +2581,30 @@ static int bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize)
25802581
return __bitmap_resize(bitmap, blocks, chunksize, false);
25812582
}
25822583

2584+
static bool bitmap_none_enabled(void *data, bool flush)
2585+
{
2586+
return false;
2587+
}
2588+
2589+
static int bitmap_none_create(struct mddev *mddev)
2590+
{
2591+
return 0;
2592+
}
2593+
2594+
static int bitmap_none_load(struct mddev *mddev)
2595+
{
2596+
return 0;
2597+
}
2598+
2599+
static void bitmap_none_destroy(struct mddev *mddev)
2600+
{
2601+
}
2602+
2603+
static int bitmap_none_get_stats(void *data, struct md_bitmap_stats *stats)
2604+
{
2605+
return -ENOENT;
2606+
}
2607+
25832608
static ssize_t
25842609
location_show(struct mddev *mddev, char *page)
25852610
{
@@ -2618,7 +2643,11 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
26182643
goto out;
26192644
}
26202645

2621-
bitmap_destroy(mddev);
2646+
sysfs_unmerge_group(&mddev->kobj, &md_bitmap_internal_group);
2647+
md_bitmap_destroy_nosysfs(mddev);
2648+
mddev->bitmap_id = ID_BITMAP_NONE;
2649+
if (!mddev_set_bitmap_ops_nosysfs(mddev))
2650+
goto none_err;
26222651
mddev->bitmap_info.offset = 0;
26232652
if (mddev->bitmap_info.file) {
26242653
struct file *f = mddev->bitmap_info.file;
@@ -2654,16 +2683,25 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
26542683
}
26552684

26562685
mddev->bitmap_info.offset = offset;
2657-
rv = bitmap_create(mddev);
2686+
md_bitmap_destroy_nosysfs(mddev);
2687+
mddev->bitmap_id = ID_BITMAP;
2688+
if (!mddev_set_bitmap_ops_nosysfs(mddev))
2689+
goto bitmap_err;
2690+
2691+
rv = md_bitmap_create_nosysfs(mddev);
26582692
if (rv)
2659-
goto out;
2693+
goto create_err;
26602694

2661-
rv = bitmap_load(mddev);
2695+
rv = mddev->bitmap_ops->load(mddev);
26622696
if (rv) {
26632697
mddev->bitmap_info.offset = 0;
2664-
bitmap_destroy(mddev);
2665-
goto out;
2698+
goto load_err;
26662699
}
2700+
2701+
rv = sysfs_merge_group(&mddev->kobj,
2702+
&md_bitmap_internal_group);
2703+
if (rv)
2704+
goto merge_err;
26672705
}
26682706
}
26692707
if (!mddev->external) {
@@ -2679,6 +2717,22 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
26792717
if (rv)
26802718
return rv;
26812719
return len;
2720+
2721+
merge_err:
2722+
mddev->bitmap_info.offset = 0;
2723+
load_err:
2724+
md_bitmap_destroy_nosysfs(mddev);
2725+
create_err:
2726+
mddev->bitmap_info.offset = 0;
2727+
mddev->bitmap_id = ID_BITMAP_NONE;
2728+
if (!mddev_set_bitmap_ops_nosysfs(mddev))
2729+
rv = -ENOENT;
2730+
goto out;
2731+
bitmap_err:
2732+
rv = -ENOENT;
2733+
none_err:
2734+
mddev->bitmap_info.offset = 0;
2735+
goto out;
26822736
}
26832737

26842738
static struct md_sysfs_entry bitmap_location =
@@ -2955,8 +3009,12 @@ static struct md_sysfs_entry max_backlog_used =
29553009
__ATTR(max_backlog_used, S_IRUGO | S_IWUSR,
29563010
behind_writes_used_show, behind_writes_used_reset);
29573011

2958-
static struct attribute *md_bitmap_attrs[] = {
3012+
static struct attribute *md_bitmap_common_attrs[] = {
29593013
&bitmap_location.attr,
3014+
NULL
3015+
};
3016+
3017+
static struct attribute *md_bitmap_internal_attrs[] = {
29603018
&bitmap_space.attr,
29613019
&bitmap_timeout.attr,
29623020
&bitmap_backlog.attr,
@@ -2967,9 +3025,41 @@ static struct attribute *md_bitmap_attrs[] = {
29673025
NULL
29683026
};
29693027

2970-
static struct attribute_group md_bitmap_group = {
3028+
static struct attribute_group md_bitmap_common_group = {
29713029
.name = "bitmap",
2972-
.attrs = md_bitmap_attrs,
3030+
.attrs = md_bitmap_common_attrs,
3031+
};
3032+
3033+
static struct attribute_group md_bitmap_internal_group = {
3034+
.name = "bitmap",
3035+
.attrs = md_bitmap_internal_attrs,
3036+
};
3037+
3038+
static const struct attribute_group *bitmap_groups[] = {
3039+
&md_bitmap_common_group,
3040+
&md_bitmap_internal_group,
3041+
NULL,
3042+
};
3043+
3044+
static const struct attribute_group *bitmap_none_groups[] = {
3045+
&md_bitmap_common_group,
3046+
NULL,
3047+
};
3048+
3049+
static struct bitmap_operations bitmap_none_ops = {
3050+
.head = {
3051+
.type = MD_BITMAP,
3052+
.id = ID_BITMAP_NONE,
3053+
.name = "none",
3054+
},
3055+
3056+
.enabled = bitmap_none_enabled,
3057+
.create = bitmap_none_create,
3058+
.load = bitmap_none_load,
3059+
.destroy = bitmap_none_destroy,
3060+
.get_stats = bitmap_none_get_stats,
3061+
3062+
.groups = bitmap_none_groups,
29733063
};
29743064

29753065
static struct bitmap_operations bitmap_ops = {
@@ -3013,21 +3103,38 @@ static struct bitmap_operations bitmap_ops = {
30133103
.set_pages = bitmap_set_pages,
30143104
.free = md_bitmap_free,
30153105

3016-
.group = &md_bitmap_group,
3106+
.groups = bitmap_groups,
30173107
};
30183108

30193109
int md_bitmap_init(void)
30203110
{
3111+
int err;
3112+
30213113
md_bitmap_wq = alloc_workqueue("md_bitmap", WQ_MEM_RECLAIM | WQ_UNBOUND,
30223114
0);
30233115
if (!md_bitmap_wq)
30243116
return -ENOMEM;
30253117

3026-
return register_md_submodule(&bitmap_ops.head);
3118+
err = register_md_submodule(&bitmap_none_ops.head);
3119+
if (err)
3120+
goto err_wq;
3121+
3122+
err = register_md_submodule(&bitmap_ops.head);
3123+
if (err)
3124+
goto err_none;
3125+
3126+
return 0;
3127+
3128+
err_none:
3129+
unregister_md_submodule(&bitmap_none_ops.head);
3130+
err_wq:
3131+
destroy_workqueue(md_bitmap_wq);
3132+
return err;
30273133
}
30283134

30293135
void md_bitmap_exit(void)
30303136
{
3031-
destroy_workqueue(md_bitmap_wq);
30323137
unregister_md_submodule(&bitmap_ops.head);
3138+
unregister_md_submodule(&bitmap_none_ops.head);
3139+
destroy_workqueue(md_bitmap_wq);
30333140
}

drivers/md/md-bitmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct bitmap_operations {
125125
void (*set_pages)(void *data, unsigned long pages);
126126
void (*free)(void *data);
127127

128-
struct attribute_group *group;
128+
const struct attribute_group **groups;
129129
};
130130

131131
/* the bitmap API */

drivers/md/md-llbitmap.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,11 @@ static struct attribute_group md_llbitmap_group = {
17381738
.attrs = md_llbitmap_attrs,
17391739
};
17401740

1741+
static const struct attribute_group *md_llbitmap_groups[] = {
1742+
&md_llbitmap_group,
1743+
NULL,
1744+
};
1745+
17411746
static struct bitmap_operations llbitmap_ops = {
17421747
.head = {
17431748
.type = MD_BITMAP,
@@ -1774,7 +1779,7 @@ static struct bitmap_operations llbitmap_ops = {
17741779
.dirty_bits = llbitmap_dirty_bits,
17751780
.write_all = llbitmap_write_all,
17761781

1777-
.group = &md_llbitmap_group,
1782+
.groups = md_llbitmap_groups,
17781783
};
17791784

17801785
int md_llbitmap_init(void)

0 commit comments

Comments
 (0)