Skip to content
Snippets Groups Projects
Commit f12449c7 authored by Peter Braam's avatar Peter Braam
Browse files

- test programs for directio, writing and opening

- phase 2 ha assistance program
parent 31b264e0
No related branches found
No related tags found
No related merge requests found
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/mman.h>
// not correctly in the headers yet!!
#define O_DIRECT 040000 /* direct disk access hint */
int main(int argc, char **argv)
{
int fd;
char *buf;
int pages;
int rc;
if (argc != 3) {
printf("Usage: %s file nr_pages\n", argv[0]);
return 1;
}
pages = strtoul(argv[2], 0, 0);
printf("directio on %s for %d pages \n", argv[1], pages);
buf = mmap(0, pages * 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANON, 0, 0);
if (!buf) {
printf("No memory %s\n", strerror(errno));
return 1;
}
fd = open(argv[1], O_DIRECT | O_RDWR | O_CREAT);
if (fd == -1) {
printf("Cannot open %s: %s\n", argv[1], strerror(errno));
return 1;
}
rc = read(fd, buf, pages * 4096);
if (rc != pages * 4096) {
printf("Read error: %s, rc %d\n", strerror(errno), rc);
return 1;
}
if ( lseek(fd, 0, SEEK_SET) != 0 ) {
printf("Cannot seek %s\n", strerror(errno));
return 1;
}
rc = write(fd, buf, pages * 4096);
if (rc != pages * 4096) {
printf("Write error %s\n", strerror(errno));
return 1;
}
return 0;
}
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
int fd;
if (argc != 2) {
printf("Usage openme <filename>\n");
exit(1);
}
fd = open(argv[1], O_RDONLY | O_CREAT, 0600);
if (fd == -1) {
printf("Error opening %s\n", argv[1]);
exit(1);
}
sleep(10000000);
return 0;
}
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
int fd, rc;
int i = 0;
char buf[4096];
memset(buf, 0, 4096);
if (argc != 2) {
printf("Usage openme <filename>\n");
exit(1);
}
fd = open(argv[1], O_RDWR | O_CREAT, 0600);
if (fd == -1) {
printf("Error opening %s\n", argv[1]);
exit(1);
}
while (1) {
sprintf(buf, "write %d\n", i);
rc = write(fd, buf, sizeof(buf));
sleep(1);
}
return 0;
}
#!/bin/bash
set -vx
date
echo "ha assist checking for problems"
sleep 3
if [ ! -e /tmp/halog ]; then
echo "no problems, exiting"
exit
fi
echo "removing /tmp/halog"
rm /tmp/halog
echo secondary start `date`
echo "- please supply a new mds"
/usr/src/portals/linux/utils/ptlctl <<EOF3
setup tcp
close_uuid mds
del_uuid mds
connect localhost 1234
add_uuid mds
quit
EOF3
echo "connected to new MDS!"
/usr/src/obd/utils/obdctl <<EOF2
name2dev RPCDEV
newconn
quit
EOF2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment