aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2017-02-11 12:46:08 -0500
committerIlya Dryomov <idryomov@gmail.com>2017-02-24 13:04:57 -0500
commitb18b9550e4059ceea0393c518eb323b95243f92f (patch)
tree4401ab6439dea8ced7d5c49039c3aa981034d444
parent55f2a04588c5881d90e22631b17a84cd25d17cc4 (diff)
libceph: get rid of ack vs commit
- CEPH_OSD_FLAG_ACK shouldn't be set anymore, so assert on it - remove support for handling ack replies (OSDs will send ack replies only if clients request them) - drop the "do lingering callbacks under osd->lock" logic from handle_reply() -- lreq->lock is sufficient in all three cases Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Sage Weil <sage@redhat.com>
-rw-r--r--include/linux/ceph/osd_client.h6
-rw-r--r--net/ceph/osd_client.c113
2 files changed, 27 insertions, 92 deletions
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index 03a6653d329a..2ea0c282f3dc 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -22,7 +22,6 @@ struct ceph_osd_client;
22 * completion callback for async writepages 22 * completion callback for async writepages
23 */ 23 */
24typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *); 24typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *);
25typedef void (*ceph_osdc_unsafe_callback_t)(struct ceph_osd_request *, bool);
26 25
27#define CEPH_HOMELESS_OSD -1 26#define CEPH_HOMELESS_OSD -1
28 27
@@ -170,15 +169,12 @@ struct ceph_osd_request {
170 unsigned int r_num_ops; 169 unsigned int r_num_ops;
171 170
172 int r_result; 171 int r_result;
173 bool r_got_reply;
174 172
175 struct ceph_osd_client *r_osdc; 173 struct ceph_osd_client *r_osdc;
176 struct kref r_kref; 174 struct kref r_kref;
177 bool r_mempool; 175 bool r_mempool;
178 struct completion r_completion; 176 struct completion r_completion; /* private to osd_client.c */
179 struct completion r_done_completion; /* fsync waiter */
180 ceph_osdc_callback_t r_callback; 177 ceph_osdc_callback_t r_callback;
181 ceph_osdc_unsafe_callback_t r_unsafe_callback;
182 struct list_head r_unsafe_item; 178 struct list_head r_unsafe_item;
183 179
184 struct inode *r_inode; /* for use by callbacks */ 180 struct inode *r_inode; /* for use by callbacks */
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index ac4753421d0c..e1c6c2b4a295 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -460,7 +460,6 @@ static void request_init(struct ceph_osd_request *req)
460 460
461 kref_init(&req->r_kref); 461 kref_init(&req->r_kref);
462 init_completion(&req->r_completion); 462 init_completion(&req->r_completion);
463 init_completion(&req->r_done_completion);
464 RB_CLEAR_NODE(&req->r_node); 463 RB_CLEAR_NODE(&req->r_node);
465 RB_CLEAR_NODE(&req->r_mc_node); 464 RB_CLEAR_NODE(&req->r_mc_node);
466 INIT_LIST_HEAD(&req->r_unsafe_item); 465 INIT_LIST_HEAD(&req->r_unsafe_item);
@@ -1637,7 +1636,7 @@ static void __submit_request(struct ceph_osd_request *req, bool wrlocked)
1637 bool need_send = false; 1636 bool need_send = false;
1638 bool promoted = false; 1637 bool promoted = false;
1639 1638
1640 WARN_ON(req->r_tid || req->r_got_reply); 1639 WARN_ON(req->r_tid);
1641 dout("%s req %p wrlocked %d\n", __func__, req, wrlocked); 1640 dout("%s req %p wrlocked %d\n", __func__, req, wrlocked);
1642 1641
1643again: 1642again:
@@ -1705,17 +1704,10 @@ promote:
1705 1704
1706static void account_request(struct ceph_osd_request *req) 1705static void account_request(struct ceph_osd_request *req)
1707{ 1706{
1708 unsigned int mask = CEPH_OSD_FLAG_ACK | CEPH_OSD_FLAG_ONDISK; 1707 WARN_ON(req->r_flags & CEPH_OSD_FLAG_ACK);
1708 WARN_ON(!(req->r_flags & (CEPH_OSD_FLAG_READ | CEPH_OSD_FLAG_WRITE)));
1709 1709
1710 if (req->r_flags & CEPH_OSD_FLAG_READ) { 1710 req->r_flags |= CEPH_OSD_FLAG_ONDISK;
1711 WARN_ON(req->r_flags & mask);
1712 req->r_flags |= CEPH_OSD_FLAG_ACK;
1713 } else if (req->r_flags & CEPH_OSD_FLAG_WRITE)
1714 WARN_ON(!(req->r_flags & mask));
1715 else
1716 WARN_ON(1);
1717
1718 WARN_ON(req->r_unsafe_callback && (req->r_flags & mask) != mask);
1719 atomic_inc(&req->r_osdc->num_requests); 1711 atomic_inc(&req->r_osdc->num_requests);
1720} 1712}
1721 1713
@@ -1750,15 +1742,15 @@ static void finish_request(struct ceph_osd_request *req)
1750 1742
1751static void __complete_request(struct ceph_osd_request *req) 1743static void __complete_request(struct ceph_osd_request *req)
1752{ 1744{
1753 if (req->r_callback) 1745 if (req->r_callback) {
1746 dout("%s req %p tid %llu cb %pf result %d\n", __func__, req,
1747 req->r_tid, req->r_callback, req->r_result);
1754 req->r_callback(req); 1748 req->r_callback(req);
1755 else 1749 }
1756 complete_all(&req->r_completion);
1757} 1750}
1758 1751
1759/* 1752/*
1760 * Note that this is open-coded in handle_reply(), which has to deal 1753 * This is open-coded in handle_reply().
1761 * with ack vs commit, dup acks, etc.
1762 */ 1754 */
1763static void complete_request(struct ceph_osd_request *req, int err) 1755static void complete_request(struct ceph_osd_request *req, int err)
1764{ 1756{
@@ -1767,7 +1759,7 @@ static void complete_request(struct ceph_osd_request *req, int err)
1767 req->r_result = err; 1759 req->r_result = err;
1768 finish_request(req); 1760 finish_request(req);
1769 __complete_request(req); 1761 __complete_request(req);
1770 complete_all(&req->r_done_completion); 1762 complete_all(&req->r_completion);
1771 ceph_osdc_put_request(req); 1763 ceph_osdc_put_request(req);
1772} 1764}
1773 1765
@@ -1793,7 +1785,7 @@ static void cancel_request(struct ceph_osd_request *req)
1793 1785
1794 cancel_map_check(req); 1786 cancel_map_check(req);
1795 finish_request(req); 1787 finish_request(req);
1796 complete_all(&req->r_done_completion); 1788 complete_all(&req->r_completion);
1797 ceph_osdc_put_request(req); 1789 ceph_osdc_put_request(req);
1798} 1790}
1799 1791
@@ -2170,7 +2162,6 @@ static void linger_commit_cb(struct ceph_osd_request *req)
2170 mutex_lock(&lreq->lock); 2162 mutex_lock(&lreq->lock);
2171 dout("%s lreq %p linger_id %llu result %d\n", __func__, lreq, 2163 dout("%s lreq %p linger_id %llu result %d\n", __func__, lreq,
2172 lreq->linger_id, req->r_result); 2164 lreq->linger_id, req->r_result);
2173 WARN_ON(!__linger_registered(lreq));
2174 linger_reg_commit_complete(lreq, req->r_result); 2165 linger_reg_commit_complete(lreq, req->r_result);
2175 lreq->committed = true; 2166 lreq->committed = true;
2176 2167
@@ -2786,31 +2777,8 @@ e_inval:
2786} 2777}
2787 2778
2788/* 2779/*
2789 * We are done with @req if 2780 * Handle MOSDOpReply. Set ->r_result and call the callback if it is
2790 * - @m is a safe reply, or 2781 * specified.
2791 * - @m is an unsafe reply and we didn't want a safe one
2792 */
2793static bool done_request(const struct ceph_osd_request *req,
2794 const struct MOSDOpReply *m)
2795{
2796 return (m->result < 0 ||
2797 (m->flags & CEPH_OSD_FLAG_ONDISK) ||
2798 !(req->r_flags & CEPH_OSD_FLAG_ONDISK));
2799}
2800
2801/*
2802 * handle osd op reply. either call the callback if it is specified,
2803 * or do the completion to wake up the waiting thread.
2804 *
2805 * ->r_unsafe_callback is set? yes no
2806 *
2807 * first reply is OK (needed r_cb/r_completion, r_cb/r_completion,
2808 * any or needed/got safe) r_done_completion r_done_completion
2809 *
2810 * first reply is unsafe r_unsafe_cb(true) (nothing)
2811 *
2812 * when we get the safe reply r_unsafe_cb(false), r_cb/r_completion,
2813 * r_done_completion r_done_completion
2814 */ 2782 */
2815static void handle_reply(struct ceph_osd *osd, struct ceph_msg *msg) 2783static void handle_reply(struct ceph_osd *osd, struct ceph_msg *msg)
2816{ 2784{
@@ -2819,7 +2787,6 @@ static void handle_reply(struct ceph_osd *osd, struct ceph_msg *msg)
2819 struct MOSDOpReply m; 2787 struct MOSDOpReply m;
2820 u64 tid = le64_to_cpu(msg->hdr.tid); 2788 u64 tid = le64_to_cpu(msg->hdr.tid);
2821 u32 data_len = 0; 2789 u32 data_len = 0;
2822 bool already_acked;
2823 int ret; 2790 int ret;
2824 int i; 2791 int i;
2825 2792
@@ -2898,50 +2865,22 @@ static void handle_reply(struct ceph_osd *osd, struct ceph_msg *msg)
2898 le32_to_cpu(msg->hdr.data_len), req->r_tid); 2865 le32_to_cpu(msg->hdr.data_len), req->r_tid);
2899 goto fail_request; 2866 goto fail_request;
2900 } 2867 }
2901 dout("%s req %p tid %llu acked %d result %d data_len %u\n", __func__, 2868 dout("%s req %p tid %llu result %d data_len %u\n", __func__,
2902 req, req->r_tid, req->r_got_reply, m.result, data_len); 2869 req, req->r_tid, m.result, data_len);
2903
2904 already_acked = req->r_got_reply;
2905 if (!already_acked) {
2906 req->r_result = m.result ?: data_len;
2907 req->r_replay_version = m.replay_version; /* struct */
2908 req->r_got_reply = true;
2909 } else if (!(m.flags & CEPH_OSD_FLAG_ONDISK)) {
2910 dout("req %p tid %llu dup ack\n", req, req->r_tid);
2911 goto out_unlock_session;
2912 }
2913
2914 if (done_request(req, &m)) {
2915 finish_request(req);
2916 if (req->r_linger) {
2917 WARN_ON(req->r_unsafe_callback);
2918 dout("req %p tid %llu cb (locked)\n", req, req->r_tid);
2919 __complete_request(req);
2920 }
2921 }
2922 2870
2871 /*
2872 * Since we only ever request ONDISK, we should only ever get
2873 * one (type of) reply back.
2874 */
2875 WARN_ON(!(m.flags & CEPH_OSD_FLAG_ONDISK));
2876 req->r_result = m.result ?: data_len;
2877 finish_request(req);
2923 mutex_unlock(&osd->lock); 2878 mutex_unlock(&osd->lock);
2924 up_read(&osdc->lock); 2879 up_read(&osdc->lock);
2925 2880
2926 if (done_request(req, &m)) { 2881 __complete_request(req);
2927 if (already_acked && req->r_unsafe_callback) { 2882 complete_all(&req->r_completion);
2928 dout("req %p tid %llu safe-cb\n", req, req->r_tid); 2883 ceph_osdc_put_request(req);
2929 req->r_unsafe_callback(req, false);
2930 } else if (!req->r_linger) {
2931 dout("req %p tid %llu cb\n", req, req->r_tid);
2932 __complete_request(req);
2933 }
2934 complete_all(&req->r_done_completion);
2935 ceph_osdc_put_request(req);
2936 } else {
2937 if (req->r_unsafe_callback) {
2938 dout("req %p tid %llu unsafe-cb\n", req, req->r_tid);
2939 req->r_unsafe_callback(req, true);
2940 } else {
2941 WARN_ON(1);
2942 }
2943 }
2944
2945 return; 2884 return;
2946 2885
2947fail_request: 2886fail_request:
@@ -3541,7 +3480,7 @@ again:
3541 up_read(&osdc->lock); 3480 up_read(&osdc->lock);
3542 dout("%s waiting on req %p tid %llu last_tid %llu\n", 3481 dout("%s waiting on req %p tid %llu last_tid %llu\n",
3543 __func__, req, req->r_tid, last_tid); 3482 __func__, req, req->r_tid, last_tid);
3544 wait_for_completion(&req->r_done_completion); 3483 wait_for_completion(&req->r_completion);
3545 ceph_osdc_put_request(req); 3484 ceph_osdc_put_request(req);
3546 goto again; 3485 goto again;
3547 } 3486 }