Skip to content

Commit ef4ca3d

Browse files
committed
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: 5ab829f ("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>
1 parent 7701e68 commit ef4ca3d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/md/md-llbitmap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,12 +1070,12 @@ static void llbitmap_start_write(struct mddev *mddev, sector_t offset,
10701070
int page_start = (start + BITMAP_DATA_OFFSET) >> PAGE_SHIFT;
10711071
int page_end = (end + BITMAP_DATA_OFFSET) >> PAGE_SHIFT;
10721072

1073-
llbitmap_state_machine(llbitmap, start, end, BitmapActionStartwrite);
1074-
10751073
while (page_start <= page_end) {
10761074
llbitmap_raise_barrier(llbitmap, page_start);
10771075
page_start++;
10781076
}
1077+
1078+
llbitmap_state_machine(llbitmap, start, end, BitmapActionStartwrite);
10791079
}
10801080

10811081
static void llbitmap_end_write(struct mddev *mddev, sector_t offset,
@@ -1102,12 +1102,12 @@ static void llbitmap_start_discard(struct mddev *mddev, sector_t offset,
11021102
int page_start = (start + BITMAP_DATA_OFFSET) >> PAGE_SHIFT;
11031103
int page_end = (end + BITMAP_DATA_OFFSET) >> PAGE_SHIFT;
11041104

1105-
llbitmap_state_machine(llbitmap, start, end, BitmapActionDiscard);
1106-
11071105
while (page_start <= page_end) {
11081106
llbitmap_raise_barrier(llbitmap, page_start);
11091107
page_start++;
11101108
}
1109+
1110+
llbitmap_state_machine(llbitmap, start, end, BitmapActionDiscard);
11111111
}
11121112

11131113
static void llbitmap_end_discard(struct mddev *mddev, sector_t offset,

0 commit comments

Comments
 (0)