<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 &quot;sparse_file&quot;:    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">&lt;<a href="mailto:andreas.dilger@intel.com" target="_blank">andreas.dilger@intel.com</a>&gt;</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 &lt;<a href="mailto:lokesh.jaliminche@gmail.com">lokesh.jaliminche@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; Does lustre support SEEK_HOLE/SEEK_DATA flag for lseek?<br>
&gt;<br>
&gt; 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>
&gt; Program :<br>
&gt; ========<br>
&gt; #include &lt;unistd.h&gt;<br>
&gt; #include &lt;sys/types.h&gt;<br>
&gt; #include &lt;stdio.h&gt;<br>
&gt; #include &lt;fcntl.h&gt;<br>
&gt; #include &lt;stdlib.h&gt;<br>
&gt; #define SEEK_OFF 10485760<br>
&gt; int main()<br>
&gt; {<br>
&gt;     int fd;<br>
&gt;     char buffer[80];<br>
&gt;     int i = 0;<br>
&gt;     static char message[]=&quot;Hello world&quot;;<br>
&gt;     fd=open(&quot;myfile&quot;, O_RDWR);<br>
&gt;     if (fd != -1)<br>
&gt;         return 1;<br>
&gt;     printf(&quot;creating hole by writing at each of %d strides\n&quot;, SEEK_OFF);<br>
&gt;     for (i = 1; i &lt; 10; i++)<br>
&gt;     {<br>
&gt;         int seek_off = i * SEEK_OFF;<br>
&gt;         int sz;<br>
&gt;         printf(&quot;seek_off %ld\n&quot;, lseek(fd, seek_off, SEEK_SET));<br>
&gt;         sz = write(fd,message,sizeof(<wbr>message));<br>
&gt;         printf(&quot;write size = %d\n&quot;, sz);<br>
&gt;         printf(&quot;String : %s\n&quot;, message);<br>
&gt;     }<br>
&gt;     printf(&quot;Demonstrating SEEK_HOLE and SEEK_DATA %d \n&quot;, SEEK_OFF);<br>
&gt;     int start_off = 0;<br>
&gt;     lseek(fd, 0, SEEK_SET);<br>
&gt;     printf(&quot;after SEEK_HOLE start_off %ld\n&quot;, lseek(fd, 0, SEEK_HOLE));<br>
&gt;     printf(&quot;after SEEK_DATA start_off %ld\n&quot;, lseek(fd, start_off, SEEK_DATA));<br>
&gt;     printf(&quot;after SEEK_HOLE start_off %ld\n&quot;, lseek(fd, 10485760, SEEK_HOLE));<br>
&gt;     printf(&quot;after SEEK_DATA start_off %ld\n&quot;, lseek(fd, (10485760 *2 ), SEEK_DATA));<br>
&gt;     close(fd);<br>
&gt; }<br>
&gt;<br>
&gt; output:<br>
&gt; =====<br>
&gt; after SEEK_HOLE start_off 94372142<br>
&gt; after SEEK_DATA start_off 0<br>
&gt; after SEEK_HOLE start_off 94372142<br>
&gt; after SEEK_DATA start_off 0<br>
&gt;<br>
&gt; Regards,<br>
&gt; Lokesh<br>
</div></div>&gt; ______________________________<wbr>_________________<br>
&gt; lustre-discuss mailing list<br>
&gt; <a href="mailto:lustre-discuss@lists.lustre.org">lustre-discuss@lists.lustre.<wbr>org</a><br>
&gt; <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>