Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

md/md-llbitmap: raise barrier before state machine transition

Move the barrier raise operation before calling llbitmap_state_machine()
in both llbitmap_start_write() and llbitmap_start_discard(). This
ensures the barrier is in place before any state transitions occur,
preventing potential race conditions where the state machine could
complete before the barrier is properly raised.

Cc: stable@vger.kernel.org
Fixes: 5ab829f1971d ("md/md-llbitmap: introduce new lockless bitmap")
Link: https://lore.kernel.org/linux-raid/20260223024038.3084853-3-yukuai@fnnas.com
Signed-off-by: Yu Kuai <yukuai@fnnas.com>

Yu Kuai ef4ca3d4 7701e68b

+4 -4
+4 -4
drivers/md/md-llbitmap.c
··· 1070 1070 int page_start = (start + BITMAP_DATA_OFFSET) >> PAGE_SHIFT; 1071 1071 int page_end = (end + BITMAP_DATA_OFFSET) >> PAGE_SHIFT; 1072 1072 1073 - llbitmap_state_machine(llbitmap, start, end, BitmapActionStartwrite); 1074 - 1075 1073 while (page_start <= page_end) { 1076 1074 llbitmap_raise_barrier(llbitmap, page_start); 1077 1075 page_start++; 1078 1076 } 1077 + 1078 + llbitmap_state_machine(llbitmap, start, end, BitmapActionStartwrite); 1079 1079 } 1080 1080 1081 1081 static void llbitmap_end_write(struct mddev *mddev, sector_t offset, ··· 1102 1102 int page_start = (start + BITMAP_DATA_OFFSET) >> PAGE_SHIFT; 1103 1103 int page_end = (end + BITMAP_DATA_OFFSET) >> PAGE_SHIFT; 1104 1104 1105 - llbitmap_state_machine(llbitmap, start, end, BitmapActionDiscard); 1106 - 1107 1105 while (page_start <= page_end) { 1108 1106 llbitmap_raise_barrier(llbitmap, page_start); 1109 1107 page_start++; 1110 1108 } 1109 + 1110 + llbitmap_state_machine(llbitmap, start, end, BitmapActionDiscard); 1111 1111 } 1112 1112 1113 1113 static void llbitmap_end_discard(struct mddev *mddev, sector_t offset,