From patchwork Thu Nov 21 12:38:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ojaswin Mujoo X-Patchwork-Id: 13881980 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 A579B1D5CF4; Thu, 21 Nov 2024 12:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732192753; cv=none; b=IL/T742AlAyoVhKe+/vRyT+lMcq+iSJDIHH2+DE7DxUwPq8p0JNi3nn4lSguKFO7FYqUn4bHjOb+mOaIYCB/26wCbHcZXH9Stb+GxxhDxxN/M6xzgoNIGhY9CdZXaQJ1nb7B3vP9JIxhvb0UIdanFkEurcx9FpzVxnmrRUN/VSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732192753; c=relaxed/simple; bh=lVZt8MAf7kkaaO+sHrnxX0XCHBKXRF4CIQEBJX6VbmM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fvm8zWAov0x0tYqfLAUiHG5vgdc9h6xBmTfucackXSfg/Rl27qvp+uVM7SPpWPFTf2Bme68NPQHhv2adBi36rtHW8z5aTqGbKSA8Axc/Br1lhqZIEsTUC8llZ8JH7GMY6bwak0K9VfkCyfEIbtcOe18Y0zk/xQSlQVTAN9b4lww= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=CXufiznA; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="CXufiznA" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AL8U2wY026462; Thu, 21 Nov 2024 12:39:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=mffRGIB0w7sWnxdiG C3Vnix6diCVwxasN7KuHTWA03M=; b=CXufiznAHQehCCZaWU0911bTAhfP+8xcF uTwBlVLOIjJTZXU6f9M+EcZ3BgjS4OSvb3LuL/+H1cm+x4sie88cLE5Riu8+9cHy RljeYwogejGpFQi94e9QyMPNhyFJQoO1iFJ9pOjnJ6IwcRrBgcWcaEDoC1oMrkAU HgRrvXH8fERCuBcUZjs489sW6poeojfR4oq6Shja7vUuCQpswwH3hcphLynktwWT Gz94GKfIahaWHxafW5Imym2w+01ykdkFnfMoyZDuy8sB/5LQmZ+FSd7R7pLb6eyX E38rk2p8LdwJPnRSc6GVLHyb82OKbvoqd7u/vno6HgS0jBxfjzdLA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42xgttjw27-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Nov 2024 12:39:02 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 4ALCYT6F025020; Thu, 21 Nov 2024 12:39:02 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42xgttjw23-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Nov 2024 12:39:02 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4ALC0PMT030928; Thu, 21 Nov 2024 12:39:01 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 42y6406v7f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Nov 2024 12:39:01 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4ALCcxC418743738 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Nov 2024 12:38:59 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 618E020040; Thu, 21 Nov 2024 12:38:59 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F134220043; Thu, 21 Nov 2024 12:38:57 +0000 (GMT) Received: from li-bb2b2a4c-3307-11b2-a85c-8fa5c3a69313.in.ibm.com (unknown [9.109.253.82]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 Nov 2024 12:38:57 +0000 (GMT) From: Ojaswin Mujoo To: linux-ext4@vger.kernel.org, Jan Kara Cc: Ritesh Harjani , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Baokun Li , Disha Goel Subject: [PATCH v2 1/2] quota: flush quota_release_work upon quota writeback Date: Thu, 21 Nov 2024 18:08:54 +0530 Message-ID: <20241121123855.645335-2-ojaswin@linux.ibm.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241121123855.645335-1-ojaswin@linux.ibm.com> References: <20241121123855.645335-1-ojaswin@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ysEZuPwQuLBF1DXoG1MEKeKGOq_5nkq7 X-Proofpoint-ORIG-GUID: T5juno6gNEwL7piVe2BgrvMhsc5AMXJy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411210098 One of the paths quota writeback is called from is: freeze_super() sync_filesystem() ext4_sync_fs() dquot_writeback_dquots() Since we currently don't always flush the quota_release_work queue in this path, we can end up with the following race: 1. dquot are added to releasing_dquots list during regular operations. 2. FS Freeze starts, however, this does not flush the quota_release_work queue. 3. Freeze completes. 4. Kernel eventually tries to flush the workqueue while FS is frozen which hits a WARN_ON since transaction gets started during frozen state: ext4_journal_check_start+0x28/0x110 [ext4] (unreliable) __ext4_journal_start_sb+0x64/0x1c0 [ext4] ext4_release_dquot+0x90/0x1d0 [ext4] quota_release_workfn+0x43c/0x4d0 Which is the following line: WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE); Which ultimately results in generic/390 failing due to dmesg noise. This was detected on powerpc machine 15 cores. To avoid this, make sure to flush the workqueue during dquot_writeback_dquots() so we dont have any pending workitems after freeze. Reported-by: Disha Goel Signed-off-by: Ojaswin Mujoo --- fs/quota/dquot.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 3dd8d6f27725..f9578918cfb2 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -688,6 +688,8 @@ int dquot_writeback_dquots(struct super_block *sb, int type) WARN_ON_ONCE(!rwsem_is_locked(&sb->s_umount)); + flush_delayed_work("a_release_work); + for (cnt = 0; cnt < MAXQUOTAS; cnt++) { if (type != -1 && cnt != type) continue; From patchwork Thu Nov 21 12:38:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ojaswin Mujoo X-Patchwork-Id: 13881981 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 C6F001D88DB; Thu, 21 Nov 2024 12:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732192756; cv=none; b=TOoXjiDBdc6TGKlVnJ4j0J9DvTXbenYheBdFmAVUb2L0NFiwVDuCUcPsNm6cHiQVvE8p9yDY1ww+DHOweoRn1nME/841geY7hbdml7IytYWWwn5icnIXGsBkaxh+4QELl51zC3AYELR8VkKpy7uKyFRX0CgGsBtJKQrJBuMyFBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732192756; c=relaxed/simple; bh=B8GqijIB9N/1AFGTCbVn1XUujQ0Lf4y4voWprvckrtg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hfQQHGW6TTYqlTK75pTpAwxpjUih0QV8N5K4VUzyHdOKkoUAAgTopgqARqmU7A4I3XW6ykFPdBY8SQRuqItyFse/gY4Dt5GsBAbCaJdlo1xC0gb4VUnTsFYCkEa3eVPP/ES6NMbKP/JwLWmSQK797L211BGcwlRAQqZdHadVxhA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=KFislYDl; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="KFislYDl" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4ALB7kOQ013740; Thu, 21 Nov 2024 12:39:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=AircdhM9t7KhZhzjR i2KyF4F7qM3wAYxutesfNE/5lI=; b=KFislYDlAcow4Q9h9OIWqgXrnbv3bwn1C REBhLLPb1+GWlf1/P6pdc4YMyEyIVkWPGOIMjxwSNGUeCpBWBRWvEANasmPOmpYM YxRj2TQcaVer9msZ1qs1cAOtM/Pzkc+jZfBaacbYtyEgcOJMWSvyWIAha3H5bxJS 1EwblMFdskkZgvpuHrdgohS+wo4OmP6NNZqXNjyeLLM1tyj3lndarWwfCovA3bh5 kdVEQHD7s3XvyyobhSPutn88eNN0dT3O0E0EFroE9iuE5bIsdt+NS3Jr/NXjJAwk 7P9ocK120fGmRoePDtMIDTJfl6UECg3EgPPEQVo2C5Ug0r7RN+Eiw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4313gss28y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Nov 2024 12:39:04 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 4ALCWMM2011487; Thu, 21 Nov 2024 12:39:03 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4313gss28v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Nov 2024 12:39:03 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4AL61x16011994; Thu, 21 Nov 2024 12:39:02 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 42y7xjrmhw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Nov 2024 12:39:02 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4ALCd1NW50463112 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Nov 2024 12:39:01 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1CF7420043; Thu, 21 Nov 2024 12:39:01 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ABE0520040; Thu, 21 Nov 2024 12:38:59 +0000 (GMT) Received: from li-bb2b2a4c-3307-11b2-a85c-8fa5c3a69313.in.ibm.com (unknown [9.109.253.82]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 Nov 2024 12:38:59 +0000 (GMT) From: Ojaswin Mujoo To: linux-ext4@vger.kernel.org, Jan Kara Cc: Ritesh Harjani , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Baokun Li , Jan Kara Subject: [PATCH v2 2/2] ext4: protect ext4_release_dquot against freezing Date: Thu, 21 Nov 2024 18:08:55 +0530 Message-ID: <20241121123855.645335-3-ojaswin@linux.ibm.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241121123855.645335-1-ojaswin@linux.ibm.com> References: <20241121123855.645335-1-ojaswin@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: tT0fGatMFgmKjtRL9IZfbIS12NEjkN5t X-Proofpoint-ORIG-GUID: TXfElQl-UB863MxzA61tWa3Mwk4Jd2Oi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 adultscore=0 mlxlogscore=973 mlxscore=0 malwarescore=0 spamscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411210098 Protect ext4_release_dquot against freezing so that we don't try to start a transaction when FS is frozen, leading to warnings. Further, avoid taking the freeze protection if a transaction is already running so that we don't need end up in a deadlock as described in 46e294efc355 ext4: fix deadlock with fs freezing and EA inodes Suggested-by: Jan Kara Signed-off-by: Ojaswin Mujoo --- fs/ext4/super.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 16a4ce704460..f7437a592359 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -6887,12 +6887,25 @@ static int ext4_release_dquot(struct dquot *dquot) { int ret, err; handle_t *handle; + bool freeze_protected = false; + + /* + * Trying to sb_start_intwrite() in a running transaction + * can result in a deadlock. Further, running transactions + * are already protected from freezing. + */ + if (!ext4_journal_current_handle()) { + sb_start_intwrite(dquot->dq_sb); + freeze_protected = true; + } handle = ext4_journal_start(dquot_to_inode(dquot), EXT4_HT_QUOTA, EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb)); if (IS_ERR(handle)) { /* Release dquot anyway to avoid endless cycle in dqput() */ dquot_release(dquot); + if (freeze_protected) + sb_end_intwrite(dquot->dq_sb); return PTR_ERR(handle); } ret = dquot_release(dquot); @@ -6903,6 +6916,10 @@ static int ext4_release_dquot(struct dquot *dquot) err = ext4_journal_stop(handle); if (!ret) ret = err; + + if (freeze_protected) + sb_end_intwrite(dquot->dq_sb); + return ret; }