<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body dir="auto">
The FIEMAP ioctl is implemented slightly differently for multi-stripe files in Lustre - it essentially does the FIEMAP separately for each stripe so that it is easier to see whether the file is fragmented. See the filefrag program in the Lustre-patched e2fsprogs. <br>
<br>
<div id="AppleMailSignature">Cheers, Andreas</div>
<div><br>
On Mar 9, 2018, at 06:01, lokesh jaliminche <<a href="mailto:lokesh.jaliminche@gmail.com">lokesh.jaliminche@gmail.com</a>> wrote:<br>
<br>
</div>
<blockquote type="cite">
<div>
<div dir="ltr">Ahh got it!!<br>
Meanwhile, I found one implicit method to find holes on the file i.e. using fiemap ioctl. <br>
I have tested it and works fine<br>
<br>
Logs :<br>
=====<br>
<div>dd if=/dev/urandom  of=sparse_file seek=10 bs=1M  count=1</div>
<div>1+0 records in</div>
<div>1+0 records out</div>
<div>1048576 bytes (1.0 MB) copied, 0.0969376 s, 10.8 MB/s</div>
<div>[<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">lokesh</span>]#
 dd if=/dev/urandom  of=sparse_file seek=20 bs=1M  count=1</div>
<div>1+0 records in</div>
<div>1+0 records out</div>
<div>1048576 bytes (1.0 MB) copied, 0.087068 s, 12.0 MB/s</div>
<div>[lokesh]# dd if=/dev/urandom  of=sparse_file seek=30 bs=1M  count=1</div>
<div>1+0 records in</div>
<div>1+0 records out</div>
<div>1048576 bytes (1.0 MB) copied, 0.0918352 s, 11.4 MB/s</div>
<div>[<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">lokesh</span>]#
 dd if=/dev/urandom  of=sparse_file seek=40 bs=1M  count=10</div>
<div>^[[A^[[D10+0 records in</div>
<div>10+0 records out</div>
<div>10485760 bytes (10 MB) copied, 0.946796 s, 11.1 MB/s</div>
<div>[<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">lokesh</span>]#
 dd if=/dev/urandom  of=sparse_file seek=50 bs=1M  count=10</div>
<div>10+0 records in</div>
<div>10+0 records out</div>
<div>10485760 bytes (10 MB) copied, 0.978465 s, 10.7 MB/s</div>
<div>[<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">lokesh</span>]#
 ./a.out sparse_file </div>
<div>Extents in file "sparse_file":    4</div>
<div>Extents returned: 4</div>
<div>Logical: ###[10485760]    Ext length: ###[1048576]    Physical: ###[104666759168]    flags: 2147483648    </div>
<div>Logical: ###[20971520]    Ext length: ###[1048576]    Physical: ###[104677244928]    flags: 2147483648    </div>
<div>Logical: ###[31457280]    Ext length: ###[1048576]    Physical: ###[104687730688]    flags: 2147483648    </div>
<div>Logical: ###[41943040]    Ext length: ###[20971520]    Physical: ###[104689827840]    flags: 2147483649   </div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Mar 9, 2018 at 2:12 PM, Dilger, Andreas <span dir="ltr">
<<a href="mailto:andreas.dilger@intel.com" target="_blank">andreas.dilger@intel.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="">On Mar 6, 2018, at 00:12, lokesh jaliminche <<a href="mailto:lokesh.jaliminche@gmail.com">lokesh.jaliminche@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> Does lustre support SEEK_HOLE/SEEK_DATA flag for lseek?<br>
><br>
> 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.<br>
<br>
</span>Lustre does not directly support the SEEK_HOLE/SEEK_DATA interface currently.<br>
What you are seeing is the default/minimum implementation provided by the<br>
lseek interface.<br>
<br>
Implementing these seek options might be quite complex for a Lustre file<br>
because of multiple stripes in the layout.  You would need to locate holes<br>
in the stripes, and then map the hole offset on the object to the file offset.<br>
<br>
If this is something you are interested to implement I would be happy to<br>
discuss it with you further.  Probably the best place to start is to file<br>
an LU ticket with details, and then interested parties can discuss the<br>
implementation there.<br>
<br>
Cheers, Andreas<br>
<div>
<div class="h5"><br>
> Program :<br>
> ========<br>
> #include <unistd.h><br>
> #include <sys/types.h><br>
> #include <stdio.h><br>
> #include <fcntl.h><br>
> #include <stdlib.h><br>
> #define SEEK_OFF 10485760<br>
> int main()<br>
> {<br>
>     int fd;<br>
>     char buffer[80];<br>
>     int i = 0;<br>
>     static char message[]="Hello world";<br>
>     fd=open("myfile", O_RDWR);<br>
>     if (fd != -1)<br>
>         return 1;<br>
>     printf("creating hole by writing at each of %d strides\n", SEEK_OFF);<br>
>     for (i = 1; i < 10; i++)<br>
>     {<br>
>         int seek_off = i * SEEK_OFF;<br>
>         int sz;<br>
>         printf("seek_off %ld\n", lseek(fd, seek_off, SEEK_SET));<br>
>         sz = write(fd,message,sizeof(<wbr>message));<br>
>         printf("write size = %d\n", sz);<br>
>         printf("String : %s\n", message);<br>
>     }<br>
>     printf("Demonstrating SEEK_HOLE and SEEK_DATA %d \n", SEEK_OFF);<br>
>     int start_off = 0;<br>
>     lseek(fd, 0, SEEK_SET);<br>
>     printf("after SEEK_HOLE start_off %ld\n", lseek(fd, 0, SEEK_HOLE));<br>
>     printf("after SEEK_DATA start_off %ld\n", lseek(fd, start_off, SEEK_DATA));<br>
>     printf("after SEEK_HOLE start_off %ld\n", lseek(fd, 10485760, SEEK_HOLE));<br>
>     printf("after SEEK_DATA start_off %ld\n", lseek(fd, (10485760 *2 ), SEEK_DATA));<br>
>     close(fd);<br>
> }<br>
><br>
> output:<br>
> =====<br>
> after SEEK_HOLE start_off 94372142<br>
> after SEEK_DATA start_off 0<br>
> after SEEK_HOLE start_off 94372142<br>
> after SEEK_DATA start_off 0<br>
><br>
> Regards,<br>
> Lokesh<br>
</div>
</div>
> ______________________________<wbr>_________________<br>
> lustre-discuss mailing list<br>
> <a href="mailto:lustre-discuss@lists.lustre.org">lustre-discuss@lists.lustre.<wbr>org</a><br>
> <a href="http://lists.lustre.org/listinfo.cgi/lustre-discuss-lustre.org" rel="noreferrer" target="_blank">
http://lists.lustre.org/<wbr>listinfo.cgi/lustre-discuss-<wbr>lustre.org</a><br>
<br>
Cheers, Andreas<br>
--<br>
Andreas Dilger<br>
Lustre Principal Architect<br>
Intel Corporation<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<blockquote type="cite">
<div><span>_______________________________________________</span><br>
<span>lustre-discuss mailing list</span><br>
<span><a href="mailto:lustre-discuss@lists.lustre.org">lustre-discuss@lists.lustre.org</a></span><br>
<span><a href="http://lists.lustre.org/listinfo.cgi/lustre-discuss-lustre.org">http://lists.lustre.org/listinfo.cgi/lustre-discuss-lustre.org</a></span><br>
</div>
</blockquote>
</body>
</html>