diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2016-04-28 10:07:22 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2016-05-25 18:36:23 -0400 |
commit | 42a2c09f2b0b95fa147bcdb56cdc02b980b9ac5e (patch) | |
tree | 29d5f7c0ac1dd6df0f8dec27dd173b4cc845d66d /net | |
parent | 0c0a8de13f9612a663b050afa955e6668858d1eb (diff) |
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/osd_client.c | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 32ba09be6ee6..c423e11d6857 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -1126,18 +1126,6 @@ static void remove_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd) | |||
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | 1128 | ||
1129 | static void remove_all_osds(struct ceph_osd_client *osdc) | ||
1130 | { | ||
1131 | dout("%s %p\n", __func__, osdc); | ||
1132 | mutex_lock(&osdc->request_mutex); | ||
1133 | while (!RB_EMPTY_ROOT(&osdc->osds)) { | ||
1134 | struct ceph_osd *osd = rb_entry(rb_first(&osdc->osds), | ||
1135 | struct ceph_osd, o_node); | ||
1136 | remove_osd(osdc, osd); | ||
1137 | } | ||
1138 | mutex_unlock(&osdc->request_mutex); | ||
1139 | } | ||
1140 | |||
1141 | static void __move_osd_to_lru(struct ceph_osd_client *osdc, | 1129 | static void __move_osd_to_lru(struct ceph_osd_client *osdc, |
1142 | struct ceph_osd *osd) | 1130 | struct ceph_osd *osd) |
1143 | { | 1131 | { |
@@ -1165,20 +1153,6 @@ static void __remove_osd_from_lru(struct ceph_osd *osd) | |||
1165 | list_del_init(&osd->o_osd_lru); | 1153 | list_del_init(&osd->o_osd_lru); |
1166 | } | 1154 | } |
1167 | 1155 | ||
1168 | static void remove_old_osds(struct ceph_osd_client *osdc) | ||
1169 | { | ||
1170 | struct ceph_osd *osd, *nosd; | ||
1171 | |||
1172 | dout("__remove_old_osds %p\n", osdc); | ||
1173 | mutex_lock(&osdc->request_mutex); | ||
1174 | list_for_each_entry_safe(osd, nosd, &osdc->osd_lru, o_osd_lru) { | ||
1175 | if (time_before(jiffies, osd->lru_ttl)) | ||
1176 | break; | ||
1177 | remove_osd(osdc, osd); | ||
1178 | } | ||
1179 | mutex_unlock(&osdc->request_mutex); | ||
1180 | } | ||
1181 | |||
1182 | /* | 1156 | /* |
1183 | * reset osd connect | 1157 | * reset osd connect |
1184 | */ | 1158 | */ |
@@ -1671,12 +1645,21 @@ static void handle_osds_timeout(struct work_struct *work) | |||
1671 | container_of(work, struct ceph_osd_client, | 1645 | container_of(work, struct ceph_osd_client, |
1672 | osds_timeout_work.work); | 1646 | osds_timeout_work.work); |
1673 | unsigned long delay = osdc->client->options->osd_idle_ttl / 4; | 1647 | unsigned long delay = osdc->client->options->osd_idle_ttl / 4; |
1648 | struct ceph_osd *osd, *nosd; | ||
1674 | 1649 | ||
1675 | dout("osds timeout\n"); | 1650 | dout("%s osdc %p\n", __func__, osdc); |
1676 | down_read(&osdc->map_sem); | 1651 | down_read(&osdc->map_sem); |
1677 | remove_old_osds(osdc); | 1652 | mutex_lock(&osdc->request_mutex); |
1678 | up_read(&osdc->map_sem); | 1653 | |
1654 | list_for_each_entry_safe(osd, nosd, &osdc->osd_lru, o_osd_lru) { | ||
1655 | if (time_before(jiffies, osd->lru_ttl)) | ||
1656 | break; | ||
1657 | |||
1658 | remove_osd(osdc, osd); | ||
1659 | } | ||
1679 | 1660 | ||
1661 | mutex_unlock(&osdc->request_mutex); | ||
1662 | up_read(&osdc->map_sem); | ||
1680 | schedule_delayed_work(&osdc->osds_timeout_work, | 1663 | schedule_delayed_work(&osdc->osds_timeout_work, |
1681 | round_jiffies_relative(delay)); | 1664 | round_jiffies_relative(delay)); |
1682 | } | 1665 | } |
@@ -2722,11 +2705,19 @@ void ceph_osdc_stop(struct ceph_osd_client *osdc) | |||
2722 | destroy_workqueue(osdc->notify_wq); | 2705 | destroy_workqueue(osdc->notify_wq); |
2723 | cancel_delayed_work_sync(&osdc->timeout_work); | 2706 | cancel_delayed_work_sync(&osdc->timeout_work); |
2724 | cancel_delayed_work_sync(&osdc->osds_timeout_work); | 2707 | cancel_delayed_work_sync(&osdc->osds_timeout_work); |
2708 | |||
2709 | mutex_lock(&osdc->request_mutex); | ||
2710 | while (!RB_EMPTY_ROOT(&osdc->osds)) { | ||
2711 | struct ceph_osd *osd = rb_entry(rb_first(&osdc->osds), | ||
2712 | struct ceph_osd, o_node); | ||
2713 | remove_osd(osdc, osd); | ||
2714 | } | ||
2715 | mutex_unlock(&osdc->request_mutex); | ||
2716 | |||
2725 | if (osdc->osdmap) { | 2717 | if (osdc->osdmap) { |
2726 | ceph_osdmap_destroy(osdc->osdmap); | 2718 | ceph_osdmap_destroy(osdc->osdmap); |
2727 | osdc->osdmap = NULL; | 2719 | osdc->osdmap = NULL; |
2728 | } | 2720 | } |
2729 | remove_all_osds(osdc); | ||
2730 | mempool_destroy(osdc->req_mempool); | 2721 | mempool_destroy(osdc->req_mempool); |
2731 | ceph_msgpool_destroy(&osdc->msgpool_op); | 2722 | ceph_msgpool_destroy(&osdc->msgpool_op); |
2732 | ceph_msgpool_destroy(&osdc->msgpool_op_reply); | 2723 | ceph_msgpool_destroy(&osdc->msgpool_op_reply); |