Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1 | #ifndef _FS_CEPH_OSD_CLIENT_H |
| 2 | #define _FS_CEPH_OSD_CLIENT_H |
| 3 | |
Ilya Dryomov | a02a946 | 2017-06-19 12:18:05 +0200 | [diff] [blame] | 4 | #include <linux/bitrev.h> |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 5 | #include <linux/completion.h> |
Sage Weil | 415e49a | 2009-12-07 13:37:03 -0800 | [diff] [blame] | 6 | #include <linux/kref.h> |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 7 | #include <linux/mempool.h> |
| 8 | #include <linux/rbtree.h> |
Elena Reshetova | 02113a0 | 2017-03-17 14:10:28 +0200 | [diff] [blame] | 9 | #include <linux/refcount.h> |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 10 | |
Alex Elder | 6c4a191 | 2012-05-16 15:16:38 -0500 | [diff] [blame] | 11 | #include <linux/ceph/types.h> |
| 12 | #include <linux/ceph/osdmap.h> |
| 13 | #include <linux/ceph/messenger.h> |
Ilya Dryomov | b2aa5d0 | 2016-06-07 21:57:15 +0200 | [diff] [blame] | 14 | #include <linux/ceph/msgpool.h> |
Alex Elder | 6c4a191 | 2012-05-16 15:16:38 -0500 | [diff] [blame] | 15 | #include <linux/ceph/auth.h> |
Alex Elder | c885837 | 2012-11-13 21:11:15 -0600 | [diff] [blame] | 16 | #include <linux/ceph/pagelist.h> |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 17 | |
| 18 | struct ceph_msg; |
| 19 | struct ceph_snap_context; |
| 20 | struct ceph_osd_request; |
| 21 | struct ceph_osd_client; |
| 22 | |
| 23 | /* |
| 24 | * completion callback for async writepages |
| 25 | */ |
Ilya Dryomov | 85e084f | 2016-04-28 16:07:24 +0200 | [diff] [blame] | 26 | typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 27 | |
Ilya Dryomov | 63244fa | 2016-04-28 16:07:23 +0200 | [diff] [blame] | 28 | #define CEPH_HOMELESS_OSD -1 |
| 29 | |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 30 | /* a given osd we're communicating with */ |
| 31 | struct ceph_osd { |
Elena Reshetova | 02113a0 | 2017-03-17 14:10:28 +0200 | [diff] [blame] | 32 | refcount_t o_ref; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 33 | struct ceph_osd_client *o_osdc; |
| 34 | int o_osd; |
| 35 | int o_incarnation; |
| 36 | struct rb_node o_node; |
| 37 | struct ceph_connection o_con; |
Ilya Dryomov | 5aea3dc | 2016-04-28 16:07:26 +0200 | [diff] [blame] | 38 | struct rb_root o_requests; |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 39 | struct rb_root o_linger_requests; |
Ilya Dryomov | a02a946 | 2017-06-19 12:18:05 +0200 | [diff] [blame] | 40 | struct rb_root o_backoff_mappings; |
| 41 | struct rb_root o_backoffs_by_id; |
Yehuda Sadeh | f5a2041 | 2010-02-03 11:00:26 -0800 | [diff] [blame] | 42 | struct list_head o_osd_lru; |
Alex Elder | 6c4a191 | 2012-05-16 15:16:38 -0500 | [diff] [blame] | 43 | struct ceph_auth_handshake o_auth; |
Yehuda Sadeh | f5a2041 | 2010-02-03 11:00:26 -0800 | [diff] [blame] | 44 | unsigned long lru_ttl; |
Yehuda Sadeh | 422d2cb | 2010-02-26 15:32:31 -0800 | [diff] [blame] | 45 | struct list_head o_keepalive_item; |
Ilya Dryomov | 5aea3dc | 2016-04-28 16:07:26 +0200 | [diff] [blame] | 46 | struct mutex lock; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
Ilya Dryomov | 3f1af42 | 2016-02-09 17:50:15 +0100 | [diff] [blame] | 49 | #define CEPH_OSD_SLAB_OPS 2 |
| 50 | #define CEPH_OSD_MAX_OPS 16 |
Sage Weil | 1b83bef | 2013-02-25 16:11:12 -0800 | [diff] [blame] | 51 | |
Alex Elder | 2ac2b7a | 2013-02-14 12:16:43 -0600 | [diff] [blame] | 52 | enum ceph_osd_data_type { |
Alex Elder | ec9123c | 2013-04-05 01:27:12 -0500 | [diff] [blame] | 53 | CEPH_OSD_DATA_TYPE_NONE = 0, |
Alex Elder | 2ac2b7a | 2013-02-14 12:16:43 -0600 | [diff] [blame] | 54 | CEPH_OSD_DATA_TYPE_PAGES, |
Alex Elder | 9a5e6d0 | 2013-03-08 13:35:36 -0600 | [diff] [blame] | 55 | CEPH_OSD_DATA_TYPE_PAGELIST, |
Alex Elder | 2ac2b7a | 2013-02-14 12:16:43 -0600 | [diff] [blame] | 56 | #ifdef CONFIG_BLOCK |
| 57 | CEPH_OSD_DATA_TYPE_BIO, |
| 58 | #endif /* CONFIG_BLOCK */ |
| 59 | }; |
| 60 | |
Alex Elder | 2794a82 | 2013-02-14 12:16:43 -0600 | [diff] [blame] | 61 | struct ceph_osd_data { |
Alex Elder | 2ac2b7a | 2013-02-14 12:16:43 -0600 | [diff] [blame] | 62 | enum ceph_osd_data_type type; |
| 63 | union { |
Alex Elder | 2794a82 | 2013-02-14 12:16:43 -0600 | [diff] [blame] | 64 | struct { |
| 65 | struct page **pages; |
Alex Elder | e0c5948 | 2013-03-07 15:38:25 -0600 | [diff] [blame] | 66 | u64 length; |
Alex Elder | 2794a82 | 2013-02-14 12:16:43 -0600 | [diff] [blame] | 67 | u32 alignment; |
| 68 | bool pages_from_pool; |
| 69 | bool own_pages; |
| 70 | }; |
Alex Elder | 9a5e6d0 | 2013-03-08 13:35:36 -0600 | [diff] [blame] | 71 | struct ceph_pagelist *pagelist; |
Alex Elder | 2794a82 | 2013-02-14 12:16:43 -0600 | [diff] [blame] | 72 | #ifdef CONFIG_BLOCK |
Alex Elder | fdce58c | 2013-03-14 14:09:06 -0500 | [diff] [blame] | 73 | struct { |
| 74 | struct bio *bio; /* list of bios */ |
| 75 | size_t bio_length; /* total in list */ |
| 76 | }; |
Alex Elder | 2794a82 | 2013-02-14 12:16:43 -0600 | [diff] [blame] | 77 | #endif /* CONFIG_BLOCK */ |
| 78 | }; |
| 79 | }; |
| 80 | |
Alex Elder | 7952873 | 2013-04-03 21:32:51 -0500 | [diff] [blame] | 81 | struct ceph_osd_req_op { |
| 82 | u16 op; /* CEPH_OSD_OP_* */ |
Ilya Dryomov | 7b25bf5 | 2014-02-25 16:22:26 +0200 | [diff] [blame] | 83 | u32 flags; /* CEPH_OSD_OP_FLAG_* */ |
Ilya Dryomov | de2aa10 | 2016-02-08 13:39:46 +0100 | [diff] [blame] | 84 | u32 indata_len; /* request */ |
Yan, Zheng | 7665d85 | 2016-01-07 16:48:57 +0800 | [diff] [blame] | 85 | u32 outdata_len; /* reply */ |
| 86 | s32 rval; |
| 87 | |
Alex Elder | 7952873 | 2013-04-03 21:32:51 -0500 | [diff] [blame] | 88 | union { |
Alex Elder | 4971977 | 2013-02-11 12:33:24 -0600 | [diff] [blame] | 89 | struct ceph_osd_data raw_data_in; |
Alex Elder | 7952873 | 2013-04-03 21:32:51 -0500 | [diff] [blame] | 90 | struct { |
| 91 | u64 offset, length; |
| 92 | u64 truncate_size; |
| 93 | u32 truncate_seq; |
Alex Elder | 5476492 | 2013-04-05 01:27:12 -0500 | [diff] [blame] | 94 | struct ceph_osd_data osd_data; |
Alex Elder | 7952873 | 2013-04-03 21:32:51 -0500 | [diff] [blame] | 95 | } extent; |
| 96 | struct { |
Ilya Dryomov | d7d5a00 | 2014-12-19 14:00:41 +0300 | [diff] [blame] | 97 | u32 name_len; |
| 98 | u32 value_len; |
Yan, Zheng | d74b50b | 2014-11-12 14:00:43 +0800 | [diff] [blame] | 99 | __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */ |
| 100 | __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */ |
| 101 | struct ceph_osd_data osd_data; |
| 102 | } xattr; |
| 103 | struct { |
Alex Elder | 7952873 | 2013-04-03 21:32:51 -0500 | [diff] [blame] | 104 | const char *class_name; |
| 105 | const char *method_name; |
Alex Elder | 5476492 | 2013-04-05 01:27:12 -0500 | [diff] [blame] | 106 | struct ceph_osd_data request_info; |
Alex Elder | 04017e2 | 2013-04-05 14:46:02 -0500 | [diff] [blame] | 107 | struct ceph_osd_data request_data; |
Alex Elder | 5476492 | 2013-04-05 01:27:12 -0500 | [diff] [blame] | 108 | struct ceph_osd_data response_data; |
Alex Elder | 7952873 | 2013-04-03 21:32:51 -0500 | [diff] [blame] | 109 | __u8 class_len; |
| 110 | __u8 method_len; |
Ilya Dryomov | bb873b539 | 2016-05-26 00:29:52 +0200 | [diff] [blame] | 111 | u32 indata_len; |
Alex Elder | 7952873 | 2013-04-03 21:32:51 -0500 | [diff] [blame] | 112 | } cls; |
| 113 | struct { |
| 114 | u64 cookie; |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 115 | __u8 op; /* CEPH_OSD_WATCH_OP_ */ |
| 116 | u32 gen; |
Alex Elder | 7952873 | 2013-04-03 21:32:51 -0500 | [diff] [blame] | 117 | } watch; |
Ilya Dryomov | c647b8a | 2014-02-25 16:22:27 +0200 | [diff] [blame] | 118 | struct { |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 119 | struct ceph_osd_data request_data; |
| 120 | } notify_ack; |
| 121 | struct { |
Ilya Dryomov | 1907920 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 122 | u64 cookie; |
| 123 | struct ceph_osd_data request_data; |
| 124 | struct ceph_osd_data response_data; |
| 125 | } notify; |
| 126 | struct { |
Douglas Fuller | a4ed38d | 2015-07-17 13:18:07 -0700 | [diff] [blame] | 127 | struct ceph_osd_data response_data; |
| 128 | } list_watchers; |
| 129 | struct { |
Ilya Dryomov | c647b8a | 2014-02-25 16:22:27 +0200 | [diff] [blame] | 130 | u64 expected_object_size; |
| 131 | u64 expected_write_size; |
| 132 | } alloc_hint; |
Alex Elder | 7952873 | 2013-04-03 21:32:51 -0500 | [diff] [blame] | 133 | }; |
| 134 | }; |
| 135 | |
Ilya Dryomov | 63244fa | 2016-04-28 16:07:23 +0200 | [diff] [blame] | 136 | struct ceph_osd_request_target { |
| 137 | struct ceph_object_id base_oid; |
| 138 | struct ceph_object_locator base_oloc; |
| 139 | struct ceph_object_id target_oid; |
| 140 | struct ceph_object_locator target_oloc; |
| 141 | |
Ilya Dryomov | dc98ff7 | 2017-06-15 16:30:53 +0200 | [diff] [blame] | 142 | struct ceph_pg pgid; /* last raw pg we mapped to */ |
| 143 | struct ceph_spg spgid; /* last actual spg we mapped to */ |
Ilya Dryomov | 63244fa | 2016-04-28 16:07:23 +0200 | [diff] [blame] | 144 | u32 pg_num; |
| 145 | u32 pg_num_mask; |
| 146 | struct ceph_osds acting; |
| 147 | struct ceph_osds up; |
| 148 | int size; |
| 149 | int min_size; |
| 150 | bool sort_bitwise; |
| 151 | |
| 152 | unsigned int flags; /* CEPH_OSD_FLAG_* */ |
| 153 | bool paused; |
| 154 | |
Ilya Dryomov | 04c7d78 | 2017-06-15 16:30:55 +0200 | [diff] [blame] | 155 | u32 epoch; |
Ilya Dryomov | dc93e0e | 2017-06-05 14:45:00 +0200 | [diff] [blame] | 156 | u32 last_force_resend; |
| 157 | |
Ilya Dryomov | 63244fa | 2016-04-28 16:07:23 +0200 | [diff] [blame] | 158 | int osd; |
| 159 | }; |
| 160 | |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 161 | /* an in-flight request */ |
| 162 | struct ceph_osd_request { |
| 163 | u64 r_tid; /* unique for this client */ |
| 164 | struct rb_node r_node; |
Ilya Dryomov | 4609245 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 165 | struct rb_node r_mc_node; /* map check */ |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 166 | struct ceph_osd *r_osd; |
Ilya Dryomov | a66dd38 | 2016-04-28 16:07:23 +0200 | [diff] [blame] | 167 | |
| 168 | struct ceph_osd_request_target r_t; |
| 169 | #define r_base_oid r_t.base_oid |
| 170 | #define r_base_oloc r_t.base_oloc |
| 171 | #define r_flags r_t.flags |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 172 | |
| 173 | struct ceph_msg *r_request, *r_reply; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 174 | u32 r_sent; /* >0 if r_request is sending/sent */ |
Sage Weil | 1b83bef | 2013-02-25 16:11:12 -0800 | [diff] [blame] | 175 | |
Alex Elder | 7952873 | 2013-04-03 21:32:51 -0500 | [diff] [blame] | 176 | /* request osd ops array */ |
| 177 | unsigned int r_num_ops; |
Alex Elder | 7952873 | 2013-04-03 21:32:51 -0500 | [diff] [blame] | 178 | |
Sage Weil | 1b83bef | 2013-02-25 16:11:12 -0800 | [diff] [blame] | 179 | int r_result; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 180 | |
| 181 | struct ceph_osd_client *r_osdc; |
Sage Weil | 415e49a | 2009-12-07 13:37:03 -0800 | [diff] [blame] | 182 | struct kref r_kref; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 183 | bool r_mempool; |
Ilya Dryomov | b18b955 | 2017-02-11 18:46:08 +0100 | [diff] [blame] | 184 | struct completion r_completion; /* private to osd_client.c */ |
Alex Elder | 26be880 | 2013-04-15 11:20:42 -0500 | [diff] [blame] | 185 | ceph_osdc_callback_t r_callback; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 186 | struct list_head r_unsafe_item; |
| 187 | |
| 188 | struct inode *r_inode; /* for use by callbacks */ |
Yehuda Sadeh | 3d14c5d | 2010-04-06 15:14:15 -0700 | [diff] [blame] | 189 | void *r_priv; /* ditto */ |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 190 | |
Ilya Dryomov | bb873b539 | 2016-05-26 00:29:52 +0200 | [diff] [blame] | 191 | /* set by submitter */ |
| 192 | u64 r_snapid; /* for reads, CEPH_NOSNAP o/w */ |
| 193 | struct ceph_snap_context *r_snapc; /* for writes */ |
| 194 | struct timespec r_mtime; /* ditto */ |
| 195 | u64 r_data_offset; /* ditto */ |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 196 | bool r_linger; /* don't resend on failure */ |
Jeff Layton | a1f4020 | 2017-04-04 08:39:37 -0400 | [diff] [blame] | 197 | bool r_abort_on_full; /* return ENOSPC when full */ |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 198 | |
Ilya Dryomov | bb873b539 | 2016-05-26 00:29:52 +0200 | [diff] [blame] | 199 | /* internal */ |
| 200 | unsigned long r_stamp; /* jiffies, send or check time */ |
Ilya Dryomov | 7cc5e38 | 2017-02-12 17:11:07 +0100 | [diff] [blame] | 201 | unsigned long r_start_stamp; /* jiffies */ |
Ilya Dryomov | bb873b539 | 2016-05-26 00:29:52 +0200 | [diff] [blame] | 202 | int r_attempts; |
Ilya Dryomov | 4609245 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 203 | u32 r_map_dne_bound; |
Ilya Dryomov | 3f1af42 | 2016-02-09 17:50:15 +0100 | [diff] [blame] | 204 | |
| 205 | struct ceph_osd_req_op r_ops[]; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 206 | }; |
| 207 | |
Ilya Dryomov | 205ee118 | 2014-01-27 17:40:20 +0200 | [diff] [blame] | 208 | struct ceph_request_redirect { |
| 209 | struct ceph_object_locator oloc; |
| 210 | }; |
| 211 | |
Ilya Dryomov | 8cb441c | 2017-06-15 16:30:54 +0200 | [diff] [blame] | 212 | /* |
| 213 | * osd request identifier |
| 214 | * |
| 215 | * caller name + incarnation# + tid to unique identify this request |
| 216 | */ |
| 217 | struct ceph_osd_reqid { |
| 218 | struct ceph_entity_name name; |
| 219 | __le64 tid; |
| 220 | __le32 inc; |
| 221 | } __packed; |
| 222 | |
| 223 | struct ceph_blkin_trace_info { |
| 224 | __le64 trace_id; |
| 225 | __le64 span_id; |
| 226 | __le64 parent_span_id; |
| 227 | } __packed; |
| 228 | |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 229 | typedef void (*rados_watchcb2_t)(void *arg, u64 notify_id, u64 cookie, |
| 230 | u64 notifier_id, void *data, size_t data_len); |
| 231 | typedef void (*rados_watcherrcb_t)(void *arg, u64 cookie, int err); |
Yehuda Sadeh | a40c4f1 | 2011-03-21 15:07:16 -0700 | [diff] [blame] | 232 | |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 233 | struct ceph_osd_linger_request { |
| 234 | struct ceph_osd_client *osdc; |
| 235 | u64 linger_id; |
| 236 | bool committed; |
Ilya Dryomov | 1907920 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 237 | bool is_watch; /* watch or notify */ |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 238 | |
| 239 | struct ceph_osd *osd; |
| 240 | struct ceph_osd_request *reg_req; |
| 241 | struct ceph_osd_request *ping_req; |
| 242 | unsigned long ping_sent; |
Ilya Dryomov | b07d3c4 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 243 | unsigned long watch_valid_thru; |
| 244 | struct list_head pending_lworks; |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 245 | |
| 246 | struct ceph_osd_request_target t; |
Ilya Dryomov | 4609245 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 247 | u32 map_dne_bound; |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 248 | |
| 249 | struct timespec mtime; |
| 250 | |
| 251 | struct kref kref; |
| 252 | struct mutex lock; |
| 253 | struct rb_node node; /* osd */ |
| 254 | struct rb_node osdc_node; /* osdc */ |
Ilya Dryomov | 4609245 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 255 | struct rb_node mc_node; /* map check */ |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 256 | struct list_head scan_item; |
| 257 | |
| 258 | struct completion reg_commit_wait; |
Ilya Dryomov | 1907920 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 259 | struct completion notify_finish_wait; |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 260 | int reg_commit_error; |
Ilya Dryomov | 1907920 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 261 | int notify_finish_error; |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 262 | int last_error; |
| 263 | |
| 264 | u32 register_gen; |
Ilya Dryomov | 1907920 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 265 | u64 notify_id; |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 266 | |
| 267 | rados_watchcb2_t wcb; |
| 268 | rados_watcherrcb_t errcb; |
| 269 | void *data; |
Ilya Dryomov | 1907920 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 270 | |
| 271 | struct page ***preply_pages; |
| 272 | size_t *preply_len; |
Yehuda Sadeh | a40c4f1 | 2011-03-21 15:07:16 -0700 | [diff] [blame] | 273 | }; |
| 274 | |
Douglas Fuller | a4ed38d | 2015-07-17 13:18:07 -0700 | [diff] [blame] | 275 | struct ceph_watch_item { |
| 276 | struct ceph_entity_name name; |
| 277 | u64 cookie; |
| 278 | struct ceph_entity_addr addr; |
| 279 | }; |
| 280 | |
Ilya Dryomov | a02a946 | 2017-06-19 12:18:05 +0200 | [diff] [blame] | 281 | struct ceph_spg_mapping { |
| 282 | struct rb_node node; |
| 283 | struct ceph_spg spgid; |
| 284 | |
| 285 | struct rb_root backoffs; |
| 286 | }; |
| 287 | |
| 288 | struct ceph_hobject_id { |
| 289 | void *key; |
| 290 | size_t key_len; |
| 291 | void *oid; |
| 292 | size_t oid_len; |
| 293 | u64 snapid; |
| 294 | u32 hash; |
| 295 | u8 is_max; |
| 296 | void *nspace; |
| 297 | size_t nspace_len; |
| 298 | s64 pool; |
| 299 | |
| 300 | /* cache */ |
| 301 | u32 hash_reverse_bits; |
| 302 | }; |
| 303 | |
| 304 | static inline void ceph_hoid_build_hash_cache(struct ceph_hobject_id *hoid) |
| 305 | { |
| 306 | hoid->hash_reverse_bits = bitrev32(hoid->hash); |
| 307 | } |
| 308 | |
| 309 | /* |
| 310 | * PG-wide backoff: [begin, end) |
| 311 | * per-object backoff: begin == end |
| 312 | */ |
| 313 | struct ceph_osd_backoff { |
| 314 | struct rb_node spg_node; |
| 315 | struct rb_node id_node; |
| 316 | |
| 317 | struct ceph_spg spgid; |
| 318 | u64 id; |
| 319 | struct ceph_hobject_id *begin; |
| 320 | struct ceph_hobject_id *end; |
| 321 | }; |
| 322 | |
Ilya Dryomov | 264048a | 2016-11-08 15:15:24 +0100 | [diff] [blame] | 323 | #define CEPH_LINGER_ID_START 0xffff000000000000ULL |
| 324 | |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 325 | struct ceph_osd_client { |
| 326 | struct ceph_client *client; |
| 327 | |
| 328 | struct ceph_osdmap *osdmap; /* current map */ |
Ilya Dryomov | 5aea3dc | 2016-04-28 16:07:26 +0200 | [diff] [blame] | 329 | struct rw_semaphore lock; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 330 | |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 331 | struct rb_root osds; /* osds */ |
Yehuda Sadeh | f5a2041 | 2010-02-03 11:00:26 -0800 | [diff] [blame] | 332 | struct list_head osd_lru; /* idle osds */ |
Ilya Dryomov | 9dd2845 | 2016-04-28 16:07:26 +0200 | [diff] [blame] | 333 | spinlock_t osd_lru_lock; |
Jeff Layton | 58eb793 | 2017-04-18 09:21:16 -0400 | [diff] [blame] | 334 | u32 epoch_barrier; |
Ilya Dryomov | 5aea3dc | 2016-04-28 16:07:26 +0200 | [diff] [blame] | 335 | struct ceph_osd homeless_osd; |
| 336 | atomic64_t last_tid; /* tid of last request */ |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 337 | u64 last_linger_id; |
| 338 | struct rb_root linger_requests; /* lingering requests */ |
Ilya Dryomov | 4609245 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 339 | struct rb_root map_checks; |
| 340 | struct rb_root linger_map_checks; |
Ilya Dryomov | 5aea3dc | 2016-04-28 16:07:26 +0200 | [diff] [blame] | 341 | atomic_t num_requests; |
| 342 | atomic_t num_homeless; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 343 | struct delayed_work timeout_work; |
Yehuda Sadeh | f5a2041 | 2010-02-03 11:00:26 -0800 | [diff] [blame] | 344 | struct delayed_work osds_timeout_work; |
Sage Weil | 039934b | 2009-11-12 15:05:52 -0800 | [diff] [blame] | 345 | #ifdef CONFIG_DEBUG_FS |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 346 | struct dentry *debugfs_file; |
Sage Weil | 039934b | 2009-11-12 15:05:52 -0800 | [diff] [blame] | 347 | #endif |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 348 | |
| 349 | mempool_t *req_mempool; |
| 350 | |
Yehuda Sadeh | 0d59ab8 | 2010-01-13 17:03:23 -0800 | [diff] [blame] | 351 | struct ceph_msgpool msgpool_op; |
Sage Weil | c16e786 | 2010-03-01 13:02:00 -0800 | [diff] [blame] | 352 | struct ceph_msgpool msgpool_op_reply; |
Yehuda Sadeh | a40c4f1 | 2011-03-21 15:07:16 -0700 | [diff] [blame] | 353 | |
Yehuda Sadeh | a40c4f1 | 2011-03-21 15:07:16 -0700 | [diff] [blame] | 354 | struct workqueue_struct *notify_wq; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 355 | }; |
| 356 | |
Ilya Dryomov | b7ec35b | 2016-04-28 16:07:25 +0200 | [diff] [blame] | 357 | static inline bool ceph_osdmap_flag(struct ceph_osd_client *osdc, int flag) |
| 358 | { |
| 359 | return osdc->osdmap->flags & flag; |
| 360 | } |
| 361 | |
Alex Elder | 5522ae0 | 2013-05-01 12:43:04 -0500 | [diff] [blame] | 362 | extern int ceph_osdc_setup(void); |
| 363 | extern void ceph_osdc_cleanup(void); |
| 364 | |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 365 | extern int ceph_osdc_init(struct ceph_osd_client *osdc, |
| 366 | struct ceph_client *client); |
| 367 | extern void ceph_osdc_stop(struct ceph_osd_client *osdc); |
| 368 | |
| 369 | extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc, |
| 370 | struct ceph_msg *msg); |
| 371 | extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc, |
| 372 | struct ceph_msg *msg); |
Jeff Layton | 58eb793 | 2017-04-18 09:21:16 -0400 | [diff] [blame] | 373 | void ceph_osdc_update_epoch_barrier(struct ceph_osd_client *osdc, u32 eb); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 374 | |
Alex Elder | 4971977 | 2013-02-11 12:33:24 -0600 | [diff] [blame] | 375 | extern void osd_req_op_init(struct ceph_osd_request *osd_req, |
Yan, Zheng | 144cba1 | 2015-04-27 11:09:54 +0800 | [diff] [blame] | 376 | unsigned int which, u16 opcode, u32 flags); |
Alex Elder | 4971977 | 2013-02-11 12:33:24 -0600 | [diff] [blame] | 377 | |
| 378 | extern void osd_req_op_raw_data_in_pages(struct ceph_osd_request *, |
| 379 | unsigned int which, |
| 380 | struct page **pages, u64 length, |
| 381 | u32 alignment, bool pages_from_pool, |
| 382 | bool own_pages); |
| 383 | |
Alex Elder | c99d2d4 | 2013-04-05 01:27:11 -0500 | [diff] [blame] | 384 | extern void osd_req_op_extent_init(struct ceph_osd_request *osd_req, |
| 385 | unsigned int which, u16 opcode, |
Alex Elder | 33803f3 | 2013-03-13 20:50:00 -0500 | [diff] [blame] | 386 | u64 offset, u64 length, |
| 387 | u64 truncate_size, u32 truncate_seq); |
Alex Elder | c99d2d4 | 2013-04-05 01:27:11 -0500 | [diff] [blame] | 388 | extern void osd_req_op_extent_update(struct ceph_osd_request *osd_req, |
| 389 | unsigned int which, u64 length); |
Yan, Zheng | 2c63f49 | 2016-01-07 17:32:54 +0800 | [diff] [blame] | 390 | extern void osd_req_op_extent_dup_last(struct ceph_osd_request *osd_req, |
| 391 | unsigned int which, u64 offset_inc); |
Alex Elder | a4ce40a | 2013-04-05 01:27:12 -0500 | [diff] [blame] | 392 | |
| 393 | extern struct ceph_osd_data *osd_req_op_extent_osd_data( |
| 394 | struct ceph_osd_request *osd_req, |
Alex Elder | 406e2c9 | 2013-04-15 14:50:36 -0500 | [diff] [blame] | 395 | unsigned int which); |
Alex Elder | a4ce40a | 2013-04-05 01:27:12 -0500 | [diff] [blame] | 396 | |
| 397 | extern void osd_req_op_extent_osd_data_pages(struct ceph_osd_request *, |
Alex Elder | 406e2c9 | 2013-04-15 14:50:36 -0500 | [diff] [blame] | 398 | unsigned int which, |
Alex Elder | a4ce40a | 2013-04-05 01:27:12 -0500 | [diff] [blame] | 399 | struct page **pages, u64 length, |
| 400 | u32 alignment, bool pages_from_pool, |
| 401 | bool own_pages); |
| 402 | extern void osd_req_op_extent_osd_data_pagelist(struct ceph_osd_request *, |
Alex Elder | 406e2c9 | 2013-04-15 14:50:36 -0500 | [diff] [blame] | 403 | unsigned int which, |
Alex Elder | a4ce40a | 2013-04-05 01:27:12 -0500 | [diff] [blame] | 404 | struct ceph_pagelist *pagelist); |
| 405 | #ifdef CONFIG_BLOCK |
| 406 | extern void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *, |
Alex Elder | 406e2c9 | 2013-04-15 14:50:36 -0500 | [diff] [blame] | 407 | unsigned int which, |
Alex Elder | a4ce40a | 2013-04-05 01:27:12 -0500 | [diff] [blame] | 408 | struct bio *bio, size_t bio_length); |
| 409 | #endif /* CONFIG_BLOCK */ |
| 410 | |
Alex Elder | 04017e2 | 2013-04-05 14:46:02 -0500 | [diff] [blame] | 411 | extern void osd_req_op_cls_request_data_pagelist(struct ceph_osd_request *, |
| 412 | unsigned int which, |
| 413 | struct ceph_pagelist *pagelist); |
Alex Elder | 6c57b55 | 2013-04-19 15:34:49 -0500 | [diff] [blame] | 414 | extern void osd_req_op_cls_request_data_pages(struct ceph_osd_request *, |
| 415 | unsigned int which, |
| 416 | struct page **pages, u64 length, |
| 417 | u32 alignment, bool pages_from_pool, |
| 418 | bool own_pages); |
Alex Elder | a4ce40a | 2013-04-05 01:27:12 -0500 | [diff] [blame] | 419 | extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *, |
Alex Elder | c99d2d4 | 2013-04-05 01:27:11 -0500 | [diff] [blame] | 420 | unsigned int which, |
Alex Elder | a4ce40a | 2013-04-05 01:27:12 -0500 | [diff] [blame] | 421 | struct page **pages, u64 length, |
| 422 | u32 alignment, bool pages_from_pool, |
| 423 | bool own_pages); |
Alex Elder | c99d2d4 | 2013-04-05 01:27:11 -0500 | [diff] [blame] | 424 | extern void osd_req_op_cls_init(struct ceph_osd_request *osd_req, |
| 425 | unsigned int which, u16 opcode, |
Alex Elder | 04017e2 | 2013-04-05 14:46:02 -0500 | [diff] [blame] | 426 | const char *class, const char *method); |
Yan, Zheng | d74b50b | 2014-11-12 14:00:43 +0800 | [diff] [blame] | 427 | extern int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int which, |
| 428 | u16 opcode, const char *name, const void *value, |
| 429 | size_t size, u8 cmp_op, u8 cmp_mode); |
Ilya Dryomov | c647b8a | 2014-02-25 16:22:27 +0200 | [diff] [blame] | 430 | extern void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req, |
| 431 | unsigned int which, |
| 432 | u64 expected_object_size, |
| 433 | u64 expected_write_size); |
Alex Elder | 33803f3 | 2013-03-13 20:50:00 -0500 | [diff] [blame] | 434 | |
Yehuda Sadeh | 3499e8a | 2010-04-06 14:51:47 -0700 | [diff] [blame] | 435 | extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, |
Yehuda Sadeh | 3499e8a | 2010-04-06 14:51:47 -0700 | [diff] [blame] | 436 | struct ceph_snap_context *snapc, |
Alex Elder | acead00 | 2013-03-14 14:09:05 -0500 | [diff] [blame] | 437 | unsigned int num_ops, |
Yehuda Sadeh | 3499e8a | 2010-04-06 14:51:47 -0700 | [diff] [blame] | 438 | bool use_mempool, |
Alex Elder | 54a5400 | 2012-11-13 21:11:15 -0600 | [diff] [blame] | 439 | gfp_t gfp_flags); |
Ilya Dryomov | 13d1ad1 | 2016-04-27 14:15:51 +0200 | [diff] [blame] | 440 | int ceph_osdc_alloc_messages(struct ceph_osd_request *req, gfp_t gfp); |
Yehuda Sadeh | 3499e8a | 2010-04-06 14:51:47 -0700 | [diff] [blame] | 441 | |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 442 | extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *, |
| 443 | struct ceph_file_layout *layout, |
| 444 | struct ceph_vino vino, |
Alex Elder | acead00 | 2013-03-14 14:09:05 -0500 | [diff] [blame] | 445 | u64 offset, u64 *len, |
Yan, Zheng | 715e4cd | 2014-11-13 14:40:37 +0800 | [diff] [blame] | 446 | unsigned int which, int num_ops, |
| 447 | int opcode, int flags, |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 448 | struct ceph_snap_context *snapc, |
Alex Elder | acead00 | 2013-03-14 14:09:05 -0500 | [diff] [blame] | 449 | u32 truncate_seq, u64 truncate_size, |
Alex Elder | 153e516 | 2013-03-01 18:00:15 -0600 | [diff] [blame] | 450 | bool use_mempool); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 451 | |
Ilya Dryomov | 9e94af2 | 2014-06-20 14:14:42 +0400 | [diff] [blame] | 452 | extern void ceph_osdc_get_request(struct ceph_osd_request *req); |
| 453 | extern void ceph_osdc_put_request(struct ceph_osd_request *req); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 454 | |
| 455 | extern int ceph_osdc_start_request(struct ceph_osd_client *osdc, |
| 456 | struct ceph_osd_request *req, |
| 457 | bool nofail); |
Ilya Dryomov | c9f9b93 | 2014-06-19 11:38:13 +0400 | [diff] [blame] | 458 | extern void ceph_osdc_cancel_request(struct ceph_osd_request *req); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 459 | extern int ceph_osdc_wait_request(struct ceph_osd_client *osdc, |
| 460 | struct ceph_osd_request *req); |
| 461 | extern void ceph_osdc_sync(struct ceph_osd_client *osdc); |
| 462 | |
Josh Durgin | dd935f4 | 2013-08-28 21:43:09 -0700 | [diff] [blame] | 463 | extern void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc); |
Ilya Dryomov | 7cca78c | 2016-04-28 16:07:28 +0200 | [diff] [blame] | 464 | void ceph_osdc_maybe_request_map(struct ceph_osd_client *osdc); |
Josh Durgin | dd935f4 | 2013-08-28 21:43:09 -0700 | [diff] [blame] | 465 | |
Douglas Fuller | 428a715 | 2015-06-17 14:49:45 -0400 | [diff] [blame] | 466 | int ceph_osdc_call(struct ceph_osd_client *osdc, |
| 467 | struct ceph_object_id *oid, |
| 468 | struct ceph_object_locator *oloc, |
| 469 | const char *class, const char *method, |
| 470 | unsigned int flags, |
| 471 | struct page *req_page, size_t req_len, |
| 472 | struct page *resp_page, size_t *resp_len); |
| 473 | |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 474 | extern int ceph_osdc_readpages(struct ceph_osd_client *osdc, |
| 475 | struct ceph_vino vino, |
| 476 | struct ceph_file_layout *layout, |
| 477 | u64 off, u64 *plen, |
| 478 | u32 truncate_seq, u64 truncate_size, |
Sage Weil | b7495fc | 2010-11-09 12:43:12 -0800 | [diff] [blame] | 479 | struct page **pages, int nr_pages, |
| 480 | int page_align); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 481 | |
| 482 | extern int ceph_osdc_writepages(struct ceph_osd_client *osdc, |
| 483 | struct ceph_vino vino, |
| 484 | struct ceph_file_layout *layout, |
| 485 | struct ceph_snap_context *sc, |
| 486 | u64 off, u64 len, |
| 487 | u32 truncate_seq, u64 truncate_size, |
| 488 | struct timespec *mtime, |
Alex Elder | 2480882 | 2013-02-15 11:42:29 -0600 | [diff] [blame] | 489 | struct page **pages, int nr_pages); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 490 | |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 491 | /* watch/notify */ |
| 492 | struct ceph_osd_linger_request * |
| 493 | ceph_osdc_watch(struct ceph_osd_client *osdc, |
| 494 | struct ceph_object_id *oid, |
| 495 | struct ceph_object_locator *oloc, |
| 496 | rados_watchcb2_t wcb, |
| 497 | rados_watcherrcb_t errcb, |
| 498 | void *data); |
| 499 | int ceph_osdc_unwatch(struct ceph_osd_client *osdc, |
| 500 | struct ceph_osd_linger_request *lreq); |
| 501 | |
| 502 | int ceph_osdc_notify_ack(struct ceph_osd_client *osdc, |
| 503 | struct ceph_object_id *oid, |
| 504 | struct ceph_object_locator *oloc, |
| 505 | u64 notify_id, |
| 506 | u64 cookie, |
| 507 | void *payload, |
| 508 | size_t payload_len); |
Ilya Dryomov | 1907920 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 509 | int ceph_osdc_notify(struct ceph_osd_client *osdc, |
| 510 | struct ceph_object_id *oid, |
| 511 | struct ceph_object_locator *oloc, |
| 512 | void *payload, |
| 513 | size_t payload_len, |
| 514 | u32 timeout, |
| 515 | struct page ***preply_pages, |
| 516 | size_t *preply_len); |
Ilya Dryomov | b07d3c4 | 2016-04-28 16:07:27 +0200 | [diff] [blame] | 517 | int ceph_osdc_watch_check(struct ceph_osd_client *osdc, |
| 518 | struct ceph_osd_linger_request *lreq); |
Douglas Fuller | a4ed38d | 2015-07-17 13:18:07 -0700 | [diff] [blame] | 519 | int ceph_osdc_list_watchers(struct ceph_osd_client *osdc, |
| 520 | struct ceph_object_id *oid, |
| 521 | struct ceph_object_locator *oloc, |
| 522 | struct ceph_watch_item **watchers, |
| 523 | u32 *num_watchers); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 524 | #endif |
| 525 | |