ceph: Fix infinite loop in __wake_requests
authorYan, Zheng <zheng.z.yan@intel.com>
Mon, 19 Nov 2012 02:49:06 +0000 (10:49 +0800)
committerAlex Elder <elder@inktank.com>
Thu, 13 Dec 2012 14:13:07 +0000 (08:13 -0600)
__wake_requests() will enter infinite loop if we use it to wake
requests in the session->s_waiting list. __wake_requests() deletes
requests from the list and __do_request() adds requests back to
the list.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Signed-off-by: Sage Weil <sage@inktank.com>
fs/ceph/mds_client.c

index 62d2342..9165eb8 100644 (file)
@@ -1876,9 +1876,14 @@ finish:
 static void __wake_requests(struct ceph_mds_client *mdsc,
                            struct list_head *head)
 {
-       struct ceph_mds_request *req, *nreq;
+       struct ceph_mds_request *req;
+       LIST_HEAD(tmp_list);
+
+       list_splice_init(head, &tmp_list);
 
-       list_for_each_entry_safe(req, nreq, head, r_wait) {
+       while (!list_empty(&tmp_list)) {
+               req = list_entry(tmp_list.next,
+                                struct ceph_mds_request, r_wait);
                list_del_init(&req->r_wait);
                __do_request(mdsc, req);
        }