Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1456992ybe; Thu, 5 Sep 2019 16:04:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlPRQPyDWQUYR2x+Fg38BVO1uCY03EjflVSWGgws217f1g5QuNHw1N3TLtNRCfLUPZYNNi X-Received: by 2002:a63:4b02:: with SMTP id y2mr5286843pga.135.1567724643684; Thu, 05 Sep 2019 16:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567724643; cv=none; d=google.com; s=arc-20160816; b=mjXpvEFv9N0KMGi3sjI5be8dzEncKiDJtFYxcbptfcaOeAUTsdE/7cYVAT46s1PMX9 EOamafd1CZH/JxnB0CLzpAFbcApKV9rX6Zet+AVElPKMqewaPHgYfQ+l+ep14y0qdsMq uA356QXViJ0OwfLwIFVwNjMYK8ZTRFP8WTjixmTDKqTJc45tavO+az4kUXvJhGgcCk1R OehfOjagO65X+bdl2WSSA3SiP2l43xy5djB6zE46yWEB8GgMqRAGsVwZ3zx4uaKUF78g BWqxnfqtSxLWQcOltJScw6pYrpSp+ofwoWRKlEmd48NhYtwM3/D99bH9U6XUFF18j6M1 G2BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rw48lb6oPazHNlLfHFNPOiaHHkOAjlWdxJAcZ8Y34T0=; b=trkLeALaRAvo3rcoio6G85A/Dg3tCH6zqeKriR9XxTYO91bxWJth76Z4Vjeuai/eUt YqaxQhUucYb4hyEpJLzLZPhkmgGZxbPa7lED0OfkWC1NF+t4UZK91MAbKNXE892G+Jpl 74uTChub0G2h0W+y71HQi1OzOuWbouOyuXu6J4CTsGcyLSW0X9eAAbKkcunTr/hRBk9v nBsmqx9lWQ61ZK1CLwBtQdm5aoCbzCi7wtSdzW7w2p+wFouO3ooVfA6mK9nuaO1e5ouo 3S2J9SPy32cTAkuZ+BMTI0qWldCDa+R6uUVo27LyMZdvlTfOekbI+1hCuAe08XEPTsxr 8HAQ== 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 69si3445823plb.10.2019.09.05.16.03.48; Thu, 05 Sep 2019 16:04:03 -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; 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 S2390228AbfIETtg (ORCPT + 99 others); Thu, 5 Sep 2019 15:49:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1774 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388189AbfIETt1 (ORCPT ); Thu, 5 Sep 2019 15:49:27 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ECCAB8831E; Thu, 5 Sep 2019 19:49:26 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id C70AA100194E; Thu, 5 Sep 2019 19:49:26 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 1BBEC2253A6; Thu, 5 Sep 2019 15:49:18 -0400 (EDT) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, virtualization@lists.linux-foundation.org, miklos@szeredi.hu Cc: linux-kernel@vger.kernel.org, virtio-fs@redhat.com, vgoyal@redhat.com, stefanha@redhat.com, dgilbert@redhat.com, mst@redhat.com Subject: [PATCH 14/18] virtiofs: Add a fuse_iqueue operation to put() reference Date: Thu, 5 Sep 2019 15:48:55 -0400 Message-Id: <20190905194859.16219-15-vgoyal@redhat.com> In-Reply-To: <20190905194859.16219-1-vgoyal@redhat.com> References: <20190905194859.16219-1-vgoyal@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 05 Sep 2019 19:49:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Soon I will make virtio_fs object reference counted, where reference will be taken by device as well as by fuse_conn (fuse_conn->fuse_iqueue->fiq_priv). When fuse_connection is going away, it should put its reference on virtio_fs object. So add a fuse_iqueue method which can be used to call into virtio_fs to put the reference on the object (fiq_priv). Signed-off-by: Vivek Goyal --- fs/fuse/fuse_i.h | 5 +++++ fs/fuse/inode.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 85e2dcad68c1..04e2c000d63f 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -479,6 +479,11 @@ struct fuse_iqueue_ops { */ void (*wake_pending_and_unlock)(struct fuse_iqueue *fiq) __releases(fiq->waitq.lock); + + /** + * Put a reference on fiq_priv. + */ + void (*put)(struct fuse_iqueue *fiq); }; /** /dev/fuse input queue operations */ diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 7fa0dcc6f565..70a433bdf01f 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -631,8 +631,14 @@ EXPORT_SYMBOL_GPL(fuse_conn_init); void fuse_conn_put(struct fuse_conn *fc) { if (refcount_dec_and_test(&fc->count)) { + struct fuse_iqueue *fiq = &fc->iq; + if (fc->destroy_req) fuse_request_free(fc->destroy_req); + if (fiq->priv && fiq->ops->put) { + fiq->ops->put(fiq); + fiq->priv = NULL; + } put_pid_ns(fc->pid_ns); put_user_ns(fc->user_ns); fc->release(fc); -- 2.20.1