Hi, folks,<div><br></div><div><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;word-wrap:break-word;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">
I'm using <em style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">CentOS5.8</em>, with <em style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">XFS</em> filesystem extend storage disks. What I want to do is, pre-allocating many files, with continuous blocks in filesystem, both single file and crossing files. That is the start block ID of the next file is following the end block ID of current file.</p>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;word-wrap:break-word;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">
I could do space pre-allocation by <strong style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">posix_allocate()</strong>, problem is the API zeros all disk space, I can't afford time consuming(I'm not sure if this API could make the blocks continuous). then I tried <a href="http://linux.die.net/man/3/xfsctl" rel="nofollow" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(74,107,130);text-decoration:none"><strong style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">xfsctl()</strong></a>, with <strong style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">XFS_IOC_RESVSP</strong> flag, I can reserve space faster.</p>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;word-wrap:break-word;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">
The problem with <strong style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">xfsctl()</strong> is, it could make the blocks continuous for individual file, but the blocks over files are <em style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">not</em> continuous. For example, 10 files, a/b/c/d/e/f... reserved. After I do the real writing to these files, it turns out the file 'b' isn't next to file 'a', and some file could be far from both previous one and next one, though other files may be neighboring with each other, rarely.</p>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;word-wrap:break-word;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">
I use the following code to do the pre-allocation:</p><pre style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;color:rgb(0,0,0);line-height:18px">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif">ftruncate(fd, FILE_SIZE);
xfs_flock_t flag = {0};
flag.l_whence = SEEK_SET;
flag.l_start = 0;
flag.l_len = 512*1024*1024;
xfsctl(fileName, fd, XFS_IOC_RESVSP64, &flag);
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;word-wrap:break-word;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">
My question is, how can I guarantee the file system blocks over files continuous? Thanks for your time and appreciate your answer.</p></div>