xfs-documentation: massive cleanups and add v5 format, reverse-mapping, reflink, and dedupe support
cover xfs-documentation: massive cleanups and add v5 format, reverse-mapping, reflink, and dedupe support
Hi all,
This is part of the third revision of an RFC for adding support to XFS for tracking reverse-mappings of physical blocks to file and metadata; and support for mapping multiple file logical blocks to the same physical block, more commonly known as reflinking. This is the first time I've posted patches against the documentation, but they fit with the pending RFCv3 code patches, so they're now a part of the full suite.
This patch set does the following:
* Cleans up leftover artifacts of the XML -> asciidoc conversion.
* Fixes the formatting of quoted text and structure field definitions.
* Fixes a lot of the strange wording in the existing documentation.
* Replaces the screen dump PNGs with (much smaller) text sections. There's a huge 1.2MB patch to remove the image files as well, but I'll probably just send that privately to Dave later on.
* Fills in the missing xfs_db examples and structure field definitions.
* Fills in the missing realtime and journal sections.
* Covers the new header formats for v5 filesystems.
* Adds a magic number index.
* Adds a brief overview of what is XFS, prior to jumping into the disk format.
* Covers sparse inodes, reverse mapping btrees, reference count btrees and reflink.
* Switches the xattr and directory chapters since the directory chapter introduces the btrees that xattrs can use.
The patch set is based on the current master branch. As specified eleswhere, I have git trees for the kernel[1], xfsprogs[2], xfstests[3], and xfs-docs[4]. Comments and questions are, as always, welcome.
--D
[1] https://github.com/djwong/linux/tree/for-dave
[2] https://github.com/djwong/xfsprogs/tree/for-dave
[3] https://github.com/djwong/xfstests/tree/for-dave
[4] https://github.com/djwong/xfs-documentation/tree/for-dave
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/21 xfsdocs: fix asciidoc confusion w.r.t. include file newline at EOF
Space each include one line apart so that asciidoc knows that each section has ended at included file's EOF. This prevents it from spewing horribly confused XML that blows up xmllint if each included file doesn't itself end with a blank line.
--- .../xfs_filesystem_structure.asciidoc | 10 ++++++++++ 1 file changed, 10 insertions(+)
design/XFS_Filesystem_Structure/xfs_filesystem_structure.asciidoc +10 -0
@@ -36,18 +36,28 @@ Global Structures ================= :leveloffset: 1 + include::allocation_groups.asciidoc[] + include::journaling_log.asciidoc[] + include::internal_inodes.asciidoc[] + :leveloffset: 0 Dynamically Allocated Structures ================================ :leveloffset: 1 + include::ondisk_inode.asciidoc[] + include::data_extents.asciidoc[] + include::extended_attributes.asciidoc[] + include::directories.asciidoc[] + include::symbolic_links.asciidoc[] + :leveloffset: 0
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/21 xfsdocs: update book subtitles and headings
In reply to Darrick J. WongThe current subtitle is redundant and since this is the third edition (the second ed. came out in 2006) we might as well note that. Update some of the headings to make it clear that we're talking about disk format and not much else.
--- design/XFS_Filesystem_Structure/docinfo.xml | 2 +- .../xfs_filesystem_structure.asciidoc | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
design/XFS_Filesystem_Structure/docinfo.xml +1 -1
@@ -1,4 +1,4 @@ -<subtitle>Documentation of the XFS filesystem on-disk structures</subtitle> +<subtitle>3rd Edition</subtitle> <abstract> <para>This book documents the XFS Filesystem Structure</para> </abstract>
design/XFS_Filesystem_Structure/xfs_filesystem_structure.asciidoc +4 -4
@@ -6,13 +6,13 @@ // and we really need an area to set up various docbook sections like copyright // and legal notice sections. // -XFS Filesystem Structure -======================== +XFS Filesystem Disk Structures +============================== :doctype: book :docinfo1: -Introduction -============ +High Level Design +================= [partintro] --
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 3/21 xfsdocs: restore the old rendering of structure field definitions
In reply to Darrick J. WongRestore the rendering of the on-disk struct fields to resemble that of the old SGI book, with bold field names on one line and the description indented below. This is a lot more readable than letting the whole field and description run together as one long line.
--- .../allocation_groups.asciidoc | 136 ++++++++++---------- .../XFS_Filesystem_Structure/common_types.asciidoc | 28 ++-- .../internal_inodes.asciidoc | 38 +++--- .../XFS_Filesystem_Structure/ondisk_inode.asciidoc | 50 ++++--- 4 files changed, 126 insertions(+), 126 deletions(-)
design/XFS_Filesystem_Structure/allocation_groups.asciidoc +68 -68
@@ -92,59 +92,59 @@ struct xfs_sb __uint32_t sb_features2; }; ---- -.sb_magicnum +*sb_magicnum*:: Identifies the filesystem. It's value is +XFS_SB_MAGIC = 0x58465342 "XFSB"+. -.sb_blocksize +*sb_blocksize*:: The size of a basic unit of space allocation in bytes. Typically, this is 4096 (4KB) but can range from 512 to 65536 bytes. -.sb_dblocks +*sb_dblocks*:: Total number of blocks available for data and metadata on the filesystem. -.sb_rblocks +*sb_rblocks*:: Number blocks in the real-time disk device. Refer to xref:Real-time_Devices[real-time sub-volumes] for more information. -.sb_rextents +*sb_rextents*:: Number of extents on the real-time device. -.sb_uuid +*sb_uuid*:: UUID (Universally Unique ID) for the filesystem. Filesystems can be mounted by the UUID instead of device name. -.sb_logstart +*sb_logstart*:: First block number for the journaling log if the log is internal (ie. not on a separate disk device). For an external log device, this will be zero (the log will also start on the first block on the log device). -.sb_rootino +*sb_rootino*:: Root inode number for the filesystem. Typically, this is 128 when using a 4KB block size. -.sb_rbmino +*sb_rbmino*:: Bitmap inode for real-time extents. -.sb_rsumino +*sb_rsumino*:: Summary inode for real-time bitmap. -.sb_rextsize +*sb_rextsize*:: Realtime extent size in blocks. -.sb_agblocks +*sb_agblocks*:: Size of each AG in blocks. For the actual size of the last AG, refer to the xref:AG_Free_Space_Management[free space] +agf_length+ value. -.sb_agcount +*sb_agcount*:: Number of AGs in the filesystem. -.sb_rbmblocks +*sb_rbmblocks*:: Number of real-time bitmap blocks. -.sb_logblocks +*sb_logblocks*:: Number of blocks for the journaling log. -.sb_versionnum +*sb_versionnum*:: Filesystem version number. This is a bitmask specifying the features enabled when creating the filesystem. Any disk checking tools or drivers that do not recognize any set bits must not operate upon the filesystem. Most of the flagsi
@@ -174,72 +174,72 @@ Version 2 directories are used. This is always set. Set if the sb_features2 field in the superblock contains more flags. |===== -.sb_sectsize +*sb_sectsize*:: Specifies the underlying disk sector size in bytes. Majority of the time, this is 512 bytes. This determines the minimum I/O alignment including Direct I/O. -.sb_inodesize +*sb_inodesize*:: Size of the inode in bytes. The default is 256 (2 inodes per standard sector) but can be made as large as 2048 bytes when creating the filesystem. -.sb_inopblock +*sb_inopblock*:: Number of inodes per block. This is equivalent to +sb_blocksize / sb_inodesize+. -.sb_fname[12] +*sb_fname[12]*:: Name for the filesystem. This value can be used in the mount command. -.sb_blocklog +*sb_blocklog*:: log~2~ value of +sb_blocksize+. In other terms, +sb_blocksize = 2^sb_blocklog^+. -.sb_sectlog +*sb_sectlog*:: log~2~ value of +sb_sectsize+. -.sb_inodelog +*sb_inodelog*:: log~2~ value of +sb_inodesize+. -.sb_inopblog +*sb_inopblog*:: log~2~ value of +sb_inopblock+. -.sb_agblklog +*sb_agblklog*:: log~2~ value of +sb_agblocks+ (rounded up). This value is used to generate inode numbers and absolute block numbers defined in extent maps. -.sb_rextslog +*sb_rextslog*:: log~2~ value of +sb_rextents+. -.sb_inprogress +*sb_inprogress*:: Flag specifying that the filesystem is being created. -.sb_imax_pct +*sb_imax_pct*:: Maximum percentage of filesystem space that can be used for inodes. The default value is 5%. -.sb_icount +*sb_icount*:: Global count for number inodes allocated on the filesystem. This is only maintained in the first superblock. -.sb_ifree +*sb_ifree*:: Global count of free inodes on the filesystem. This is only maintained in the first superblock. -.sb_fdblocks +*sb_fdblocks*:: Global count of free data blocks on the filesystem. This is only maintained in the first superblock. -.sb_frextents +*sb_frextents*:: Global count of free real-time extents on the filesystem. This is only maintained in the first superblock. -.sb_uquotino +*sb_uquotino*:: Inode for user quotas. This and the following two quota fields only apply if +XFS_SB_VERSION_QUOTABIT+ flag is set in +sb_versionnum+. Refer to xref:Quota_Inodes[quota inodes] for more information -.sb_gquotino +*sb_gquotino*:: Inode for group or project quotas. Group and Project quotas cannot be used at the same time. -.sb_qflags +*sb_qflags*:: Quota flags. It can be a combination of the following flags: .Superblock quota flags
@@ -255,37 +255,37 @@ Quota flags. It can be a combination of the following flags: | +XFS_GQUOTA_ACCT+ | Group quota accounting is enabled. |===== -.sb_flags +*sb_flags*:: Miscellaneous flags. -.sb_shared_vn +*sb_shared_vn*:: Reserved and must be zero ("vn" stands for version number). -.sb_inoalignmt +*sb_inoalignmt*:: Inode chunk alignment in fsblocks. -.sb_unit +*sb_unit*:: Underlying stripe or raid unit in blocks. -.sb_width +*sb_width*:: Underlying stripe or raid width in blocks. -.sb_dirblklog +*sb_dirblklog*:: log~2~ multiplier that determines the granularity of directory block allocations in fsblocks. -.sb_logsectlog +*sb_logsectlog*:: log~2~ value of the log subvolume's sector size. This is only used if the journaling log is on a separate disk device (i.e. not internal). -.sb_logsectsize +*sb_logsectsize*:: The log's sector size in bytes if the filesystem uses an external log device. -.sb_logsunit +*sb_logsunit*:: The log device's stripe or raid unit size. This only applies to version 2 logs +XFS_SB_VERSION_LOGV2BIT+ is set in +sb_versionnum+. -.sb_features2 +*sb_features2*:: Additional version flags if +XFS_SB_VERSION_MOREBITSBIT+ is set in +sb_versionnum+. The currently defined additional features include:
@@ -417,45 +417,45 @@ struct xfs_agf { The rest of the bytes in the sector are zeroed. +XFS_BTNUM_AGF+ is set to 2, index 0 for the count B+tree and index 1 for the size B+tree. -.agf_magicnum +*agf_magicnum*:: Specifies the magic number for the AGF sector: "XAGF" (0x58414746). -.agf_versionnum +*agf_versionnum*:: Set to +XFS_AGF_VERSION+ which is currently 1. -.agf_seqno +*agf_seqno*:: Specifies the AG number for the sector. -.agf_length +*agf_length*:: Specifies the size of the AG in filesystem blocks. For all AGs except the last, This must be equal to the superblock's +sb_agblocks+ value. For the last AG, this could be less than the +sb_agblocks+ value. It is this value that should be used to determine the size of the AG. -.agf_roots +*agf_roots*:: Specifies the block number for the root of the two free space B+trees. -.agf_levels +*agf_levels*:: Specifies the level or depth of the two free space B+trees. For a fresh AG, this will be one, and the "roots" will point to a single leaf of level 0. -.agf_flfirst +*agf_flfirst*:: Specifies the index of the first "free list" block. Free lists are covered in more detail later on. -.agf_fllast +*agf_fllast*:: Specifies the index of the last "free list" block. -.agf_flcount +*agf_flcount*:: Specifies the number of blocks in the "free list". -.agf_freeblks +*agf_freeblks*:: Specifies the current number of free blocks in the AG. -.agf_longest +*agf_longest*:: Specifies the number of blocks of longest contiguous free space in the AG. -.agf_btreeblks +*agf_btreeblks*:: Specifies the number of blocks used for the free space B+trees. This is only used if the +XFS_SB_VERSION2_LAZYSBCOUNTBIT+ bit is set in +sb_features2+.
@@ -688,37 +688,37 @@ struct xfs_agi { __be32 agi_unlinked[64]; } ---- -.agi_magicnum +*agi_magicnum*:: Specifies the magic number for the AGI sector: "XAGI" (0x58414749). -.agi_versionnum +*agi_versionnum*:: Set to +XFS_AGI_VERSION+ which is currently 1. -.agi_seqno +*agi_seqno*:: Specifies the AG number for the sector. -.agi_length +*agi_length*:: Specifies the size of the AG in filesystem blocks. -.agi_count +*agi_count*:: Specifies the number of inodes allocated for the AG. -.agi_root +*agi_root*:: Specifies the block number in the AG containing the root of the inode B+tree. -.agi_level +*agi_level*:: Specifies the number of levels in the inode B+tree. -.agi_freecount +*agi_freecount*:: Specifies the number of free inodes in the AG. -.agi_newino +*agi_newino*:: Specifies AG relative inode number most recently allocated. -.agi_dirino +*agi_dirino*:: Deprecated and not used, it's always set to NULL (-1). -.agi_unlinked[64] +*agi_unlinked[64]*:: Hash table of unlinked (deleted) inodes that are still being referenced. Refer to xref:Unlinked_Pointer[unlinked list pointers] for more information.
design/XFS_Filesystem_Structure/common_types.asciidoc +14 -14
@@ -3,47 +3,47 @@ All the following XFS types can be found in xfs_types.h. NULL values are always -1 on disk (ie. all bits for the value set to one). -.xfs_ino_t +*xfs_ino_t*:: Unsigned 64 bit absolute xref:Inode_Numbers[inode number]. -.xfs_off_t +*xfs_off_t*:: Signed 64 bit file offset. -.xfs_daddr_t +*xfs_daddr_t*:: Signed 64 bit disk address. -.xfs_agnumber_t +*xfs_agnumber_t*:: Unsigned 32 bit xref:Allocation_Groups[AG number]. -.xfs_agblock_t +*xfs_agblock_t*:: Unsigned 32 bit AG relative block number. -.xfs_extlen_t +*xfs_extlen_t*:: Unsigned 32 bit xref:Data_Extents[extent] length in blocks. -.xfs_extnum_t +*xfs_extnum_t*:: Signed 32 bit number of extents in a file. -.xfs_dablk_t +*xfs_dablk_t*:: Unsigned 32 bit block number for xref:Directories[directories] and xref:Extended_Attributes[extended attributes]. -.xfs_dahash_t +*xfs_dahash_t*:: Unsigned 32 bit hash of a directory file name or extended attribute name. -.xfs_dfsbno_t +*xfs_dfsbno_t*:: Unsigned 64 bit filesystem block number combining xref:Allocation_Groups[AG number] and block offset into the AG. -.xfs_drfsbno_t +*xfs_drfsbno_t*:: Unsigned 64 bit raw filesystem block number. -.xfs_drtbno_t +*xfs_drtbno_t*:: Unsigned 64 bit extent number in the xref:Real-time_Devices[real-time] sub-volume. -.xfs_dfiloff_t +*xfs_dfiloff_t*:: Unsigned 64 bit block offset into a file. -.xfs_dfilblks_t +*xfs_dfilblks_t*:: Unsigned 64 bit block count for a file.
design/XFS_Filesystem_Structure/internal_inodes.asciidoc +19 -19
@@ -62,14 +62,14 @@ struct xfs_dqblk { }; ---- -.d_magic +*d_magic*:: Specifies the signature where these two bytes are 0x4451 (+XFS_DQUOT_MAGIC+), or "DQ" in ASCII. -.d_version +*d_version*:: Specifies the structure version, currently this is one (+XFS_DQUOT_VERSION+). -.d_flags +*d_flags*:: Specifies which type of ID the structure applies to: [source, c]
@@ -79,71 +79,71 @@ Specifies which type of ID the structure applies to: #define XFS_DQ_GROUP 0x0004 ---- -.d_id</term> +*d_id*:: The ID for the quota structure. This will be a uid, gid or projid based on the value of +d_flags+. -.d_blk_hardlimit +*d_blk_hardlimit*:: Specifies the hard limit for the number of filesystem blocks the ID can own. The ID will not be able to use more space than this limit. If it is attempted, +ENOSPC+ will be returned. -.d_blk_softlimit +*d_blk_softlimit*:: Specifies the soft limit for the number of filesystem blocks the ID can own. The ID can temporarily use more space than by +d_blk_softlimit+ up to +d_blk_hardlimit+. If the space is not freed by the time limit specified by ID zero's +d_btimer+ value, the ID will be denied more space until the total blocks owned goes below +d_blk_softlimit+. -.d_ino_hardlimit +*d_ino_hardlimit*:: Specifies the hard limit for the number of inodes the ID can own. The ID will not be able to create or own any more inodes if +d_icount+ reaches this value. -.d_ino_softlimit +*d_ino_softlimit*:: Specifies the soft limit for the number of inodes the ID can own. The ID can temporarily create or own more inodes than specified by d_ino_softlimit up to d_ino_hardlimit. If the inode count is not reduced by the time limit specified by ID zero's d_itimer value, the ID will be denied from creating or owning more inodes until the count goes below d_ino_softlimit. -.d_bcount +*d_bcount*:: Specifies how many filesystem blocks are actually owned by the ID. -.d_icount +*d_icount*:: Specifies how many inodes are actually owned by the ID. -.d_itimer +*d_itimer*:: Specifies the time when the ID's +d_icount+ exceeded +d_ino_softlimit+. The soft limit will turn into a hard limit after the elapsed time exceeds ID zero's +d_itimer+ value. When d_icount goes back below +d_ino_softlimit+, +d_itimer+ is reset back to zero. -.d_btimer +*d_btimer*:: Specifies the time when the ID's +d_bcount+ exceeded +d_blk_softlimit+. The soft limit will turn into a hard limit after the elapsed time exceeds ID zero's +d_btimer+ value. When d_bcount goes back below +d_blk_softlimit+, +d_btimer+ is reset back to zero. -.d_iwarns -.d_bwarns -.d_rtbwarns +*d_iwarns*:: +*d_bwarns*:: +*d_rtbwarns*:: Specifies how many times a warning has been issued. Currently not used. -.d_rtb_hardlimit +*d_rtb_hardlimit*:: Specifies the hard limit for the number of real-time blocks the ID can own. The ID cannot own more space on the real-time subvolume beyond this limit. -.d_rtb_softlimit +*d_rtb_softlimit*:: Specifies the soft limit for the number of real-time blocks the ID can own. The ID can temporarily own more space than specified by +d_rtb_softlimit+ up to +d_rtb_hardlimit+. If +d_rtbcount+ is not reduced by the time limit specified by ID zero's +d_rtbtimer value+, the ID will be denied from owning more space until the count goes below +d_rtb_softlimit+. -.d_rtbcount +*d_rtbcount*:: Specifies how many real-time blocks are currently owned by the ID. -.d_rtbtimer +*d_rtbtimer*:: Specifies the time when the ID's +d_rtbcount+ exceeded +d_rtb_softlimit+. The soft limit will turn into a hard limit after the elapsed time exceeds ID zero's +d_rtbtimer+ value. When +d_rtbcount+ goes back below +d_rtb_softlimit+,
design/XFS_Filesystem_Structure/ondisk_inode.asciidoc +25 -25
142 lines not on this page · raw message
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 4/21 xfsdocs: convert html entities to regular characters
In reply to Darrick J. WongConvert HTML entities back to regular characters, since this is now ASCII.
--- .../XFS_Filesystem_Structure/directories.asciidoc | 20 ++++++++++---------- .../extended_attributes.asciidoc | 14 +++++++------- 2 files changed, 17 insertions(+), 17 deletions(-)
design/XFS_Filesystem_Structure/directories.asciidoc +10 -10
@@ -321,8 +321,8 @@ blocksize = 4096 ... dirblklog = 0 ... -xfs_db> inode <inode#> -xfs_db> p +xfs_db> inode <inode#> +xfs_db> p core.magic = 0x494e core.mode = 040755 core.version = 1
@@ -694,9 +694,9 @@ And the last data block: ---- -xfs_db> dblock 2 -xfs_db> type dir2 -xfs_db> p +xfs_db> dblock 2 +xfs_db> type dir2 +xfs_db> p dhdr.magic = 0x58443244 dhdr.bestfree[0].offset = 0x70 dhdr.bestfree[0].length = 0xf90
@@ -892,8 +892,8 @@ blocksize = 4096 ... dirblklog = 2 ... -xfs_db> inode <inode#> -xfs_db> p +xfs_db> inode <inode#> +xfs_db> p core.magic = 0x494e core.mode = 040755 core.version = 1
@@ -1101,9 +1101,9 @@ u.bmbt.level = 1 u.bmbt.numrecs = 1 u.bmbt.keys[1] = [startoff] 1:[0] u.bmbt.ptrs[1] = 1:89 -xfs_db> fsblock 89 -xfs_db> type bmapbtd -xfs_db> p +xfs_db> fsblock 89 +xfs_db> type bmapbtd +xfs_db> p magic = 0x424d4150 level = 0 numrecs = 234
design/XFS_Filesystem_Structure/extended_attributes.asciidoc +7 -7
@@ -355,8 +355,8 @@ core.aformat = 2 (extents) ... a.bmx[0] = [startoff,startblock,blockcount,extentflag] 0:[0,37535,9,0] -xfs_db> ablock 0 -xfs_db> p +xfs_db> ablock 0 +xfs_db> p hdr.info.forw = 0 hdr.info.back = 0 hdr.info.magic = 0xfbee
@@ -580,9 +580,9 @@ rightsib = 109968 recs[1-127] = [startoff,startblock,blockcount,extentflag] 1:[0,81870,1,0] ... -xfs_db> fsblock 109968 -xfs_db> type bmapbtd -xfs_db> p +xfs_db> fsblock 109968 +xfs_db> type bmapbtd +xfs_db> p magic = 0x424d4150 level = 0 numrecs = 147
@@ -591,8 +591,8 @@ rightsib = null recs[1-147] = [startoff,startblock,blockcount,extentflag] ... (which is fsblock 81870) -xfs_db> ablock 0 -xfs_db> p +xfs_db> ablock 0 +xfs_db> p hdr.info.forw = 0 hdr.info.back = 0 hdr.info.magic = 0xfebe
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 5/21 xfsdocs: convert images to text
In reply to Darrick J. WongConvert images that are purely screenshots of xfs_db sessions to text, to reduce the document size and format better.
--- .../XFS_Filesystem_Structure/data_extents.asciidoc | 37 ++++- .../XFS_Filesystem_Structure/directories.asciidoc | 65 +++++++- .../extended_attributes.asciidoc | 161 ++++++++++++++++++-- .../symbolic_links.asciidoc | 15 ++ 4 files changed, 251 insertions(+), 27 deletions(-)
design/XFS_Filesystem_Structure/data_extents.asciidoc +33 -4
@@ -132,14 +132,43 @@ u.bmx[0-2] = [startoff,startblock,blockcount,extentflag] Raw disk version of the inode with the third extent highlighted (+di_u+ always starts at offset 0x64): -.Raw inode contents with extents -image::images/code/33a.png[] +[subs="quotes"] +---- +xfs_db> type text +xfs_db> p +00: 49 4e 81 a4 01 02 00 01 00 00 00 00 00 00 00 00 IN.............. +10: 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 ................ +20: 44 b6 88 dd 2f 8a ed d0 44 b6 88 f7 10 8c 5b de D.......D....... +30: 44 b6 88 f7 10 8c 5b d0 00 00 00 00 01 7b b0 00 D............... +40: 00 00 00 00 00 00 17 bb 00 00 00 00 00 00 00 03 ................ +50: 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 ................ +60: ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 0d ................ +70: 5e a0 07 e9 00 00 00 00 00 0f d2 00 00 00 00 0f ................ +80: 58 e0 07 e9 *00 00 00 00 00 1f a4 00 00 00 00 11 X............... +90: 53 20 07 e9* 00 00 00 00 00 00 00 00 00 00 00 00 S............... +a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +be: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +co: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +do: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +fo: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +---- We can expand the highlighted section into the following bit array from MSB to LSB with the file offset and the block count highlighted: -.Encoded extent -image::images/code/33b.png[] +[subs="quotes"] +---- +127-96: 0**000 0000 0000 0000 0000 0000 0000 0000** + 95-64: **0000 0000 0001 1111 1010 010**0 0000 0000 + 63-32: 0000 0000 0000 0000 0000 0000 0000 1111 + 31-0 : 0101 1000 111**0 0000 0000 0111 1110 1001** + +Grouping by highlights we get: + file offset = 0x0fd2 (4050) + start block = 0x7ac7 (31431) + block count = 0x07e9 (2025) +---- A 4MB file with two extents and a hole in the middle, the first extent containing 64KB of data, the second about 4MB in containing 32KB (+write+ 64KB,
design/XFS_Filesystem_Structure/directories.asciidoc +57 -8
87 lines not on this page · raw message
design/XFS_Filesystem_Structure/extended_attributes.asciidoc +148 -13
197 lines not on this page · raw message
design/XFS_Filesystem_Structure/symbolic_links.asciidoc +13 -2
@@ -38,8 +38,19 @@ u.symlink = "small_target" Raw on-disk data with the link contents highlighted: -.Shortform symbolic link format -image::images/code/61.png[] +[subs="quotes"] +---- +xfs_db> type text +xfs_db> p +00: 49 4e a1 ff 01 01 00 01 00 00 00 00 00 00 00 00 IN.............. +10: 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 ................ +20: 44 be e1 c7 03 c4 d4 18 44 be el c7 03 c4 d4 18 D.......D....... +30: 44 be e1 c7 03 c4 d4 18 00 00 00 00 00 00 00 Oc D............... +40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +50: 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 ................ +60: ff ff ff ff *73 6d 61 6c 6c 5f 74 61 72 67 65 74* ....small.target +70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +---- [[Extent_Symbolic_Links]]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 6/21 xfsdocs: update types
In reply to Darrick J. WongUpdate the common data types to reflect modern XFS source.
--- .../allocation_groups.asciidoc | 8 +++---- .../XFS_Filesystem_Structure/common_types.asciidoc | 23 ++++++++++++++------ .../XFS_Filesystem_Structure/data_extents.asciidoc | 4 ++- .../XFS_Filesystem_Structure/ondisk_inode.asciidoc | 2 +- 4 files changed, 23 insertions(+), 14 deletions(-)
design/XFS_Filesystem_Structure/allocation_groups.asciidoc +4 -4
@@ -47,11 +47,11 @@ struct xfs_sb { __uint32_t sb_magicnum; __uint32_t sb_blocksize; - xfs_drfsbno_t sb_dblocks; - xfs_drfsbno_t sb_rblocks; - xfs_drtbno_t sb_rextents; + xfs_rfsblock_t sb_dblocks; + xfs_rfsblock_t sb_rblocks; + xfs_rtblock_t sb_rextents; uuid_t sb_uuid; - xfs_dfsbno_t sb_logstart; + xfs_fsblock_t sb_logstart; xfs_ino_t sb_rootino; xfs_ino_t sb_rbmino; xfs_ino_t sb_rsumino;
design/XFS_Filesystem_Structure/common_types.asciidoc +16 -7
@@ -10,7 +10,7 @@ Unsigned 64 bit absolute xref:Inode_Numbers[inode number]. Signed 64 bit file offset. *xfs_daddr_t*:: -Signed 64 bit disk address. +Signed 64 bit disk address (sectors). *xfs_agnumber_t*:: Unsigned 32 bit xref:Allocation_Groups[AG number].
@@ -22,7 +22,10 @@ Unsigned 32 bit AG relative block number. Unsigned 32 bit xref:Data_Extents[extent] length in blocks. *xfs_extnum_t*:: -Signed 32 bit number of extents in a file. +Signed 32 bit number of extents in a data fork. + +*xfs_aextnum_t*:: +Signed 16 bit number of extents in an attribute fork. *xfs_dablk_t*:: Unsigned 32 bit block number for xref:Directories[directories] and
@@ -31,19 +34,25 @@ xref:Extended_Attributes[extended attributes]. *xfs_dahash_t*:: Unsigned 32 bit hash of a directory file name or extended attribute name. -*xfs_dfsbno_t*:: +*xfs_fsblock_t*:: Unsigned 64 bit filesystem block number combining xref:Allocation_Groups[AG number] and block offset into the AG. -*xfs_drfsbno_t*:: +*xfs_rfsblock_t*:: Unsigned 64 bit raw filesystem block number. -*xfs_drtbno_t*:: +*xfs_rtblock_t*:: Unsigned 64 bit extent number in the xref:Real-time_Devices[real-time] sub-volume. -*xfs_dfiloff_t*:: +*xfs_fileoff_t*:: Unsigned 64 bit block offset into a file. -*xfs_dfilblks_t*:: +*xfs_filblks_t*:: Unsigned 64 bit block count for a file. + +*uuid_t*:: +16-byte universally unique identifier (UUID). + +*xfs_fsize_t*:: +Signed 64 bit byte size of a file.
design/XFS_Filesystem_Structure/data_extents.asciidoc +2 -2
@@ -217,9 +217,9 @@ struct xfs_bmdr_block { __be16 bb_numrecs; }; struct xfs_bmbt_key { - xfs_dfiloff_t br_startoff; + xfs_fileoff_t br_startoff; }; -typedef xfs_dfsbno_t xfs_bmbt_ptr_t, xfs_bmdr_ptr_t; +typedef xfs_fsblock_t xfs_bmbt_ptr_t, xfs_bmdr_ptr_t; ---- * On disk, the B+tree node starts with the +xfs_bmbr_block_t+ header followed by
design/XFS_Filesystem_Structure/ondisk_inode.asciidoc +1 -1
@@ -88,7 +88,7 @@ struct xfs_dinode_core { xfs_timestamp_t di_mtime; xfs_timestamp_t di_ctime; xfs_fsize_t di_size; - xfs_drfsbno_t di_nblocks; + xfs_rfsblock_t di_nblocks; xfs_extlen_t di_extsize; xfs_extnum_t di_nextents; xfs_aextnum_t di_anextents;
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 7/21 xfsdocs: make example section titles consistent
In reply to Darrick J. WongMake the section titles of the examples consistently formatted.
--- .../allocation_groups.asciidoc | 6 +++--- .../XFS_Filesystem_Structure/data_extents.asciidoc | 6 +++--- .../XFS_Filesystem_Structure/directories.asciidoc | 16 ++++++++-------- .../extended_attributes.asciidoc | 16 ++++++++-------- .../symbolic_links.asciidoc | 8 ++++---- 5 files changed, 26 insertions(+), 26 deletions(-)
design/XFS_Filesystem_Structure/allocation_groups.asciidoc +3 -3
@@ -308,7 +308,7 @@ its parent inode. The primary purpose for this information is in backup systems. |===== -=== xfs_db superblock example +=== xfs_db Superblock Example A filesystem is made on a single SATA disk with the following command:
@@ -548,7 +548,7 @@ image::images/16.png[] The presence of these reserved block guarantees that the free space B+trees can be updated if any blocks are freed by extent changes in a full AG. -==== xfs_db AGF Examples +==== xfs_db AGF Example These examples are derived from an AG that has been deliberately fragmented. The AGF:
@@ -772,7 +772,7 @@ And a 2-level inode B+tree: image::images/20b.png[] -==== xfs_db AGI examples +==== xfs_db AGI Example TODO [[Real-time_Devices]]
design/XFS_Filesystem_Structure/data_extents.asciidoc +3 -3
@@ -88,7 +88,7 @@ The number of extents that can fit in the inode depends on the inode size and can up to 19 extents with this format. Beyond this, extents have to use the B+tree format. -=== xfs_db: Inode data fork extents +=== xfs_db Inode Data Fork Extents Example An 8MB file with one extent:
@@ -268,9 +268,9 @@ bits in size. .Single level extent B+tree image::images/35.png[] -.Multi-level extent B+tree +.Multiple level extent B+tree image::images/36.png[] -=== BMBT xfs_db Example +=== xfs_db bmbt Example TODO
design/XFS_Filesystem_Structure/directories.asciidoc +8 -8
@@ -47,7 +47,7 @@ typedef __uint32_t xfs_dir2_dataptr_t; [[Shortform_Directories]] -== Shortform Directories +== Short Form Directories * Directory entries are stored within the inode.
@@ -86,7 +86,7 @@ typedef struct xfs_dir2_sf_entry { } xfs_dir2_sf_entry_t; ---- -.Shortform Directory layout +.Short form directory layout image::images/39.png[] * Inode numbers are stored using 4 or 8 bytes depending on whether all the inode
@@ -107,7 +107,7 @@ typedef union { } xfs_dir2_inou_t; ---- -=== Shortform Directory xfs_db Example +=== xfs_db Short Form Directory Example A directory is created with 4 files, all inode numbers fitting within 4 bytes:
@@ -325,7 +325,7 @@ lookup speed for large directories. If they were not stored, the hashes have to be calculated for all entries each time a lookup occurs in a directory. -=== Block Directory xfs_db Example +=== xfs_db Block Directory Example A directory is created with 8 entries, directory block size = filesystem block size:
@@ -585,7 +585,7 @@ block's +bestfree[0].length+ value. .Leaf directory free entry detail image::images/48.png[] -=== Leaf Directory xfs_db Example +=== xfs_db Leaf Directory Example For this example, a directory was created with 256 entries (frame000000.tst to frame000255.tst) and then deleted some files (frame00005*, frame00018* and
@@ -905,10 +905,10 @@ less than or equal to +hdr.nused. hdr.nused+ should be the same as the index of the last data directory block plus one (i.e. when the last data block is freed, +nused+ and +nvalid+ are decremented). -.Node Directory Layout +.Node directory layout image::images/54.png[] -=== Node Directory xfs_db Example +=== xfs_db Node Directory Example With the node directory examples, we are using a filesystems with 4KB block size, and a 16KB directory size. The directory has over 2000 entries:
@@ -1111,7 +1111,7 @@ that B+trees can handle: required hundreds of thousand files with quite long file names (or millions with shorter names) to get a second freeindex block. -=== B+tree Directory xfs_db Example +=== xfs_db B+tree Directory Example A directory has been created with 200,000 entries with each entry being 100 characters long. The filesystem block size and directory block size are 4KB:
design/XFS_Filesystem_Structure/extended_attributes.asciidoc +8 -8
@@ -41,7 +41,7 @@ The following four sections describe each of the on-disk formats. [[Shortform_Attributes]] -== Shortform Attributes +== Short Form Attributes When the all extended attributes can fit within the inode's attribute fork, the inode's +di_aformat+ is set to "local" and the attributes are stored in the
@@ -67,7 +67,7 @@ typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t; typedef struct xfs_attr_sf_entry xfs_attr_sf_entry_t; ---- -.Shortform attribute layout +.Short form attribute layout image::images/64.png[]
@@ -89,7 +89,7 @@ immediately follows the name in the array. | +XFS_ATTR_SECURE+ | The attribute's namespace is "secure". |===== -=== Shortform attribute xfs_db example +=== xfs_db Short Form Attribute Example A file is created and two attributes are set:
@@ -387,7 +387,7 @@ using the +xfs_attr_leaf_name_local_t+ structure. For large attribute values that cannot be stored within the leaf, separate filesystem blocks are allocated to store the value. They use the +xfs_attr_leaf_name_remote_t+ structure. -.Leaf Attribute layout +.Leaf attribute layout image::images/69.png[] Both local and remote entries can be interleaved as they are only addressed by
@@ -403,7 +403,7 @@ crash during the time that the bit is set. The bit is cleared when attribute has finished being setup. This is done because some large attributes cannot be created inside a single transaction. -=== Leaf Attribute xfs_db Example +=== xfs_db Leaf Attribute Example A single 30KB extended attribute is added to an inode:
@@ -538,10 +538,10 @@ to lookup, you read the node's btree array and first +hashval+ in the array that exceeds the given hash and it can then be found in the block pointed to by the +before+ value. -.Node Attribute layout +.Node attribute layout image::images/72.png[] -=== Node Attribute xfs_db Example +=== xfs_db Node Attribute Example An inode with 1000 small attributes with the naming "attribute_n" where 'n' is a number:
@@ -685,7 +685,7 @@ Attributes. Refer to the previous section on B+tree Data Extents for more information on XFS B+tree extents. -=== B+tree Attribute xfs_db Example +=== xfs_db B+tree Attribute Example Added 2000 attributes with 729 byte values to a file:
design/XFS_Filesystem_Structure/symbolic_links.asciidoc +4 -4
@@ -7,16 +7,16 @@ Symbolic links to a file can be stored in one of two formats: "local" and [[Shortform_Symbolic_Links]] -== Shortform Symbolic Links +== Short Form Symbolic Links Symbolic links are stored with the "local" +di_format+ if the symbolic link can fit within the inode's data fork. The link data is an array of characters (+di_symlink+ array in the data fork union). -.Symbolic link shortform layout +.Symbolic link short form layout image::images/61.png[] -=== Shortform symbolic link xfs_db example +=== xfs_db Short Form Symbolic Link Example A short symbolic link to a file is created:
@@ -66,7 +66,7 @@ characters. .Symbolic link extent layout image::images/62.png[] -=== Symbolic link extent xfs_db example +=== xfs_db Symbolic Link Extent Example A longer link is created (greater than 156 bytes):
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 9/21 xfsdocs: add missing structure field definitions
In reply to Darrick J. WongAdd missing field definitions for various data structures.
--- .../allocation_groups.asciidoc | 32 +++ .../XFS_Filesystem_Structure/data_extents.asciidoc | 27 ++ .../XFS_Filesystem_Structure/directories.asciidoc | 240 ++++++++++++++++++++ design/XFS_Filesystem_Structure/docinfo.xml | 1 .../extended_attributes.asciidoc | 86 +++++++ 5 files changed, 386 insertions(+)
design/XFS_Filesystem_Structure/allocation_groups.asciidoc +32 -0
@@ -501,6 +501,23 @@ struct xfs_btree_sblock { }; ---- +*bb_magic*:: +Specifies the magic number for the per-AG B+tree block. + +*bb_level*:: +The level of the tree in which this block is found. If this value is 0, this +is a leaf block and contains records; otherwise, it is a node block and +contains keys and pointers. + +*bb_numrecs*:: +Number of records in this block. + +*bb_leftsib*:: +AG block number of the left sibling of this B+tree node. + +*bb_rightsib*:: +AG block number of the right sibling of this B+tree node. + [[AG_Free_Space_Btrees]] === AG Free Space B+trees
@@ -519,6 +536,12 @@ struct xfs_alloc_rec { }; ---- +*ar_startblock*:: +AG block number of the start of the free space. + +*ar_blockcount*:: +Length of the free space. + Node pointers are an AG relative block pointer: [source, c]
@@ -776,6 +799,15 @@ struct xfs_inobt_rec { }; ---- +*ir_startino*:: +The lowest-numbered inode in this chunk. + +*ir_freecount*:: +Number of free inodes in this chunk. + +*ir_free*:: +A 64 element bitmap showing which inodes in this chunk are free. + Nodes contain key/pointer pairs using the following types: [source,c]
design/XFS_Filesystem_Structure/data_extents.asciidoc +27 -0
@@ -33,8 +33,16 @@ struct xfs_bmbt_irec { }; ---- +*br_startoff*:: +Logical block offset of this mapping. +*br_startblock*:: +Filesystem block of this mapping. +*br_blockcount*:: +The length of this mapping. + +*br_state*:: The extent +br_state+ field uses the following enum declaration: [source, c]
@@ -250,6 +258,25 @@ struct xfs_btree_lblock { }; ---- +*bb_magic*:: +Specifies the magic number for the BMBT block: "BMAP" (0x424d4150). + +*bb_level*:: +The level of the tree in which this block is found. If this value is 0, this +is a leaf block and contains records; otherwise, it is a node block and +contains keys and pointers. + +*bb_numrecs*:: +Number of records in this block. + +*bb_leftsib*:: +FS block number of the left sibling of this B+tree node. + +*bb_rightsib*:: +FS block number of the right sibling of this B+tree node. + +// force-split the lists + * For intermediate nodes, the data following +xfs_btree_lblock+ is the same as the root node: array of +xfs_bmbt_key+ value followed by an array of +xfs_bmbt_ptr_t+ values that starts halfway through the block (offset 0x808 for
design/XFS_Filesystem_Structure/directories.asciidoc +240 -0
342 lines not on this page · raw message
design/XFS_Filesystem_Structure/docinfo.xml +1 -0
@@ -82,6 +82,7 @@ <revdescription> <simplelist> <member>Miscellaneous fixes.</member> + <member>Add missing field definitions.</member> </simplelist> </revdescription> </revision>
design/XFS_Filesystem_Structure/extended_attributes.asciidoc +86 -0
126 lines not on this page · raw message
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 8/21 xfsdocs: fix various errors and missing bits in the text
In reply to Darrick J. WongFix typos and grammatical errors in the text.
--- .../allocation_groups.asciidoc | 128 +++++++++++-------- .../XFS_Filesystem_Structure/data_extents.asciidoc | 64 +++++---- .../XFS_Filesystem_Structure/directories.asciidoc | 136 ++++++++++++-------- design/XFS_Filesystem_Structure/docinfo.xml | 16 ++ .../extended_attributes.asciidoc | 96 ++++++++------ .../internal_inodes.asciidoc | 33 +++-- .../XFS_Filesystem_Structure/ondisk_inode.asciidoc | 83 +++++++----- 7 files changed, 319 insertions(+), 237 deletions(-)
design/XFS_Filesystem_Structure/allocation_groups.asciidoc +77 -51
@@ -3,9 +3,8 @@ XFS filesystems are divided into a number of equally sized chunks called Allocation Groups. Each AG can almost be thought of as an individual filesystem -that maintains it's own space usage. Each AG can be up to one terabyte in size -(512 bytes * 2^31^), regardless of the underlying -device's sector size. +that maintains its own space usage. Each AG can be up to one terabyte in size +(512 bytes × 2^31^), regardless of the underlying device's sector size. Each AG has the following characteristics:
@@ -14,15 +13,15 @@ Each AG has the following characteristics: * Inode allocation and tracking Having multiple AGs allows XFS to handle most operations in parallel without -degrading performance as the number of concurrent accessing increases. +degrading performance as the number of concurrent accesses increases. -The only global information maintained by the first AG (primary) is free spac e +The only global information maintained by the first AG (primary) is free space across the filesystem and total inode counts. If the +XFS_SB_VERSION2_LAZYSBCOUNTBIT+ flag is set in the superblock, these are only updated on-disk when the filesystem is cleanly unmounted (umount or shutdown). -Immediately after a mkfs.xfs, the primary AG has the following disk layout the -subsequent AGs do not have any inodes allocated: +Immediately after a +mkfs.xfs+, the primary AG has the following disk layout; +the subsequent AGs do not have any inodes allocated: .Allocation group layout image::images/6.png[]
@@ -32,9 +31,10 @@ Each of these structures are expanded upon in the following sections. [[Superblocks]] == Superblocks -Each AG starts with a superblock. The first one is the primary superblock that -stores aggregate AG information. Secondary superblocks are only used by -xfs_repair when the primary superblock has been corrupted. +Each AG starts with a superblock. The first one, in AG 0, is the primary +superblock which stores aggregate AG information. Secondary superblocks are +only used by xfs_repair when the primary superblock has been corrupted. A +superblock is one sector in length. The superblock is defined by the following structure. The description of each field follows.
@@ -93,7 +93,7 @@ struct xfs_sb }; ---- *sb_magicnum*:: -Identifies the filesystem. It's value is +XFS_SB_MAGIC = 0x58465342 "XFSB"+. +Identifies the filesystem. Its value is +XFS_SB_MAGIC = 0x58465342 "XFSB"+. *sb_blocksize*:: The size of a basic unit of space allocation in bytes. Typically, this is 4096
@@ -116,11 +116,14 @@ the UUID instead of device name. *sb_logstart*:: First block number for the journaling log if the log is internal (ie. not on a separate disk device). For an external log device, this will be zero (the log -will also start on the first block on the log device). +will also start on the first block on the log device). The identity of the log +devices is not recorded in the filesystem, but the UUIDs of the filesystem and +the log device are compared to prevent corruption. *sb_rootino*:: -Root inode number for the filesystem. Typically, this is 128 when using a -4KB block size. +Root inode number for the filesystem. Normally, the root inode is at the +start of the first possible inode chunk in AG 0. This is 128 when using a 4KB +block size. *sb_rbmino*:: Bitmap inode for real-time extents.
@@ -147,9 +150,9 @@ Number of blocks for the journaling log. *sb_versionnum*:: Filesystem version number. This is a bitmask specifying the features enabled when creating the filesystem. Any disk checking tools or drivers that do not -recognize any set bits must not operate upon the filesystem. Most of the flagsi -indicate features introduced over time. The value must be 4 including the -following flags: +recognize any set bits must not operate upon the filesystem. Most of the flags +indicate features introduced over time. If the value of the lower nibble is 4, +the higher bits indicate feature flags as follows: .Version 4 Superblock version flags [options="header"]
@@ -175,8 +178,8 @@ Set if the sb_features2 field in the superblock contains more flags. |===== *sb_sectsize*:: -Specifies the underlying disk sector size in bytes. Majority of the time, this -is 512 bytes. This determines the minimum I/O alignment including Direct I/O. +Specifies the underlying disk sector size in bytes. Typically this is 512 or +4096 bytes. This determines the minimum I/O alignment, especially for direct I/O. *sb_inodesize*:: Size of the inode in bytes. The default is 256 (2 inodes per standard sector)
@@ -258,6 +261,13 @@ Quota flags. It can be a combination of the following flags: *sb_flags*:: Miscellaneous flags. +.Superblock flags +[options="header"] +|===== +| Flag | Description +| +XFS_SBF_READONLY+ | Only read-only mounts allowed. +|===== + *sb_shared_vn*:: Reserved and must be zero ("vn" stands for version number).
@@ -300,17 +310,29 @@ primary superblock when the filesystem is cleanly unmounted. | +XFS_SB_VERSION2_ATTR2BIT+ | Extended attributes version 2. Making a filesystem with this optimises the inode -layout of extended attributes. +layout of extended attributes. See the section about +xref:Extended_Attribute_Versions[extended attribute versions] for more +information. | +XFS_SB_VERSION2_PARENTBIT+ | Parent pointers. All inodes must have an extended attribute that points back to its parent inode. The primary purpose for this information is in backup systems. + +| +XFS_SB_VERSION2_PROJID32BIT+ | +32-bit Project ID. Inodes can be associated with a project ID number, which +can be used to enforce disk space usage quotas for a particular group of +directories. This flag indicates that project IDs can be 32 bits in size. + +| +XFS_SB_VERSION2_FTYPE+ | +Directory file type. Each directory entry records the type of the inode to +which the entry points. This speeds up directory iteration by removing the +need to load every inode into memory. |===== === xfs_db Superblock Example -A filesystem is made on a single SATA disk with the following command: +A filesystem is made on a single disk with the following command: ---- # mkfs.xfs -i attr=2 -n size=16384 -f /dev/sda7
@@ -385,7 +407,7 @@ One B+tree tracks space by block number, the second by the size of the free space block. This scheme allows XFS to quickly find free space near a given block or of a given size. -All block numbers, indexes and counts are AG relative. +All block numbers, indexes, and counts are AG relative. [[AG_Free_Space_Block]] === AG Free Space Block
@@ -414,8 +436,9 @@ struct xfs_agf { }; ---- -The rest of the bytes in the sector are zeroed. +XFS_BTNUM_AGF+ is set to 2, -index 0 for the count B+tree and index 1 for the size B+tree. +The rest of the bytes in the sector are zeroed. +XFS_BTNUM_AGF+ is set to 2: +index 0 for the free space B+tree indexed by block number; and index 1 for the +free space B+tree indexed by extent size. *agf_magicnum*:: Specifies the magic number for the AGF sector: "XAGF" (0x58414746).
@@ -428,7 +451,7 @@ Specifies the AG number for the sector. *agf_length*:: Specifies the size of the AG in filesystem blocks. For all AGs except the last, -This must be equal to the superblock's +sb_agblocks+ value. For the last AG, +this must be equal to the superblock's +sb_agblocks+ value. For the last AG, this could be less than the +sb_agblocks+ value. It is this value that should be used to determine the size of the AG.
@@ -459,14 +482,13 @@ Specifies the number of blocks of longest contiguous free space in the AG. Specifies the number of blocks used for the free space B+trees. This is only used if the +XFS_SB_VERSION2_LAZYSBCOUNTBIT+ bit is set in +sb_features2+. -[[AG_Free_Space_Btrees]] -=== AG Free Space B+trees +[[Short_Format_Btrees]] +=== Short Format B+trees -The two Free Space B+trees store a sorted array of block offset and block -counts in the leaves of the B+tree. The first B+tree is sorted by the offset, -the second by the count or size. - -The trees use the following header: +Each allocation group uses a ``short format'' B+tree to index various +information about the allocation group. The structure is called short format +because all block pointers are AG block numbers. The trees use the following +header: [source, c] ----
@@ -479,6 +501,13 @@ struct xfs_btree_sblock { }; ---- +[[AG_Free_Space_Btrees]] +=== AG Free Space B+trees + +The two Free Space B+trees store a sorted array of block offset and block +counts in the leaves of the B+tree. The first B+tree is sorted by the offset, +the second by the count or size. + Leaf nodes contain a sorted array of offset/count pairs which are also used for node keys:
@@ -531,7 +560,7 @@ including inodes, data, directories and extended attributes. With a freshly made filesystem, 4 blocks are reserved immediately after the free space B+tree root blocks (blocks 4 to 7). As they are used up as the free space fragments, additional blocks will be reserved from the AG and added to the free -list array. +list array. This size may increase as features are added. As the free list array is located within a single sector, a typical device will have space for 128 elements in the array (512 bytes per sector, 4 bytes per AG
@@ -545,8 +574,8 @@ values. The array is managed as a circular list. .AG Free List layout image::images/16.png[] -The presence of these reserved block guarantees that the free space B+trees can -be updated if any blocks are freed by extent changes in a full AG. +The presence of these reserved blocks guarantees that the free space B+trees +can be updated if any blocks are freed by extent changes in a full AG. ==== xfs_db AGF Example
@@ -584,8 +613,8 @@ bno[0-127] = 0:4 1:5 2:6 3:7 4:83342 5:83343 6:83344 7:83345 8:83346 9:83347 26:80205 27:83344 ---- -The free space B+tree sorted by block offset, the root block is from the AGF's -+bnoroot+ value: +The root block of the free space B+tree sorted by block offset is found in the +AGF's +bnoroot+ value: ---- xfs_db> fsblock 7
@@ -602,11 +631,11 @@ ptrs[1-4] = 1:2 2:83347 3:6 4:4 ---- Blocks 2, 83347, 6 and 4 contain the leaves for the free space B+tree by -starting block. Block 2 would contain offsets 16 up to but not including 184586 +starting block. Block 2 would contain offsets 12 up to but not including 184586 while block 4 would have all offsets from 511629 to the end of the AG. -The free space B+tree sorted by block count, the root block is from the AGF's -+cntroot+ value: +The root block of the free space B+tree sorted by block count is found in the +AGF's +cntroot+ value: ---- xfs_db> fsblock 83343
@@ -642,7 +671,7 @@ recs[1-344] = [startblock,blockcount] 342:[513712,755] 343:[230317,258229] 344:[538795,3384327] ---- -The longest block count must be the same as the AGF's +longest+ value. +The longest block count (3384327) must be the same as the AGF's +longest+ value. [[AG_Inode_Management]] == AG Inode Management
@@ -659,7 +688,7 @@ structures. Absolute inode numbers include the AG number in the high bits, above the bits used for the AG relative inode number. Absolute inode numbers are found in -xref:Directories[directory] entries. +xref:Directories[directory] entries and the superblock. .Inode number formats image::images/18.png[]
@@ -713,10 +742,10 @@ Specifies the number of levels in the inode B+tree. Specifies the number of free inodes in the AG. *agi_newino*:: -Specifies AG relative inode number most recently allocated. +Specifies AG-relative inode number of the most recently allocated chunk. *agi_dirino*:: -Deprecated and not used, it's always set to NULL (-1). +Deprecated and not used, this is always set to NULL (-1). *agi_unlinked[64]*:: Hash table of unlinked (deleted) inodes that are still being referenced. Refer
@@ -734,6 +763,8 @@ The B+tree header for the nodes and leaves use the +xfs_btree_sblock+ structure which is the same as the header used in the xref:AG_Free_Space_Btrees[AGF B+trees]. +The magic number of the inode B+tree is ``IABT'' (0x49414254). + Leaves contain an array of the following structure: [source,c]
@@ -755,20 +786,15 @@ struct xfs_inobt_key { typedef __be32 xfs_inobt_ptr_t; ---- -For the leaf entries, +ir_startino+ specifies the starting inode number for the -chunk, +ir_freecount+ specifies the number of free entries in the chuck, and the -+ir_free+ is a 64 element bit array specifying which entries are free in the -chunk. - The following diagram illustrates a single level inode B+tree: -.Single Level inode b+tree +.Single Level inode B+tree image::images/20a.png[] And a 2-level inode B+tree: -.Multi-Level inode b+tree +.Multi-Level inode B+tree image::images/20b.png[]
design/XFS_Filesystem_Structure/data_extents.asciidoc +33 -31
138 lines not on this page · raw message
design/XFS_Filesystem_Structure/directories.asciidoc +79 -57
293 lines not on this page · raw message
design/XFS_Filesystem_Structure/docinfo.xml +16 -0
@@ -1,7 +1,9 @@ <subtitle>3rd Edition</subtitle> +<!-- <abstract> <para>This book documents the XFS Filesystem Structure</para> </abstract> +--> <corpauthor> </corpauthor> <copyright>
@@ -69,4 +71,18 @@ </simplelist> </revdescription> </revision> + <revision> + <revnumber>3</revnumber> + <date>October 2015</date> + <author> + <firstname>Darrick</firstname> + <surname>Wong</surname> + <email></email> + </author> + <revdescription> + <simplelist> + <member>Miscellaneous fixes.</member> + </simplelist> + </revdescription> + </revision> </revhistory>
design/XFS_Filesystem_Structure/extended_attributes.asciidoc +51 -45
180 lines not on this page · raw message
design/XFS_Filesystem_Structure/internal_inodes.asciidoc +17 -16
@@ -28,8 +28,9 @@ multiplied by the size of +xfs_dqblk_t+ (136 bytes). .Quota inode layout image::images/76.png[] -Quota information stored in the two inodes (in data extents) are an array of the -+xfs_dqblk+ structure where there is one instance for each ID in the system: +Quota information is stored in the data extents of the two reserved quota +inodes as an array of the +xfs_dqblk+ structures, where there is one array +element for each ID in the system: [source, c] ----
@@ -67,7 +68,7 @@ Specifies the signature where these two bytes are 0x4451 (+XFS_DQUOT_MAGIC+), or "DQ" in ASCII. *d_version*:: -Specifies the structure version, currently this is one (+XFS_DQUOT_VERSION+). +The structure version, currently this is 1 (+XFS_DQUOT_VERSION+). *d_flags*:: Specifies which type of ID the structure applies to:
@@ -84,33 +85,33 @@ The ID for the quota structure. This will be a uid, gid or projid based on the value of +d_flags+. *d_blk_hardlimit*:: -Specifies the hard limit for the number of filesystem blocks the ID can own. The +The hard limit for the number of filesystem blocks the ID can own. The ID will not be able to use more space than this limit. If it is attempted, +ENOSPC+ will be returned. *d_blk_softlimit*:: -Specifies the soft limit for the number of filesystem blocks the ID can own. +The soft limit for the number of filesystem blocks the ID can own. The ID can temporarily use more space than by +d_blk_softlimit+ up to +d_blk_hardlimit+. If the space is not freed by the time limit specified by ID zero's +d_btimer+ value, the ID will be denied more space until the total blocks owned goes below +d_blk_softlimit+. *d_ino_hardlimit*:: -Specifies the hard limit for the number of inodes the ID can own. The ID will +The hard limit for the number of inodes the ID can own. The ID will not be able to create or own any more inodes if +d_icount+ reaches this value. *d_ino_softlimit*:: -Specifies the soft limit for the number of inodes the ID can own. The ID can -temporarily create or own more inodes than specified by d_ino_softlimit up to -d_ino_hardlimit. If the inode count is not reduced by the time limit specified -by ID zero's d_itimer value, the ID will be denied from creating or owning more -inodes until the count goes below d_ino_softlimit. +The soft limit for the number of inodes the ID can own. The ID can +temporarily create or own more inodes than specified by +d_ino_softlimit+ up to ++d_ino_hardlimit+. If the inode count is not reduced by the time limit specified +by ID zero's +d_itimer+ value, the ID will be denied from creating or owning more +inodes until the count goes below +d_ino_softlimit+. *d_bcount*:: -Specifies how many filesystem blocks are actually owned by the ID. +How many filesystem blocks are actually owned by the ID. *d_icount*:: -Specifies how many inodes are actually owned by the ID. +How many inodes are actually owned by the ID. *d_itimer*:: Specifies the time when the ID's +d_icount+ exceeded +d_ino_softlimit+. The soft
@@ -130,18 +131,18 @@ is reset back to zero. Specifies how many times a warning has been issued. Currently not used. *d_rtb_hardlimit*:: -Specifies the hard limit for the number of real-time blocks the ID can own. The +The hard limit for the number of real-time blocks the ID can own. The ID cannot own more space on the real-time subvolume beyond this limit. *d_rtb_softlimit*:: -Specifies the soft limit for the number of real-time blocks the ID can own. The +The soft limit for the number of real-time blocks the ID can own. The ID can temporarily own more space than specified by +d_rtb_softlimit+ up to +d_rtb_hardlimit+. If +d_rtbcount+ is not reduced by the time limit specified by ID zero's +d_rtbtimer value+, the ID will be denied from owning more space until the count goes below +d_rtb_softlimit+. *d_rtbcount*:: -Specifies how many real-time blocks are currently owned by the ID. +How many real-time blocks are currently owned by the ID. *d_rtbtimer*:: Specifies the time when the ID's +d_rtbcount+ exceeded +d_rtb_softlimit+. The
design/XFS_Filesystem_Structure/ondisk_inode.asciidoc +46 -37
183 lines not on this page · raw message
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 10/21 xfsdocs: add missing xfs_db examples
In reply to Darrick J. WongFix some of the more egregious missing xfs_db examples so that the reader can appreciate what the data structures look like.
--- .../allocation_groups.asciidoc | 74 ++++++++++++++++++++ .../XFS_Filesystem_Structure/data_extents.asciidoc | 41 +++++++++++ .../XFS_Filesystem_Structure/directories.asciidoc | 55 +++++++++++++++ design/XFS_Filesystem_Structure/docinfo.xml | 1 4 files changed, 168 insertions(+), 3 deletions(-)
design/XFS_Filesystem_Structure/allocation_groups.asciidoc +73 -1
@@ -831,7 +831,79 @@ image::images/20b.png[] ==== xfs_db AGI Example -TODO + +This is an AGI of a freshly populated filesystem: + +---- +xfs_db> agi 0 +xfs_db> p +magicnum = 0x58414749 +versionnum = 1 +seqno = 0 +length = 825457 +count = 5440 +root = 3 +level = 1 +freecount = 9 +newino = 5792 +dirino = null +unlinked[0-63] = +uuid = 3dfa1e5c-5a5f-4ca2-829a-000e453600fe +lsn = 0x1000032c2 +crc = 0x14cb7e5c (correct) +free_root = 4 +free_level = 1 +---- + +From this example, we see that the inode B+tree is rooted at AG block 3 and +that the free inode B+tree is rooted at AG block 4. Let's look at the +inode B+tree: + +---- +xfs_db> addr root +xfs_db> p +magic = 0x49414233 +level = 0 +numrecs = 85 +leftsib = null +rightsib = null +bno = 24 +lsn = 0x1000032c2 +uuid = 3dfa1e5c-5a5f-4ca2-829a-000e453600fe +owner = 0 +crc = 0x768f9592 (correct) +recs[1-85] = [startino,freecount,free] + 1:[96,0,0] 2:[160,0,0] 3:[224,0,0] 4:[288,0,0] + 5:[352,0,0] 6:[416,0,0] 7:[480,0,0] 8:[544,0,0] + 9:[608,0,0] 10:[672,0,0] 11:[736,0,0] 12:[800,0,0] + ... + 85:[5792,9,0xff80000000000000] +---- + +Most of the inode chunks on this filesystem are totally full, since the +free+ +value is zero. This means that we ought to expect inode 160 to be linked +somewhere in the directory structure. However, notice that 0xff80000000000000 +in record 85 -- this means that we would expect inode 5856 to be free. Moving +on to the free inode B+tree, we see that this is indeed the case: + +---- +xfs_db> addr free_root +xfs_db> p +magic = 0x46494233 +level = 0 +numrecs = 1 +leftsib = null +rightsib = null +bno = 32 +lsn = 0x1000032c2 +uuid = 3dfa1e5c-5a5f-4ca2-829a-000e453600fe +owner = 0 +crc = 0x338af88a (correct) +recs[1] = [startino,freecount,free] 1:[5792,9,0xff80000000000000] +---- + +Observe also that the AGI's +agi_newino+ points to this chunk, which has never +been fully allocated. [[Real-time_Devices]] == Real-time Devices
design/XFS_Filesystem_Structure/data_extents.asciidoc +40 -1
44 lines not on this page · raw message
design/XFS_Filesystem_Structure/directories.asciidoc +54 -1
62 lines not on this page · raw message
design/XFS_Filesystem_Structure/docinfo.xml +1 -0
@@ -83,6 +83,7 @@ <simplelist> <member>Miscellaneous fixes.</member> <member>Add missing field definitions.</member> + <member>Add some missing xfs_db examples.</member> </simplelist> </revdescription> </revision>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 11/21 xfsdocs: fix quoted text markings
In reply to Darrick J. WongUse asciidoc quotes for quoted strings.
--- .../allocation_groups.asciidoc | 24 ++--- .../XFS_Filesystem_Structure/data_extents.asciidoc | 4 - .../XFS_Filesystem_Structure/directories.asciidoc | 98 ++++++++++---------- .../extended_attributes.asciidoc | 26 +++-- .../internal_inodes.asciidoc | 2 .../XFS_Filesystem_Structure/ondisk_inode.asciidoc | 32 +++---- .../symbolic_links.asciidoc | 8 +- 7 files changed, 97 insertions(+), 97 deletions(-)
design/XFS_Filesystem_Structure/allocation_groups.asciidoc +12 -12
@@ -93,7 +93,7 @@ struct xfs_sb }; ---- *sb_magicnum*:: -Identifies the filesystem. Its value is +XFS_SB_MAGIC = 0x58465342 "XFSB"+. +Identifies the filesystem. Its value is +XFS_SB_MAGIC+ ``XFSB'' (0x58465342). *sb_blocksize*:: The size of a basic unit of space allocation in bytes. Typically, this is 4096
@@ -269,7 +269,7 @@ Miscellaneous flags. |===== *sb_shared_vn*:: -Reserved and must be zero ("vn" stands for version number). +Reserved and must be zero (``vn'' stands for version number). *sb_inoalignmt*:: Inode chunk alignment in fsblocks.
@@ -413,8 +413,8 @@ All block numbers, indexes, and counts are AG relative. === AG Free Space Block The second sector in an AG contains the information about the two free space -B+trees and associated free space information for the AG. The "AG Free Space -Block", also knows as the +AGF+, uses the following structure: +B+trees and associated free space information for the AG. The ``AG Free Space +Block'' also knows as the +AGF+, uses the following structure: [source, c] ----
@@ -441,7 +441,7 @@ index 0 for the free space B+tree indexed by block number; and index 1 for the free space B+tree indexed by extent size. *agf_magicnum*:: -Specifies the magic number for the AGF sector: "XAGF" (0x58414746). +Specifies the magic number for the AGF sector: ``XAGF'' (0x58414746). *agf_versionnum*:: Set to +XFS_AGF_VERSION+ which is currently 1.
@@ -460,17 +460,17 @@ Specifies the block number for the root of the two free space B+trees. *agf_levels*:: Specifies the level or depth of the two free space B+trees. For a fresh AG, this -will be one, and the "roots" will point to a single leaf of level 0. +will be one, and the ``roots'' will point to a single leaf of level 0. *agf_flfirst*:: -Specifies the index of the first "free list" block. Free lists are covered in +Specifies the index of the first ``free list'' block. Free lists are covered in more detail later on. *agf_fllast*:: -Specifies the index of the last "free list" block. +Specifies the index of the last ``free list'' block. *agf_flcount*:: -Specifies the number of blocks in the "free list". +Specifies the number of blocks in the ``free list''. *agf_freeblks*:: Specifies the current number of free blocks in the AG.
@@ -551,8 +551,8 @@ typedef __be32 xfs_alloc_ptr_t; * As the free space tracking is AG relative, all the block numbers are only 32-bits. -* The +bb_magic+ value depends on the B+tree: "ABTB" (0x41425442) for the block -offset B+tree, "ABTC" (0x41425443) for the block count B+tree. +* The +bb_magic+ value depends on the B+tree: ``ABTB'' (0x41425442) for the block +offset B+tree, ``ABTC'' (0x41425443) for the block count B+tree. * The +xfs_btree_sblock_t+ header is used for intermediate B+tree node as well as the leaves. * For a typical 4KB filesystem block size, the offset for the +xfs_alloc_ptr_t+
@@ -741,7 +741,7 @@ struct xfs_agi { } ---- *agi_magicnum*:: -Specifies the magic number for the AGI sector: "XAGI" (0x58414749). +Specifies the magic number for the AGI sector: ``XAGI'' (0x58414749). *agi_versionnum*:: Set to +XFS_AGI_VERSION+ which is currently 1.
design/XFS_Filesystem_Structure/data_extents.asciidoc +2 -2
@@ -3,7 +3,7 @@ XFS manages space using extents, which are defined as a starting location and length. A fork in an XFS inode maps a logical offset to a space extent. This -enables a file's extent map to support sparse files (i.e. "holes" in the file). +enables a file's extent map to support sparse files (i.e. ``holes'' in the file). A flag is also used to specify if the extent has been preallocated but has not yet been written (unwritten extent).
@@ -259,7 +259,7 @@ struct xfs_btree_lblock { ---- *bb_magic*:: -Specifies the magic number for the BMBT block: "BMAP" (0x424d4150). +Specifies the magic number for the BMBT block: ``BMAP'' (0x424d4150). *bb_level*:: The level of the tree in which this block is found. If this value is 0, this
design/XFS_Filesystem_Structure/directories.asciidoc +49 -49
275 lines not on this page · raw message
design/XFS_Filesystem_Structure/extended_attributes.asciidoc +13 -13
@@ -26,8 +26,8 @@ To view extended attributes from the command line, use the +getfattr+ command. To set or delete extended attributes, use the +setfattr+ command. ACLs control should use the +getfacl+ and +setfacl+ commands. -XFS attributes supports three namespaces: "user", "trusted" (or "root" using -IRIX terminology), and "secure". +XFS attributes supports three namespaces: ``user'', ``trusted'' (or ``root'' using +IRIX terminology), and ``secure''. See the section about xref:Extended_Attribute_Versions[extended attributes] in the inode for instructions on how to calculate the location of the attributes.
@@ -39,7 +39,7 @@ The following four sections describe each of the on-disk formats. == Short Form Attributes When the all extended attributes can fit within the inode's attribute fork, the -inode's +di_aformat+ is set to "local" and the attributes are stored in the +inode's +di_aformat+ is set to ``local'' and the attributes are stored in the inode's literal area starting at offset +di_forkoff × 8+. Shortform attributes use the following structures:
@@ -85,9 +85,9 @@ A combination of the following: [options="header"] |===== | Flag | Description -| 0 | The attribute's namespace is "user". -| +XFS_ATTR_ROOT+ | The attribute's namespace is "trusted". -| +XFS_ATTR_SECURE+ | The attribute's namespace is "secure". +| 0 | The attribute's namespace is ``user''. +| +XFS_ATTR_ROOT+ | The attribute's namespace is ``trusted''. +| +XFS_ATTR_SECURE+ | The attribute's namespace is ``secure''. | +XFS_ATTR_INCOMPLETE+ | This attribute is being modified. | +XFS_ATTR_LOCAL+ | The attribute value is contained within this block. |=====
@@ -314,10 +314,10 @@ an inode before they are moved to another filesystem block. == Leaf Attributes When an inode's attribute fork space is used up with shortform attributes and -more are added, the attribute format is migrated to "extents". +more are added, the attribute format is migrated to ``extents''. Extent based attributes use hash/index pairs to speed up an attribute lookup. -The first part of the "leaf" contains an array of fixed size hash/index pairs +The first part of the ``leaf'' contains an array of fixed size hash/index pairs with the flags stored as well. The remaining part of the leaf block contains the array name/value pairs, where each element varies in length.
@@ -486,7 +486,7 @@ appropriate structure can be used. Since duplicate hash keys are possible, for each hash that matches during a lookup, the actual name string must be compared. -An "incomplete" bit is also used for attribute flags. It shows that an attribute +An ``incomplete'' bit is also used for attribute flags. It shows that an attribute is in the middle of being created and should not be shown to the user if we crash during the time that the bit is set. The bit is cleared when attribute has finished being set up. This is done because some large attributes cannot
@@ -635,7 +635,7 @@ image::images/72.png[] === xfs_db Node Attribute Example -An inode with 1000 small attributes with the naming "attribute_n" where 'n' is a +An inode with 1000 small attributes with the naming ``attribute_n'' where 'n' is a number: ----
@@ -677,7 +677,7 @@ The hashes are in ascending order in the btree array, and if the hash for the attribute we are looking up is before the entry, we go to the addressed attribute block. -For example, to lookup attribute "attribute_267": +For example, to lookup attribute ``attribute_267'': ---- xfs_db> hash attribute_267
@@ -745,7 +745,7 @@ nvlist[84].value = "value_266\d" Each of the hash entries has +XFS_ATTR_LOCAL+ flag set (1), which means the attribute's value follows immediately after the name. Raw disk of the name/value -pair at offset 2864 (0xb30), highlighted with "value_267\d" following +pair at offset 2864 (0xb30), highlighted with ``value_267'' following immediately after the name: [subs="quotes"]
@@ -768,7 +768,7 @@ has 2 unused bytes after it. == B+tree Attributes When the attribute's extent map in an inode grows beyond the available space, -the inode's attribute format is changed to a "btree". The inode contains root +the inode's attribute format is changed to a ``btree''. The inode contains root node of the extent B+tree which then address the leaves that contains the extent arrays for the attribute data. The attribute data itself in the allocated filesystem blocks use the same layout and structures as described in
design/XFS_Filesystem_Structure/internal_inodes.asciidoc +1 -1
@@ -65,7 +65,7 @@ struct xfs_dqblk { *d_magic*:: Specifies the signature where these two bytes are 0x4451 (+XFS_DQUOT_MAGIC+), -or "DQ" in ASCII. +or ``DQ'' in ASCII. *d_version*:: The structure version, currently this is 1 (+XFS_DQUOT_VERSION+).
design/XFS_Filesystem_Structure/ondisk_inode.asciidoc +16 -16
@@ -15,7 +15,7 @@ image::images/23.png[] * The core contains what the inode represents, stat data, and information describing the data and attribute forks. -* The +di_u+ "data fork" contains normal data related to the inode. Its contents +* The +di_u+ ``data fork'' contains normal data related to the inode. Its contents depends on the file type specified by +di_core.di_mode+ (eg. regular file, directory, link, etc) and how much information is contained in the file which determined by +di_core.di_format+. The following union to represent this data is
@@ -34,7 +34,7 @@ union { } di_u; ---- -* The +di_a+ "attribute fork" contains extended attributes. Its layout is +* The +di_a+ ``attribute fork'' contains extended attributes. Its layout is determined by the +di_core.di_aformat+ value. Its representation is declared as follows:
@@ -54,7 +54,7 @@ within the union are directly cast depending on the +di_mode/di_format+ and explain the various structures in use within the inode. The remaining space in the inode after +di_next_unlinked+ where the two forks -are located is called the inode's "literal area". This starts at offset 100 +are located is called the inode's ``literal area''. This starts at offset 100 (0x64) in the inode. The space for each of the two forks in the literal area is determined by the
@@ -103,7 +103,7 @@ struct xfs_dinode_core { ---- *di_magic*:: -The inode signature; these two bytes are 0x494e, or "IN" in ASCII. +The inode signature; these two bytes are ``IN'' (0x494e). *di_mode*:: Specifies the mode access bits and type of file using the standard S_Ixxx values
@@ -117,13 +117,13 @@ converted on the fly to v2 when required. *di_format*:: Specifies the format of the data fork in conjunction with the +di_mode+ type. -This can be one of several values. For directories and links, it can be "local" -where all metadata associated with the file is within the inode; "extents" where +This can be one of several values. For directories and links, it can be ``local'' +where all metadata associated with the file is within the inode; ``extents'' where the inode contains an array of extents to other filesystem blocks which contain -the associated metadata or data; or "btree" where the inode contains a B+tree +the associated metadata or data; or ``btree'' where the inode contains a B+tree root node which points to filesystem blocks containing the metadata or data. Migration between the formats depends on the amount of metadata associated with -the inode. "dev" is used for character and block devices while "uuid" is +the inode. ``dev'' is used for character and block devices while ``uuid'' is currently not used. [source, c]
@@ -171,7 +171,7 @@ Incremented on flush. Specifies the last access time of the files using UNIX time conventions the following structure. This value may be undefined if the filesystem is mounted -with the "noatime" option. XFS supports timestamps with nanosecond resolution: +with the ``noatime'' option. XFS supports timestamps with nanosecond resolution: [source, c] ----
@@ -226,7 +226,7 @@ details. *di_aformat*:: Specifies the format of the attribute fork. This uses the same values as -+di_format+, but restricted to "local", "extents" and "btree" formats for ++di_format+, but restricted to ``local'', ``extents'' and ``btree'' formats for extended attribute data. *di_dmevmask*::
@@ -312,10 +312,10 @@ image::images/28.png[] The structure of the inode's data fork based is on the inode's type and +di_format+. It always starts at offset 100 (0x64) in the inode's space which is -the start of the inode's "literal area". The size of the data fork is determined +the start of the inode's ``literal area''. The size of the data fork is determined by the type and format. The maximum size is determined by the inode size and +di_forkoff+. In code, use the +XFS_DFORK_PTR+ macro specifying +XFS_DATA_FORK+ -for the "which" parameter. Alternatively, the +XFS_DFORK_DPTR+ macro can be +for the ``which'' parameter. Alternatively, the +XFS_DFORK_DPTR+ macro can be used. Each of the following sub-sections summarises the contents of the data fork
@@ -403,7 +403,7 @@ does not contain any extended attributes. If non-zero, the attribute fork's byte offset into the literal area can be computed from +di_forkoff × 8+. Attributes must be allocated on a 64-bit boundary on the disk. To access the extended attributes in code, use the +XFS_DFORK_PTR+ macro specifying -+XFS_ATTR_FORK+ for the "which" parameter. Alternatively, the +XFS_DFORK_APTR+ ++XFS_ATTR_FORK+ for the ``which'' parameter. Alternatively, the +XFS_DFORK_APTR+ macro can be used. The structure of the attribute fork depends on the +di_aformat+ value
@@ -429,13 +429,13 @@ xref:Extended_Attributes[Extended Attributes] in this document. [[Extended_Attribute_Versions]] === Extended Attribute Versions -Extended attributes come in two versions: "attr1" or "attr2". The attribute +Extended attributes come in two versions: ``attr1'' or ``attr2''. The attribute version is specified by the +XFS_SB_VERSION2_ATTR2BIT+ flag in the +sb_features2+ field in the superblock. It determines how the inode's extra space is split between +di_u+ and +di_a+ forks which also determines how the +di_forkoff+ value is maintained in the inode's core. -With "attr1" attributes, the +di_forkoff+ is set to somewhere in the middle of +With ``attr1'' attributes, the +di_forkoff+ is set to somewhere in the middle of the space between the core and end of the inode and never changes (which has the effect of artificially limiting the space for data information). As the data fork grows, when it gets to +di_forkoff+, it will move the data to the next
@@ -443,7 +443,7 @@ format level (ie. local < extent < btree). If very little space is used for either attributes or data, then a good portion of the available inode space is wasted with this version. -"Attr2" was introduced to maximum the utilisation of the inode's literal area. +``attr2'' was introduced to maximum the utilisation of the inode's literal area. The +di_forkoff+ starts at the end of the inode and works its way to the data fork as attributes are added. Attr2 is highly recommended if extended attributes are used.
design/XFS_Filesystem_Structure/symbolic_links.asciidoc +4 -4
@@ -1,15 +1,15 @@ [[Symbolic_Links]] = Symbolic Links -Symbolic links to a file can be stored in one of two formats: "local" and -"extents". The length of the symlink contents is always specified by the inode's +Symbolic links to a file can be stored in one of two formats: ``local'' and +``extents''. The length of the symlink contents is always specified by the inode's +di_size+ value. [[Shortform_Symbolic_Links]] == Short Form Symbolic Links -Symbolic links are stored with the "local" +di_format+ if the symbolic link can +Symbolic links are stored with the ``local'' +di_format+ if the symbolic link can fit within the inode's data fork. The link data is an array of characters (+di_symlink+ array in the data fork union).
@@ -58,7 +58,7 @@ xfs_db> p If the length of the symbolic link exceeds the space available in the inode's data fork, the link is moved to a new filesystem block and the inode's -+di_format+ is changed to "extents". The location of the block(s) is specified ++di_format+ is changed to ``extents''. The location of the block(s) is specified by the data fork's +di_bmx[]+ array. In the significant majority of cases, this will be in one filesystem block as a symlink cannot be longer than 1024 characters.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 12/21 xfsdocs: introduce XFS at a high level
In reply to Darrick J. WongProvide a quick overview of the history and design goals of XFS, and specify what exactly this documentation aims to do.
--- .../allocation_groups.asciidoc | 9 +++-- design/XFS_Filesystem_Structure/docinfo.xml | 3 +- design/XFS_Filesystem_Structure/overview.asciidoc | 38 ++++++++++++++++++++ .../xfs_filesystem_structure.asciidoc | 31 +++++++++++++--- 4 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 design/XFS_Filesystem_Structure/overview.asciidoc
design/XFS_Filesystem_Structure/allocation_groups.asciidoc +5 -4
@@ -1,10 +1,11 @@ [[Allocation_Groups]] = Allocation Groups -XFS filesystems are divided into a number of equally sized chunks called -Allocation Groups. Each AG can almost be thought of as an individual filesystem -that maintains its own space usage. Each AG can be up to one terabyte in size -(512 bytes × 2^31^), regardless of the underlying device's sector size. +As mentioned earlier, XFS filesystems are divided into a number of equally +sized chunks called Allocation Groups. Each AG can almost be thought of as an +individual filesystem that maintains its own space usage. Each AG can be up to +one terabyte in size (512 bytes × 2^31^), regardless of the underlying device's +sector size. Each AG has the following characteristics:
design/XFS_Filesystem_Structure/docinfo.xml +2 -1
@@ -1,7 +1,7 @@ <subtitle>3rd Edition</subtitle> <!-- <abstract> - <para>This book documents the XFS Filesystem Structure</para> + <para>This book documents the on-disk structure of the XFS filesystem.</para> </abstract> --> <corpauthor>
@@ -84,6 +84,7 @@ <member>Miscellaneous fixes.</member> <member>Add missing field definitions.</member> <member>Add some missing xfs_db examples.</member> + <member>Add an overview of XFS.</member> </simplelist> </revdescription> </revision>
design/XFS_Filesystem_Structure/overview.asciidoc new file +38 -0
@@ -0,0 +1,38 @@ += Overview + +XFS presents to users a standard Unix filesystem interface: a rooted +tree of directories, files, symbolic links, and devices. All five of those +entities are represented inside the filesystem by an index node, or ``inode''; +each node is uniquely referenced by an inode number. Directories consist of +(name, inode number) tuples and it is possible for multiple tuples to contain +the same inode number. Data blocks are associated with files by means of a +block map in each index node. It is also possible to attach (key, value) +tuples to any index node; these are known as ``extended attributes'', which +extend beyond the standard Unix file attributes. + +Internally, XFS filesystems are divided into a number of equally sized chunks +called Allocation Groups. Each AG can almost be thought of as an individual +filesystem that maintains its own space usage, index nodes, and other secondary +metadata. Having multiple AGs allows XFS to handle most operations in parallel +without degrading performance as the number of concurrent accesses increases. +Each allocation group uses multiple B+trees to maintain bookkeeping records +such as the locations of free blocks, the locations of allocated inodes, and +the locations of free inodes. + +Files, symbolic links, and directories can have up to two block maps, or +``forks'', which associate filesystems blocks with a particular file or +directory. The ``attribute fork'' tracks blocks used to store and index +extended attributes, whereas the ``data fork'' tracks file data blocks, +symbolic link targets, or directory blocks, depending on the type of the inode +record. Both forks associate a logical offset with an extent of physical +blocks, which makes sparse files and directories possible. Directory entries +and extended attributes are contained inside a second-level data structure +within the blocks that are mapped by the forks. This structure consists of +variable-length directory or attribute records and possible a second B+tree to +index these records. + +XFS employs a journalling log in which metadata changes are collected so that +filesystem operations can be carried out atomically in the case of a crash. +Furthermore, there is the concept of a real-time device wherein allocations are +tracked more simply and in larger chunks to reduce jitter in allocation +latency.
design/XFS_Filesystem_Structure/xfs_filesystem_structure.asciidoc +25 -6
@@ -16,17 +16,36 @@ High Level Design [partintro] -- -This document describes the layout of an XFS filesystem. - -It shows how to manually inspect it by showing examples using the xfs_db -user-space tool supplied with the XFS filesystem driver. - -TODO: More description. +XFS is a high performance filesystem which was designed to maximize parallel +throughput and to scale up to extremely large 64-bit storage systems. +Originally developed by SGI in October 1993 for IRIX, XFS can handle large +files, large filesystems, many inodes, large directories, large file +attributes, and large allocations. Filesystems are optimized for parallel +access by splitting the storage device into semi-autonomous allocation groups. +XFS employs branching trees (B+ trees) to facilitate fast searches of large +lists; it also uses delayed extent-based allocation to improve data contiguity +and IO performance. + +This document describes the on-disk layout of an XFS filesystem and how to use +the debugging tools +xfs_db+ and +xfs_logprint+ to inspect the metadata +structures. It also describes how on-disk metadata relates to the higher level +design goals. + +The information contained in this document derives from the XFS source code in +the Linux kernel as of v4.3. This book's source code is available at ++git://git.kernel.org/pub/scm/fs/xfs/xfs-documentation.git+. Feedback should +be sent to the XFS mailing list, currently at [email protected]+. + +[NOTE] +All fields in XFS metadata structures are in big-endian byte order except for +log items which are formatted in host order. -- // Push titles down one level :leveloffset: 1 +include::overview.asciidoc[] + include::common_types.asciidoc[] // return titles to normal
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 13/21 xfsdocs: document the xfs log format
In reply to Darrick J. WongDiscuss the on-disk log format and provide an example of walking through the log with xfs_logprint.
--- design/XFS_Filesystem_Structure/docinfo.xml | 1 .../journaling_log.asciidoc | 836 ++++++++++++++++++++ 2 files changed, 836 insertions(+), 1 deletion(-)
design/XFS_Filesystem_Structure/docinfo.xml +1 -0
@@ -85,6 +85,7 @@ <member>Add missing field definitions.</member> <member>Add some missing xfs_db examples.</member> <member>Add an overview of XFS.</member> + <member>Document the journal format.</member> </simplelist> </revdescription> </revision>
design/XFS_Filesystem_Structure/journaling_log.asciidoc +835 -1
838 lines not on this page · raw message
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 14/21 xfsdocs: document the operation of the realtime device and inodes
In reply to Darrick J. Wong--- .../allocation_groups.asciidoc | 17 +++++++++- design/XFS_Filesystem_Structure/docinfo.xml | 1 + .../internal_inodes.asciidoc | 35 +++++++++++--------- 3 files changed, 36 insertions(+), 17 deletions(-)
design/XFS_Filesystem_Structure/allocation_groups.asciidoc +15 -2
@@ -909,5 +909,18 @@ been fully allocated. [[Real-time_Devices]] == Real-time Devices -TODO - +The performance of the standard XFS allocator varies depending on the internal +state of the various metadata indices enabled on the filesystem. For +applications which need to minimize the jitter of allocation latency, XFS +supports the notion of a ``real-time device''. This is a special device +separate from the regular filesystem where extent allocations are tracked with +a bitmap and free space is indexed with a two-dimensional array. If an inode +is flagged with +XFS_DIFLAG_REALTIME+, its data will live on the real time +device. The metadata for real time devices is discussed in the section about +xref:Real-time_Inodes[real time inodes]. + +By placing the real time device (and the journal) on separate high-performance +storage devices, it is possible to reduce most of the unpredictability in I/O +response times that come from metadata operations. + +None of the XFS per-AG B+trees are involved with real time files.
design/XFS_Filesystem_Structure/docinfo.xml +1 -0
@@ -86,6 +86,7 @@ <member>Add some missing xfs_db examples.</member> <member>Add an overview of XFS.</member> <member>Document the journal format.</member> + <member>Document the realtime device.</member> </simplelist> </revdescription> </revision>
design/XFS_Filesystem_Structure/internal_inodes.asciidoc +20 -15
@@ -160,24 +160,29 @@ Bitmap Inode and the Summary Inode. [[Real-Time_Bitmap_Inode]] === Real-Time Bitmap Inode -The Bitmap Inode tracks the used/free space in the real-time device using an -old-style bitmap. One bit is allocated per real-time extent. The size of an -extent is specified by the superblock's +sb_rextsize+ value. +The real time bitmap inode, +sb_rbmino+, tracks the used/free space in the +real-time device using an old-style bitmap. One bit is allocated per real-time +extent. The size of an extent is specified by the superblock's +sb_rextsize+ +value. The number of blocks used by the bitmap inode is equal to the number of -real-time extents (+sb_rextents+) divided by the block size (+sb_blocksize+) and -bits per byte. This value is stored in +sb_rbmblocks+. The nblocks and extent -array for the inode should match this. - -[source, c] - xfs_ino_t sb_rbmino; +real-time extents (+sb_rextents+) divided by the block size (+sb_blocksize+) +and bits per byte. This value is stored in +sb_rbmblocks+. The nblocks and +extent array for the inode should match this. Each real time block gets its +own bit in the bitmap. [[Real-Time_Summary_Inode]] === Real-Time Summary Inode -The Summary Inode keeps the used/free space accounting information for the -real-time device. - -[source, c] - xfs_ino_t sb_rsumino; - +The real time summary inode, +sb_rsumino+, tracks the used and free space +accounting information for the real-time device. This file indexes the +approximate location of each free extent on the real-time device first by +log2(extent size) and then by the real-time bitmap block number. The size of +the summary inode file is equal to +sb_rbmblocks+ × log2(realtime device size) +× sizeof(+xfs_suminfo_t+). The entry for a given log2(extent size) and +rtbitmap block number is 0 if there is no free extents of that size at that +rtbitmap location, and positive if there are any. + +This data structure is not particularly space efficient, however it is a very +fast way to provide the same data as the two free space B+trees for regular +files since the space is preallocated and metadata maintenance is minimal.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 15/21 xfsdocs: add documentation of v5 fields
In reply to Darrick J. WongDocument the new fields and data structures added in XFS v5 filesystems.
--- .../allocation_groups.asciidoc | 223 +++++++++++++++++++ .../XFS_Filesystem_Structure/data_extents.asciidoc | 35 +++ .../XFS_Filesystem_Structure/directories.asciidoc | 230 +++++++++++++++++++- design/XFS_Filesystem_Structure/docinfo.xml | 16 + .../extended_attributes.asciidoc | 81 +++++++ .../internal_inodes.asciidoc | 15 + .../XFS_Filesystem_Structure/ondisk_inode.asciidoc | 62 +++++ .../symbolic_links.asciidoc | 45 ++++ 8 files changed, 675 insertions(+), 32 deletions(-)
design/XFS_Filesystem_Structure/allocation_groups.asciidoc +214 -9
@@ -40,8 +40,6 @@ superblock is one sector in length. The superblock is defined by the following structure. The description of each field follows. -TODO: update for v5 formats. - [source, c] ---- struct xfs_sb
@@ -91,6 +89,20 @@ struct xfs_sb __uint16_t sb_logsectsize; __uint32_t sb_logsunit; __uint32_t sb_features2; + __uint32_t sb_bad_features2; + + /* version 5 superblock fields start here */ + __uint32_t sb_features_compat; + __uint32_t sb_features_ro_compat; + __uint32_t sb_features_incompat; + __uint32_t sb_features_log_incompat; + + __uint32_t sb_crc; + xfs_extlen_t sb_spino_align; + + xfs_ino_t sb_pquotino; + xfs_lsn_t sb_lsn; + uuid_t sb_meta_uuid; }; ---- *sb_magicnum*::
@@ -152,8 +164,8 @@ Number of blocks for the journaling log. Filesystem version number. This is a bitmask specifying the features enabled when creating the filesystem. Any disk checking tools or drivers that do not recognize any set bits must not operate upon the filesystem. Most of the flags -indicate features introduced over time. If the value of the lower nibble is 4, -the higher bits indicate feature flags as follows: +indicate features introduced over time. If the value of the lower nibble is >= +4, the higher bits indicate feature flags as follows: .Version 4 Superblock version flags [options="header"]
@@ -178,13 +190,17 @@ Version 2 directories are used. This is always set. Set if the sb_features2 field in the superblock contains more flags. |===== +If the lower nibble of this value is 5, then this is a v5 filesystem; the ++XFS_SB_VERSION2_CRCBIT+ feature must be set in +sb_features2+. + *sb_sectsize*:: Specifies the underlying disk sector size in bytes. Typically this is 512 or 4096 bytes. This determines the minimum I/O alignment, especially for direct I/O. *sb_inodesize*:: Size of the inode in bytes. The default is 256 (2 inodes per standard sector) -but can be made as large as 2048 bytes when creating the filesystem. +but can be made as large as 2048 bytes when creating the filesystem. On a v5 +filesystem, the default inode size is 512 bytes. *sb_inopblock*:: Number of inodes per block. This is equivalent to +sb_blocksize / sb_inodesize+.
@@ -324,12 +340,81 @@ its parent inode. The primary purpose for this information is in backup systems. can be used to enforce disk space usage quotas for a particular group of directories. This flag indicates that project IDs can be 32 bits in size. +| +XFS_SB_VERSION2_CRCBIT+ | +Metadata checksumming. All metadata blocks have an extended header containing +the block checksum, a copy of the metadata UUID, the log sequence number of the +last update to prevent stale replays, and a back pointer to the owner of the +block. This feature must be and can only be set if the lowest nibble of ++sb_versionnum+ is set to 5. + | +XFS_SB_VERSION2_FTYPE+ | Directory file type. Each directory entry records the type of the inode to which the entry points. This speeds up directory iteration by removing the need to load every inode into memory. |===== +*sb_bad_features2*:: +This field mirrors +sb_features2+, due to past 64-bit alignment errors. + +*sb_features_compat*:: +Read-write compatible feature flags. The kernel can still read and write this +FS even if it doesn't understand the flag. Currently, there are no valid +flags. + +*sb_features_ro_compat*:: +Read-only compatible feature flags. The kernel can still read this FS even if +it doesn't understand the flag. + +.Extended Version 5 Superblock Read-Only compatibility flags +[options="header"] +|===== +| Flag | Description +| +XFS_SB_FEAT_RO_COMPAT_FINOBT+ | +Free inode B+tree. Each allocation group contains a B+tree to track inode chunks +containing free inodes. This is a performance optimization to reduce the time +required to allocate inodes. +|===== + +*sb_features_incompat*:: +Read-write incompatible feature flags. The kernel cannot read or write this +FS if it doesn't understand the flag. + +.Extended Version 5 Superblock Read-Write incompatibility flags +[options="header"] +|===== +| Flag | Description +| +XFS_SB_FEAT_INCOMPAT_FTYPE+ | +Directory file type. Each directory entry tracks the type of the inode to +which the entry points. This is a performance optimization to remove the need +to load every inode into memory to iterate a directory. + +| +XFS_SB_FEAT_INCOMPAT_META_UUID+ | +Metadata UUID. The UUID stamped into each metadata block must match the value +in +sb_meta_uuid+. This enables the administrator to change +sb_uuid+ at will +without having to rewrite the entire filesystem. +|===== + +*sb_features_log_incompat*:: +Read-write incompatible feature flags for the log. The kernel cannot read or +write this FS log if it doesn't understand the flag. Currently, no flags are +defined. + +*sb_crc*:: +Superblock checksum. + +*sb_spino_align*:: +Sparse inode alignment. + +*sb_pquotino*:: +Project quota inode. + +*sb_lsn*:: +Log sequence number of the last superblock update. + +*sb_meta_uuid*:: +If the +XFS_SB_FEAT_INCOMPAT_META_UUID+ feature is set, then the UUID field in +all metadata blocks must match this UUID. If not, the block header UUID field +must match +sb_uuid+. === xfs_db Superblock Example
@@ -405,7 +490,7 @@ features2 = 8 The XFS filesystem tracks free space in an allocation group using two B+trees. One B+tree tracks space by block number, the second by the size of the free -space block. This scheme allows XFS to quickly find free space near a given +space block. This scheme allows XFS to find quickly free space near a given block or of a given size. All block numbers, indexes, and counts are AG relative.
@@ -434,6 +519,15 @@ struct xfs_agf { __be32 agf_freeblks; __be32 agf_longest; __be32 agf_btreeblks; + + /* version 5 filesystem fields start here */ + uuid_t agf_uuid; + __be64 agf_spare64[16]; + + /* unlogged fields, written during buffer writeback. */ + __be64 agf_lsn; + __be32 agf_crc; + __be32 agf_spare2; }; ----
@@ -483,6 +577,22 @@ Specifies the number of blocks of longest contiguous free space in the AG. Specifies the number of blocks used for the free space B+trees. This is only used if the +XFS_SB_VERSION2_LAZYSBCOUNTBIT+ bit is set in +sb_features2+. +*agf_uuid*:: +The UUID of this block, which must match either +sb_uuid+ or +sb_meta_uuid+ +depending on which features are set. + +*agf_spare64*:: +Empty space in the logged part of the AGF sector, for use for future features. + +*agf_lsn*:: +Log sequence number of the last AGF write. + +*agf_crc*:: +Checksum of the AGF sector. + +*agf_spare2*:: +Empty space in the unlogged part of the AGF sector. + [[Short_Format_Btrees]] === Short Format B+trees
@@ -499,6 +609,13 @@ struct xfs_btree_sblock { __be16 bb_numrecs; __be32 bb_leftsib; __be32 bb_rightsib; + + /* version 5 filesystem fields start here */ + __be64 bb_blkno; + __be64 bb_lsn; + uuid_t bb_uuid; + __be32 bb_owner; + __le32 bb_crc; }; ----
@@ -519,6 +636,22 @@ AG block number of the left sibling of this B+tree node. *bb_rightsib*:: AG block number of the right sibling of this B+tree node. +*bb_blkno*:: +FS block number of this B+tree block. + +*bb_lsn*:: +Log sequence number of the last write to this block. + +*bb_uuid*:: +The UUID of this block, which must match either +sb_uuid+ or +sb_meta_uuid+ +depending on which features are set. + +*bb_owner*:: +The AG number that this B+tree block ought to be in. + +*bb_crc*:: +Checksum of the B+tree block. + [[AG_Free_Space_Btrees]] === AG Free Space B+trees
@@ -553,7 +686,9 @@ typedef __be32 xfs_alloc_ptr_t; * As the free space tracking is AG relative, all the block numbers are only 32-bits. * The +bb_magic+ value depends on the B+tree: ``ABTB'' (0x41425442) for the block -offset B+tree, ``ABTC'' (0x41425443) for the block count B+tree. +offset B+tree, ``ABTC'' (0x41425443) for the block count B+tree. On a v5 +filesystem, these are ``AB3B'' (0x41423342) and ``AB3C'' (0x41423343), +respectively. * The +xfs_btree_sblock_t+ header is used for intermediate B+tree node as well as the leaves. * For a typical 4KB filesystem block size, the offset for the +xfs_alloc_ptr_t+
@@ -595,6 +730,38 @@ Active elements in the array are specified by the xref:AG_Free_Space_Block[AGF's] +agf_flfirst+, +agf_fllast+ and +agf_flcount+ values. The array is managed as a circular list. +On a v5 filesystem, the following header precedes the free list entries: + +[source, c] +---- +struct xfs_agfl { + __be32 agfl_magicnum; + __be32 agfl_seqno; + uuid_t agfl_uuid; + __be64 agfl_lsn; + __be32 agfl_crc; +}; +---- + +*agfl_magicnum*:: +Specifies the magic number for the AGFL sector: "XAFL" (0x5841464c). + +*agfl_seqno*:: +Specifies the AG number for the sector. + +*agfl_uuid*:: +The UUID of this block, which must match either +sb_uuid+ or +sb_meta_uuid+ +depending on which features are set. + +*agfl_lsn*:: +Log sequence number of the last AGFL write. + +*agfl_crc*:: +Checksum of the AGFL sector. + +On a v4 filesystem there is no header; the array of free block numbers begins +at the beginning of the sector. + .AG Free List layout image::images/16.png[]
@@ -739,6 +906,18 @@ struct xfs_agi { __be32 agi_newino; __be32 agi_dirino; __be32 agi_unlinked[64]; + + /* + * v5 filesystem fields start here; this marks the end of logging region 1 + * and start of logging region 2. + */ + uuid_t agi_uuid; + __be32 agi_crc; + __be32 agi_pad32; + __be64 agi_lsn; + + __be32 agi_free_root; + __be32 agi_free_level; } ---- *agi_magicnum*::
@@ -775,19 +954,45 @@ Deprecated and not used, this is always set to NULL (-1). Hash table of unlinked (deleted) inodes that are still being referenced. Refer to xref:Unlinked_Pointer[unlinked list pointers] for more information. +*agi_uuid*:: +The UUID of this block, which must match either +sb_uuid+ or +sb_meta_uuid+ +depending on which features are set. + +*agi_crc*:: +Checksum of the AGI sector. + +*agi_pad32*:: +Padding field, otherwise unused. + +*agi_lsn*:: +Log sequence number of the last write to this block. + +*agi_free_root*:: +Specifies the block number in the AG containing the root of the free inode +B+tree. + +*agi_free_level*:: +Specifies the number of levels in the free inode B+tree. [[Inode_Btrees]] == Inode B+trees Inodes are allocated in chunks of 64, and a B+tree is used to track these chunks of inodes as they are allocated and freed. The block containing root of the -B+tree is defined by the AGI's +agi_root+ value. +B+tree is defined by the AGI's +agi_root+ value. If the ++XFS_SB_FEAT_RO_COMPAT_FINOBT+ feature is enabled, a second B+tree is used to +track the chunks containing free inodes; this is an optimization to speed up +inode allocation. The B+tree header for the nodes and leaves use the +xfs_btree_sblock+ structure which is the same as the header used in the xref:AG_Free_Space_Btrees[AGF B+trees]. -The magic number of the inode B+tree is ``IABT'' (0x49414254). +The magic number of the inode B+tree is ``IABT'' (0x49414254). On a v5 +filesystem, the magic number is ``IAB3'' (0x49414233). + +The magic number of the free inode B+tree is ``FIBT'' (0x46494254). On a v5 +filesystem, the magic number is ``FIB3'' (0x46494254). Leaves contain an array of the following structure:
design/XFS_Filesystem_Structure/data_extents.asciidoc +32 -3
@@ -94,8 +94,9 @@ image::images/32.png[] The number of extents that can fit in the inode depends on the inode size and +di_forkoff+. For a default 256 byte inode with no extended attributes, a file -can have up to 9 extents with this format. Beyond this, extents have to use the -B+tree format. +can have up to 9 extents with this format. On a default v5 filesystem with 512 +byte inodes, a file can have up to 21 extents with this format. Beyond that, +extents have to use the B+tree format. === xfs_db Inode Data Fork Extents Example
@@ -242,7 +243,7 @@ and the leaves. This will be less if +di_forkoff+ is not zero (i.e. attributes are in use on the inode). [[Long_Format_Btrees]] -== Long Format B+trees +=== Long Format B+trees The subsequent nodes and leaves of the B+tree use the +xfs_btree_lblock+ declaration:
@@ -255,11 +256,20 @@ struct xfs_btree_lblock { __be16 bb_numrecs; __be64 bb_leftsib; __be64 bb_rightsib; + + /* version 5 filesystem fields start here */ + __be64 bb_blkno; + __be64 bb_lsn; + uuid_t bb_uuid; + __be64 bb_owner; + __le32 bb_crc; + __be32 bb_pad; }; ---- *bb_magic*:: Specifies the magic number for the BMBT block: ``BMAP'' (0x424d4150). +On a v5 filesystem, this is ``BMA3'' (0x424d4133). *bb_level*:: The level of the tree in which this block is found. If this value is 0, this
@@ -275,6 +285,25 @@ FS block number of the left sibling of this B+tree node. *bb_rightsib*:: FS block number of the right sibling of this B+tree node. +*bb_blkno*:: +FS block number of this B+tree block. + +*bb_lsn*:: +Log sequence number of the last write to this block. + +*bb_uuid*:: +The UUID of this block, which must match either +sb_uuid+ or +sb_meta_uuid+ +depending on which features are set. + +*bb_owner*:: +The AG number that this B+tree block ought to be in. + +*bb_crc*:: +Checksum of the B+tree block. + +*bb_pad*:: +Pads the structure to 64 bytes. + // force-split the lists * For intermediate nodes, the data following +xfs_btree_lblock+ is the same as
design/XFS_Filesystem_Structure/directories.asciidoc +222 -8
303 lines not on this page · raw message
design/XFS_Filesystem_Structure/docinfo.xml +16 -0
@@ -90,4 +90,20 @@ </simplelist> </revdescription> </revision> + <revision> + <revnumber>3.1</revnumber> + <date>October 2015</date> + <author> + <firstname>Darrick</firstname> + <surname>Wong</surname> + <email></email> + </author> + <revdescription> + <simplelist> + <member>Add v5 fields.</member> + <member>Discuss metadata integrity.</member> + <member>Document the free inode B+tree.</member> + </simplelist> + </revdescription> + </revision> </revhistory>
design/XFS_Filesystem_Structure/extended_attributes.asciidoc +78 -3
108 lines not on this page · raw message
design/XFS_Filesystem_Structure/internal_inodes.asciidoc +15 -0
@@ -60,6 +60,11 @@ struct xfs_disk_dquot { struct xfs_dqblk { struct xfs_disk_dquot dd_diskdq; char dd_fill[32]; + + /* version 5 filesystem fields begin here */ + __be32 dd_crc; + __be64 dd_lsn; + uuid_t dd_uuid; }; ----
@@ -150,6 +155,16 @@ soft limit will turn into a hard limit after the elapsed time exceeds ID zero's +d_rtbtimer+ value. When +d_rtbcount+ goes back below +d_rtb_softlimit+, +d_rtbtimer+ is reset back to zero. +*dd_uuid*:: +The UUID of this block, which must match either +sb_uuid+ or +sb_meta_uuid+ +depending on which features are set. + +*dd_lsn*:: +Log sequence number of the last DQ block write. + +*dd_crc*:: +Checksum of the DQ block. + [[Real-time_Inodes]] == Real-time Inodes
design/XFS_Filesystem_Structure/ondisk_inode.asciidoc +53 -9
94 lines not on this page · raw message
design/XFS_Filesystem_Structure/symbolic_links.asciidoc +45 -0
51 lines not on this page · raw message
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 16/21 xfsdocs: add a chapter discussing v5 disk format
In reply to Darrick J. WongAdd a chapter to give an overview of the enhanced metadata integrity fields present on a v5 filesystem.
--- .../metadata_integrity.asciidoc | 36 ++++++++++++++++++++ .../xfs_filesystem_structure.asciidoc | 2 + 2 files changed, 38 insertions(+) create mode 100644 design/XFS_Filesystem_Structure/metadata_integrity.asciidoc
design/XFS_Filesystem_Structure/metadata_integrity.asciidoc new file +36 -0
@@ -0,0 +1,36 @@ += Metadata Integrity + +Prior to version 5, most XFS metadata blocks contained a magic number that +could provide a minimal sanity check that a block read off the disk contained +the same type of data that the code thought it was reading off the disk. +However, this was insufficient -- given a correct type code, it was still +impossible to tell if the block was from a previous filesystem, or happened to +be owned by something else, or had been written to the wrong location on disk. +Furthermore, not all metadata blocks had magic numbers -- remote extended +attributes and extent symbolic links had no protection at all. + +Therefore, the version 5 disk format introduced larger headers for all metadata +types, which enable the filesystem to check information being read from the +disk more rigorously. Metadata integrity fields now include: + +* *Magic* numbers, to classify all types of metadata. This is unchanged from v4. +* A copy of the filesystem *UUID*, to confirm that a given disk block is connected to the superblock. +* The *owner*, to avoid accessing a piece of metadata which belongs to some other part of the filesystem. +* The filesystem *block number*, to detect misplaced writes. +* The *log serial number* of the last write to this block, to avoid replaying obsolete log entries. +* A CRC32c *checksum* of the entire block, to detect minor corruption. + +Metadata integrity coverage has been extended to all metadata blocks in the +filesystem, with the following notes: + +* Inodes can have multiple ``owners'' in the directory tree; therefore the record contains the inode number instead of an owner or a block number. +* Superblocks have no owners. +* The disk quota file has no owner or block numbers. +* Metadata owned by files list the inode number as the owner. +* Per-AG data and B+tree blocks list the AG number as the owner. +* Per-AG header sectors don't list owners or block numbers, since they have fixed locations. +* Remote attribute blocks are not logged and therefore the LSN must be -1. + +This functionality enables XFS to decide that a block contents are so +unexpected that it should stop immediately. Unfortunately checksums do not +allow for automatic correction. Please keep regular backups, as always.
design/XFS_Filesystem_Structure/xfs_filesystem_structure.asciidoc +2 -0
@@ -46,6 +46,8 @@ log items which are formatted in host order. include::overview.asciidoc[] +include::metadata_integrity.asciidoc[] + include::common_types.asciidoc[] // return titles to normal
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 18/21 xfsdocs: document the sparse inodes feature
In reply to Darrick J. WongDocument the new sparse inodes feature and how it affects the inobt records.
--- .../allocation_groups.asciidoc | 157 ++++++++++++++++++++ design/XFS_Filesystem_Structure/docinfo.xml | 1 2 files changed, 155 insertions(+), 3 deletions(-)
design/XFS_Filesystem_Structure/allocation_groups.asciidoc +154 -3
@@ -388,6 +388,18 @@ Directory file type. Each directory entry tracks the type of the inode to which the entry points. This is a performance optimization to remove the need to load every inode into memory to iterate a directory. +| +XFS_SB_FEAT_INCOMPAT_SPINODES+ | +Sparse inodes. This feature relaxes the requirement to allocate inodes in +chunks of 64. When the free space is heavily fragmented, there might exist +plenty of free space but not enough contiguous free space to allocate a new +inode chunk. With this feature, the user can continue to create files until +all free space is exhausted. + +Unused space in the inode B+tree records are used to track which parts of the +inode chunk are not inodes. + +See the chapter on xref:Sparse_Inodes[Sparse Inodes] for more information. + | +XFS_SB_FEAT_INCOMPAT_META_UUID+ | Metadata UUID. The UUID stamped into each metadata block must match the value in +sb_meta_uuid+. This enables the administrator to change +sb_uuid+ at will
@@ -977,9 +989,9 @@ Specifies the number of levels in the free inode B+tree. [[Inode_Btrees]] == Inode B+trees -Inodes are allocated in chunks of 64, and a B+tree is used to track these chunks -of inodes as they are allocated and freed. The block containing root of the -B+tree is defined by the AGI's +agi_root+ value. If the +Inodes are traditionally allocated in chunks of 64, and a B+tree is used to +track these chunks of inodes as they are allocated and freed. The block +containing root of the B+tree is defined by the AGI's +agi_root+ value. If the +XFS_SB_FEAT_RO_COMPAT_FINOBT+ feature is enabled, a second B+tree is used to track the chunks containing free inodes; this is an optimization to speed up inode allocation.
@@ -1111,6 +1123,145 @@ recs[1] = [startino,freecount,free] 1:[5792,9,0xff80000000000000] Observe also that the AGI's +agi_newino+ points to this chunk, which has never been fully allocated. +[[Sparse_Inodes]] +== Sparse Inodes + +As mentioned in the previous section, XFS allocates inodes in chunks of 64. If +there are no free extents large enough to hold a full chunk of 64 inodes, the +inode allocation fails and XFS claims to have run out of space. On a +filesystem with highly fragmented free space, this can lead to out of space +errors long before the filesystem runs out of free blocks. + +The sparse inode feature tracks inode chunks in the inode B+tree as if they +were full chunks but uses some previously unused bits in the freecount field to +track which parts of the inode chunk are not allocated for use as inodes. This +allows XFS to allocate inodes one block at a time if absolutely necessary. + +The inode and free inode B+trees operate in the same manner as they do without +the sparse inode feature; the B+tree header for the nodes and leaves use the ++xfs_btree_sblock+ structure which is the same as the header used in the +xref:AG_Free_Space_Btrees[AGF B+trees]. + +Leaves contain an array of the following structure: + +[source,c] +---- +struct xfs_inobt_rec { + __be32 ir_startino; + __be16 ir_holemask; + __u8 ir_count; + __u8 ir_freecount; + __be64 ir_free; +}; +---- + +*ir_startino*:: +The lowest-numbered inode in this chunk, rounded down to the nearest multiple +of 64, even if the start of this chunk is sparse. + +*ir_holemask*:: +A 16 element bitmap showing which parts of the chunk are not allocated to +inodes. Each bit represents four inodes; if a bit is marked here, the +corresponding bits in ir_free must also be marked. + +*ir_count*:: +Number of inodes allocated to this chunk. + +*ir_freecount*:: +Number of free inodes in this chunk. + +*ir_free*:: +A 64 element bitmap showing which inodes in this chunk are not available for +allocation. + +==== xfs_db Sparse Inode AGI Example + +This example derives from an AG that has been deliberately fragmented. The +inode B+tree: + +---- +xfs_db> agi 0 +xfs_db> p +magicnum = 0x58414749 +versionnum = 1 +seqno = 0 +length = 6400 +count = 10432 +root = 2381 +level = 2 +freecount = 0 +newino = 14912 +dirino = null +unlinked[0-63] = +uuid = b9b4623b-f678-4d48-8ce7-ce08950e3cd6 +lsn = 0x600000ac4 +crc = 0xef550dbc (correct) +free_root = 4 +free_level = 1 +---- + +This AGI was formatted on a v5 filesystem; notice the extra v5 fields. So far +everything else looks much the same as always. + +---- +xfs_db> addr root +magic = 0x49414233 +level = 1 +numrecs = 2 +leftsib = null +rightsib = null +bno = 19048 +lsn = 0x50000192b +uuid = b9b4623b-f678-4d48-8ce7-ce08950e3cd6 +owner = 0 +crc = 0xd98cd2ca (correct) +keys[1-2] = [startino] 1:[128] 2:[35136] +ptrs[1-2] = 1:3 2:2380 +xfs_db> addr ptrs[1] +xfs_db> p +magic = 0x49414233 +level = 0 +numrecs = 159 +leftsib = null +rightsib = 2380 +bno = 24 +lsn = 0x600000ac4 +uuid = b9b4623b-f678-4d48-8ce7-ce08950e3cd6 +owner = 0 +crc = 0x836768a6 (correct) +recs[1-159] = [startino,holemask,count,freecount,free] + 1:[128,0,64,0,0] + 2:[14912,0xff,32,0,0xffffffff] + 3:[15040,0,64,0,0] + 4:[15168,0xff00,32,0,0xffffffff00000000] + 5:[15296,0,64,0,0] + 6:[15424,0xff,32,0,0xffffffff] + 7:[15552,0,64,0,0] + 8:[15680,0xff00,32,0,0xffffffff00000000] + 9:[15808,0,64,0,0] + 10:[15936,0xff,32,0,0xffffffff] +---- + +Here we see the difference in the inode B+tree records. For example, in record +2, we see that the holemask has a value of 0xff. This means that the first +sixteen inodes in this chunk record do not actually map to inode blocks; the +first inode in this chunk is actually inode 14944: + +---- +xfs_db> inode 14912 +Metadata corruption detected at block 0x3a40/0x2000 +... +Metadata CRC error detected for ino 14912 +xfs_db> p core.magic +core.magic = 0 +xfs_db> inode 14944 +xfs_db> p core.magic +core.magic = 0x494e +---- + +The chunk record also indicates that this chunk has 32 inodes, and that the +missing inodes are also ``free''. + [[Real-time_Devices]] == Real-time Devices
design/XFS_Filesystem_Structure/docinfo.xml +1 -0
@@ -104,6 +104,7 @@ <member>Discuss metadata integrity.</member> <member>Document the free inode B+tree.</member> <member>Create an index of magic numbers.</member> + <member>Document sparse inodes.</member> </simplelist> </revdescription> </revision>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 17/21 xfsdocs: document magic numbers and theoretical limits
In reply to Darrick J. Wong--- design/XFS_Filesystem_Structure/docinfo.xml | 1 design/XFS_Filesystem_Structure/magic.asciidoc | 86 ++++++++++++++++++++ .../xfs_filesystem_structure.asciidoc | 2 3 files changed, 89 insertions(+) create mode 100644 design/XFS_Filesystem_Structure/magic.asciidoc
design/XFS_Filesystem_Structure/docinfo.xml +1 -0
@@ -103,6 +103,7 @@ <member>Add v5 fields.</member> <member>Discuss metadata integrity.</member> <member>Document the free inode B+tree.</member> + <member>Create an index of magic numbers.</member> </simplelist> </revdescription> </revision>
design/XFS_Filesystem_Structure/magic.asciidoc new file +86 -0
86 lines not on this page · raw message
design/XFS_Filesystem_Structure/xfs_filesystem_structure.asciidoc +2 -0
@@ -50,6 +50,8 @@ include::metadata_integrity.asciidoc[] include::common_types.asciidoc[] +include::magic.asciidoc[] + // return titles to normal :leveloffset: 0
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 19/21 xfsdocs: reverse-mapping btree documentation
In reply to Darrick J. WongAdd chapters on the operation of the reverse mapping btree and future things we could do with rmap data.
--- .../allocation_groups.asciidoc | 24 +- design/XFS_Filesystem_Structure/docinfo.xml | 14 + .../reconstruction.asciidoc | 53 +++++ design/XFS_Filesystem_Structure/rmapbt.asciidoc | 223 ++++++++++++++++++++ .../xfs_filesystem_structure.asciidoc | 4 5 files changed, 310 insertions(+), 8 deletions(-) create mode 100644 design/XFS_Filesystem_Structure/reconstruction.asciidoc create mode 100644 design/XFS_Filesystem_Structure/rmapbt.asciidoc
design/XFS_Filesystem_Structure/allocation_groups.asciidoc +16 -8
@@ -12,6 +12,7 @@ Each AG has the following characteristics: * A super block describing overall filesystem info * Free space management * Inode allocation and tracking + * Reverse block-mapping index (optional) Having multiple AGs allows XFS to handle most operations in parallel without degrading performance as the number of concurrent accesses increases.
@@ -373,6 +374,12 @@ it doesn't understand the flag. Free inode B+tree. Each allocation group contains a B+tree to track inode chunks containing free inodes. This is a performance optimization to reduce the time required to allocate inodes. + +| +XFS_SB_FEAT_RO_COMPAT_RMAPBT+ | +Reverse mapping B+tree. Each allocation group contains a B+tree containing +records mapping AG blocks to their owners. See the section about +xref:Reconstruction[reconstruction] for more details. + |===== *sb_features_incompat*::
@@ -522,9 +529,7 @@ struct xfs_agf { __be32 agf_seqno; __be32 agf_length; __be32 agf_roots[XFS_BTNUM_AGF]; - __be32 agf_spare0; __be32 agf_levels[XFS_BTNUM_AGF]; - __be32 agf_spare1; __be32 agf_flfirst; __be32 agf_fllast; __be32 agf_flcount;
@@ -543,9 +548,10 @@ struct xfs_agf { }; ---- -The rest of the bytes in the sector are zeroed. +XFS_BTNUM_AGF+ is set to 2: -index 0 for the free space B+tree indexed by block number; and index 1 for the -free space B+tree indexed by extent size. +The rest of the bytes in the sector are zeroed. +XFS_BTNUM_AGF+ is set to 3: +index 0 for the free space B+tree indexed by block number; index 1 for the free +space B+tree indexed by extent size; and index 2 for the reverse-mapping +B+tree. *agf_magicnum*:: Specifies the magic number for the AGF sector: ``XAGF'' (0x58414746).
@@ -563,11 +569,13 @@ this could be less than the +sb_agblocks+ value. It is this value that should be used to determine the size of the AG. *agf_roots*:: -Specifies the block number for the root of the two free space B+trees. +Specifies the block number for the root of the two free space B+trees and the +reverse-mapping B+tree, if enabled. *agf_levels*:: -Specifies the level or depth of the two free space B+trees. For a fresh AG, this -will be one, and the ``roots'' will point to a single leaf of level 0. +Specifies the level or depth of the two free space B+trees and the +reverse-mapping B+tree, if enabled. For a fresh AG, this value will be one, +and the ``roots'' will point to a single leaf of level 0. *agf_flfirst*:: Specifies the index of the first ``free list'' block. Free lists are covered in
design/XFS_Filesystem_Structure/docinfo.xml +14 -0
@@ -108,4 +108,18 @@ </simplelist> </revdescription> </revision> + <revision> + <revnumber>3.14</revnumber> + <date>November 2015</date> + <author> + <firstname>Darrick</firstname> + <surname>Wong</surname> + <email></email> + </author> + <revdescription> + <simplelist> + <member>Document the reverse-mapping btree.</member> + </simplelist> + </revdescription> + </revision> </revhistory>
design/XFS_Filesystem_Structure/reconstruction.asciidoc new file +53 -0
53 lines not on this page · raw message
design/XFS_Filesystem_Structure/rmapbt.asciidoc new file +223 -0
223 lines not on this page · raw message
design/XFS_Filesystem_Structure/xfs_filesystem_structure.asciidoc +4 -0
@@ -48,6 +48,8 @@ include::overview.asciidoc[] include::metadata_integrity.asciidoc[] +include::reconstruction.asciidoc[] + include::common_types.asciidoc[] include::magic.asciidoc[]
@@ -62,6 +64,8 @@ Global Structures include::allocation_groups.asciidoc[] +include::rmapbt.asciidoc[] + include::journaling_log.asciidoc[] include::internal_inodes.asciidoc[]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 20/21 xfsdocs: document refcount btree and reflink
In reply to Darrick J. WongDocument the reference count btree and talk a little bit about how the reflink feature uses it.
--- .../allocation_groups.asciidoc | 20 ++- .../XFS_Filesystem_Structure/directories.asciidoc | 1 design/XFS_Filesystem_Structure/docinfo.xml | 2 .../XFS_Filesystem_Structure/ondisk_inode.asciidoc | 10 + .../XFS_Filesystem_Structure/refcountbt.asciidoc | 145 ++++++++++++++++++++ design/XFS_Filesystem_Structure/reflink.asciidoc | 40 ++++++ .../xfs_filesystem_structure.asciidoc | 4 + 7 files changed, 218 insertions(+), 4 deletions(-) create mode 100644 design/XFS_Filesystem_Structure/refcountbt.asciidoc create mode 100644 design/XFS_Filesystem_Structure/reflink.asciidoc
design/XFS_Filesystem_Structure/allocation_groups.asciidoc +18 -2
@@ -13,6 +13,7 @@ Each AG has the following characteristics: * Free space management * Inode allocation and tracking * Reverse block-mapping index (optional) + * Data block reference count index (optional) Having multiple AGs allows XFS to handle most operations in parallel without degrading performance as the number of concurrent accesses increases.
@@ -380,6 +381,12 @@ Reverse mapping B+tree. Each allocation group contains a B+tree containing records mapping AG blocks to their owners. See the section about xref:Reconstruction[reconstruction] for more details. +| +XFS_SB_FEAT_RO_COMPAT_REFLINK+ | +Reference count B+tree. Each allocation group contains a B+tree to track the +reference counts of AG blocks. This enables files to share data blocks safely. +See the section about xref:Reflink_Deduplication[reflink and deduplication] for +more details. + |===== *sb_features_incompat*::
@@ -539,7 +546,9 @@ struct xfs_agf { /* version 5 filesystem fields start here */ uuid_t agf_uuid; - __be64 agf_spare64[16]; + __be32 agf_refcount_root; + __be32 agf_refcount_level; + __be64 agf_spare64[15]; /* unlogged fields, written during buffer writeback. */ __be64 agf_lsn;
@@ -601,6 +610,12 @@ used if the +XFS_SB_VERSION2_LAZYSBCOUNTBIT+ bit is set in +sb_features2+. The UUID of this block, which must match either +sb_uuid+ or +sb_meta_uuid+ depending on which features are set. +*agf_refcount_root*:: +Block number for the root of the reference count B+tree, if enabled. + +*agf_refcount_root*:: +Depth of the reference count B+tree, if enabled. + *agf_spare64*:: Empty space in the logged part of the AGF sector, for use for future features.
@@ -1287,4 +1302,5 @@ By placing the real time device (and the journal) on separate high-performance storage devices, it is possible to reduce most of the unpredictability in I/O response times that come from metadata operations. -None of the XFS per-AG B+trees are involved with real time files. +None of the XFS per-AG B+trees are involved with real time files. It is not +possible for real time files to share data blocks.
design/XFS_Filesystem_Structure/directories.asciidoc +1 -0
@@ -1419,6 +1419,7 @@ The hash value of a particular record. The directory/attribute logical block containing all entries up to the corresponding hash value. +// * The freeindex's +bests+ array starts from the end of the block and grows to the start of the block.
design/XFS_Filesystem_Structure/docinfo.xml +2 -0
@@ -119,6 +119,8 @@ <revdescription> <simplelist> <member>Document the reverse-mapping btree.</member> + <member>Document the reference-count btree.</member> + <member>Discuss block sharing, reflink, & deduplication.</member> </simplelist> </revdescription> </revision>
design/XFS_Filesystem_Structure/ondisk_inode.asciidoc +8 -2
@@ -313,8 +313,14 @@ Counts the number of changes made to the attributes in this inode. Log sequence number of the last inode write. *di_flags2*:: -Specifies extended flags associated with a v3 inode. There are no flags defined -currently. +Specifies extended flags associated with a v3 inode. + +.Version 3 Inode flags +[options="header"] +|===== +| Flag | Description +| +XFS_DIFLAG2_REFLINK+ | This inode shares (or has shared) data blocks with another inode. +|===== *di_pad2*:: Padding for future expansion of the inode.
design/XFS_Filesystem_Structure/refcountbt.asciidoc new file +145 -0
145 lines not on this page · raw message
design/XFS_Filesystem_Structure/reflink.asciidoc new file +40 -0
@@ -0,0 +1,40 @@ +[[Reflink_Deduplication]] += Sharing Data Blocks + +On a traditional filesystem, there is a 1:1 mapping between a logical block +offset in a file and a physical block on disk, which is to say that physical +blocks are not shared. However, there exist various use cases for being able +to share blocks between files -- deduplicating files saves space on archival +systems; creating space-efficient clones of disk images for virtual machines +and containers facilitates efficient datacenters; and deferring the payment of +the allocation cost of a file system tree copy as long as possible makes +regular work faster. In all of these cases, a write to one of the shared +copies *must* not affect the other shared copies, which means that writes to +shared blocks must employ a copy-on-write strategy. Sharing blocks in this +manner is commonly referred to as ``reflinking''. + +XFS implements block sharing in a fairly straightforward manner. All existing +data fork structures remain unchanged, save for the addition of a +per-allocation group xref:Reference_Count_Btree[reference count B+tree]. This +data structure tracks reference counts for all shared physical blocks, with a +few rules to maintain compatibility with existing code: If a block is free, it +will be tracked in the free space B+trees. If a block is owned by a single +file, it appears in neither the free space nor the reference count B+trees. If +a block is shared, it will appear in the reference count B+tree with a +reference count >= 2. The first two cases are established precedent in XFS, so +the third case is the only behavioral change. + +When a filesystem block is shared, the block mapping in the destination file is +updated to point to that filesystem block and the reference count btree records +are updated to reflect the increased refcount. If a shared block is written, a +new block will be allocated, the dirty data written to this new block, and the +file's block mapping updated to point to the new block. If a shared block is +unmapped, the reference count records are updated to reflect the decreased +refcount and the block is also freed if its reference count becomes zero. This +enables users to create space efficient clones of disk images and to copy +filesystem subtrees quickly, using the standard Linux coreutils packages. + +Deduplication employs the same mechanism to share blocks and copy them at write +time. However, the kernel confirms that the contents of both files are +identical before updating the destination file's mapping. This enables XFS to +be used by userspace deduplication programs such as +duperemove+.
design/XFS_Filesystem_Structure/xfs_filesystem_structure.asciidoc +4 -0
@@ -48,6 +48,8 @@ include::overview.asciidoc[] include::metadata_integrity.asciidoc[] +include::reflink.asciidoc[] + include::reconstruction.asciidoc[] include::common_types.asciidoc[]
@@ -66,6 +68,8 @@ include::allocation_groups.asciidoc[] include::rmapbt.asciidoc[] +include::refcountbt.asciidoc[] + include::journaling_log.asciidoc[] include::internal_inodes.asciidoc[]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 21/21 xfsdocs: move directory chapter before xattr chapter
In reply to Darrick J. WongSince the chapter on directories introduces data structures that are referenced in the xattr chapter, the book should discuss directories first.
--- .../xfs_filesystem_structure.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
design/XFS_Filesystem_Structure/xfs_filesystem_structure.asciidoc +2 -2
@@ -85,10 +85,10 @@ include::ondisk_inode.asciidoc[] include::data_extents.asciidoc[] -include::extended_attributes.asciidoc[] - include::directories.asciidoc[] +include::extended_attributes.asciidoc[] + include::symbolic_links.asciidoc[] :leveloffset: 0
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs