* [PATCH 2/8] Use ARRAY_SIZE()
2017-01-23 15:13 [PATCH 1/8] Define pointer alignment macro in fio.h kusumi.tomohiro
@ 2017-01-23 15:13 ` kusumi.tomohiro
2017-01-23 15:13 ` [PATCH 3/8] Fix wrong comment on exit condition of threads/processes kusumi.tomohiro
` (6 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: kusumi.tomohiro @ 2017-01-23 15:13 UTC (permalink / raw)
To: axboe, fio; +Cc: Tomohiro Kusumi
From: Tomohiro Kusumi <tkusumi@tuxera.com>
They can assume ARRAY_SIZE() is defined and usable as far as fio's
internal code is concerned (i.e. FIO_INTERNAL defined).
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
gclient.c | 2 +-
gfio.c | 2 +-
lib/num2str.c | 4 +---
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/gclient.c b/gclient.c
index 5ce33d0..928a1b7 100644
--- a/gclient.c
+++ b/gclient.c
@@ -48,7 +48,7 @@ static GtkActionEntry results_menu_items[] = {
{ "PrintFile", GTK_STOCK_PRINT, "Print", "<Control>P", NULL, G_CALLBACK(results_print) },
{ "CloseFile", GTK_STOCK_CLOSE, "Close", "<Control>W", NULL, G_CALLBACK(results_close) },
};
-static gint results_nmenu_items = sizeof(results_menu_items) / sizeof(results_menu_items[0]);
+static gint results_nmenu_items = ARRAY_SIZE(results_menu_items);
static const gchar *results_ui_string = " \
<ui> \
diff --git a/gfio.c b/gfio.c
index 9ccf78c..9c917cb 100644
--- a/gfio.c
+++ b/gfio.c
@@ -1271,7 +1271,7 @@ static GtkActionEntry menu_items[] = {
{ "Quit", GTK_STOCK_QUIT, NULL, "<Control>Q", NULL, G_CALLBACK(quit_clicked) },
{ "About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK(about_dialog) },
};
-static gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
+static gint nmenu_items = ARRAY_SIZE(menu_items);
static const gchar *ui_string = " \
<ui> \
diff --git a/lib/num2str.c b/lib/num2str.c
index 940d4a5..ed3545d 100644
--- a/lib/num2str.c
+++ b/lib/num2str.c
@@ -4,8 +4,6 @@
#include "../fio.h"
-#define ARRAY_LENGTH(arr) sizeof(arr) / sizeof((arr)[0])
-
/**
* num2str() - Cheesy number->string conversion, complete with carry rounding error.
* @num: quantity (e.g., number of blocks, bytes or bits)
@@ -75,7 +73,7 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, int units)
if (modulo == -1U) {
done:
- if (post_index >= ARRAY_LENGTH(sistr))
+ if (post_index >= ARRAY_SIZE(sistr))
post_index = 0;
sprintf(buf, "%llu%s%s", (unsigned long long) num,
--
2.5.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/8] Fix wrong comment on exit condition of threads/processes
2017-01-23 15:13 [PATCH 1/8] Define pointer alignment macro in fio.h kusumi.tomohiro
2017-01-23 15:13 ` [PATCH 2/8] Use ARRAY_SIZE() kusumi.tomohiro
@ 2017-01-23 15:13 ` kusumi.tomohiro
2017-01-23 15:13 ` [PATCH 4/8] Remove unused io_u's priv union field kusumi.tomohiro
` (5 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: kusumi.tomohiro @ 2017-01-23 15:13 UTC (permalink / raw)
To: axboe, fio; +Cc: Tomohiro Kusumi
From: Tomohiro Kusumi <tkusumi@tuxera.com>
74f4b020 in 2013 has changed the exit condition from min to max,
so sync the comment with 74f4b020.
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
backend.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/backend.c b/backend.c
index fc64709..27e36bb 100644
--- a/backend.c
+++ b/backend.c
@@ -1359,7 +1359,7 @@ static bool keep_running(struct thread_data *td)
uint64_t diff;
/*
- * If the difference is less than the minimum IO size, we
+ * If the difference is less than the maximum IO size, we
* are done.
*/
diff = limit - ddir_rw_sum(td->io_bytes);
--
2.5.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/8] Remove unused io_u's priv union field
2017-01-23 15:13 [PATCH 1/8] Define pointer alignment macro in fio.h kusumi.tomohiro
2017-01-23 15:13 ` [PATCH 2/8] Use ARRAY_SIZE() kusumi.tomohiro
2017-01-23 15:13 ` [PATCH 3/8] Fix wrong comment on exit condition of threads/processes kusumi.tomohiro
@ 2017-01-23 15:13 ` kusumi.tomohiro
2017-01-23 16:06 ` Andrey Kuzmin
2017-01-23 15:13 ` [PATCH 5/8] Remove unused disk_util's name field kusumi.tomohiro
` (4 subsequent siblings)
7 siblings, 1 reply; 12+ messages in thread
From: kusumi.tomohiro @ 2017-01-23 15:13 UTC (permalink / raw)
To: axboe, fio; +Cc: Tomohiro Kusumi
From: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
ioengine.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/ioengine.h b/ioengine.h
index 89873e7..7249df6 100644
--- a/ioengine.h
+++ b/ioengine.h
@@ -123,7 +123,6 @@ struct io_u {
struct ibv_mr *mr;
#endif
void *mmap_data;
- uint64_t null;
};
};
--
2.5.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 4/8] Remove unused io_u's priv union field
2017-01-23 15:13 ` [PATCH 4/8] Remove unused io_u's priv union field kusumi.tomohiro
@ 2017-01-23 16:06 ` Andrey Kuzmin
2017-01-23 18:01 ` Jens Axboe
0 siblings, 1 reply; 12+ messages in thread
From: Andrey Kuzmin @ 2017-01-23 16:06 UTC (permalink / raw)
To: kusumi.tomohiro; +Cc: Tomohiro Kusumi, fio, axboe
[-- Attachment #1: Type: text/plain, Size: 699 bytes --]
This may break some I/O engines.
On Jan 23, 2017 18:13, <kusumi.tomohiro@gmail.com> wrote:
From: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
ioengine.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/ioengine.h b/ioengine.h
index 89873e7..7249df6 100644
--- a/ioengine.h
+++ b/ioengine.h
@@ -123,7 +123,6 @@ struct io_u {
struct ibv_mr *mr;
#endif
void *mmap_data;
- uint64_t null;
};
};
--
2.5.5
--
To unsubscribe from this list: send the line "unsubscribe fio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: Type: text/html, Size: 1425 bytes --]
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 4/8] Remove unused io_u's priv union field
2017-01-23 16:06 ` Andrey Kuzmin
@ 2017-01-23 18:01 ` Jens Axboe
2017-01-23 18:08 ` Andrey Kuzmin
0 siblings, 1 reply; 12+ messages in thread
From: Jens Axboe @ 2017-01-23 18:01 UTC (permalink / raw)
To: Andrey Kuzmin, kusumi.tomohiro; +Cc: Tomohiro Kusumi, fio
On 01/23/2017 09:06 AM, Andrey Kuzmin wrote:
> This may break some I/O engines.
Are you using it? I'm happy to revert that change, it's not like
it's gaining us back some memory. It is annoying to have no in-tree
users of a "feature", though.
--
Jens Axboe
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/8] Remove unused io_u's priv union field
2017-01-23 18:01 ` Jens Axboe
@ 2017-01-23 18:08 ` Andrey Kuzmin
0 siblings, 0 replies; 12+ messages in thread
From: Andrey Kuzmin @ 2017-01-23 18:08 UTC (permalink / raw)
To: Jens Axboe; +Cc: Tomohiro Kusumi, fio, Tomohiro Kusumi
[-- Attachment #1: Type: text/plain, Size: 552 bytes --]
On Jan 23, 2017 21:01, "Jens Axboe" <axboe@kernel.dk> wrote:
On 01/23/2017 09:06 AM, Andrey Kuzmin wrote:
> This may break some I/O engines.
Are you using it? I'm happy to revert that change, it's not like
it's gaining us back some memory. It is annoying to have no in-tree
users of a "feature", though.
That's likely my bad as, from my (now apparently wrong) recollection, some
in-tree engines were utilizing it. I'm fine with the removal otherwise,
although it's a nice generic place-holder that avoids casting.
Regards,
Andfey
--
Jens Axboe
[-- Attachment #2: Type: text/html, Size: 1347 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 5/8] Remove unused disk_util's name field
2017-01-23 15:13 [PATCH 1/8] Define pointer alignment macro in fio.h kusumi.tomohiro
` (2 preceding siblings ...)
2017-01-23 15:13 ` [PATCH 4/8] Remove unused io_u's priv union field kusumi.tomohiro
@ 2017-01-23 15:13 ` kusumi.tomohiro
2017-01-23 15:13 ` [PATCH 6/8] Add missing free(td->sysfs_root); kusumi.tomohiro
` (3 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: kusumi.tomohiro @ 2017-01-23 15:13 UTC (permalink / raw)
To: axboe, fio; +Cc: Tomohiro Kusumi
From: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
diskutil.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/diskutil.h b/diskutil.h
index ff8a5b0..04fdde2 100644
--- a/diskutil.h
+++ b/diskutil.h
@@ -46,7 +46,6 @@ struct disk_util {
*/
struct flist_head slavelist;
- char *name;
char *sysfs_root;
char path[PATH_MAX];
int major, minor;
--
2.5.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/8] Add missing free(td->sysfs_root);
2017-01-23 15:13 [PATCH 1/8] Define pointer alignment macro in fio.h kusumi.tomohiro
` (3 preceding siblings ...)
2017-01-23 15:13 ` [PATCH 5/8] Remove unused disk_util's name field kusumi.tomohiro
@ 2017-01-23 15:13 ` kusumi.tomohiro
2017-01-23 15:13 ` [PATCH 7/8] Fix bad pointer du->sysfs_root kusumi.tomohiro
` (2 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: kusumi.tomohiro @ 2017-01-23 15:13 UTC (permalink / raw)
To: axboe, fio; +Cc: Tomohiro Kusumi
From: Tomohiro Kusumi <tkusumi@tuxera.com>
->sysfs_root for td (not du) is always strdup'd.
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
filesetup.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/filesetup.c b/filesetup.c
index eb28826..4aaa903 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -1208,6 +1208,7 @@ void close_and_free_files(struct thread_data *td)
td->o.filename = NULL;
free(td->files);
free(td->file_locks);
+ free(td->sysfs_root);
td->files_index = 0;
td->files = NULL;
td->file_locks = NULL;
--
2.5.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 7/8] Fix bad pointer du->sysfs_root
2017-01-23 15:13 [PATCH 1/8] Define pointer alignment macro in fio.h kusumi.tomohiro
` (4 preceding siblings ...)
2017-01-23 15:13 ` [PATCH 6/8] Add missing free(td->sysfs_root); kusumi.tomohiro
@ 2017-01-23 15:13 ` kusumi.tomohiro
2017-01-23 15:13 ` [PATCH 8/8] Remove/Move Linux specific sysfs_root field from thread_data kusumi.tomohiro
2017-01-23 15:26 ` [PATCH 1/8] Define pointer alignment macro in fio.h Jens Axboe
7 siblings, 0 replies; 12+ messages in thread
From: kusumi.tomohiro @ 2017-01-23 15:13 UTC (permalink / raw)
To: axboe, fio; +Cc: Tomohiro Kusumi
From: Tomohiro Kusumi <tkusumi@tuxera.com>
There are two call paths for disk_util_add() (usually the second one)
which assigns ->sysfs_root for a newly allocated disk_util*, but both
temppath/foo are local char[] within their stack, so strdup/free it.
-> find_add_disk_slaves(...)
-> __init_per_file_disk_util(..., temppath)
-> disk_util_add(..., path)
-> du->sysfs_root = path; /* == &temppath[0] */
-> init_per_file_disk_util(...)
-> __init_per_file_disk_util(..., foo)
-> disk_util_add(..., path)
-> du->sysfs_root = path; /* == &foo[0] */
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
diskutil.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/diskutil.c b/diskutil.c
index 27ddb46..c34841a 100644
--- a/diskutil.c
+++ b/diskutil.c
@@ -37,6 +37,7 @@ static void disk_util_free(struct disk_util *du)
}
fio_mutex_remove(du->lock);
+ free(du->sysfs_root);
sfree(du);
}
@@ -305,7 +306,7 @@ static struct disk_util *disk_util_add(struct thread_data *td, int majdev,
return NULL;
}
strncpy((char *) du->dus.name, basename(path), FIO_DU_NAME_SZ - 1);
- du->sysfs_root = path;
+ du->sysfs_root = strdup(path);
du->major = majdev;
du->minor = mindev;
INIT_FLIST_HEAD(&du->slavelist);
--
2.5.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 8/8] Remove/Move Linux specific sysfs_root field from thread_data
2017-01-23 15:13 [PATCH 1/8] Define pointer alignment macro in fio.h kusumi.tomohiro
` (5 preceding siblings ...)
2017-01-23 15:13 ` [PATCH 7/8] Fix bad pointer du->sysfs_root kusumi.tomohiro
@ 2017-01-23 15:13 ` kusumi.tomohiro
2017-01-23 15:26 ` [PATCH 1/8] Define pointer alignment macro in fio.h Jens Axboe
7 siblings, 0 replies; 12+ messages in thread
From: kusumi.tomohiro @ 2017-01-23 15:13 UTC (permalink / raw)
To: axboe, fio; +Cc: Tomohiro Kusumi
From: Tomohiro Kusumi <tkusumi@tuxera.com>
struct thread_data is better without having a Linux specific field
(even if sysfs_root is simply unused on non Linux environment) given
that other Linux specific code such as diskutil/cgroup/blktrace/etc
are compiled only on Linux.
This commit uses td->files[0]->du->sysfs_root instead of td->sysfs_root,
but results the same from the way diskutil is currently implemented.
Besides being platform independent, it's also better in terms of data
structure since sysfs_root isn't always per-td attribute as mentioned
below.
For example, when N(>1) files are specified via filename= option
(e.g. filename=/dev/sdb:/dev/sdc for N=2), td:files is 1:N, therefore
td:du and td:du->sysfs_root are also 1:N in case of /dev/sdb:/dev/sdc,
however td:td->sysfs_root is obviously 1:1 which in this case means
td->sysfs_root is sysfs root for /dev/sdb (regardless of other files)
from the way td->sysfs_root is set only if it hasn't yet been set.
In other words, if filename=/dev/sdb:/dev/sdc is given, ioscheduler=
option only works against /dev/sdb, which could be different from what
users would expect, but this commit just removes sysfs_root from
struct thread_data without any functional change.
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
backend.c | 7 ++++++-
diskutil.c | 9 +--------
filesetup.c | 1 -
fio.h | 2 --
4 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/backend.c b/backend.c
index 27e36bb..1c1f2f9 100644
--- a/backend.c
+++ b/backend.c
@@ -1261,6 +1261,10 @@ static int init_io_u(struct thread_data *td)
return 0;
}
+/*
+ * This function is Linux specific.
+ * FIO_HAVE_IOSCHED_SWITCH enabled currently means it's Linux.
+ */
static int switch_ioscheduler(struct thread_data *td)
{
#ifdef FIO_HAVE_IOSCHED_SWITCH
@@ -1271,7 +1275,8 @@ static int switch_ioscheduler(struct thread_data *td)
if (td_ioengine_flagged(td, FIO_DISKLESSIO))
return 0;
- sprintf(tmp, "%s/queue/scheduler", td->sysfs_root);
+ assert(td->files && td->files[0]);
+ sprintf(tmp, "%s/queue/scheduler", td->files[0]->du->sysfs_root);
f = fopen(tmp, "r+");
if (!f) {
diff --git a/diskutil.c b/diskutil.c
index c34841a..c3bcec9 100644
--- a/diskutil.c
+++ b/diskutil.c
@@ -431,9 +431,6 @@ static struct disk_util *__init_per_file_disk_util(struct thread_data *td,
sprintf(path, "%s", tmp);
}
- if (td->o.ioscheduler && !td->sysfs_root)
- td->sysfs_root = strdup(path);
-
return disk_util_add(td, majdev, mindev, path);
}
@@ -452,12 +449,8 @@ static struct disk_util *init_per_file_disk_util(struct thread_data *td,
mindev);
du = disk_util_exists(majdev, mindev);
- if (du) {
- if (td->o.ioscheduler && !td->sysfs_root)
- td->sysfs_root = strdup(du->sysfs_root);
-
+ if (du)
return du;
- }
/*
* for an fs without a device, we will repeatedly stat through
diff --git a/filesetup.c b/filesetup.c
index 4aaa903..eb28826 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -1208,7 +1208,6 @@ void close_and_free_files(struct thread_data *td)
td->o.filename = NULL;
free(td->files);
free(td->file_locks);
- free(td->sysfs_root);
td->files_index = 0;
td->files = NULL;
td->file_locks = NULL;
diff --git a/fio.h b/fio.h
index 14950fc..19ac0af 100644
--- a/fio.h
+++ b/fio.h
@@ -205,8 +205,6 @@ struct thread_data {
void *iolog_buf;
FILE *iolog_f;
- char *sysfs_root;
-
unsigned long rand_seeds[FIO_RAND_NR_OFFS];
struct frand_state bsrange_state;
--
2.5.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/8] Define pointer alignment macro in fio.h
2017-01-23 15:13 [PATCH 1/8] Define pointer alignment macro in fio.h kusumi.tomohiro
` (6 preceding siblings ...)
2017-01-23 15:13 ` [PATCH 8/8] Remove/Move Linux specific sysfs_root field from thread_data kusumi.tomohiro
@ 2017-01-23 15:26 ` Jens Axboe
7 siblings, 0 replies; 12+ messages in thread
From: Jens Axboe @ 2017-01-23 15:26 UTC (permalink / raw)
To: kusumi.tomohiro; +Cc: fio, Tomohiro Kusumi
On Tue, Jan 24 2017, kusumi.tomohiro@gmail.com wrote:
> From: Tomohiro Kusumi <tkusumi@tuxera.com>
>
> Define PTR_ALIGN() as a common utility within the entire fio,
> but inside FIO_INTERNAL guard since it could be a common name.
Thanks, applied 1-8.
--
Jens Axboe
^ permalink raw reply [flat|nested] 12+ messages in thread