Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3887512imu; Mon, 10 Dec 2018 09:20:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/VBf/NVswJA6xGyClKeitLvCwZOBtkXbfsk8Jbthbk6E3vEZrn20sfYBTpd+W0NC4HvlIPE X-Received: by 2002:a17:902:6909:: with SMTP id j9mr12431979plk.196.1544462443098; Mon, 10 Dec 2018 09:20:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544462443; cv=none; d=google.com; s=arc-20160816; b=LqnLio6Jc0fKewV8q7IWkb8WblhKBsPxOwOivlQl7qK2zXp8C8WeiR96MxD3EEl50f wUSZznNcwGQO78mT2DMKJWAp2b6ee9um28pWdg7jRLS8RZKyCEUkKYn5HmL/L8/cxU4s 2VqKJLxQzWEVCECMWZgFWUTauxjRCOEF4XO3nKqh4RJnZRAH2W1MAxIz/zE7l1JeDW2T l/kF0uuISvoKDi/rWD8FM1OmYd8q0VXl3ezCFI+sJZYFjHGeRCpL08OjcYThGXHQpS1+ qJsfRalOIOS4E9kyx0reOaSN4px1DkZVOOuU+WOWQjGBIFTR0OPHSz0s1C4wcCnmdxF/ uoFw== 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=jUBXXGgdct+IMQ+dH+K2gysjIjCXdL1SqNHVVFjIhwk=; b=DFo3/nB+8vOKUWhUIsDb5CVeO0EmwqcNPip5qveyaNbEz2sStjGQqIyHFu9RRb1AlE T86uZX4mx+7Rl8F+L0AVIjicbT+ziwC74o4zjMnHsneww668ZihynTpuyRjyToTm3tEj r9ffoU5IZsaukbGrlrZlQM3rnVg3MF4OLl9q4aKZ5n0vOKjyvfzHGahWrzt+04EgW+TX Q7MXD/D4Bt72wQBW9km8rAIzSISXRYRybu0Vm6hLE0MpKLavfXihxhykJDZzgWJyM6RC BX8eZYiBNVIU98foRdYO9U6Jx1r+/ADGlSdLobwaALjI5YX86l9S12CcZAnbCxBESURi iFtw== 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 m20si9573666pgk.323.2018.12.10.09.20.27; Mon, 10 Dec 2018 09:20:43 -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 S1728858AbeLJRQa (ORCPT + 99 others); Mon, 10 Dec 2018 12:16:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34806 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728389AbeLJRNg (ORCPT ); Mon, 10 Dec 2018 12:13:36 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 77F023002C74; 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 2321D5D75F; Mon, 10 Dec 2018 17:13:34 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 3A81B223C12; 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 14/52] fuse: add fuse_conn->dax_dev field Date: Mon, 10 Dec 2018 12:12:40 -0500 Message-Id: <20181210171318.16998-15-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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 10 Dec 2018 17:13:35 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Hajnoczi A struct dax_device instance is a prerequisite for the DAX filesystem APIs. Let virtio_fs associate a dax_device with a fuse_conn. Classic FUSE and CUSE set the pointer to NULL, disabling DAX. Signed-off-by: Stefan Hajnoczi --- fs/fuse/cuse.c | 3 ++- fs/fuse/fuse_i.h | 8 +++++++- fs/fuse/inode.c | 9 ++++++--- fs/fuse/virtio_fs.c | 3 ++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c index 98dc780cbafa..bf8c1c470e8c 100644 --- a/fs/fuse/cuse.c +++ b/fs/fuse/cuse.c @@ -503,7 +503,8 @@ static int cuse_channel_open(struct inode *inode, struct file *file) * Limit the cuse channel to requests that can * be represented in file->f_cred->user_ns. */ - fuse_conn_init(&cc->fc, file->f_cred->user_ns, &fuse_dev_fiq_ops, NULL); + fuse_conn_init(&cc->fc, file->f_cred->user_ns, NULL, &fuse_dev_fiq_ops, + NULL); fud = fuse_dev_alloc(&cc->fc); if (!fud) { diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index f463586f2c9e..b5a6a12e67d6 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -803,6 +803,9 @@ struct fuse_conn { /** List of device instances belonging to this connection */ struct list_head devices; + + /** DAX device, non-NULL if DAX is supported */ + struct dax_device *dax_dev; }; static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) @@ -1025,7 +1028,8 @@ struct fuse_conn *fuse_conn_get(struct fuse_conn *fc); * Initialize fuse_conn */ void fuse_conn_init(struct fuse_conn *fc, struct user_namespace *user_ns, - const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv); + struct dax_device *dax_dev, + const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv); /** * Release reference to fuse_conn @@ -1045,12 +1049,14 @@ int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev, * Fill in superblock and initialize fuse connection * @sb: partially-initialized superblock to fill in * @mount_data: mount parameters + * @dax_dev: DAX device, may be NULL * @fiq_ops: fuse input queue operations * @fiq_priv: device-specific state for fuse_iqueue * @fudptr: fuse_dev pointer to fill in, should contain NULL on entry */ int fuse_fill_super_common(struct super_block *sb, struct fuse_mount_data *mount_data, + struct dax_device *dax_dev, const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv, void **fudptr); diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 31bb817575c4..10e4a39318c4 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -600,7 +600,8 @@ static void fuse_pqueue_init(struct fuse_pqueue *fpq) } void fuse_conn_init(struct fuse_conn *fc, struct user_namespace *user_ns, - const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv) + struct dax_device *dax_dev, + const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv) { memset(fc, 0, sizeof(*fc)); spin_lock_init(&fc->lock); @@ -625,6 +626,7 @@ void fuse_conn_init(struct fuse_conn *fc, struct user_namespace *user_ns, fc->attr_version = 1; get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); fc->pid_ns = get_pid_ns(task_active_pid_ns(current)); + fc->dax_dev = dax_dev; fc->user_ns = get_user_ns(user_ns); } EXPORT_SYMBOL_GPL(fuse_conn_init); @@ -1072,6 +1074,7 @@ EXPORT_SYMBOL_GPL(fuse_dev_free); int fuse_fill_super_common(struct super_block *sb, struct fuse_mount_data *mount_data, + struct dax_device *dax_dev, const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv, void **fudptr) @@ -1122,7 +1125,7 @@ int fuse_fill_super_common(struct super_block *sb, if (!fc) goto err; - fuse_conn_init(fc, sb->s_user_ns, fiq_ops, fiq_priv); + fuse_conn_init(fc, sb->s_user_ns, dax_dev, fiq_ops, fiq_priv); fc->release = fuse_free_conn; fud = fuse_dev_alloc(fc); @@ -1233,7 +1236,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) (file->f_cred->user_ns != sb->s_user_ns)) goto err_fput; - err = fuse_fill_super_common(sb, &d, &fuse_dev_fiq_ops, NULL, + err = fuse_fill_super_common(sb, &d, NULL, &fuse_dev_fiq_ops, NULL, &file->private_data); err_fput: fput(file); diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index fd914f2c6209..ba615ec2603e 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -844,7 +844,8 @@ static int virtio_fs_fill_super(struct super_block *sb, void *data, /* TODO this sends FUSE_INIT and could cause hiprio or notifications * virtqueue races since they haven't been set up yet! */ - err = fuse_fill_super_common(sb, &d, &virtio_fs_fiq_ops, fs, + err = fuse_fill_super_common(sb, &d, fs->dax_dev, + &virtio_fs_fiq_ops, fs, (void **)&fs->vqs[2].fud); if (err < 0) goto err_fud; -- 2.13.6