1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 23d14c5d2SYehuda Sadeh #ifndef _FS_CEPH_OSD_CLIENT_H 33d14c5d2SYehuda Sadeh #define _FS_CEPH_OSD_CLIENT_H 43d14c5d2SYehuda Sadeh 5a02a946dSIlya Dryomov #include <linux/bitrev.h> 63d14c5d2SYehuda Sadeh #include <linux/completion.h> 73d14c5d2SYehuda Sadeh #include <linux/kref.h> 83d14c5d2SYehuda Sadeh #include <linux/mempool.h> 93d14c5d2SYehuda Sadeh #include <linux/rbtree.h> 1002113a0fSElena Reshetova #include <linux/refcount.h> 113d14c5d2SYehuda Sadeh 126c4a1915SAlex Elder #include <linux/ceph/types.h> 136c4a1915SAlex Elder #include <linux/ceph/osdmap.h> 146c4a1915SAlex Elder #include <linux/ceph/messenger.h> 15b2aa5d0bSIlya Dryomov #include <linux/ceph/msgpool.h> 166c4a1915SAlex Elder #include <linux/ceph/auth.h> 17c885837fSAlex Elder #include <linux/ceph/pagelist.h> 183d14c5d2SYehuda Sadeh 193d14c5d2SYehuda Sadeh struct ceph_msg; 203d14c5d2SYehuda Sadeh struct ceph_snap_context; 213d14c5d2SYehuda Sadeh struct ceph_osd_request; 223d14c5d2SYehuda Sadeh struct ceph_osd_client; 233d14c5d2SYehuda Sadeh 243d14c5d2SYehuda Sadeh /* 253d14c5d2SYehuda Sadeh * completion callback for async writepages 263d14c5d2SYehuda Sadeh */ 2785e084feSIlya Dryomov typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *); 283d14c5d2SYehuda Sadeh 2963244fa1SIlya Dryomov #define CEPH_HOMELESS_OSD -1 3063244fa1SIlya Dryomov 313d14c5d2SYehuda Sadeh /* a given osd we're communicating with */ 323d14c5d2SYehuda Sadeh struct ceph_osd { 3302113a0fSElena Reshetova refcount_t o_ref; 343d14c5d2SYehuda Sadeh struct ceph_osd_client *o_osdc; 353d14c5d2SYehuda Sadeh int o_osd; 363d14c5d2SYehuda Sadeh int o_incarnation; 373d14c5d2SYehuda Sadeh struct rb_node o_node; 383d14c5d2SYehuda Sadeh struct ceph_connection o_con; 395aea3dcdSIlya Dryomov struct rb_root o_requests; 40922dab61SIlya Dryomov struct rb_root o_linger_requests; 41a02a946dSIlya Dryomov struct rb_root o_backoff_mappings; 42a02a946dSIlya Dryomov struct rb_root o_backoffs_by_id; 433d14c5d2SYehuda Sadeh struct list_head o_osd_lru; 446c4a1915SAlex Elder struct ceph_auth_handshake o_auth; 453d14c5d2SYehuda Sadeh unsigned long lru_ttl; 463d14c5d2SYehuda Sadeh struct list_head o_keepalive_item; 475aea3dcdSIlya Dryomov struct mutex lock; 483d14c5d2SYehuda Sadeh }; 493d14c5d2SYehuda Sadeh 503f1af42aSIlya Dryomov #define CEPH_OSD_SLAB_OPS 2 513f1af42aSIlya Dryomov #define CEPH_OSD_MAX_OPS 16 521b83bef2SSage Weil 532ac2b7a6SAlex Elder enum ceph_osd_data_type { 54ec9123c5SAlex Elder CEPH_OSD_DATA_TYPE_NONE = 0, 552ac2b7a6SAlex Elder CEPH_OSD_DATA_TYPE_PAGES, 569a5e6d09SAlex Elder CEPH_OSD_DATA_TYPE_PAGELIST, 572ac2b7a6SAlex Elder #ifdef CONFIG_BLOCK 582ac2b7a6SAlex Elder CEPH_OSD_DATA_TYPE_BIO, 592ac2b7a6SAlex Elder #endif /* CONFIG_BLOCK */ 60b9e281c2SIlya Dryomov CEPH_OSD_DATA_TYPE_BVECS, 612ac2b7a6SAlex Elder }; 622ac2b7a6SAlex Elder 632794a82aSAlex Elder struct ceph_osd_data { 642ac2b7a6SAlex Elder enum ceph_osd_data_type type; 652ac2b7a6SAlex Elder union { 662794a82aSAlex Elder struct { 672794a82aSAlex Elder struct page **pages; 68e0c59487SAlex Elder u64 length; 692794a82aSAlex Elder u32 alignment; 702794a82aSAlex Elder bool pages_from_pool; 712794a82aSAlex Elder bool own_pages; 722794a82aSAlex Elder }; 739a5e6d09SAlex Elder struct ceph_pagelist *pagelist; 742794a82aSAlex Elder #ifdef CONFIG_BLOCK 75fdce58ccSAlex Elder struct { 765359a17dSIlya Dryomov struct ceph_bio_iter bio_pos; 775359a17dSIlya Dryomov u32 bio_length; 78fdce58ccSAlex Elder }; 792794a82aSAlex Elder #endif /* CONFIG_BLOCK */ 800010f705SIlya Dryomov struct { 81b9e281c2SIlya Dryomov struct ceph_bvec_iter bvec_pos; 820010f705SIlya Dryomov u32 num_bvecs; 830010f705SIlya Dryomov }; 842794a82aSAlex Elder }; 852794a82aSAlex Elder }; 862794a82aSAlex Elder 8779528734SAlex Elder struct ceph_osd_req_op { 8879528734SAlex Elder u16 op; /* CEPH_OSD_OP_* */ 897b25bf5fSIlya Dryomov u32 flags; /* CEPH_OSD_OP_FLAG_* */ 90de2aa102SIlya Dryomov u32 indata_len; /* request */ 917665d85bSYan, Zheng u32 outdata_len; /* reply */ 927665d85bSYan, Zheng s32 rval; 937665d85bSYan, Zheng 9479528734SAlex Elder union { 9549719778SAlex Elder struct ceph_osd_data raw_data_in; 9679528734SAlex Elder struct { 9779528734SAlex Elder u64 offset, length; 9879528734SAlex Elder u64 truncate_size; 9979528734SAlex Elder u32 truncate_seq; 1005476492fSAlex Elder struct ceph_osd_data osd_data; 10179528734SAlex Elder } extent; 10279528734SAlex Elder struct { 103d7d5a007SIlya Dryomov u32 name_len; 104d7d5a007SIlya Dryomov u32 value_len; 105d74b50beSYan, Zheng __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */ 106d74b50beSYan, Zheng __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */ 107d74b50beSYan, Zheng struct ceph_osd_data osd_data; 108d74b50beSYan, Zheng } xattr; 109d74b50beSYan, Zheng struct { 11079528734SAlex Elder const char *class_name; 11179528734SAlex Elder const char *method_name; 1125476492fSAlex Elder struct ceph_osd_data request_info; 11304017e29SAlex Elder struct ceph_osd_data request_data; 1145476492fSAlex Elder struct ceph_osd_data response_data; 11579528734SAlex Elder __u8 class_len; 11679528734SAlex Elder __u8 method_len; 117bb873b53SIlya Dryomov u32 indata_len; 11879528734SAlex Elder } cls; 11979528734SAlex Elder struct { 12079528734SAlex Elder u64 cookie; 121922dab61SIlya Dryomov __u8 op; /* CEPH_OSD_WATCH_OP_ */ 122922dab61SIlya Dryomov u32 gen; 12379528734SAlex Elder } watch; 124c647b8a8SIlya Dryomov struct { 125922dab61SIlya Dryomov struct ceph_osd_data request_data; 126922dab61SIlya Dryomov } notify_ack; 127922dab61SIlya Dryomov struct { 12819079203SIlya Dryomov u64 cookie; 12919079203SIlya Dryomov struct ceph_osd_data request_data; 13019079203SIlya Dryomov struct ceph_osd_data response_data; 13119079203SIlya Dryomov } notify; 13219079203SIlya Dryomov struct { 133a4ed38d7SDouglas Fuller struct ceph_osd_data response_data; 134a4ed38d7SDouglas Fuller } list_watchers; 135a4ed38d7SDouglas Fuller struct { 136c647b8a8SIlya Dryomov u64 expected_object_size; 137c647b8a8SIlya Dryomov u64 expected_write_size; 138c647b8a8SIlya Dryomov } alloc_hint; 13923ddf9beSLuis Henriques struct { 14023ddf9beSLuis Henriques u64 snapid; 14123ddf9beSLuis Henriques u64 src_version; 14223ddf9beSLuis Henriques u8 flags; 14323ddf9beSLuis Henriques u32 src_fadvise_flags; 14423ddf9beSLuis Henriques struct ceph_osd_data osd_data; 14523ddf9beSLuis Henriques } copy_from; 14679528734SAlex Elder }; 14779528734SAlex Elder }; 14879528734SAlex Elder 14963244fa1SIlya Dryomov struct ceph_osd_request_target { 15063244fa1SIlya Dryomov struct ceph_object_id base_oid; 15163244fa1SIlya Dryomov struct ceph_object_locator base_oloc; 15263244fa1SIlya Dryomov struct ceph_object_id target_oid; 15363244fa1SIlya Dryomov struct ceph_object_locator target_oloc; 15463244fa1SIlya Dryomov 155dc98ff72SIlya Dryomov struct ceph_pg pgid; /* last raw pg we mapped to */ 156dc98ff72SIlya Dryomov struct ceph_spg spgid; /* last actual spg we mapped to */ 15763244fa1SIlya Dryomov u32 pg_num; 15863244fa1SIlya Dryomov u32 pg_num_mask; 15963244fa1SIlya Dryomov struct ceph_osds acting; 16063244fa1SIlya Dryomov struct ceph_osds up; 16163244fa1SIlya Dryomov int size; 16263244fa1SIlya Dryomov int min_size; 16363244fa1SIlya Dryomov bool sort_bitwise; 164ae78dd81SIlya Dryomov bool recovery_deletes; 16563244fa1SIlya Dryomov 16663244fa1SIlya Dryomov unsigned int flags; /* CEPH_OSD_FLAG_* */ 16763244fa1SIlya Dryomov bool paused; 16863244fa1SIlya Dryomov 16904c7d789SIlya Dryomov u32 epoch; 170dc93e0e2SIlya Dryomov u32 last_force_resend; 171dc93e0e2SIlya Dryomov 17263244fa1SIlya Dryomov int osd; 17363244fa1SIlya Dryomov }; 17463244fa1SIlya Dryomov 1753d14c5d2SYehuda Sadeh /* an in-flight request */ 1763d14c5d2SYehuda Sadeh struct ceph_osd_request { 1773d14c5d2SYehuda Sadeh u64 r_tid; /* unique for this client */ 1783d14c5d2SYehuda Sadeh struct rb_node r_node; 1794609245eSIlya Dryomov struct rb_node r_mc_node; /* map check */ 18088bc1922SIlya Dryomov struct work_struct r_complete_work; 1813d14c5d2SYehuda Sadeh struct ceph_osd *r_osd; 182a66dd383SIlya Dryomov 183a66dd383SIlya Dryomov struct ceph_osd_request_target r_t; 184a66dd383SIlya Dryomov #define r_base_oid r_t.base_oid 185a66dd383SIlya Dryomov #define r_base_oloc r_t.base_oloc 186a66dd383SIlya Dryomov #define r_flags r_t.flags 1873d14c5d2SYehuda Sadeh 1883d14c5d2SYehuda Sadeh struct ceph_msg *r_request, *r_reply; 1893d14c5d2SYehuda Sadeh u32 r_sent; /* >0 if r_request is sending/sent */ 1901b83bef2SSage Weil 19179528734SAlex Elder /* request osd ops array */ 19279528734SAlex Elder unsigned int r_num_ops; 19379528734SAlex Elder 1941b83bef2SSage Weil int r_result; 1953d14c5d2SYehuda Sadeh 1963d14c5d2SYehuda Sadeh struct ceph_osd_client *r_osdc; 1973d14c5d2SYehuda Sadeh struct kref r_kref; 1983d14c5d2SYehuda Sadeh bool r_mempool; 199b18b9550SIlya Dryomov struct completion r_completion; /* private to osd_client.c */ 20026be8808SAlex Elder ceph_osdc_callback_t r_callback; 2013d14c5d2SYehuda Sadeh 2023d14c5d2SYehuda Sadeh struct inode *r_inode; /* for use by callbacks */ 20394e85771SIlya Dryomov struct list_head r_private_item; /* ditto */ 2043d14c5d2SYehuda Sadeh void *r_priv; /* ditto */ 2053d14c5d2SYehuda Sadeh 206bb873b53SIlya Dryomov /* set by submitter */ 207bb873b53SIlya Dryomov u64 r_snapid; /* for reads, CEPH_NOSNAP o/w */ 208bb873b53SIlya Dryomov struct ceph_snap_context *r_snapc; /* for writes */ 209fac02ddfSArnd Bergmann struct timespec64 r_mtime; /* ditto */ 210bb873b53SIlya Dryomov u64 r_data_offset; /* ditto */ 211922dab61SIlya Dryomov bool r_linger; /* don't resend on failure */ 2123d14c5d2SYehuda Sadeh 213bb873b53SIlya Dryomov /* internal */ 214bb873b53SIlya Dryomov unsigned long r_stamp; /* jiffies, send or check time */ 2157cc5e38fSIlya Dryomov unsigned long r_start_stamp; /* jiffies */ 216bb873b53SIlya Dryomov int r_attempts; 2174609245eSIlya Dryomov u32 r_map_dne_bound; 2183f1af42aSIlya Dryomov 2193f1af42aSIlya Dryomov struct ceph_osd_req_op r_ops[]; 2203d14c5d2SYehuda Sadeh }; 2213d14c5d2SYehuda Sadeh 222205ee118SIlya Dryomov struct ceph_request_redirect { 223205ee118SIlya Dryomov struct ceph_object_locator oloc; 224205ee118SIlya Dryomov }; 225205ee118SIlya Dryomov 2268cb441c0SIlya Dryomov /* 2278cb441c0SIlya Dryomov * osd request identifier 2288cb441c0SIlya Dryomov * 2298cb441c0SIlya Dryomov * caller name + incarnation# + tid to unique identify this request 2308cb441c0SIlya Dryomov */ 2318cb441c0SIlya Dryomov struct ceph_osd_reqid { 2328cb441c0SIlya Dryomov struct ceph_entity_name name; 2338cb441c0SIlya Dryomov __le64 tid; 2348cb441c0SIlya Dryomov __le32 inc; 2358cb441c0SIlya Dryomov } __packed; 2368cb441c0SIlya Dryomov 2378cb441c0SIlya Dryomov struct ceph_blkin_trace_info { 2388cb441c0SIlya Dryomov __le64 trace_id; 2398cb441c0SIlya Dryomov __le64 span_id; 2408cb441c0SIlya Dryomov __le64 parent_span_id; 2418cb441c0SIlya Dryomov } __packed; 2428cb441c0SIlya Dryomov 243922dab61SIlya Dryomov typedef void (*rados_watchcb2_t)(void *arg, u64 notify_id, u64 cookie, 244922dab61SIlya Dryomov u64 notifier_id, void *data, size_t data_len); 245922dab61SIlya Dryomov typedef void (*rados_watcherrcb_t)(void *arg, u64 cookie, int err); 246a40c4f10SYehuda Sadeh 247922dab61SIlya Dryomov struct ceph_osd_linger_request { 248922dab61SIlya Dryomov struct ceph_osd_client *osdc; 249922dab61SIlya Dryomov u64 linger_id; 250922dab61SIlya Dryomov bool committed; 25119079203SIlya Dryomov bool is_watch; /* watch or notify */ 252922dab61SIlya Dryomov 253922dab61SIlya Dryomov struct ceph_osd *osd; 254922dab61SIlya Dryomov struct ceph_osd_request *reg_req; 255922dab61SIlya Dryomov struct ceph_osd_request *ping_req; 256922dab61SIlya Dryomov unsigned long ping_sent; 257b07d3c4bSIlya Dryomov unsigned long watch_valid_thru; 258b07d3c4bSIlya Dryomov struct list_head pending_lworks; 259922dab61SIlya Dryomov 260922dab61SIlya Dryomov struct ceph_osd_request_target t; 2614609245eSIlya Dryomov u32 map_dne_bound; 262922dab61SIlya Dryomov 263fac02ddfSArnd Bergmann struct timespec64 mtime; 264922dab61SIlya Dryomov 265922dab61SIlya Dryomov struct kref kref; 266922dab61SIlya Dryomov struct mutex lock; 267922dab61SIlya Dryomov struct rb_node node; /* osd */ 268922dab61SIlya Dryomov struct rb_node osdc_node; /* osdc */ 2694609245eSIlya Dryomov struct rb_node mc_node; /* map check */ 270922dab61SIlya Dryomov struct list_head scan_item; 271922dab61SIlya Dryomov 272922dab61SIlya Dryomov struct completion reg_commit_wait; 27319079203SIlya Dryomov struct completion notify_finish_wait; 274922dab61SIlya Dryomov int reg_commit_error; 27519079203SIlya Dryomov int notify_finish_error; 276922dab61SIlya Dryomov int last_error; 277922dab61SIlya Dryomov 278922dab61SIlya Dryomov u32 register_gen; 27919079203SIlya Dryomov u64 notify_id; 280922dab61SIlya Dryomov 281922dab61SIlya Dryomov rados_watchcb2_t wcb; 282922dab61SIlya Dryomov rados_watcherrcb_t errcb; 283922dab61SIlya Dryomov void *data; 28419079203SIlya Dryomov 28519079203SIlya Dryomov struct page ***preply_pages; 28619079203SIlya Dryomov size_t *preply_len; 287a40c4f10SYehuda Sadeh }; 288a40c4f10SYehuda Sadeh 289a4ed38d7SDouglas Fuller struct ceph_watch_item { 290a4ed38d7SDouglas Fuller struct ceph_entity_name name; 291a4ed38d7SDouglas Fuller u64 cookie; 292a4ed38d7SDouglas Fuller struct ceph_entity_addr addr; 293a4ed38d7SDouglas Fuller }; 294a4ed38d7SDouglas Fuller 295a02a946dSIlya Dryomov struct ceph_spg_mapping { 296a02a946dSIlya Dryomov struct rb_node node; 297a02a946dSIlya Dryomov struct ceph_spg spgid; 298a02a946dSIlya Dryomov 299a02a946dSIlya Dryomov struct rb_root backoffs; 300a02a946dSIlya Dryomov }; 301a02a946dSIlya Dryomov 302a02a946dSIlya Dryomov struct ceph_hobject_id { 303a02a946dSIlya Dryomov void *key; 304a02a946dSIlya Dryomov size_t key_len; 305a02a946dSIlya Dryomov void *oid; 306a02a946dSIlya Dryomov size_t oid_len; 307a02a946dSIlya Dryomov u64 snapid; 308a02a946dSIlya Dryomov u32 hash; 309a02a946dSIlya Dryomov u8 is_max; 310a02a946dSIlya Dryomov void *nspace; 311a02a946dSIlya Dryomov size_t nspace_len; 312a02a946dSIlya Dryomov s64 pool; 313a02a946dSIlya Dryomov 314a02a946dSIlya Dryomov /* cache */ 315a02a946dSIlya Dryomov u32 hash_reverse_bits; 316a02a946dSIlya Dryomov }; 317a02a946dSIlya Dryomov 318a02a946dSIlya Dryomov static inline void ceph_hoid_build_hash_cache(struct ceph_hobject_id *hoid) 319a02a946dSIlya Dryomov { 320a02a946dSIlya Dryomov hoid->hash_reverse_bits = bitrev32(hoid->hash); 321a02a946dSIlya Dryomov } 322a02a946dSIlya Dryomov 323a02a946dSIlya Dryomov /* 324a02a946dSIlya Dryomov * PG-wide backoff: [begin, end) 325a02a946dSIlya Dryomov * per-object backoff: begin == end 326a02a946dSIlya Dryomov */ 327a02a946dSIlya Dryomov struct ceph_osd_backoff { 328a02a946dSIlya Dryomov struct rb_node spg_node; 329a02a946dSIlya Dryomov struct rb_node id_node; 330a02a946dSIlya Dryomov 331a02a946dSIlya Dryomov struct ceph_spg spgid; 332a02a946dSIlya Dryomov u64 id; 333a02a946dSIlya Dryomov struct ceph_hobject_id *begin; 334a02a946dSIlya Dryomov struct ceph_hobject_id *end; 335a02a946dSIlya Dryomov }; 336a02a946dSIlya Dryomov 337264048afSIlya Dryomov #define CEPH_LINGER_ID_START 0xffff000000000000ULL 338264048afSIlya Dryomov 3393d14c5d2SYehuda Sadeh struct ceph_osd_client { 3403d14c5d2SYehuda Sadeh struct ceph_client *client; 3413d14c5d2SYehuda Sadeh 3423d14c5d2SYehuda Sadeh struct ceph_osdmap *osdmap; /* current map */ 3435aea3dcdSIlya Dryomov struct rw_semaphore lock; 3443d14c5d2SYehuda Sadeh 3453d14c5d2SYehuda Sadeh struct rb_root osds; /* osds */ 3463d14c5d2SYehuda Sadeh struct list_head osd_lru; /* idle osds */ 3479dd2845cSIlya Dryomov spinlock_t osd_lru_lock; 34858eb7932SJeff Layton u32 epoch_barrier; 3495aea3dcdSIlya Dryomov struct ceph_osd homeless_osd; 3505aea3dcdSIlya Dryomov atomic64_t last_tid; /* tid of last request */ 351922dab61SIlya Dryomov u64 last_linger_id; 352922dab61SIlya Dryomov struct rb_root linger_requests; /* lingering requests */ 3534609245eSIlya Dryomov struct rb_root map_checks; 3544609245eSIlya Dryomov struct rb_root linger_map_checks; 3555aea3dcdSIlya Dryomov atomic_t num_requests; 3565aea3dcdSIlya Dryomov atomic_t num_homeless; 35766850df5SIlya Dryomov int abort_err; 3583d14c5d2SYehuda Sadeh struct delayed_work timeout_work; 3593d14c5d2SYehuda Sadeh struct delayed_work osds_timeout_work; 3603d14c5d2SYehuda Sadeh #ifdef CONFIG_DEBUG_FS 3613d14c5d2SYehuda Sadeh struct dentry *debugfs_file; 3623d14c5d2SYehuda Sadeh #endif 3633d14c5d2SYehuda Sadeh 3643d14c5d2SYehuda Sadeh mempool_t *req_mempool; 3653d14c5d2SYehuda Sadeh 3663d14c5d2SYehuda Sadeh struct ceph_msgpool msgpool_op; 3673d14c5d2SYehuda Sadeh struct ceph_msgpool msgpool_op_reply; 368a40c4f10SYehuda Sadeh 369a40c4f10SYehuda Sadeh struct workqueue_struct *notify_wq; 37088bc1922SIlya Dryomov struct workqueue_struct *completion_wq; 3713d14c5d2SYehuda Sadeh }; 3723d14c5d2SYehuda Sadeh 373b7ec35b3SIlya Dryomov static inline bool ceph_osdmap_flag(struct ceph_osd_client *osdc, int flag) 374b7ec35b3SIlya Dryomov { 375b7ec35b3SIlya Dryomov return osdc->osdmap->flags & flag; 376b7ec35b3SIlya Dryomov } 377b7ec35b3SIlya Dryomov 3785522ae0bSAlex Elder extern int ceph_osdc_setup(void); 3795522ae0bSAlex Elder extern void ceph_osdc_cleanup(void); 3805522ae0bSAlex Elder 3813d14c5d2SYehuda Sadeh extern int ceph_osdc_init(struct ceph_osd_client *osdc, 3823d14c5d2SYehuda Sadeh struct ceph_client *client); 3833d14c5d2SYehuda Sadeh extern void ceph_osdc_stop(struct ceph_osd_client *osdc); 3843d14c5d2SYehuda Sadeh 3853d14c5d2SYehuda Sadeh extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc, 3863d14c5d2SYehuda Sadeh struct ceph_msg *msg); 3873d14c5d2SYehuda Sadeh extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc, 3883d14c5d2SYehuda Sadeh struct ceph_msg *msg); 38958eb7932SJeff Layton void ceph_osdc_update_epoch_barrier(struct ceph_osd_client *osdc, u32 eb); 39066850df5SIlya Dryomov void ceph_osdc_abort_requests(struct ceph_osd_client *osdc, int err); 3913d14c5d2SYehuda Sadeh 3924cf3e6dfSIlya Dryomov #define osd_req_op_data(oreq, whch, typ, fld) \ 3934cf3e6dfSIlya Dryomov ({ \ 3944cf3e6dfSIlya Dryomov struct ceph_osd_request *__oreq = (oreq); \ 3954cf3e6dfSIlya Dryomov unsigned int __whch = (whch); \ 3964cf3e6dfSIlya Dryomov BUG_ON(__whch >= __oreq->r_num_ops); \ 3974cf3e6dfSIlya Dryomov &__oreq->r_ops[__whch].typ.fld; \ 3984cf3e6dfSIlya Dryomov }) 3994cf3e6dfSIlya Dryomov 40049719778SAlex Elder extern void osd_req_op_init(struct ceph_osd_request *osd_req, 401144cba14SYan, Zheng unsigned int which, u16 opcode, u32 flags); 40249719778SAlex Elder 40349719778SAlex Elder extern void osd_req_op_raw_data_in_pages(struct ceph_osd_request *, 40449719778SAlex Elder unsigned int which, 40549719778SAlex Elder struct page **pages, u64 length, 40649719778SAlex Elder u32 alignment, bool pages_from_pool, 40749719778SAlex Elder bool own_pages); 40849719778SAlex Elder 409c99d2d4aSAlex Elder extern void osd_req_op_extent_init(struct ceph_osd_request *osd_req, 410c99d2d4aSAlex Elder unsigned int which, u16 opcode, 41133803f33SAlex Elder u64 offset, u64 length, 41233803f33SAlex Elder u64 truncate_size, u32 truncate_seq); 413c99d2d4aSAlex Elder extern void osd_req_op_extent_update(struct ceph_osd_request *osd_req, 414c99d2d4aSAlex Elder unsigned int which, u64 length); 4152c63f49aSYan, Zheng extern void osd_req_op_extent_dup_last(struct ceph_osd_request *osd_req, 4162c63f49aSYan, Zheng unsigned int which, u64 offset_inc); 417a4ce40a9SAlex Elder 418a4ce40a9SAlex Elder extern struct ceph_osd_data *osd_req_op_extent_osd_data( 419a4ce40a9SAlex Elder struct ceph_osd_request *osd_req, 420406e2c9fSAlex Elder unsigned int which); 421a4ce40a9SAlex Elder 422a4ce40a9SAlex Elder extern void osd_req_op_extent_osd_data_pages(struct ceph_osd_request *, 423406e2c9fSAlex Elder unsigned int which, 424a4ce40a9SAlex Elder struct page **pages, u64 length, 425a4ce40a9SAlex Elder u32 alignment, bool pages_from_pool, 426a4ce40a9SAlex Elder bool own_pages); 427a4ce40a9SAlex Elder extern void osd_req_op_extent_osd_data_pagelist(struct ceph_osd_request *, 428406e2c9fSAlex Elder unsigned int which, 429a4ce40a9SAlex Elder struct ceph_pagelist *pagelist); 430a4ce40a9SAlex Elder #ifdef CONFIG_BLOCK 4315359a17dSIlya Dryomov void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *osd_req, 432406e2c9fSAlex Elder unsigned int which, 4335359a17dSIlya Dryomov struct ceph_bio_iter *bio_pos, 4345359a17dSIlya Dryomov u32 bio_length); 435a4ce40a9SAlex Elder #endif /* CONFIG_BLOCK */ 4360010f705SIlya Dryomov void osd_req_op_extent_osd_data_bvecs(struct ceph_osd_request *osd_req, 4370010f705SIlya Dryomov unsigned int which, 4380010f705SIlya Dryomov struct bio_vec *bvecs, u32 num_bvecs, 4390010f705SIlya Dryomov u32 bytes); 440b9e281c2SIlya Dryomov void osd_req_op_extent_osd_data_bvec_pos(struct ceph_osd_request *osd_req, 441b9e281c2SIlya Dryomov unsigned int which, 442b9e281c2SIlya Dryomov struct ceph_bvec_iter *bvec_pos); 443a4ce40a9SAlex Elder 44404017e29SAlex Elder extern void osd_req_op_cls_request_data_pagelist(struct ceph_osd_request *, 44504017e29SAlex Elder unsigned int which, 44604017e29SAlex Elder struct ceph_pagelist *pagelist); 4476c57b554SAlex Elder extern void osd_req_op_cls_request_data_pages(struct ceph_osd_request *, 4486c57b554SAlex Elder unsigned int which, 4496c57b554SAlex Elder struct page **pages, u64 length, 4506c57b554SAlex Elder u32 alignment, bool pages_from_pool, 4516c57b554SAlex Elder bool own_pages); 452b9e281c2SIlya Dryomov void osd_req_op_cls_request_data_bvecs(struct ceph_osd_request *osd_req, 453b9e281c2SIlya Dryomov unsigned int which, 4540010f705SIlya Dryomov struct bio_vec *bvecs, u32 num_bvecs, 4550010f705SIlya Dryomov u32 bytes); 456a4ce40a9SAlex Elder extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *, 457c99d2d4aSAlex Elder unsigned int which, 458a4ce40a9SAlex Elder struct page **pages, u64 length, 459a4ce40a9SAlex Elder u32 alignment, bool pages_from_pool, 460a4ce40a9SAlex Elder bool own_pages); 46124639ce5SIlya Dryomov int osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which, 46204017e29SAlex Elder const char *class, const char *method); 463d74b50beSYan, Zheng extern int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int which, 464d74b50beSYan, Zheng u16 opcode, const char *name, const void *value, 465d74b50beSYan, Zheng size_t size, u8 cmp_op, u8 cmp_mode); 466c647b8a8SIlya Dryomov extern void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req, 467c647b8a8SIlya Dryomov unsigned int which, 468c647b8a8SIlya Dryomov u64 expected_object_size, 469c647b8a8SIlya Dryomov u64 expected_write_size); 47033803f33SAlex Elder 4713d14c5d2SYehuda Sadeh extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, 4723d14c5d2SYehuda Sadeh struct ceph_snap_context *snapc, 473acead002SAlex Elder unsigned int num_ops, 4743d14c5d2SYehuda Sadeh bool use_mempool, 47554a54007SAlex Elder gfp_t gfp_flags); 47613d1ad16SIlya Dryomov int ceph_osdc_alloc_messages(struct ceph_osd_request *req, gfp_t gfp); 4773d14c5d2SYehuda Sadeh 4783d14c5d2SYehuda Sadeh extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *, 4793d14c5d2SYehuda Sadeh struct ceph_file_layout *layout, 4803d14c5d2SYehuda Sadeh struct ceph_vino vino, 481acead002SAlex Elder u64 offset, u64 *len, 482715e4cd4SYan, Zheng unsigned int which, int num_ops, 483715e4cd4SYan, Zheng int opcode, int flags, 4843d14c5d2SYehuda Sadeh struct ceph_snap_context *snapc, 485acead002SAlex Elder u32 truncate_seq, u64 truncate_size, 486153e5167SAlex Elder bool use_mempool); 4873d14c5d2SYehuda Sadeh 4889e94af20SIlya Dryomov extern void ceph_osdc_get_request(struct ceph_osd_request *req); 4899e94af20SIlya Dryomov extern void ceph_osdc_put_request(struct ceph_osd_request *req); 4903d14c5d2SYehuda Sadeh 4913d14c5d2SYehuda Sadeh extern int ceph_osdc_start_request(struct ceph_osd_client *osdc, 4923d14c5d2SYehuda Sadeh struct ceph_osd_request *req, 4933d14c5d2SYehuda Sadeh bool nofail); 494c9f9b93dSIlya Dryomov extern void ceph_osdc_cancel_request(struct ceph_osd_request *req); 4953d14c5d2SYehuda Sadeh extern int ceph_osdc_wait_request(struct ceph_osd_client *osdc, 4963d14c5d2SYehuda Sadeh struct ceph_osd_request *req); 4973d14c5d2SYehuda Sadeh extern void ceph_osdc_sync(struct ceph_osd_client *osdc); 4983d14c5d2SYehuda Sadeh 499dd935f44SJosh Durgin extern void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc); 5007cca78c9SIlya Dryomov void ceph_osdc_maybe_request_map(struct ceph_osd_client *osdc); 501dd935f44SJosh Durgin 502428a7158SDouglas Fuller int ceph_osdc_call(struct ceph_osd_client *osdc, 503428a7158SDouglas Fuller struct ceph_object_id *oid, 504428a7158SDouglas Fuller struct ceph_object_locator *oloc, 505428a7158SDouglas Fuller const char *class, const char *method, 506428a7158SDouglas Fuller unsigned int flags, 507428a7158SDouglas Fuller struct page *req_page, size_t req_len, 50868ada915SIlya Dryomov struct page **resp_pages, size_t *resp_len); 509428a7158SDouglas Fuller 5103d14c5d2SYehuda Sadeh extern int ceph_osdc_readpages(struct ceph_osd_client *osdc, 5113d14c5d2SYehuda Sadeh struct ceph_vino vino, 5123d14c5d2SYehuda Sadeh struct ceph_file_layout *layout, 5133d14c5d2SYehuda Sadeh u64 off, u64 *plen, 5143d14c5d2SYehuda Sadeh u32 truncate_seq, u64 truncate_size, 515b7495fc2SSage Weil struct page **pages, int nr_pages, 516b7495fc2SSage Weil int page_align); 5173d14c5d2SYehuda Sadeh 5183d14c5d2SYehuda Sadeh extern int ceph_osdc_writepages(struct ceph_osd_client *osdc, 5193d14c5d2SYehuda Sadeh struct ceph_vino vino, 5203d14c5d2SYehuda Sadeh struct ceph_file_layout *layout, 5213d14c5d2SYehuda Sadeh struct ceph_snap_context *sc, 5223d14c5d2SYehuda Sadeh u64 off, u64 len, 5233d14c5d2SYehuda Sadeh u32 truncate_seq, u64 truncate_size, 524fac02ddfSArnd Bergmann struct timespec64 *mtime, 52524808826SAlex Elder struct page **pages, int nr_pages); 5263d14c5d2SYehuda Sadeh 52723ddf9beSLuis Henriques int ceph_osdc_copy_from(struct ceph_osd_client *osdc, 52823ddf9beSLuis Henriques u64 src_snapid, u64 src_version, 52923ddf9beSLuis Henriques struct ceph_object_id *src_oid, 53023ddf9beSLuis Henriques struct ceph_object_locator *src_oloc, 53123ddf9beSLuis Henriques u32 src_fadvise_flags, 53223ddf9beSLuis Henriques struct ceph_object_id *dst_oid, 53323ddf9beSLuis Henriques struct ceph_object_locator *dst_oloc, 53423ddf9beSLuis Henriques u32 dst_fadvise_flags, 53523ddf9beSLuis Henriques u8 copy_from_flags); 53623ddf9beSLuis Henriques 537922dab61SIlya Dryomov /* watch/notify */ 538922dab61SIlya Dryomov struct ceph_osd_linger_request * 539922dab61SIlya Dryomov ceph_osdc_watch(struct ceph_osd_client *osdc, 540922dab61SIlya Dryomov struct ceph_object_id *oid, 541922dab61SIlya Dryomov struct ceph_object_locator *oloc, 542922dab61SIlya Dryomov rados_watchcb2_t wcb, 543922dab61SIlya Dryomov rados_watcherrcb_t errcb, 544922dab61SIlya Dryomov void *data); 545922dab61SIlya Dryomov int ceph_osdc_unwatch(struct ceph_osd_client *osdc, 546922dab61SIlya Dryomov struct ceph_osd_linger_request *lreq); 547922dab61SIlya Dryomov 548922dab61SIlya Dryomov int ceph_osdc_notify_ack(struct ceph_osd_client *osdc, 549922dab61SIlya Dryomov struct ceph_object_id *oid, 550922dab61SIlya Dryomov struct ceph_object_locator *oloc, 551922dab61SIlya Dryomov u64 notify_id, 552922dab61SIlya Dryomov u64 cookie, 553922dab61SIlya Dryomov void *payload, 5546d54228fSIlya Dryomov u32 payload_len); 55519079203SIlya Dryomov int ceph_osdc_notify(struct ceph_osd_client *osdc, 55619079203SIlya Dryomov struct ceph_object_id *oid, 55719079203SIlya Dryomov struct ceph_object_locator *oloc, 55819079203SIlya Dryomov void *payload, 5596d54228fSIlya Dryomov u32 payload_len, 56019079203SIlya Dryomov u32 timeout, 56119079203SIlya Dryomov struct page ***preply_pages, 56219079203SIlya Dryomov size_t *preply_len); 563b07d3c4bSIlya Dryomov int ceph_osdc_watch_check(struct ceph_osd_client *osdc, 564b07d3c4bSIlya Dryomov struct ceph_osd_linger_request *lreq); 565a4ed38d7SDouglas Fuller int ceph_osdc_list_watchers(struct ceph_osd_client *osdc, 566a4ed38d7SDouglas Fuller struct ceph_object_id *oid, 567a4ed38d7SDouglas Fuller struct ceph_object_locator *oloc, 568a4ed38d7SDouglas Fuller struct ceph_watch_item **watchers, 569a4ed38d7SDouglas Fuller u32 *num_watchers); 5703d14c5d2SYehuda Sadeh #endif 5713d14c5d2SYehuda Sadeh 572