From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 869153DBD44 for ; Fri, 12 Jun 2026 12:48:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.218.45 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781268505; cv=pass; b=KWd2A3TnzUGidrsuVYVB1mnuKMCDGAGfp3fqjUx3ldhcnPk2tbAhHS1pA1edqnBH1sTNt4R6Vl6xDfnkbMCal2KlZ+1yMNhlZFgjJQ69GxHvEiX52m0cJe2fE2FEM1fwM7Kk/5sgR7R12GMVVRPETvop5XxP8r+weKu0SNMe0rc= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781268505; c=relaxed/simple; bh=wzyefegPQ56HaP/L1vGqh6l0U8XZBoOuHJKAbUD1xfE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=kSdFrYHgHh4mgEjGk/t3FnHUdcK88eDSAPbe+yXzFtaIMsquSItm+XAESs0tZFd8Ykl0LPQgPQ43hWuvdyHmo8TlQ7LaxW5dmtGkMmt46oNlqGZExanTl7VVWeb0Gipb6cOPDFj5e4YXf3QAP5O0ebtufLFGgJqJdZ2ibPMPCpY= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mZ/Sas0R; arc=pass smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mZ/Sas0R" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-bebb72b845aso155870866b.3 for ; Fri, 12 Jun 2026 05:48:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781268503; cv=none; d=google.com; s=arc-20240605; b=Bljp/g4yWIpFEShdJa0X5VMmmOVJgPsLP7nH2h3dSusssnZ29NCWrIo1VYVry7KCpN sVxJZv9w+sfVoUBVXSBxFUcDlhuDMAAEh45qZIf/WCrI/644Cr+SWJAnJJMgh3ZaRCDT Xby3GzlgDh9y+n7JOLRAhtrG0HaErYax0rXM73SIXV+sJiy546Kv77MHCt/rsgHlqJl2 xVp4ibDU09G0Ye+fA/qw2kFSY348qeeLpxWbmNwwUOuhZBzGnNaf1eSLL4vVmUU7frzo azDetu+Q/cr/KofCJFcUMo4ivoDW2gH0T8AL66QXzeGzufmhsb0AuLnAcP/KAWXSWsSo CWxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=C/B24oGIDZCDxK/eGLCqt4DHARmDrIFcF//V/k+AUtA=; fh=yvgWP7OCtVHmRwAwetcUSS3vcAi5oUD1rAxkuKk1baI=; b=e7Ty9kgcXw093FcLGZTAz0IHRleMtZM4W1VmdC/MSdLsT3pv7E02eDVFkijL98SNzW Yfk6Vb4aqUQABpUL+Z3broCyc1ng3eBNBRVIT+Sal735jrDB0kQyt1hTfZOtGRawOOMw TN92I/QvZc0n/Q0qjGZX9kvgAa3mn0sdaxzxL/Wp7ByAAtvrBlB69gpH6h6jyfPqDPLk PlPLuNSOeWhHqGanaRWAMrpsFcnvaHNkEAWeh9MI5fPLO8exefr6dtVfVKoHmIIjAhIy /xoZnLnIpSQUZsgMrccDw6+BzAIe2ybb4UNEz8WFEXJeXsb/GFfU7YgIiIf6kjD0Onuw 6tjQ==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781268503; x=1781873303; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=C/B24oGIDZCDxK/eGLCqt4DHARmDrIFcF//V/k+AUtA=; b=mZ/Sas0Rr2Ae8XJV2K1x12ancKIjrL82SpdoTRjGXrRNLDLc5civ9lnTN6CaIEv0Qt 6aCOaEmTWrdkWw6WZExJ2gdOX/4jcexU/Lq61MEsA1ZaCwEXuUuv2pJI4NVEJxop9ZyS FFJU/FvhJgs+FQCakUAvvo4/nvvwEhv76wSw5iPFufVk8s7YtbeoSeAIe1RikWYA97R0 CHeeq/oDMtj+V1Xek7smLhv0bSXhanpezgdmaRa8D5QIKFIWnA5VLbF+z/pYjtOWLCCB LWQUz+hi4N9AByrt2Cz3UXD7yNvUxyd0tHw9Ay5G+0IWB+EI92+H5oYtcOVMcOchMZ0Y 2nCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781268503; x=1781873303; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=C/B24oGIDZCDxK/eGLCqt4DHARmDrIFcF//V/k+AUtA=; b=fo+eoPhWWlxXKDXCA8tbi+gxQ1nYL/zap75Qbt/fEcNmNVJ2qe3WXrlcaDlDDOjG/I izKgqsshYbEq11TnaCOVlE0advbpKatxVl12Fh6tr4+wEN4Bn5A0h5jWXtW+AD+1a7Zf KugD90AU2WqyZ7D2N9/l/WHgPtOx+ZbBJ1YL+Eim/pqmPtR36HH+agNRc/nKuX92NwKo JVa5/UHH7hZvKOUgX5MODl6g+43YsN52nCvWZIybLhrGfy3UF1AGS1VsYT+czGowvV1j orlUG98LQT2viTZAXEhjiz0lTcs2Id82A6AeA3F0ZH3BiuzM4lhaCzKa3cN4WxkJkY8p XcoA== X-Forwarded-Encrypted: i=1; AFNElJ8R4jzBKQHSJRKVqF6pxtwjo8BeznXUHMQON+AQ5ubmrWS680eh7EntJLyvdeWKt1GMnypUEpyBVYOi/Fw=@vger.kernel.org X-Gm-Message-State: AOJu0YzUzhNu3J9/x1/jd+XZEwcFNDpuCxjXyOI0nUe0STZXGCaBX4e6 SKB4cgBXcwj+giStzEhl+U6sPdbv0MzZtoe2yRu0W4xQ9Q7OeubpBC6BXuJoqA54IQjNzy97AGC Hc7jvQt0uBpuH42zwnFiLjXIOHAw5AL0YFr/1s30OyQ== X-Gm-Gg: Acq92OHUXuzem9zdyxsBD/3r7vjwyrbuy27pbn41g7HD+RriH9Xuj0OXEUufFth/ZtB uUYM4Llpt7jUgAxhfhmT0tM8Lx0cxCPSfZa2EG/CWiwv9LpLW+OqszmmxX6AOE2bXWRIk9ljoDS m3gb4dG0h2r7c+3LA/9pXLDeRuZUt8gqhzgtjAvL8gu1DatrsOxNBWUL1oQ/kqEja5To18KFW8T RY/iJM8wph6bQiEaXE+8IE2lohF/M8mJmyM0T32LM2kSVpGVTn3zQLebsAttF6Y6Pag1ClJxoVB bHkW9ShovrfFXiKnE4KpcIlw+vw4InMHQGQEKjoCzYzlnmD6Kg== X-Received: by 2002:a17:907:7212:b0:bd5:7c2:7622 with SMTP id a640c23a62f3a-bfe2c09ded7mr139483466b.49.1781268502503; Fri, 12 Jun 2026 05:48:22 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260612114917.2192-1-aditya.ansh182@gmail.com> <20260612114917.2192-2-aditya.ansh182@gmail.com> In-Reply-To: <20260612114917.2192-2-aditya.ansh182@gmail.com> From: Aditya Prakash Srivastava Date: Fri, 12 Jun 2026 18:18:11 +0530 X-Gm-Features: AVVi8Ce1MI2RmRgthudlq6kJ37NVTS7dG9j4zOH4Owck4u_ON47J8q_fURPt-co Message-ID: Subject: Re: [PATCH v2 1/2] xfs: add a XFS_TRANS_WRITECOUNT_TRYLOCK flag To: Carlos Maiolino Cc: Christoph Hellwig , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Apologies for the mailing list noise in v2; a local stale patch file collision caused the wrong files and version headers to be sent. Please ignore this version v2 completely and take a look at the clean v3 series. Thanks Aditya Prakash Srivastava On Fri, Jun 12, 2026 at 5:20=E2=80=AFPM Aditya Srivastava wrote: > > From: Aditya Prakash Srivastava > > Introduce a new transaction allocation flag, XFS_TRANS_WRITECOUNT_TRYLOCK= . > When this flag is specified, __xfs_trans_alloc() attempts to obtain > freeze protection using sb_start_intwrite_trylock() instead of blocking > indefinitely on sb_start_intwrite(). > > If the trylock fails, the allocation is aborted gracefully: the freshly > allocated transaction handle is freed, and the function returns the > appropriate error pointer ERR_PTR(-EAGAIN), which is then propagated > to the caller by xfs_trans_alloc(). > > Also add an assertion in __xfs_trans_alloc() to ensure that both > XFS_TRANS_NO_WRITECOUNT and XFS_TRANS_WRITECOUNT_TRYLOCK are never > specified at the same time, as they are mutually exclusive. > > Suggested-by: Christoph Hellwig > Signed-off-by: Aditya Prakash Srivastava > --- > fs/xfs/libxfs/xfs_shared.h | 3 +++ > fs/xfs/xfs_trans.c | 12 +++++++++++- > 2 files changed, 14 insertions(+), 1 deletion(-) > > diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h > index b1e0d9bc1f7d..68d22b6cddd3 100644 > --- a/fs/xfs/libxfs/xfs_shared.h > +++ b/fs/xfs/libxfs/xfs_shared.h > @@ -164,6 +164,9 @@ void xfs_log_get_max_trans_res(struct xfs_moun= t *mp, > /* Transaction has locked the rtbitmap and rtsum inodes */ > #define XFS_TRANS_RTBITMAP_LOCKED (1u << 9) > > +/* Try lock filesystem superblock for freeze protection */ > +#define XFS_TRANS_WRITECOUNT_TRYLOCK (1u << 10) > + > /* > * Field values for xfs_trans_mod_sb. > */ > diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c > index 148cc32449c1..3860e44d6439 100644 > --- a/fs/xfs/xfs_trans.c > +++ b/fs/xfs/xfs_trans.c > @@ -216,10 +216,18 @@ __xfs_trans_alloc( > struct xfs_trans *tp; > > ASSERT(!(flags & XFS_TRANS_RES_FDBLKS) || xfs_has_lazysbcount(mp)= ); > + ASSERT(!((flags & XFS_TRANS_NO_WRITECOUNT) && > + (flags & XFS_TRANS_WRITECOUNT_TRYLOCK))); > > tp =3D kmem_cache_zalloc(xfs_trans_cache, GFP_KERNEL | __GFP_NOFA= IL); > - if (!(flags & XFS_TRANS_NO_WRITECOUNT)) > + if (flags & XFS_TRANS_WRITECOUNT_TRYLOCK) { > + if (!sb_start_intwrite_trylock(mp->m_super)) { > + kmem_cache_free(xfs_trans_cache, tp); > + return ERR_PTR(-EAGAIN); > + } > + } else if (!(flags & XFS_TRANS_NO_WRITECOUNT)) { > sb_start_intwrite(mp->m_super); > + } > xfs_trans_set_context(tp); > tp->t_flags =3D flags; > tp->t_mountp =3D mp; > @@ -252,6 +260,8 @@ xfs_trans_alloc( > */ > retry: > tp =3D __xfs_trans_alloc(mp, flags); > + if (IS_ERR(tp)) > + return PTR_ERR(tp); > WARN_ON(mp->m_super->s_writers.frozen =3D=3D SB_FREEZE_COMPLETE); > error =3D xfs_trans_reserve(tp, resp, blocks, rtextents); > if (error =3D=3D -ENOSPC && want_retry) { > -- > 2.47.3 >