Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11793027pjo; Thu, 2 Jan 2020 14:22:31 -0800 (PST) X-Google-Smtp-Source: APXvYqwE3yaVQpzriMDVBkO6Y8vxf70pcBDAFE7yTiT7/6uUXN7ZuNYwWO6cXsqUsmmYN4sB7u4X X-Received: by 2002:a9d:7f12:: with SMTP id j18mr98128980otq.17.1578003751326; Thu, 02 Jan 2020 14:22:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578003751; cv=none; d=google.com; s=arc-20160816; b=AI1fYvN9uQ4dfBUIlIrtpYcaOzPWA4P3wAazBk7EuOMyqF3bSO7qL4FarKeCNGPMaQ bU7qYv92mpt2BgMH644hDn9zbCi/GFZkYP7XEfRXmwscc+VkjNXcXkUT5fejrEkQVFTn lt/Wg1C/0L6pdESYjm1JhukY1eRu24IeHEyXyx5RBRJz797gAtVqDF9L0xiYkCNOFS5o YKyfO37om0yQx2UIqg+FM3t8g/29sl5u7vJs5JOkbz8e+03j937SxPCUt+Wg4UN//HuC JuEVxfvMpf/9LhLq2PJvo/xe5mqNn8Yj1/yzGC9txZgu4D40pWgn74Dno2xuLkHstGXR ByBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Z8JglROXZrV22tZ+VxARu/LLP4lUtvL6fLqEAt5VI+g=; b=vu+xjlAaiSyKaVq0IRePhYRCfGMUlqAxkTRhwNxENqk01lOxSQyrZfYbiMqUP0Mrgu QZBzavGTaS25CHqgoCL/++K/qeFI7eeD+AQzSeYMp8jMWVePro+RgcNON/C9aDqssmsf oygyz+JxCrogLDSLpvzA+bvyhm9Q70DCI+eXSISCHsrbdD6a+HcfRGjlz7TinsYJM5Hh k7krp8nZWdanNDxexYP/Q9FoyhAV/IkA1kBQQqhSBAyXFqcLg1Kp02tl3r1fxigyJNG2 eYIKrxC6omd8RGIoZWj3ggjagiOhAsMZU00bzVU0A2wwnXgCU6bdvSr/pf8xk/VFBML1 0gfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rDX2BFz2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f25si19257790oti.244.2020.01.02.14.22.18; Thu, 02 Jan 2020 14:22:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rDX2BFz2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728935AbgABWVD (ORCPT + 99 others); Thu, 2 Jan 2020 17:21:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:39504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728920AbgABWVB (ORCPT ); Thu, 2 Jan 2020 17:21:01 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 8A68920866; Thu, 2 Jan 2020 22:21:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003661; bh=iprWCtLGEBo8BgYJE9kAck3R9X49tsn0AWg2uJ6REZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rDX2BFz2/A7osvKq9EZ0IFU2LQs2ovhoSsk8XsO5h8Dpvh3VzLreLPYeZfL9PD4xE GG3FXUJ+GwlHYzxjGEMhAxjeYuDn6YweraIdb03yUxtPR+GaBm71zNOLYDjLCxgvRw JQz1hnSfte86Abcccd/N8b+06NbygEKY6HA8sf3s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chengguang Xu , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 4.19 062/114] f2fs: choose hardlimit when softlimit is larger than hardlimit in f2fs_statfs_project() Date: Thu, 2 Jan 2020 23:07:14 +0100 Message-Id: <20200102220035.294585461@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220029.183913184@linuxfoundation.org> References: <20200102220029.183913184@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chengguang Xu [ Upstream commit 909110c060f22e65756659ec6fa957ae75777e00 ] 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 *** Report for project quotas on device /dev/nvme0n1p8 Block grace time: 7days; Inode grace time: 7days Block limits File limits Project used soft hard grace used soft hard grace ---------------------------------------------------------------------- 0 -- 4 0 0 1 0 0 123 +- 10248 20480 10240 2 0 0 The result of df command as below: [root@hades f2fs]# df -h /mnt/f2fs/test Filesystem Size Used Avail Use% Mounted on /dev/nvme0n1p8 20M 11M 10M 51% /mnt/f2fs Even though it looks like there is another 10M free space to use, if we write new data to diretory test(inherit project id), the write will fail with errno(-EDQUOT). After this patch, the df result looks like below. [root@hades f2fs]# df -h /mnt/f2fs/test Filesystem Size Used Avail Use% Mounted on /dev/nvme0n1p8 10M 10M 0 100% /mnt/f2fs Signed-off-by: Chengguang Xu Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/super.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 7a9cc64f5ca3..662c7de58b99 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1148,9 +1148,13 @@ static int f2fs_statfs_project(struct super_block *sb, return PTR_ERR(dquot); spin_lock(&dquot->dq_dqb_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; @@ -1159,9 +1163,13 @@ static int f2fs_statfs_project(struct super_block *sb, (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 = -- 2.20.1