Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp288109rwr; Thu, 4 May 2023 19:18:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fCR50XxJFSnweihp2yw5N05dbVLSfATbPSZMQU9667OVRI/+xoVDiLMNFHnpvSwNQoQ4y X-Received: by 2002:a17:902:da8e:b0:1aa:f6f2:46b7 with SMTP id j14-20020a170902da8e00b001aaf6f246b7mr6931443plx.34.1683253131589; Thu, 04 May 2023 19:18:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683253131; cv=none; d=google.com; s=arc-20160816; b=NKDyKF5/m5Zvg3f2bCjWGiA+DmHukJy6WpgnPDF0tU5FvVB86MsC/olYu7B9+bvma7 n84+oCgb9kTsqSwp82Zk63caLhZuPqYj7A83+y5v5MxWGjchM82mwKt3KEPRKaUfR2SU dj3TjNjEvR/xlZk6i39CSYu5GGPgJppc40to/OjiL8T13gsLgQB3gAXbLB/dW9zApiLf gE49FxRVUIOOiljKiEEBCFQbxsc6M+atwmxGneeNUjj+nOjPPLeSO7w2aTE9hYyAkBKm ivQQC1cfQ16om0wvjmr9l3aqQTCRx0iZDjnkwZHCbjPJ+mJvojRaI+h3QUGRhIk5/B6P 9VRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+1lZHH9cJOkUnL6+SkM6O5cU5HIeggOc99mIe6aElrU=; b=bhgkiS7L0QyUr4QVlBmmTlkypUnvCRhbEGIg866wsiiRAOxn9dbAYnCTNXdAyDtFuD ZNgOVWly6OL42jjPrdWHBIA8HRXD6RTbjxweDU4rAVBWvnv61qFsTL6HHKpKIQC2WgtT wDtdh8Z716Rf+qIyJsTfB4DZHkhdnZH2Yw1NFW7UoILfhftY3KMoBtcJOV563bKXoPln N390VPTy2CMoFyZyvtfXoyGGX3La1/mZu6aLLK/mDOLlC4nn989j/l/3IqgovaTMeBch IXgrlLtnHEFYwSQ9LO0UaW3MYvgLMm58qzDdZgWwG1LFgCw6sugH/kN34Va8nrjmbfZt wP9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EqYJuGvV; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j14-20020a170902da8e00b001a93e74c8b6si547155plx.595.2023.05.04.19.18.31; Thu, 04 May 2023 19:18:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EqYJuGvV; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229514AbjEECHf (ORCPT + 99 others); Thu, 4 May 2023 22:07:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjEECHe (ORCPT ); Thu, 4 May 2023 22:07:34 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FB1230EE for ; Thu, 4 May 2023 19:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683252406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+1lZHH9cJOkUnL6+SkM6O5cU5HIeggOc99mIe6aElrU=; b=EqYJuGvVpvFIvPUj5Z8M09XAei+4J57uwNCfCEIC7uoiFXXsJEI5BEU/Q0jvC7DbTZZPWx E75llk23qenckFApUs5hgRNltFHKzcI7izWx8fK9okFsY9on9z0TGJEDqwse0ikPuaMiU9 Wl7juIA1L2VisRoAdC+wdVrQ4BZtsnI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-130-vimcqaoUNs6Ig5aKRDdcoA-1; Thu, 04 May 2023 22:06:41 -0400 X-MC-Unique: vimcqaoUNs6Ig5aKRDdcoA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F118A85A5B1; Fri, 5 May 2023 02:06:40 +0000 (UTC) Received: from ovpn-8-16.pek2.redhat.com (ovpn-8-20.pek2.redhat.com [10.72.8.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C782B2026D16; Fri, 5 May 2023 02:06:33 +0000 (UTC) Date: Fri, 5 May 2023 10:06:28 +0800 From: Ming Lei To: Keith Busch Cc: Theodore Ts'o , linux-ext4@vger.kernel.org, Andreas Dilger , linux-block@vger.kernel.org, Andrew Morton , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Dave Chinner , Eric Sandeen , Christoph Hellwig , Zhang Yi , ming.lei@redhat.com Subject: Re: [ext4 io hang] buffered write io hang in balance_dirty_pages Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, May 04, 2023 at 09:59:52AM -0600, Keith Busch wrote: > On Thu, Apr 27, 2023 at 10:20:28AM +0800, Ming Lei wrote: > > Hello Guys, > > > > I got one report in which buffered write IO hangs in balance_dirty_pages, > > after one nvme block device is unplugged physically, then umount can't > > succeed. > > > > Turns out it is one long-term issue, and it can be triggered at least > > since v5.14 until the latest v6.3. > > > > And the issue can be reproduced reliably in KVM guest: > > > > 1) run the following script inside guest: > > > > mkfs.ext4 -F /dev/nvme0n1 > > mount /dev/nvme0n1 /mnt > > dd if=/dev/zero of=/mnt/z.img& > > sleep 10 > > echo 1 > /sys/block/nvme0n1/device/device/remove > > > > 2) dd hang is observed and /dev/nvme0n1 is gone actually > > Sorry to jump in so late. > > For an ungraceful nvme removal, like a surpirse hot unplug, the driver > sets the capacity to 0 and that effectively ends all dirty page writers > that could stall forward progress on the removal. And that 0 capacity > should also cause 'dd' to exit. Actually nvme device has been gone, and the hang just happens in balance_dirty_pages() from generic_perform_write(). The issue should be triggered on all kinds of disks which can be hot-unplug, and it can be duplicated on both ublk and nvme easily. > > But this is not an ungraceful removal, so we're not getting that forced > behavior. Could we use the same capacity trick here after flushing any > outstanding dirty pages? set_capacity(0) has been called in del_gendisk() after fsync_bdev() & __invalidate_device(), but I understand FS code just try best to flush dirty pages. And when the bdev is gone, these un-flushed dirty pages need cleanup, otherwise they can't be used any more. Thanks, Ming