virtio_fs.c (58ada94f95f71d4f73197ab0e9603dbba6e47fe3) virtio_fs.c (1efcf39eb627573f8d543ea396cf36b0651b1e56)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * virtio-fs: Virtio Filesystem
4 * Copyright (C) 2018 Red Hat, Inc.
5 */
6
7#include <linux/fs.h>
8#include <linux/module.h>

--- 34 unchanged lines hidden (view full) ---

43 struct kref refcount;
44 struct list_head list; /* on virtio_fs_instances */
45 char *tag;
46 struct virtio_fs_vq *vqs;
47 unsigned int nvqs; /* number of virtqueues */
48 unsigned int num_request_queues; /* number of request queues */
49};
50
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * virtio-fs: Virtio Filesystem
4 * Copyright (C) 2018 Red Hat, Inc.
5 */
6
7#include <linux/fs.h>
8#include <linux/module.h>

--- 34 unchanged lines hidden (view full) ---

43 struct kref refcount;
44 struct list_head list; /* on virtio_fs_instances */
45 char *tag;
46 struct virtio_fs_vq *vqs;
47 unsigned int nvqs; /* number of virtqueues */
48 unsigned int num_request_queues; /* number of request queues */
49};
50
51struct virtio_fs_forget {
51struct virtio_fs_forget_req {
52 struct fuse_in_header ih;
53 struct fuse_forget_in arg;
52 struct fuse_in_header ih;
53 struct fuse_forget_in arg;
54};
55
56struct virtio_fs_forget {
54 /* This request can be temporarily queued on virt queue */
55 struct list_head list;
57 /* This request can be temporarily queued on virt queue */
58 struct list_head list;
59 struct virtio_fs_forget_req req;
56};
57
58static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
59 struct fuse_req *req, bool in_flight);
60
61static inline struct virtio_fs_vq *vq_to_fsvq(struct virtqueue *vq)
62{
63 struct virtio_fs *fs = vq->vdev->priv;

--- 256 unchanged lines hidden (view full) ---

320static int send_forget_request(struct virtio_fs_vq *fsvq,
321 struct virtio_fs_forget *forget,
322 bool in_flight)
323{
324 struct scatterlist sg;
325 struct virtqueue *vq;
326 int ret = 0;
327 bool notify;
60};
61
62static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
63 struct fuse_req *req, bool in_flight);
64
65static inline struct virtio_fs_vq *vq_to_fsvq(struct virtqueue *vq)
66{
67 struct virtio_fs *fs = vq->vdev->priv;

--- 256 unchanged lines hidden (view full) ---

324static int send_forget_request(struct virtio_fs_vq *fsvq,
325 struct virtio_fs_forget *forget,
326 bool in_flight)
327{
328 struct scatterlist sg;
329 struct virtqueue *vq;
330 int ret = 0;
331 bool notify;
332 struct virtio_fs_forget_req *req = &forget->req;
328
329 spin_lock(&fsvq->lock);
330 if (!fsvq->connected) {
331 if (in_flight)
332 dec_in_flight_req(fsvq);
333 kfree(forget);
334 goto out;
335 }
336
333
334 spin_lock(&fsvq->lock);
335 if (!fsvq->connected) {
336 if (in_flight)
337 dec_in_flight_req(fsvq);
338 kfree(forget);
339 goto out;
340 }
341
337 sg_init_one(&sg, forget, sizeof(*forget));
342 sg_init_one(&sg, req, sizeof(*req));
338 vq = fsvq->vq;
339 dev_dbg(&vq->vdev->dev, "%s\n", __func__);
340
341 ret = virtqueue_add_outbuf(vq, &sg, 1, forget, GFP_ATOMIC);
342 if (ret < 0) {
343 if (ret == -ENOMEM || ret == -ENOSPC) {
344 pr_debug("virtio-fs: Could not queue FORGET: err=%d. Will try later\n",
345 ret);

--- 379 unchanged lines hidden (view full) ---

725#endif
726};
727
728static void virtio_fs_wake_forget_and_unlock(struct fuse_iqueue *fiq)
729__releases(fiq->lock)
730{
731 struct fuse_forget_link *link;
732 struct virtio_fs_forget *forget;
343 vq = fsvq->vq;
344 dev_dbg(&vq->vdev->dev, "%s\n", __func__);
345
346 ret = virtqueue_add_outbuf(vq, &sg, 1, forget, GFP_ATOMIC);
347 if (ret < 0) {
348 if (ret == -ENOMEM || ret == -ENOSPC) {
349 pr_debug("virtio-fs: Could not queue FORGET: err=%d. Will try later\n",
350 ret);

--- 379 unchanged lines hidden (view full) ---

730#endif
731};
732
733static void virtio_fs_wake_forget_and_unlock(struct fuse_iqueue *fiq)
734__releases(fiq->lock)
735{
736 struct fuse_forget_link *link;
737 struct virtio_fs_forget *forget;
738 struct virtio_fs_forget_req *req;
733 struct virtio_fs *fs;
734 struct virtio_fs_vq *fsvq;
735 u64 unique;
736
737 link = fuse_dequeue_forget(fiq, 1, NULL);
738 unique = fuse_get_unique(fiq);
739
740 fs = fiq->priv;
741 fsvq = &fs->vqs[VQ_HIPRIO];
742 spin_unlock(&fiq->lock);
743
744 /* Allocate a buffer for the request */
745 forget = kmalloc(sizeof(*forget), GFP_NOFS | __GFP_NOFAIL);
739 struct virtio_fs *fs;
740 struct virtio_fs_vq *fsvq;
741 u64 unique;
742
743 link = fuse_dequeue_forget(fiq, 1, NULL);
744 unique = fuse_get_unique(fiq);
745
746 fs = fiq->priv;
747 fsvq = &fs->vqs[VQ_HIPRIO];
748 spin_unlock(&fiq->lock);
749
750 /* Allocate a buffer for the request */
751 forget = kmalloc(sizeof(*forget), GFP_NOFS | __GFP_NOFAIL);
752 req = &forget->req;
746
753
747 forget->ih = (struct fuse_in_header){
754 req->ih = (struct fuse_in_header){
748 .opcode = FUSE_FORGET,
749 .nodeid = link->forget_one.nodeid,
750 .unique = unique,
755 .opcode = FUSE_FORGET,
756 .nodeid = link->forget_one.nodeid,
757 .unique = unique,
751 .len = sizeof(*forget),
758 .len = sizeof(*req),
752 };
759 };
753 forget->arg = (struct fuse_forget_in){
760 req->arg = (struct fuse_forget_in){
754 .nlookup = link->forget_one.nlookup,
755 };
756
757 send_forget_request(fsvq, forget, false);
758 kfree(link);
759}
760
761static void virtio_fs_wake_interrupt_and_unlock(struct fuse_iqueue *fiq)

--- 467 unchanged lines hidden ---
761 .nlookup = link->forget_one.nlookup,
762 };
763
764 send_forget_request(fsvq, forget, false);
765 kfree(link);
766}
767
768static void virtio_fs_wake_interrupt_and_unlock(struct fuse_iqueue *fiq)

--- 467 unchanged lines hidden ---