Re: [Linux Kernel Bug] INFO: task hung in lookup_open
From: Carlos Maiolino
Date: Sat Dec 05 2026 - 02:08:05 EST
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:
> <TASK>
> __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
> </TASK>
> INFO: task repro.out:9442 blocked for more than 15 seconds.
> Not tainted 7.4.0-rc5 #62
> Call Trace:
> <TASK>
> __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
> </TASK>
>
> 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