Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3887617imu; Mon, 10 Dec 2018 09:20:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/VOK8u4fOgjcEcmzW5oYWu8qbg/hUL7e8XCqGXEd3LTC/t+S89fKBmLGDZuXwtieYp2DaEX X-Received: by 2002:a17:902:8346:: with SMTP id z6mr12775440pln.340.1544462447055; Mon, 10 Dec 2018 09:20:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544462447; cv=none; d=google.com; s=arc-20160816; b=QwxFIPqLp1DBIP6l2bKd5lEtM3rtklwtf2ohK8Ow/TLqie7eXp9MqppGbbqtfDmrhT NnbyeSIMmEJtkv4yhCJGJN+DW1hCixCi3DVQ0W8XOXzWMKYuBGqfXZ6mIAc9yceVzu4W gMoBP4kiOAKlyXLDUDjJPohALd53YLP0Ev2o1E5uXiJEHuBIC+THYhmENGL2YJNxvZa4 7nsw+JQbTlL8EVY7Cvwdge9rnkD7TFnqpz5ylL5xYoINrCNrrOeg0qUpAUXkW685EM5g f3x2xc9Tb1N+gtd7HxSWYp9O+NFNdZqB6rKj57YOro14BRNzw14sY+6gHSjFb/2pf969 eMEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=vKnbLu9OnMg18xIn3cFZpb7XlyRJVbd8PgQMF8OzcY0=; b=hdGT+goxDxXv/tMWDXZB8Lk+id/iNwrZVUq7BJtfuMxXjhD+lN6WmNQsmTEZMmBjJv k9Z4j4rwfTrx9qBaG8HBBYhgU8klFlww7pwbxlRlXbOqVNeOO5wt3ZFt/E906s+vAfjX jLJF3/sq7lUNL7uf34ct5G4Ex97yB8SPBpVCIPdvxK61sKxuM/8P/00zwocEXnwPLNXz ciAvnM8UvAenmer+Y1Q5XVqpBFLlM9Yq0cPHpjGUq3u2blG1v8sI38z30AeIhJldVp+P JpQZS6t+qUtgu/e13ga3CMGec/EMYajy53t85/fWO9NzHiSsEXDDbPFVJOGImsOv1OTA sYEg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 z71si9450326pgd.490.2018.12.10.09.20.31; Mon, 10 Dec 2018 09:20:47 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728899AbeLJRQl (ORCPT + 99 others); Mon, 10 Dec 2018 12:16:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52378 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728403AbeLJRNg (ORCPT ); Mon, 10 Dec 2018 12:13:36 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E94497AE95; Mon, 10 Dec 2018 17:13:35 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4632600D7; Mon, 10 Dec 2018 17:13:35 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id B56C3224279; Mon, 10 Dec 2018 12:13:30 -0500 (EST) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: vgoyal@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com, sweil@redhat.com, swhiteho@redhat.com Subject: [PATCH 45/52] virtio: Free fuse devices on umount Date: Mon, 10 Dec 2018 12:13:11 -0500 Message-Id: <20181210171318.16998-46-vgoyal@redhat.com> In-Reply-To: <20181210171318.16998-1-vgoyal@redhat.com> References: <20181210171318.16998-1-vgoyal@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 10 Dec 2018 17:13:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Dr. David Alan Gilbert" When unmounting the fs close all the fuse devices. This includes making sure the daemon gets a FUSE_DESTROY to tell it. Signed-off-by: Dr. David Alan Gilbert --- fs/fuse/fuse_i.h | 1 + fs/fuse/inode.c | 3 ++- fs/fuse/virtio_fs.c | 13 ++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 7b2db87c6ead..30c7b4b56200 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -85,6 +85,7 @@ struct fuse_mount_data { unsigned default_permissions:1; unsigned allow_other:1; unsigned dax:1; + unsigned destroy:1; unsigned max_read; unsigned blksize; diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 178ac3171564..4d2d623e607f 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1263,7 +1263,7 @@ int fuse_fill_super_common(struct super_block *sb, goto err_put_root; __set_bit(FR_BACKGROUND, &init_req->flags); - if (is_bdev) { + if (mount_data->destroy) { fc->destroy_req = fuse_request_alloc(0); if (!fc->destroy_req) goto err_free_init_req; @@ -1339,6 +1339,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) d.fiq_ops = &fuse_dev_fiq_ops; d.fiq_priv = NULL; d.fudptr = &file->private_data; + d.destroy = is_bdev; err = fuse_fill_super_common(sb, &d); err_fput: diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index f436f5b3f85c..c71bc47395b4 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -1128,6 +1128,7 @@ static int virtio_fs_fill_super(struct super_block *sb, void *data, d.fiq_ops = &virtio_fs_fiq_ops; d.fiq_priv = fs; d.fudptr = (void **)&fs->vqs[2].fud; + d.destroy = true; /* Send destroy request on unmount */ err = fuse_fill_super_common(sb, &d); if (err < 0) @@ -1160,6 +1161,16 @@ static int virtio_fs_fill_super(struct super_block *sb, void *data, return err; } +static void virtio_kill_sb(struct super_block *sb) +{ + struct fuse_conn *fc = get_fuse_conn_super(sb); + fuse_kill_sb_anon(sb); + if (fc) { + struct virtio_fs *vfs = fc->iq.priv; + virtio_fs_free_devs(vfs); + } +} + static struct dentry *virtio_fs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *raw_data) @@ -1171,7 +1182,7 @@ static struct file_system_type virtio_fs_type = { .owner = THIS_MODULE, .name = KBUILD_MODNAME, .mount = virtio_fs_mount, - .kill_sb = fuse_kill_sb_anon, + .kill_sb = virtio_kill_sb, }; static int __init virtio_fs_init(void) -- 2.13.6