scattered page writeback
cover scattered page writeback
This series adds scattered page writeback, which uses one OSD request to writeback nonconsecutive dirty page within single strip. Scattered page writeback can increase performance of buffered random writes.
Yan, Zheng (6):
libceph: enlarge max number of operations in OSD request
libceph: move r_reply_op_{len,result} into struct ceph_osd_req_op
libceph: allow reserving operations in OSD request
libceph: add helper that extends numner of operations in OSD request
libceph: add helper that duplicates last extent operation
ceph: scattered page writeback
drivers/block/rbd.c | 2 +- fs/ceph/addr.c | 209 ++++++++++++++++++++++++---------------- include/linux/ceph/osd_client.h | 17 +++- net/ceph/osd_client.c | 138 ++++++++++++++++++++++---- 4 files changed, 260 insertions(+), 106 deletions(-)
Signature · 1 line
2.5.0
PATCH 1/6 libceph: enlarge max number of operations in OSD request
Each operation requires a 'ceph_osd_req_op' structure. To avoid increasing memory usage of 'struct ceph_osd_request' in ordinary cases, we dynamically allocate 'ceph_osd_req_op' structures when number of operations in OSD request are larger than 3
--- include/linux/ceph/osd_client.h | 6 ++++-- net/ceph/osd_client.c | 45 +++++++++++++++++++++++++++++------------ 2 files changed, 36 insertions(+), 15 deletions(-)
include/linux/ceph/osd_client.h +4 -2
@@ -43,7 +43,8 @@ struct ceph_osd { }; -#define CEPH_OSD_MAX_OP 3 +#define CEPH_OSD_MAX_OP 16 +#define CEPH_OSD_INITIAL_OP 3enum ceph_osd_data_type {CEPH_OSD_DATA_TYPE_NONE =0 ,
@@ -136,7 +137,8 @@ struct ceph_osd_request {/* request osd ops array */ unsigned int r_num_ops; -struct ceph_osd_req_op r_ops[CEPH_OSD_MAX_OP ]; +struct ceph_osd_req_op *r_ops; +struct ceph_osd_req_op r_inline_ops[CEPH_OSD_INITIAL_OP ];/* these are updated on each send */ __le32 *r_request_osdmap_epoch;
net/ceph/osd_client.c +32 -13
83 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 2/6 libceph: move r_reply_op_{len,result} into struct ceph_osd_req_op
In reply to Yan, ZhengThis avoids defining large array of r_reply_op_{len,result} in in 'struct ceph_osd_request'
--- drivers/block/rbd.c | 2 +- include/linux/ceph/osd_client.h | 5 +++-- net/ceph/osd_client.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-)
drivers/block/rbd.c +1 -1
@@ -1854,7 +1854,7 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req,* passed to the block layer, which just supports a 32-bit * length field. */ - obj_request->xferred = osd_req->r_reply_op_len[0 ]; + obj_request->xferred = osd_req->r_ops[0 ].reply_op_len;rbd_assert (obj_request->xferred < (u64 )UINT_MAX ); opcode = osd_req->r_ops[0 ].op;
include/linux/ceph/osd_client.h +3 -2
@@ -116,6 +116,9 @@ struct ceph_osd_req_op {u64 expected_write_size; } alloc_hint; }; +/* reply */ +int reply_op_len; +s32 reply_op_result; };/* an in-flight request */
@@ -150,8 +153,6 @@ struct ceph_osd_request {struct ceph_eversion *r_request_reassert_version;int r_result; -int r_reply_op_len[CEPH_OSD_MAX_OP ]; -s32 r_reply_op_result[CEPH_OSD_MAX_OP ];int r_got_reply;int r_linger;
net/ceph/osd_client.c +2 -2
@@ -1839,7 +1839,7 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg)int len; len =le32_to_cpu (op->payload_len); - req->r_reply_op_len[i] = len; + req->r_ops[i].reply_op_len = len;dout (" op %d has %d bytes\n" , i, len); payload_len += len; p +=sizeof (*op);
@@ -1854,7 +1854,7 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg)ceph_decode_need (&p, end,4 + numops *4 , bad_put); retry_attempt =ceph_decode_32 (&p);for (i =0 ; i < numops; i++) - req->r_reply_op_result[i] =ceph_decode_32 (&p); + req->r_ops[i].reply_op_result =ceph_decode_32 (&p);if (le16_to_cpu (msg->hdr.version) >=6 ) { p +=8 +4 ;/* skip replay_version */
Signature · 1 line
2.5.0
PATCH 3/6 libceph: allow reserving operations in OSD request
In reply to Yan, ZhengThis allows us to reserve some operations for furture use. we do not need to use all reserved operations.
--- include/linux/ceph/osd_client.h | 1 + net/ceph/osd_client.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
include/linux/ceph/osd_client.h +1 -0
@@ -139,6 +139,7 @@ struct ceph_osd_request {u32 r_sent;/* >0 if r_request is sending/sent */ /* request osd ops array */ +unsigned int r_max_ops;unsigned int r_num_ops;struct ceph_osd_req_op *r_ops;struct ceph_osd_req_op r_inline_ops[CEPH_OSD_INITIAL_OP ];
net/ceph/osd_client.c +5 -2
@@ -385,7 +385,8 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, req->r_osdc = osdc; req->r_mempool = use_mempool; - req->r_num_ops = num_ops; + req->r_num_ops =0 ; + req->r_max_ops = num_ops;if (num_ops <=CEPH_OSD_INITIAL_OP ) { req->r_ops = req->r_inline_ops;
@@ -479,8 +480,10 @@ _osd_req_op_init(struct ceph_osd_request *osd_req, unsigned int which, {struct ceph_osd_req_op *op; -BUG_ON (which >= osd_req->r_num_ops); +BUG_ON (which >= osd_req->r_max_ops);BUG_ON (!osd_req_opcode_valid (opcode)); +if (which >= osd_req->r_num_ops) + osd_req->r_num_ops = which +1 ; op = &osd_req->r_ops[which];memset (op,0 ,sizeof (*op));
Signature · 1 line
2.5.0
PATCH 4/6 libceph: add helper that extends numner of operations in OSD request
In reply to Yan, ZhengThe helper function resizes the r_ops array and re-allocates request message.
--- include/linux/ceph/osd_client.h | 3 ++ net/ceph/osd_client.c | 61 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+)
include/linux/ceph/osd_client.h +3 -0
@@ -322,6 +322,9 @@ extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *unsigned int num_ops, bool use_mempool, gfp_t gfp_flags); +extern int ceph_osdc_extend_request (struct ceph_osd_request *req, +unsigned int num_ops,gfp_t gfp_flags); + extern void ceph_osdc_build_request(struct ceph_osd_request *req, u64 off, struct ceph_snap_context *snapc,
net/ceph/osd_client.c +61 -0
67 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 5/6 libceph: add helper that duplicates last extent operation
In reply to Yan, ZhengThis helper duplicates last extent operation in OSD request, then adjusts the new extent operation's offset and length. The helper is for scatterd page writeback, which adds nonconsecutive dirty pages to single OSD request.
--- include/linux/ceph/osd_client.h | 2 ++ net/ceph/osd_client.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+)
include/linux/ceph/osd_client.h +2 -0
@@ -267,6 +267,8 @@ extern void osd_req_op_extent_init(struct ceph_osd_request *osd_req, u64 truncate_size, u32 truncate_seq);extern void osd_req_op_extent_update (struct ceph_osd_request *osd_req,unsigned int which,u64 length); +extern void osd_req_op_extent_dup_last (struct ceph_osd_request *osd_req, +u64 offset_inc); extern struct ceph_osd_data *osd_req_op_extent_osd_data( struct ceph_osd_request *osd_req,
net/ceph/osd_client.c +21 -0
@@ -604,6 +604,27 @@ void osd_req_op_extent_update(struct ceph_osd_request *osd_req, }EXPORT_SYMBOL (osd_req_op_extent_update); +void osd_req_op_extent_dup_last (struct ceph_osd_request *osd_req, +u64 offset_inc) +{ +struct ceph_osd_req_op *op, *prev_op; +int which; + +BUG_ON (osd_req->r_num_ops ==0 ); + which = osd_req->r_num_ops; + + prev_op = &osd_req->r_ops[which -1 ]; + op =_osd_req_op_init (osd_req, which, prev_op->op, prev_op->flags); +/* dup previous one */ + op->payload_len = prev_op->payload_len; + op->extent = prev_op->extent; +/* adjust offset */ + op->extent.offset += offset_inc; + op->extent.length -= offset_inc; + op->payload_len -= offset_inc; +} +EXPORT_SYMBOL (osd_req_op_extent_dup_last); +void osd_req_op_cls_init (struct ceph_osd_request *osd_req,unsigned int which,u16 opcode,const char *class,const char *method) {
Signature · 1 line
2.5.0
PATCH 6/6 ceph: scattered page writeback
In reply to Yan, ZhengThis patch makes ceph_writepages_start() try using single OSD request to write all dirty pages within a strip. When a nonconsecutive dirty page is found, ceph_writepages_start() tries starting a new write operation to existing OSD request. If it succeeds, it uses the new operation to writeback the dirty page.
--- fs/ceph/addr.c | 209 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 125 insertions(+), 84 deletions(-)
fs/ceph/addr.c +125 -84
@@ -606,71 +606,71 @@ static void writepages_finish(struct ceph_osd_request *req,struct inode *inode = req->r_inode;struct ceph_inode_info *ci =ceph_inode (inode);struct ceph_osd_data *osd_data; -unsigned wrote;struct page *page; -int num_pages; -int i; +int num_pages, total_pages =0 ; +int i, j; +int rc = req->r_result;struct ceph_snap_context *snapc = req->r_snapc;struct address_space *mapping = inode->i_mapping; -int rc = req->r_result; -u64 bytes = req->r_ops[0 ].extent.length;struct ceph_fs_client *fsc =ceph_inode_to_client (inode); -long writeback_stat; -unsigned issued =ceph_caps_issued (ci); +bool remove_page; - osd_data =osd_req_op_extent_osd_data (req,0 ); -BUG_ON (osd_data->type !=CEPH_OSD_DATA_TYPE_PAGES ); - num_pages =calc_pages_for ((u64 )osd_data->alignment, - (u64 )osd_data->length); -if (rc >=0 ) { -/* -* Assume we wrote the pages we originally sent. The -* osd might reply with fewer pages if our writeback -* raced with a truncation and was adjusted at the osd, -* so don't believe the reply. -*/ - wrote = num_pages; - }else { - wrote =0 ; + +dout ("writepages_finish %p rc %d\n" , inode, rc); +if (rc <0 )mapping_set_error (mapping, rc); - } -dout ("writepages_finish %p rc %d bytes %llu wrote %d (pages)\n" , - inode, rc, bytes, wrote); -/* clean all pages */ -for (i =0 ; i < num_pages; i++) { - page = osd_data->pages[i]; -BUG_ON (!page); -WARN_ON (!PageUptodate (page)); +/* +* We lost the cache cap, need to truncate the page before +* it is unlocked, otherwise we'd truncate it later in the +* page truncation thread, possibly losing some data that +* raced its way in +*/ + remove_page = !(ceph_caps_issued (ci) & + (CEPH_CAP_FILE_CACHE |CEPH_CAP_FILE_LAZYIO )); - writeback_stat = -atomic_long_dec_return (&fsc->writeback_count); -if (writeback_stat < -CONGESTION_OFF_THRESH (fsc->mount_options->congestion_kb)) -clear_bdi_congested (&fsc->backing_dev_info, -BLK_RW_ASYNC ); +/* clean all pages */ +for (i =0 ; i < req->r_num_ops; i++) { +if (req->r_ops[i].op !=CEPH_OSD_OP_WRITE ) +break ; -ceph_put_snap_context (page_snap_context (page)); - page->private =0 ; -ClearPagePrivate (page); -dout ("unlocking %d %p\n" , i, page); -end_page_writeback (page); + osd_data =osd_req_op_extent_osd_data (req, i); +BUG_ON (osd_data->type !=CEPH_OSD_DATA_TYPE_PAGES ); + num_pages =calc_pages_for ((u64 )osd_data->alignment, + (u64 )osd_data->length); + total_pages += num_pages; +for (j =0 ; j < num_pages; j++) { + page = osd_data->pages[j]; +BUG_ON (!page); +WARN_ON (!PageUptodate (page)); + +if (atomic_long_dec_return (&fsc->writeback_count) < +CONGESTION_OFF_THRESH ( + fsc->mount_options->congestion_kb)) +clear_bdi_congested (&fsc->backing_dev_info, +BLK_RW_ASYNC ); + +ceph_put_snap_context (page_snap_context (page)); + page->private =0 ; +ClearPagePrivate (page); +dout ("unlocking %p\n" , page); +end_page_writeback (page); + +if (remove_page) +generic_error_remove_page (inode->i_mapping, + page); -/* -* We lost the cache cap, need to truncate the page before -* it is unlocked, otherwise we'd truncate it later in the -* page truncation thread, possibly losing some data that -* raced its way in -*/ -if ((issued & (CEPH_CAP_FILE_CACHE |CEPH_CAP_FILE_LAZYIO )) ==0 ) -generic_error_remove_page (inode->i_mapping, page); +unlock_page (page); + } +dout ("writepages_finish %p wrote %llu bytes cleaned %d pages\n" , + inode, osd_data->length, rc >=0 ? num_pages :0 ); -unlock_page (page); +ceph_release_pages (osd_data->pages, num_pages); } -dout ("%p wrote+cleaned %d pages\n" , inode, wrote); -ceph_put_wrbuffer_cap_refs (ci, num_pages, snapc); -ceph_release_pages (osd_data->pages, num_pages); +ceph_put_wrbuffer_cap_refs (ci, total_pages, snapc); + + osd_data =osd_req_op_extent_osd_data (req,0 );if (osd_data->pages_from_pool)mempool_free (osd_data->pages,ceph_sb_to_client (inode->i_sb)->wb_pagevec_pool);
@@ -778,17 +778,15 @@ retry:while (!done && index <= end) {unsigned i;int first; -pgoff_t next; -int pvec_pages, locked_pages; -struct page **pages =NULL ; +pgoff_t strip_end =0 ; +int num_ops =0 , max_ops =0 ; +int pvec_pages, locked_pages =0 ; +struct page **pages =NULL , **data_pages =NULL ;mempool_t *pool =NULL ;/* Becomes non-null if mempool used */ struct page *page;int want; -u64 offset, len; -long writeback_stat; +u64 offset =0 , len =0 ; - next =0 ; - locked_pages =0 ; max_pages = max_pages_ever; get_more_pages:
@@ -824,8 +822,8 @@ get_more_pages:unlock_page (page);break ; } -if (next && (page->index != next)) { -dout ("not consecutive %p\n" , page); +if (strip_end && (page->index > strip_end)) { +dout ("end of strip %p\n" , page);unlock_page (page);break ; }
@@ -875,10 +873,11 @@ get_more_pages:/* prepare async write request */ offset = (u64 )page_offset (page); len = wsize; + max_ops =CEPH_OSD_INITIAL_OP ; req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, vino, - offset, &len, 0, - do_sync ? 2 : 1, + offset, &len, + 0, max_ops, CEPH_OSD_OP_WRITE, CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK,
@@ -890,9 +889,8 @@ get_more_pages:break ; } -if (do_sync) -osd_req_op_init (req,1 , -CEPH_OSD_OP_STARTSYNC ,0 ); + strip_end = page->index + + ((len -1 ) >>PAGE_CACHE_SHIFT ); req->r_callback = writepages_finish; req->r_inode = inode;
@@ -905,6 +903,48 @@ get_more_pages: pages =mempool_alloc (pool,GFP_NOFS );BUG_ON (!pages); } + + num_ops =1 ; + data_pages = pages; + len =0 ; + }else if (page->index != + (offset + len) >>PAGE_CACHE_SHIFT ) { +u64 offset_inc; +bool new_op = true; + +if (num_ops + do_sync ==CEPH_OSD_MAX_OP ) { + new_op = false; + }else if (num_ops + do_sync == max_ops) { + max_ops = num_ops <<1 ; + max_ops =min (max_ops,CEPH_OSD_MAX_OP ); +if (ceph_osdc_extend_request (req, + max_ops, +GFP_NOFS ) <0 ) + new_op = false; + } +if (!new_op) { +redirty_page_for_writepage (wbc, page); +unlock_page (page); +break ; + } + + offset_inc = (u64 )page_offset (page) - offset; +osd_req_op_extent_dup_last (req, offset_inc); + +dout ("writepages got pages at %llu~%llu\n" , + offset, len); + +osd_req_op_extent_update (req, num_ops -1 , len); +osd_req_op_extent_osd_data_pages (req, + num_ops -1 , + data_pages, + len,0 , + !!pool, false); + + num_ops++; + data_pages = pages + locked_pages; + offset = (u64 )page_offset (page); + len =0 ; }/* note position of first page in pvec */
@@ -913,9 +953,8 @@ get_more_pages:dout ("%p will write page %p idx %lu\n" , inode, page, page->index); - writeback_stat = -atomic_long_inc_return (&fsc->writeback_count); -if (writeback_stat >CONGESTION_ON_THRESH ( +if (atomic_long_inc_return (&fsc->writeback_count) > +CONGESTION_ON_THRESH ( fsc->mount_options->congestion_kb)) {set_bdi_congested (&fsc->backing_dev_info,BLK_RW_ASYNC );
@@ -924,7 +963,7 @@ get_more_pages:set_page_writeback (page); pages[locked_pages] = page; locked_pages++; - next = page->index +1 ; + len +=PAGE_CACHE_SIZE ; }/* did we get anything? */
@@ -952,31 +991,34 @@ get_more_pages: }/* Format the osd request message and submit the write */ - offset =page_offset (pages[0 ]); - len = (u64 )locked_pages <<PAGE_CACHE_SHIFT ;if (snap_size ==-1 ) { +/* writepages_finish() clears writeback pages +* according to the data length, so make sure +* data length covers all locked pages */ +u64 min_len = len +1 -PAGE_CACHE_SIZE ; len =min (len, (u64 )i_size_read (inode) - offset); -/* writepages_finish() clears writeback pages -* according to the data length, so make sure -* data length covers all locked pages */ - len =max (len,1 + - ((u64)(locked_pages -1 ) <<PAGE_CACHE_SHIFT )); + len =max (len, min_len); }else { len =min (len, snap_size - offset); } -dout ("writepages got %d pages at %llu~%llu\n" , - locked_pages, offset, len); +dout ("writepages got pages at %llu~%llu\n" , offset, len); -osd_req_op_extent_osd_data_pages (req,0 , pages, len,0 , - !!pool, false); +osd_req_op_extent_osd_data_pages (req, num_ops -1 , data_pages, + len,0 , !!pool, false); +osd_req_op_extent_update (req, num_ops -1 , len); +if (do_sync) { +osd_req_op_init (req, num_ops,CEPH_OSD_OP_STARTSYNC ,0 ); + num_ops++; + } +BUG_ON (num_ops > max_ops); + + index = pages[locked_pages -1 ]->index +1 ; pages =NULL ;/* request message now owns the pages array */ pool =NULL ;/* Update the write op length in case we changed it */ -osd_req_op_extent_update (req,0 , len); - vino =ceph_vino (inode);ceph_osdc_build_request (req, offset, snapc, vino.snap, &inode->i_mtime);
@@ -986,7 +1028,6 @@ get_more_pages: req =NULL ;/* continue? */ - index = next; wbc->nr_to_write -= locked_pages;if (wbc->nr_to_write <=0 ) done =1 ;
Signature · 1 line
2.5.0
Ilya Dryomov
maintainerQuoted 3 lines · Zheng
This series adds scattered page writeback, which uses one OSD request to writeback nonconsecutive dirty page within single strip. Scattered page writeback can increase performance of buffered random writes.
Hi Zheng,
I took a cursory look at this and I really wonder if turning an OSD request with its two messages into an ad-hoc dynamic array and using it like that is a good idea. ceph_writepages_start() is one easy to follow function - is there no way to pre-calculate the number of dirty pages we'd want to stuff into a single request, or at least estimate it? With the geometric expansion you've got in there, you'd go 3 -> 6 -> 12 -> 16 for a 16 page strip? That seems suboptimal...
A couple of implementation details in libceph that stood out:
- Why use ceph_kvmalloc() for r_ops array? It's at most ~2k, so you'd only be using vmalloc() as a fallback and we don't want to do that.
- Moving reply_op_{len,result} into ceph_osd_req_op to save memory is the right thing, but, continuing on that, why waste r_inline_ops in the >CEPH_OSD_INITIAL_OP case? That's almost a quarter of r_ops max capacity - ~500 bytes for each "fat" request.
- Why is it that request message's front is enlarged proportionally to max_ops, while reply message's front is always enlarged by (MAX-INITIAL)*foo? Shouldn't it be proportional to max_ops as well? It definitely deserves a comment, if not.
- The "4" in (sizeof(struct ceph_osd_op) + 4) also deserves a comment. I had to go and look to figure out that it's for reply_op_result.
Thanks,
Ilya
Quoted 30 lines · Ilya Dryomov
Quoted 3 lines · Zheng
This series adds scattered page writeback, which uses one OSD request to writeback nonconsecutive dirty page within single strip. Scattered page writeback can increase performance of buffered random writes.
Hi Zheng,
I took a cursory look at this and I really wonder if turning an OSD request with its two messages into an ad-hoc dynamic array and using it like that is a good idea.
ceph_writepages_start()is one easy to follow function - is there no way to pre-calculate the number of dirty pages we'd want to stuff into a single request, or at least estimate it? With the geometric expansion you've got in there, you'd go 3 -> 6 -> 12 -> 16 for a 16 page strip? That seems suboptimal...A couple of implementation details in libceph that stood out:
- Why use
ceph_kvmalloc()forr_opsarray? It's at most ~2k, so you'd only be usingvmalloc()as a fallback and we don't want to do that.- Moving reply_op_{len,result} into
ceph_osd_req_opto save memory is the right thing, but, continuing on that, why waster_inline_opsin the >CEPH_OSD_INITIAL_OP case? That's almost a quarter ofr_opsmax capacity - ~500 bytes for each "fat" request.- Why is it that request message's front is enlarged proportionally to
max_ops, while reply message's front is always enlarged by (MAX-INITIAL)*foo? Shouldn't it be proportional tomax_opsas well? It definitely deserves a comment, if not.
Quoted 6 lines
- The "4" in (
sizeof(struct ceph_osd_op)+ 4) also deserves a comment. I had to go and look to figure out that it's forreply_op_result.Thanks,
Ilya
Hi,
I have send V2 patches which address most of your comments. For simplicity, the code still does not use r_inline_ops when num_ops > CEPH_OSD_INITIAL_OP. I assume the kernel slab allocator is efficient in allocating memory < 4k. The difference between allocating 2k memory and 1.5k memory can be negligible.
Regards
Yan, Zheng
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Ilya Dryomov
maintainerQuoted 38 lines · Zheng
Quoted 30 lines · Ilya Dryomov
Quoted 3 lines · Zheng
This series adds scattered page writeback, which uses one OSD request to writeback nonconsecutive dirty page within single strip. Scattered page writeback can increase performance of buffered random writes.
Hi Zheng,
I took a cursory look at this and I really wonder if turning an OSD request with its two messages into an ad-hoc dynamic array and using it like that is a good idea.
ceph_writepages_start()is one easy to follow function - is there no way to pre-calculate the number of dirty pages we'd want to stuff into a single request, or at least estimate it? With the geometric expansion you've got in there, you'd go 3 -> 6 -> 12 -> 16 for a 16 page strip? That seems suboptimal...A couple of implementation details in libceph that stood out:
- Why use
ceph_kvmalloc()forr_opsarray? It's at most ~2k, so you'd only be usingvmalloc()as a fallback and we don't want to do that.- Moving reply_op_{len,result} into
ceph_osd_req_opto save memory is the right thing, but, continuing on that, why waster_inline_opsin the >CEPH_OSD_INITIAL_OP case? That's almost a quarter ofr_opsmax capacity - ~500 bytes for each "fat" request.- Why is it that request message's front is enlarged proportionally to
max_ops, while reply message's front is always enlarged by (MAX-INITIAL)*foo? Shouldn't it be proportional tomax_opsas well? It definitely deserves a comment, if not.Quoted 6 lines
- The "4" in (
sizeof(struct ceph_osd_op)+ 4) also deserves a comment. I had to go and look to figure out that it's forreply_op_result.Thanks,
Ilya
Quoted 7 lines
Hi,
I have send V2 patches which address most of your comments. For simplicity, the code still does not use
r_inline_opswhennum_ops>CEPH_OSD_INITIAL_OP. I assume the kernel slab allocator is efficient in allocating memory < 4k. The difference between allocating 2k memory and 1.5k memory can be negligible.
I'm not sure I buy that argument - that's ~500 bytes for each fat OSD request, of which there can be many.
I see in your v2 you pre-calculate the number of dirty pages, but still start with a small OSD request and then expand in one go. Expanding that way is better, but what I was getting at is can we pre-calculate before allocating an OSD request? Then, try to allocate a fat request, if that fails with -ENOMEM, get a small request from the mempool. That would be a lot simpler and we won't have to argue about r_inline_ops ;)
Thanks,
Ilya
Quoted 53 lines · Ilya Dryomov
Quoted 38 lines · Zheng
Quoted 30 lines · Ilya Dryomov
Quoted 3 lines · Zheng
This series adds scattered page writeback, which uses one OSD request to writeback nonconsecutive dirty page within single strip. Scattered page writeback can increase performance of buffered random writes.
Hi Zheng,
I took a cursory look at this and I really wonder if turning an OSD request with its two messages into an ad-hoc dynamic array and using it like that is a good idea.
ceph_writepages_start()is one easy to follow function - is there no way to pre-calculate the number of dirty pages we'd want to stuff into a single request, or at least estimate it? With the geometric expansion you've got in there, you'd go 3 -> 6 -> 12 -> 16 for a 16 page strip? That seems suboptimal...A couple of implementation details in libceph that stood out:
- Why use
ceph_kvmalloc()forr_opsarray? It's at most ~2k, so you'd only be usingvmalloc()as a fallback and we don't want to do that.- Moving reply_op_{len,result} into
ceph_osd_req_opto save memory is the right thing, but, continuing on that, why waster_inline_opsin the >CEPH_OSD_INITIAL_OP case? That's almost a quarter ofr_opsmax capacity - ~500 bytes for each "fat" request.- Why is it that request message's front is enlarged proportionally to
max_ops, while reply message's front is always enlarged by (MAX-INITIAL)*foo? Shouldn't it be proportional tomax_opsas well? It definitely deserves a comment, if not.Quoted 6 lines
- The "4" in (
sizeof(struct ceph_osd_op)+ 4) also deserves a comment. I had to go and look to figure out that it's forreply_op_result.Thanks,
Ilya
Quoted 7 lines
Hi,
I have send V2 patches which address most of your comments. For simplicity, the code still does not use
r_inline_opswhennum_ops>CEPH_OSD_INITIAL_OP. I assume the kernel slab allocator is efficient in allocating memory < 4k. The difference between allocating 2k memory and 1.5k memory can be negligible.I'm not sure I buy that argument - that's ~500 bytes for each fat OSD request, of which there can be many.
Quoted 7 lines
I see in your v2 you pre-calculate the number of dirty pages, but still start with a small OSD request and then expand in one go. Expanding that way is better, but what I was getting at is can we pre-calculate before allocating an OSD request? Then, try to allocate a fat request, if that fails with
-ENOMEM, get a small request from the mempool. That would be a lot simpler and we won't have to argue aboutr_inline_ops;)
end v3 for patch 6. please take a look
Regards
Yan, Zheng
Quoted 3 lines
Thanks,
Ilya