Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3492008ybv; Mon, 10 Feb 2020 00:40:44 -0800 (PST) X-Google-Smtp-Source: APXvYqye7J1IdTbGDd3FwHDx9GaxAfaTD3MAewKVTxEz4wBebQMgXTtnygdsA9QnM/qMT3/x44gG X-Received: by 2002:a9d:2184:: with SMTP id s4mr244202otb.121.1581324044093; Mon, 10 Feb 2020 00:40:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581324044; cv=none; d=google.com; s=arc-20160816; b=RLoAQXiNOEVYRASQe9f95LH0Ou1Hx6vFzdUKcGMne1K9oOlz2Fp2BTt4WB12XECrZA 65e1/2sJGOARkErIV62pzjazkYktxZRXnyVIFNKaBasoydDapcwB0igXjdXK40516XvQ vrERip1Fk1dUWNJovwdBTn4Y3dP9bgXT4xMmRHmcxP5V8VhB5OZuAMIG3PPNhhUU35cS AwWPTSTPtwpa4w6B881+nRMcQZL64zfla7orgCPwlvJg5Pf2GJCNfnq6vzUl+EgEmiXC wJNhmA1qHL7WTBGS1cPj1Rja3BPzOcBWSsIpUDcNWCcX6wUjBaq77AQQRN5VJxkdzQWD roAg== 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 :date:subject:message-id:cc:to:from:dkim-signature; bh=3A7kgd9EwxxMVaCsrHVPwN4E1w1q0zJ27JUMCn1+j8I=; b=xOn5jf5ylv13C9tXSI84wyu3H7iXxvfurLKz7D+BES9CA0XJ4qYzIUXNLXXIFP21HT CC7NuwQ8rfYcZPYz3VnbV+YunsBY36qDh46wJ1h4Fxp4wRIiQYazPD/5mSAVfawJdPuz FCdv9m5ZVQshQtBjy4WJ+a+BKNuAT/vb27n5aJbqctiE3YYDfOaI4tTPutoNNs0wxA/7 4RbQ+sxWNzhcsezuubdjrkcKFWpJ64r/MUXMb2WK+meqVZYO8g48UwTHAbvAMbePxoxl zg3BrXOoEkKtUd7Pe8w/Yu9D6p7dzVKoo+IDVF0Cv9kTnOYUhmR7HoMK8P6v1XQ930zd zVVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mykernel.net header.s=zohomail header.b="gYDNzy/O"; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 m9si7887996oie.148.2020.02.10.00.40.21; Mon, 10 Feb 2020 00:40:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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=@mykernel.net header.s=zohomail header.b="gYDNzy/O"; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726796AbgBJIkU (ORCPT + 99 others); Mon, 10 Feb 2020 03:40:20 -0500 Received: from sender2-of-o52.zoho.com.cn ([163.53.93.247]:21146 "EHLO sender2-of-o52.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726061AbgBJIkU (ORCPT ); Mon, 10 Feb 2020 03:40:20 -0500 X-Greylist: delayed 908 seconds by postgrey-1.27 at vger.kernel.org; Mon, 10 Feb 2020 03:40:19 EST DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1581323102; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=3A7kgd9EwxxMVaCsrHVPwN4E1w1q0zJ27JUMCn1+j8I=; b=gYDNzy/O4jxLfCBiZ8K3/QwpPIF1VpHqO3T0Vu8/4n3gQhZKFzF2+Q0141VSoCA1 VG7Ljt525yGdq940vhNk/GjSGDeBo2QY/DPn+S6B5gfVKnfWV5RTHYLmn/f6SuoOmL6 X52DMQ+eydX3jo7x0LoAFMA1ohoMXzSkSkX+nsX8= Received: from localhost.localdomain.localdomain (113.88.132.74 [113.88.132.74]) by mx.zoho.com.cn with SMTPS id 1581323097919611.4267119995156; Mon, 10 Feb 2020 16:24:57 +0800 (CST) From: Chengguang Xu To: tytso@mit.edu, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, Chengguang Xu Message-ID: <20200210082445.2379-1-cgxu519@mykernel.net> Subject: [PATCH] ext4: code cleanup for ext4_statfs_project() Date: Mon, 10 Feb 2020 16:24:45 +0800 X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoCNMailClient: External Content-Type: text/plain; charset=utf8 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Calling min_not_zero() to simplify complicated prjquota limit comparison in ext4_statfs_project(). Signed-off-by: Chengguang Xu --- fs/ext4/super.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 8434217549b3..5fc1f47f4c6f 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5585,13 +5585,8 @@ static int ext4_statfs_project(struct super_block *s= b, =09=09return PTR_ERR(dquot); =09spin_lock(&dquot->dq_dqb_lock); =20 -=09limit =3D 0; -=09if (dquot->dq_dqb.dqb_bsoftlimit && -=09 (!limit || dquot->dq_dqb.dqb_bsoftlimit < limit)) -=09=09limit =3D dquot->dq_dqb.dqb_bsoftlimit; -=09if (dquot->dq_dqb.dqb_bhardlimit && -=09 (!limit || dquot->dq_dqb.dqb_bhardlimit < limit)) -=09=09limit =3D dquot->dq_dqb.dqb_bhardlimit; +=09limit =3D min_not_zero(dquot->dq_dqb.dqb_bsoftlimit, +=09=09=09=09dquot->dq_dqb.dqb_bhardlimit); =09limit >>=3D sb->s_blocksize_bits; =20 =09if (limit && buf->f_blocks > limit) { @@ -5603,14 +5598,8 @@ static int ext4_statfs_project(struct super_block *s= b, =09=09=09 (buf->f_blocks - curblock) : 0; =09} =20 -=09limit =3D 0; -=09if (dquot->dq_dqb.dqb_isoftlimit && -=09 (!limit || dquot->dq_dqb.dqb_isoftlimit < limit)) -=09=09limit =3D dquot->dq_dqb.dqb_isoftlimit; -=09if (dquot->dq_dqb.dqb_ihardlimit && -=09 (!limit || dquot->dq_dqb.dqb_ihardlimit < limit)) -=09=09limit =3D dquot->dq_dqb.dqb_ihardlimit; - +=09limit =3D min_not_zero(dquot->dq_dqb.dqb_isoftlimit, +=09=09=09=09dquot->dq_dqb.dqb_ihardlimit); =09if (limit && buf->f_files > limit) { =09=09buf->f_files =3D limit; =09=09buf->f_ffree =3D --=20 2.21.1