Commit 8d4b989
committed
nvdimm/btt: Handle preemption in BTT lane acquisition
BTT lanes serialize access to per-lane metadata and workspace state
during BTT I/O. The btt-check unit test reports data mismatches during
BTT writes due to a race in lane acquisition that can lead to silent
data corruption.
The existing lane model uses a spinlock together with a per-CPU
recursion count. That recursion model stopped being valid after BTT
lanes became preemptible: another task can run on the same CPU,
observe a non-zero recursion count, bypass locking, and use the same
lane concurrently.
BTT lanes are also held across arena_write_bytes() calls. That path
reaches nsio_rw_bytes(), which flushes writes with nvdimm_flush().
Some provider flush callbacks can sleep, making a spinlock the wrong
primitive for the lane lifetime.
Replace the spinlock-based recursion model with a dynamically
allocated per-lane mutex array and take the lane lock
unconditionally.
Add might_sleep() to catch any future atomic-context caller.
Found with the ndctl unit test btt-check.sh.
Fixes: 36c75ce ("nd_btt: Make BTT lanes preemptible")
Assisted-by: Claude-Sonnet:4.5
Tested-by: Aboorva Devarajan <aboorvad@linux.ibm.com>
Reviewed-by: Aboorva Devarajan <aboorvad@linux.ibm.com>
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://patch.msgid.link/20260528021625.618462-1-alison.schofield@intel.com
Signed-off-by: Alison Schofield <alison.schofield@intel.com>1 parent e43ffb6 commit 8d4b989
3 files changed
Lines changed: 29 additions & 53 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
166 | | - | |
| 164 | + | |
| 165 | + | |
167 | 166 | | |
168 | 167 | | |
169 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | 368 | | |
374 | 369 | | |
375 | 370 | | |
| |||
400 | 395 | | |
401 | 396 | | |
402 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
403 | 402 | | |
404 | 403 | | |
405 | 404 | | |
| |||
420 | 419 | | |
421 | 420 | | |
422 | 421 | | |
423 | | - | |
| 422 | + | |
424 | 423 | | |
425 | 424 | | |
426 | 425 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
196 | 198 | | |
197 | 199 | | |
198 | 200 | | |
| |||
904 | 906 | | |
905 | 907 | | |
906 | 908 | | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
913 | 912 | | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
| 913 | + | |
| 914 | + | |
919 | 915 | | |
920 | 916 | | |
| 917 | + | |
921 | 918 | | |
922 | | - | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | | - | |
927 | | - | |
| 919 | + | |
928 | 920 | | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
| 921 | + | |
936 | 922 | | |
| 923 | + | |
| 924 | + | |
937 | 925 | | |
938 | 926 | | |
939 | 927 | | |
940 | 928 | | |
941 | 929 | | |
| 930 | + | |
942 | 931 | | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
| 932 | + | |
953 | 933 | | |
954 | 934 | | |
955 | 935 | | |
| |||
1019 | 999 | | |
1020 | 1000 | | |
1021 | 1001 | | |
1022 | | - | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
1023 | 1007 | | |
1024 | 1008 | | |
1025 | 1009 | | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
| 1010 | + | |
| 1011 | + | |
1033 | 1012 | | |
1034 | 1013 | | |
1035 | 1014 | | |
| |||
1046 | 1025 | | |
1047 | 1026 | | |
1048 | 1027 | | |
1049 | | - | |
1050 | 1028 | | |
1051 | 1029 | | |
1052 | 1030 | | |
| |||
0 commit comments