Skip to content

Commit 3aad5d3

Browse files
rhvgoyalJens Axboe
authored andcommitted
blkio-throttle: Fix link failure failure on i386
o Randy Dunlap reported following linux-next failure. This patch fixes it. on i386: blk-throttle.c:(.text+0x1abb8): undefined reference to `__udivdi3' blk-throttle.c:(.text+0x1b1dc): undefined reference to `__udivdi3' o bytes_per_second interface is 64bit and I was continuing to do 64 bit division even on 32bit platform without help of special macros/functions hence the failure. Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Reported-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
1 parent fe07143 commit 3aad5d3

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

‎block/blk-throttle.c‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,8 @@ throtl_slice_used(struct throtl_data *td, struct throtl_grp *tg, bool rw)
378378
static inline void
379379
throtl_trim_slice(struct throtl_data *td, struct throtl_grp *tg, bool rw)
380380
{
381-
unsigned long nr_slices, bytes_trim, time_elapsed, io_trim;
381+
unsigned long nr_slices, time_elapsed, io_trim;
382+
u64 bytes_trim, tmp;
382383

383384
BUG_ON(time_before(tg->slice_end[rw], tg->slice_start[rw]));
384385

@@ -396,8 +397,10 @@ throtl_trim_slice(struct throtl_data *td, struct throtl_grp *tg, bool rw)
396397

397398
if (!nr_slices)
398399
return;
400+
tmp = tg->bps[rw] * throtl_slice * nr_slices;
401+
do_div(tmp, HZ);
402+
bytes_trim = tmp;
399403

400-
bytes_trim = (tg->bps[rw] * throtl_slice * nr_slices)/HZ;
401404
io_trim = (tg->iops[rw] * throtl_slice * nr_slices)/HZ;
402405

403406
if (!bytes_trim && !io_trim)
@@ -415,7 +418,7 @@ throtl_trim_slice(struct throtl_data *td, struct throtl_grp *tg, bool rw)
415418

416419
tg->slice_start[rw] += nr_slices * throtl_slice;
417420

418-
throtl_log_tg(td, tg, "[%c] trim slice nr=%lu bytes=%lu io=%lu"
421+
throtl_log_tg(td, tg, "[%c] trim slice nr=%lu bytes=%llu io=%lu"
419422
" start=%lu end=%lu jiffies=%lu",
420423
rw == READ ? 'R' : 'W', nr_slices, bytes_trim, io_trim,
421424
tg->slice_start[rw], tg->slice_end[rw], jiffies);
@@ -462,7 +465,7 @@ static bool tg_with_in_bps_limit(struct throtl_data *td, struct throtl_grp *tg,
462465
struct bio *bio, unsigned long *wait)
463466
{
464467
bool rw = bio_data_dir(bio);
465-
u64 bytes_allowed, extra_bytes;
468+
u64 bytes_allowed, extra_bytes, tmp;
466469
unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd;
467470

468471
jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[rw];
@@ -473,8 +476,9 @@ static bool tg_with_in_bps_limit(struct throtl_data *td, struct throtl_grp *tg,
473476

474477
jiffy_elapsed_rnd = roundup(jiffy_elapsed_rnd, throtl_slice);
475478

476-
bytes_allowed = (tg->bps[rw] * jiffies_to_msecs(jiffy_elapsed_rnd))
477-
/ MSEC_PER_SEC;
479+
tmp = tg->bps[rw] * jiffies_to_msecs(jiffy_elapsed_rnd);
480+
do_div(tmp, MSEC_PER_SEC);
481+
bytes_allowed = tmp;
478482

479483
if (tg->bytes_disp[rw] + bio->bi_size <= bytes_allowed) {
480484
if (wait)

0 commit comments

Comments
 (0)