2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
34 #include <attr/xattr.h>
36 #define XFS_ERRTAG_MAX 17
70 typedef void (*opfnc_t)(int, long);
72 typedef struct opdesc {
85 typedef struct flist {
92 typedef struct pathname {
98 #define FT_DIRm (1 << FT_DIR)
100 #define FT_REGm (1 << FT_REG)
102 #define FT_SYMm (1 << FT_SYM)
104 #define FT_DEVm (1 << FT_DEV)
106 #define FT_RTFm (1 << FT_RTF)
108 #define FT_ANYm ((1 << FT_nft) - 1)
109 #define FT_REGFILE (FT_REGm | FT_RTFm)
110 #define FT_NOTDIR (FT_ANYm & ~FT_DIRm)
112 #define FLIST_SLOT_INCR 16
115 #define MAXFSIZE ((1ULL << 63) - 1ULL)
116 #define MAXFSIZE32 ((1ULL << 40) - 1ULL)
118 void allocsp_f(int, long);
119 void attr_remove_f(int, long);
120 void attr_set_f(int, long);
121 void bulkstat_f(int, long);
122 void bulkstat1_f(int, long);
123 void chown_f(int, long);
124 void creat_f(int, long);
125 void dread_f(int, long);
126 void dwrite_f(int, long);
127 void fdatasync_f(int, long);
128 void freesp_f(int, long);
129 void fsync_f(int, long);
130 void getdents_f(int, long);
131 void link_f(int, long);
132 void mkdir_f(int, long);
133 void mknod_f(int, long);
134 void read_f(int, long);
135 void readlink_f(int, long);
136 void rename_f(int, long);
137 void resvsp_f(int, long);
138 void rmdir_f(int, long);
139 void stat_f(int, long);
140 void symlink_f(int, long);
141 void sync_f(int, long);
142 void truncate_f(int, long);
143 void unlink_f(int, long);
144 void unresvsp_f(int, long);
145 void write_f(int, long);
148 { OP_ALLOCSP, "allocsp", allocsp_f, 1, 1 },
149 { OP_ATTR_REMOVE, "attr_remove", attr_remove_f, /* 1 */ 0, 1 },
150 { OP_ATTR_SET, "attr_set", attr_set_f, /* 2 */ 0, 1 },
151 { OP_BULKSTAT, "bulkstat", bulkstat_f, 1, 0 },
152 { OP_BULKSTAT1, "bulkstat1", bulkstat1_f, 1, 0 },
153 { OP_CHOWN, "chown", chown_f, 3, 1 },
154 { OP_CREAT, "creat", creat_f, 4, 1 },
155 { OP_DREAD, "dread", dread_f, 4, 0 },
156 { OP_DWRITE, "dwrite", dwrite_f, 4, 1 },
157 { OP_FDATASYNC, "fdatasync", fdatasync_f, 1, 1 },
158 { OP_FREESP, "freesp", freesp_f, 1, 1 },
159 { OP_FSYNC, "fsync", fsync_f, 1, 1 },
160 { OP_GETDENTS, "getdents", getdents_f, 1, 0 },
161 { OP_LINK, "link", link_f, 1, 1 },
162 { OP_MKDIR, "mkdir", mkdir_f, 2, 1 },
163 { OP_MKNOD, "mknod", mknod_f, 2, 1 },
164 { OP_READ, "read", read_f, 1, 0 },
165 { OP_READLINK, "readlink", readlink_f, 1, 0 },
166 { OP_RENAME, "rename", rename_f, 2, 1 },
167 { OP_RESVSP, "resvsp", resvsp_f, 1, 1 },
168 { OP_RMDIR, "rmdir", rmdir_f, 1, 1 },
169 { OP_STAT, "stat", stat_f, 1, 0 },
170 { OP_SYMLINK, "symlink", symlink_f, 2, 1 },
171 { OP_SYNC, "sync", sync_f, 1, 0 },
172 { OP_TRUNCATE, "truncate", truncate_f, 2, 1 },
173 { OP_UNLINK, "unlink", unlink_f, 1, 1 },
174 { OP_UNRESVSP, "unresvsp", unresvsp_f, 1, 1 },
175 { OP_WRITE, "write", write_f, 4, 1 },
178 flist_t flist[FT_nft] = {
191 xfs_fsop_geom_t geom;
204 unsigned long seed = 0;
208 void add_to_flist(int, int, int);
209 void append_pathname(pathname_t *, char *);
210 int attr_list_path(pathname_t *, char *, const int, int);
211 int attr_remove_path(pathname_t *, const char *, int);
212 int attr_set_path(pathname_t *, const char *, const char *, const int, int);
213 void check_cwd(void);
214 int creat_path(pathname_t *, mode_t);
215 void dcache_enter(int, int);
216 void dcache_init(void);
217 fent_t *dcache_lookup(int);
218 void dcache_purge(int);
219 void del_from_flist(int, int);
220 int dirid_to_name(char *, int);
222 void fent_to_name(pathname_t *, flist_t *, fent_t *);
223 void fix_parent(int, int);
224 void free_pathname(pathname_t *);
225 int generate_fname(fent_t *, int, pathname_t *, int *, int *);
226 int get_fname(int, long, pathname_t *, flist_t **, fent_t **, int *);
227 void init_pathname(pathname_t *);
228 int lchown_path(pathname_t *, uid_t, gid_t);
229 int link_path(pathname_t *, pathname_t *);
230 int lstat64_path(pathname_t *, struct stat64 *);
231 void make_freq_table(void);
232 int mkdir_path(pathname_t *, mode_t);
233 int mknod_path(pathname_t *, mode_t, dev_t);
234 void namerandpad(int, char *, int);
235 int open_path(pathname_t *, int);
236 DIR *opendir_path(pathname_t *);
237 void process_freq(char *);
238 int readlink_path(pathname_t *, char *, size_t);
239 int rename_path(pathname_t *, pathname_t *);
240 int rmdir_path(pathname_t *);
241 void separate_pathname(pathname_t *, char *, pathname_t *);
242 void show_ops(int, char *);
243 int stat64_path(pathname_t *, struct stat64 *);
244 int symlink_path(const char *, pathname_t *);
245 int truncate64_path(pathname_t *, off64_t);
246 int unlink_path(pathname_t *);
248 void write_freq(void);
249 void zero_freq(void);
251 int main(int argc, char **argv)
255 char *dirname = NULL;
264 xfs_error_injection_t err_inj;
266 errrange = errtag = 0;
268 nops = sizeof(ops) / sizeof(ops[0]);
269 ops_end = &ops[nops];
271 while ((c = getopt(argc, argv, "d:e:f:i:n:p:rs:vwzHS")) != -1) {
277 sscanf(optarg, "%d", &errtag);
281 } else if (errtag == 0)
283 if (errtag >= XFS_ERRTAG_MAX) {
285 "error tag %d too large (max %d)\n",
286 errtag, XFS_ERRTAG_MAX - 1);
291 process_freq(optarg);
294 ilist = realloc(ilist, ++ilistlen * sizeof(*ilist));
295 ilist[ilistlen - 1] = strtol(optarg, &p, 16);
298 operations = atoi(optarg);
301 nproc = atoi(optarg);
307 seed = strtoul(optarg, NULL, 0);
324 fprintf(stderr, "%s - invalid parameters\n",
334 /* no directory specified */
335 if (!nousage) usage();
339 (void)mkdir(dirname, 0777);
340 if (chdir(dirname) < 0) {
344 sprintf(buf, "fss%x", getpid());
345 fd = creat(buf, 0666);
346 if (lseek64(fd, (off64_t)(MAXFSIZE32 + 1ULL), SEEK_SET) < 0)
347 maxfsize = (off64_t)MAXFSIZE32;
349 maxfsize = (off64_t)MAXFSIZE;
354 gettimeofday(&t, (void *)NULL);
355 seed = (int)t.tv_sec ^ (int)t.tv_usec;
356 printf("seed = %ld\n", seed);
358 i = ioctl(fd, XFS_IOC_FSGEOMETRY, &geom);
359 if (i >= 0 && geom.rtblocks)
360 rtpct = MIN(MAX(geom.rtblocks * 100 /
361 (geom.rtblocks + geom.datablocks), 1), 99);
370 for (i = 0; i < j; i++)
373 errtag = (random() % (XFS_ERRTAG_MAX-1)) + 1;
379 for (i = 0; i < j; i++)
382 errtag += (random() % (XFS_ERRTAG_MAX - errtag));
384 printf("Injecting failure on tag #%d\n", errtag);
385 err_inj.errtag = errtag;
387 srval = ioctl(fd, XFS_IOC_ERROR_INJECTION, &err_inj);
389 perror("fsstress - XFS_SYSSGI error injection call");
397 for (i = 0; i < nproc; i++) {
404 while (wait(&stat) > 0)
409 if((srval = ioctl(fd, XFS_IOC_ERROR_CLEARALL, &err_inj)) != 0) {
410 fprintf(stderr, "Bad ej clear on %d (%d).\n", fd, errno);
411 perror("fsstress - XFS_SYSSGI clear error injection call");
422 add_to_flist(int ft, int id, int parent)
428 if (ftp->nfiles == ftp->nslots) {
429 ftp->nslots += FLIST_SLOT_INCR;
430 ftp->fents = realloc(ftp->fents, ftp->nslots * sizeof(fent_t));
432 fep = &ftp->fents[ftp->nfiles++];
434 fep->parent = parent;
438 append_pathname(pathname_t *name, char *str)
444 if (len && *str == '/' && name->len == 0) {
445 fprintf(stderr, "fsstress: append_pathname failure\n");
451 name->path = realloc(name->path, name->len + 1 + len);
452 strcpy(&name->path[name->len], str);
457 attr_list_path(pathname_t *name, char *buffer, const int buffersize, int flags)
459 char buf[MAXNAMELEN];
463 if (flags != ATTR_DONTFOLLOW) {
467 rval = llistxattr(name->path, buffer, buffersize);
468 if (rval >= 0 || errno != ENAMETOOLONG)
470 separate_pathname(name, buf, &newname);
471 if (chdir(buf) == 0) {
472 rval = attr_list_path(&newname, buffer, buffersize, flags);
475 free_pathname(&newname);
480 attr_remove_path(pathname_t *name, const char *attrname, int flags)
482 char buf[MAXNAMELEN];
486 rval = attr_remove(name->path, attrname, flags);
487 if (rval >= 0 || errno != ENAMETOOLONG)
489 separate_pathname(name, buf, &newname);
490 if (chdir(buf) == 0) {
491 rval = attr_remove_path(&newname, attrname, flags);
494 free_pathname(&newname);
499 attr_set_path(pathname_t *name, const char *attrname, const char *attrvalue,
500 const int valuelength, int flags)
502 char buf[MAXNAMELEN];
506 rval = attr_set(name->path, attrname, attrvalue, valuelength, flags);
507 if (rval >= 0 || errno != ENAMETOOLONG)
509 separate_pathname(name, buf, &newname);
510 if (chdir(buf) == 0) {
511 rval = attr_set_path(&newname, attrname, attrvalue, valuelength,
515 free_pathname(&newname);
523 struct stat64 statbuf;
525 if (stat64(".", &statbuf) == 0 && statbuf.st_ino == top_ino)
528 fprintf(stderr, "fsstress: check_cwd failure\n");
535 creat_path(pathname_t *name, mode_t mode)
537 char buf[MAXNAMELEN];
541 rval = creat(name->path, mode);
542 if (rval >= 0 || errno != ENAMETOOLONG)
544 separate_pathname(name, buf, &newname);
545 if (chdir(buf) == 0) {
546 rval = creat_path(&newname, mode);
549 free_pathname(&newname);
554 dcache_enter(int dirid, int slot)
556 dcache[dirid % NDCACHE] = slot;
564 for (i = 0; i < NDCACHE; i++)
569 dcache_lookup(int dirid)
574 i = dcache[dirid % NDCACHE];
575 if (i >= 0 && (fep = &flist[FT_DIR].fents[i])->id == dirid)
581 dcache_purge(int dirid)
585 dcp = &dcache[dirid % NDCACHE];
586 if (*dcp >= 0 && flist[FT_DIR].fents[*dcp].id == dirid)
591 del_from_flist(int ft, int slot)
597 dcache_purge(ftp->fents[slot].id);
598 if (slot != ftp->nfiles - 1) {
600 dcache_purge(ftp->fents[ftp->nfiles - 1].id);
601 ftp->fents[slot] = ftp->fents[--ftp->nfiles];
607 dirid_to_fent(int dirid)
613 if ((fep = dcache_lookup(dirid)))
615 flp = &flist[FT_DIR];
616 for (fep = flp->fents, efep = &fep[flp->nfiles]; fep < efep; fep++) {
617 if (fep->id == dirid) {
618 dcache_enter(dirid, fep - flp->fents);
628 struct stat64 statbuf;
634 sprintf(buf, "p%x", procid);
635 (void)mkdir(buf, 0777);
636 if (chdir(buf) < 0 || stat64(".", &statbuf) < 0) {
640 top_ino = statbuf.st_ino;
641 homedir = getcwd(NULL, -1);
646 for (opno = 0; opno < operations; opno++) {
647 p = &ops[freq_table[random() % freq_table_size]];
648 p->func(opno, random());
650 * test for forced shutdown by stat'ing the test
651 * directory. If this stat returns EIO, assume
652 * the forced shutdown happened.
654 if (errtag != 0 && opno % 100 == 0) {
655 rval = stat64(".", &statbuf);
657 fprintf(stderr, "Detected EIO\n");
665 fent_to_name(pathname_t *name, flist_t *flp, fent_t *fep)
667 char buf[MAXNAMELEN];
673 if (fep->parent != -1) {
674 pfep = dirid_to_fent(fep->parent);
675 fent_to_name(name, &flist[FT_DIR], pfep);
676 append_pathname(name, "/");
678 i = sprintf(buf, "%c%x", flp->tag, fep->id);
679 namerandpad(fep->id, buf, i);
680 append_pathname(name, buf);
684 fix_parent(int oldid, int newid)
691 for (i = 0, flp = flist; i < FT_nft; i++, flp++) {
692 for (j = 0, fep = flp->fents; j < flp->nfiles; j++, fep++) {
693 if (fep->parent == oldid)
700 free_pathname(pathname_t *name)
710 generate_fname(fent_t *fep, int ft, pathname_t *name, int *idp, int *v)
712 char buf[MAXNAMELEN];
719 len = sprintf(buf, "%c%x", flp->tag, id = nameseq++);
720 namerandpad(id, buf, len);
722 fent_to_name(name, &flist[FT_DIR], fep);
723 append_pathname(name, "/");
725 append_pathname(name, buf);
728 for (j = 0; !*v && j < ilistlen; j++) {
729 if (ilist[j] == id) {
738 get_fname(int which, long r, pathname_t *name, flist_t **flpp, fent_t **fepp,
748 for (i = 0, c = 0, flp = flist; i < FT_nft; i++, flp++) {
749 if (which & (1 << i))
761 for (i = 0, c = 0, flp = flist; i < FT_nft; i++, flp++) {
762 if (which & (1 << i)) {
763 if (x < c + flp->nfiles) {
764 fep = &flp->fents[x - c];
766 fent_to_name(name, flp, fep);
772 for (j = 0; !*v && j < ilistlen; j++) {
773 if (ilist[j] == fep->id) {
784 fprintf(stderr, "fsstress: get_fname failure\n");
792 init_pathname(pathname_t *name)
799 lchown_path(pathname_t *name, uid_t owner, gid_t group)
801 char buf[MAXNAMELEN];
805 rval = lchown(name->path, owner, group);
806 if (rval >= 0 || errno != ENAMETOOLONG)
808 separate_pathname(name, buf, &newname);
809 if (chdir(buf) == 0) {
810 rval = lchown_path(&newname, owner, group);
813 free_pathname(&newname);
818 link_path(pathname_t *name1, pathname_t *name2)
820 char buf1[MAXNAMELEN];
821 char buf2[MAXNAMELEN];
827 rval = link(name1->path, name2->path);
828 if (rval >= 0 || errno != ENAMETOOLONG)
830 separate_pathname(name1, buf1, &newname1);
831 separate_pathname(name2, buf2, &newname2);
832 if (strcmp(buf1, buf2) == 0) {
833 if (chdir(buf1) == 0) {
834 rval = link_path(&newname1, &newname2);
838 if (strcmp(buf1, "..") == 0)
840 else if (strcmp(buf2, "..") == 0)
842 else if (strlen(buf1) == 0)
844 else if (strlen(buf2) == 0)
847 down1 = MAX(newname1.len, 3 + name2->len) <=
848 MAX(3 + name1->len, newname2.len);
850 free_pathname(&newname2);
851 append_pathname(&newname2, "../");
852 append_pathname(&newname2, name2->path);
853 if (chdir(buf1) == 0) {
854 rval = link_path(&newname1, &newname2);
858 free_pathname(&newname1);
859 append_pathname(&newname1, "../");
860 append_pathname(&newname1, name1->path);
861 if (chdir(buf2) == 0) {
862 rval = link_path(&newname1, &newname2);
867 free_pathname(&newname1);
868 free_pathname(&newname2);
873 lstat64_path(pathname_t *name, struct stat64 *sbuf)
875 char buf[MAXNAMELEN];
879 rval = lstat64(name->path, sbuf);
880 if (rval >= 0 || errno != ENAMETOOLONG)
882 separate_pathname(name, buf, &newname);
883 if (chdir(buf) == 0) {
884 rval = lstat64_path(&newname, sbuf);
887 free_pathname(&newname);
892 make_freq_table(void)
898 for (p = ops, f = 0; p < ops_end; p++)
900 freq_table = malloc(f * sizeof(*freq_table));
902 for (p = ops, i = 0; p < ops_end; p++) {
903 for (f = 0; f < p->freq; f++, i++)
904 freq_table[i] = p->op;
909 mkdir_path(pathname_t *name, mode_t mode)
911 char buf[MAXNAMELEN];
915 rval = mkdir(name->path, mode);
916 if (rval >= 0 || errno != ENAMETOOLONG)
918 separate_pathname(name, buf, &newname);
919 if (chdir(buf) == 0) {
920 rval = mkdir_path(&newname, mode);
923 free_pathname(&newname);
928 mknod_path(pathname_t *name, mode_t mode, dev_t dev)
930 char buf[MAXNAMELEN];
934 rval = mknod(name->path, mode, dev);
935 if (rval >= 0 || errno != ENAMETOOLONG)
937 separate_pathname(name, buf, &newname);
938 if (chdir(buf) == 0) {
939 rval = mknod_path(&newname, mode, dev);
942 free_pathname(&newname);
947 namerandpad(int id, char *buf, int i)
950 static int buckets[] =
951 { 2, 4, 8, 16, 32, 64, 128, MAXNAMELEN - 1 };
957 bucket = (id ^ namerand) % (sizeof(buckets) / sizeof(buckets[0]));
958 padmod = buckets[bucket] + 1 - i;
961 padlen = (id ^ namerand) % padmod;
963 memset(&buf[i], 'X', padlen);
964 buf[i + padlen] = '\0';
969 open_path(pathname_t *name, int oflag)
971 char buf[MAXNAMELEN];
975 rval = open(name->path, oflag);
976 if (rval >= 0 || errno != ENAMETOOLONG)
978 separate_pathname(name, buf, &newname);
979 if (chdir(buf) == 0) {
980 rval = open_path(&newname, oflag);
983 free_pathname(&newname);
988 opendir_path(pathname_t *name)
990 char buf[MAXNAMELEN];
994 rval = opendir(name->path);
995 if (rval || errno != ENAMETOOLONG)
997 separate_pathname(name, buf, &newname);
998 if (chdir(buf) == 0) {
999 rval = opendir_path(&newname);
1002 free_pathname(&newname);
1007 process_freq(char *arg)
1012 s = strchr(arg, '=');
1014 fprintf(stderr, "bad argument '%s'\n", arg);
1018 for (p = ops; p < ops_end; p++) {
1019 if (strcmp(arg, p->name) == 0) {
1024 fprintf(stderr, "can't find op type %s for -f\n", arg);
1029 readlink_path(pathname_t *name, char *lbuf, size_t lbufsiz)
1031 char buf[MAXNAMELEN];
1035 rval = readlink(name->path, lbuf, lbufsiz);
1036 if (rval >= 0 || errno != ENAMETOOLONG)
1038 separate_pathname(name, buf, &newname);
1039 if (chdir(buf) == 0) {
1040 rval = readlink_path(&newname, lbuf, lbufsiz);
1043 free_pathname(&newname);
1048 rename_path(pathname_t *name1, pathname_t *name2)
1050 char buf1[MAXNAMELEN];
1051 char buf2[MAXNAMELEN];
1053 pathname_t newname1;
1054 pathname_t newname2;
1057 rval = rename(name1->path, name2->path);
1058 if (rval >= 0 || errno != ENAMETOOLONG)
1060 separate_pathname(name1, buf1, &newname1);
1061 separate_pathname(name2, buf2, &newname2);
1062 if (strcmp(buf1, buf2) == 0) {
1063 if (chdir(buf1) == 0) {
1064 rval = rename_path(&newname1, &newname2);
1068 if (strcmp(buf1, "..") == 0)
1070 else if (strcmp(buf2, "..") == 0)
1072 else if (strlen(buf1) == 0)
1074 else if (strlen(buf2) == 0)
1077 down1 = MAX(newname1.len, 3 + name2->len) <=
1078 MAX(3 + name1->len, newname2.len);
1080 free_pathname(&newname2);
1081 append_pathname(&newname2, "../");
1082 append_pathname(&newname2, name2->path);
1083 if (chdir(buf1) == 0) {
1084 rval = rename_path(&newname1, &newname2);
1088 free_pathname(&newname1);
1089 append_pathname(&newname1, "../");
1090 append_pathname(&newname1, name1->path);
1091 if (chdir(buf2) == 0) {
1092 rval = rename_path(&newname1, &newname2);
1097 free_pathname(&newname1);
1098 free_pathname(&newname2);
1103 rmdir_path(pathname_t *name)
1105 char buf[MAXNAMELEN];
1109 rval = rmdir(name->path);
1110 if (rval >= 0 || errno != ENAMETOOLONG)
1112 separate_pathname(name, buf, &newname);
1113 if (chdir(buf) == 0) {
1114 rval = rmdir_path(&newname);
1117 free_pathname(&newname);
1122 separate_pathname(pathname_t *name, char *buf, pathname_t *newname)
1126 init_pathname(newname);
1127 slash = strchr(name->path, '/');
1128 if (slash == NULL) {
1133 strcpy(buf, name->path);
1135 append_pathname(newname, slash + 1);
1141 show_ops(int flag, char *lead_str)
1146 /* print in list form */
1149 for (p = ops; p < ops_end; p++) {
1150 if (lead_str != NULL && x+strlen(p->name)>=WIDTH-5)
1151 x=printf("%s%s", (p==ops)?"":"\n", lead_str);
1152 x+=printf("%s ", p->name);
1157 for (f = 0, p = ops; p < ops_end; p++)
1163 for (p = ops; p < ops_end; p++) {
1164 if (flag != 0 || p->freq > 0) {
1165 if (lead_str != NULL)
1166 printf("%s", lead_str);
1167 printf("%20s %d/%d %s\n",
1168 p->name, p->freq, f,
1169 (p->iswrite == 0) ? " " : "write op");
1176 stat64_path(pathname_t *name, struct stat64 *sbuf)
1178 char buf[MAXNAMELEN];
1182 rval = stat64(name->path, sbuf);
1183 if (rval >= 0 || errno != ENAMETOOLONG)
1185 separate_pathname(name, buf, &newname);
1186 if (chdir(buf) == 0) {
1187 rval = stat64_path(&newname, sbuf);
1190 free_pathname(&newname);
1195 symlink_path(const char *name1, pathname_t *name)
1197 char buf[MAXNAMELEN];
1201 if (!strcmp(name1, name->path)) {
1202 printf("yikes! %s %s\n", name1, name->path);
1206 rval = symlink(name1, name->path);
1207 if (rval >= 0 || errno != ENAMETOOLONG)
1209 separate_pathname(name, buf, &newname);
1210 if (chdir(buf) == 0) {
1211 rval = symlink_path(name1, &newname);
1214 free_pathname(&newname);
1219 truncate64_path(pathname_t *name, off64_t length)
1221 char buf[MAXNAMELEN];
1225 rval = truncate64(name->path, length);
1226 if (rval >= 0 || errno != ENAMETOOLONG)
1228 separate_pathname(name, buf, &newname);
1229 if (chdir(buf) == 0) {
1230 rval = truncate64_path(&newname, length);
1233 free_pathname(&newname);
1238 unlink_path(pathname_t *name)
1240 char buf[MAXNAMELEN];
1244 rval = unlink(name->path);
1245 if (rval >= 0 || errno != ENAMETOOLONG)
1247 separate_pathname(name, buf, &newname);
1248 if (chdir(buf) == 0) {
1249 rval = unlink_path(&newname);
1252 free_pathname(&newname);
1259 printf("Usage: %s -H or\n", myprog);
1260 printf(" %s [-d dir][-e errtg][-f op_name=freq][-n nops]\n",
1262 printf(" [-p nproc][-r len][-s seed][-v][-w][-z][-S]\n");
1264 printf(" -d dir specifies the base directory for operations\n");
1265 printf(" -e errtg specifies error injection stuff\n");
1266 printf(" -f op_name=freq changes the frequency of option name to freq\n");
1267 printf(" the valid operation names are:\n");
1269 printf(" -n nops specifies the no. of operations per process (default 1)\n");
1270 printf(" -p nproc specifies the no. of processes (default 1)\n");
1271 printf(" -r specifies random name padding\n");
1272 printf(" -s seed specifies the seed for the random generator (default random)\n");
1273 printf(" -v specifies verbose mode\n");
1274 printf(" -w zeros frequencies of non-write operations\n");
1275 printf(" -z zeros frequencies of all operations\n");
1276 printf(" -S prints the table of operations (omitting zero frequency)\n");
1277 printf(" -H prints usage and exits\n");
1285 for (p = ops; p < ops_end; p++) {
1296 for (p = ops; p < ops_end; p++)
1301 allocsp_f(int opno, long r)
1313 if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
1315 printf("%d/%d: allocsp - no filename\n", procid, opno);
1319 fd = open_path(&f, O_RDWR);
1320 e = fd < 0 ? errno : 0;
1324 printf("%d/%d: allocsp - open %s failed %d\n",
1325 procid, opno, f.path, e);
1329 if (fstat64(fd, &stb) < 0) {
1331 printf("%d/%d: allocsp - fstat64 %s failed %d\n",
1332 procid, opno, f.path, errno);
1337 lr = ((__int64_t)random() << 32) + random();
1338 off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
1340 fl.l_whence = SEEK_SET;
1343 e = ioctl(fd, XFS_IOC_ALLOCSP64, &fl) < 0 ? errno : 0;
1345 printf("%d/%d: ioctl(XFS_IOC_ALLOCSP64) %s %lld 0 %d\n",
1346 procid, opno, f.path, off, e);
1352 attr_remove_f(int opno, long r)
1364 if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
1365 append_pathname(&f, ".");
1367 e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW);
1370 for (l = buf; l - buf <= e; l += strlen(l)+1)
1371 if (strncmp(l, "user.",5) == 0)
1376 printf("%d/%d: attr_remove - no attrs for %s\n",
1377 procid, opno, f.path);
1381 which = (int)(random() % total);
1384 e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW);
1388 for (l = buf; l - buf <= e; l += strlen(l)+1) {
1389 if (strncmp(l, "user.",5) == 0) {
1390 if (++ent == which) {
1396 if (aname == NULL) {
1399 "%d/%d: attr_remove - name %d not found at %s\n",
1400 procid, opno, which, f.path);
1404 e = attr_remove_path(&f, aname, ATTR_DONTFOLLOW) < 0 ? errno : 0;
1407 printf("%d/%d: attr_remove %s %s %d\n",
1408 procid, opno, f.path, aname, e);
1413 attr_set_f(int opno, long r)
1420 static int lengths[] = { 10, 100, 1000, 10000 };
1425 if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
1426 append_pathname(&f, ".");
1427 sprintf(aname, "a%x", nameseq++);
1428 li = (int)(random() % (sizeof(lengths) / sizeof(lengths[0])));
1429 len = (int)(random() % lengths[li]);
1433 memset(aval, nameseq & 0xff, len);
1434 e = attr_set_path(&f, aname, aval, len, ATTR_DONTFOLLOW) < 0 ?
1439 printf("%d/%d: attr_set %s %s %d\n", procid, opno, f.path,
1445 bulkstat_f(int opno, long r)
1453 xfs_fsop_bulkreq_t bsr;
1456 nent = (r % 999) + 2;
1457 t = malloc(nent * sizeof(*t));
1458 fd = open(".", O_RDONLY);
1466 while (ioctl(fd, XFS_IOC_FSBULKSTAT, &bsr) == 0 && count > 0)
1470 printf("%d/%d: bulkstat nent %d total %lld\n",
1471 procid, opno, nent, total);
1476 bulkstat1_f(int opno, long r)
1486 xfs_fsop_bulkreq_t bsr;
1489 good = random() & 1;
1491 /* use an inode we know exists */
1493 if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
1494 append_pathname(&f, ".");
1495 ino = stat64_path(&f, &s) < 0 ? (ino64_t)r : s.st_ino;
1500 * pick a random inode
1502 * note this can generate kernel warning messages
1503 * since bulkstat_one will read the disk block that
1504 * would contain a given inode even if that disk
1505 * block doesn't contain inodes.
1507 * this is detected later, but not until after the
1508 * warning is displayed.
1510 * "XFS: device 0x825- bad inode magic/vsn daddr 0x0 #0"
1516 fd = open(".", O_RDONLY);
1523 e = ioctl(fd, XFS_IOC_FSBULKSTAT_SINGLE, &bsr) < 0 ? errno : 0;
1525 printf("%d/%d: bulkstat1 %s ino %lld %d\n",
1526 procid, opno, good?"real":"random", (int64_t)ino, e);
1531 chown_f(int opno, long r)
1540 if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
1541 append_pathname(&f, ".");
1542 u = (uid_t)random();
1543 nbits = (int)(random() % 32);
1544 u &= (1 << nbits) - 1;
1545 e = lchown_path(&f, u, -1) < 0 ? errno : 0;
1548 printf("%d/%d: chown %s %d %d\n", procid, opno, f.path, u, e);
1553 creat_f(int opno, long r)
1568 if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v1))
1573 type = rtpct ? ((random() % 100) > rtpct ? FT_REG : FT_RTF) : FT_REG;
1575 extsize = (random() % 10) + 1;
1578 e = generate_fname(fep, type, &f, &id, &v);
1582 fent_to_name(&f, &flist[FT_DIR], fep);
1583 printf("%d/%d: creat - no filename from %s\n",
1584 procid, opno, f.path);
1589 fd = creat_path(&f, 0666);
1590 e = fd < 0 ? errno : 0;
1594 if (extsize && ioctl(fd, XFS_IOC_FSGETXATTR, &a) >= 0) {
1595 a.fsx_xflags |= XFS_XFLAG_REALTIME;
1597 geom.rtextsize * geom.blocksize * extsize;
1598 if (ioctl(fd, XFS_IOC_FSSETXATTR, &a) < 0)
1601 add_to_flist(type, id, parid);
1605 printf("%d/%d: creat %s x:%d %d %d\n", procid, opno, f.path,
1606 extsize ? a.fsx_extsize : 0, e, e1);
1611 dread_f(int opno, long r)
1615 struct dioattr diob;
1626 if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
1628 printf("%d/%d: dread - no filename\n", procid, opno);
1632 fd = open_path(&f, O_RDONLY|O_DIRECT);
1633 e = fd < 0 ? errno : 0;
1637 printf("%d/%d: dread - open %s failed %d\n",
1638 procid, opno, f.path, e);
1642 if (fstat64(fd, &stb) < 0) {
1644 printf("%d/%d: dread - fstat64 %s failed %d\n",
1645 procid, opno, f.path, errno);
1650 if (stb.st_size == 0) {
1652 printf("%d/%d: dread - %s zero size\n", procid, opno,
1658 if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
1661 "%d/%d: dread - ioctl(fd, XFS_IOC_DIOINFO) %s failed %d\n",
1662 procid, opno, f.path, errno);
1667 align = (__int64_t)diob.d_miniosz;
1668 lr = ((__int64_t)random() << 32) + random();
1669 off = (off64_t)(lr % stb.st_size);
1670 off -= (off % align);
1671 lseek64(fd, off, SEEK_SET);
1672 len = (random() % (getpagesize() * 32)) + 1;
1673 len -= (len % align);
1676 else if (len > diob.d_maxiosz)
1677 len = diob.d_maxiosz;
1678 buf = memalign(diob.d_mem, len);
1679 e = read(fd, buf, len) < 0 ? errno : 0;
1682 printf("%d/%d: dread %s [%lld,%d] %d\n",
1683 procid, opno, f.path, off, len, e);
1689 dwrite_f(int opno, long r)
1693 struct dioattr diob;
1704 if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
1706 printf("%d/%d: dwrite - no filename\n", procid, opno);
1710 fd = open_path(&f, O_WRONLY|O_DIRECT);
1711 e = fd < 0 ? errno : 0;
1715 printf("%d/%d: dwrite - open %s failed %d\n",
1716 procid, opno, f.path, e);
1720 if (fstat64(fd, &stb) < 0) {
1722 printf("%d/%d: dwrite - fstat64 %s failed %d\n",
1723 procid, opno, f.path, errno);
1728 if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
1731 "%d/%d: dwrite - ioctl(fd, XFS_IOC_DIOINFO) %s failed %d\n",
1732 procid, opno, f.path, errno);
1737 align = (__int64_t)diob.d_miniosz;
1738 lr = ((__int64_t)random() << 32) + random();
1739 off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
1740 off -= (off % align);
1741 lseek64(fd, off, SEEK_SET);
1742 len = (random() % (getpagesize() * 32)) + 1;
1743 len -= (len % align);
1746 else if (len > diob.d_maxiosz)
1747 len = diob.d_maxiosz;
1748 buf = memalign(diob.d_mem, len);
1750 lseek64(fd, off, SEEK_SET);
1751 memset(buf, nameseq & 0xff, len);
1752 e = write(fd, buf, len) < 0 ? errno : 0;
1755 printf("%d/%d: dwrite %s [%lld,%d] %d\n",
1756 procid, opno, f.path, off, len, e);
1762 fdatasync_f(int opno, long r)
1770 if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
1772 printf("%d/%d: fdatasync - no filename\n",
1777 fd = open_path(&f, O_WRONLY);
1778 e = fd < 0 ? errno : 0;
1782 printf("%d/%d: fdatasync - open %s failed %d\n",
1783 procid, opno, f.path, e);
1787 e = fdatasync(fd) < 0 ? errno : 0;
1789 printf("%d/%d: fdatasync %s %d\n", procid, opno, f.path, e);
1795 freesp_f(int opno, long r)
1807 if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
1809 printf("%d/%d: freesp - no filename\n", procid, opno);
1813 fd = open_path(&f, O_RDWR);
1814 e = fd < 0 ? errno : 0;
1818 printf("%d/%d: freesp - open %s failed %d\n",
1819 procid, opno, f.path, e);
1823 if (fstat64(fd, &stb) < 0) {
1825 printf("%d/%d: freesp - fstat64 %s failed %d\n",
1826 procid, opno, f.path, errno);
1831 lr = ((__int64_t)random() << 32) + random();
1832 off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
1834 fl.l_whence = SEEK_SET;
1837 e = ioctl(fd, XFS_IOC_FREESP64, &fl) < 0 ? errno : 0;
1839 printf("%d/%d: ioctl(XFS_IOC_FREESP64) %s %lld 0 %d\n",
1840 procid, opno, f.path, off, e);
1846 fsync_f(int opno, long r)
1854 if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
1856 printf("%d/%d: fsync - no filename\n", procid, opno);
1860 fd = open_path(&f, O_WRONLY);
1861 e = fd < 0 ? errno : 0;
1865 printf("%d/%d: fsync - open %s failed %d\n",
1866 procid, opno, f.path, e);
1870 e = fsync(fd) < 0 ? errno : 0;
1872 printf("%d/%d: fsync %s %d\n", procid, opno, f.path, e);
1878 getdents_f(int opno, long r)
1885 if (!get_fname(FT_DIRm, r, &f, NULL, NULL, &v))
1886 append_pathname(&f, ".");
1887 dir = opendir_path(&f);
1891 printf("%d/%d: getdents - can't open %s\n",
1892 procid, opno, f.path);
1896 while (readdir64(dir) != NULL)
1899 printf("%d/%d: getdents %s 0\n", procid, opno, f.path);
1905 link_f(int opno, long r)
1918 if (!get_fname(FT_NOTDIR, r, &f, &flp, NULL, &v1)) {
1920 printf("%d/%d: link - no file\n", procid, opno);
1924 if (!get_fname(FT_DIRm, random(), NULL, NULL, &fep, &v))
1930 e = generate_fname(fep, flp - flist, &l, &id, &v1);
1934 fent_to_name(&l, &flist[FT_DIR], fep);
1935 printf("%d/%d: link - no filename from %s\n",
1936 procid, opno, l.path);
1942 e = link_path(&f, &l) < 0 ? errno : 0;
1945 add_to_flist(flp - flist, id, parid);
1947 printf("%d/%d: link %s %s %d\n", procid, opno, f.path, l.path,
1954 mkdir_f(int opno, long r)
1964 if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v))
1969 e = generate_fname(fep, FT_DIR, &f, &id, &v1);
1973 fent_to_name(&f, &flist[FT_DIR], fep);
1974 printf("%d/%d: mkdir - no filename from %s\n",
1975 procid, opno, f.path);
1980 e = mkdir_path(&f, 0777) < 0 ? errno : 0;
1983 add_to_flist(FT_DIR, id, parid);
1985 printf("%d/%d: mkdir %s %d\n", procid, opno, f.path, e);
1990 mknod_f(int opno, long r)
2000 if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v))
2005 e = generate_fname(fep, FT_DEV, &f, &id, &v1);
2009 fent_to_name(&f, &flist[FT_DIR], fep);
2010 printf("%d/%d: mknod - no filename from %s\n",
2011 procid, opno, f.path);
2016 e = mknod_path(&f, S_IFCHR|0444, 0) < 0 ? errno : 0;
2019 add_to_flist(FT_DEV, id, parid);
2021 printf("%d/%d: mknod %s %d\n", procid, opno, f.path, e);
2026 read_f(int opno, long r)
2039 if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
2041 printf("%d/%d: read - no filename\n", procid, opno);
2045 fd = open_path(&f, O_RDONLY);
2046 e = fd < 0 ? errno : 0;
2050 printf("%d/%d: read - open %s failed %d\n",
2051 procid, opno, f.path, e);
2055 if (fstat64(fd, &stb) < 0) {
2057 printf("%d/%d: read - fstat64 %s failed %d\n",
2058 procid, opno, f.path, errno);
2063 if (stb.st_size == 0) {
2065 printf("%d/%d: read - %s zero size\n", procid, opno,
2071 lr = ((__int64_t)random() << 32) + random();
2072 off = (off64_t)(lr % stb.st_size);
2073 lseek64(fd, off, SEEK_SET);
2074 len = (random() % (getpagesize() * 32)) + 1;
2076 e = read(fd, buf, len) < 0 ? errno : 0;
2079 printf("%d/%d: read %s [%lld,%d] %d\n",
2080 procid, opno, f.path, off, len, e);
2086 readlink_f(int opno, long r)
2094 if (!get_fname(FT_SYMm, r, &f, NULL, NULL, &v)) {
2096 printf("%d/%d: readlink - no filename\n", procid, opno);
2100 e = readlink_path(&f, buf, PATH_MAX) < 0 ? errno : 0;
2103 printf("%d/%d: readlink %s %d\n", procid, opno, f.path, e);
2108 rename_f(int opno, long r)
2123 if (!get_fname(FT_ANYm, r, &f, &flp, &fep, &v1)) {
2125 printf("%d/%d: rename - no filename\n", procid, opno);
2129 if (!get_fname(FT_DIRm, random(), NULL, NULL, &dfep, &v))
2134 init_pathname(&newf);
2135 e = generate_fname(dfep, flp - flist, &newf, &id, &v1);
2139 fent_to_name(&f, &flist[FT_DIR], dfep);
2140 printf("%d/%d: rename - no filename from %s\n",
2141 procid, opno, f.path);
2143 free_pathname(&newf);
2147 e = rename_path(&f, &newf) < 0 ? errno : 0;
2150 if (flp - flist == FT_DIR) {
2152 fix_parent(oldid, id);
2154 del_from_flist(flp - flist, fep - flp->fents);
2155 add_to_flist(flp - flist, id, parid);
2158 printf("%d/%d: rename %s to %s %d\n", procid, opno, f.path,
2160 free_pathname(&newf);
2165 resvsp_f(int opno, long r)
2177 if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
2179 printf("%d/%d: resvsp - no filename\n", procid, opno);
2183 fd = open_path(&f, O_RDWR);
2184 e = fd < 0 ? errno : 0;
2188 printf("%d/%d: resvsp - open %s failed %d\n",
2189 procid, opno, f.path, e);
2193 if (fstat64(fd, &stb) < 0) {
2195 printf("%d/%d: resvsp - fstat64 %s failed %d\n",
2196 procid, opno, f.path, errno);
2201 lr = ((__int64_t)random() << 32) + random();
2202 off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
2204 fl.l_whence = SEEK_SET;
2206 fl.l_len = (off64_t)(random() % (1024 * 1024));
2207 e = ioctl(fd, XFS_IOC_RESVSP64, &fl) < 0 ? errno : 0;
2209 printf("%d/%d: ioctl(XFS_IOC_RESVSP64) %s %lld %lld %d\n",
2210 procid, opno, f.path, off, fl.l_len, e);
2216 rmdir_f(int opno, long r)
2224 if (!get_fname(FT_DIRm, r, &f, NULL, &fep, &v)) {
2226 printf("%d/%d: rmdir - no directory\n", procid, opno);
2230 e = rmdir_path(&f) < 0 ? errno : 0;
2233 del_from_flist(FT_DIR, fep - flist[FT_DIR].fents);
2235 printf("%d/%d: rmdir %s %d\n", procid, opno, f.path, e);
2240 stat_f(int opno, long r)
2248 if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v)) {
2250 printf("%d/%d: stat - no entries\n", procid, opno);
2254 e = lstat64_path(&f, &stb) < 0 ? errno : 0;
2257 printf("%d/%d: stat %s %d\n", procid, opno, f.path, e);
2262 symlink_f(int opno, long r)
2275 if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v))
2280 e = generate_fname(fep, FT_SYM, &f, &id, &v1);
2284 fent_to_name(&f, &flist[FT_DIR], fep);
2285 printf("%d/%d: symlink - no filename from %s\n",
2286 procid, opno, f.path);
2291 len = (int)(random() % PATH_MAX);
2292 val = malloc(len + 1);
2294 memset(val, 'x', len);
2296 for (i = 10; i < len - 1; i += 10)
2298 e = symlink_path(val, &f) < 0 ? errno : 0;
2301 add_to_flist(FT_SYM, id, parid);
2304 printf("%d/%d: symlink %s %d\n", procid, opno, f.path, e);
2310 sync_f(int opno, long r)
2314 printf("%d/%d: sync\n", procid, opno);
2318 truncate_f(int opno, long r)
2328 if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
2330 printf("%d/%d: truncate - no filename\n", procid, opno);
2334 e = stat64_path(&f, &stb) < 0 ? errno : 0;
2338 printf("%d/%d: truncate - stat64 %s failed %d\n",
2339 procid, opno, f.path, e);
2343 lr = ((__int64_t)random() << 32) + random();
2344 off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
2346 e = truncate64_path(&f, off) < 0 ? errno : 0;
2349 printf("%d/%d: truncate %s %lld %d\n", procid, opno, f.path,
2355 unlink_f(int opno, long r)
2364 if (!get_fname(FT_NOTDIR, r, &f, &flp, &fep, &v)) {
2366 printf("%d/%d: unlink - no file\n", procid, opno);
2370 e = unlink_path(&f) < 0 ? errno : 0;
2373 del_from_flist(flp - flist, fep - flp->fents);
2375 printf("%d/%d: unlink %s %d\n", procid, opno, f.path, e);
2380 unresvsp_f(int opno, long r)
2392 if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
2394 printf("%d/%d: unresvsp - no filename\n", procid, opno);
2398 fd = open_path(&f, O_RDWR);
2399 e = fd < 0 ? errno : 0;
2403 printf("%d/%d: unresvsp - open %s failed %d\n",
2404 procid, opno, f.path, e);
2408 if (fstat64(fd, &stb) < 0) {
2410 printf("%d/%d: unresvsp - fstat64 %s failed %d\n",
2411 procid, opno, f.path, errno);
2416 lr = ((__int64_t)random() << 32) + random();
2417 off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
2419 fl.l_whence = SEEK_SET;
2421 fl.l_len = (off64_t)(random() % (1 << 20));
2422 e = ioctl(fd, XFS_IOC_UNRESVSP64, &fl) < 0 ? errno : 0;
2424 printf("%d/%d: ioctl(XFS_IOC_UNRESVSP64) %s %lld %lld %d\n",
2425 procid, opno, f.path, off, fl.l_len, e);
2431 write_f(int opno, long r)
2444 if (!get_fname(FT_REGm, r, &f, NULL, NULL, &v)) {
2446 printf("%d/%d: write - no filename\n", procid, opno);
2450 fd = open_path(&f, O_WRONLY);
2451 e = fd < 0 ? errno : 0;
2455 printf("%d/%d: write - open %s failed %d\n",
2456 procid, opno, f.path, e);
2460 if (fstat64(fd, &stb) < 0) {
2462 printf("%d/%d: write - fstat64 %s failed %d\n",
2463 procid, opno, f.path, errno);
2468 lr = ((__int64_t)random() << 32) + random();
2469 off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
2471 lseek64(fd, off, SEEK_SET);
2472 len = (random() % (getpagesize() * 32)) + 1;
2474 memset(buf, nameseq & 0xff, len);
2475 e = write(fd, buf, len) < 0 ? errno : 0;
2478 printf("%d/%d: write %s [%lld,%d] %d\n",
2479 procid, opno, f.path, off, len, e);