Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2876AECAAD8 for ; Wed, 14 Sep 2022 03:49:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229641AbiINDtP (ORCPT ); Tue, 13 Sep 2022 23:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbiINDtK (ORCPT ); Tue, 13 Sep 2022 23:49:10 -0400 Received: from smtp1.onthe.net.au (smtp1.onthe.net.au [203.22.196.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F3A8B6F562 for ; Tue, 13 Sep 2022 20:49:04 -0700 (PDT) Received: from localhost (smtp2.private.onthe.net.au [10.200.63.13]) by smtp1.onthe.net.au (Postfix) with ESMTP id 36C0D613C5; Wed, 14 Sep 2022 13:49:03 +1000 (EST) Received: from smtp1.onthe.net.au ([10.200.63.11]) by localhost (smtp.onthe.net.au [10.200.63.13]) (amavisd-new, port 10028) with ESMTP id bjS4rqvMlpwD; Wed, 14 Sep 2022 13:49:03 +1000 (AEST) Received: from athena.private.onthe.net.au (chris-gw2-vpn.private.onthe.net.au [10.9.3.2]) by smtp1.onthe.net.au (Postfix) with ESMTP id 0EB3760F6F; Wed, 14 Sep 2022 13:49:03 +1000 (EST) Received: by athena.private.onthe.net.au (Postfix, from userid 1026) id E96006803C7; Wed, 14 Sep 2022 13:49:02 +1000 (AEST) Date: Wed, 14 Sep 2022 13:49:02 +1000 From: Chris Dunlop To: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Subject: Re: rbd unmap fails with "Device or resource busy" Message-ID: <20220914034902.GA691415@onthe.net.au> References: <20220913012043.GA568834@onthe.net.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Hi Illya, On Tue, Sep 13, 2022 at 01:43:16PM +0200, Ilya Dryomov wrote: > On Tue, Sep 13, 2022 at 3:44 AM Chris Dunlop wrote: >> What can make a "rbd unmap" fail, assuming the device is not mounted >> and not (obviously) open by any other processes? >> >> linux-5.15.58 >> ceph-16.2.9 >> >> I have multiple XFS on rbd filesystems, and often create rbd snapshots, >> map and read-only mount the snapshot, perform some work on the fs, then >> unmount and unmap. The unmap regularly (about 1 in 10 times) fails >> like: >> >> $ sudo rbd unmap /dev/rbd29 >> rbd: sysfs write failed >> rbd: unmap failed: (16) Device or resource busy >> >> I've double checked the device is no longer mounted, and, using "lsof" >> etc., nothing has the device open. > > One thing that "lsof" is oblivious to is multipath, see > https://tracker.ceph.com/issues/12763. The server is not using multipath - e.g. there's no multipathd, and: $ find /dev/mapper/ -name '*mpath*' ...finds nothing. >> I've found that waiting "a while", e.g. 5-30 minutes, will usually >> allow the "busy" device to be unmapped without the -f flag. > > "Device or resource busy" error from "rbd unmap" clearly indicates > that the block device is still open by something. In this case -- you > are mounting a block-level snapshot of an XFS filesystem whose "HEAD" > is already mounted -- perhaps it could be some background XFS worker > thread? I'm not sure if "nouuid" mount option solves all issues there. Good suggestion, I should have considered that first. I've now tried it without the mount at all, i.e. with no XFS or other filesystem: ------------------------------------------------------------------------------ #!/bin/bash set -e rbdname=pool/name for ((i=0; ++i<=50; )); do dev=$(rbd map "${rbdname}") ts "${i}: ${dev}" dd if="${dev}" of=/dev/null bs=1G count=1 for ((j=0; ++j; )); do rbd unmap "${dev}" && break sleep 1m done (( j > 1 )) && echo "$j minutes to unmap" done ------------------------------------------------------------------------------ This failed at about the same rate, i.e. around 1 in 10. This time it only took 2 minutes each time to successfully unmap after the initial unmap failed - I'm not sure if this is due to the test change (no mount), or related to how busy the machine is otherwise. The upshot is, it definitely looks like there's something related to the underlying rbd that's preventing the unmap. > Have you encountered this error in other scenarios, i.e. without > mounting snapshots this way or with ext4 instead of XFS? I've seen the same issue after unmounting r/w filesystems, but I don't do that nearly as often so it hasn't been a pain point. However, per the test above, the issue is unrelated to the mount. Cheers, Chris