From patchwork Thu Feb 13 15:19:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 231341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE44DC2BA83 for ; Thu, 13 Feb 2020 15:58:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A43B720675 for ; Thu, 13 Feb 2020 15:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581609481; bh=Jg2YPwfNrRdnvddyGCDdUaKjhZDrWOEC5yiut1w0o48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BvRVs+ecdethciZUHOu8LgbeiiZfjZcF2hfL+hRc/lTRZaRPIQFZ3cocN6WfcbboB PUy5Zw9IJAfL6exyqWz2anzNhec/GKAxBbHeCxCu11QI/aUEUz9oH+ENN3hu2xW1Nl aPYqZCHfPE2G4mcP56Sjk9hQ5Q3FlYS+9RxTTTx0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727964AbgBMP57 (ORCPT ); Thu, 13 Feb 2020 10:57:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:40396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728956AbgBMPZP (ORCPT ); Thu, 13 Feb 2020 10:25:15 -0500 Received: from localhost (unknown [104.132.1.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7A09924690; Thu, 13 Feb 2020 15:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607514; bh=Jg2YPwfNrRdnvddyGCDdUaKjhZDrWOEC5yiut1w0o48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HWOOvzYdTcQG4jwPruTthXCQcQZ8KPet578fH41EgewJN1cpLE/W3tOSbWLhjotZK QZzaDzA2wihgIBzlIsoopizJ9CtodAZ1iKscO5UFCas5nel3ogEoUUZ0CFlhFgO0tY PRiytTtODmZIFArsXzX0yu0pAxqYL2biF7yW3nbk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org Subject: [PATCH 4.14 049/173] f2fs: choose hardlimit when softlimit is larger than hardlimit in f2fs_statfs_project() Date: Thu, 13 Feb 2020 07:19:12 -0800 Message-Id: <20200213151946.325063379@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151931.677980430@linuxfoundation.org> References: <20200213151931.677980430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Chengguang Xu commit 909110c060f22e65756659ec6fa957ae75777e00 upstream. Setting softlimit larger than hardlimit seems meaningless for disk quota but currently it is allowed. In this case, there may be a bit of comfusion for users when they run df comamnd to directory which has project quota. For example, we set 20M softlimit and 10M hardlimit of block usage limit for project quota of test_dir(project id 123). [root@hades f2fs]# repquota -P -a --- fs/f2fs/super.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -912,9 +912,13 @@ static int f2fs_statfs_project(struct su return PTR_ERR(dquot); spin_lock(&dq_data_lock); - limit = (dquot->dq_dqb.dqb_bsoftlimit ? - dquot->dq_dqb.dqb_bsoftlimit : - dquot->dq_dqb.dqb_bhardlimit) >> sb->s_blocksize_bits; + limit = 0; + if (dquot->dq_dqb.dqb_bsoftlimit) + limit = dquot->dq_dqb.dqb_bsoftlimit; + if (dquot->dq_dqb.dqb_bhardlimit && + (!limit || dquot->dq_dqb.dqb_bhardlimit < limit)) + limit = dquot->dq_dqb.dqb_bhardlimit; + if (limit && buf->f_blocks > limit) { curblock = dquot->dq_dqb.dqb_curspace >> sb->s_blocksize_bits; buf->f_blocks = limit; @@ -923,9 +927,13 @@ static int f2fs_statfs_project(struct su (buf->f_blocks - curblock) : 0; } - limit = dquot->dq_dqb.dqb_isoftlimit ? - dquot->dq_dqb.dqb_isoftlimit : - dquot->dq_dqb.dqb_ihardlimit; + limit = 0; + if (dquot->dq_dqb.dqb_isoftlimit) + limit = dquot->dq_dqb.dqb_isoftlimit; + if (dquot->dq_dqb.dqb_ihardlimit && + (!limit || dquot->dq_dqb.dqb_ihardlimit < limit)) + limit = dquot->dq_dqb.dqb_ihardlimit; + if (limit && buf->f_files > limit) { buf->f_files = limit; buf->f_ffree =