<div dir="ltr">So it&#39;s a test issue. The utility assumes the fs allocates in 4K units. That&#39;s why it only works when clustersize is 4K.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 8, 2013 at 8:09 AM, David Weber <span dir="ltr">&lt;<a href="mailto:wb@munzinger.de" target="_blank">wb@munzinger.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Am Donnerstag, 8. August 2013, 07:30:27 schrieb Sunil Mushran:<br>
<div class="im">&gt; Interesting. Please can you print the inode disk using the command below.<br>
&gt; The file path is minus the mounted dir.<br>
&gt;<br>
&gt; debugfs.ocfs2 -R &quot;stat /relative/path/to/file&quot; /dev/DEVICE<br>
&gt;<br>
&gt; It is saying that the fs has allocated a block when it did not need to. It<br>
&gt; could be that the test utility does not handle blocks larger than 4K, or<br>
&gt; the fiemap ioctl has a bug or the fs is indeed allocating a block when it<br>
&gt; does not need to. The above command will show us the actual layout on disk.<br>
<br>
</div>Thank you for looking into this!<br>
<br>
# ./fiemap-tester /mnt/kvm-images/fiemap_new<br>
<div class="im">Starting infinite run, if you don&#39;t see any output then its working properly.<br>
HEY FS PERSON: your fs is weird.  I specifically wanted a<br>
hole and you allocated a block anyway.  FIBMAP confirms that<br>
you allocated a block, and the block is filled with 0&#39;s so<br>
everything is kosher, but you still allocated a block when<br>
didn&#39;t need to.  This may or may not be what you wanted,<br>
which is why I&#39;m only printing this message once, in case<br>
you didn&#39;t do it on purpose. This was at block 0.<br>
ERROR: preallocated extent is not marked with FIEMAP_EXTENT_UNWRITTEN: 0<br>
map is<br>
&#39;HDHPHHDDHPHPHPHDDHHPPDDPPPHHHPDDDPDHHHHDDDPPHPPPDPHHPPDPPHHDDPDPPHDHPDDDDPDPPDPHDDPPDDPPHDDPDHHHDDPDHPHPDPPDDHPHPPHDPHPHDDHDPDPDHDHPDDPHPPPHDPPDPDDHPHDDPPHPDHPPHPPHPHHPHDHPPDDPHDHHPPHPPDHPHPHDHPPDDDDPHHHPPPHHHDDDDPDPDDPPPHPHDPPPHDPDPHDDHPPPDPDHPHHPHDHHDHPDPHDDPPHDPPDDPDDPPDHPPDPDHHPHDHPPHDDHDPHPPPDHPDDDHDDHDPPHHDDPPDPDDHDHHPHDPHHPPPDPPDHDHHPPHDPHDPPHDPHHPPP&#39;<br>

</div>logical: [       0..     255] phys: 206615552..206615807 flags: 0x000 tot: 256<br>
Problem comparing fiemap and map<br>
<br>
# debugfs.ocfs2 -R &quot;stat /fiemap_new&quot; /dev/drbd0<br>
        Inode: 92668161   Mode: 0644   Generation: 3713753505 (0xdd5b61a1)<br>
        FS Generation: 2357962590 (0x8c8ba75e)<br>
        CRC32: 00000000   ECC: 0000<br>
        Type: Regular   Attr: 0x0   Flags: Valid<br>
        Dynamic Features: (0x0)<br>
        User: 0 (root)   Group: 0 (root)   Size: 1470464<br>
        Links: 1   Clusters: 2<br>
        ctime: 0x5203b200 0x991cd -- Thu Aug  8 16:58:08.627149 2013<br>
        atime: 0x5203b200 0xc0accc -- Thu Aug  8 16:58:08.12627148 2013<br>
        mtime: 0x5203b200 0x991cd -- Thu Aug  8 16:58:08.627149 2013<br>
        dtime: 0x0 -- Thu Jan  1 01:00:00 1970<br>
        Refcount Block: 0<br>
        Last Extblk: 0   Orphan Slot: 0<br>
        Sub Alloc Slot: 0   Sub Alloc Bit: 1<br>
        Tree Depth: 0   Count: 243   Next Free Rec: 2<br>
        ## Offset        Clusters       Block#          Flags<br>
        0  0             1              206615552       0x0<br>
        1  1             1              206619648       0x0<br>
