aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVivek Goyal <vgoyal@redhat.com>2019-10-15 13:46:24 -0400
committerMiklos Szeredi <mszeredi@redhat.com>2019-10-21 09:57:07 -0400
commit5dbe190f341206a7896f7e40c1e3a36933d812f3 (patch)
tree3129c354c0777d5d1bd0447d9cbfd8ebb9389734
parent7ee1e2e631dbf0ff0df2a67a1e01ba3c1dce7a46 (diff)
virtiofs: Set FR_SENT flag only after request has been sent
FR_SENT flag should be set when request has been sent successfully sent over virtqueue. This is used by interrupt logic to figure out if interrupt request should be sent or not. Also add it to fqp->processing list after sending it successfully. Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r--fs/fuse/virtio_fs.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index a2724b77221d..6d153e70c87b 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -857,6 +857,7 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
857 unsigned int i; 857 unsigned int i;
858 int ret; 858 int ret;
859 bool notify; 859 bool notify;
860 struct fuse_pqueue *fpq;
860 861
861 /* Does the sglist fit on the stack? */ 862 /* Does the sglist fit on the stack? */
862 total_sgs = sg_count_fuse_req(req); 863 total_sgs = sg_count_fuse_req(req);
@@ -911,6 +912,15 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
911 goto out; 912 goto out;
912 } 913 }
913 914
915 /* Request successfully sent. */
916 fpq = &fsvq->fud->pq;
917 spin_lock(&fpq->lock);
918 list_add_tail(&req->list, fpq->processing);
919 spin_unlock(&fpq->lock);
920 set_bit(FR_SENT, &req->flags);
921 /* matches barrier in request_wait_answer() */
922 smp_mb__after_atomic();
923
914 fsvq->in_flight++; 924 fsvq->in_flight++;
915 notify = virtqueue_kick_prepare(vq); 925 notify = virtqueue_kick_prepare(vq);
916 926
@@ -939,7 +949,6 @@ __releases(fiq->lock)
939 struct virtio_fs *fs; 949 struct virtio_fs *fs;
940 struct fuse_conn *fc; 950 struct fuse_conn *fc;
941 struct fuse_req *req; 951 struct fuse_req *req;
942 struct fuse_pqueue *fpq;
943 struct virtio_fs_vq *fsvq; 952 struct virtio_fs_vq *fsvq;
944 int ret; 953 int ret;
945 954
@@ -958,14 +967,6 @@ __releases(fiq->lock)
958 req->in.h.nodeid, req->in.h.len, 967 req->in.h.nodeid, req->in.h.len,
959 fuse_len_args(req->args->out_numargs, req->args->out_args)); 968 fuse_len_args(req->args->out_numargs, req->args->out_args));
960 969
961 fpq = &fs->vqs[queue_id].fud->pq;
962 spin_lock(&fpq->lock);
963 list_add_tail(&req->list, fpq->processing);
964 spin_unlock(&fpq->lock);
965 set_bit(FR_SENT, &req->flags);
966 /* matches barrier in request_wait_answer() */
967 smp_mb__after_atomic();
968
969retry: 970retry:
970 fsvq = &fs->vqs[queue_id]; 971 fsvq = &fs->vqs[queue_id];
971 ret = virtio_fs_enqueue_req(fsvq, req); 972 ret = virtio_fs_enqueue_req(fsvq, req);
@@ -978,10 +979,6 @@ retry:
978 } 979 }
979 req->out.h.error = ret; 980 req->out.h.error = ret;
980 pr_err("virtio-fs: virtio_fs_enqueue_req() failed %d\n", ret); 981 pr_err("virtio-fs: virtio_fs_enqueue_req() failed %d\n", ret);
981 spin_lock(&fpq->lock);
982 clear_bit(FR_SENT, &req->flags);
983 list_del_init(&req->list);
984 spin_unlock(&fpq->lock);
985 982
986 /* Can't end request in submission context. Use a worker */ 983 /* Can't end request in submission context. Use a worker */
987 spin_lock(&fsvq->lock); 984 spin_lock(&fsvq->lock);