* [TESTCASE] test orphan recovery code
@ 2008-07-24 19:42 Josef Bacik
0 siblings, 0 replies; only message in thread
From: Josef Bacik @ 2008-07-24 19:42 UTC (permalink / raw)
To: linux-btrfs
Hello,
Another one for the qa suite. This will create 1001 files, unlink them, and
then do a sysrq+b which is like hitting the reset button on your box to make
sure that on mount when the box comes back up all the files are cleaned up.
Don't run this unless you expect the box to be reset. Successfull running of
this testcase should result in no file_# files being left over and no orphan
records left. Thanks,
Josef
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
int main(void)
{
int fd, i, proc_fd;
char buf[80];
for (i = 0; i <= 1000; i++) {
snprintf(buf, 80, "file_%d", i);
fd = open(buf, O_RDONLY | O_CREAT, 0666);
unlink(buf);
}
fsync(fd);
printf("rebooting...\n");
proc_fd = open("/proc/sysrq-trigger", O_WRONLY);
if (proc_fd < 0) {
fprintf(stderr, "Error opening sysrq: %d\n", errno);
}
write(proc_fd, "b", 1);
/* should be dead by now so no need to clean anything up */
return 0;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-07-24 19:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-24 19:42 [TESTCASE] test orphan recovery code Josef Bacik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox