Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4982329ybc; Fri, 15 Nov 2019 13:00:41 -0800 (PST) X-Google-Smtp-Source: APXvYqxsFmkYz2eZUpcm7xo4Hf63T6uUW722LtLDpxRW2smZMI0qZuAXoHgSEBZyKpvxfJVLThYq X-Received: by 2002:a17:906:5e52:: with SMTP id b18mr3711990eju.318.1573851641624; Fri, 15 Nov 2019 13:00:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573851641; cv=none; d=google.com; s=arc-20160816; b=sNGFdhvUynxvuySPFbmFwRMiHdc+8sOSZBgsQV93AVC7y/VGec3UlJ26ApWIMwBrc9 GI0izkyVajZBMrkfAXvWLoQqtkPQMtUKjcoY0FeGHZQztmzHnIuAmF9gu7MNwmlTbpFl KsWDA8y95txR5TFF31MkMw4A9kFKUEN88foKg+EMtlP/NAGJK6A6rsLdsKS32p3jCxSc V08A/E1yEVYzuZMGoUSZYdCECNcxXmqVDhefyK7b1VRsMRBlWrsJ1jFB2eESBBGrwR8s 7yx2MgXhiMuRbepZ5Ep7L7eYNuFBGykLAShNYdO5oGiBjrb9tLI+axJcCI9L99UfTpZw 6ktQ== 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 :dkim-signature; bh=2QEJbiz+89oQBqVefvp57/tK+Zdt+Qq0QP+KzJjkhEg=; b=i2ZOThLq3NPoo4TRuhksuyl6EEcexsmlj/D6MEjcP2iHnOubLujBYs77Yliy2R+fPe NIDJmZglyFQkU0BWq3wCI1f16diWw3tsDS/ej/erPm7Kunwo5HbBDu1KVsZ78AeQ5I1c NBurSntgajV39J2hxhEZZBq7481jg8IWa7QHJhW9DvuiW5ZT3rkSVQNFZawb6j3RGV6Q usQecz/rVPozEMLrD5mN+BgMVLsb8MqloyosAhnoanSk8BK2Xz5W7+VwOy6cI8hOoHxz xwL67Gwjaoiux+mpM50Pn8z4Yu4T12u1NUshEGtG1wgR68I5CbTlUSgRlKuDRqOT+DWL 00sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b8Jcmhx0; 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 h13si6524100ejq.54.2019.11.15.13.00.16; Fri, 15 Nov 2019 13:00:41 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b8Jcmhx0; 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 S1726953AbfKOU5Y (ORCPT + 99 others); Fri, 15 Nov 2019 15:57:24 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:57419 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726599AbfKOU5Y (ORCPT ); Fri, 15 Nov 2019 15:57:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573851443; 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=b8Jcmhx0OzjJubvi2pY/5T37fY3RgIlcXds7l8pW+/Zmj/USLy8LfyB38hGkUqiZ0Tal6b Ba33KKai61EnMfzdHD1CkXTigAdGmRLgoNjhKoKHVNwfaz9N1YAqq6ElONYyZef9GsD/x5 v8VVMZ2Ju5IX1NPSH0ZOwMFRE/P/eb8= 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 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 work= s fine as long as number of queues are not dynamic. I am about to introduce one more virtqueue, called notification queue, whic= h 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 { =09struct virtio_fs_vq *vqs; =09unsigned int nvqs; /* number of virtqueues */ =09unsigned int num_request_queues; /* number of request queues */ +=09unsigned int first_reqq_idx;=09/* First request queue idx */ }; =20 struct virtio_fs_forget_req { @@ -597,7 +598,9 @@ static int virtio_fs_setup_vqs(struct virtio_device *vd= ev, =09if (fs->num_request_queues =3D=3D 0) =09=09return -EINVAL; =20 -=09fs->nvqs =3D VQ_REQUEST + fs->num_request_queues; +=09/* One hiprio queue and rest are request queues */ +=09fs->nvqs =3D 1 + fs->num_request_queues; +=09fs->first_reqq_idx =3D 1; =09fs->vqs =3D kcalloc(fs->nvqs, sizeof(fs->vqs[VQ_HIPRIO]), GFP_KERNEL); =09if (!fs->vqs) =09=09return -ENOMEM; @@ -617,10 +620,11 @@ static int virtio_fs_setup_vqs(struct virtio_device *= vdev, =09names[VQ_HIPRIO] =3D fs->vqs[VQ_HIPRIO].name; =20 =09/* Initialize the requests virtqueues */ -=09for (i =3D VQ_REQUEST; i < fs->nvqs; i++) { +=09for (i =3D fs->first_reqq_idx; i < fs->nvqs; i++) { =09=09char vq_name[VQ_NAME_LEN]; =20 -=09=09snprintf(vq_name, VQ_NAME_LEN, "requests.%u", i - VQ_REQUEST); +=09=09snprintf(vq_name, VQ_NAME_LEN, "requests.%u", +=09=09=09 i - fs->first_reqq_idx); =09=09virtio_fs_init_vq(&fs->vqs[i], vq_name, VQ_REQUEST); =09=09callbacks[i] =3D virtio_fs_vq_done; =09=09names[i] =3D fs->vqs[i].name; @@ -990,7 +994,7 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *f= svq, static void virtio_fs_wake_pending_and_unlock(struct fuse_iqueue *fiq) __releases(fiq->lock) { -=09unsigned int queue_id =3D VQ_REQUEST; /* TODO multiqueue */ +=09unsigned int queue_id; =09struct virtio_fs *fs; =09struct fuse_req *req; =09struct virtio_fs_vq *fsvq; @@ -1004,6 +1008,7 @@ __releases(fiq->lock) =09spin_unlock(&fiq->lock); =20 =09fs =3D fiq->priv; +=09queue_id =3D fs->first_reqq_idx; =20 =09pr_debug("%s: opcode %u unique %#llx nodeid %#llx in.len %u out.len %u\= n", =09=09 __func__, req->in.h.opcode, req->in.h.unique, @@ -1077,7 +1082,7 @@ static int virtio_fs_fill_super(struct super_block *s= b) =20 =09err =3D -ENOMEM; =09/* Allocate fuse_dev for hiprio and notification queues */ -=09for (i =3D 0; i < VQ_REQUEST; i++) { +=09for (i =3D 0; i < fs->first_reqq_idx; i++) { =09=09struct virtio_fs_vq *fsvq =3D &fs->vqs[i]; =20 =09=09fsvq->fud =3D fuse_dev_alloc(); @@ -1085,17 +1090,17 @@ static int virtio_fs_fill_super(struct super_block = *sb) =09=09=09goto err_free_fuse_devs; =09} =20 -=09ctx.fudptr =3D (void **)&fs->vqs[VQ_REQUEST].fud; +=09ctx.fudptr =3D (void **)&fs->vqs[fs->first_reqq_idx].fud; =09err =3D fuse_fill_super_common(sb, &ctx); =09if (err < 0) =09=09goto err_free_fuse_devs; =20 -=09fc =3D fs->vqs[VQ_REQUEST].fud->fc; +=09fc =3D fs->vqs[fs->first_reqq_idx].fud->fc; =20 =09for (i =3D 0; i < fs->nvqs; i++) { =09=09struct virtio_fs_vq *fsvq =3D &fs->vqs[i]; =20 -=09=09if (i =3D=3D VQ_REQUEST) +=09=09if (i =3D=3D fs->first_reqq_idx) =09=09=09continue; /* already initialized */ =09=09fuse_dev_install(fsvq->fud, fc); =09} --=20 2.20.1