Commit 85e084fe authored by Ilya Dryomov's avatar Ilya Dryomov

libceph: drop msg argument from ceph_osdc_callback_t

finish_read(), its only user, uses it to get to hdr.data_len, which is
what ->r_result is set to on success.  This gains us the ability to
safely call callbacks from contexts other than reply, e.g. map check.
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent bb873b53
...@@ -1828,13 +1828,12 @@ static void rbd_osd_call_callback(struct rbd_obj_request *obj_request) ...@@ -1828,13 +1828,12 @@ static void rbd_osd_call_callback(struct rbd_obj_request *obj_request)
obj_request_done_set(obj_request); obj_request_done_set(obj_request);
} }
static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, static void rbd_osd_req_callback(struct ceph_osd_request *osd_req)
struct ceph_msg *msg)
{ {
struct rbd_obj_request *obj_request = osd_req->r_priv; struct rbd_obj_request *obj_request = osd_req->r_priv;
u16 opcode; u16 opcode;
dout("%s: osd_req %p msg %p\n", __func__, osd_req, msg); dout("%s: osd_req %p\n", __func__, osd_req);
rbd_assert(osd_req == obj_request->osd_req); rbd_assert(osd_req == obj_request->osd_req);
if (obj_request_img_data_test(obj_request)) { if (obj_request_img_data_test(obj_request)) {
rbd_assert(obj_request->img_request); rbd_assert(obj_request->img_request);
......
...@@ -257,12 +257,12 @@ static int ceph_readpage(struct file *filp, struct page *page) ...@@ -257,12 +257,12 @@ static int ceph_readpage(struct file *filp, struct page *page)
/* /*
* Finish an async read(ahead) op. * Finish an async read(ahead) op.
*/ */
static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg) static void finish_read(struct ceph_osd_request *req)
{ {
struct inode *inode = req->r_inode; struct inode *inode = req->r_inode;
struct ceph_osd_data *osd_data; struct ceph_osd_data *osd_data;
int rc = req->r_result; int rc = req->r_result <= 0 ? req->r_result : 0;
int bytes = le32_to_cpu(msg->hdr.data_len); int bytes = req->r_result >= 0 ? req->r_result : 0;
int num_pages; int num_pages;
int i; int i;
...@@ -598,8 +598,7 @@ static void ceph_release_pages(struct page **pages, int num) ...@@ -598,8 +598,7 @@ static void ceph_release_pages(struct page **pages, int num)
* If we get an error, set the mapping error bit, but not the individual * If we get an error, set the mapping error bit, but not the individual
* page error bits. * page error bits.
*/ */
static void writepages_finish(struct ceph_osd_request *req, static void writepages_finish(struct ceph_osd_request *req)
struct ceph_msg *msg)
{ {
struct inode *inode = req->r_inode; struct inode *inode = req->r_inode;
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
......
...@@ -616,8 +616,7 @@ static void ceph_aio_complete(struct inode *inode, ...@@ -616,8 +616,7 @@ static void ceph_aio_complete(struct inode *inode,
kfree(aio_req); kfree(aio_req);
} }
static void ceph_aio_complete_req(struct ceph_osd_request *req, static void ceph_aio_complete_req(struct ceph_osd_request *req)
struct ceph_msg *msg)
{ {
int rc = req->r_result; int rc = req->r_result;
struct inode *inode = req->r_inode; struct inode *inode = req->r_inode;
...@@ -740,7 +739,7 @@ static void ceph_aio_retry_work(struct work_struct *work) ...@@ -740,7 +739,7 @@ static void ceph_aio_retry_work(struct work_struct *work)
out: out:
if (ret < 0) { if (ret < 0) {
req->r_result = ret; req->r_result = ret;
ceph_aio_complete_req(req, NULL); ceph_aio_complete_req(req);
} }
ceph_put_snap_context(snapc); ceph_put_snap_context(snapc);
...@@ -961,7 +960,7 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter, ...@@ -961,7 +960,7 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
req, false); req, false);
if (ret < 0) { if (ret < 0) {
req->r_result = ret; req->r_result = ret;
ceph_aio_complete_req(req, NULL); ceph_aio_complete_req(req);
} }
} }
return -EIOCBQUEUED; return -EIOCBQUEUED;
......
...@@ -20,8 +20,7 @@ struct ceph_osd_client; ...@@ -20,8 +20,7 @@ struct ceph_osd_client;
/* /*
* completion callback for async writepages * completion callback for async writepages
*/ */
typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *, typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *);
struct ceph_msg *);
typedef void (*ceph_osdc_unsafe_callback_t)(struct ceph_osd_request *, bool); typedef void (*ceph_osdc_unsafe_callback_t)(struct ceph_osd_request *, bool);
#define CEPH_HOMELESS_OSD -1 #define CEPH_HOMELESS_OSD -1
......
...@@ -2048,7 +2048,7 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg) ...@@ -2048,7 +2048,7 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg)
result >= 0 && !(flags & CEPH_OSD_FLAG_ONDISK)) result >= 0 && !(flags & CEPH_OSD_FLAG_ONDISK))
req->r_unsafe_callback(req, true); req->r_unsafe_callback(req, true);
if (req->r_callback) if (req->r_callback)
req->r_callback(req, msg); req->r_callback(req);
else else
complete_all(&req->r_completion); complete_all(&req->r_completion);
} }
...@@ -2072,7 +2072,7 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg) ...@@ -2072,7 +2072,7 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg)
req->r_result = -EIO; req->r_result = -EIO;
__unregister_request(osdc, req); __unregister_request(osdc, req);
if (req->r_callback) if (req->r_callback)
req->r_callback(req, msg); req->r_callback(req);
else else
complete_all(&req->r_completion); complete_all(&req->r_completion);
complete_request(req); complete_request(req);
......
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