Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp366355pxb; Wed, 18 Aug 2021 04:23:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0zLIFYA4tpTzcvElVyT/18xqeVwzSzLRiLP57KW3idQqlcdg8YfSVdTzcSJxrma+HBSqz X-Received: by 2002:a17:907:1b29:: with SMTP id mp41mr9328646ejc.459.1629285823390; Wed, 18 Aug 2021 04:23:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629285823; cv=none; d=google.com; s=arc-20160816; b=oT+DWLB/Xm1lr2e0Yji27mGjG174RAwDkewW3jsMWkF/Cbt2PbWEKgiv5OjcDQXS4G uqECcuagcAskpHFSMsBBkMxpmlqaxP83UrIj0dSUlFhb95Q5c6jUDmBFANVG19ZzUZH0 1BzaAGdhtwWMwuOpAVdA4/TsLkmAy58FASzBTftjdxrVGVc3KQrHIHBqNldv/VVFpArp V+HBuLvmyJiUon4VG6CXy2Ny+3jh2b8mAd99YQVjFCKXTsld9TX71PdCVEYrotOdGAxB iY6SKRevUKwl/bLCmcpBzXzF5SrHO/XjLKgwlCshPbQd81gUu/G68lvpKbaCDzRS2jv2 uQ9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=Nfs/VbiqMsvN+i2jlep8mCHKNU0YRmgP4676mrqOt6A=; b=mlNZ8pCWZPjkXVBDbpU9k9kdVjHTi7TXMCnPG1TzCrJzc3YWYK4FMUf7iVTgidZoK/ zwGjEDRICWYBrwzc9HdZe7WIkvlbj2lBA0lYv0MRs7glrvAojq4Us2SQyRCZ7BwUcCvQ bifoKpuUkzRMqlkGJyqsN3UA58B2aPMCZ/zKdixFxBLcvwlgXzIPzfgsp52cvFWTi4zd dvr4atkhbhts0IyYlidlwTxlxL5gCxvUXhqN7hztha9Wf1mZ8XuF1NEEHS0h4WzTeOF6 hRX/G0ovPq/xfYtw+MAKsUI0jSAaUhxiRXlQGsvQSWQ4NCUnxMtidHM5wl98vpf/n2xs Tnvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h13si5575644ejt.369.2021.08.18.04.23.18; Wed, 18 Aug 2021 04:23:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235440AbhHRLVX (ORCPT + 99 others); Wed, 18 Aug 2021 07:21:23 -0400 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:45576 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234913AbhHRLVW (ORCPT ); Wed, 18 Aug 2021 07:21:22 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0UjhxFsf_1629285645; Received: from B-D1K7ML85-0059.local(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0UjhxFsf_1629285645) by smtp.aliyun-inc.com(127.0.0.1); Wed, 18 Aug 2021 19:20:46 +0800 Subject: Re: [PATCH] ocfs2: reflink deadlock when clone file to the same directory simultaneously To: Gang He , mark@fasheh.com, jlbec@evilplan.org, Wengang Wang Cc: linux-kernel@vger.kernel.org, ocfs2-devel@oss.oracle.com, akpm@linux-foundation.org References: <20210729110230.18983-1-ghe@suse.com> <5821fd0f-2018-dc1b-a5c0-f948a7debff4@linux.alibaba.com> <71608a14-58f4-dba0-d695-fee65de89192@linux.alibaba.com> <801438f5-655a-c708-aa25-343d54a2f11e@suse.com> From: Joseph Qi Message-ID: <86e3d724-3147-ccaa-998f-0f857c575f7e@linux.alibaba.com> Date: Wed, 18 Aug 2021 19:20:45 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <801438f5-655a-c708-aa25-343d54a2f11e@suse.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/18/21 5:20 PM, Gang He wrote: > > > On 2021/8/13 17:54, Joseph Qi wrote: >> >> >> On 8/9/21 6:08 PM, Gang He wrote: >>> Hi Joseph and All, >>> >>> The deadlock is caused by self-locking on one node. >>> There is three node cluster (mounted to /mnt/shared), the user run reflink command to clone the file to the same directory repeatedly, >>> e.g. >>>   reflink "/mnt/shared/test" \ >>>   "/mnt/shared/.snapshots/test.`date +%m%d%H%M%S`.`hostname`" >>> >>> After a while, the reflink process on each node is hung, the file system cannot be listed. >>> The problematic reflink command process is blocked by itself, e.g. the reflink process is hung at ghe-sle15sp2-nd2, >>> kernel: task:reflink         state:D stack:    0 pid:16992 ppid:  4530 >>> kernel: Call Trace: >>> kernel:  __schedule+0x2fd/0x750 >>> kernel:  ? try_to_wake_up+0x17b/0x4e0 >>> kernel:  schedule+0x2f/0xa0 >>> kernel:  schedule_timeout+0x1cc/0x310 >>> kernel:  ? __wake_up_common+0x74/0x120 >>> kernel:  wait_for_completion+0xba/0x140 >>> kernel:  ? wake_up_q+0xa0/0xa0 >>> kernel:  __ocfs2_cluster_lock.isra.41+0x3b5/0x820 [ocfs2] >>> kernel:  ? ocfs2_inode_lock_full_nested+0x1fc/0x960 [ocfs2] >>> kernel:  ocfs2_inode_lock_full_nested+0x1fc/0x960 [ocfs2] >>> kernel:  ocfs2_init_security_and_acl+0xbe/0x1d0 [ocfs2] >>> kernel:  ocfs2_reflink+0x436/0x4c0 [ocfs2] >>> kernel:  ? ocfs2_reflink_ioctl+0x2ca/0x360 [ocfs2] >>> kernel:  ocfs2_reflink_ioctl+0x2ca/0x360 [ocfs2] >>> kernel:  ocfs2_ioctl+0x25e/0x670 [ocfs2] >>> kernel:  do_vfs_ioctl+0xa0/0x680 >>> kernel:  ksys_ioctl+0x70/0x80 >>> >>> In fact, the destination directory(.snapshots) inode dlm lock was acquired by ghe-sle15sp2-nd2, next there is bast message from other nodes to ask ghe-sle15sp2-nd2 downconvert lock, but the operation failed, the kernel message is printed like, >>> kernel: (ocfs2dc-AA35DD9,2560,3):ocfs2_downconvert_lock:3660 ERROR: DLM error -16 while calling ocfs2_dlm_lock on resource M0000000000000000046e0200000000 >>> kernel: (ocfs2dc-AA35DD9,2560,3):ocfs2_unblock_lock:3904 ERROR: status = -16 >>> kernel: (ocfs2dc-AA35DD9,2560,3):ocfs2_process_blocked_lock:4303 ERROR: status = -16 >>> >>> Then, the reflink process tries to acquire this directory inode dlm lock, the process is blocked, the dlm lock resource in memory looks like >>> >>>      l_name = "M0000000000000000046e0200000000", >>>      l_ro_holders = 0, >>>      l_ex_holders = 0, >>>      l_level = 5 '\005', >>>      l_requested = 0 '\000', >>>      l_blocking = 5 '\005', >>>      l_type = 0 '\000', >>>      l_action = 0 '\000', >>>      l_unlock_action = 0 '\000', >>>      l_pending_gen = 645948, >>> >>> >>> So far, I do not know what makes dlm lock function failed, it also looks we do not handle this failure case in dlmglue layer, but I always reproduce this hang with my test script, e.g. >>> >>>    loop=1 >>>    while ((loop++)) ; do >>>          for i in `seq 1 100`; do >>>            reflink "/mnt/shared/test" "/mnt/shared/.snapshots /test.${loop}.${i}.`date +%m%d%H%M%S`.`hostname`" >>>          done >>>          usleep 500000 >>>          rm -f /mnt/shared/.snapshots/testnode1.qcow2.*.`hostname` >>>    done >>> >>> My patch changes multiple acquiring dest directory inode dlm lock during in ocfs2_reflink function, it avoids the hang issue happen again.The code change also can improve reflink performance in this case. >>> >>> Thanks >>> Gang >> >> 'status = -16' implies DLM_CANCELGRANT. >> Do you use stack user instead of o2cb? If yes, can you try o2cb with >> your reproducer? > > I setup o2cb based ocfs2 clusters with sle15sp2 and oracleLinux8u4. > After two day testing with the same script, I did not encounter dlm_lock downconvert failure, the hang issue did not happen. > After my patch was applied, there was not any side effect, the reflink performance was doubled in the case. > Do you mean the hang only happens on stack user? IMO, we'd better directly fix the stack user hang first, and then optimize reflink performance. Thanks, Joseph