Details
-
Improvement
-
Resolution: Fixed
-
Minor
-
Lustre 2.10.0
-
None
-
9223372036854775807
Description
With local ext4 and XFS filesystems, it is possible to use "df /path/to/directory" to return the current quota usage for the projid associated with that directory as "used", and min(projid quota limit, free space) as "total". This is a natural interface for users/applications, since it represents the used/maximum space for that subdirectory. Otherwise, the user will get EDQUOT back when the project quota runs out for that directory and applications will not be able to figure out how much data they could write into that directory.
static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf) { buf->f_type = EXT4_SUPER_MAGIC; buf->f_bsize = sb->s_blocksize; buf->f_blocks = ext4_blocks_count(es) - EXT4_C2B(sbi, overhead); buf->f_bfree = EXT4_C2B(sbi, percpu_counter_sum_positive(&sbi->s_freeclusters_counter) - percpu_counter_sum_positive(&sbi->s_dirtyclusters_counter)); buf->f_bavail = buf->f_bfree - (ext4_r_blocks_count(es) + resv_blocks); if (buf->f_bfree < (ext4_r_blocks_count(es) + resv_blocks)) buf->f_bavail = 0; buf->f_files = le32_to_cpu(es->s_inodes_count); buf->f_ffree = percpu_counter_sum_positive(&sbi->s_freeinodes_counter); #ifdef CONFIG_QUOTA if (ext4_test_inode_flag(dentry->d_inode, EXT4_INODE_PROJINHERIT) && sb_has_quota_limits_enabled(sb, PRJQUOTA)) ext4_statfs_project(sb, EXT4_I(dentry->d_inode)->i_projid, buf); #endif }
/* * Directory tree accounting is implemented using project quotas, where * the project identifier is inherited from parent directories. * A statvfs (df, etc.) of a directory that is using project quota should * return a statvfs of the project, not the entire filesystem. * This makes such trees appear as if they are filesystems in themselves. */ void xfs_fill_statvfs_from_dquot(struct kstatfs *statp, struct xfs_dquot *dqp) { uint64_t limit; limit = dqp->q_core.d_blk_softlimit ? be64_to_cpu(dqp->q_core.d_blk_softlimit) : be64_to_cpu(dqp->q_core.d_blk_hardlimit); if (limit && statp->f_blocks > limit) { statp->f_blocks = limit; statp->f_bfree = statp->f_bavail = (statp->f_blocks > dqp->q_res_bcount) ? (statp->f_blocks - dqp->q_res_bcount) : 0; } limit = dqp->q_core.d_ino_softlimit ? be64_to_cpu(dqp->q_core.d_ino_softlimit) : be64_to_cpu(dqp->q_core.d_ino_hardlimit); if (limit && statp->f_files > limit) { statp->f_files = limit; statp->f_ffree = (statp->f_files > dqp->q_res_icount) ? (statp->f_ffree - dqp->q_res_icount) : 0; } } void xfs_qm_statvfs(xfs_inode_t *ip, struct kstatfs *statp) { if (!xfs_qm_dqget(mp, NULL, xfs_get_projid(ip), XFS_DQ_PROJ, 0, &dqp)) { xfs_fill_statvfs_from_dquot(statp, dqp); xfs_qm_dqput(dqp); } }
It be useful to be able to do the same with Lustre. One option would be to transfer the projid to the MDS and OSS in the OBD_STATFS request order to get the space usage for that projid directly. Currently the client RPC request body is empty, so there is no place to put the projid, but a new body could be added. The other option would be to check for a projid on the inode in ll_statfs() and ll_obd_statfs(), and if projid != 0 send the equivalent of "lfs quota -p" for that projid, and use it for the statfs "used" and "total" values.
Attachments
Issue Links
- is related to
-
LU-17395 df -h is limited by project quota even if quota enforcement is disabled
-
- Open
-
-
LU-19034 'lfs df' should limit statfs by project quota limits
-
- Open
-
-
LUDOC-460 document statfs functionality for project quotas
-
- Resolved
-
- is related to
-
LU-15721 projid quota limit statfs() on directories only with PROJINHERIT
-
- Resolved
-
-
LU-16771 add client statfs() cache for project quotas
-
- Resolved
-
-
LU-4017 Add project quota support feature
-
- Resolved
-
-
LU-12480 add STATX_PROJID to upstream kernel
-
- Open
-
-
LU-7236 OST connect and disconnect on demand
-
- Resolved
-
-
LU-10018 MDT as a statfs proxy
-
- Resolved
-
I got a further questions for 'lfs df' case:
[root@server_el7_vm1 lustre]# lfs df /mnt/lustre
UUID 1K-blocks Used Available Use% Mounted on
lustre-MDT0000_UUID 5825660 47240 5255588 1% /mnt/lustre[MDT:0]
lustre-OST0000_UUID 9662472 38040 9083760 1% /mnt/lustre[OST:0]
lustre-OST0001_UUID 9662472 38044 9083756 1% /mnt/lustre[OST:1]
lustre-OST0002_UUID 9662472 38044 9083756 1% /mnt/lustre[OST:2]
lustre-OST0003_UUID 9662472 38044 9083756 1% /mnt/lustre[OST:3]
filesystem_summary: 38649888 152172 36335028 1% /mnt/lustre
What exactly 'avail' space and total space we should report for each OST/MDT?
I supposed we might need get each slave's granted space as total space and calculate
avail space based on that?
And existed quotactl doesn't report that information back, we might need extend to support that?