<div><div class="h5"><br>
<br>
&gt; On Aug 8, 2013, at 2:16 AM, David Weber &lt;<a href="mailto:wb@munzinger.de">wb@munzinger.de</a>&gt; wrote:<br>
&gt; &gt; Am Mittwoch, 7. August 2013, 22:07:19 schrieb Jeff Liu:<br>
&gt; &gt;&gt; On 08/07/2013 05:17 PM, David Weber wrote:<br>
&gt; &gt;&gt;&gt; Hi,<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; We are trying to use OCFS2 as VM storage. After running into problems<br>
&gt; &gt;&gt;&gt; with<br>
&gt; &gt;&gt;&gt; qemu&#39;s disk_mirror feature we now think there could be a problem with<br>
&gt; &gt;&gt;&gt; the<br>
&gt; &gt;&gt;&gt; FIEMAP ioctl in OCFS2.<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; As far as I understand the situation looks like this:<br>
&gt; &gt;&gt;&gt; Qemu inquiries the FS if the given section of the image is already<br>
&gt; &gt;&gt;&gt; allocated via the FIEMAP ioctl [1]<br>
&gt; &gt;&gt;&gt; It especially checks if fm_mapped_extents is greater 0.<br>
&gt; &gt;&gt;&gt; OCFS2 reports on sections bigger 1048576 there would be 0 mapped_extents<br>
&gt; &gt;&gt;&gt; which is wrong.<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; I extended a userspace FIEMAP util [2] a bit to specify the start and<br>
&gt; &gt;&gt;&gt; length parameter [3] as an easier testcase.<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; When we create a big file which has no holes<br>
&gt; &gt;&gt;&gt; dd if=/dev/urandom of=/mnt/kvm-images/urandom.img bs=1M count=1000<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; We get on lower sections the expected output:<br>
&gt; &gt;&gt;&gt; ./a.out /mnt/kvm-images/urandom.img 10000 10<br>
&gt; &gt;&gt;&gt; start: 2710, length: a<br>
&gt; &gt;&gt;&gt; File /mnt/kvm-images/urandom.img has 1 extents:<br>
&gt; &gt;&gt;&gt; #       Logical          Physical         Length           Flags<br>
&gt; &gt;&gt;&gt; 0:      0000000000000000 0000004ca3f00000 000000000be00000 0000<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; But on sections &gt;= 1048576 it reports there wouldn&#39;t be any extents<br>
&gt; &gt;&gt;&gt; which<br>
&gt; &gt;&gt;&gt; is as far as I understand wrong:<br>
&gt; &gt;&gt;&gt; ./a.out /mnt/kvm-images/urandom.img 1048576 10<br>
&gt; &gt;&gt;&gt; start: 100000, length: a<br>
&gt; &gt;&gt;&gt; File /mnt/kvm-images/urandom.img has 0 extents:<br>
&gt; &gt;&gt;&gt; #       Logical          Physical         Length           Flags<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Thanks for your report, looks this problem has existed over years.<br>
&gt; &gt;&gt; As a quick response, could you please try the below fix?<br>
&gt; &gt;<br>
&gt; &gt; Thank you very much! This solved the problems with qemu.<br>
&gt; &gt;<br>
&gt; &gt; I found a fiemap-tester util[1] in the xfstests project and it runs fine<br>
&gt; &gt; on<br>
&gt; &gt; OCFS2 with 4K cluster size but fails with 1M. I have however no idea if<br>
&gt; &gt; this is a severe problem.<br>
&gt; &gt;<br>
&gt; &gt; # gcc -DHAVE_FALLOCATE=1 -o fiemap-tester fiemap-tester.c<br>
&gt; &gt; # ./fiemap-tester /mnt/kvm-images/fiemap_test<br>
&gt; &gt; Starting infinite run, if you don&#39;t see any output then its working<br>
&gt; &gt; properly. HEY FS PERSON: your fs is weird.  I specifically wanted a<br>
&gt; &gt; hole and you allocated a block anyway.  FIBMAP confirms that<br>
&gt; &gt; you allocated a block, and the block is filled with 0&#39;s so<br>
&gt; &gt; everything is kosher, but you still allocated a block when<br>
&gt; &gt; didn&#39;t need to.  This may or may not be what you wanted,<br>
&gt; &gt; which is why I&#39;m only printing this message once, in case<br>
&gt; &gt; you didn&#39;t do it on purpose. This was at block 0.<br>
&gt; &gt; ERROR: preallocated extent is not marked with FIEMAP_EXTENT_UNWRITTEN: 0<br>
&gt; &gt; map is<br>
&gt; &gt; &#39;HDHPHHDDHPHPHPHDDHHPPDDPPPHHHPDDDPDHHHHDDDPPHPPPDPHHPPDPPHHDDPDPPHDHPDDDD<br>
&gt; &gt; PDPPDPHDDPPDDPPHDDPDHHHDDPDHPHPDPPDDHPHPPHDPHPHDDHDPDPDHDHPDDPHPPPHDPPDPDD<br>
&gt; &gt; HPHDDPPHPDHPPHPPHPHHPHDHPPDDPHDHHPPHPPDHPHPHDHPPDDDDPHHHPPPHHHDDDDPDPDDPPP<br>
&gt; &gt; HPHDPPPHDPDPHDDHPPPDPDHPHHPHDHHDHPDPHDDPPHDPPDDPDDPPDHPPDPDHHPHDHPPHDDHDPH<br>
</div></div>&gt; &gt; PPPDHPDDDHDDHDPPHHDDPPDPDDHDHHPHDPHHPPPDPPDHDHHPPHDPHDPPHDPHHPPP&#39; logical:<br>
<div class="HOEnZb"><div class="h5">&gt; &gt; [       0..     255] phys: 132160512..132160767 flags: 0x000 tot: 256<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; [1]<br>
&gt; &gt; <a href="http://oss.sgi.com/cgi-bin/gitweb.cgi?p=xfs/cmds/xfstests.git;a=blob_plai" target="_blank">http://oss.sgi.com/cgi-bin/gitweb.cgi?p=xfs/cmds/xfstests.git;a=blob_plai</a><br>
&gt; &gt; n;f=src/fiemap-tester.c;hb=HEAD&gt;<br>
&gt; &gt;&gt; From: Jie Liu &lt;<a href="mailto:jeff.liu@oracle.com">jeff.liu@oracle.com</a>&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Call fiemap ioctl(2) with given start offset as well as an desired<br>
&gt; &gt;&gt; mapping range should show extents if possible.  However, we calculate<br>
&gt; &gt;&gt; the end offset of mapping via &#39;mapping_end -= cpos&#39; before iterating<br>
&gt; &gt;&gt; the extent records which would cause problems, e.g,<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Cluster size 4096:<br>
&gt; &gt;&gt; debugfs.ocfs2 1.6.3<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;        Block Size Bits: 12   Cluster Size Bits: 12<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; The extended fiemap test utility From David:<br>
&gt; &gt;&gt; <a href="https://gist.github.com/anonymous/6172331" target="_blank">https://gist.github.com/anonymous/6172331</a><br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; # dd if=/dev/urandom of=/ocfs2/test_file bs=1M count=1000<br>
&gt; &gt;&gt; # ./fiemap /ocfs2/test_file 4096 10<br>
&gt; &gt;&gt; start: 4096, length: 10<br>
&gt; &gt;&gt; File /ocfs2/test_file has 0 extents:<br>
&gt; &gt;&gt; #    Logical          Physical         Length           Flags<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;    ^^^^^ &lt;-- No extents<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; In this case, at ocfs2_fiemap(): cpos == mapping_end == 1. Hence the<br>
&gt; &gt;&gt; loop of searching extent records was not executed at all.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; This patch remove the in question &#39;mapping_end -= cpos&#39;, and loops<br>
&gt; &gt;&gt; until the cpos is larger than the mapping_end instead.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; # ./fiemap /ocfs2/test_file 4096 10<br>
&gt; &gt;&gt; start: 4096, length: 10<br>
&gt; &gt;&gt; File /ocfs2/test_file has 1 extents:<br>
&gt; &gt;&gt; #    Logical          Physical         Length           Flags<br>
&gt; &gt;&gt; 0:    0000000000000000 0000000056a01000 0000000006a00000 0000<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Reported-by: David Weber &lt;<a href="mailto:wb@munzinger.de">wb@munzinger.de</a>&gt;<br>
&gt; &gt;&gt; Cc: Mark Fashen &lt;<a href="mailto:mfasheh@suse.de">mfasheh@suse.de</a>&gt;<br>
&gt; &gt;&gt; Cc: Joel Becker &lt;<a href="mailto:jlbec@evilplan.org">jlbec@evilplan.org</a>&gt;<br>
&gt; &gt;&gt; Signed-off-by: Jie Liu &lt;<a href="mailto:jeff.liu@oracle.com">jeff.liu@oracle.com</a>&gt;<br>
&gt; &gt;&gt; ---<br>
&gt; &gt;&gt; fs/ocfs2/extent_map.c |    1 -<br>
&gt; &gt;&gt; 1 file changed, 1 deletion(-)<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c<br>
&gt; &gt;&gt; index 2487116..8460647 100644<br>
&gt; &gt;&gt; --- a/fs/ocfs2/extent_map.c<br>
&gt; &gt;&gt; +++ b/fs/ocfs2/extent_map.c<br>
&gt; &gt;&gt; @@ -781,7 +781,6 @@ int ocfs2_fiemap(struct inode *inode, struct<br>
&gt; &gt;&gt; fiemap_extent_info *fieinfo, cpos = map_start &gt;&gt; osb-&gt;s_clustersize_bits;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;    mapping_end = ocfs2_clusters_for_bytes(inode-&gt;i_sb,<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;                           map_start + map_len);<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; -    mapping_end -= cpos;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;    is_last = 0;<br>
&gt; &gt;&gt;    while (cpos &lt; mapping_end &amp;&amp; !is_last) {<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;        u32 fe_flags;<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; We&#39;re running linux-3.11-rc4 plus the following patches:<br>
&gt; &gt;&gt;&gt; [PATCH V2] ocfs2: update inode size after zeroed the hole<br>
&gt; &gt;&gt;&gt; [PATCH RESEND] ocfs2: fix NULL pointer dereference in<br>
&gt; &gt;&gt;&gt; ocfs2_duplicate_clusters_by_page<br>
&gt; &gt;&gt;&gt; NULL pointer dereference at    ocfs2_dir_foreach_blk_id<br>
&gt; &gt;&gt;&gt; [patch v3] ocfs2: ocfs2: fix recent memory corruption bug<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; o2info --volinfo  /dev/drbd0<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;       Label: kvm-images<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;        UUID: BE7C101466AD4F2196A849C7A6031263<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;  Block Size: 4096<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; Cluster Size: 1048576<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;  Node Slots: 8<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;    Features: backup-super strict-journal-super sparse extended-slotmap<br>
&gt; &gt;&gt;&gt;    Features: inline-data xattr indexed-dirs refcount discontig-bg<br>
&gt; &gt;&gt;&gt;    unwritten<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; Thanks in advance!<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; Cheers,<br>
&gt; &gt;&gt;&gt; David<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; [1]<br>
&gt; &gt;&gt;&gt; <a href="http://git.qemu.org/?p=qemu.git;a=blob;f=block/raw-posix.c;h=ba721d3f5bd" target="_blank">http://git.qemu.org/?p=qemu.git;a=blob;f=block/raw-posix.c;h=ba721d3f5bd</a><br>
&gt; &gt;&gt;&gt; 9<br>
&gt; &gt;&gt;&gt; 8a6b62791c2e20dbf2894021ad76;hb=HEAD#l1087<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; [2]<br>
&gt; &gt;&gt;&gt; <a href="http://smackerelofopinion.blogspot.de/2010/01/using-fiemap-ioctl-to-get-" target="_blank">http://smackerelofopinion.blogspot.de/2010/01/using-fiemap-ioctl-to-get-</a>&gt; &gt;&gt;&gt; f<br>
&gt; &gt;&gt;&gt; ile-extents.html<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; [3] <a href="https://gist.github.com/anonymous/6172331" target="_blank">https://gist.github.com/anonymous/6172331</a><br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; _______________________________________________<br>
&gt; &gt;&gt;&gt; Ocfs2-devel mailing list<br>
&gt; &gt;&gt;&gt; <a href="mailto:Ocfs2-devel@oss.oracle.com">Ocfs2-devel@oss.oracle.com</a><br>
&gt; &gt;&gt;&gt; <a href="https://oss.oracle.com/mailman/listinfo/ocfs2-devel" target="_blank">https://oss.oracle.com/mailman/listinfo/ocfs2-devel</a><br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Ocfs2-devel mailing list<br>
&gt; &gt; <a href="mailto:Ocfs2-devel@oss.oracle.com">Ocfs2-devel@oss.oracle.com</a><br>
&gt; &gt; <a href="https://oss.oracle.com/mailman/listinfo/ocfs2-devel" target="_blank">https://oss.oracle.com/mailman/listinfo/ocfs2-devel</a><br>
</div></div></blockquote></div><br></div>