Skip to content

Commit 7d251be

Browse files
committed
Merge tag 'md-6.11-20240704' of git://git.kernel.org/pub/scm/linux/kernel/git/song/md into for-6.11/block
Merge MD fixes from Song: "This PR contains various small fixes by Yu Kuai, Benjamin Marzinski, Christophe JAILLET, and Yang Li." * tag 'md-6.11-20240704' of git://git.kernel.org/pub/scm/linux/kernel/git/song/md: md/raid5: recheck if reshape has finished with device_lock held md: Don't wait for MD_RECOVERY_NEEDED for HOT_REMOVE_DISK ioctl md-cluster: Constify struct md_cluster_operations md: Remove unneeded semicolon md/raid5: fix spares errors about rcu usage
2 parents 162e068 + 25b3a82 commit 7d251be

File tree

4 files changed

+52
-42
lines changed

4 files changed

+52
-42
lines changed

drivers/md/md-cluster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ static int gather_bitmaps(struct md_rdev *rdev)
15701570
return err;
15711571
}
15721572

1573-
static struct md_cluster_operations cluster_ops = {
1573+
static const struct md_cluster_operations cluster_ops = {
15741574
.join = join,
15751575
.leave = leave,
15761576
.slot_number = slot_number,

drivers/md/md.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static DEFINE_SPINLOCK(pers_lock);
8585

8686
static const struct kobj_type md_ktype;
8787

88-
struct md_cluster_operations *md_cluster_ops;
88+
const struct md_cluster_operations *md_cluster_ops;
8989
EXPORT_SYMBOL(md_cluster_ops);
9090
static struct module *md_cluster_mod;
9191

@@ -627,7 +627,7 @@ static void md_submit_flush_data(struct work_struct *ws)
627627
* always is 0, make_request() will not be called here.
628628
*/
629629
if (WARN_ON_ONCE(!mddev->pers->make_request(mddev, bio)))
630-
bio_io_error(bio);;
630+
bio_io_error(bio);
631631
}
632632

633633
/* The pair is percpu_ref_get() from md_flush_request() */
@@ -7765,12 +7765,6 @@ static int md_ioctl(struct block_device *bdev, blk_mode_t mode,
77657765
return get_bitmap_file(mddev, argp);
77667766
}
77677767

7768-
if (cmd == HOT_REMOVE_DISK)
7769-
/* need to ensure recovery thread has run */
7770-
wait_event_interruptible_timeout(mddev->sb_wait,
7771-
!test_bit(MD_RECOVERY_NEEDED,
7772-
&mddev->recovery),
7773-
msecs_to_jiffies(5000));
77747768
if (cmd == STOP_ARRAY || cmd == STOP_ARRAY_RO) {
77757769
/* Need to flush page cache, and ensure no-one else opens
77767770
* and writes
@@ -8543,7 +8537,7 @@ int unregister_md_personality(struct md_personality *p)
85438537
}
85448538
EXPORT_SYMBOL(unregister_md_personality);
85458539

8546-
int register_md_cluster_operations(struct md_cluster_operations *ops,
8540+
int register_md_cluster_operations(const struct md_cluster_operations *ops,
85478541
struct module *module)
85488542
{
85498543
int ret = 0;

drivers/md/md.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ static inline void safe_put_page(struct page *p)
849849

850850
extern int register_md_personality(struct md_personality *p);
851851
extern int unregister_md_personality(struct md_personality *p);
852-
extern int register_md_cluster_operations(struct md_cluster_operations *ops,
852+
extern int register_md_cluster_operations(const struct md_cluster_operations *ops,
853853
struct module *module);
854854
extern int unregister_md_cluster_operations(void);
855855
extern int md_setup_cluster(struct mddev *mddev, int nodes);
@@ -932,7 +932,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
932932
}
933933
}
934934

935-
extern struct md_cluster_operations *md_cluster_ops;
935+
extern const struct md_cluster_operations *md_cluster_ops;
936936
static inline int mddev_is_clustered(struct mddev *mddev)
937937
{
938938
return mddev->cluster_info && mddev->bitmap_info.nodes > 1;

drivers/md/raid5.c

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static int raid6_idx_to_slot(int idx, struct stripe_head *sh,
155155
return slot;
156156
}
157157

158-
static void print_raid5_conf (struct r5conf *conf);
158+
static void print_raid5_conf(struct r5conf *conf);
159159

160160
static int stripe_operations_active(struct stripe_head *sh)
161161
{
@@ -5899,6 +5899,39 @@ static int add_all_stripe_bios(struct r5conf *conf,
58995899
return ret;
59005900
}
59015901

5902+
enum reshape_loc {
5903+
LOC_NO_RESHAPE,
5904+
LOC_AHEAD_OF_RESHAPE,
5905+
LOC_INSIDE_RESHAPE,
5906+
LOC_BEHIND_RESHAPE,
5907+
};
5908+
5909+
static enum reshape_loc get_reshape_loc(struct mddev *mddev,
5910+
struct r5conf *conf, sector_t logical_sector)
5911+
{
5912+
sector_t reshape_progress, reshape_safe;
5913+
/*
5914+
* Spinlock is needed as reshape_progress may be
5915+
* 64bit on a 32bit platform, and so it might be
5916+
* possible to see a half-updated value
5917+
* Of course reshape_progress could change after
5918+
* the lock is dropped, so once we get a reference
5919+
* to the stripe that we think it is, we will have
5920+
* to check again.
5921+
*/
5922+
spin_lock_irq(&conf->device_lock);
5923+
reshape_progress = conf->reshape_progress;
5924+
reshape_safe = conf->reshape_safe;
5925+
spin_unlock_irq(&conf->device_lock);
5926+
if (reshape_progress == MaxSector)
5927+
return LOC_NO_RESHAPE;
5928+
if (ahead_of_reshape(mddev, logical_sector, reshape_progress))
5929+
return LOC_AHEAD_OF_RESHAPE;
5930+
if (ahead_of_reshape(mddev, logical_sector, reshape_safe))
5931+
return LOC_INSIDE_RESHAPE;
5932+
return LOC_BEHIND_RESHAPE;
5933+
}
5934+
59025935
static enum stripe_result make_stripe_request(struct mddev *mddev,
59035936
struct r5conf *conf, struct stripe_request_ctx *ctx,
59045937
sector_t logical_sector, struct bio *bi)
@@ -5913,28 +5946,14 @@ static enum stripe_result make_stripe_request(struct mddev *mddev,
59135946
seq = read_seqcount_begin(&conf->gen_lock);
59145947

59155948
if (unlikely(conf->reshape_progress != MaxSector)) {
5916-
/*
5917-
* Spinlock is needed as reshape_progress may be
5918-
* 64bit on a 32bit platform, and so it might be
5919-
* possible to see a half-updated value
5920-
* Of course reshape_progress could change after
5921-
* the lock is dropped, so once we get a reference
5922-
* to the stripe that we think it is, we will have
5923-
* to check again.
5924-
*/
5925-
spin_lock_irq(&conf->device_lock);
5926-
if (ahead_of_reshape(mddev, logical_sector,
5927-
conf->reshape_progress)) {
5928-
previous = 1;
5929-
} else {
5930-
if (ahead_of_reshape(mddev, logical_sector,
5931-
conf->reshape_safe)) {
5932-
spin_unlock_irq(&conf->device_lock);
5933-
ret = STRIPE_SCHEDULE_AND_RETRY;
5934-
goto out;
5935-
}
5949+
enum reshape_loc loc = get_reshape_loc(mddev, conf,
5950+
logical_sector);
5951+
if (loc == LOC_INSIDE_RESHAPE) {
5952+
ret = STRIPE_SCHEDULE_AND_RETRY;
5953+
goto out;
59365954
}
5937-
spin_unlock_irq(&conf->device_lock);
5955+
if (loc == LOC_AHEAD_OF_RESHAPE)
5956+
previous = 1;
59385957
}
59395958

59405959
new_sector = raid5_compute_sector(conf, logical_sector, previous,
@@ -6112,8 +6131,7 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
61126131
/* Bail out if conflicts with reshape and REQ_NOWAIT is set */
61136132
if ((bi->bi_opf & REQ_NOWAIT) &&
61146133
(conf->reshape_progress != MaxSector) &&
6115-
!ahead_of_reshape(mddev, logical_sector, conf->reshape_progress) &&
6116-
ahead_of_reshape(mddev, logical_sector, conf->reshape_safe)) {
6134+
get_reshape_loc(mddev, conf, logical_sector) == LOC_INSIDE_RESHAPE) {
61176135
bio_wouldblock_error(bi);
61186136
if (rw == WRITE)
61196137
md_write_end(mddev);
@@ -7568,11 +7586,11 @@ static struct r5conf *setup_conf(struct mddev *mddev)
75687586
if (test_bit(Replacement, &rdev->flags)) {
75697587
if (disk->replacement)
75707588
goto abort;
7571-
RCU_INIT_POINTER(disk->replacement, rdev);
7589+
disk->replacement = rdev;
75727590
} else {
75737591
if (disk->rdev)
75747592
goto abort;
7575-
RCU_INIT_POINTER(disk->rdev, rdev);
7593+
disk->rdev = rdev;
75767594
}
75777595

75787596
if (test_bit(In_sync, &rdev->flags)) {
@@ -8054,7 +8072,7 @@ static void raid5_status(struct seq_file *seq, struct mddev *mddev)
80548072
seq_printf (seq, "]");
80558073
}
80568074

8057-
static void print_raid5_conf (struct r5conf *conf)
8075+
static void print_raid5_conf(struct r5conf *conf)
80588076
{
80598077
struct md_rdev *rdev;
80608078
int i;
@@ -8068,15 +8086,13 @@ static void print_raid5_conf (struct r5conf *conf)
80688086
conf->raid_disks,
80698087
conf->raid_disks - conf->mddev->degraded);
80708088

8071-
rcu_read_lock();
80728089
for (i = 0; i < conf->raid_disks; i++) {
8073-
rdev = rcu_dereference(conf->disks[i].rdev);
8090+
rdev = conf->disks[i].rdev;
80748091
if (rdev)
80758092
pr_debug(" disk %d, o:%d, dev:%pg\n",
80768093
i, !test_bit(Faulty, &rdev->flags),
80778094
rdev->bdev);
80788095
}
8079-
rcu_read_unlock();
80808096
}
80818097

80828098
static int raid5_spare_active(struct mddev *mddev)

0 commit comments

Comments
 (0)