From patchwork Fri Nov 15 20:57:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Goyal X-Patchwork-Id: 11247109 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A009313BD for ; Fri, 15 Nov 2019 20:57:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 79AA520748 for ; Fri, 15 Nov 2019 20:57:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aqYGFAQ4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727041AbfKOU52 (ORCPT ); Fri, 15 Nov 2019 15:57:28 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:51820 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726980AbfKOU50 (ORCPT ); Fri, 15 Nov 2019 15:57:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573851445; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2QEJbiz+89oQBqVefvp57/tK+Zdt+Qq0QP+KzJjkhEg=; b=aqYGFAQ45XJacNXBR+BEKQxU3LhIVPQWlNKG8Zwf+2V6tpBFz1+QFR4G71+owak+b0veyf uG9ZK4uV6wDb5Zmxfty2ysARB3fld019CBn6cbQp2plQTt9q9Tyu/gDG2dB0vdKdVkzCWW Unm5yaakOrAySKABgMS6NDWg6VcDjz4= 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-242-WxEv-1IUOTq9QO01IYm4bA-1; Fri, 15 Nov 2019 15:57:21 -0500 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 EF51F18B9FAA; Fri, 15 Nov 2019 20:57:20 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B58260BF7; Fri, 15 Nov 2019 20:57:15 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id A79D7224776; Fri, 15 Nov 2019 15:57:14 -0500 (EST) From: Vivek Goyal To: virtio-fs@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vgoyal@redhat.com, stefanha@redhat.com, dgilbert@redhat.com, miklos@szeredi.hu Subject: [PATCH 2/4] virtiofs: Add an index to keep track of first request queue Date: Fri, 15 Nov 2019 15:57:03 -0500 Message-Id: <20191115205705.2046-3-vgoyal@redhat.com> In-Reply-To: <20191115205705.2046-1-vgoyal@redhat.com> References: <20191115205705.2046-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: WxEv-1IUOTq9QO01IYm4bA-1 X-Mimecast-Spam-Score: 0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org We have many virtqueues and first queue which carries fuse normal requests (except forget requests) has index pointed to by enum VQ_REQUEST. This works fine as long as number of queues are not dynamic. I am about to introduce one more virtqueue, called notification queue, which will be present only if device on host supports it. That means index of request queue will change depending on if notification queue is present or not. So, add a variable to keep track of that index and this will help when notification queue is added in next patch. Signed-off-by: Vivek Goyal --- fs/fuse/virtio_fs.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index a0fb0a93980c..1ab4b7b83707 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -49,6 +49,7 @@ struct virtio_fs { struct virtio_fs_vq *vqs; unsigned int nvqs; /* number of virtqueues */ unsigned int num_request_queues; /* number of request queues */ + unsigned int first_reqq_idx; /* First request queue idx */ }; struct virtio_fs_forget_req { @@ -597,7 +598,9 @@ static int virtio_fs_setup_vqs(struct virtio_device *vdev, if (fs->num_request_queues == 0) return -EINVAL; - fs->nvqs = VQ_REQUEST + fs->num_request_queues; + /* One hiprio queue and rest are request queues */ + fs->nvqs = 1 + fs->num_request_queues; + fs->first_reqq_idx = 1; fs->vqs = kcalloc(fs->nvqs, sizeof(fs->vqs[VQ_HIPRIO]), GFP_KERNEL); if (!fs->vqs) return -ENOMEM; @@ -617,10 +620,11 @@ static int virtio_fs_setup_vqs(struct virtio_device *vdev, names[VQ_HIPRIO] = fs->vqs[VQ_HIPRIO].name; /* Initialize the requests virtqueues */ - for (i = VQ_REQUEST; i < fs->nvqs; i++) { + for (i = fs->first_reqq_idx; i < fs->nvqs; i++) { char vq_name[VQ_NAME_LEN]; - snprintf(vq_name, VQ_NAME_LEN, "requests.%u", i - VQ_REQUEST); + snprintf(vq_name, VQ_NAME_LEN, "requests.%u", + i - fs->first_reqq_idx); virtio_fs_init_vq(&fs->vqs[i], vq_name, VQ_REQUEST); callbacks[i] = virtio_fs_vq_done; names[i] = fs->vqs[i].name; @@ -990,7 +994,7 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq, static void virtio_fs_wake_pending_and_unlock(struct fuse_iqueue *fiq) __releases(fiq->lock) { - unsigned int queue_id = VQ_REQUEST; /* TODO multiqueue */ + unsigned int queue_id; struct virtio_fs *fs; struct fuse_req *req; struct virtio_fs_vq *fsvq; @@ -1004,6 +1008,7 @@ __releases(fiq->lock) spin_unlock(&fiq->lock); fs = fiq->priv; + queue_id = fs->first_reqq_idx; pr_debug("%s: opcode %u unique %#llx nodeid %#llx in.len %u out.len %u\n", __func__, req->in.h.opcode, req->in.h.unique, @@ -1077,7 +1082,7 @@ static int virtio_fs_fill_super(struct super_block *sb) err = -ENOMEM; /* Allocate fuse_dev for hiprio and notification queues */ - for (i = 0; i < VQ_REQUEST; i++) { + for (i = 0; i < fs->first_reqq_idx; i++) { struct virtio_fs_vq *fsvq = &fs->vqs[i]; fsvq->fud = fuse_dev_alloc(); @@ -1085,17 +1090,17 @@ static int virtio_fs_fill_super(struct super_block *sb) goto err_free_fuse_devs; } - ctx.fudptr = (void **)&fs->vqs[VQ_REQUEST].fud; + ctx.fudptr = (void **)&fs->vqs[fs->first_reqq_idx].fud; err = fuse_fill_super_common(sb, &ctx); if (err < 0) goto err_free_fuse_devs; - fc = fs->vqs[VQ_REQUEST].fud->fc; + fc = fs->vqs[fs->first_reqq_idx].fud->fc; for (i = 0; i < fs->nvqs; i++) { struct virtio_fs_vq *fsvq = &fs->vqs[i]; - if (i == VQ_REQUEST) + if (i == fs->first_reqq_idx) continue; /* already initialized */ fuse_dev_install(fsvq->fud, fc); }