libceph: open-code remove_{all,old}_osds()
They are called only once, from ceph_osdc_stop() and handle_osds_timeout() respectively. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
parent
0c0a8de13f
commit
42a2c09f2b
@ -1126,18 +1126,6 @@ static void remove_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_all_osds(struct ceph_osd_client *osdc)
|
|
||||||
{
|
|
||||||
dout("%s %p\n", __func__, osdc);
|
|
||||||
mutex_lock(&osdc->request_mutex);
|
|
||||||
while (!RB_EMPTY_ROOT(&osdc->osds)) {
|
|
||||||
struct ceph_osd *osd = rb_entry(rb_first(&osdc->osds),
|
|
||||||
struct ceph_osd, o_node);
|
|
||||||
remove_osd(osdc, osd);
|
|
||||||
}
|
|
||||||
mutex_unlock(&osdc->request_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void __move_osd_to_lru(struct ceph_osd_client *osdc,
|
static void __move_osd_to_lru(struct ceph_osd_client *osdc,
|
||||||
struct ceph_osd *osd)
|
struct ceph_osd *osd)
|
||||||
{
|
{
|
||||||
@ -1165,20 +1153,6 @@ static void __remove_osd_from_lru(struct ceph_osd *osd)
|
|||||||
list_del_init(&osd->o_osd_lru);
|
list_del_init(&osd->o_osd_lru);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_old_osds(struct ceph_osd_client *osdc)
|
|
||||||
{
|
|
||||||
struct ceph_osd *osd, *nosd;
|
|
||||||
|
|
||||||
dout("__remove_old_osds %p\n", osdc);
|
|
||||||
mutex_lock(&osdc->request_mutex);
|
|
||||||
list_for_each_entry_safe(osd, nosd, &osdc->osd_lru, o_osd_lru) {
|
|
||||||
if (time_before(jiffies, osd->lru_ttl))
|
|
||||||
break;
|
|
||||||
remove_osd(osdc, osd);
|
|
||||||
}
|
|
||||||
mutex_unlock(&osdc->request_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* reset osd connect
|
* reset osd connect
|
||||||
*/
|
*/
|
||||||
@ -1671,12 +1645,21 @@ static void handle_osds_timeout(struct work_struct *work)
|
|||||||
container_of(work, struct ceph_osd_client,
|
container_of(work, struct ceph_osd_client,
|
||||||
osds_timeout_work.work);
|
osds_timeout_work.work);
|
||||||
unsigned long delay = osdc->client->options->osd_idle_ttl / 4;
|
unsigned long delay = osdc->client->options->osd_idle_ttl / 4;
|
||||||
|
struct ceph_osd *osd, *nosd;
|
||||||
|
|
||||||
dout("osds timeout\n");
|
dout("%s osdc %p\n", __func__, osdc);
|
||||||
down_read(&osdc->map_sem);
|
down_read(&osdc->map_sem);
|
||||||
remove_old_osds(osdc);
|
mutex_lock(&osdc->request_mutex);
|
||||||
up_read(&osdc->map_sem);
|
|
||||||
|
|
||||||
|
list_for_each_entry_safe(osd, nosd, &osdc->osd_lru, o_osd_lru) {
|
||||||
|
if (time_before(jiffies, osd->lru_ttl))
|
||||||
|
break;
|
||||||
|
|
||||||
|
remove_osd(osdc, osd);
|
||||||
|
}
|
||||||
|
|
||||||
|
mutex_unlock(&osdc->request_mutex);
|
||||||
|
up_read(&osdc->map_sem);
|
||||||
schedule_delayed_work(&osdc->osds_timeout_work,
|
schedule_delayed_work(&osdc->osds_timeout_work,
|
||||||
round_jiffies_relative(delay));
|
round_jiffies_relative(delay));
|
||||||
}
|
}
|
||||||
@ -2722,11 +2705,19 @@ void ceph_osdc_stop(struct ceph_osd_client *osdc)
|
|||||||
destroy_workqueue(osdc->notify_wq);
|
destroy_workqueue(osdc->notify_wq);
|
||||||
cancel_delayed_work_sync(&osdc->timeout_work);
|
cancel_delayed_work_sync(&osdc->timeout_work);
|
||||||
cancel_delayed_work_sync(&osdc->osds_timeout_work);
|
cancel_delayed_work_sync(&osdc->osds_timeout_work);
|
||||||
|
|
||||||
|
mutex_lock(&osdc->request_mutex);
|
||||||
|
while (!RB_EMPTY_ROOT(&osdc->osds)) {
|
||||||
|
struct ceph_osd *osd = rb_entry(rb_first(&osdc->osds),
|
||||||
|
struct ceph_osd, o_node);
|
||||||
|
remove_osd(osdc, osd);
|
||||||
|
}
|
||||||
|
mutex_unlock(&osdc->request_mutex);
|
||||||
|
|
||||||
if (osdc->osdmap) {
|
if (osdc->osdmap) {
|
||||||
ceph_osdmap_destroy(osdc->osdmap);
|
ceph_osdmap_destroy(osdc->osdmap);
|
||||||
osdc->osdmap = NULL;
|
osdc->osdmap = NULL;
|
||||||
}
|
}
|
||||||
remove_all_osds(osdc);
|
|
||||||
mempool_destroy(osdc->req_mempool);
|
mempool_destroy(osdc->req_mempool);
|
||||||
ceph_msgpool_destroy(&osdc->msgpool_op);
|
ceph_msgpool_destroy(&osdc->msgpool_op);
|
||||||
ceph_msgpool_destroy(&osdc->msgpool_op_reply);
|
ceph_msgpool_destroy(&osdc->msgpool_op_reply);
|
||||||
|
Loading…
Reference in New Issue
Block a user