Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-9555

"df /path" and "lfs df /path" should return projid-specific values

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: Lustre 2.10.0
    • Fix Version/s: Lustre 2.14.0
    • Labels:
      None
    • Rank (Obsolete):
      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

            Activity

              People

              • Assignee:
                wshilong Wang Shilong
                Reporter:
                adilger Andreas Dilger
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated: