[lustre-discuss] Hole Identification in file
lokesh jaliminche
lokesh.jaliminche at gmail.com
Mon Mar 5 23:12:29 PST 2018
Hi,
Does lustre support SEEK_HOLE/SEEK_DATA flag for lseek?
I did some experiment with the below program to find out if lustre supports
SEEK_HOLE and SEEK_DATA flag. I found that lustre always returns the end of
the file for SEEK_HOLE and 0 for SEEK_DATA and as per the man page this is
the simplest implementation that file system can have(If they dont want to
support these flags). So just wanted to confirm.
Program :
========
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#define SEEK_OFF 10485760
int main()
{
int fd;
char buffer[80];
int i = 0;
static char message[]="Hello world";
fd=open("myfile", O_RDWR);
if (fd != -1)
return 1;
printf("creating hole by writing at each of %d strides\n", SEEK_OFF);
for (i = 1; i < 10; i++)
{
int seek_off = i * SEEK_OFF;
int sz;
printf("seek_off %ld\n", lseek(fd, seek_off, SEEK_SET));
sz = write(fd,message,sizeof(message));
printf("write size = %d\n", sz);
printf("String : %s\n", message);
}
printf("Demonstrating SEEK_HOLE and SEEK_DATA %d \n", SEEK_OFF);
int start_off = 0;
lseek(fd, 0, SEEK_SET);
printf("after SEEK_HOLE start_off %ld\n", lseek(fd, 0, SEEK_HOLE));
printf("after SEEK_DATA start_off %ld\n", lseek(fd, start_off,
SEEK_DATA));
printf("after SEEK_HOLE start_off %ld\n", lseek(fd, 10485760,
SEEK_HOLE));
printf("after SEEK_DATA start_off %ld\n", lseek(fd, (10485760 *2 ),
SEEK_DATA));
close(fd);
}
output:
=====
after SEEK_HOLE start_off 94372142
after SEEK_DATA start_off 0
after SEEK_HOLE start_off 94372142
after SEEK_DATA start_off 0
Regards,
Lokesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lustre.org/pipermail/lustre-discuss-lustre.org/attachments/20180306/769a9be9/attachment.html>
More information about the lustre-discuss
mailing list