<div dir="ltr">As I said that wasn't the limit I was hitting. Here is the program that I wrote:<div><br></div><div><div>#include <stdint.h></div><div>#include <errno.h></div><div>#include <stdio.h></div><div>#include <sys/types.h></div><div>#include <sys/stat.h></div><div>#include <fcntl.h></div><div>#include <unistd.h></div><div>#include <string.h></div><div><br></div><div>int main() {</div><div>  for (uint64_t i = 0;; ++i) {</div><div>    char buf[256];</div><div>    snprintf(buf, 256, "d/%032lx", i);</div><div>    if (i % 65536 == 0)</div><div>      puts(buf);</div><div>    int fd = open(buf, O_CREAT);</div><div>    if (fd == -1) {</div><div>      printf("open: %s\n", strerror(errno));</div><div>      return 1;</div><div>    }</div><div>    close(fd);</div><div>  }</div><div>}</div></div><div><br></div><div>The output ends in:</div><div><br></div><div><div>d/00000000000000000000000000980000</div><div>d/00000000000000000000000000990000</div><div>d/000000000000000000000000009a0000</div><div>d/000000000000000000000000009b0000</div><div>d/000000000000000000000000009c0000</div><div>d/000000000000000000000000009d0000</div><div>d/000000000000000000000000009e0000</div><div>d/000000000000000000000000009f0000</div><div>open: No space left on device</div></div><div><br></div><div>df:</div><div><div>Filesystem                                              1K-blocks      Used Available Use% Mounted on</div><div>[redacted] 856678580 780069796  33068920  96% [redacted]</div></div><div><br></div><div>df -i:</div><div><div>Filesystem                                                Inodes    IUsed    IFree IUse% Mounted on</div><div>[redacted] 54411264 18824333 35586931   35% [redacted]</div></div><div><br></div><div>Peter</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 10, 2018 at 1:40 PM, Fangrui Song <span dir="ltr"><<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
su<br>
truncate -s 100G 100G<br>
mkfs.ext4 100G<br>
mkdir ext4<br>
mount 100G ext4<br>
cd ext4<br>
<br>
mkdir p<br>
cd p<br>
python3 -c 'for i in range(6600000):\n with open(str(i),"w"): pass'<br>
<br>
<br>
It runs out of inodes with some message like:<br>
<br>
OSError: [Errno 28] No space left on device: '6553587'<br>
<br>
<br>
umount ext4; dumpe2fs 100G # says the inodes are used up<br>
...<br>
Free inodes:              0<br>
...<div class="HOEnZb"><div class="h5"><br>
<br>
On 2018-04-10, Peter Collingbourne wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
No, these were empty files. It wasn't an inode limit because I could still<br>
create files in other directories.<br>
<br>
Peter<br>
<br>
On Tue, Apr 10, 2018 at 10:35 AM, Fangrui Song <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> wrote:<br>
<br>
   On 2018-04-09, Peter Collingbourne wrote:<br>
<br>
       Are you sure about that? I'm pretty sure that before writing that<br>
       comment I<br>
       wrote a small program that created lots of files (not subdirectories)<br>
       in a<br>
       directory until it started getting error messages, which started<br>
       happening at<br>
       around 6000000 files.<br>
<br>
       Peter<br>
<br>
   I guess you created a file of 100GiB. The number of inodes is roughly<br>
   6553600.<br>
<br>
   100*1024*1024*1024 / 16384 = 6553600.0 where 16384 is the default<br>
   bytes-per-inode (man mke2fs).<br>
<br>
   % truncate -s 100G 100G<br>
   % mkfs.ext4 100G<br>
   % dumpe2fs 100G<br>
   .....<br>
   Inode count:              6553600<br>
   .....<br>
<br>
   Each file consumes one inode and the number of files in that directory<br>
   is limited by this factor.<br>
<br>
       On Mon, Apr 9, 2018 at 5:12 PM, Fangrui Song via llvm-commits <<br>
       <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
<br>
          Author: maskray<br>
          Date: Mon Apr  9 17:12:28 2018<br>
          New Revision: 329648<br>
<br>
          URL: <a href="http://llvm.org/viewvc/llvm-project?rev=329648&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=329648&view=rev</a><br>
          Log:<br>
          [CachePruning] Fix comment about ext4 per-directory file limit. NFC<br>
<br>
          There is a limit on number of subdirectories if dir_nlinks is not<br>
          enabled (31998), but per-directory number of files is not limited.<br>
<br>
          Modified:<br>
              llvm/trunk/include/llvm/Suppor<wbr>t/CachePruning.h<br>
<br>
          Modified: llvm/trunk/include/llvm/Suppor<wbr>t/CachePruning.h<br>
          URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/include/llvm/</a><br>
       Support/<br>
          CachePruning.h?rev=329648&r1=<wbr>329647&r2=329648&view=diff<br>
          =============================<wbr>==============================<wbr>=========<br>
       =======<br>
          ===<br>
          --- llvm/trunk/include/llvm/Suppor<wbr>t/CachePruning.h (original)<br>
          +++ llvm/trunk/include/llvm/Suppor<wbr>t/CachePruning.h Mon Apr  9<br>
       17:12:28 2018<br>
          @@ -52,9 +52,8 @@ struct CachePruningPolicy {<br>
             /// the number of files based pruning.<br>
             ///<br>
             /// This defaults to 1000000 because with that many files there<br>
       are<br>
          -  /// diminishing returns on the effectiveness of the cache, and<br>
       some file<br>
          -  /// systems have a limit on how many files can be contained in a<br>
          directory<br>
          -  /// (notably ext4, which is limited to around 6000000 files).<br>
          +  /// diminishing returns on the effectiveness of the cache, and<br>
       file<br>
          +  /// systems have a limit on total number of files.<br>
             uint64_t MaxSizeFiles = 1000000;<br>
           };<br>
<br>
          _____________________________<wbr>__________________<br>
          llvm-commits mailing list<br>
          <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
          <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin<wbr>/mailman/listinfo/llvm-commits</a><br>
<br>
       --<br>
       -- <br>
       Peter<br>
<br>
   --<br>
   宋方睿<br>
<br>
--<br>
-- <br>
Peter<br>
</blockquote>
<br></div></div><span class="HOEnZb"><font color="#888888">
-- <br>
宋方睿<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div>