Commit d19f98c
nvme-tcp: fix usage of page_frag_cache
commit 36ac05f upstream.
nvme uses page_frag_cache to preallocate PDU for each preallocated request
of block device. Block devices are created in parallel threads,
consequently page_frag_cache is used in not thread-safe manner.
That leads to incorrect refcounting of backstore pages and premature free.
That can be catched by !sendpage_ok inside network stack:
WARNING: CPU: 7 PID: 467 at ../net/core/skbuff.c:6931 skb_splice_from_iter+0xfa/0x310.
tcp_sendmsg_locked+0x782/0xce0
tcp_sendmsg+0x27/0x40
sock_sendmsg+0x8b/0xa0
nvme_tcp_try_send_cmd_pdu+0x149/0x2a0
Then random panic may occur.
Fix that by serializing the usage of page_frag_cache.
Fixes: 4e893ca ("nvme_core: scan namespaces asynchronously")
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
Signed-off-by: Daniel Wagner <wagi@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
[carlos.bilbao: adjust context in nvme_tcp_free_queue; branch predates
19bdb70 ("nvme-tcp: lockdep: use dynamic lockdep keys per socket
instance")]
Signed-off-by: Carlos Bilbao (Lambda) <carlos.bilbao@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent 2acc77e commit d19f98c
1 file changed
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
| |||
552 | 553 | | |
553 | 554 | | |
554 | 555 | | |
| 556 | + | |
555 | 557 | | |
556 | 558 | | |
557 | 559 | | |
| 560 | + | |
558 | 561 | | |
559 | 562 | | |
560 | 563 | | |
| |||
1452 | 1455 | | |
1453 | 1456 | | |
1454 | 1457 | | |
| 1458 | + | |
1455 | 1459 | | |
1456 | 1460 | | |
1457 | 1461 | | |
| 1462 | + | |
1458 | 1463 | | |
1459 | 1464 | | |
1460 | 1465 | | |
| |||
1485 | 1490 | | |
1486 | 1491 | | |
1487 | 1492 | | |
| 1493 | + | |
1488 | 1494 | | |
1489 | 1495 | | |
1490 | 1496 | | |
| |||
1807 | 1813 | | |
1808 | 1814 | | |
1809 | 1815 | | |
| 1816 | + | |
1810 | 1817 | | |
1811 | 1818 | | |
1812 | 1819 | | |
| |||
1946 | 1953 | | |
1947 | 1954 | | |
1948 | 1955 | | |
| 1956 | + | |
1949 | 1957 | | |
1950 | 1958 | | |
1951 | 1959 | | |
| |||
0 commit comments