By &quot;<span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">According to your advice...</span>&quot;, I mean what your demonstrated.<div><br></div><div>I mount with inode64, and everything is working perfectly.</div>

<div>Many thanks, really appreciate!<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 9, 2012 at 11:08 AM, Dave Chinner <span dir="ltr">&lt;<a href="mailto:david@fromorbit.com" target="_blank">david@fromorbit.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">On Fri, Nov 09, 2012 at 10:04:57AM +0800, huubby zhou wrote:<br>


&gt; Hi, Dave,<br>
&gt;<br>
&gt; Thanks for the answer, it&#39;s great, and I apologize for the terrible format.<br>
&gt;<br>
&gt; &gt;You can&#39;t, directly. If you have enough contiguous free space in the<br>
&gt; &gt;AG that you are allocating in, then you will get contiguous files if<br>
&gt; &gt;the allocation size lines up with the filesystem geometry:<br>
&gt; &gt;<br>
&gt; &gt;$ for i in `seq 1 10` ; do sudo xfs_io -f -c &quot;truncate 512m&quot; -c &quot;resvsp 0<br>
&gt; 512m&quot; foo.$i ; done<br>
&gt; &gt;$ sudo xfs_bmap -vp foo.[1-9] foo.10 |grep &quot; 0:&quot;<br>
&gt; &gt; EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS<br>
&gt; &gt; sudo xfs_bmap -vp foo.[1-9] foo.10 |grep &quot; 0:&quot;<br>
&gt; &gt;   0: [0..1048575]:    8096..1056671     0 (8096..1056671)  1048576 10000<br>
&gt; &gt;   0: [0..1048575]:    1056672..2105247  0 (1056672..2105247) 1048576 10000<br>
&gt; &gt;   0: [0..1048575]:    2105248..3153823  0 (2105248..3153823) 1048576 10000<br>
&gt; &gt;   0: [0..1048575]:    3153824..4202399  0 (3153824..4202399) 1048576 10000<br>
&gt; &gt;   0: [0..1048575]:    4202400..5250975  0 (4202400..5250975) 1048576 10000<br>
&gt; &gt;   0: [0..1048575]:    5250976..6299551  0 (5250976..6299551) 1048576 10000<br>
&gt; &gt;   0: [0..1048575]:    6299552..7348127  0 (6299552..7348127) 1048576 10000<br>
&gt; &gt;   0: [0..1048575]:    7348128..8396703  0 (7348128..8396703) 1048576 10000<br>
&gt; &gt;   0: [0..1048575]:    8396704..9445279  0 (8396704..9445279) 1048576 10000<br>
&gt; &gt;   0: [0..1048575]:    9445280..10493855  0 (9445280..10493855) 1048576<br>
&gt; 10000<br>
&gt; &gt;<br>
&gt; &gt;So all those files are contiguous both internally and externally. If<br>
&gt; &gt;there isn&#39;t sufficient contiguous freespace, or there is allocator<br>
&gt; &gt;contention, this won&#39;t happen - it&#39;s best effort behaviour....<br>
&gt;<br>
&gt; I believe you got these in a single AG, but I do the allocation in<br>
&gt; filesystem<br>
&gt; with multi-AGs, specifically, it is a 6T storage space, and I run the<br>
&gt; mkfs.xfs<br>
&gt; without setting the AG number/size, it ends up with 32 AGs.<br>
&gt; My files layout:<br>
&gt;     - 0                         - dir<br>
&gt;     | - 0                       - dir<br>
&gt;     | | - 1                     - file<br>
&gt;     | | - 2                     - file<br>
&gt;     | | - 3                     - file<br>
&gt;     | | - 4                     - file<br>
&gt;     | | - 5                     - file<br>
&gt;     | | - ...                   - file<br>
&gt;     | | - 128                   - file<br>
&gt;     | - 1                       - dir<br>
&gt;     | | - 1                     - file<br>
&gt;     | | - 2                     - file<br>
&gt;     | | - 3                     - file<br>
&gt;     | | - 4                     - file<br>
&gt;     | | - 5                     - file<br>
&gt;     | | - ...                   - file<br>
&gt;     | | - 128                   - file<br>
&gt;     | - ...                     - dir<br>
&gt; Every file is 512MB, every directory holds 512MB*128=64GB.<br>
<br>
</div></div>Yup, that&#39;s exactly by design. That&#39;s how the inode64 allocation<br>
policy is supposed to work.<br>
<div class="im"><br>
&gt; According to your advice and XFS document, I tried to set the AG size to<br>
&gt; 64GB,<br>
<br>
</div>What advice might that be? I don&#39;t thikn I&#39;ve ever recommended<br>
anyone use 96*64GB AGs. Unless you have 96 allocations all occurring<br>
at the same time (very rare, in my experience), there is no need for<br>
some many AGs.<br>
<div><div class="h5"><br>
<br>
&gt; for avoiding the allocator contention and keeping all files in single<br>
&gt; directory<br>
&gt; fall in the same AG, but it didn&#39;t work. The files are still in different<br>
&gt; AGs.<br>
&gt; My xfs_info:<br>
&gt; meta-data=/dev/sdc2              isize=256    agcount=96, agsize=16777216<br>
&gt; blks<br>
&gt;          =                       sectsz=512   attr=0<br>
&gt; data     =                       bsize=4096   blocks=1610116329, imaxpct=25<br>
&gt;          =                       sunit=0      swidth=0 blks, unwritten=1<br>
&gt; naming   =version 2              bsize=4096<br>
&gt; log      =internal log           bsize=4096   blocks=32768, version=1<br>
&gt;          =                       sectsz=512   sunit=0 blks, lazy-count=0<br>
&gt; realtime =none                   extsz=4096   blocks=0, rtextents=0<br>
&gt;<br>
&gt; The files:<br>
&gt; $ for i in `seq 1 10` ; do sudo xfs_io -f -c &quot;truncate 512m&quot; -c &quot;resvsp 0<br>
&gt; 512m&quot; foo.$i ; done<br>
&gt; $ sudo xfs_bmap -vp *| grep &quot; 0:&quot;<br>
&gt;    0: [0..1048575]:    2147483712..2148532287 16 (64..1048639)    1048576<br>
&gt; 10000<br>
&gt;    0: [0..1048575]:    3355443264..3356491839 25 (64..1048639)    1048576<br>
&gt; 10000<br>
&gt;    0: [0..1048575]:    2281701440..2282750015 17 (64..1048639)    1048576<br>
&gt; 10000<br>
&gt;    0: [0..1048575]:    2415919168..2416967743 18 (64..1048639)    1048576<br>
&gt; 10000<br>
&gt;    0: [0..1048575]:    2550136896..2551185471 19 (64..1048639)    1048576<br>
&gt; 10000<br>
&gt;    0: [0..1048575]:    2684354624..2685403199 20 (64..1048639)    1048576<br>
&gt; 10000<br>
&gt;    0: [0..1048575]:    2818572352..2819620927 21 (64..1048639)    1048576<br>
&gt; 10000<br>
&gt;    0: [0..1048575]:    2952790080..2953838655 22 (64..1048639)    1048576<br>
&gt; 10000<br>
&gt;    0: [0..1048575]:    3087007808..3088056383 23 (64..1048639)    1048576<br>
&gt; 10000<br>
&gt;    0: [0..1048575]:    3221225536..3222274111 24 (64..1048639)    1048576<br>
&gt; 10000<br>
<br>
</div></div>That&#39;s inode32 allocator behaviour (rotoring each new allocation<br>
across a different AG). Mount with inode64 - it&#39;s the default in the<br>
latest kernels - and it will behave as I demonstrated.<br>
<div class=""><div class="h5"><br>
Cheers,<br>
<br>
Dave.<br>
<br>
--<br>
Dave Chinner<br>
<a href="mailto:david@fromorbit.com">david@fromorbit.com</a><br>
</div></div></blockquote></div><br></div></div>