From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796454479; b=F6oyDT+BxljGliST5y/sGlKu8xoImRvIlsNJuDC3x9rQobCd2ui+x4/G3qXiMXYQ1K6A Crb5g77iTiG2tluVL2P1RJa2wlvKUAilvJ459J8EQwK6VfanOtPNf0wiGfOXKAhh79uXz gaBahNGXqT6ncgoTWUrHJ3ZhKzEwqWdQpUmljUOXU4L/DDGHslzTAQvA8NE6RcywUTGNV pZehdy6KzbVEy1A80l0xOP+3zEL13ykfQ50iVW3sQCazM0A4dswsCFpx/dcWFegtxpWxx jbvcCseH3a+YaX+ZTm7SaEW7+DNljsi8sNsvq33QOK50mVvHb/BiEYVkqzv1kK+0q/g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796454479; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=xMJY9BrJtY4NsIvTIGfn1KnZnksewXkGVRxrqwVMC5c=; b=GzIE544eLnD/yh0UH2gGfAwbB+MRvmvP1besAvNGtUW/X4Vg+Qs1wt1u8FpsP1WnW1qF W2yblfBDMv4LNT9Kt0T+CNR3Mv/TsPxQwfJ8t8XPbD8DRrpGzEKVaHYORvvAp0QK/wKj7 9a8B4CIJ0zGoBwSad/f5rec23E8+xC5UnFsMJFQP2vSkXWkvZw61QTi0WMiZnYQY7lrBy IkDVuHzoRdzMfzYCf6oujCRVq94SZWkXF1P5DfVb/MfvcVpQak78ZVIUj5qawdrk4VqNp iJxtxHEQ6skwARguicD8nM4X9Xm2steTKwdYsCwzQsW0c+jDACa/cBm5+q4CMKSRzkA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bHmx1Gnz; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAC38606A322; Sat, 5 Dec 2026 07:07:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bHmx1Gnz Received: by smtp.kernel.org (Postfix) with ESMTPSA id 186BF1F00936; Sat, 5 Dec 2026 07:07:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796454479; bh=xMJY9BrJtY4NsIvTIGfn1KnZnksewXkGVRxrqwVMC5c=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=bHmx1GnzqAmvY/LNlSHZQf4BnXmhZbUElyxtggeXYpcxu8WRs2PRk5DntQXx6lGEM 6uRDRqnrsVJe+s1KZmJrqXUBhXYYT2CUTYcSGn/+0LuvWl478gp/RwJMhgYfEOsPc8 MFsEhKhHLCYFeZuYtl4yohaFCDXcm06rqSNvldCVg6NIxuxH9u5UOYq6Hz8ts5Db0B A/Tg1+mTV0LkxdeS3lI1uOOpYcPpXsDrnWfRczyy2FMhr86hr2eG+ufrPbzniDfJrY v+8if/RaHjWojuEmpuWGDIycxSE/Zy8ETW2NxM+L1lOiYRA+b79V192ouDLjwfO7Bb FplO0rkcGfJBQ== Date: Sat, 5 Dec 2026 08:07:54 +0100 From: Carlos Maiolino To: Jiaming Zhang Cc: linux-xfs@vger.kernel.org, "Darrick J. Wong" , Eric Sandeen , linux-kernel@vger.kernel.org Subject: Re: [Linux Kernel Bug] INFO: task hung in lookup_open Message-ID: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Sat, Dec 05, 2026 at 01:18:21PM +0800, Jiaming Zhang wrote: > Hi Linux kernel developers and maintainers, > > We are writing to report a hung-task issue on the XFS subsystem, > reproducible on the latest version of Linux (v7.4-rc5, commit > fe6ff8d5d675). > > It is triggered by mounting a small-block XFS image whose journal is > sized near the minimum log size (requiring CAP_SYS_ADMIN to mount) and > calling setxattr() with a large extended attribute on a directory while > concurrently opening a file inside it. Below is the kernel report: > > INFO: task repro.out:9432 blocked for more than 15 seconds. > Not tainted 7.4.0-rc5 #62 > Call Trace: > > __schedule+0x17c5/0x5b30 kernel/sched/core.c:7437 > schedule+0x165/0x2b0 kernel/sched/core.c:7529 > schedule_preempt_disabled+0x13/0x30 kernel/sched/core.c:7586 > rwsem_down_read_slowpath+0x708/0x9c0 kernel/locking/rwsem.c:1114 > down_read+0x97/0x320 kernel/locking/rwsem.c:1576 > inode_lock_shared include/linux/fs.h:1042 [inline] > lookup_open+0x201/0x1760 fs/namei.c:4466 > path_openat+0x6cd/0x1f80 fs/namei.c:5013 > do_file_open+0x203/0x440 fs/namei.c:5045 > do_sys_openat2+0x107/0x1e0 fs/open.c:1443 > __x64_sys_openat+0x138/0x170 fs/open.c:1460 > do_syscall_64+0x17b/0x560 arch/x86/entry/syscall_64.c:89 > entry_SYSCALL_64_after_hwframe+0x77/0x7f > > INFO: task repro.out:9442 blocked for more than 15 seconds. > Not tainted 7.4.0-rc5 #62 > Call Trace: > > __schedule+0x17c5/0x5b30 kernel/sched/core.c:7437 > schedule+0x165/0x2b0 kernel/sched/core.c:7529 > xlog_grant_head_wait+0x443/0xa10 fs/xfs/xfs_log.c:217 > xlog_grant_head_check+0x289/0x420 fs/xfs/xfs_log.c:-1 > xfs_log_reserve+0x2bc/0x780 fs/xfs/xfs_log.c:387 > xfs_trans_reserve fs/xfs/xfs_trans.c:174 [inline] > xfs_trans_alloc+0x29c/0x980 fs/xfs/xfs_trans.c:260 > xfs_trans_alloc_inode+0x13c/0x4a0 fs/xfs/xfs_trans.c:1088 > xfs_attr_set+0x808/0x13a0 fs/xfs/libxfs/xfs_attr.c:1183 > xfs_xattr_set+0x14d/0x250 fs/xfs/xfs_xattr.c:186 > __vfs_setxattr+0x43c/0x480 fs/xattr.c:223 > __vfs_setxattr_noperm+0x12d/0x660 fs/xattr.c:257 > vfs_setxattr+0x155/0x370 fs/xattr.c:344 > filename_setxattr+0x286/0x610 fs/xattr.c:690 > path_setxattrat+0x367/0x3b0 fs/xattr.c:734 > __x64_sys_setxattr+0xbc/0xe0 fs/xattr.c:764 > do_syscall_64+0x17b/0x560 arch/x86/entry/syscall_64.c:89 > entry_SYSCALL_64_after_hwframe+0x77/0x7f > > > Showing all locks held in the system: > locks held by repro.out/9432: 2, last CPU#0: > #0: ffff8880005c6478 (sb_writers#11){.+.+}-{0:0}, at: > mnt_want_write+0x41/0x90 fs/namespace.c:531 > #1: ffff88802994d2d0 > (&inode->i_sb->s_type->i_mutex_dir_key){++++}-{4:4}, at: > lookup_open+0x201/0x1760 fs/namei.c:4466 > locks held by repro.out/9442: 3, last CPU#1: > #0: ffff8880005c6478 (sb_writers#11){.+.+}-{0:0}, at: > mnt_want_write+0x41/0x90 fs/namespace.c:531 > #1: ffff88802994d2d0 > (&inode->i_sb->s_type->i_mutex_dir_key){++++}-{4:4}, at: > vfs_setxattr+0x12e/0x370 fs/xattr.c:343 > #2: ffff8880005c6668 (sb_internal#2){.+.+}-{0:0}, at: > xfs_trans_alloc+0xd7/0x980 fs/xfs/xfs_trans.c:258 > > Following is the root cause analysis for this issue. Note that the > analysis was performed with the assistance of an LLM, and we have tried > our best to ensure its accuracy. > > The hung-task triggers because lookup_open() is waiting for a shared > lock on the directory's i_rwsem while a concurrent setxattr() on the > same directory holds that i_rwsem exclusively. The setxattr() task > sleeps forever in xlog_grant_head_wait() to wait for XFS journal space. > > That sleep never finishes because its runtime log reservation disagrees > with the mount-time minimum journal size check. In XFS, small extended > attributes fit in a logged btree leaf block, whereas large values live > in separate remote blocks written synchronously to disk without being > logged (unless experimental log-assisted xattrs are enabled). > > At mount time, xfs_log_calc_max_attrsetm_res() estimates the worst-case > attribute log reservation based on the maximum local size and omits > remote value blocks. Meanwhile, at runtime, xfs_attr_calc_size() counts > those remote blocks toward disk-space reservation, and > xfs_attr_set_resv() reserves log space for every block in that total. > > On a small-block filesystem whose journal was sized near the mount-time > minimum, charging per-block journal space against unlogged remote value > blocks pushes the log reservation above the size of the entire journal. > > Since the journal cannot provide more space than its total size, log > flushes cannot satisfy the reservation and xlog_grant_head_wait() never > wakes up. The setxattr() task sleeps uninterruptibly while holding > i_rwsem and filesystem freeze protection, preventing directory access, > freeze, and unmount, and triggering a hung-task report. > > To fix this issue, we can subtract the unlogged remote attribute value > blocks in xfs_attr_set_resv() when log-assisted xattrs are not active, > which keeps the disk block reservation unchanged while matching the > mount-time log reservation model: > > diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c > index c4bb59633ce8..ef51158a1948 100644 > --- a/fs/xfs/libxfs/xfs_attr.c > +++ b/fs/xfs/libxfs/xfs_attr.c > @@ -332,12 +332,19 @@ xfs_attr_set_resv( > const struct xfs_da_args *args) > { > struct xfs_mount *mp = args->dp->i_mount; > + unsigned int nblks = args->total; > struct xfs_trans_res ret = { > - .tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + > - M_RES(mp)->tr_attrsetrt.tr_logres * args->total, > .tr_logcount = XFS_ATTRSET_LOG_COUNT, > .tr_logflags = XFS_TRANS_PERM_LOG_RES, > }; > + int local; > + > + xfs_attr_leaf_newentsize(args, &local); > + if (!local && !(args->op_flags & XFS_DA_OP_LOGGED)) > + nblks -= xfs_attr3_rmt_blocks(mp, args->valuelen); > + > + ret.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + > + M_RES(mp)->tr_attrsetrt.tr_logres * nblks; > > return ret; > } > diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c > index 82932b5c02fd..a0ef5c557ef2 100644 > --- a/fs/xfs/libxfs/xfs_attr_leaf.c > +++ b/fs/xfs/libxfs/xfs_attr_leaf.c > @@ -2920,8 +2920,8 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t > *leaf, int index) > */ > int > xfs_attr_leaf_newentsize( > - struct xfs_da_args *args, > - int *local) > + const struct xfs_da_args *args, > + int *local) > { > int size; > > diff --git a/fs/xfs/libxfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h > index 72639efe6ac3..b74fcf3a3041 100644 > --- a/fs/xfs/libxfs/xfs_attr_leaf.h > +++ b/fs/xfs/libxfs/xfs_attr_leaf.h > @@ -100,7 +100,7 @@ void xfs_attr3_leaf_unbalance(struct xfs_da_state *state, > xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_buf *bp, int *count); > int xfs_attr_leaf_order(struct xfs_buf *leaf1_bp, > struct xfs_buf *leaf2_bp); > -int xfs_attr_leaf_newentsize(struct xfs_da_args *args, int *local); > +int xfs_attr_leaf_newentsize(const struct xfs_da_args *args, int *local); > int xfs_attr3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp, > xfs_ino_t owner, xfs_dablk_t bno, struct xfs_buf **bpp); > void xfs_attr3_leaf_hdr_from_disk(struct xfs_da_geometry *geo, > > The kernel console output, kernel config, and C > reproducer are available on Google Drive: > https://drive.google.com/drive/folders/1nUNZj2FTnUvwAS8FkvgN8WdznOhC20S4?usp=sharing Send the reproducer inlined to the email, nobody is gonna follow random links on the mailing list. Same is valid for console output, kernel config, etc... At minimum send the files attached to the message. > > Best regards, > Jiaming Zhang