* [PATCH v2 1/2] src/dmiperf: Remove obsolete dmiperf
@ 2020-12-09 4:58 Xiao Yang
2020-12-09 4:58 ` [PATCH v2 2/2] src/multi_open_unlink: Stop using attr_set Xiao Yang
2020-12-09 5:24 ` [PATCH v2 1/2] src/dmiperf: Remove obsolete dmiperf Xiao Yang
0 siblings, 2 replies; 3+ messages in thread
From: Xiao Yang @ 2020-12-09 4:58 UTC (permalink / raw)
To: darrick.wong, eguan; +Cc: fstests, Xiao Yang
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
src/Makefile | 2 +-
src/dmiperf.c | 275 --------------------------------------------------
2 files changed, 1 insertion(+), 276 deletions(-)
delete mode 100644 src/dmiperf.c
diff --git a/src/Makefile b/src/Makefile
index 32940142..80f7b892 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -11,7 +11,7 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \
mmapcat append_reader append_writer dirperf metaperf \
devzero feature alloc fault fstest t_access_root \
godown resvtest writemod writev_on_pagefault makeextents itrash rename \
- multi_open_unlink dmiperf unwritten_sync genhashnames t_holes \
+ multi_open_unlink unwritten_sync genhashnames t_holes \
t_mmap_writev t_truncate_cmtime dirhash_collide t_rename_overwrite \
holetest t_truncate_self af_unix t_mmap_stale_pmd \
t_mmap_cow_race t_mmap_fallocate fsync-err t_mmap_write_ro \
diff --git a/src/dmiperf.c b/src/dmiperf.c
deleted file mode 100644
index 4026dcfb..00000000
--- a/src/dmiperf.c
+++ /dev/null
@@ -1,275 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2006 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <dirent.h>
-#include <malloc.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <attr/attributes.h>
-
-typedef unsigned int uint_t;
-
-/*
- * Loop over directory sizes:
- * make m directories
- * touch n files in each directory
- * write y bytes to all files in each directory
- * set DMF attribute on x files in each directory
- * Change directory sizes by multiplication or addition.
- * Allow control of starting & stopping sizes, name length, target directory.
- * Print size and wallclock time (ms per file).
- * Output can be used to make graphs (gnuplot)
- */
-
-static uint_t addval;
-static uint_t dirchars;
-static char *directory;
-static uint_t firstsize;
-static uint_t lastsize;
-static uint_t minchars;
-static double mulval;
-static uint_t nchars;
-static uint_t ndirs;
-static uint_t pfxchars;
-static off64_t fsize;
-static char *buffer;
-static size_t bsize;
-
-static int mkfile(char *, char *);
-static void filename(int, int, char *);
-static int hexchars(uint_t);
-static uint_t nextsize(uint_t);
-static double now(void);
-static void usage(void);
-
-/*
- * Maximum size allowed, this is pretty nuts.
- * The largest one we've ever built has been about 2 million.
- */
-#define MAX_DIR_SIZE (16 * 1024 * 1024)
-#define DFL_FIRST_SIZE 1
-#define DFL_LAST_SIZE (1024 * 1024)
-#define MAX_DIR_COUNT 1024
-#define MIN_DIR_COUNT 1
-
-#define DMFATTRLEN 22
-#define DMFATTRNAME "SGI_DMI_DMFATTR"
-
-int
-main(int argc, char **argv)
-{
- int c;
- uint_t cursize;
- int i;
- int j;
- char name[NAME_MAX + 1];
- char attr[DMFATTRLEN];
- double stime;
-
- while ((c = getopt(argc, argv, "a:b:c:d:f:l:m:n:s:")) != -1) {
- switch (c) {
- case 'a':
- addval = (uint_t)atoi(optarg);
- break;
- case 'b':
- bsize = (size_t)atol(optarg);
- break;
- case 'c':
- nchars = (uint_t)atoi(optarg);
- break;
- case 'd':
- directory = optarg;
- break;
- case 'f':
- firstsize = (uint_t)atoi(optarg);
- break;
- case 'l':
- lastsize = (uint_t)atoi(optarg);
- break;
- case 'm':
- mulval = atof(optarg);
- break;
- case 'n':
- ndirs = (uint_t)atoi(optarg);
- break;
- case 's':
- fsize = (off64_t)atol(optarg);
- break;
- case '?':
- default:
- usage();
- exit(1);
- }
- }
- if (!addval && !mulval)
- mulval = 2.0;
- else if ((addval && mulval) || mulval < 0.0) {
- usage();
- exit(1);
- }
- if (!bsize)
- bsize = 1024 * 1024;
- buffer = memalign(getpagesize(), bsize);
- memset(buffer, 0xfeed, bsize);
- memset(attr, 0xaaaaaaa, sizeof(attr));
-
- if (!directory)
- directory = ".";
- else {
- if (mkdir(directory, 0777) < 0 && errno != EEXIST) {
- perror(directory);
- exit(1);
- }
- if (chdir(directory) < 0) {
- perror(directory);
- exit(1);
- }
- }
- if (firstsize == 0)
- firstsize = DFL_FIRST_SIZE;
- else if (firstsize > MAX_DIR_SIZE)
- firstsize = MAX_DIR_SIZE;
- if (lastsize == 0)
- lastsize = DFL_LAST_SIZE;
- else if (lastsize > MAX_DIR_SIZE)
- lastsize = MAX_DIR_SIZE;
- if (lastsize < firstsize)
- lastsize = firstsize;
- minchars = hexchars(lastsize - 1);
- if (nchars < minchars)
- nchars = minchars;
- else if (nchars >= NAME_MAX + 1)
- nchars = NAME_MAX;
- if (ndirs > MAX_DIR_COUNT)
- ndirs = MAX_DIR_COUNT;
- if (ndirs < MIN_DIR_COUNT)
- ndirs = MIN_DIR_COUNT;
- dirchars = hexchars(ndirs);
- pfxchars = nchars - minchars;
- if (pfxchars)
- memset(&name[dirchars + 1], 'a', pfxchars);
-
- cursize = firstsize;
- for (j = 0; j < ndirs; j++) {
- filename(0, j, name);
- name[dirchars] = '\0';
- mkdir(name, 0777);
- stime = now();
- for (i = 0; i < cursize; i++) {
- filename((i + j) % cursize, j, name);
- close(mkfile(name, attr));
- }
- printf("%d %.3f\n", cursize,
- (now() - stime) * 1.0e3 / (cursize * ndirs));
- cursize = nextsize(cursize);
- }
- return 0;
-}
-
-static int
-mkfile(char *name, char *attr)
-{
- int fd;
- ssize_t wrote, wsize;
- off64_t bytes = fsize;
-
- if ((fd = open(name, O_WRONLY | O_CREAT | O_EXCL | O_DIRECT, 0666)) < 0) {
- perror("open");
- exit(1);
- }
- if (attr_setf(fd, DMFATTRNAME, attr, DMFATTRLEN, ATTR_ROOT) < 0) {
- perror("attr_setf");
- exit(1);
- }
- while (bytes > 0) {
- wsize = (bsize < bytes) ? bsize : bytes;
- if ((wrote = write(fd, buffer, wsize)) < 0) {
- perror("write");
- exit(1);
- }
- bytes -= wrote;
- }
- return fd;
-}
-
-static void
-filename(int idx, int dir, char *name)
-{
- static char hexc[16] = "0123456789abcdef";
- int i;
-
- for (i = dirchars - 1; i >= 0; i--)
- *name++ = hexc[(dir >> (4 * i)) & 0xf];
- *name++ = '/';
- name += pfxchars; /* skip pfx a's */
- for (i = minchars - 1; i >= 0; i--)
- *name++ = hexc[(idx >> (4 * i)) & 0xf];
- *name = '\0';
-}
-
-static int
-hexchars(uint_t maxval)
-{
- if (maxval < 16)
- return 1;
- if (maxval < 16 * 16)
- return 2;
- if (maxval < 16 * 16 * 16)
- return 3;
- if (maxval < 16 * 16 * 16 * 16)
- return 4;
- if (maxval < 16 * 16 * 16 * 16 * 16)
- return 5;
- if (maxval < 16 * 16 * 16 * 16 * 16 * 16)
- return 6;
- if (maxval < 16 * 16 * 16 * 16 * 16 * 16 * 16)
- return 7;
- return 8;
-}
-
-static uint_t
-nextsize(uint_t cursize)
-{
- double n;
-
- n = cursize;
- if (addval)
- n += addval;
- else
- n *= mulval;
- if (n > (double)lastsize + 0.5)
- return lastsize + 1; /* i.e. out of bounds */
- else if ((uint_t)n == cursize)
- return cursize + 1;
- else
- return (uint_t)n;
-}
-
-static double
-now(void)
-{
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
- return (double)tv.tv_sec + 1.0e-6 * (double)tv.tv_usec;
-}
-
-static void
-usage(void)
-{
- fprintf(stderr,
- "usage: dirperf [-d dir] [-a addstep | -m mulstep] [-f first] "
- "[-l last] [-c nchars] [-n ndirs] [-s size]\n");
-}
--
2.23.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH v2 2/2] src/multi_open_unlink: Stop using attr_set
2020-12-09 4:58 [PATCH v2 1/2] src/dmiperf: Remove obsolete dmiperf Xiao Yang
@ 2020-12-09 4:58 ` Xiao Yang
2020-12-09 5:24 ` [PATCH v2 1/2] src/dmiperf: Remove obsolete dmiperf Xiao Yang
1 sibling, 0 replies; 3+ messages in thread
From: Xiao Yang @ 2020-12-09 4:58 UTC (permalink / raw)
To: darrick.wong, eguan; +Cc: fstests, Xiao Yang
Avoid the following warning by replacing deprecated
attr_set with setxattr:
---------------------------------------------------
warning: 'attr_set' is deprecated: Use setxattr or lsetxattr instead [-Wdeprecated-declarations]
---------------------------------------------------
Also remove unneeded flags, <attr/attributes.h> and $(LIBATTR).
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
src/Makefile | 2 +-
src/multi_open_unlink.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index 80f7b892..811b24e4 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -33,7 +33,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
SUBDIRS = log-writes perf
-LLDLIBS = $(LIBATTR) $(LIBHANDLE) $(LIBACL) -lpthread -lrt
+LLDLIBS = $(LIBHANDLE) $(LIBACL) -lpthread -lrt
ifeq ($(HAVE_XLOG_ASSIGN_LSN), true)
LINUX_TARGETS += loggen
diff --git a/src/multi_open_unlink.c b/src/multi_open_unlink.c
index d697e5f1..c221d39e 100644
--- a/src/multi_open_unlink.c
+++ b/src/multi_open_unlink.c
@@ -12,9 +12,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <attr/attributes.h>
+#include <sys/xattr.h>
#define MAX_EA_NAME 30
+#define MAX_VALUELEN (64*1024)
/*
* multi_open_unlink path_prefix num_files sleep_time
@@ -40,7 +41,7 @@ main(int argc, char *argv[])
int sleep_time = 60;
int num_files = 100;
int num_eas = 0;
- int value_size = ATTR_MAX_VALUELEN;
+ int value_size = MAX_VALUELEN;
int fd = -1;
int i,j,c;
@@ -87,7 +88,6 @@ main(int argc, char *argv[])
int sts;
char *attrvalue;
char attrname[MAX_EA_NAME];
- int flags = 0;
snprintf(attrname, MAX_EA_NAME, "user.name.%d", j);
@@ -98,7 +98,7 @@ main(int argc, char *argv[])
return 1;
}
- sts = attr_set(path, attrname, attrvalue, value_size, flags);
+ sts = setxattr(path, attrname, attrvalue, value_size, 0);
if (sts == -1) {
fprintf(stderr, "%s: failed to create EA \"%s\" of size %d on path \"%s\": %s\n",
prog, attrname, value_size, path, strerror(errno));
--
2.23.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2 1/2] src/dmiperf: Remove obsolete dmiperf
2020-12-09 4:58 [PATCH v2 1/2] src/dmiperf: Remove obsolete dmiperf Xiao Yang
2020-12-09 4:58 ` [PATCH v2 2/2] src/multi_open_unlink: Stop using attr_set Xiao Yang
@ 2020-12-09 5:24 ` Xiao Yang
1 sibling, 0 replies; 3+ messages in thread
From: Xiao Yang @ 2020-12-09 5:24 UTC (permalink / raw)
To: Xiao Yang; +Cc: darrick.wong, eguan, fstests
Hi,
Sorry, I forgot to remove the related item(src/dmiperf) in .gitignore.
I will send v3 patch soon.
Best Regards,
Xiao Yang
On 2020/12/9 12:58, Xiao Yang wrote:
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> ---
> src/Makefile | 2 +-
> src/dmiperf.c | 275 --------------------------------------------------
> 2 files changed, 1 insertion(+), 276 deletions(-)
> delete mode 100644 src/dmiperf.c
>
> diff --git a/src/Makefile b/src/Makefile
> index 32940142..80f7b892 100644
> --- a/src/Makefile
> +++ b/src/Makefile
> @@ -11,7 +11,7 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \
> mmapcat append_reader append_writer dirperf metaperf \
> devzero feature alloc fault fstest t_access_root \
> godown resvtest writemod writev_on_pagefault makeextents itrash rename \
> - multi_open_unlink dmiperf unwritten_sync genhashnames t_holes \
> + multi_open_unlink unwritten_sync genhashnames t_holes \
> t_mmap_writev t_truncate_cmtime dirhash_collide t_rename_overwrite \
> holetest t_truncate_self af_unix t_mmap_stale_pmd \
> t_mmap_cow_race t_mmap_fallocate fsync-err t_mmap_write_ro \
> diff --git a/src/dmiperf.c b/src/dmiperf.c
> deleted file mode 100644
> index 4026dcfb..00000000
> --- a/src/dmiperf.c
> +++ /dev/null
> @@ -1,275 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * Copyright (c) 2006 Silicon Graphics, Inc.
> - * All Rights Reserved.
> - */
> -
> -#include <sys/types.h>
> -#include <sys/param.h>
> -#include <sys/stat.h>
> -#include <sys/time.h>
> -#include <dirent.h>
> -#include <malloc.h>
> -#include <errno.h>
> -#include <fcntl.h>
> -#include <math.h>
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <string.h>
> -#include <unistd.h>
> -#include <attr/attributes.h>
> -
> -typedef unsigned int uint_t;
> -
> -/*
> - * Loop over directory sizes:
> - * make m directories
> - * touch n files in each directory
> - * write y bytes to all files in each directory
> - * set DMF attribute on x files in each directory
> - * Change directory sizes by multiplication or addition.
> - * Allow control of starting & stopping sizes, name length, target directory.
> - * Print size and wallclock time (ms per file).
> - * Output can be used to make graphs (gnuplot)
> - */
> -
> -static uint_t addval;
> -static uint_t dirchars;
> -static char *directory;
> -static uint_t firstsize;
> -static uint_t lastsize;
> -static uint_t minchars;
> -static double mulval;
> -static uint_t nchars;
> -static uint_t ndirs;
> -static uint_t pfxchars;
> -static off64_t fsize;
> -static char *buffer;
> -static size_t bsize;
> -
> -static int mkfile(char *, char *);
> -static void filename(int, int, char *);
> -static int hexchars(uint_t);
> -static uint_t nextsize(uint_t);
> -static double now(void);
> -static void usage(void);
> -
> -/*
> - * Maximum size allowed, this is pretty nuts.
> - * The largest one we've ever built has been about 2 million.
> - */
> -#define MAX_DIR_SIZE (16 * 1024 * 1024)
> -#define DFL_FIRST_SIZE 1
> -#define DFL_LAST_SIZE (1024 * 1024)
> -#define MAX_DIR_COUNT 1024
> -#define MIN_DIR_COUNT 1
> -
> -#define DMFATTRLEN 22
> -#define DMFATTRNAME "SGI_DMI_DMFATTR"
> -
> -int
> -main(int argc, char **argv)
> -{
> - int c;
> - uint_t cursize;
> - int i;
> - int j;
> - char name[NAME_MAX + 1];
> - char attr[DMFATTRLEN];
> - double stime;
> -
> - while ((c = getopt(argc, argv, "a:b:c:d:f:l:m:n:s:")) != -1) {
> - switch (c) {
> - case 'a':
> - addval = (uint_t)atoi(optarg);
> - break;
> - case 'b':
> - bsize = (size_t)atol(optarg);
> - break;
> - case 'c':
> - nchars = (uint_t)atoi(optarg);
> - break;
> - case 'd':
> - directory = optarg;
> - break;
> - case 'f':
> - firstsize = (uint_t)atoi(optarg);
> - break;
> - case 'l':
> - lastsize = (uint_t)atoi(optarg);
> - break;
> - case 'm':
> - mulval = atof(optarg);
> - break;
> - case 'n':
> - ndirs = (uint_t)atoi(optarg);
> - break;
> - case 's':
> - fsize = (off64_t)atol(optarg);
> - break;
> - case '?':
> - default:
> - usage();
> - exit(1);
> - }
> - }
> - if (!addval && !mulval)
> - mulval = 2.0;
> - else if ((addval && mulval) || mulval < 0.0) {
> - usage();
> - exit(1);
> - }
> - if (!bsize)
> - bsize = 1024 * 1024;
> - buffer = memalign(getpagesize(), bsize);
> - memset(buffer, 0xfeed, bsize);
> - memset(attr, 0xaaaaaaa, sizeof(attr));
> -
> - if (!directory)
> - directory = ".";
> - else {
> - if (mkdir(directory, 0777) < 0 && errno != EEXIST) {
> - perror(directory);
> - exit(1);
> - }
> - if (chdir(directory) < 0) {
> - perror(directory);
> - exit(1);
> - }
> - }
> - if (firstsize == 0)
> - firstsize = DFL_FIRST_SIZE;
> - else if (firstsize > MAX_DIR_SIZE)
> - firstsize = MAX_DIR_SIZE;
> - if (lastsize == 0)
> - lastsize = DFL_LAST_SIZE;
> - else if (lastsize > MAX_DIR_SIZE)
> - lastsize = MAX_DIR_SIZE;
> - if (lastsize < firstsize)
> - lastsize = firstsize;
> - minchars = hexchars(lastsize - 1);
> - if (nchars < minchars)
> - nchars = minchars;
> - else if (nchars >= NAME_MAX + 1)
> - nchars = NAME_MAX;
> - if (ndirs > MAX_DIR_COUNT)
> - ndirs = MAX_DIR_COUNT;
> - if (ndirs < MIN_DIR_COUNT)
> - ndirs = MIN_DIR_COUNT;
> - dirchars = hexchars(ndirs);
> - pfxchars = nchars - minchars;
> - if (pfxchars)
> - memset(&name[dirchars + 1], 'a', pfxchars);
> -
> - cursize = firstsize;
> - for (j = 0; j < ndirs; j++) {
> - filename(0, j, name);
> - name[dirchars] = '\0';
> - mkdir(name, 0777);
> - stime = now();
> - for (i = 0; i < cursize; i++) {
> - filename((i + j) % cursize, j, name);
> - close(mkfile(name, attr));
> - }
> - printf("%d %.3f\n", cursize,
> - (now() - stime) * 1.0e3 / (cursize * ndirs));
> - cursize = nextsize(cursize);
> - }
> - return 0;
> -}
> -
> -static int
> -mkfile(char *name, char *attr)
> -{
> - int fd;
> - ssize_t wrote, wsize;
> - off64_t bytes = fsize;
> -
> - if ((fd = open(name, O_WRONLY | O_CREAT | O_EXCL | O_DIRECT, 0666)) < 0) {
> - perror("open");
> - exit(1);
> - }
> - if (attr_setf(fd, DMFATTRNAME, attr, DMFATTRLEN, ATTR_ROOT) < 0) {
> - perror("attr_setf");
> - exit(1);
> - }
> - while (bytes > 0) {
> - wsize = (bsize < bytes) ? bsize : bytes;
> - if ((wrote = write(fd, buffer, wsize)) < 0) {
> - perror("write");
> - exit(1);
> - }
> - bytes -= wrote;
> - }
> - return fd;
> -}
> -
> -static void
> -filename(int idx, int dir, char *name)
> -{
> - static char hexc[16] = "0123456789abcdef";
> - int i;
> -
> - for (i = dirchars - 1; i >= 0; i--)
> - *name++ = hexc[(dir >> (4 * i)) & 0xf];
> - *name++ = '/';
> - name += pfxchars; /* skip pfx a's */
> - for (i = minchars - 1; i >= 0; i--)
> - *name++ = hexc[(idx >> (4 * i)) & 0xf];
> - *name = '\0';
> -}
> -
> -static int
> -hexchars(uint_t maxval)
> -{
> - if (maxval < 16)
> - return 1;
> - if (maxval < 16 * 16)
> - return 2;
> - if (maxval < 16 * 16 * 16)
> - return 3;
> - if (maxval < 16 * 16 * 16 * 16)
> - return 4;
> - if (maxval < 16 * 16 * 16 * 16 * 16)
> - return 5;
> - if (maxval < 16 * 16 * 16 * 16 * 16 * 16)
> - return 6;
> - if (maxval < 16 * 16 * 16 * 16 * 16 * 16 * 16)
> - return 7;
> - return 8;
> -}
> -
> -static uint_t
> -nextsize(uint_t cursize)
> -{
> - double n;
> -
> - n = cursize;
> - if (addval)
> - n += addval;
> - else
> - n *= mulval;
> - if (n > (double)lastsize + 0.5)
> - return lastsize + 1; /* i.e. out of bounds */
> - else if ((uint_t)n == cursize)
> - return cursize + 1;
> - else
> - return (uint_t)n;
> -}
> -
> -static double
> -now(void)
> -{
> - struct timeval tv;
> -
> - gettimeofday(&tv, NULL);
> - return (double)tv.tv_sec + 1.0e-6 * (double)tv.tv_usec;
> -}
> -
> -static void
> -usage(void)
> -{
> - fprintf(stderr,
> - "usage: dirperf [-d dir] [-a addstep | -m mulstep] [-f first] "
> - "[-l last] [-c nchars] [-n ndirs] [-s size]\n");
> -}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-09 5:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-09 4:58 [PATCH v2 1/2] src/dmiperf: Remove obsolete dmiperf Xiao Yang
2020-12-09 4:58 ` [PATCH v2 2/2] src/multi_open_unlink: Stop using attr_set Xiao Yang
2020-12-09 5:24 ` [PATCH v2 1/2] src/dmiperf: Remove obsolete dmiperf Xiao Yang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.