Commit 7407a10d authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Miklos Szeredi

fuse: Do some refactoring in fuse_dev_do_write()

This is needed for next patch.
Signed-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent 5e0fed71
...@@ -1915,16 +1915,17 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, ...@@ -1915,16 +1915,17 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud,
struct fuse_req *req; struct fuse_req *req;
struct fuse_out_header oh; struct fuse_out_header oh;
err = -EINVAL;
if (nbytes < sizeof(struct fuse_out_header)) if (nbytes < sizeof(struct fuse_out_header))
return -EINVAL; goto out;
err = fuse_copy_one(cs, &oh, sizeof(oh)); err = fuse_copy_one(cs, &oh, sizeof(oh));
if (err) if (err)
goto err_finish; goto copy_finish;
err = -EINVAL; err = -EINVAL;
if (oh.len != nbytes) if (oh.len != nbytes)
goto err_finish; goto copy_finish;
/* /*
* Zero oh.unique indicates unsolicited notification message * Zero oh.unique indicates unsolicited notification message
...@@ -1932,41 +1933,40 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, ...@@ -1932,41 +1933,40 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud,
*/ */
if (!oh.unique) { if (!oh.unique) {
err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs); err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs);
return err ? err : nbytes; goto out;
} }
err = -EINVAL; err = -EINVAL;
if (oh.error <= -1000 || oh.error > 0) if (oh.error <= -1000 || oh.error > 0)
goto err_finish; goto copy_finish;
spin_lock(&fpq->lock); spin_lock(&fpq->lock);
err = -ENOENT; req = NULL;
if (!fpq->connected) if (fpq->connected)
goto err_unlock_pq; req = request_find(fpq, oh.unique & ~FUSE_INT_REQ_BIT);
req = request_find(fpq, oh.unique & ~FUSE_INT_REQ_BIT); err = -ENOENT;
if (!req) if (!req) {
goto err_unlock_pq; spin_unlock(&fpq->lock);
goto copy_finish;
}
/* Is it an interrupt reply ID? */ /* Is it an interrupt reply ID? */
if (oh.unique & FUSE_INT_REQ_BIT) { if (oh.unique & FUSE_INT_REQ_BIT) {
__fuse_get_request(req); __fuse_get_request(req);
spin_unlock(&fpq->lock); spin_unlock(&fpq->lock);
err = -EINVAL; err = 0;
if (nbytes != sizeof(struct fuse_out_header)) { if (nbytes != sizeof(struct fuse_out_header))
fuse_put_request(fc, req); err = -EINVAL;
goto err_finish; else if (oh.error == -ENOSYS)
}
if (oh.error == -ENOSYS)
fc->no_interrupt = 1; fc->no_interrupt = 1;
else if (oh.error == -EAGAIN) else if (oh.error == -EAGAIN)
queue_interrupt(&fc->iq, req); queue_interrupt(&fc->iq, req);
fuse_put_request(fc, req); fuse_put_request(fc, req);
fuse_copy_finish(cs); goto copy_finish;
return nbytes;
} }
clear_bit(FR_SENT, &req->flags); clear_bit(FR_SENT, &req->flags);
...@@ -1992,14 +1992,12 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, ...@@ -1992,14 +1992,12 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud,
spin_unlock(&fpq->lock); spin_unlock(&fpq->lock);
request_end(fc, req); request_end(fc, req);
out:
return err ? err : nbytes; return err ? err : nbytes;
err_unlock_pq: copy_finish:
spin_unlock(&fpq->lock);
err_finish:
fuse_copy_finish(cs); fuse_copy_finish(cs);
return err; goto out;
} }
static ssize_t fuse_dev_write(struct kiocb *iocb, struct iov_iter *from) static ssize_t fuse_dev_write(struct kiocb *iocb, struct iov_iter *from)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment