Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+21 -30
+21 -30
net/ceph/osd_client.c
··· 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 1129 static void __move_osd_to_lru(struct ceph_osd_client *osdc, 1142 1130 struct ceph_osd *osd) 1143 1131 { ··· 1151 1163 dout("__remove_osd_from_lru %p\n", osd); 1152 1164 if (!list_empty(&osd->o_osd_lru)) 1153 1165 list_del_init(&osd->o_osd_lru); 1154 - } 1155 - 1156 - static void remove_old_osds(struct ceph_osd_client *osdc) 1157 - { 1158 - struct ceph_osd *osd, *nosd; 1159 - 1160 - dout("__remove_old_osds %p\n", osdc); 1161 - mutex_lock(&osdc->request_mutex); 1162 - list_for_each_entry_safe(osd, nosd, &osdc->osd_lru, o_osd_lru) { 1163 - if (time_before(jiffies, osd->lru_ttl)) 1164 - break; 1165 - remove_osd(osdc, osd); 1166 - } 1167 - mutex_unlock(&osdc->request_mutex); 1168 1166 } 1169 1167 1170 1168 /* ··· 1645 1671 container_of(work, struct ceph_osd_client, 1646 1672 osds_timeout_work.work); 1647 1673 unsigned long delay = osdc->client->options->osd_idle_ttl / 4; 1674 + struct ceph_osd *osd, *nosd; 1648 1675 1649 - dout("osds timeout\n"); 1676 + dout("%s osdc %p\n", __func__, osdc); 1650 1677 down_read(&osdc->map_sem); 1651 - remove_old_osds(osdc); 1652 - up_read(&osdc->map_sem); 1678 + mutex_lock(&osdc->request_mutex); 1653 1679 1680 + list_for_each_entry_safe(osd, nosd, &osdc->osd_lru, o_osd_lru) { 1681 + if (time_before(jiffies, osd->lru_ttl)) 1682 + break; 1683 + 1684 + remove_osd(osdc, osd); 1685 + } 1686 + 1687 + mutex_unlock(&osdc->request_mutex); 1688 + up_read(&osdc->map_sem); 1654 1689 schedule_delayed_work(&osdc->osds_timeout_work, 1655 1690 round_jiffies_relative(delay)); 1656 1691 } ··· 2705 2722 destroy_workqueue(osdc->notify_wq); 2706 2723 cancel_delayed_work_sync(&osdc->timeout_work); 2707 2724 cancel_delayed_work_sync(&osdc->osds_timeout_work); 2725 + 2726 + mutex_lock(&osdc->request_mutex); 2727 + while (!RB_EMPTY_ROOT(&osdc->osds)) { 2728 + struct ceph_osd *osd = rb_entry(rb_first(&osdc->osds), 2729 + struct ceph_osd, o_node); 2730 + remove_osd(osdc, osd); 2731 + } 2732 + mutex_unlock(&osdc->request_mutex); 2733 + 2708 2734 if (osdc->osdmap) { 2709 2735 ceph_osdmap_destroy(osdc->osdmap); 2710 2736 osdc->osdmap = NULL; 2711 2737 } 2712 - remove_all_osds(osdc); 2713 2738 mempool_destroy(osdc->req_mempool); 2714 2739 ceph_msgpool_destroy(&osdc->msgpool_op); 2715 2740 ceph_msgpool_destroy(&osdc->msgpool_op_reply);