Recent changes

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

 



The following changes since commit 893b37c668638714f8240a1dcf8548836fe51233:

  HP-UX: add fdatasync() (2011-07-11 14:43:26 +0200)

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

Jens Axboe (5):
      Allow percentage setting for size=
      Fix compile on older systems that don't have fallocate() on Linux
      Add gettid() for proper thread affinity on Linux
      Add gettid() for FreeBSD/OSX/Solaris
      gettid() for NetBSD

 HOWTO           |    5 ++++-
 filesetup.c     |    3 +++
 fio.1           |    4 +++-
 fio.c           |    7 ++++---
 fio.h           |    1 +
 helpers.c       |    6 ++++++
 helpers.h       |    1 +
 options.c       |   17 +++++++++++++++--
 os/os-freebsd.h |    9 +++++++++
 os/os-linux.h   |   15 ++++++++++++++-
 os/os-mac.h     |    6 ++++++
 os/os-netbsd.h  |    9 +++++++++
 os/os-solaris.h |    5 +++++
 os/os.h         |    7 +++++++
 parse.c         |   29 +++++++++++++++++++++--------
 parse.h         |    5 +++++
 16 files changed, 113 insertions(+), 16 deletions(-)

---

Diff of recent changes:

diff --git a/HOWTO b/HOWTO
index ee899b8..ce1bd9e 100644
--- a/HOWTO
+++ b/HOWTO
@@ -382,7 +382,10 @@ size=int	The total size of file io for this job. Fio will run until
 		fio will divide this size between the available files
 		specified by the job. If not set, fio will use the full
 		size of the given files or devices. If the the files
-		do not exist, size must be given.
+		do not exist, size must be given. It is also possible to
+		give size as a percentage between 1 and 100. If size=20%
+		is given, fio will use 20% of the full size of the given
+		files or devices.
 
 filesize=int	Individual file sizes. May be a range, in which case fio
 		will select sizes for files at random within the given range
diff --git a/filesetup.c b/filesetup.c
index 2a79e74..8f51592 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -759,6 +759,9 @@ int setup_files(struct thread_data *td)
 		}
 	}
 
+	if (td->o.size_percent)
+		total_size = (total_size * td->o.size_percent) / 100;
+
 	if (!td->o.size || td->o.size > total_size)
 		td->o.size = total_size;
 
diff --git a/fio.1 b/fio.1
index 0838d07..b7046d5 100644
--- a/fio.1
+++ b/fio.1
@@ -257,7 +257,9 @@ been transfered, unless limited by other options (\fBruntime\fR, for instance).
 Unless \fBnrfiles\fR and \fBfilesize\fR options are given, this amount will be
 divided between the available files for the job. If not set, fio will use the
 full size of the given files or devices. If the the files do not exist, size
