Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp531470ybh; Wed, 11 Mar 2020 06:00:38 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuiQw1NltH3eMuArhTqWgtVwFz2nHsDtZyUjl2u2/SOZbK+ae3OfxLw4TmCXHWgwOFZMFmy X-Received: by 2002:aca:b4c3:: with SMTP id d186mr1733678oif.131.1583931638405; Wed, 11 Mar 2020 06:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583931638; cv=none; d=google.com; s=arc-20160816; b=gFupp5HovJKEZ/h25WZQXI62fYoTfu49HHDb0izUpwD6SddFd3wk2emWkHBO70SzGI 9fDWd+ibsZu78ovy1OWIy9BpIIbE0Nael45q71F/luRghrtphQSKa0PyDeAUfU6IcIWJ BpiXrK1goBJ1Y0Q0ZAnanvlqKyOqHbXDWG2Hlh4iKp5dEikMotSLOUafkxRHpePLOuq0 6jUaDM27mWSFybypQZMeWGitLIJ6spe0aThBIXwWusDQahyoD0Kc+bNDEHlJ7cZ3xiu0 L4Z82qLUoCtSUaBWRUHdDCOjJH2UrZ4LZ7DD9pvA1YghgEyMd9rBZ2YMXvml4sazXMzA snwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=eRHGawj8EctzUWRxgMWMCKcmyXT/eFQgkAXnHzfcavw=; b=xBCdETzpWGPAtglQfGQ076J3dj4SsJQFjQnwvIAPZ8EpJgLnTRtCRmok1o+kDRQs0x lYPt8678hdoilk8RUvuKpGro5hHcFiXlo9dhGz5U8J0i8DrHmeSVp1wOLANLyKtOQQrK Ch/z7CuUMIF52g53xZa0h6Emyaupr5CL/MC4LSnCyjgBEmS0cpX1aNzzf0pIjcPbVldR 2Q7YZ1YuqreBCpeLHDVUcwdb/Jbyvqg+H0XSIrTR9wDe5AjGqxiHhddqQnKWgjzEyCOJ 8t23rHFYvz8pRu2D9a0/0SjrR69IdWq/5ZU2kVlg/wpjkb7hcoR5nvKzPw4Lze/VYqwI XRVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZfTaqQP+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si1008976oia.264.2020.03.11.06.00.25; Wed, 11 Mar 2020 06:00:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZfTaqQP+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1729472AbgCKM7h (ORCPT + 99 others); Wed, 11 Mar 2020 08:59:37 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:60157 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729232AbgCKM7h (ORCPT ); Wed, 11 Mar 2020 08:59:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583931575; 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=eRHGawj8EctzUWRxgMWMCKcmyXT/eFQgkAXnHzfcavw=; b=ZfTaqQP+OzuLv3sQ7SDCgXigTrpPdQMZEeoU66HWJTglxKT49lNUw6dLjDwf+dAFvXtKS/ 2XXRJiBzao+4C5augEXOUUiTIz1LLVN+Rz1S6OZCn2lVo/fW4uqsFapiz5jFT6N3ziLUqp QFASNuXb6BmKMVv5M2gv8iSpFCyaF2U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-k6PJU7nPPLWeiHCzgt1RXQ-1; Wed, 11 Mar 2020 08:59:34 -0400 X-MC-Unique: k6PJU7nPPLWeiHCzgt1RXQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B2BD100550E; Wed, 11 Mar 2020 12:59:32 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C3F660C18; Wed, 11 Mar 2020 12:59:24 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id DD31F22021D; Wed, 11 Mar 2020 08:59:23 -0400 (EDT) Date: Wed, 11 Mar 2020 08:59:23 -0400 From: Vivek Goyal To: Liu Bo Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, virtio-fs@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com, mst@redhat.com Subject: Re: [PATCH 20/20] fuse,virtiofs: Add logic to free up a memory range Message-ID: <20200311125923.GA83257@redhat.com> References: <20200304165845.3081-1-vgoyal@redhat.com> <20200304165845.3081-21-vgoyal@redhat.com> <20200311051641.l6gonmmyb4o5rcrb@rsjd01523.et2sqa> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200311051641.l6gonmmyb4o5rcrb@rsjd01523.et2sqa> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 11, 2020 at 01:16:42PM +0800, Liu Bo wrote: [..] > > @@ -719,6 +723,7 @@ void fuse_conn_put(struct fuse_conn *fc) > > if (refcount_dec_and_test(&fc->count)) { > > struct fuse_iqueue *fiq = &fc->iq; > > > > + flush_delayed_work(&fc->dax_free_work); > > Today while debugging another case, I realized that flushing work here > at the very last fuse_conn_put() is a bit too late, here's my analysis, > > umount kthread > > deactivate_locked_super > ->virtio_kill_sb try_to_free_dmap_chunks > ->generic_shutdown_super ->igrab() > ... > ->evict_inodes() -> check all inodes' count > ->fuse_conn_put ->iput > ->virtio_fs_free_devs > ->fuse_dev_free > ->fuse_conn_put // vq1 > ->fuse_dev_free > ->fuse_conn_put // vq2 > ->flush_delayed_work > > The above can end up with a warning message reported by evict_inodes() > about stable inodes. Hi Liu Bo, Which warning is that? Can you point me to it in code. > So I think it's necessary to put either > cancel_delayed_work_sync() or flush_delayed_work() before going to > generic_shutdown_super(). In general I agree that shutting down memory range freeing worker earling in unmount/shutdown sequence makes sense. It does not seem to help to let it run while filesystem is going away. How about following patch. --- fs/fuse/inode.c | 1 - fs/fuse/virtio_fs.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) Index: redhat-linux/fs/fuse/virtio_fs.c =================================================================== --- redhat-linux.orig/fs/fuse/virtio_fs.c 2020-03-10 14:11:10.970284651 -0400 +++ redhat-linux/fs/fuse/virtio_fs.c 2020-03-11 08:27:08.103330039 -0400 @@ -1295,6 +1295,11 @@ static void virtio_kill_sb(struct super_ vfs = fc->iq.priv; fsvq = &vfs->vqs[VQ_HIPRIO]; + /* Stop dax worker. Soon evict_inodes() will be called which will + * free all memory ranges belonging to all inodes. + */ + flush_delayed_work(&fc->dax_free_work); + /* Stop forget queue. Soon destroy will be sent */ spin_lock(&fsvq->lock); fsvq->connected = false; Index: redhat-linux/fs/fuse/inode.c =================================================================== --- redhat-linux.orig/fs/fuse/inode.c 2020-03-10 09:13:35.132565666 -0400 +++ redhat-linux/fs/fuse/inode.c 2020-03-11 08:22:02.685330039 -0400 @@ -723,7 +723,6 @@ void fuse_conn_put(struct fuse_conn *fc) if (refcount_dec_and_test(&fc->count)) { struct fuse_iqueue *fiq = &fc->iq; - flush_delayed_work(&fc->dax_free_work); if (fc->dax_dev) fuse_free_dax_mem_ranges(&fc->free_ranges); if (fiq->ops->release)