From: David Butterfield <dab21774@gmail.com>
To: drbd-dev@lists.linbit.com, Lars Ellenberg <lars.ellenberg@linbit.com>
Subject: Re: [Drbd-dev] q->queue_lock initialization
Date: Tue, 18 Jun 2019 13:45:20 -0600 [thread overview]
Message-ID: <53823072-4be7-dc0c-5abe-08588ba5b68e@gmail.com> (raw)
In-Reply-To: <20190612142612.GB5803@soda.linbit>
Regarding initialization of q->queue_lock:
Apparently the DRBD source requires that
!defined(COMPAT_HAVE_BLK_QUEUE_FLAG_SET) implies defined(blk_queue_plugged)
So I suppose that must be true in all Linux kernel versions at or above 2.6.32.
But I did not implement or #define blk_queue_plugged, so the initialization of
q->queue_lock at drbd_main.c:3773 did not happen, so the spin_lock_irqsave() in the
compatibility version of blk_queue_flag_set:1942 would use the NULL q->queue_lock.
So I will look into defining blk_queue_plugged in my ~2.6.32 environment.
Thanks for your help understanding this.
From drbd_nl.c:
1937 #ifndef COMPAT_HAVE_BLK_QUEUE_FLAG_SET
1938 static void blk_queue_flag_set(unsigned int flag, struct request_queue *q)
1939 {
1940 unsigned long flags;
1941
1942 spin_lock_irqsave(q->queue_lock, flags);
1943 queue_flag_set(flag, q);
1944 spin_unlock_irqrestore(q->queue_lock, flags);
1945 }
From drbd_main.c:
3772 #ifdef blk_queue_plugged
3773 q->queue_lock = &resource->req_lock; /* needed since we use */
3774 /* plugging on a queue, that actually has no requests! */
3775 q->unplug_fn = drbd_unplug_fn;
3776 #endif
drbdsetup attach leads to spin_lock(NULL):
/usermode_compat/src/usermode_lib.h:1098:19: runtime error: member access within null pointer of type 'struct spinlock_t'
Thread 5 "netlink_recv" received signal SIGSEGV, Segmentation fault.
(gdb)
(gdb) bt
#0 __GI___pthread_mutex_trylock (mutex=0x8) at ../nptl/pthread_mutex_trylock.c:41
#1 0x0000555555c2994a in _spin_lock_try (lock=0x0, whence=0x555555e99859 "drbd_nl.c:1951") at usermode_compat/src/usermode_lib.h:1098
#2 0x0000555555c2a070 in _spin_lock (lock=0x0, whence=0x555555e99859 "drbd_nl.c:1951") at usermode_compat/src/usermode_lib.h:1125
#3 0x0000555555c60f73 in blk_queue_flag_clear (flag=4294967295, q=0x7fff6400c800) at drbd_nl.c:1951
#4 0x0000555555c613c9 in decide_on_discard_support (device=0x7fff6401c400, q=0x7fff6400c800, b=0x5555562374c0, discard_zeroes_if_aligned=true) at drbd_nl.c:1987
#5 0x0000555555c6196d in drbd_setup_queue_param (device=0x7fff6401c400, bdev=0x7fff6405d400, max_bio_size=1048576, o=0x0) at drbd_nl.c:2115
#6 0x0000555555c62194 in drbd_reconsider_queue_parameters (device=0x7fff6401c400, bdev=0x7fff6405d400, o=0x0) at drbd_nl.c:2143
#7 0x0000555555c710b0 in drbd_adm_attach (skb=0x7fff64037d40, info=0x7ffff5626460) at drbd_nl.c:3042
#8 0x0000555555e33586 in genl_rcv_msg (skb=0x7fff64037d40, nlh=0x7fff6405f000) at UMC_genl.c:566
#9 0x0000555555e33cfa in netlink_rcv_skb (skb=0x7fff64037d40, cb=0x555555e32e99 <genl_rcv_msg>) at UMC_genl.c:618
#10 0x0000555555e33ef9 in genl_rcv (skb=0x7fff64037d40) at UMC_genl.c:639
#11 0x0000555555e2d78b in on_netlink_recv (sk=0x555556233098, len=0) at usermode_lib.c:994
#12 0x0000555555e2b9dc in UMC_sock_recv_event (env=0x555556233000, events=1, err=0) at usermode_lib.c:792
#13 0x00007ffff7f5eec3 in callback_deliver (err=0, arg=1, cb=0x5555562357c0) at mte_event_task.c:128
#14 event_poll_deliver (nevents=<optimized out>, events=<optimized out>) at mte_event_task.c:254
#15 event_task_loop (event_task=event_task@entry=0x555556234e00) at mte_event_task.c:741
#16 0x00007ffff7f62d0f in mte_event_task_run (event_task=0x555556234e00) at mte_event_task.c:860
#17 0x0000555555e2276f in UMC_irqthread_fn (v_irqthread=0x555556233a00) at usermode_lib.c:187
#18 0x00007ffff7f4cc05 in sys_thread_fn (env=<optimized out>) at mte_service.c:145
#19 0x00007ffff757d182 in start_thread (arg=<optimized out>) at pthread_create.c:486
#20 0x00007ffff74a6b1f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Nice to be able to use valgrind and gdb and libubsan!
prev parent reply other threads:[~2019-06-18 19:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-05 16:15 [Drbd-dev] main.c comments David Butterfield
2019-06-12 14:26 ` Lars Ellenberg
2019-06-18 17:58 ` David Butterfield
2019-06-18 19:45 ` David Butterfield [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53823072-4be7-dc0c-5abe-08588ba5b68e@gmail.com \
--to=dab21774@gmail.com \
--cc=drbd-dev@lists.linbit.com \
--cc=lars.ellenberg@linbit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox