跳转到主内容

什么是目录大小?

Views:
116
Visibility:
Public
Votes:
0
Category:
ontap-9
Specialty:
core
Last Updated:

适用场景

  • ONTAP
  • 目录

问题解答

注意:此上下文中的"目录大小"短语不适用于给定目录中所有文件的内容所使用的总磁盘空间。  

要了解目录大小、我们首先需要了解目录的实际含义。在Unix类型的操作系统中、通常有三种主要类型的文件: 

  • 常规文件
  • 特殊文件
  • 目录文件

常规文件包含用户和应用程序创建的数据。有关特殊文件、请参见 Linux/Unix中的文件类型详细说明。  本文讨论目录文件。

什么是目录文件?

文件系统会跟踪每个文件的名称、位置和其他元数据。如果此元数据仅位于索引节点或文件本身中、则从磁盘读取文件需要极长的时间。为了缓解此性能问题、文件名和其他所需元数据会保留在一个名为目录文件的文件中。

注意: 有关文件的某些文件元数据内容的示例、请参见下面的追加信息 ?什么是索引节点?

目录文件的某些内容包括:

  • 文件名
  • DOS 8.3名称(如果使用CIFS创建)
  • 索引节点编号 
如何查找目录文件的大小

在单个目录中的文件数量较多的环境中、目录文件的大小变得非常重要。  现代文件系统允许在一个目录中使用较长的文件名和大量的文件。  文件名的长度以及单个目录中的文件数都会影响目录文件大小。

要查看目录文件大小、请从客户端使用以下命令: 

$ ls -l
-rwxr-xr-x  1 user group    98404 Nov  8  2021 application.png    
drwxr-xr-x  3 user group    4096 Apr 13  2022 backup
-rw-rw-r--  1 user group   2221823 Aug 30  2021 ems.log.0000000009.txt  
-rwxr-xr-x  1 user group   1174298 Feb 12  2020 putty.log
drwxrwxr-x  4 user group    12288 Sep 17  2021 logs

  • 此输出中的第五列显示了每个文件所使用的空间。
  • 突出显示的条目是目录文件的大小(以字节为单位)。
  • 新创建的目录的默认大小为4096字节。
目录文件的大容量是什么? 

在ONTAP 中、如果目录文件大小为2MiB或更大、则会视为较大、以便进行搜索。此大小及更大的目录文件会自动编制索引、以提高搜索性能。

追加信息

$ stat file.dat
  File: file.dat
  Size: 419430400     Blocks: 822432    IO Block: 65536  regular file  
Device: 3bh/59d Inode: 99629125   Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1010/user)   Gid: (   80/   grp)
Context: system_u:object_r:nfs_t:s0
Access: 2017-01-16 04:54:15.115626000 -0800
Modify: 2013-01-09 02:48:00.000000000 -0800
Change: 2017-01-16 04:54:15.116631000 -0800
 Birth: -

  • 目录文件元数据示例

  $ stat fspopulate
  File: fspopulate
  Size: 4096       Blocks: 8      IO Block: 32768  directory    
Device: 3bh/59d Inode: 89991994   Links: 4
Access: (2755/drwxr-sr-x)  Uid: ( 1010/user)   Gid: (   80/   grp)
Context: system_u:object_r:nfs_t:s0
Access: 2022-05-30 03:45:53.110149000 -0700
Modify: 2017-01-16 04:54:15.538648000 -0800
Change: 2017-01-16 04:54:15.538648000 -0800
 Birth: -

 

NetApp provides no representations or warranties regarding the accuracy or reliability or serviceability of any information or recommendations provided in this publication or with respect to any results that may be obtained by the use of the information or observance of any recommendations provided herein. The information in this document is distributed AS IS and the use of this information or the implementation of any recommendations or techniques herein is a customer's responsibility and depends on the customer's ability to evaluate and integrate them into the customer's operational environment. This document and the information contained herein may be used solely in connection with the NetApp products discussed in this document.