mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
libceph: define struct ceph_sparse_extent and add some helpers
When the OSD sends back a sparse read reply, it contains an array of these structures. Define the structure and add a couple of helpers for dealing with them. Also add a place in struct ceph_osd_req_op to store the extent buffer, and code to free it if it's populated when the req is torn down. Signed-off-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Xiubo Li <xiubli@redhat.com> Reviewed-and-tested-by: Luís Henriques <lhenriques@suse.de> Reviewed-by: Milind Changire <mchangir@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
parent
08b8a0440e
commit
a679e50f72
2 changed files with 55 additions and 1 deletions
|
@ -29,6 +29,17 @@ typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *);
|
||||||
|
|
||||||
#define CEPH_HOMELESS_OSD -1
|
#define CEPH_HOMELESS_OSD -1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A single extent in a SPARSE_READ reply.
|
||||||
|
*
|
||||||
|
* Note that these come from the OSD as little-endian values. On BE arches,
|
||||||
|
* we convert them in-place after receipt.
|
||||||
|
*/
|
||||||
|
struct ceph_sparse_extent {
|
||||||
|
u64 off;
|
||||||
|
u64 len;
|
||||||
|
} __packed;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A given osd we're communicating with.
|
* A given osd we're communicating with.
|
||||||
*
|
*
|
||||||
|
@ -104,6 +115,8 @@ struct ceph_osd_req_op {
|
||||||
u64 offset, length;
|
u64 offset, length;
|
||||||
u64 truncate_size;
|
u64 truncate_size;
|
||||||
u32 truncate_seq;
|
u32 truncate_seq;
|
||||||
|
int sparse_ext_cnt;
|
||||||
|
struct ceph_sparse_extent *sparse_ext;
|
||||||
struct ceph_osd_data osd_data;
|
struct ceph_osd_data osd_data;
|
||||||
} extent;
|
} extent;
|
||||||
struct {
|
struct {
|
||||||
|
@ -510,6 +523,20 @@ extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,
|
||||||
u32 truncate_seq, u64 truncate_size,
|
u32 truncate_seq, u64 truncate_size,
|
||||||
bool use_mempool);
|
bool use_mempool);
|
||||||
|
|
||||||
|
int __ceph_alloc_sparse_ext_map(struct ceph_osd_req_op *op, int cnt);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* How big an extent array should we preallocate for a sparse read? This is
|
||||||
|
* just a starting value. If we get more than this back from the OSD, the
|
||||||
|
* receiver will reallocate.
|
||||||
|
*/
|
||||||
|
#define CEPH_SPARSE_EXT_ARRAY_INITIAL 16
|
||||||
|
|
||||||
|
static inline int ceph_alloc_sparse_ext_map(struct ceph_osd_req_op *op)
|
||||||
|
{
|
||||||
|
return __ceph_alloc_sparse_ext_map(op, CEPH_SPARSE_EXT_ARRAY_INITIAL);
|
||||||
|
}
|
||||||
|
|
||||||
extern void ceph_osdc_get_request(struct ceph_osd_request *req);
|
extern void ceph_osdc_get_request(struct ceph_osd_request *req);
|
||||||
extern void ceph_osdc_put_request(struct ceph_osd_request *req);
|
extern void ceph_osdc_put_request(struct ceph_osd_request *req);
|
||||||
|
|
||||||
|
@ -564,5 +591,19 @@ int ceph_osdc_list_watchers(struct ceph_osd_client *osdc,
|
||||||
struct ceph_object_locator *oloc,
|
struct ceph_object_locator *oloc,
|
||||||
struct ceph_watch_item **watchers,
|
struct ceph_watch_item **watchers,
|
||||||
u32 *num_watchers);
|
u32 *num_watchers);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
/* Find offset into the buffer of the end of the extent map */
|
||||||
|
static inline u64 ceph_sparse_ext_map_end(struct ceph_osd_req_op *op)
|
||||||
|
{
|
||||||
|
struct ceph_sparse_extent *ext;
|
||||||
|
|
||||||
|
/* No extents? No data */
|
||||||
|
if (op->extent.sparse_ext_cnt == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ext = &op->extent.sparse_ext[op->extent.sparse_ext_cnt - 1];
|
||||||
|
|
||||||
|
return ext->off + ext->len - op->extent.offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -378,6 +378,7 @@ static void osd_req_op_data_release(struct ceph_osd_request *osd_req,
|
||||||
case CEPH_OSD_OP_READ:
|
case CEPH_OSD_OP_READ:
|
||||||
case CEPH_OSD_OP_WRITE:
|
case CEPH_OSD_OP_WRITE:
|
||||||
case CEPH_OSD_OP_WRITEFULL:
|
case CEPH_OSD_OP_WRITEFULL:
|
||||||
|
kfree(op->extent.sparse_ext);
|
||||||
ceph_osd_data_release(&op->extent.osd_data);
|
ceph_osd_data_release(&op->extent.osd_data);
|
||||||
break;
|
break;
|
||||||
case CEPH_OSD_OP_CALL:
|
case CEPH_OSD_OP_CALL:
|
||||||
|
@ -1120,6 +1121,18 @@ fail:
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(ceph_osdc_new_request);
|
EXPORT_SYMBOL(ceph_osdc_new_request);
|
||||||
|
|
||||||
|
int __ceph_alloc_sparse_ext_map(struct ceph_osd_req_op *op, int cnt)
|
||||||
|
{
|
||||||
|
op->extent.sparse_ext_cnt = cnt;
|
||||||
|
op->extent.sparse_ext = kmalloc_array(cnt,
|
||||||
|
sizeof(*op->extent.sparse_ext),
|
||||||
|
GFP_NOFS);
|
||||||
|
if (!op->extent.sparse_ext)
|
||||||
|
return -ENOMEM;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(__ceph_alloc_sparse_ext_map);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We keep osd requests in an rbtree, sorted by ->r_tid.
|
* We keep osd requests in an rbtree, sorted by ->r_tid.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue