From 9016356a288cb3365ba69c4f287406aa7ebdf97a Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Tue, 11 Feb 2020 10:32:29 +0800 Subject: [PATCH] LU-13234: osd-ldiskfs: hold inode mutex for ldiskfs_orphan_add() See following warning: /home/green/git/lustre-release/ldiskfs/namei.c:3310 ldiskfs_orphan_add+0x11e/0x2a0 [ldiskfs] ... Call Trace: [] dump_stack+0x19/0x1b [] __warn+0xd8/0x100 [] warn_slowpath_null+0x1d/0x20 [] ldiskfs_orphan_add+0x11e/0x2a0 [ldiskfs] [] osd_punch+0x2a3/0x6c0 [osd_ldiskfs] [] ? tgt_fmd_put+0x41/0x120 [ptlrpc] [] ofd_object_punch+0x7e8/0xce0 [ofd] [] ofd_punch_hdl+0x4f3/0xa70 [ofd] [] tgt_request_handle+0x965/0x1620 [ptlrpc] [] ? libcfs_nid2str_r+0xfe/0x130 [lnet] [] ptlrpc_server_handle_request+0x250/0xb10 [ptlrpc] [] ? __wake_up_common_lock+0x91/0xc0 [] ? sched_feat_set+0xf0/0xf0 [] ptlrpc_main+0xcb0/0x1cb0 [ptlrpc] [] ? finish_task_switch+0x5d/0x1b0 [] ? ptlrpc_register_service+0xff0/0xff0 [ptlrpc] [] kthread+0xe4/0xf0 [] ? kthread_create_on_node+0x140/0x140 [] ret_from_fork_nospec_begin+0x7/0x21 [] ? kthread_create_on_node+0x140/0x140 Hold mutex lock for ldiskfs_orphan_add() to eliminate warning. Fixes: f64e9f19f68e ("LU-12977 ldiskfs: properly take inode_lock() for truncates") Change-Id: I810c3c170649b3c96d98f227a480bb1092f2386c Signed-off-by: Wang Shilong Reviewed-on: https://review.whamcloud.com/37528 Reviewed-by: Andreas Dilger Tested-by: jenkins Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 26d9c3b..3f83d18 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -1948,10 +1948,12 @@ static int osd_punch(const struct lu_env *env, struct dt_object *dt, GOTO(out, rc); } + inode_lock(inode); /* add to orphan list to ensure truncate completion * if this transaction succeed. ldiskfs_truncate() * will take the inode out of the list */ rc = ldiskfs_orphan_add(oh->ot_handle, inode); + inode_unlock(inode); if (rc != 0) GOTO(out, rc); -- 1.8.3.1