<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/md/md-cluster.c, branch linux-4.9.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.9.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.9.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-08-21T09:01:58Z</updated>
<entry>
<title>md-cluster: fix wild pointer of unlock_all_bitmaps()</title>
<updated>2020-08-21T09:01:58Z</updated>
<author>
<name>Zhao Heming</name>
</author>
<published>2020-07-09T03:29:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e51f5c5d5a3f5472ffb007ec09ecd9025fc84455'/>
<id>urn:sha1:e51f5c5d5a3f5472ffb007ec09ecd9025fc84455</id>
<content type='text'>
[ Upstream commit 60f80d6f2d07a6d8aee485a1d1252327eeee0c81 ]

reproduction steps:
```
node1 # mdadm -C /dev/md0 -b clustered -e 1.2 -n 2 -l mirror /dev/sda
/dev/sdb
node2 # mdadm -A /dev/md0 /dev/sda /dev/sdb
node1 # mdadm -G /dev/md0 -b none
mdadm: failed to remove clustered bitmap.
node1 # mdadm -S --scan
^C  &lt;==== mdadm hung &amp; kernel crash
```

kernel stack:
```
[  335.230657] general protection fault: 0000 [#1] SMP NOPTI
[...]
[  335.230848] Call Trace:
[  335.230873]  ? unlock_all_bitmaps+0x5/0x70 [md_cluster]
[  335.230886]  unlock_all_bitmaps+0x3d/0x70 [md_cluster]
[  335.230899]  leave+0x10f/0x190 [md_cluster]
[  335.230932]  ? md_super_wait+0x93/0xa0 [md_mod]
[  335.230947]  ? leave+0x5/0x190 [md_cluster]
[  335.230973]  md_cluster_stop+0x1a/0x30 [md_mod]
[  335.230999]  md_bitmap_free+0x142/0x150 [md_mod]
[  335.231013]  ? _cond_resched+0x15/0x40
[  335.231025]  ? mutex_lock+0xe/0x30
[  335.231056]  __md_stop+0x1c/0xa0 [md_mod]
[  335.231083]  do_md_stop+0x160/0x580 [md_mod]
[  335.231119]  ? 0xffffffffc05fb078
[  335.231148]  md_ioctl+0xa04/0x1930 [md_mod]
[  335.231165]  ? filename_lookup+0xf2/0x190
[  335.231179]  blkdev_ioctl+0x93c/0xa10
[  335.231205]  ? _cond_resched+0x15/0x40
[  335.231214]  ? __check_object_size+0xd4/0x1a0
[  335.231224]  block_ioctl+0x39/0x40
[  335.231243]  do_vfs_ioctl+0xa0/0x680
[  335.231253]  ksys_ioctl+0x70/0x80
[  335.231261]  __x64_sys_ioctl+0x16/0x20
[  335.231271]  do_syscall_64+0x65/0x1f0
[  335.231278]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
```

Signed-off-by: Zhao Heming &lt;heming.zhao@suse.com&gt;
Signed-off-by: Song Liu &lt;songliubraving@fb.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>md-cluster: clear another node's suspend_area after the copy is finished</title>
<updated>2018-10-04T00:01:43Z</updated>
<author>
<name>Guoqing Jiang</name>
</author>
<published>2018-07-02T08:26:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0e085b03e65f568a6cad0faab64989c50c912185'/>
<id>urn:sha1:0e085b03e65f568a6cad0faab64989c50c912185</id>
<content type='text'>
[ Upstream commit 010228e4a932ca1e8365e3b58c8e1e44c16ff793 ]

When one node leaves cluster or stops the resyncing
(resync or recovery) array, then other nodes need to
call recover_bitmaps to continue the unfinished task.

But we need to clear suspend_area later after other
nodes copy the resync information to their bitmap
(by call bitmap_copy_from_slot). Otherwise, all nodes
could write to the suspend_area even the suspend_area
is not handled by any node, because area_resyncing
returns 0 at the beginning of raid1_write_request.
Which means one node could write suspend_area while
another node is resyncing the same area, then data
could be inconsistent.

So let's clear suspend_area later to avoid above issue
with the protection of bm lock. Also it is straightforward
to clear suspend_area after nodes have copied the resync
info to bitmap.

Signed-off-by: Guoqing Jiang &lt;gqjiang@suse.com&gt;
Reviewed-by: NeilBrown &lt;neilb@suse.com&gt;
Signed-off-by: Shaohua Li &lt;shli@fb.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>md-cluster: fix potential lock issue in add_new_disk</title>
<updated>2018-04-13T17:48:03Z</updated>
<author>
<name>Guoqing Jiang</name>
</author>
<published>2017-05-16T06:01:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=03858f5f7ad86a1b8332e4a3329b7757c34da30c'/>
<id>urn:sha1:03858f5f7ad86a1b8332e4a3329b7757c34da30c</id>
<content type='text'>
[ Upstream commit 2dffdc0724004f38f5e39907747b53e4b0d80e59 ]

