fd = open("/dev/escache0", O_RDWR | O_DIRECT);
blktrace -d /dev/escache0 -o - | blkparse -i -
252,0 4 1 0.000000000 30655 Q WS 0 + 1 [openescache]
2. O_SYNC
252,0 6 1 129.714324326 30666 Q WS 0 + 8 [openescache]
252,0 6 2 129.725375608 30666 Q FWS [openescache]
F means 'flush'
openescache.c
#define _GNU_SOURCE
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <stdio.h>
#define BLOCKSIZE 512
int main() {
int fd, i;
void *buffer;
char image[BLOCKSIZE];
for(i=0; i<BLOCKSIZE; i++)
image[i] = 0xa2;
posix_memalign(&buffer, BLOCKSIZE, BLOCKSIZE);
memcpy(buffer, image, sizeof(image));
fd = open("/dev/escache0", O_RDWR | O_SYNC);
if (fd == -1) {
printf("open failed");
return -1;
}
write(fd, buffer, BLOCKSIZE);
close(fd);
free(buffer);
return 0;
}
沒有留言:
張貼留言