-must be given.
+must be given. It is also possible to give size as a percentage between 1 and
+100. If size=20% is given, fio will use 20% of the full size of the given files
+or devices.
 .TP
 .BI fill_device \fR=\fPbool "\fR,\fB fill_fs" \fR=\fPbool
 Sets size to something really large and waits for ENOSPC (no space left on
diff --git a/fio.c b/fio.c
index a8608f4..2855ddf 100644
--- a/fio.c
+++ b/fio.c
@@ -1045,10 +1045,11 @@ static void *thread_main(void *data)
 	pthread_condattr_t attr;
 	int clear_state;
 
-	if (!td->o.use_thread)
+	if (!td->o.use_thread) {
 		setsid();
-
-	td->pid = getpid();
+		td->pid = getpid();
+	} else
+		td->pid = gettid();
 
 	dprint(FD_PROCESS, "jobs pid=%d started\n", (int) td->pid);
 
diff --git a/fio.h b/fio.h
index b869dd1..d8e3011 100644
--- a/fio.h
+++ b/fio.h
@@ -165,6 +165,7 @@ struct thread_options {
 	unsigned int iodepth_batch_complete;
 
 	unsigned long long size;
+	unsigned int size_percent;
 	unsigned int fill_device;
 	unsigned long long file_size_low;
 	unsigned long long file_size_high;
diff --git a/helpers.c b/helpers.c
index 1b6dea8..9562567 100644
--- a/helpers.c
+++ b/helpers.c
@@ -9,6 +9,12 @@
 #include "arch/arch.h"
 #include "os/os.h"
 
+int _weak fallocate(int fd, int mode, off_t offset, off_t len)
+{
+	errno = ENOSYS;
+	return -1;
+}
+
 #ifndef __NR_fallocate
 int _weak posix_fallocate(int fd, off_t offset, off_t len)
 {
diff --git a/helpers.h b/helpers.h
index 7b1ad34..da20a6b 100644
--- a/helpers.h
+++ b/helpers.h
@@ -7,6 +7,7 @@
 
 struct in_addr;
 
+extern int _weak fallocate(int fd, int mode, off_t offset, off_t len);
 extern int _weak posix_memalign(void **ptr, size_t align, size_t size);
 extern int _weak posix_fallocate(int fd, off_t offset, off_t len);
 extern int _weak inet_aton(const char *cp, struct in_addr *inp);
diff --git a/options.c b/options.c
index b4456a4..74c6478 100644
--- a/options.c
+++ b/options.c
@@ -744,6 +744,20 @@ static int str_gtod_cpu_cb(void *data, long long *il)
 	return 0;
 }
 
+static int str_size_cb(void *data, unsigned long long *__val)
+{
+	struct thread_data *td = data;
+	unsigned long long v = *__val;
+
+	if (parse_is_percent(v)) {
+		td->o.size = 0;
+		td->o.size_percent = -1ULL - v;
+	} else
+		td->o.size = v;
+
+	return 0;
+}
+
 static int rw_verify(struct fio_option *o, void *data)
 {
 	struct thread_data *td = data;
@@ -1031,8 +1045,7 @@ static struct fio_option options[FIO_MAX_OPTS] = {
 	{
 		.name	= "size",
 		.type	= FIO_OPT_STR_VAL,
-		.off1	= td_var_offset(size),
-		.minval = 1,
+		.cb	= str_size_cb,
 		.help	= "Total size of device or files",
 	},
 	{
diff --git a/os/os-freebsd.h b/os/os-freebsd.h
index 7a79dd0..fad051f 100644
--- a/os/os-freebsd.h
+++ b/os/os-freebsd.h
@@ -13,6 +13,7 @@
 #define FIO_USE_GENERIC_RAND
 #define FIO_HAVE_CHARDEV_SIZE
 #define FIO_HAVE_CLOCK_MONOTONIC
+#define FIO_HAVE_GETTID
 
 #define OS_MAP_ANON		MAP_ANON
 
@@ -51,6 +52,14 @@ static inline unsigned long long os_phys_mem(void)
 	return mem;
 }
 
+static inline int gettid(void)
+{
+	long lwpid;
+
+	thr_self(&lwpid);
+	return (int) lwpid;
+}
+
 #ifdef MADV_FREE
 #define FIO_MADV_FREE	MADV_FREE
 #endif
diff --git a/os/os-linux.h b/os/os-linux.h
index 024ef89..a36552b 100644
--- a/os/os-linux.h
+++ b/os/os-linux.h
@@ -32,7 +32,6 @@
 #define FIO_HAVE_BLKTRACE
 #define FIO_HAVE_STRSEP
 #define FIO_HAVE_FALLOCATE
-#define FIO_HAVE_LINUX_FALLOCATE
 #define FIO_HAVE_POSIXAIO_FSYNC
 #define FIO_HAVE_PSHARED_MUTEX
 #define FIO_HAVE_CL_SIZE
@@ -42,6 +41,15 @@
 #define FIO_HAVE_TRIM
 #define FIO_HAVE_BINJECT
 #define FIO_HAVE_CLOCK_MONOTONIC
+#define FIO_HAVE_GETTID
+
+/*
+ * Can only enable this for newer glibcs, or the header and defines are
+ * missing
+ */
+#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 6
+#define FIO_HAVE_LINUX_FALLOCATE
+#endif
 
 #ifdef SYNC_FILE_RANGE_WAIT_BEFORE
 #define FIO_HAVE_SYNC_FILE_RANGE
@@ -102,6 +110,11 @@ static inline int ioprio_set(int which, int who, int ioprio)
 	return syscall(__NR_ioprio_set, which, who, ioprio);
 }
 
+static inline int gettid(void)
+{
+	return syscall(__NR_gettid);
+}
+
 /*
  * Just check for SPLICE_F_MOVE, if that isn't there, assume the others
  * aren't either.
diff --git a/os/os-mac.h b/os/os-mac.h
index 7446a43..0d3cae3 100644
--- a/os/os-mac.h
+++ b/os/os-mac.h
@@ -22,6 +22,7 @@
 #define FIO_HAVE_POSIXAIO
 #define FIO_HAVE_CLOCK_MONOTONIC
 #define FIO_USE_GENERIC_RAND
+#define FIO_HAVE_GETTID
 
 #define OS_MAP_ANON		MAP_ANON
 
@@ -147,4 +148,9 @@ static inline unsigned long long os_phys_mem(void)
 	sysctl(mib, 2, &mem, &len, NULL, 0);
 	return mem;
 }
+
+static inline int gettid(void)
+{
+	return mach_thread_self();
+}
 #endif
diff --git a/os/os-netbsd.h b/os/os-netbsd.h
index 8f61ec5..7f5f484 100644
--- a/os/os-netbsd.h
+++ b/os/os-netbsd.h
@@ -19,6 +19,7 @@
 #define FIO_HAVE_FDATASYNC
 #define FIO_USE_GENERIC_BDEV_SIZE
 #define FIO_USE_GENERIC_RAND
+#define FIO_HAVE_GETTID
 
 #undef	FIO_HAVE_CPU_AFFINITY	/* XXX notyet */
 
@@ -45,6 +46,14 @@ static inline unsigned long long os_phys_mem(void)
 	return mem;
 }
 
+static inline int gettid(void)
+{
+	long lwpid;
+
+	thr_self(&lwpid);
+	return (int) lwpid;
+}
+
 #ifdef MADV_FREE
 #define FIO_MADV_FREE	MADV_FREE
 #endif
diff --git a/os/os-solaris.h b/os/os-solaris.h
index 681d4a6..e1627d7 100644
--- a/os/os-solaris.h
+++ b/os/os-solaris.h
@@ -119,6 +119,11 @@ static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
 	return 0;
 }
 
+static inline int gettid(void)
+{
+	return pthread_self();
+}
+
 /*
  * Should be enough, not aware of what (if any) restrictions Solaris has
  */
diff --git a/os/os.h b/os/os.h
index 3df7b41..cd2bb52 100644
--- a/os/os.h
+++ b/os/os.h
@@ -187,4 +187,11 @@ static inline unsigned int cpus_online(void)
 }
 #endif
 