The add_new_disk returns with communication locked if
__sendmsg returns failure, fix it with call unlock_comm
before return.

Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
CC: Goldwyn Rodrigues &lt;rgoldwyn@suse.com&gt;
Signed-off-by: Guoqing Jiang &lt;gqjiang@suse.com&gt;
Signed-off-by: Shaohua Li &lt;shli@fb.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>md-cluster: free md_cluster_info if node leave cluster</title>
<updated>2017-12-20T09:07:18Z</updated>
<author>
<name>Guoqing Jiang</name>
</author>
<published>2017-02-24T03:15:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9bcd15bdfb6151e0418fa9321d4dce2b2eb0cb16'/>
<id>urn:sha1:9bcd15bdfb6151e0418fa9321d4dce2b2eb0cb16</id>
<content type='text'>
[ Upstream commit 9c8043f337f14d1743006dfc59c03e80a42e3884 ]

To avoid memory leak, we need to free the cinfo which
is allocated when node join cluster.

Reviewed-by: NeilBrown &lt;neilb@suse.com&gt;
Signed-off-by: Guoqing Jiang &lt;gqjiang@suse.com&gt;
Signed-off-by: Shaohua Li &lt;shli@fb.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>md-cluster: make resync lock also could be interruptted</title>
<updated>2016-09-21T16:09:44Z</updated>
<author>
<name>Guoqing Jiang</name>
</author>
<published>2016-08-12T05:42:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d6385db94196b253ae5eb3678fa95cdf1f839fcc'/>
<id>urn:sha1:d6385db94196b253ae5eb3678fa95cdf1f839fcc</id>
<content type='text'>
When one node is perform resync or recovery, other nodes
can't get resync lock and could block for a while before
it holds the lock, so we can't stop array immediately for
this scenario.

To make array could be stop quickly, we check MD_CLOSING
in dlm_lock_sync_interruptible to make us can interrupt
the lock request.

Reviewed-by: NeilBrown &lt;neilb@suse.com&gt;
Signed-off-by: Guoqing Jiang &lt;gqjiang@suse.com&gt;
Signed-off-by: Shaohua Li &lt;shli@fb.com&gt;
</content>
</entry>
<entry>
<title>md-cluster: introduce dlm_lock_sync_interruptible to fix tasks hang</title>
<updated>2016-09-21T16:09:44Z</updated>
<author>
<name>Guoqing Jiang</name>
</author>
<published>2016-08-12T05:42:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7bcda7149dd6911bee15a51b22477f592f8b9620'/>
<id>urn:sha1:7bcda7149dd6911bee15a51b22477f592f8b9620</id>
<content type='text'>
When some node leaves cluster, then it's bitmap need to be
synced by another node, so "md*_recover" thread is triggered
for the purpose. However, with below steps. we can find tasks
hang happened either in B or C.

1. Node A create a resyncing cluster raid1, assemble it in
   other two nodes (B and C).
2. stop array in B and C.
3. stop array in A.

linux44:~ # ps aux|grep md|grep D
root	5938	0.0  0.1  19852  1964 pts/0    D+   14:52   0:00 mdadm -S md0
root	5939	0.0  0.0      0     0 ?        D    14:52   0:00 [md0_recover]

linux44:~ # cat /proc/5939/stack
[&lt;ffffffffa04cf321&gt;] dlm_lock_sync+0x71/0x90 [md_cluster]
[&lt;ffffffffa04d0705&gt;] recover_bitmaps+0x125/0x220 [md_cluster]
[&lt;ffffffffa052105d&gt;] md_thread+0x16d/0x180 [md_mod]
[&lt;ffffffff8107ad94&gt;] kthread+0xb4/0xc0
[&lt;ffffffff8152a518&gt;] ret_from_fork+0x58/0x90

linux44:~ # cat /proc/5938/stack
[&lt;ffffffff8107afde&gt;] kthread_stop+0x6e/0x120
[&lt;ffffffffa0519da0&gt;] md_unregister_thread+0x40/0x80 [md_mod]
[&lt;ffffffffa04cfd20&gt;] leave+0x70/0x120 [md_cluster]
[&lt;ffffffffa0525e24&gt;] md_cluster_stop+0x14/0x30 [md_mod]
[&lt;ffffffffa05269ab&gt;] bitmap_free+0x14b/0x150 [md_mod]
[&lt;ffffffffa0523f3b&gt;] do_md_stop+0x35b/0x5a0 [md_mod]
[&lt;ffffffffa0524e83&gt;] md_ioctl+0x873/0x1590 [md_mod]
[&lt;ffffffff81288464&gt;] blkdev_ioctl+0x214/0x7d0
[&lt;ffffffff811dd3dd&gt;] block_ioctl+0x3d/0x40
[&lt;ffffffff811b92d4&gt;] do_vfs_ioctl+0x2d4/0x4b0
[&lt;ffffffff811b9538&gt;] SyS_ioctl+0x88/0xa0
[&lt;ffffffff8152a5c9&gt;] system_call_fastpath+0x16/0x1b

