Skip to contentSkip to conversation

Recent changes (master)

PATCH Jens Axboe 1 participant 1 message Mar 18, 2017 Library code

lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

The following changes since commit 8243be59aa35aa016fcbeee99353b08376953911:

Add 'stats' option (2017-03-16 14:43:37 -0600)

are available in the git repository at:

git://git.kernel.dk/fio.git master

for you to fetch changes up to d9bb03d475e918e08c38bd882032ff788daa297f:

is_power_of_2() should return bool (2017-03-17 10:39:42 -0600)

----------------------------------------------------------------
Jens Axboe (2):
io_u: we don't need to set power_2 to false
is_power_of_2() should return bool

Pan Liu (1):
fixed the error=invalid argument when the lower bound of bsrange is not power of 2.

 io_u.c     | 7 +++++--
 lib/pow2.h | 3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)

---

Diff of recent changes:

io_u.c +5 -2
index f6efae0..5f01c1b 100644
@@ -533,6 +533,7 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u,
 	unsigned int buflen = 0;
 	unsigned int minbs, maxbs;
 	uint64_t frand_max, r;
+	bool power_2;
 
 	assert(ddir_rw(ddir));
 
@@ -577,9 +578,11 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u,
 			}
 		}
 
-		if (!td->o.bs_unaligned && is_power_of_2(minbs))
+		power_2 = is_power_of_2(minbs);
+		if (!td->o.bs_unaligned && power_2)
 			buflen &= ~(minbs - 1);
-
+		else if (!td->o.bs_unaligned && !power_2) 
+			buflen -= buflen % minbs; 
 	} while (!io_u_fits(td, io_u, buflen));
 
 	return buflen;
lib/pow2.h +2 -1
index f3ca4d7..2cbca1a 100644
@@ -2,8 +2,9 @@
 #define FIO_POW2_H
 
 #include <inttypes.h>
+#include "types.h"
 
-static inline int is_power_of_2(uint64_t val)
+static inline bool is_power_of_2(uint64_t val)
 {
 	return (val != 0 && ((val & (val - 1)) == 0));
 }