Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp274965lqp; Fri, 12 Apr 2024 18:30:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVJl9iJvE0palSlOfJiBGKfDp9jYbhZFqfptBxsSobLP2PGcM1RjUOIwm5+aG6FSac/tqWHdjPJlgSMpD1LL3nhpyayykPRyE/GJ+b3kA== X-Google-Smtp-Source: AGHT+IE2MYpBcBUMaFh+/1QCwQsHd6IfAY6QGLnyRDSzZzmvFwGBkFNWhWIat3nBDbC+CqmL/NLO X-Received: by 2002:a17:907:9404:b0:a52:30d4:20e6 with SMTP id dk4-20020a170907940400b00a5230d420e6mr3887321ejc.10.1712971838621; Fri, 12 Apr 2024 18:30:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712971838; cv=pass; d=google.com; s=arc-20160816; b=nosMZS0ENMniS4H02D92lLodDNlEZdKNoIUXAm1m0FTKnHQqaBN6509QBY2ZrimWqa aAI6OzsbOmGRvjmk3Bw/TRIGqvujoPgl1p0IHsTs4Z2wBajAVMuqiQVh6KNq96cig3+G K0SXKT8E3FLJdYQeWyFxsnKZ6Ite5S91zDoUwqcDFtH/+fgwbnVQJUfYTvoo9SLu9TE6 SKRs3YzXku8h9gw1Lvmek9fBzTqQnDRHYNM/heZ5bdxUW+SDS4WQ3srJ+GbFuSUPYp1w y0Q0okvnHzbSrdsym/ydJP/MWTn1+fZlTm7HLWmhJhAgkySfa6pHYyCK2gUdPF5ZnmYX VkmQ== 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:dkim-signature; bh=foj7S2Vgm2L/j7xOtyGwxdgq1V5bFjrL4CoNlejz51A=; fh=Lb5NCRMQKywxC07h+lUrDH3ay742ZH4UwvHZj/Z+Pzk=; b=izldzLZrnCM+vbvNdfn3t7AmxZqUegAi0P0a1HfGCkeFzttTdaFg5pOIkzGhaRcXPz it4B1M1XlsA41iCOKlFh4NL/lZ1obbEILlps5zuYW+xOfIWPmflnEXUC1njJE5Gm6mR7 UW9MM62ChO94TSXe72qjoIS7tC6nkPuD/bwFXlq2hnA5I2jHSvTZtKLl5+/sfaytLNf7 XUwhScePjFt47ZOS/fXoG10qhqiCYb/zWfZbxmM+P2IfkUGXIe6FUy29COHM8OWeIJ34 XMVB1aXxUGMowZSVEuGmd2ELbYNr/ZpA+6a8Y31wix6Ig7W3OaELolsQRvsKCFtHH4bj mjBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nzstgtCA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-143489-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143489-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id di22-20020a170906731600b00a4e2b8acd37si2229658ejc.787.2024.04.12.18.30.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 18:30:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143489-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nzstgtCA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-143489-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143489-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5B99C1F2292C for ; Sat, 13 Apr 2024 01:30:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFD8CBE5E; Sat, 13 Apr 2024 01:30:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nzstgtCA" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0EBA063C8; Sat, 13 Apr 2024 01:30:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712971828; cv=none; b=MBNwKn6J6UA6OHtAQN06P7XxzWXmJ1qj5RzNy9/btmF5XJGoRGrjhMpQlqr6Plzg2kn9no5APSWR95HXQgop2/dVT/GS64wxNGuQ8uuMhVj5duuaqFF3ILTISZTXonyXASwIRpxjho3hdWann0soSquGYPwNn6ySjSP0gnQ1iWY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712971828; c=relaxed/simple; bh=d2icaWJTTOCZ5p+K61BPO2+gXckymnqiwHcjN9WUKe0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=EzXmH94mKSxo0c9J1oWCAOFBleHXrMg8UkY1Rb40hhkM5dH4DTsbP2DXgr3i/v51L2LNwvF24Jgx4LENoXNoQ38M7EpUbkpG9YDKqrMc1glgNLS9rxRnImhyXQXCqkbwtwihe7QSuJwjAfEswzHvU8BPFtHwE4BQmaObzbenc4w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nzstgtCA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FEA4C113CC; Sat, 13 Apr 2024 01:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712971827; bh=d2icaWJTTOCZ5p+K61BPO2+gXckymnqiwHcjN9WUKe0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=nzstgtCALFZLYrHVuB/4ho0QONvxViQK41ZeNBgY1MirDR3BM9reA6wzV3ztKn/4Y 7olDDQ2OiPSG4aBWP6FQKq5GkNFvseLFwAhIKCfOaSTndLaiGXXwbg6YiB/Vf3RwrU s/6cgMFMYGdfFB9DeQ+VHSdeB5+llLPq4peH4z7be9HlFEbjJ9na80l5IZVYTSJYxk MYZloJslfAW5QblF1coreliXQcwNQiKovAm2Tljv5rxT1ZASKHUg1fiIubF+y8C+RN u0U57Vzcoyd256Shgr/BihKR91Jb76oIKFTpxFqSoqd15BItGAeSvWhACmaPxcvarH N6H4FU+hy7O6A== Message-ID: <43f55f4b-cb2a-4845-9ded-40ce68f3351c@kernel.org> Date: Sat, 13 Apr 2024 09:30:22 +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 Cc: Jan Kara , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240412094942.2131243-1-chao@kernel.org> <20240412121517.dydwqiqkdzvwpwf5@quack3> <20240412130130.m4msohzpiojtve7r@quack3> Content-Language: en-US From: Chao Yu In-Reply-To: <20240412130130.m4msohzpiojtve7r@quack3> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 Correct, I missed that case. > and eventually we've crashed in ext4_create(). I've fixed up the patch to > make mark_all_dquots() return 0 or error. Thank you for catching and fixing it. Thanks, > > 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 >>