Whamcloud - gitweb
LU-9859 tracefile: convert list_for_each_entry_safe() to while(!list_empty()) 70/41670/4
authorNeilBrown <neilb@suse.de>
Mon, 15 Feb 2021 14:57:07 +0000 (09:57 -0500)
committerOleg Drokin <green@whamcloud.com>
Sat, 6 Mar 2021 02:35:42 +0000 (02:35 +0000)
These loops are removing all elements from a list.
So using while(!list_empty()) makes the intent clearer.

Linux-commit: fdafb01e2c70e6b5321d158a2ff1f20a13d9b365

Change-Id: Idda25888e424a1deaa4d7c6fad427d494b1f56e5
Signed-off-by: NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/41670
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/tracefile.c

index 7acc5bb..d3a0803 100644 (file)
@@ -858,12 +858,12 @@ void cfs_trace_flush_pages(void)
 {
        struct page_collection pc;
        struct cfs_trace_page *tage;
 {
        struct page_collection pc;
        struct cfs_trace_page *tage;
-       struct cfs_trace_page *tmp;
 
        pc.pc_want_daemon_pages = 1;
        collect_pages(&pc);
 
        pc.pc_want_daemon_pages = 1;
        collect_pages(&pc);
-       list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) {
-
+       while (!list_empty(&pc.pc_pages)) {
+               tage = list_first_entry(&pc.pc_pages,
+                                       struct cfs_trace_page, linkage);
                __LASSERT_TAGE_INVARIANT(tage);
 
                list_del(&tage->linkage);
                __LASSERT_TAGE_INVARIANT(tage);
 
                list_del(&tage->linkage);
@@ -1280,7 +1280,6 @@ static void trace_cleanup_on_all_cpus(void)
 {
        struct cfs_trace_cpu_data *tcd;
        struct cfs_trace_page *tage;
 {
        struct cfs_trace_cpu_data *tcd;
        struct cfs_trace_page *tage;
-       struct cfs_trace_page *tmp;
        int i, cpu;
 
        for_each_possible_cpu(cpu) {
        int i, cpu;
 
        for_each_possible_cpu(cpu) {
@@ -1290,7 +1289,10 @@ static void trace_cleanup_on_all_cpus(void)
                                continue;
                        tcd->tcd_shutting_down = 1;
 
                                continue;
                        tcd->tcd_shutting_down = 1;
 
-                       list_for_each_entry_safe(tage, tmp, &tcd->tcd_pages, linkage) {
+                       while (!list_empty(&tcd->tcd_pages)) {
+                               tage = list_first_entry(&tcd->tcd_pages,
+                                                       struct cfs_trace_page,
+                                                       linkage);
                                __LASSERT_TAGE_INVARIANT(tage);
 
                                list_del(&tage->linkage);
                                __LASSERT_TAGE_INVARIANT(tage);
 
                                list_del(&tage->linkage);