Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp361108lqt; Thu, 18 Apr 2024 19:04:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWlZkpE9QDZVCUR7Yh+IpHiFKUaLMPh725Lk6sKklZdn8GDSgMGfYN2wP2GPj6lPP+3S2EdFSwuU+1IT/VpPvEdCd4AIrQWZz2EFBM6Gg== X-Google-Smtp-Source: AGHT+IE8cD0LCN/fMVCnVclGMLuPA1wgrBQ8jqyQcpsKDhW8EzD6cdUh7v0yVgBLCzO1clJ/PrrT X-Received: by 2002:ad4:424f:0:b0:69b:1a43:27f5 with SMTP id l15-20020ad4424f000000b0069b1a4327f5mr735865qvq.35.1713492254067; Thu, 18 Apr 2024 19:04:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713492254; cv=pass; d=google.com; s=arc-20160816; b=M1oussd9LYlyVT+gkDHF//9rfjZ1zn4290nljNEzrfGbXxPxv+MiaQSQX4qHsdAJWB gFAAw2CRUejbq/Jpe79o1lDC6+XuqBgc3eAKONA+IvYCXST+D8nv9kE9gIBB/mYGo4s2 FOvtUwBxAvYWPsMFmfeJx/ZLlf+1NrAJY+eBEAwDNVvQJ3X0PtvI0YQJ4WcR2hfwZ1LG JnH5oXUwQqhXQwpS+y/zNIzhjl3JNOuI8TZt+etYbsE5hCR+qlKsU2NunDMpL43OsO/U HuLuKy3IzcV8V7+sduStgRi1+nH/OTyyEzlikAnMzi5GgSSVA0+4qk0h2JChFLA76J0J AcXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=DEQEbU9xfJTa62i+kqLd50IBKPgtLGGZs77r0IHIcSs=; fh=L73nD7SxCnSQgdS1vC70ktEf0D1oHiYzzQkMvyU2Xe8=; b=QcAYV/8+WMZxYYy5kOed2M9wdF3WW/V42BZ6sWDtCtEZrgePRFc6Lc5srdIr+r3vRt w4j9xexwArvXdVOwyvxzWCBnaUZ7FJ/PFT5k9JA1yhQERyryGkAMDeme2IO296GQFBRz Apq4YLfYGmolY7wan5m8QA/UDRzna1rdvHfmGiW6D2V/lFE27DYj3YhFIJmooZDSygMM gl6k4Hu5i4ZnQnDkvQ1x6fQf5HtMuRxEDwaz75Ygcv5v0eO3QwrsFblDZD4AUie7k3pa 9rM3CN/N99l/3UKwMh0eRihIAXuArgL9Y7ow4Qj/b16GAUv+ZvegBESyjzksNiT7W52j ZXlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-150927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150927-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 4-20020a0562140d6400b006990dcb83dcsi2902656qvs.251.2024.04.18.19.04.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 19:04:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-150927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150927-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B84C91C21D3A for ; Fri, 19 Apr 2024 02:04:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 712167460; Fri, 19 Apr 2024 02:04:06 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47AD415A4; Fri, 19 Apr 2024 02:04:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713492245; cv=none; b=jyw+iaAdsHOVBprcoREDHH36oHB8e5chbq9YKs+vZGh81Rmsqa8odyB6Yj1pNoZFlZA2ZucpoyO/MDeEqgrUxsSMfxHlXxB243Jg2S+/8yzwmWfGGMR7fJgEoh3IAA0jrWLDJDZeYwT8ECZrJXFElukwSzFu1uF5jdaQIzG3kR4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713492245; c=relaxed/simple; bh=OykcDlVX+9nmzM/ihAuEwCvKbcJZwvq+flSaFWyV+AY=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=ci1GGGrZ5vqHsgxXCJqibuWz1KwuLuwzkFO9QnvvMUGbSRLb838z3TcRK6bx9hqL/azYdc9R9xGYUoKKvktxZoHNIqY+B2NzAjJkC5x58RY/GDV4g9ix1xaWjQFt+rT7o1Pz5rFVT7IfDqT9qqa+ByHZikReJRk+vj1cvvXDBog= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4VLHTs0SfVz1RCsb; Fri, 19 Apr 2024 09:43:13 +0800 (CST) Received: from canpemm500009.china.huawei.com (unknown [7.192.105.203]) by mail.maildlp.com (Postfix) with ESMTPS id E244F14035F; Fri, 19 Apr 2024 09:46:12 +0800 (CST) Received: from [10.108.234.194] (10.108.234.194) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 19 Apr 2024 09:46:12 +0800 Message-ID: <070eba70-0168-42e6-8bca-0936711074e4@huawei.com> Date: Fri, 19 Apr 2024 09:46:11 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] quota: fix to propagate error of mark_dquot_dirty() to caller To: Jan Kara , Chao Yu CC: Jan Kara , , References: <20240412094942.2131243-1-chao@kernel.org> <20240412121517.dydwqiqkdzvwpwf5@quack3> <20240412130130.m4msohzpiojtve7r@quack3> Content-Language: en-US From: "wangjianjian (C)" In-Reply-To: <20240412130130.m4msohzpiojtve7r@quack3> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500009.china.huawei.com (7.192.105.203) On 2024/4/12 21:01, Jan Kara wrote: > On Fri 12-04-24 14:15:17, Jan Kara wrote: >> On Fri 12-04-24 17:49:42, Chao Yu wrote: >>> in order to let caller be aware of failure of mark_dquot_dirty(). >>> >>> Signed-off-by: Chao Yu >> >> Thanks. I've added the patch to my tree. > > So this patch was buggy because mark_all_dquots() dirty was returning 1 in > case some dquot was indeed dirtied which resulted in e.g. > dquot_alloc_inode() to return 1 and consequently __ext4_new_inode() to fail This is what I try to say in my another f2fs patch, some callers use if return value is zero not *less than zero* to check success or not. Luckily, maybe f2fs doesn't use it this way. > and eventually we've crashed in ext4_create(). I've fixed up the patch to > make mark_all_dquots() return 0 or error. > > Honza > >>> --- >>> fs/quota/dquot.c | 21 ++++++++++++++------- >>> 1 file changed, 14 insertions(+), 7 deletions(-) >>> >>> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c >>> index dacbee455c03..b2a109d8b198 100644 >>> --- a/fs/quota/dquot.c >>> +++ b/fs/quota/dquot.c >>> @@ -1737,7 +1737,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags) >>> >>> if (reserve) >>> goto out_flush_warn; >>> - mark_all_dquot_dirty(dquots); >>> + ret = mark_all_dquot_dirty(dquots); >>> out_flush_warn: >>> srcu_read_unlock(&dquot_srcu, index); >>> flush_warnings(warn); >>> @@ -1786,7 +1786,7 @@ int dquot_alloc_inode(struct inode *inode) >>> warn_put_all: >>> spin_unlock(&inode->i_lock); >>> if (ret == 0) >>> - mark_all_dquot_dirty(dquots); >>> + ret = mark_all_dquot_dirty(dquots); >>> srcu_read_unlock(&dquot_srcu, index); >>> flush_warnings(warn); >>> return ret; >>> @@ -1990,7 +1990,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to) >>> qsize_t inode_usage = 1; >>> struct dquot __rcu **dquots; >>> struct dquot *transfer_from[MAXQUOTAS] = {}; >>> - int cnt, index, ret = 0; >>> + int cnt, index, ret = 0, err; >>> char is_valid[MAXQUOTAS] = {}; >>> struct dquot_warn warn_to[MAXQUOTAS]; >>> struct dquot_warn warn_from_inodes[MAXQUOTAS]; >>> @@ -2087,8 +2087,12 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to) >>> * mark_all_dquot_dirty(). >>> */ >>> index = srcu_read_lock(&dquot_srcu); >>> - mark_all_dquot_dirty((struct dquot __rcu **)transfer_from); >>> - mark_all_dquot_dirty((struct dquot __rcu **)transfer_to); >>> + err = mark_all_dquot_dirty((struct dquot __rcu **)transfer_from); >>> + if (err < 0) >>> + ret = err; >>> + err = mark_all_dquot_dirty((struct dquot __rcu **)transfer_to); >>> + if (err < 0) >>> + ret = err; >>> srcu_read_unlock(&dquot_srcu, index); >>> >>> flush_warnings(warn_to); >>> @@ -2098,7 +2102,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to) >>> for (cnt = 0; cnt < MAXQUOTAS; cnt++) >>> if (is_valid[cnt]) >>> transfer_to[cnt] = transfer_from[cnt]; >>> - return 0; >>> + return ret; >>> over_quota: >>> /* Back out changes we already did */ >>> for (cnt--; cnt >= 0; cnt--) { >>> @@ -2726,6 +2730,7 @@ static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di) >>> struct mem_dqblk *dm = &dquot->dq_dqb; >>> int check_blim = 0, check_ilim = 0; >>> struct mem_dqinfo *dqi = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type]; >>> + int ret; >>> >>> if (di->d_fieldmask & ~VFS_QC_MASK) >>> return -EINVAL; >>> @@ -2807,7 +2812,9 @@ static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di) >>> else >>> set_bit(DQ_FAKE_B, &dquot->dq_flags); >>> spin_unlock(&dquot->dq_dqb_lock); >>> - mark_dquot_dirty(dquot); >>> + ret = mark_dquot_dirty(dquot); >>> + if (ret < 0) >>> + return ret; >>> >>> return 0; >>> } >>> -- >>> 2.40.1 >>> >> -- >> Jan Kara >> SUSE Labs, CR >> -- Regards