From nobody Fri Nov 22 22:48:30 2024 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 Content-Type: text/plain; charset="utf-8" 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 =3D 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 =3D true; + } =20 handle =3D 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 =3D dquot_release(dquot); @@ -6903,6 +6916,10 @@ static int ext4_release_dquot(struct dquot *dquot) err =3D ext4_journal_stop(handle); if (!ret) ret =3D err; + + if (freeze_protected) + sb_end_intwrite(dquot->dq_sb); + return ret; } =20 --=20 2.43.5