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; 13979528734SAlex Elder }; 14079528734SAlex Elder }; 14179528734SAlex Elder 14263244fa1SIlya Dryomov struct ceph_osd_request_target { 14363244fa1SIlya Dryomov struct ceph_object_id base_oid; 14463244fa1SIlya Dryomov struct ceph_object_locator base_oloc; 14563244fa1SIlya Dryomov struct ceph_object_id target_oid; 14663244fa1SIlya Dryomov struct ceph_object_locator target_oloc; 14763244fa1SIlya Dryomov 148dc98ff72SIlya Dryomov struct ceph_pg pgid; /* last raw pg we mapped to */ 149dc98ff72SIlya Dryomov struct ceph_spg spgid; /* last actual spg we mapped to */ 15063244fa1SIlya Dryomov u32 pg_num; 15163244fa1SIlya Dryomov u32 pg_num_mask; 15263244fa1SIlya Dryomov struct ceph_osds acting; 15363244fa1SIlya Dryomov struct ceph_osds up; 15463244fa1SIlya Dryomov int size; 15563244fa1SIlya Dryomov int min_size; 15663244fa1SIlya Dryomov bool sort_bitwise; 157ae78dd81SIlya Dryomov bool recovery_deletes; 15863244fa1SIlya Dryomov 15963244fa1SIlya Dryomov unsigned int flags; /* CEPH_OSD_FLAG_* */ 16063244fa1SIlya Dryomov bool paused; 16163244fa1SIlya Dryomov 16204c7d789SIlya Dryomov u32 epoch; 163dc93e0e2SIlya Dryomov u32 last_force_resend; 164dc93e0e2SIlya Dryomov 16563244fa1SIlya Dryomov int osd; 16663244fa1SIlya Dryomov }; 16763244fa1SIlya Dryomov 1683d14c5d2SYehuda Sadeh /* an in-flight request */ 1693d14c5d2SYehuda Sadeh struct ceph_osd_request { 1703d14c5d2SYehuda Sadeh u64 r_tid; /* unique for this client */ 1713d14c5d2SYehuda Sadeh struct rb_node r_node; 1724609245eSIlya Dryomov struct rb_node r_mc_node; /* map check */ 17388bc1922SIlya Dryomov struct work_struct r_complete_work; 1743d14c5d2SYehuda Sadeh struct ceph_osd *r_osd; 175a66dd383SIlya Dryomov 176a66dd383SIlya Dryomov struct ceph_osd_request_target r_t; 177a66dd383SIlya Dryomov #define r_base_oid r_t.base_oid 178a66dd383SIlya Dryomov #define r_base_oloc r_t.base_oloc 179a66dd383SIlya Dryomov #define r_flags r_t.flags 1803d14c5d2SYehuda Sadeh 1813d14c5d2SYehuda Sadeh struct ceph_msg *r_request, *r_reply; 1823d14c5d2SYehuda Sadeh u32 r_sent; /* >0 if r_request is sending/sent */ 1831b83bef2SSage Weil 18479528734SAlex Elder /* request osd ops array */ 18579528734SAlex Elder unsigned int r_num_ops; 18679528734SAlex Elder 1871b83bef2SSage Weil int r_result; 1883d14c5d2SYehuda Sadeh 1893d14c5d2SYehuda Sadeh struct ceph_osd_client *r_osdc; 1903d14c5d2SYehuda Sadeh struct kref r_kref; 1913d14c5d2SYehuda Sadeh bool r_mempool; 192b18b9550SIlya Dryomov struct completion r_completion; /* private to osd_client.c */ 19326be8808SAlex Elder ceph_osdc_callback_t r_callback; 1943d14c5d2SYehuda Sadeh struct list_head r_unsafe_item; 1953d14c5d2SYehuda Sadeh 1963d14c5d2SYehuda Sadeh struct inode *r_inode; /* for use by callbacks */ 1973d14c5d2SYehuda Sadeh void *r_priv; /* ditto */ 1983d14c5d2SYehuda Sadeh 199bb873b53SIlya Dryomov /* set by submitter */ 200bb873b53SIlya Dryomov u64 r_snapid; /* for reads, CEPH_NOSNAP o/w */ 201bb873b53SIlya Dryomov struct ceph_snap_context *r_snapc; /* for writes */ 202bb873b53SIlya Dryomov struct timespec r_mtime; /* ditto */ 203bb873b53SIlya Dryomov u64 r_data_offset; /* ditto */ 204922dab61SIlya Dryomov bool r_linger; /* don't resend on failure */ 2053d14c5d2SYehuda Sadeh 206bb873b53SIlya Dryomov /* internal */ 207bb873b53SIlya Dryomov unsigned long r_stamp; /* jiffies, send or check time */ 2087cc5e38fSIlya Dryomov unsigned long r_start_stamp; /* jiffies */ 209bb873b53SIlya Dryomov int r_attempts; 2104609245eSIlya Dryomov u32 r_map_dne_bound; 2113f1af42aSIlya Dryomov 2123f1af42aSIlya Dryomov struct ceph_osd_req_op r_ops[]; 2133d14c5d2SYehuda Sadeh }; 2143d14c5d2SYehuda Sadeh 215205ee118SIlya Dryomov struct ceph_request_redirect { 216205ee118SIlya Dryomov struct ceph_object_locator oloc; 217205ee118SIlya Dryomov }; 218205ee118SIlya Dryomov 2198cb441c0SIlya Dryomov /* 2208cb441c0SIlya Dryomov * osd request identifier 2218cb441c0SIlya Dryomov * 2228cb441c0SIlya Dryomov * caller name + incarnation# + tid to unique identify this request 2238cb441c0SIlya Dryomov */ 2248cb441c0SIlya Dryomov struct ceph_osd_reqid { 2258cb441c0SIlya Dryomov struct ceph_entity_name name; 2268cb441c0SIlya Dryomov __le64 tid; 2278cb441c0SIlya Dryomov __le32 inc; 2288cb441c0SIlya Dryomov } __packed; 2298cb441c0SIlya Dryomov 2308cb441c0SIlya Dryomov struct ceph_blkin_trace_info { 2318cb441c0SIlya Dryomov __le64 trace_id; 2328cb441c0SIlya Dryomov __le64 span_id; 2338cb441c0SIlya Dryomov __le64 parent_span_id; 2348cb441c0SIlya Dryomov } __packed; 2358cb441c0SIlya Dryomov 236922dab61SIlya Dryomov typedef void (*rados_watchcb2_t)(void *arg, u64 notify_id, u64 cookie, 237922dab61SIlya Dryomov u64 notifier_id, void *data, size_t data_len); 238922dab61SIlya Dryomov typedef void (*rados_watcherrcb_t)(void *arg, u64 cookie, int err); 239a40c4f10SYehuda Sadeh 240922dab61SIlya Dryomov struct ceph_osd_linger_request { 241922dab61SIlya Dryomov struct ceph_osd_client *osdc; 242922dab61SIlya Dryomov u64 linger_id; 243922dab61SIlya Dryomov bool committed; 24419079203SIlya Dryomov bool is_watch; /* watch or notify */ 245922dab61SIlya Dryomov 246922dab61SIlya Dryomov struct ceph_osd *osd; 247922dab61SIlya Dryomov struct ceph_osd_request *reg_req; 248922dab61SIlya Dryomov struct ceph_osd_request *ping_req; 249922dab61SIlya Dryomov unsigned long ping_sent; 250b07d3c4bSIlya Dryomov unsigned long watch_valid_thru; 251b07d3c4bSIlya Dryomov struct list_head pending_lworks; 252922dab61SIlya Dryomov 253922dab61SIlya Dryomov struct ceph_osd_request_target t; 2544609245eSIlya Dryomov u32 map_dne_bound; 255922dab61SIlya Dryomov 256922dab61SIlya Dryomov struct timespec mtime; 257922dab61SIlya Dryomov 258922dab61SIlya Dryomov struct kref kref; 259922dab61SIlya Dryomov struct mutex lock; 260922dab61SIlya Dryomov struct rb_node node; /* osd */ 261922dab61SIlya Dryomov struct rb_node osdc_node; /* osdc */ 2624609245eSIlya Dryomov struct rb_node mc_node; /* map check */ 263922dab61SIlya Dryomov struct list_head scan_item; 264922dab61SIlya Dryomov 265922dab61SIlya Dryomov struct completion reg_commit_wait; 26619079203SIlya Dryomov struct completion notify_finish_wait; 267922dab61SIlya Dryomov int reg_commit_error; 26819079203SIlya Dryomov int notify_finish_error; 269922dab61SIlya Dryomov int last_error; 270922dab61SIlya Dryomov 271922dab61SIlya Dryomov u32 register_gen; 27219079203SIlya Dryomov u64 notify_id; 273922dab61SIlya Dryomov 274922dab61SIlya Dryomov rados_watchcb2_t wcb; 275922dab61SIlya Dryomov rados_watcherrcb_t errcb; 276922dab61SIlya Dryomov void *data; 27719079203SIlya Dryomov 27819079203SIlya Dryomov struct page ***preply_pages; 27919079203SIlya Dryomov size_t *preply_len; 280a40c4f10SYehuda Sadeh }; 281a40c4f10SYehuda Sadeh 282a4ed38d7SDouglas Fuller struct ceph_watch_item { 283a4ed38d7SDouglas Fuller struct ceph_entity_name name; 284a4ed38d7SDouglas Fuller u64 cookie; 285a4ed38d7SDouglas Fuller struct ceph_entity_addr addr; 286a4ed38d7SDouglas Fuller }; 287a4ed38d7SDouglas Fuller 288a02a946dSIlya Dryomov struct ceph_spg_mapping { 289a02a946dSIlya Dryomov struct rb_node node; 290a02a946dSIlya Dryomov struct ceph_spg spgid; 291a02a946dSIlya Dryomov 292a02a946dSIlya Dryomov struct rb_root backoffs; 293a02a946dSIlya Dryomov }; 294a02a946dSIlya Dryomov 295a02a946dSIlya Dryomov struct ceph_hobject_id { 296a02a946dSIlya Dryomov void *key; 297a02a946dSIlya Dryomov size_t key_len; 298a02a946dSIlya Dryomov void *oid; 299a02a946dSIlya Dryomov size_t oid_len; 300a02a946dSIlya Dryomov u64 snapid; 301a02a946dSIlya Dryomov u32 hash; 302a02a946dSIlya Dryomov u8 is_max; 303a02a946dSIlya Dryomov void *nspace; 304a02a946dSIlya Dryomov size_t nspace_len; 305a02a946dSIlya Dryomov s64 pool; 306a02a946dSIlya Dryomov 307a02a946dSIlya Dryomov /* cache */ 308a02a946dSIlya Dryomov u32 hash_reverse_bits; 309a02a946dSIlya Dryomov }; 310a02a946dSIlya Dryomov 311a02a946dSIlya Dryomov static inline void ceph_hoid_build_hash_cache(struct ceph_hobject_id *hoid) 312a02a946dSIlya Dryomov { 313a02a946dSIlya Dryomov hoid->hash_reverse_bits = bitrev32(hoid->hash); 314a02a946dSIlya Dryomov } 315a02a946dSIlya Dryomov 316a02a946dSIlya Dryomov /* 317a02a946dSIlya Dryomov * PG-wide backoff: [begin, end) 318a02a946dSIlya Dryomov * per-object backoff: begin == end 319a02a946dSIlya Dryomov */ 320a02a946dSIlya Dryomov struct ceph_osd_backoff { 321a02a946dSIlya Dryomov struct rb_node spg_node; 322a02a946dSIlya Dryomov struct rb_node id_node; 323a02a946dSIlya Dryomov 324a02a946dSIlya Dryomov struct ceph_spg spgid; 325a02a946dSIlya Dryomov u64 id; 326a02a946dSIlya Dryomov struct ceph_hobject_id *begin; 327a02a946dSIlya Dryomov struct ceph_hobject_id *end; 328a02a946dSIlya Dryomov }; 329a02a946dSIlya Dryomov 330264048afSIlya Dryomov #define CEPH_LINGER_ID_START 0xffff000000000000ULL 331264048afSIlya Dryomov 3323d14c5d2SYehuda Sadeh struct ceph_osd_client { 3333d14c5d2SYehuda Sadeh struct ceph_client *client; 3343d14c5d2SYehuda Sadeh 3353d14c5d2SYehuda Sadeh struct ceph_osdmap *osdmap; /* current map */ 3365aea3dcdSIlya Dryomov struct rw_semaphore lock; 3373d14c5d2SYehuda Sadeh 3383d14c5d2SYehuda Sadeh struct rb_root osds; /* osds */ 3393d14c5d2SYehuda Sadeh struct list_head osd_lru; /* idle osds */ 3409dd2845cSIlya Dryomov spinlock_t osd_lru_lock; 34158eb7932SJeff Layton u32 epoch_barrier; 3425aea3dcdSIlya Dryomov struct ceph_osd homeless_osd; 3435aea3dcdSIlya Dryomov atomic64_t last_tid; /* tid of last request */ 344922dab61SIlya Dryomov u64 last_linger_id; 345922dab61SIlya Dryomov struct rb_root linger_requests; /* lingering requests */ 3464609245eSIlya Dryomov struct rb_root map_checks; 3474609245eSIlya Dryomov struct rb_root linger_map_checks; 3485aea3dcdSIlya Dryomov atomic_t num_requests; 3495aea3dcdSIlya Dryomov atomic_t num_homeless; 350c843d13cSIlya Dryomov bool abort_on_full; /* abort w/ ENOSPC when full */ 35166850df5SIlya Dryomov int abort_err; 3523d14c5d2SYehuda Sadeh struct delayed_work timeout_work; 3533d14c5d2SYehuda Sadeh struct delayed_work osds_timeout_work; 3543d14c5d2SYehuda Sadeh #ifdef CONFIG_DEBUG_FS 3553d14c5d2SYehuda Sadeh struct dentry *debugfs_file; 3563d14c5d2SYehuda Sadeh #endif 3573d14c5d2SYehuda Sadeh 3583d14c5d2SYehuda Sadeh mempool_t *req_mempool; 3593d14c5d2SYehuda Sadeh 3603d14c5d2SYehuda Sadeh struct ceph_msgpool msgpool_op; 3613d14c5d2SYehuda Sadeh struct ceph_msgpool msgpool_op_reply; 362a40c4f10SYehuda Sadeh 363a40c4f10SYehuda Sadeh struct workqueue_struct *notify_wq; 36488bc1922SIlya Dryomov struct workqueue_struct *completion_wq; 3653d14c5d2SYehuda Sadeh }; 3663d14c5d2SYehuda Sadeh 367b7ec35b3SIlya Dryomov static inline bool ceph_osdmap_flag(struct ceph_osd_client *osdc, int flag) 368b7ec35b3SIlya Dryomov { 369b7ec35b3SIlya Dryomov return osdc->osdmap->flags & flag; 370b7ec35b3SIlya Dryomov } 371b7ec35b3SIlya Dryomov 3725522ae0bSAlex Elder extern int ceph_osdc_setup(void); 3735522ae0bSAlex Elder extern void ceph_osdc_cleanup(void); 3745522ae0bSAlex Elder 3753d14c5d2SYehuda Sadeh extern int ceph_osdc_init(struct ceph_osd_client *osdc, 3763d14c5d2SYehuda Sadeh struct ceph_client *client); 3773d14c5d2SYehuda Sadeh extern void ceph_osdc_stop(struct ceph_osd_client *osdc); 3783d14c5d2SYehuda Sadeh 3793d14c5d2SYehuda Sadeh extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc, 3803d14c5d2SYehuda Sadeh struct ceph_msg *msg); 3813d14c5d2SYehuda Sadeh extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc, 3823d14c5d2SYehuda Sadeh struct ceph_msg *msg); 38358eb7932SJeff Layton void ceph_osdc_update_epoch_barrier(struct ceph_osd_client *osdc, u32 eb); 38466850df5SIlya Dryomov void ceph_osdc_abort_requests(struct ceph_osd_client *osdc, int err); 3853d14c5d2SYehuda Sadeh 38649719778SAlex Elder extern void osd_req_op_init(struct ceph_osd_request *osd_req, 387144cba14SYan, Zheng unsigned int which, u16 opcode, u32 flags); 38849719778SAlex Elder 38949719778SAlex Elder extern void osd_req_op_raw_data_in_pages(struct ceph_osd_request *, 39049719778SAlex Elder unsigned int which, 39149719778SAlex Elder struct page **pages, u64 length, 39249719778SAlex Elder u32 alignment, bool pages_from_pool, 39349719778SAlex Elder bool own_pages); 39449719778SAlex Elder 395c99d2d4aSAlex Elder extern void osd_req_op_extent_init(struct ceph_osd_request *osd_req, 396c99d2d4aSAlex Elder unsigned int which, u16 opcode, 39733803f33SAlex Elder u64 offset, u64 length, 39833803f33SAlex Elder u64 truncate_size, u32 truncate_seq); 399c99d2d4aSAlex Elder extern void osd_req_op_extent_update(struct ceph_osd_request *osd_req, 400c99d2d4aSAlex Elder unsigned int which, u64 length); 4012c63f49aSYan, Zheng extern void osd_req_op_extent_dup_last(struct ceph_osd_request *osd_req, 4022c63f49aSYan, Zheng unsigned int which, u64 offset_inc); 403a4ce40a9SAlex Elder 404a4ce40a9SAlex Elder extern struct ceph_osd_data *osd_req_op_extent_osd_data( 405a4ce40a9SAlex Elder struct ceph_osd_request *osd_req, 406406e2c9fSAlex Elder unsigned int which); 407a4ce40a9SAlex Elder 408a4ce40a9SAlex Elder extern void osd_req_op_extent_osd_data_pages(struct ceph_osd_request *, 409406e2c9fSAlex Elder unsigned int which, 410a4ce40a9SAlex Elder struct page **pages, u64 length, 411a4ce40a9SAlex Elder u32 alignment, bool pages_from_pool, 412a4ce40a9SAlex Elder bool own_pages); 413a4ce40a9SAlex Elder extern void osd_req_op_extent_osd_data_pagelist(struct ceph_osd_request *, 414406e2c9fSAlex Elder unsigned int which, 415a4ce40a9SAlex Elder struct ceph_pagelist *pagelist); 416a4ce40a9SAlex Elder #ifdef CONFIG_BLOCK 4175359a17dSIlya Dryomov void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *osd_req, 418406e2c9fSAlex Elder unsigned int which, 4195359a17dSIlya Dryomov struct ceph_bio_iter *bio_pos, 4205359a17dSIlya Dryomov u32 bio_length); 421a4ce40a9SAlex Elder #endif /* CONFIG_BLOCK */ 4220010f705SIlya Dryomov void osd_req_op_extent_osd_data_bvecs(struct ceph_osd_request *osd_req, 4230010f705SIlya Dryomov unsigned int which, 4240010f705SIlya Dryomov struct bio_vec *bvecs, u32 num_bvecs, 4250010f705SIlya Dryomov u32 bytes); 426b9e281c2SIlya Dryomov void osd_req_op_extent_osd_data_bvec_pos(struct ceph_osd_request *osd_req, 427b9e281c2SIlya Dryomov unsigned int which, 428b9e281c2SIlya Dryomov struct ceph_bvec_iter *bvec_pos); 429a4ce40a9SAlex Elder 43004017e29SAlex Elder extern void osd_req_op_cls_request_data_pagelist(struct ceph_osd_request *, 43104017e29SAlex Elder unsigned int which, 43204017e29SAlex Elder struct ceph_pagelist *pagelist); 4336c57b554SAlex Elder extern void osd_req_op_cls_request_data_pages(struct ceph_osd_request *, 4346c57b554SAlex Elder unsigned int which, 4356c57b554SAlex Elder struct page **pages, u64 length, 4366c57b554SAlex Elder u32 alignment, bool pages_from_pool, 4376c57b554SAlex Elder bool own_pages); 438b9e281c2SIlya Dryomov void osd_req_op_cls_request_data_bvecs(struct ceph_osd_request *osd_req, 439b9e281c2SIlya Dryomov unsigned int which, 4400010f705SIlya Dryomov struct bio_vec *bvecs, u32 num_bvecs, 4410010f705SIlya Dryomov u32 bytes); 442a4ce40a9SAlex Elder extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *, 443c99d2d4aSAlex Elder unsigned int which, 444a4ce40a9SAlex Elder struct page **pages, u64 length, 445a4ce40a9SAlex Elder u32 alignment, bool pages_from_pool, 446a4ce40a9SAlex Elder bool own_pages); 447fe943d50SChengguang Xu extern int osd_req_op_cls_init(struct ceph_osd_request *osd_req, 448c99d2d4aSAlex Elder unsigned int which, u16 opcode, 44904017e29SAlex Elder const char *class, const char *method); 450d74b50beSYan, Zheng extern int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int which, 451d74b50beSYan, Zheng u16 opcode, const char *name, const void *value, 452d74b50beSYan, Zheng size_t size, u8 cmp_op, u8 cmp_mode); 453c647b8a8SIlya Dryomov extern void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req, 454c647b8a8SIlya Dryomov unsigned int which, 455c647b8a8SIlya Dryomov u64 expected_object_size, 456c647b8a8SIlya Dryomov u64 expected_write_size); 45733803f33SAlex Elder 4583d14c5d2SYehuda Sadeh extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, 4593d14c5d2SYehuda Sadeh struct ceph_snap_context *snapc, 460acead002SAlex Elder unsigned int num_ops, 4613d14c5d2SYehuda Sadeh bool use_mempool, 46254a54007SAlex Elder gfp_t gfp_flags); 46313d1ad16SIlya Dryomov int ceph_osdc_alloc_messages(struct ceph_osd_request *req, gfp_t gfp); 4643d14c5d2SYehuda Sadeh 4653d14c5d2SYehuda Sadeh extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *, 4663d14c5d2SYehuda Sadeh struct ceph_file_layout *layout, 4673d14c5d2SYehuda Sadeh struct ceph_vino vino, 468acead002SAlex Elder u64 offset, u64 *len, 469715e4cd4SYan, Zheng unsigned int which, int num_ops, 470715e4cd4SYan, Zheng int opcode, int flags, 4713d14c5d2SYehuda Sadeh struct ceph_snap_context *snapc, 472acead002SAlex Elder u32 truncate_seq, u64 truncate_size, 473153e5167SAlex Elder bool use_mempool); 4743d14c5d2SYehuda Sadeh 4759e94af20SIlya Dryomov extern void ceph_osdc_get_request(struct ceph_osd_request *req); 4769e94af20SIlya Dryomov extern void ceph_osdc_put_request(struct ceph_osd_request *req); 4773d14c5d2SYehuda Sadeh 4783d14c5d2SYehuda Sadeh extern int ceph_osdc_start_request(struct ceph_osd_client *osdc, 4793d14c5d2SYehuda Sadeh struct ceph_osd_request *req, 4803d14c5d2SYehuda Sadeh bool nofail); 481c9f9b93dSIlya Dryomov extern void ceph_osdc_cancel_request(struct ceph_osd_request *req); 4823d14c5d2SYehuda Sadeh extern int ceph_osdc_wait_request(struct ceph_osd_client *osdc, 4833d14c5d2SYehuda Sadeh struct ceph_osd_request *req); 4843d14c5d2SYehuda Sadeh extern void ceph_osdc_sync(struct ceph_osd_client *osdc); 4853d14c5d2SYehuda Sadeh 486dd935f44SJosh Durgin extern void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc); 4877cca78c9SIlya Dryomov void ceph_osdc_maybe_request_map(struct ceph_osd_client *osdc); 488dd935f44SJosh Durgin 489428a7158SDouglas Fuller int ceph_osdc_call(struct ceph_osd_client *osdc, 490428a7158SDouglas Fuller struct ceph_object_id *oid, 491428a7158SDouglas Fuller struct ceph_object_locator *oloc, 492428a7158SDouglas Fuller const char *class, const char *method, 493428a7158SDouglas Fuller unsigned int flags, 494428a7158SDouglas Fuller struct page *req_page, size_t req_len, 495428a7158SDouglas Fuller struct page *resp_page, size_t *resp_len); 496428a7158SDouglas Fuller 4973d14c5d2SYehuda Sadeh extern int ceph_osdc_readpages(struct ceph_osd_client *osdc, 4983d14c5d2SYehuda Sadeh struct ceph_vino vino, 4993d14c5d2SYehuda Sadeh struct ceph_file_layout *layout, 5003d14c5d2SYehuda Sadeh u64 off, u64 *plen, 5013d14c5d2SYehuda Sadeh u32 truncate_seq, u64 truncate_size, 502b7495fc2SSage Weil struct page **pages, int nr_pages, 503b7495fc2SSage Weil int page_align); 5043d14c5d2SYehuda Sadeh 5053d14c5d2SYehuda Sadeh extern int ceph_osdc_writepages(struct ceph_osd_client *osdc, 5063d14c5d2SYehuda Sadeh struct ceph_vino vino, 5073d14c5d2SYehuda Sadeh struct ceph_file_layout *layout, 5083d14c5d2SYehuda Sadeh struct ceph_snap_context *sc, 5093d14c5d2SYehuda Sadeh u64 off, u64 len, 5103d14c5d2SYehuda Sadeh u32 truncate_seq, u64 truncate_size, 5113d14c5d2SYehuda Sadeh struct timespec *mtime, 51224808826SAlex Elder struct page **pages, int nr_pages); 5133d14c5d2SYehuda Sadeh 514922dab61SIlya Dryomov /* watch/notify */ 515922dab61SIlya Dryomov struct ceph_osd_linger_request * 516922dab61SIlya Dryomov ceph_osdc_watch(struct ceph_osd_client *osdc, 517922dab61SIlya Dryomov struct ceph_object_id *oid, 518922dab61SIlya Dryomov struct ceph_object_locator *oloc, 519922dab61SIlya Dryomov rados_watchcb2_t wcb, 520922dab61SIlya Dryomov rados_watcherrcb_t errcb, 521922dab61SIlya Dryomov void *data); 522922dab61SIlya Dryomov int ceph_osdc_unwatch(struct ceph_osd_client *osdc, 523922dab61SIlya Dryomov struct ceph_osd_linger_request *lreq); 524922dab61SIlya Dryomov 525922dab61SIlya Dryomov int ceph_osdc_notify_ack(struct ceph_osd_client *osdc, 526922dab61SIlya Dryomov struct ceph_object_id *oid, 527922dab61SIlya Dryomov struct ceph_object_locator *oloc, 528922dab61SIlya Dryomov u64 notify_id, 529922dab61SIlya Dryomov u64 cookie, 530922dab61SIlya Dryomov void *payload, 5316d54228fSIlya Dryomov u32 payload_len); 53219079203SIlya Dryomov int ceph_osdc_notify(struct ceph_osd_client *osdc, 53319079203SIlya Dryomov struct ceph_object_id *oid, 53419079203SIlya Dryomov struct ceph_object_locator *oloc, 53519079203SIlya Dryomov void *payload, 5366d54228fSIlya Dryomov u32 payload_len, 53719079203SIlya Dryomov u32 timeout, 53819079203SIlya Dryomov struct page ***preply_pages, 53919079203SIlya Dryomov size_t *preply_len); 540b07d3c4bSIlya Dryomov int ceph_osdc_watch_check(struct ceph_osd_client *osdc, 541b07d3c4bSIlya Dryomov struct ceph_osd_linger_request *lreq); 542a4ed38d7SDouglas Fuller int ceph_osdc_list_watchers(struct ceph_osd_client *osdc, 543a4ed38d7SDouglas Fuller struct ceph_object_id *oid, 544a4ed38d7SDouglas Fuller struct ceph_object_locator *oloc, 545a4ed38d7SDouglas Fuller struct ceph_watch_item **watchers, 546a4ed38d7SDouglas Fuller u32 *num_watchers); 5473d14c5d2SYehuda Sadeh #endif 5483d14c5d2SYehuda Sadeh 549