git://scm.lunaixsky.com
/
lunaix-os.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
59e84af
)
scale up the fragfile sample size
fs-race-fix
author
Lunaixsky
<lunaixsky@qq.com>
Sun, 4 May 2025 18:25:26 +0000
(19:25 +0100)
committer
Lunaixsky
<lunaixsky@qq.com>
Sun, 4 May 2025 18:25:26 +0000
(19:25 +0100)
lunaix-os/usr/fragfile.c
patch
|
blob
|
history
diff --git
a/lunaix-os/usr/fragfile.c
b/lunaix-os/usr/fragfile.c
index 8ceb2d5a0664f63ffd24ed3e27f3853e075e6f36..a67b94aaee47e99cd82a9f015245569cb20e3cc6 100644
(file)
--- a/
lunaix-os/usr/fragfile.c
+++ b/
lunaix-os/usr/fragfile.c
@@
-8,10
+8,14
@@
static char alphabets[] = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"01234567890";
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"01234567890";
+#define NR_BUFSIZE 4096
+#define NR_NAME_LEN 8
+#define NR_REPEAT 5
+
int main()
{
int main()
{
- unsigned int buf[
4096
];
- char name[
8
];
+ unsigned int buf[
NR_BUFSIZE
];
+ char name[
NR_NAME_LEN + 1
];
int fd = open("/dev/rand", O_RDONLY);
if (mkdir("testdir") && errno != EEXIST)
int fd = open("/dev/rand", O_RDONLY);
if (mkdir("testdir") && errno != EEXIST)
@@
-26,25
+30,35
@@
int main()
_exit(1);
}
_exit(1);
}
+ int nr_total = NR_REPEAT * NR_BUFSIZE / NR_NAME_LEN;
+
int cnt = 0;
int cnt = 0;
- for (int i = 0; i <
1
; i++)
+ for (int i = 0; i <
NR_REPEAT
; i++)
{
int n = read(fd, buf, 4096 * sizeof(int));
int j = 0, k = 0;
while (j < 4096) {
name[k++] = alphabets[buf[j++] % 63];
{
int n = read(fd, buf, 4096 * sizeof(int));
int j = 0, k = 0;
while (j < 4096) {
name[k++] = alphabets[buf[j++] % 63];
- if (k <
7
) {
+ if (k <
NR_NAME_LEN
) {
continue;
}
k = 0;
cnt++;
continue;
}
k = 0;
cnt++;
- name[
7
] = 0;
+ name[
NR_NAME_LEN
] = 0;
- printf("[%0
3d] creating: %s\n", cnt
, name);
+ printf("[%0
4d/%04d] creating: %s\r", cnt, nr_total
, name);
int fd2 = open(name, O_RDONLY | O_CREAT);
int fd2 = open(name, O_RDONLY | O_CREAT);
- if (fd2 < 0) {
+
+ if (fd2 < 0)
+ {
+ printf("\n");
+ if (errno == EDQUOT) {
+ printf("Out of quota\n");
+ return 0;
+ }
+
printf("Unable to open %d\n", errno);
continue;
}
printf("Unable to open %d\n", errno);
continue;
}
@@
-52,6
+66,6
@@
int main()
close(fd2);
}
}
close(fd2);
}
}
-
+ printf("\n");
return 0;
}
\ No newline at end of file
return 0;
}
\ No newline at end of file