+static int ll_statfs_project(struct inode *inode, struct kstatfs *sfs)
+{
+ struct if_quotactl qctl = {
+ .qc_cmd = LUSTRE_Q_GETQUOTA,
+ .qc_type = PRJQUOTA,
+ .qc_valid = QC_GENERAL,
+ };
+ u64 limit, curblock;
+ int ret;
+
+ qctl.qc_id = ll_i2info(inode)->lli_projid;
+ ret = quotactl_ioctl(ll_i2sbi(inode), &qctl);
+ if (ret) {
+ /* ignore errors if project ID does not have
+ * a quota limit or feature unsupported.
+ */
+ if (ret == -ESRCH || ret == -EOPNOTSUPP)
+ ret = 0;
+ return ret;
+ }
+
+ limit = ((qctl.qc_dqblk.dqb_bsoftlimit ?
+ qctl.qc_dqblk.dqb_bsoftlimit :
+ qctl.qc_dqblk.dqb_bhardlimit) * 1024) / sfs->f_bsize;
+ if (limit && sfs->f_blocks > limit) {
+ curblock = (qctl.qc_dqblk.dqb_curspace +
+ sfs->f_bsize - 1) / sfs->f_bsize;
+ sfs->f_blocks = limit;
+ sfs->f_bfree = sfs->f_bavail =
+ (sfs->f_blocks > curblock) ?
+ (sfs->f_blocks - curblock) : 0;
+ }
+
+ limit = qctl.qc_dqblk.dqb_isoftlimit ?
+ qctl.qc_dqblk.dqb_isoftlimit :
+ qctl.qc_dqblk.dqb_ihardlimit;
+ if (limit && sfs->f_files > limit) {
+ sfs->f_files = limit;
+ sfs->f_ffree = (sfs->f_files >
+ qctl.qc_dqblk.dqb_curinodes) ?
+ (sfs->f_files - qctl.qc_dqblk.dqb_curinodes) : 0;
+ }
+
+ return 0;
+}
+