Skip to content

Commit

Permalink
Fix alignment_offset calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
pykello committed Feb 7, 2025
1 parent cf15fc9 commit 4ef9bdd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/lib/bdev_ubi_stripe.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "bdev_ubi_internal.h"

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

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

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

0 comments on commit 4ef9bdd

Please sign in to comment.