The problem is caused by recover_bitmaps can't reliably abort
when the thread is unregistered. So dlm_lock_sync_interruptible
is introduced to detect the thread's situation to fix the problem.

Reviewed-by: NeilBrown &lt;neilb@suse.com&gt;
Signed-off-by: Guoqing Jiang &lt;gqjiang@suse.com&gt;
Signed-off-by: Shaohua Li &lt;shli@fb.com&gt;
</content>
</entry>
<entry>
<title>md-cluster: convert the completion to wait queue</title>
<updated>2016-09-21T16:09:44Z</updated>
<author>
<name>Guoqing Jiang</name>
</author>
<published>2016-08-12T05:42:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fccb60a42cdd863aa80f32214ae58ae13936c927'/>
<id>urn:sha1:fccb60a42cdd863aa80f32214ae58ae13936c927</id>
<content type='text'>
Previously, we used completion to sync between require dlm lock
and sync_ast, however we will have to expose completion.wait
and completion.done in dlm_lock_sync_interruptible (introduced
later), it is not a common usage for completion, so convert
related things to wait queue.

Reviewed-by: NeilBrown &lt;neilb@suse.com&gt;
Signed-off-by: Guoqing Jiang &lt;gqjiang@suse.com&gt;
Signed-off-by: Shaohua Li &lt;shli@fb.com&gt;
</content>
</entry>
<entry>
<title>md-cluster: protect md_find_rdev_nr_rcu with rcu lock</title>
<updated>2016-09-21T16:09:44Z</updated>
<author>
<name>Guoqing Jiang</name>
</author>
<published>2016-08-12T05:42:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5f0aa21da6cc620b08e5f69f51db29cb1f722174'/>
<id>urn:sha1:5f0aa21da6cc620b08e5f69f51db29cb1f722174</id>
<content type='text'>
We need to use rcu_read_lock/unlock to avoid potential
race.

Reported-by: Shaohua Li &lt;shli@fb.com&gt;
Reviewed-by: NeilBrown &lt;neilb@suse.com&gt;
Signed-off-by: Guoqing Jiang &lt;gqjiang@suse.com&gt;
Signed-off-by: Shaohua Li &lt;shli@fb.com&gt;
</content>
</entry>
<entry>
<title>md-cluster: remove some unnecessary dlm_unlock_sync</title>
<updated>2016-09-21T16:09:44Z</updated>
<author>
<name>Guoqing Jiang</name>
</author>
<published>2016-08-12T05:42:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e3f924d3dfc672dd1292bc7eb6f2a305c13981ec'/>
<id>urn:sha1:e3f924d3dfc672dd1292bc7eb6f2a305c13981ec</id>
<content type='text'>
Since DLM_LKF_FORCEUNLOCK is used in lockres_free,
we don't need to call dlm_unlock_sync before free
lock resource.

Reviewed-by: NeilBrown &lt;neilb@suse.com&gt;
Signed-off-by: Guoqing Jiang &lt;gqjiang@suse.com&gt;
Signed-off-by: Shaohua Li &lt;shli@fb.com&gt;
</content>
</entry>
<entry>
<title>md-cluster: use FORCEUNLOCK in lockres_free</title>
<updated>2016-09-21T16:09:44Z</updated>
<author>
<name>Guoqing Jiang</name>
</author>
<published>2016-08-12T05:42:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=400cb454a4205ec1d7311bc3dd8104859c26ba46'/>
<id>urn:sha1:400cb454a4205ec1d7311bc3dd8104859c26ba46</id>
<content type='text'>
For dlm_unlock, we need to pass flag to dlm_unlock as the
third parameter instead of set res-&gt;flags.

Also, DLM_LKF_FORCEUNLOCK is more suitable for dlm_unlock
since it works even the lock is on waiting or convert queue.

Acked-by: NeilBrown &lt;neilb@suse.com&gt;
Signed-off-by: Guoqing Jiang &lt;gqjiang@suse.com&gt;
Signed-off-by: Shaohua Li &lt;shli@fb.com&gt;
</content>
</entry>
</feed>
