From patchwork Tue May 8 09:00:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 910066 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.alibaba.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40gD3x73hCz9s1w for ; Tue, 8 May 2018 19:01:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754233AbeEHJBB (ORCPT ); Tue, 8 May 2018 05:01:01 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:50271 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754210AbeEHJBA (ORCPT ); Tue, 8 May 2018 05:01:00 -0400 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R121e4; CH=green; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e01355; MF=bo.liu@linux.alibaba.com; NM=1; PH=DS; RN=1; SR=0; TI=SMTPD_---0T0cFxY2_1525770048; Received: from localhost(mailfrom:bo.liu@linux.alibaba.com fp:SMTPD_---0T0cFxY2_1525770048) by smtp.aliyun-inc.com(127.0.0.1); Tue, 08 May 2018 17:00:48 +0800 From: Liu Bo To: Subject: [PATCH] Ext4: df: fix df to report reserved bytes in quota Date: Tue, 8 May 2018 17:00:43 +0800 Message-Id: <1525770043-36347-1-git-send-email-bo.liu@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Without quota, df takes both on-disk allocated blocks and dirty reserved blocks as used, while with quota, df only takes on-disk allocated blocks by reading quota's information. To avoid confusing users, this fixes df to read quota's reservd bytes also. Signed-off-by: Qixuan Wu Signed-off-by: Liu Bo --- fs/ext4/super.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index eb104e8476f0..a49d3709c928 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5240,7 +5240,7 @@ static int ext4_statfs_project(struct super_block *sb, struct kqid qid; struct dquot *dquot; u64 limit; - u64 curblock; + u64 curblock, rsvblock; qid = make_kqid_projid(projid); dquot = dqget(sb, qid); @@ -5253,10 +5253,11 @@ static int ext4_statfs_project(struct super_block *sb, dquot->dq_dqb.dqb_bhardlimit) >> sb->s_blocksize_bits; if (limit && buf->f_blocks > limit) { curblock = dquot->dq_dqb.dqb_curspace >> sb->s_blocksize_bits; + rsvblock = dquot->dq_dqb.dqb_rsvspace >> sb->s_blocksize_bits; buf->f_blocks = limit; buf->f_bfree = buf->f_bavail = - (buf->f_blocks > curblock) ? - (buf->f_blocks - curblock) : 0; + (buf->f_blocks > (curblock + rsvblock)) ? + (buf->f_blocks - (curblock + rsvblock)) : 0; } limit = dquot->dq_dqb.dqb_isoftlimit ?