Recent changes (master)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following changes since commit 70a7516894d8cf78be7d8ef89444d9faf0d3e87a:

  Remove repeated --readonly options in documentation (2013-01-10 13:20:02 +0100)

are available in the git repository at:
  git://git.kernel.dk/fio.git master

Jens Axboe (2):
      filesetup: limit rand map to the actual IO size, if needed
      lfsr: ensure we don't generate an offset + buflen that exceeds the max size

Jianpeng Ma (1):
      Add a check avoid segfault

 filesetup.c |    8 +++++++-
 io_u.c      |   22 +++++++++++-----------
 lib/lfsr.c  |    5 +++--
 lib/lfsr.h  |    2 +-
 4 files changed, 22 insertions(+), 15 deletions(-)

---

Diff of recent changes:

diff --git a/filesetup.c b/filesetup.c
index 69eb37c..478bda8 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -956,7 +956,9 @@ int init_random_map(struct thread_data *td)
 		return 0;
 
 	for_each_file(td, f, i) {
-		blocks = (f->real_file_size + td->o.rw_min_bs - 1) /
+		uint64_t file_size = min(f->real_file_size, f->io_size);
+
+		blocks = (file_size + td->o.rw_min_bs - 1) /
 				(unsigned long long) td->o.rw_min_bs;
 		if (td->o.random_generator == FIO_RAND_GEN_LFSR) {
 			unsigned long seed;
@@ -1079,6 +1081,10 @@ int add_file(struct thread_data *td, const char *fname)
 		dprint(FD_FILE, "resize file array to %d files\n", new_size);
 
 		td->files = realloc(td->files, new_size * sizeof(f));
+		if (td->files == NULL) {
+			log_err("fio: realloc OOM\n");
+			assert(0);
+		}
 		td->files_size = new_size;
 	}
 	td->files[cur_files] = f;
diff --git a/io_u.c b/io_u.c
index 91d1290..94fd123 100644
--- a/io_u.c
+++ b/io_u.c
@@ -49,11 +49,11 @@ static void mark_random_map(struct thread_data *td, struct io_u *io_u)
 		io_u->buflen = nr_blocks * min_bs;
 }
 
-static unsigned long long last_block(struct thread_data *td, struct fio_file *f,
-				     enum fio_ddir ddir)
+static uint64_t last_block(struct thread_data *td, struct fio_file *f,
+			   enum fio_ddir ddir)
 {
-	unsigned long long max_blocks;
-	unsigned long long max_size;
+	uint64_t max_blocks;
+	uint64_t max_size;
 
 	assert(ddir_rw(ddir));
 
@@ -77,14 +77,14 @@ static unsigned long long last_block(struct thread_data *td, struct fio_file *f,
 static int __get_next_rand_offset(struct thread_data *td, struct fio_file *f,
 				  enum fio_ddir ddir, unsigned long long *b)
 {
-	unsigned long long r;
+	unsigned long long r, lastb;
 
-	if (td->o.random_generator == FIO_RAND_GEN_TAUSWORTHE) {
-		unsigned long long rmax, lastb;
+	lastb = last_block(td, f, ddir);
+	if (!lastb)
+		return 1;
 
-		lastb = last_block(td, f, ddir);
-		if (!lastb)
-			return 1;
+	if (td->o.random_generator == FIO_RAND_GEN_TAUSWORTHE) {
+		unsigned long long rmax;
 
 		rmax = td->o.use_os_rand ? OS_RAND_MAX : FRAND_MAX;
 
@@ -102,7 +102,7 @@ static int __get_next_rand_offset(struct thread_data *td, struct fio_file *f,
 	} else {
 		uint64_t off = 0;
 
-		if (lfsr_next(&f->lfsr, &off))
+		if (lfsr_next(&f->lfsr, &off, lastb))
 			return 1;
 
 		*b = off;
diff --git a/lib/lfsr.c b/lib/lfsr.c
index 8a70029..975c6a5 100644
--- a/lib/lfsr.c
+++ b/lib/lfsr.c
@@ -216,14 +216,15 @@ static uint64_t __lfsr_next(uint64_t v, struct lfsr_taps *lt)
 	return xor_mask | (v >> 1);
 }
 
-int lfsr_next(struct fio_lfsr *fl, uint64_t *off)
+int lfsr_next(struct fio_lfsr *fl, uint64_t *off, uint64_t last)
 {
 	if (fl->num_vals > fl->max_val)
 		return 1;
 
 	do {
 		fl->last_val = __lfsr_next(fl->last_val, &fl->taps);
-		if (fl->last_val - 1 <= fl->max_val)
+		if (fl->last_val - 1 <= fl->max_val &&
+		    fl->last_val <= last)
 			break;
 	} while (1);
 
diff --git a/lib/lfsr.h b/lib/lfsr.h
index 09f5ac0..898646e 100644
--- a/lib/lfsr.h
+++ b/lib/lfsr.h
@@ -18,7 +18,7 @@ struct fio_lfsr {
 	struct lfsr_taps taps;
 };
 
-int lfsr_next(struct fio_lfsr *fl, uint64_t *off);
+int lfsr_next(struct fio_lfsr *fl, uint64_t *off, uint64_t);
 int lfsr_init(struct fio_lfsr *fl, uint64_t size, unsigned long seed);
 
 #endif
--
To unsubscribe from this list: send the line "unsubscribe fio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux