
xfs文件系统xfs_quota配额设置(2)- 配置信息存储位置探究
xfs文件系统中有专门的inode存储xfs_quota配额信息,另外,被约束了project配额的目录和文件,在inode元数据中,也会有project id属性。
所以即使没有/etc/projects这些配置文件,服务器重启后,配额限制也不会被取消。
下面样例为project配额方式下查看quota配置信息。
xfs_quota -x -c 'report' /dev/sdb1命令,查看project id列表和Limit。
[root@n11b-sata4000 ~]# xfs_quota -x -c 'report' /dev/sdb1
Project quota on /datb (/dev/sdb1)
Blocks
Project ID Used Soft Hard Warn/Grace
---------- --------------------------------------------------
#0 0 0 0 00 [--------]
#65 838989988 0 1073741824 00 [--------]
#70 5707854264 0 6442450944 00 [--------]
#75 86060848 0 1073741824 00 [--------]下面通过xfs_db来查看指定project id的quota配置,与xfs_quota命令输出结果进行比对。
xfs_db -r /dev/sdb1命令,进入xfs_db交互环境。
dquot指令会将指针移动到quote block。然后我们再通过print指令查看对应block的数据。
xfs_db> dquot
bad argument count 0 to dquot, expected between 1 and 2 arguments
xfs_db> dquot -p 65
xfs_db> p
diskdq.magic = 0x4451
diskdq.version = 0x1
diskdq.flags = 0x2
diskdq.id = 65
diskdq.blk_hardlimit = 268435456
diskdq.blk_softlimit = 0
diskdq.ino_hardlimit = 0
diskdq.ino_softlimit = 0
diskdq.bcount = 209596326
diskdq.icount = 79006
diskdq.itimer = 0
diskdq.btimer = 0
diskdq.iwarns = 0
diskdq.bwarns = 0
diskdq.rtb_hardlimit = 0
diskdq.rtb_softlimit = 0
diskdq.rtbcount = 0
diskdq.rtbtimer = 0
diskdq.rtbwarns = 0
crc = 0xd01d9e6f (correct)
lsn = 0x9900318fc0
uuid = 2c74c638-4645-48c1-822b-d99499823932注意,该project的配额限制是实际是1TB。
dquot指令看到的hardlimit是268435456 blks。1 blk为4096Bytes,即4KB。
xfs_quota命令看到的hardlimit是1073741824 blks, 该命令blks的单位是1KB。
xfs_db> sb
xfs_db> p
magicnum = 0x58465342
blocksize = 4096
dblocks = 6835933184
rblocks = 0
rextents = 0
uuid = 2c74c638-4645-48c1-822b-d99499823932
logstart = 4294967304
rootino = 1024
rbmino = 1025
rsumino = 1026
rextsize = 1
agblocks = 213622912
agcount = 32
rbmblocks = 0
logblocks = 521728
versionnum = 0xb5e5
sectsize = 512
inodesize = 512
inopblock = 8
fname = "\000\000\000\000\000\000\000\000\000\000\000\000"
blocklog = 12
sectlog = 9
inodelog = 9
inopblog = 3
agblklog = 28
rextslog = 0
inprogress = 0
imax_pct = 5
icount = 82880
ifree = 1044
fdblocks = 5184855878
frextents = 0
uquotino = null
gquotino = null
qflags = 0x608
flags = 0
shared_vn = 0
inoalignmt = 4
unit = 128
width = 64
dirblklog = 0
logsectlog = 0
logsectsize = 0
logsunit = 32768
features2 = 0x18a
bad_features2 = 0x18a
features_compat = 0
features_ro_compat = 0
features_incompat = 0x1
features_log_incompat = 0
crc = 0xda95173e (correct)
spino_align = 0
pquotino = 1027
lsn = 0x9900319280
meta_uuid = 00000000-0000-0000-0000-000000000000pquotino = 1027,该值表示project quota信息所在的inode值
xfs_db> inode 1027
xfs_db> p
core.magic = 0x494e
core.mode = 0100000
core.version = 3
core.format = 2 (extents)
core.nlinkv2 = 1
core.onlink = 0
core.projid_lo = 0
core.projid_hi = 0
core.uid = 0
core.gid = 0
core.flushiter = 0
core.atime.sec = Fri Dec 13 19:36:38 2024
core.atime.nsec = 659545008
core.mtime.sec = Fri Dec 13 19:36:38 2024
core.mtime.nsec = 659545008
core.ctime.sec = Fri Dec 13 19:36:38 2024
core.ctime.nsec = 659545008
core.size = 0
core.nblocks = 2
core.extsize = 0
core.nextents = 2
core.naextents = 0
core.forkoff = 0
core.aformat = 2 (extents)
core.dmevmask = 0
core.dmstate = 0
core.newrtbm = 0
core.prealloc = 0
core.realtime = 0
core.immutable = 0
core.append = 0
core.sync = 0
core.noatime = 0
core.nodump = 0
core.rtinherit = 0
core.projinherit = 0
core.nosymlinks = 0
core.extsz = 0
core.extszinherit = 0
core.nodefrag = 0
core.filestream = 0
core.gen = 755468223
next_unlinked = null
v3.crc = 0x3789a69b (correct)
v3.change_count = 4
v3.lsn = 0x1000001c0
v3.flags2 = 0
v3.crtime.sec = Fri Dec 13 19:36:38 2024
v3.crtime.nsec = 659545008
v3.inumber = 1027
v3.uuid = 2c74c638-4645-48c1-822b-d99499823932
u3.bmx[0-1] = [startoff,startblock,blockcount,extentflag] 0:[0,127,1,0] 1:[2,126,1,0] core.format = 2 (extents)
u3.bmx[0-1] = [startoff,startblock,blockcount,extentflag] 0:[0,127,1,0] 1:[2,126,1,0]u3.bmx值表示该inode数据部分占用了2个block,分别为0,127,1,0和2,126,1,0。
也就是block 127和block 126。
移动指针到block 126,查看内容。1个sector是512Bytes,1个block是8个sector,4KB。
xfs_db> fsblock 126
xfs_db> p
000: 44510102 0000003c 00000000 00000000 00000000 00000000 00000000 00000000
020: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
040: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
060: 00000000 00000000 00000000 837cd8e3 00000000 00000000 2c74c638 464548c1
080: 822bd994 99823932 44510102 0000003d 00000000 00000000 00000000 00000000
0a0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
0c0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
0e0: 00000000 00000000 00000000 00000000 00000000 1c2bc1a0 00000000 00000000
100: 2c74c638 464548c1 822bd994 99823932 44510102 0000003e 00000000 00000000
120: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
140: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
160: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 bdd3ea65
180: 00000000 00000000 2c74c638 464548c1 822bd994 99823932 44510102 0000003f
1a0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
1c0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
1e0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
200: 00000000 2284f326 00000000 00000000 2c74c638 464548c1 822bd994 99823932
220: 44510102 00000040 00000000 00000000 00000000 00000000 00000000 00000000
240: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
260: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
280: 00000000 00000000 00000000 986bbc0b 00000000 00000000 2c74c638 464548c1
2a0: 822bd994 99823932 44510102 00000041 00000000 10000000 00000000 00000000
2c0: 00000000 00000000 00000000 00000000 00000000 0c7e2fa6 00000000 0001349e
2e0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
300: 00000000 00000000 00000000 00000000 00000000 40228da9 00000099 00319240
320: 2c74c638 464548c1 822bd994 99823932 44510102 00000042 00000000 00000000
340: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
360: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
380: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 a6c48e8d
3a0: 00000000 00000000 2c74c638 464548c1 822bd994 99823932 44510102 00000043
3c0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
3e0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
400: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
420: 00000000 399397ce 00000000 00000000 2c74c638 464548c1 822bd994 99823932
440: 44510102 00000044 00000000 00000000 00000000 00000000 00000000 00000000
460: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
480: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
4a0: 00000000 00000000 00000000 15433502 00000000 00000000 2c74c638 464548c1
4c0: 822bd994 99823932 44510102 00000045 00000000 00000000 00000000 00000000
4e0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
500: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
520: 00000000 00000000 00000000 00000000 00000000 8a142c41 00000000 00000000
540: 2c74c638 464548c1 822bd994 99823932 44510102 00000046 00000000 60000000
560: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 550dbcb4
580: 00000000 00000adc 00000000 00000000 00000000 00000000 00000000 00000000
5a0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 81ac527e
5c0: 00000095 00205680 2c74c638 464548c1 822bd994 99823932 44510102 00000047
5e0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
600: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
620: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
640: 00000000 b4bb1ec7 00000000 00000000 2c74c638 464548c1 822bd994 99823932
660: 44510102 00000048 00000000 00000000 00000000 00000000 00000000 00000000
680: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
6a0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
6c0: 00000000 00000000 00000000 823aae18 00000000 00000000 2c74c638 464548c1
6e0: 822bd994 99823932 44510102 00000049 00000000 00000000 00000000 00000000
700: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
720: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
740: 00000000 00000000 00000000 00000000 00000000 1d6db75b 00000000 00000000
760: 2c74c638 464548c1 822bd994 99823932 44510102 0000004a 00000000 00000000
780: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
7a0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
7c0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 bc959c9e
7e0: 00000000 00000000 2c74c638 464548c1 822bd994 99823932 44510102 0000004b
800: 00000000 10000000 00000000 00000000 00000000 00000000 00000000 00000000
820: 00000000 00d54566 00000000 0000002e 00000000 00000000 00000000 00000000
840: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
860: 00000000 e3b06332 00000099 003190c0 2c74c638 464548c1 822bd994 99823932
880: 44510102 0000004c 00000000 00000000 00000000 00000000 00000000 00000000
8a0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
8c0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
8e0: 00000000 00000000 00000000 0f122711 00000000 00000000 2c74c638 464548c1
900: 822bd994 99823932 44510102 0000004d 00000000 00000000 00000000 00000000
920: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
940: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
960: 00000000 00000000 00000000 00000000 00000000 90453e52 00000000 00000000
980: 2c74c638 464548c1 822bd994 99823932 44510102 0000004e 00000000 00000000
9a0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
9c0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
9e0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 31bd1597
a00: 00000000 00000000 2c74c638 464548c1 822bd994 99823932 44510102 0000004f
a20: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
a40: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
a60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
a80: 00000000 aeea0cd4 00000000 00000000 2c74c638 464548c1 822bd994 99823932
aa0: 44510102 00000050 00000000 00000000 00000000 00000000 00000000 00000000
ac0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ae0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
b00: 00000000 00000000 00000000 acc9982d 00000000 00000000 2c74c638 464548c1
b20: 822bd994 99823932 44510102 00000051 00000000 00000000 00000000 00000000
b40: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
b60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
b80: 00000000 00000000 00000000 00000000 00000000 339e816e 00000000 00000000
ba0: 2c74c638 464548c1 822bd994 99823932 44510102 00000052 00000000 00000000
bc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
be0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
c00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 9266aaab
c20: 00000000 00000000 2c74c638 464548c1 822bd994 99823932 44510102 00000053
c40: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
c60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
c80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ca0: 00000000 0d31b3e8 00000000 00000000 2c74c638 464548c1 822bd994 99823932
cc0: 44510102 00000054 00000000 00000000 00000000 00000000 00000000 00000000
ce0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
d00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
d20: 00000000 00000000 00000000 21e11124 00000000 00000000 2c74c638 464548c1
d40: 822bd994 99823932 44510102 00000055 00000000 00000000 00000000 00000000
d60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
d80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
da0: 00000000 00000000 00000000 00000000 00000000 beb60867 00000000 00000000
dc0: 2c74c638 464548c1 822bd994 99823932 44510102 00000056 00000000 00000000
de0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
e00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
e20: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 1f4e23a2
e40: 00000000 00000000 2c74c638 464548c1 822bd994 99823932 44510102 00000057
e60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
e80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ea0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ec0: 00000000 80193ae1 00000000 00000000 2c74c638 464548c1 822bd994 99823932
ee0: 44510102 00000058 00000000 00000000 00000000 00000000 00000000 00000000
f00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
f20: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
f40: 00000000 00000000 00000000 b6988a3e 00000000 00000000 2c74c638 464548c1
f60: 822bd994 99823932 44510102 00000059 00000000 00000000 00000000 00000000
f80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
fa0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
fc0: 00000000 00000000 00000000 00000000 00000000 29cf937d 00000000 00000000
fe0: 2c74c638 464548c1 822bd994 99823932 00000000 00000000 00000000 00000000查看当前地址
xfs_db> addr
current
byte offset 516096, length 4096
buffer block 1008 (fsbno 126), 8 bbs
inode 1027, dir inode -1, type dataaddr指令解释
xfs_db> addr
current
byte offset 516096, length 4096
buffer block 1008 (fsbno 126), 8 bbs
inode 1027, dir inode -1, type databuffer block编号,是磁盘sector地址编号,磁盘sector为512Bytes
fsbno为文件系统block编号,1个block是8个sector,所以buffer block number = 8* fsbno.
byte offset = fsbno * 4096.
修改展示类型为dqblk,查看各字段内容。这里只会打印第1条记录。每条记录占136字节。
xfs_db> type dqblk
xfs_db> p
diskdq.magic = 0x4451
diskdq.version = 0x1
diskdq.flags = 0x2
diskdq.id = 60
diskdq.blk_hardlimit = 0
diskdq.blk_softlimit = 0
diskdq.ino_hardlimit = 0
diskdq.ino_softlimit = 0
diskdq.bcount = 0
diskdq.icount = 0
diskdq.itimer = 0
diskdq.btimer = 0
diskdq.iwarns = 0
diskdq.bwarns = 0
diskdq.rtb_hardlimit = 0
diskdq.rtb_softlimit = 0
diskdq.rtbcount = 0
diskdq.rtbtimer = 0
diskdq.rtbwarns = 0
crc = 0x837cd8e3 (correct)
lsn = 0
uuid = 2c74c638-4645-48c1-822b-d99499823932 dqblk The quota information is stored in files referred to by the
superblock uquotino and pquotino fields. Each filesystem
block in a quota file contains a constant number of quota
entries. The quota entry size is currently 136 bytes, so
with a 4KiB filesystem block size there are 30 quota
entries per block. The dquot command is used to locate
these entries in the filesystem. The file entries are
indexed by the user or project identifier to determine the
block and offset. Each quota entry has the following
fields:
magic magic number, 0x4451 ('DQ').
version
version number, currently 1.
flags flags, values include 0x01 for user quota,
0x02 for project quota.
id user or project identifier.
blk_hardlimit
absolute limit on blocks in use.
blk_softlimit
preferred limit on blocks in use.
ino_hardlimit
absolute limit on inodes in use.
ino_softlimit
preferred limit on inodes in use.
bcount blocks actually in use.
icount inodes actually in use.
itimer time when service will be refused if soft
limit is violated for inodes.
btimer time when service will be refused if soft
limit is violated for blocks.
iwarns number of warnings issued about inode limit
violations.
bwarns number of warnings issued about block limit
violations.
rtb_hardlimit
absolute limit on realtime blocks in use.
rtb_softlimit
preferred limit on realtime blocks in use.
rtbcount
realtime blocks actually in use.
rtbtimer
time when service will be refused if soft
limit is violated for realtime blocks.
rtbwarns
number of warnings issued about realtime
block limit violations.各字段含义和所占字节数在fs/xfs/libxfs/xfs_format.h中定义。
/*
* This is the main portion of the on-disk representation of quota
* information for a user. This is the q_core of the struct xfs_dquot that
* is kept in kernel memory. We pad this with some more expansion room
* to construct the on disk structure.
*/
struct xfs_disk_dquot {
__be16 d_magic; /* dquot magic = XFS_DQUOT_MAGIC */
__u8 d_version; /* dquot version */
__u8 d_flags; /* XFS_DQ_USER/PROJ/GROUP */
__be32 d_id; /* user,project,group id */
__be64 d_blk_hardlimit;/* absolute limit on disk blks */
__be64 d_blk_softlimit;/* preferred limit on disk blks */
__be64 d_ino_hardlimit;/* maximum # allocated inodes */
__be64 d_ino_softlimit;/* preferred inode limit */
__be64 d_bcount; /* disk blocks owned by the user */
__be64 d_icount; /* inodes owned by the user */
__be32 d_itimer; /* zero if within inode limits if not,
this is when we refuse service */
__be32 d_btimer; /* similar to above; for disk blocks */
__be16 d_iwarns; /* warnings issued wrt num inodes */
__be16 d_bwarns; /* warnings issued wrt disk blocks */
__be32 d_pad0; /* 64 bit align */
__be64 d_rtb_hardlimit;/* absolute limit on realtime blks */
__be64 d_rtb_softlimit;/* preferred limit on RT disk blks */
__be64 d_rtbcount; /* realtime blocks owned */
__be32 d_rtbtimer; /* similar to above; for RT disk blocks */
__be16 d_rtbwarns; /* warnings issued wrt RT disk blocks */
__be16 d_pad;
}; xfs_db> inode 34364113976
xfs_db> p
core.magic = 0x494e
core.mode = 0100644
core.version = 3
core.format = 2 (extents)
core.nlinkv2 = 1
core.onlink = 0
core.projid_lo = 65
core.projid_hi = 0
core.uid = 0
core.gid = 0
core.flushiter = 0
core.atime.sec = Wed Sep 24 15:29:49 2025
core.atime.nsec = 579983170
core.mtime.sec = Wed Sep 24 15:29:49 2025
core.mtime.nsec = 768987513
core.ctime.sec = Wed Sep 24 15:29:49 2025
core.ctime.nsec = 768987513
core.size = 498020
core.nblocks = 122
core.extsize = 0
core.nextents = 1
core.naextents = 0
core.forkoff = 0
core.aformat = 2 (extents)
core.dmevmask = 0
core.dmstate = 0
core.newrtbm = 0
core.prealloc = 0
core.realtime = 0
core.immutable = 0
core.append = 0
core.sync = 0
core.noatime = 0
core.nodump = 0
core.rtinherit = 0
core.projinherit = 0
core.nosymlinks = 0
core.extsz = 0
core.extszinherit = 0
core.nodefrag = 0
core.filestream = 0
core.gen = 2598271720
next_unlinked = null
v3.crc = 0x3c4e2b83 (correct)
v3.change_count = 9
v3.lsn = 0x580003fe80
v3.flags2 = 0
v3.crtime.sec = Wed Sep 24 15:29:49 2025
v3.crtime.nsec = 579983170
v3.inumber = 34364113976
v3.uuid = 2c74c638-4645-48c1-822b-d99499823932
u3.bmx[0] = [startoff,startblock,blockcount,extentflag] 0:[0,4295514258,122,0]可见,core.projid_lo = 65,即配置项目ID为65,该文件受到project 65的配额限制约束。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。