Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19205457rwd; Wed, 28 Jun 2023 06:31:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7u6nIEd2UpRXt4/eaMeFU8wnaucLiV5IdH3vjThekm9hwNSWFqEG8fuokXSiAl/VOZIx/d X-Received: by 2002:a17:903:11c6:b0:1b6:b1f3:add5 with SMTP id q6-20020a17090311c600b001b6b1f3add5mr11427991plh.27.1687959065954; Wed, 28 Jun 2023 06:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687959065; cv=none; d=google.com; s=arc-20160816; b=kwAnUMWU0UTdGm/PUagIsuVwUc5ieDABaTtg5gHapP28qGbSRifug70UMW7j+/ukmF H/a4oiHQ8OxChHLabCJXVL3gPkSUR7zqZkNIxQDGuGZdIA5UhoiqzDzpkpN8cz2FkcvV Gmio+oJeMIhUU6DuWd33KeQajDtd+xqU7naqrdbk2UCfPsKmKswUveV4kbciouXEsIUN 3nu7/Nn/FetAdr8zSobBUb1WYT9+D7wZfQ+ahFVUS3pFwy3ZNFwSVVMNmLsglOgvwd/f MjwXV4Fo3PTcII/1zo54VgRf7lJqWTAigCJQZ/And7wdphU4soOSMBCkSv5+ldEA4YyA EL2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=k3803zrpojoyIGDeMElexBNZngRvfvN6LU/9u3GBycE=; fh=fHzCyx2lgDg5rzxkd+fn4L1zIOfYfCj3lN8BN24cVWY=; b=BUBqJEBV6oQlStu/Jm3pjpOSRB+vJH5FoOqdRVDnNKgK5ECjly93lW6k94URqwdoE3 sGHQsfviIIG1KlYR/b2B+fHob+ON/Atl2jnt1Mpy23g6Ul81ptD6qNU2o0ljUruIBAnx jTCV1+2Za5QIAAp2UWgA7+knWN99G+G0W32OnRrrDPAXL3T0icFiJe3WpJ86wlK+miCG lXbAR2BHgA29VFY4N9XfmHBuFFLLapkS4Mn/GgMeM2wLulaYGO8jDq5LueKB8oKt5eWm tTkf6LvyqKYjq69zBAVuhfFS7Dp2SyowQMHS2jvYAl5wpIBKBvZtusulY/zMcva5vXq/ wkzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a4-20020a170902ecc400b001b559aa99bfsi9740161plh.455.2023.06.28.06.30.52; Wed, 28 Jun 2023 06:31:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231937AbjF1NY3 (ORCPT + 99 others); Wed, 28 Jun 2023 09:24:29 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:44130 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231825AbjF1NYW (ORCPT ); Wed, 28 Jun 2023 09:24:22 -0400 Received: from dggpeml500021.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Qrhzm3pmnzMpbx; Wed, 28 Jun 2023 21:21:08 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggpeml500021.china.huawei.com (7.185.36.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 28 Jun 2023 21:24:19 +0800 From: Baokun Li To: CC: , , , , , , , Subject: [PATCH v2 6/7] quota: simplify drop_dquot_ref() Date: Wed, 28 Jun 2023 21:21:54 +0800 Message-ID: <20230628132155.1560425-7-libaokun1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628132155.1560425-1-libaokun1@huawei.com> References: <20230628132155.1560425-1-libaokun1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500021.china.huawei.com (7.185.36.21) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Now when dqput() drops the last reference count, it will call synchronize_srcu(&dquot_srcu) in quota_release_workfn() to ensure that no other user will use the dquot after the last reference count is dropped, so we don't need to call synchronize_srcu(&dquot_srcu) in drop_dquot_ref() and remove the corresponding logic directly to simplify the code. Signed-off-by: Baokun Li --- fs/quota/dquot.c | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index e8e702ac64e5..df028fb2ce72 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -1090,8 +1090,7 @@ static int add_dquot_ref(struct super_block *sb, int type) * Remove references to dquots from inode and add dquot to list for freeing * if we have the last reference to dquot */ -static void remove_inode_dquot_ref(struct inode *inode, int type, - struct list_head *tofree_head) +static void remove_inode_dquot_ref(struct inode *inode, int type) { struct dquot **dquots = i_dquot(inode); struct dquot *dquot = dquots[type]; @@ -1100,21 +1099,7 @@ static void remove_inode_dquot_ref(struct inode *inode, int type, return; dquots[type] = NULL; - if (list_empty(&dquot->dq_free)) { - /* - * The inode still has reference to dquot so it can't be in the - * free list - */ - spin_lock(&dq_list_lock); - list_add(&dquot->dq_free, tofree_head); - spin_unlock(&dq_list_lock); - } else { - /* - * Dquot is already in a list to put so we won't drop the last - * reference here. - */ - dqput(dquot); - } + dqput(dquot); } /* @@ -1137,8 +1122,7 @@ static void put_dquot_list(struct list_head *tofree_head) } } -static void remove_dquot_ref(struct super_block *sb, int type, - struct list_head *tofree_head) +static void remove_dquot_ref(struct super_block *sb, int type) { struct inode *inode; #ifdef CONFIG_QUOTA_DEBUG @@ -1159,7 +1143,7 @@ static void remove_dquot_ref(struct super_block *sb, int type, if (unlikely(inode_get_rsv_space(inode) > 0)) reserved = 1; #endif - remove_inode_dquot_ref(inode, type, tofree_head); + remove_inode_dquot_ref(inode, type); } spin_unlock(&dq_data_lock); } @@ -1176,13 +1160,8 @@ static void remove_dquot_ref(struct super_block *sb, int type, /* Gather all references from inodes and drop them */ static void drop_dquot_ref(struct super_block *sb, int type) { - LIST_HEAD(tofree_head); - - if (sb->dq_op) { - remove_dquot_ref(sb, type, &tofree_head); - synchronize_srcu(&dquot_srcu); - put_dquot_list(&tofree_head); - } + if (sb->dq_op) + remove_dquot_ref(sb, type); } static inline -- 2.31.1