+#ifndef FIO_HAVE_GETTID
+static inline int gettid(void)
+{
+	return getpid();
+}
+#endif
+
 #endif
diff --git a/parse.c b/parse.c
index 97ea4aa..ef23fbe 100644
--- a/parse.c
+++ b/parse.c
@@ -118,7 +118,8 @@ static unsigned long get_mult_time(char c)
 	}
 }
 
-static unsigned long long __get_mult_bytes(const char *p, void *data)
+static unsigned long long __get_mult_bytes(const char *p, void *data,
+					   int *percent)
 {
 	unsigned int kb_base = fio_get_kb_base(data);
 	unsigned long long ret = 1;
@@ -158,6 +159,10 @@ static unsigned long long __get_mult_bytes(const char *p, void *data)
 		pow = 2;
 	else if (!strcmp("k", c) || !strcmp("kb", c))
 		pow = 1;
+	else if (!strcmp("%", c)) {
+		*percent = 1;
+		return ret;
+	}
 
 	while (pow--)
 		ret *= (unsigned long long) mult;
@@ -166,12 +171,13 @@ static unsigned long long __get_mult_bytes(const char *p, void *data)
 	return ret;
 }
 
-static unsigned long long get_mult_bytes(const char *str, int len, void *data)
+static unsigned long long get_mult_bytes(const char *str, int len, void *data,
+					 int *percent)
 {
 	const char *p = str;
 
 	if (len < 2)
-		return __get_mult_bytes(str, data);
+		return __get_mult_bytes(str, data, percent);
 
         /*
          * Go forward until we hit a non-digit
@@ -182,10 +188,10 @@ static unsigned long long get_mult_bytes(const char *str, int len, void *data)
 		p++;
 	}
 
-	if (!isalpha((int) *p))
+	if (!isalpha((int) *p) && (*p != '%'))
 		p = NULL;
 
-	return __get_mult_bytes(p, data);
+	return __get_mult_bytes(p, data, percent);
 }
 
 /*
@@ -208,9 +214,16 @@ int str_to_decimal(const char *str, long long *val, int kilo, void *data)
 	if (*val == LONG_MAX && errno == ERANGE)
 		return 1;
 
-	if (kilo)
-		*val *= get_mult_bytes(str, len, data);
-	else
+	if (kilo) {
+		unsigned long long mult;
+		int perc = 0;
+
+		mult = get_mult_bytes(str, len, data, &perc);
+		if (perc)
+			*val = -1ULL - *val;
+		else
+			*val *= mult;
+	} else
 		*val *= get_mult_time(str[len - 1]);
 
 	return 0;
diff --git a/parse.h b/parse.h
index 41e3633..2dd8459 100644
--- a/parse.h
+++ b/parse.h
@@ -89,4 +89,9 @@ typedef int (fio_opt_str_set_fn)(void *);
 #define max(a, b)	((a) > (b) ? (a) : (b))
 #endif
 
+static inline int parse_is_percent(unsigned long long val)
+{
+	return val <= -1ULL && val >= (-1ULL - 100ULL);
+}
+
 #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