diff options
author | Kirill Tkhai <ktkhai@virtuozzo.com> | 2018-11-08 04:05:36 -0500 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2019-02-13 07:15:13 -0500 |
commit | 7407a10de57f5810f3f0e778eb1db0923d24ab16 (patch) | |
tree | 704c88e08900487a128bbdb1e3250b72319ee50a /fs/fuse | |
parent | 5e0fed717a383ce6e894334cffe7a2acc9dc17b9 (diff) |
fuse: Do some refactoring in fuse_dev_do_write()
This is needed for next patch.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/fuse')
-rw-r--r-- | fs/fuse/dev.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 0a69656402e5..682c7914a0a0 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
@@ -1915,16 +1915,17 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, | |||
1915 | struct fuse_req *req; | 1915 | struct fuse_req *req; |
1916 | struct fuse_out_header oh; | 1916 | struct fuse_out_header oh; |
1917 | 1917 | ||
1918 | err = -EINVAL; | ||
1918 | if (nbytes < sizeof(struct fuse_out_header)) | 1919 | if (nbytes < sizeof(struct fuse_out_header)) |
1919 | return -EINVAL; | 1920 | goto out; |
1920 | 1921 | ||
1921 | err = fuse_copy_one(cs, &oh, sizeof(oh)); | 1922 | err = fuse_copy_one(cs, &oh, sizeof(oh)); |
1922 | if (err) | 1923 | if (err) |
1923 | goto err_finish; | 1924 | goto copy_finish; |
1924 | 1925 | ||
1925 | err = -EINVAL; | 1926 | err = -EINVAL; |
1926 | if (oh.len != nbytes) | 1927 | if (oh.len != nbytes) |
1927 | goto err_finish; | 1928 | goto copy_finish; |
1928 | 1929 | ||
1929 | /* | 1930 | /* |
1930 | * Zero oh.unique indicates unsolicited notification message | 1931 | * Zero oh.unique indicates unsolicited notification message |
@@ -1932,41 +1933,40 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, | |||
1932 | */ | 1933 | */ |
1933 | if (!oh.unique) { | 1934 | if (!oh.unique) { |
1934 | err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs); | 1935 | err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs); |
1935 | return err ? err : nbytes; | 1936 | goto out; |
1936 | } | 1937 | } |
1937 | 1938 | ||
1938 | err = -EINVAL; | 1939 | err = -EINVAL; |
1939 | if (oh.error <= -1000 || oh.error > 0) | 1940 | if (oh.error <= -1000 || oh.error > 0) |
1940 | goto err_finish; | 1941 | goto copy_finish; |
1941 | 1942 | ||
1942 | spin_lock(&fpq->lock); | 1943 | spin_lock(&fpq->lock); |
1943 | err = -ENOENT; | 1944 | req = NULL; |
1944 | if (!fpq->connected) | 1945 | if (fpq->connected) |
1945 | goto err_unlock_pq; | 1946 | req = request_find(fpq, oh.unique & ~FUSE_INT_REQ_BIT); |
1946 | 1947 | ||
1947 | req = request_find(fpq, oh.unique & ~FUSE_INT_REQ_BIT); | 1948 | err = -ENOENT; |
1948 | if (!req) | 1949 | if (!req) { |
1949 | goto err_unlock_pq; | 1950 | spin_unlock(&fpq->lock); |
1951 | goto copy_finish; | ||
1952 | } | ||
1950 | 1953 | ||
1951 | /* Is it an interrupt reply ID? */ | 1954 | /* Is it an interrupt reply ID? */ |
1952 | if (oh.unique & FUSE_INT_REQ_BIT) { | 1955 | if (oh.unique & FUSE_INT_REQ_BIT) { |
1953 | __fuse_get_request(req); | 1956 | __fuse_get_request(req); |
1954 | spin_unlock(&fpq->lock); | 1957 | spin_unlock(&fpq->lock); |
1955 | 1958 | ||
1956 | err = -EINVAL; | 1959 | err = 0; |
1957 | if (nbytes != sizeof(struct fuse_out_header)) { | 1960 | if (nbytes != sizeof(struct fuse_out_header)) |
1958 | fuse_put_request(fc, req); | 1961 | err = -EINVAL; |
1959 | goto err_finish; | 1962 | else if (oh.error == -ENOSYS) |
1960 | } | ||
1961 | |||
1962 | if (oh.error == -ENOSYS) | ||
1963 | fc->no_interrupt = 1; | 1963 | fc->no_interrupt = 1; |
1964 | else if (oh.error == -EAGAIN) | 1964 | else if (oh.error == -EAGAIN) |
1965 | queue_interrupt(&fc->iq, req); | 1965 | queue_interrupt(&fc->iq, req); |
1966 | |||
1966 | fuse_put_request(fc, req); | 1967 | fuse_put_request(fc, req); |
1967 | 1968 | ||
1968 | fuse_copy_finish(cs); | 1969 | goto copy_finish; |
1969 | return nbytes; | ||
1970 | } | 1970 | } |
1971 | 1971 | ||
1972 | clear_bit(FR_SENT, &req->flags); | 1972 | clear_bit(FR_SENT, &req->flags); |
@@ -1992,14 +1992,12 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, | |||
1992 | spin_unlock(&fpq->lock); | 1992 | spin_unlock(&fpq->lock); |
1993 | 1993 | ||
1994 | request_end(fc, req); | 1994 | request_end(fc, req); |
1995 | 1995 | out: | |
1996 | return err ? err : nbytes; | 1996 | return err ? err : nbytes; |
1997 | 1997 | ||
1998 | err_unlock_pq: | 1998 | copy_finish: |
1999 | spin_unlock(&fpq->lock); | ||
2000 | err_finish: | ||
2001 | fuse_copy_finish(cs); | 1999 | fuse_copy_finish(cs); |
2002 | return err; | 2000 | goto out; |
2003 | } | 2001 | } |
2004 | 2002 | ||
2005 | static ssize_t fuse_dev_write(struct kiocb *iocb, struct iov_iter *from) | 2003 | static ssize_t fuse_dev_write(struct kiocb *iocb, struct iov_iter *from) |