Skip to content

Commit 5dbe190

Browse files
rhvgoyalMiklos Szeredi
authored andcommitted
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 <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 7ee1e2e commit 5dbe190

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

fs/fuse/virtio_fs.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
857857
unsigned int i;
858858
int ret;
859859
bool notify;
860+
struct fuse_pqueue *fpq;
860861

861862
/* Does the sglist fit on the stack? */
862863
total_sgs = sg_count_fuse_req(req);
@@ -911,6 +912,15 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
911912
goto out;
912913
}
913914

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+
914924
fsvq->in_flight++;
915925
notify = virtqueue_kick_prepare(vq);
916926

@@ -939,7 +949,6 @@ __releases(fiq->lock)
939949
struct virtio_fs *fs;
940950
struct fuse_conn *fc;
941951
struct fuse_req *req;
942-
struct fuse_pqueue *fpq;
943952
struct virtio_fs_vq *fsvq;
944953
int ret;
945954

@@ -958,14 +967,6 @@ __releases(fiq->lock)
958967
req->in.h.nodeid, req->in.h.len,
959968
fuse_len_args(req->args->out_numargs, req->args->out_args));
960969

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-
969970
retry:
970971
fsvq = &fs->vqs[queue_id];
971972
ret = virtio_fs_enqueue_req(fsvq, req);
@@ -978,10 +979,6 @@ __releases(fiq->lock)
978979
}
979980
req->out.h.error = ret;
980981
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);
985982

986983
/* Can't end request in submission context. Use a worker */
987984
spin_lock(&fsvq->lock);

0 commit comments

Comments
 (0)