Skip to content

Commit 4ef9bdd

Browse files
committed
Fix alignment_offset calculation
1 parent cf15fc9 commit 4ef9bdd

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/lib/bdev_ubi_stripe.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#include "bdev_ubi_internal.h"
32

43
#include "spdk/likely.h"
@@ -22,8 +21,8 @@ void ubi_start_fetch_stripe(struct ubi_io_channel *ch,
2221
uint64_t offset = ubi_bdev->stripe_size_kb * 1024L * stripe_idx;
2322
uint32_t nbytes = ubi_bdev->stripe_size_kb * 1024L;
2423

25-
uint32_t alignment_offset =
26-
alignment - ((uint64_t)stripe_fetch->buf & (alignment - 1));
24+
uint64_t remainder = (uint64_t)stripe_fetch->buf & (alignment - 1);
25+
uint32_t alignment_offset = remainder ? (alignment - remainder) : 0;
2726
stripe_fetch->buf_aligned = stripe_fetch->buf + alignment_offset;
2827

2928
io_uring_prep_read(sqe, ch->image_file_fd, stripe_fetch->buf_aligned, nbytes, offset);

0 commit comments

Comments
 (0)