libceph: don't consume a ref on pagelist in ceph_msg_data_add_pagelist()
Because send_mds_reconnect() wants to send a message with a pagelist and pass the ownership to the messenger, ceph_msg_data_add_pagelist() consumes a ref which is then put in ceph_msg_data_destroy(). This makes managing pagelists in the OSD client (where they are wrapped in ceph_osd_data) unnecessarily hard because the handoff only happens in ceph_osdc_start_request() instead of when the pagelist is passed to ceph_osd_data_pagelist_init(). I counted several memory leaks on various error paths. Fix up ceph_msg_data_add_pagelist() and carry a pagelist ref in ceph_osd_data. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
@@ -126,6 +126,9 @@ static void ceph_osd_data_init(struct ceph_osd_data *osd_data)
|
||||
osd_data->type = CEPH_OSD_DATA_TYPE_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Consumes @pages if @own_pages is true.
|
||||
*/
|
||||
static void ceph_osd_data_pages_init(struct ceph_osd_data *osd_data,
|
||||
struct page **pages, u64 length, u32 alignment,
|
||||
bool pages_from_pool, bool own_pages)
|
||||
@@ -138,6 +141,9 @@ static void ceph_osd_data_pages_init(struct ceph_osd_data *osd_data,
|
||||
osd_data->own_pages = own_pages;
|
||||
}
|
||||
|
||||
/*
|
||||
* Consumes a ref on @pagelist.
|
||||
*/
|
||||
static void ceph_osd_data_pagelist_init(struct ceph_osd_data *osd_data,
|
||||
struct ceph_pagelist *pagelist)
|
||||
{
|
||||
@@ -362,6 +368,8 @@ static void ceph_osd_data_release(struct ceph_osd_data *osd_data)
|
||||
num_pages = calc_pages_for((u64)osd_data->alignment,
|
||||
(u64)osd_data->length);
|
||||
ceph_release_page_vector(osd_data->pages, num_pages);
|
||||
} else if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGELIST) {
|
||||
ceph_pagelist_release(osd_data->pagelist);
|
||||
}
|
||||
ceph_osd_data_init(osd_data);
|
||||
}
|
||||
|
Reference in New Issue
Block a user