Commit 7d07402e authored by Jens Axboe's avatar Jens Axboe

Merge tag 'md-next-20230814-resend' of...

Merge tag 'md-next-20230814-resend' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md into for-6.6/block

Pull MD fixes from Song:

"1. raid6test build fixes, by WANG Xuerui
 2. Various non-urgent fixes."

* tag 'md-next-20230814-resend' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md:
  md/raid5-cache: fix null-ptr-deref for r5l_flush_stripe_to_raid()
  raid6: test: only check for Altivec if building on powerpc hosts
  raid6: test: make sure all intermediate and artifact files are .gitignored
  raid6: test: cosmetic cleanups for the test Makefile
  raid6: guard the tables.c include of <linux/export.h> with __KERNEL__
  raid6: remove the <linux/export.h> include from recov.c
  md: Hold mddev->reconfig_mutex when trying to get mddev->sync_thread
  md/raid10: fix a 'conf->barrier' leakage in raid10_takeover()
  md: raid1: fix potential OOB in raid1_remove_disk()
  md/raid5-cache: fix a deadlock in r5l_exit_log()
parents 66a6a5d0 0d0bd28c
...@@ -952,8 +952,8 @@ static int join(struct mddev *mddev, int nodes) ...@@ -952,8 +952,8 @@ static int join(struct mddev *mddev, int nodes)
return 0; return 0;
err: err:
set_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); set_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state);
md_unregister_thread(&cinfo->recovery_thread); md_unregister_thread(mddev, &cinfo->recovery_thread);
md_unregister_thread(&cinfo->recv_thread); md_unregister_thread(mddev, &cinfo->recv_thread);
lockres_free(cinfo->message_lockres); lockres_free(cinfo->message_lockres);
lockres_free(cinfo->token_lockres); lockres_free(cinfo->token_lockres);
lockres_free(cinfo->ack_lockres); lockres_free(cinfo->ack_lockres);
...@@ -1015,8 +1015,8 @@ static int leave(struct mddev *mddev) ...@@ -1015,8 +1015,8 @@ static int leave(struct mddev *mddev)
resync_bitmap(mddev); resync_bitmap(mddev);
set_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); set_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state);
md_unregister_thread(&cinfo->recovery_thread); md_unregister_thread(mddev, &cinfo->recovery_thread);
md_unregister_thread(&cinfo->recv_thread); md_unregister_thread(mddev, &cinfo->recv_thread);
lockres_free(cinfo->message_lockres); lockres_free(cinfo->message_lockres);
lockres_free(cinfo->token_lockres); lockres_free(cinfo->token_lockres);
lockres_free(cinfo->ack_lockres); lockres_free(cinfo->ack_lockres);
......
...@@ -6258,7 +6258,7 @@ static void mddev_detach(struct mddev *mddev) ...@@ -6258,7 +6258,7 @@ static void mddev_detach(struct mddev *mddev)
mddev->pers->quiesce(mddev, 1); mddev->pers->quiesce(mddev, 1);
mddev->pers->quiesce(mddev, 0); mddev->pers->quiesce(mddev, 0);
} }
md_unregister_thread(&mddev->thread); md_unregister_thread(mddev, &mddev->thread);
if (mddev->queue) if (mddev->queue)
blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
} }
...@@ -7990,9 +7990,10 @@ struct md_thread *md_register_thread(void (*run) (struct md_thread *), ...@@ -7990,9 +7990,10 @@ struct md_thread *md_register_thread(void (*run) (struct md_thread *),
} }
EXPORT_SYMBOL(md_register_thread); EXPORT_SYMBOL(md_register_thread);
void md_unregister_thread(struct md_thread __rcu **threadp) void md_unregister_thread(struct mddev *mddev, struct md_thread __rcu **threadp)
{ {
struct md_thread *thread = rcu_dereference_protected(*threadp, true); struct md_thread *thread = rcu_dereference_protected(*threadp,
lockdep_is_held(&mddev->reconfig_mutex));
if (!thread) if (!thread)
return; return;
...@@ -9484,7 +9485,7 @@ void md_reap_sync_thread(struct mddev *mddev) ...@@ -9484,7 +9485,7 @@ void md_reap_sync_thread(struct mddev *mddev)
bool is_reshaped = false; bool is_reshaped = false;
/* resync has finished, collect result */ /* resync has finished, collect result */
md_unregister_thread(&mddev->sync_thread); md_unregister_thread(mddev, &mddev->sync_thread);
atomic_inc(&mddev->sync_seq); atomic_inc(&mddev->sync_seq);
if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery) && if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery) &&
......
...@@ -761,7 +761,7 @@ extern struct md_thread *md_register_thread( ...@@ -761,7 +761,7 @@ extern struct md_thread *md_register_thread(
void (*run)(struct md_thread *thread), void (*run)(struct md_thread *thread),
struct mddev *mddev, struct mddev *mddev,
const char *name); const char *name);
extern void md_unregister_thread(struct md_thread __rcu **threadp); extern void md_unregister_thread(struct mddev *mddev, struct md_thread __rcu **threadp);
extern void md_wakeup_thread(struct md_thread __rcu *thread); extern void md_wakeup_thread(struct md_thread __rcu *thread);
extern void md_check_recovery(struct mddev *mddev); extern void md_check_recovery(struct mddev *mddev);
extern void md_reap_sync_thread(struct mddev *mddev); extern void md_reap_sync_thread(struct mddev *mddev);
......
...@@ -1837,6 +1837,10 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev) ...@@ -1837,6 +1837,10 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
struct r1conf *conf = mddev->private; struct r1conf *conf = mddev->private;
int err = 0; int err = 0;
int number = rdev->raid_disk; int number = rdev->raid_disk;
if (unlikely(number >= conf->raid_disks))
goto abort;
struct raid1_info *p = conf->mirrors + number; struct raid1_info *p = conf->mirrors + number;
if (rdev != p->rdev) if (rdev != p->rdev)
...@@ -3152,7 +3156,7 @@ static int raid1_run(struct mddev *mddev) ...@@ -3152,7 +3156,7 @@ static int raid1_run(struct mddev *mddev)
* RAID1 needs at least one disk in active * RAID1 needs at least one disk in active
*/ */
if (conf->raid_disks - mddev->degraded < 1) { if (conf->raid_disks - mddev->degraded < 1) {
md_unregister_thread(&conf->thread); md_unregister_thread(mddev, &conf->thread);
ret = -EINVAL; ret = -EINVAL;
goto abort; goto abort;
} }
...@@ -3179,7 +3183,7 @@ static int raid1_run(struct mddev *mddev) ...@@ -3179,7 +3183,7 @@ static int raid1_run(struct mddev *mddev)
ret = md_integrity_register(mddev); ret = md_integrity_register(mddev);
if (ret) { if (ret) {
md_unregister_thread(&mddev->thread); md_unregister_thread(mddev, &mddev->thread);
goto abort; goto abort;
} }
return 0; return 0;
......
...@@ -4320,7 +4320,7 @@ static int raid10_run(struct mddev *mddev) ...@@ -4320,7 +4320,7 @@ static int raid10_run(struct mddev *mddev)
return 0; return 0;
out_free_conf: out_free_conf:
md_unregister_thread(&mddev->thread); md_unregister_thread(mddev, &mddev->thread);
raid10_free_conf(conf); raid10_free_conf(conf);
mddev->private = NULL; mddev->private = NULL;
out: out:
...@@ -4417,7 +4417,6 @@ static void *raid10_takeover_raid0(struct mddev *mddev, sector_t size, int devs) ...@@ -4417,7 +4417,6 @@ static void *raid10_takeover_raid0(struct mddev *mddev, sector_t size, int devs)
rdev->new_raid_disk = rdev->raid_disk * 2; rdev->new_raid_disk = rdev->raid_disk * 2;
rdev->sectors = size; rdev->sectors = size;
} }
WRITE_ONCE(conf->barrier, 1);
} }
return conf; return conf;
......
...@@ -1260,14 +1260,13 @@ static void r5l_log_flush_endio(struct bio *bio) ...@@ -1260,14 +1260,13 @@ static void r5l_log_flush_endio(struct bio *bio)
if (bio->bi_status) if (bio->bi_status)
md_error(log->rdev->mddev, log->rdev); md_error(log->rdev->mddev, log->rdev);
bio_uninit(bio);
spin_lock_irqsave(&log->io_list_lock, flags); spin_lock_irqsave(&log->io_list_lock, flags);
list_for_each_entry(io, &log->flushing_ios, log_sibling) list_for_each_entry(io, &log->flushing_ios, log_sibling)
r5l_io_run_stripes(io); r5l_io_run_stripes(io);
list_splice_tail_init(&log->flushing_ios, &log->finished_ios); list_splice_tail_init(&log->flushing_ios, &log->finished_ios);
spin_unlock_irqrestore(&log->io_list_lock, flags); spin_unlock_irqrestore(&log->io_list_lock, flags);
bio_uninit(bio);
} }
/* /*
...@@ -3168,12 +3167,15 @@ void r5l_exit_log(struct r5conf *conf) ...@@ -3168,12 +3167,15 @@ void r5l_exit_log(struct r5conf *conf)
{ {
struct r5l_log *log = conf->log; struct r5l_log *log = conf->log;
/* Ensure disable_writeback_work wakes up and exits */ md_unregister_thread(conf->mddev, &log->reclaim_thread);
wake_up(&conf->mddev->sb_wait);
flush_work(&log->disable_writeback_work);
md_unregister_thread(&log->reclaim_thread);
/*
* 'reconfig_mutex' is held by caller, set 'confg->log' to NULL to
* ensure disable_writeback_work wakes up and exits.
*/
conf->log = NULL; conf->log = NULL;
wake_up(&conf->mddev->sb_wait);
flush_work(&log->disable_writeback_work);
mempool_exit(&log->meta_pool); mempool_exit(&log->meta_pool);
bioset_exit(&log->bs); bioset_exit(&log->bs);
......
...@@ -8107,7 +8107,7 @@ static int raid5_run(struct mddev *mddev) ...@@ -8107,7 +8107,7 @@ static int raid5_run(struct mddev *mddev)
return 0; return 0;
abort: abort:
md_unregister_thread(&mddev->thread); md_unregister_thread(mddev, &mddev->thread);
print_raid5_conf(conf); print_raid5_conf(conf);
free_conf(conf); free_conf(conf);
mddev->private = NULL; mddev->private = NULL;
......
...@@ -56,7 +56,9 @@ int main(int argc, char *argv[]) ...@@ -56,7 +56,9 @@ int main(int argc, char *argv[])
uint8_t v; uint8_t v;
uint8_t exptbl[256], invtbl[256]; uint8_t exptbl[256], invtbl[256];
printf("#ifdef __KERNEL__\n");
printf("#include <linux/export.h>\n"); printf("#include <linux/export.h>\n");
printf("#endif\n");
printf("#include <linux/raid/pq.h>\n"); printf("#include <linux/raid/pq.h>\n");
/* Compute multiplication table */ /* Compute multiplication table */
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
* the syndrome.) * the syndrome.)
*/ */
#include <linux/export.h>
#include <linux/raid/pq.h> #include <linux/raid/pq.h>
/* Recover two failed data blocks. */ /* Recover two failed data blocks. */
......
/int.uc
/neon.uc
/raid6test
...@@ -6,14 +6,15 @@ ...@@ -6,14 +6,15 @@
pound := \# pound := \#
CC = gcc # Adjust as desired
OPTFLAGS = -O2 # Adjust as desired CC = gcc
CFLAGS = -I.. -I ../../../include -g $(OPTFLAGS) OPTFLAGS = -O2
LD = ld CFLAGS = -I.. -I ../../../include -g $(OPTFLAGS)
AWK = awk -f LD = ld
AR = ar AWK = awk -f
RANLIB = ranlib AR = ar
OBJS = int1.o int2.o int4.o int8.o int16.o int32.o recov.o algos.o tables.o RANLIB = ranlib
OBJS = int1.o int2.o int4.o int8.o int16.o int32.o recov.o algos.o tables.o
ARCH := $(shell uname -m 2>/dev/null | sed -e /s/i.86/i386/) ARCH := $(shell uname -m 2>/dev/null | sed -e /s/i.86/i386/)
ifeq ($(ARCH),i386) ifeq ($(ARCH),i386)
...@@ -34,24 +35,25 @@ ifeq ($(ARCH),aarch64) ...@@ -34,24 +35,25 @@ ifeq ($(ARCH),aarch64)
HAS_NEON = yes HAS_NEON = yes
endif endif
ifeq ($(findstring ppc,$(ARCH)),ppc)
CFLAGS += -I../../../arch/powerpc/include
HAS_ALTIVEC := $(shell printf '$(pound)include <altivec.h>\nvector int a;\n' |\
gcc -c -x c - >/dev/null && rm ./-.o && echo yes)
endif
ifeq ($(IS_X86),yes) ifeq ($(IS_X86),yes)
OBJS += mmx.o sse1.o sse2.o avx2.o recov_ssse3.o recov_avx2.o avx512.o recov_avx512.o OBJS += mmx.o sse1.o sse2.o avx2.o recov_ssse3.o recov_avx2.o avx512.o recov_avx512.o
CFLAGS += -DCONFIG_X86 CFLAGS += -DCONFIG_X86
CFLAGS += $(shell echo "vpmovm2b %k1, %zmm5" | \ CFLAGS += $(shell echo "vpmovm2b %k1, %zmm5" | \
gcc -c -x assembler - >/dev/null 2>&1 && \ gcc -c -x assembler - >/dev/null 2>&1 && \
rm ./-.o && echo -DCONFIG_AS_AVX512=1) rm ./-.o && echo -DCONFIG_AS_AVX512=1)
else ifeq ($(HAS_NEON),yes) else ifeq ($(HAS_NEON),yes)
OBJS += neon.o neon1.o neon2.o neon4.o neon8.o recov_neon.o recov_neon_inner.o OBJS += neon.o neon1.o neon2.o neon4.o neon8.o recov_neon.o recov_neon_inner.o
CFLAGS += -DCONFIG_KERNEL_MODE_NEON=1 CFLAGS += -DCONFIG_KERNEL_MODE_NEON=1
else else ifeq ($(HAS_ALTIVEC),yes)
HAS_ALTIVEC := $(shell printf '$(pound)include <altivec.h>\nvector int a;\n' |\ CFLAGS += -DCONFIG_ALTIVEC
gcc -c -x c - >/dev/null && rm ./-.o && echo yes) OBJS += altivec1.o altivec2.o altivec4.o altivec8.o \
ifeq ($(HAS_ALTIVEC),yes) vpermxor1.o vpermxor2.o vpermxor4.o vpermxor8.o
CFLAGS += -I../../../arch/powerpc/include
CFLAGS += -DCONFIG_ALTIVEC
OBJS += altivec1.o altivec2.o altivec4.o altivec8.o \
vpermxor1.o vpermxor2.o vpermxor4.o vpermxor8.o
endif
endif endif
.c.o: .c.o:
...@@ -63,12 +65,12 @@ endif ...@@ -63,12 +65,12 @@ endif
%.uc: ../%.uc %.uc: ../%.uc
cp -f $< $@ cp -f $< $@
all: raid6.a raid6test all: raid6.a raid6test
raid6.a: $(OBJS) raid6.a: $(OBJS)
rm -f $@ rm -f $@
$(AR) cq $@ $^ $(AR) cq $@ $^
$(RANLIB) $@ $(RANLIB) $@
raid6test: test.c raid6.a raid6test: test.c raid6.a
$(CC) $(CFLAGS) -o raid6test $^ $(CC) $(CFLAGS) -o raid6test $^
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment