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

staging: erofs: unzip_{pagevec.h,vle.c}: rectify BUG_ONs

remove all redundant BUG_ONs, and turn the rest
useful usages to DBG_BUGONs.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Gao Xiang and committed by
Greg Kroah-Hartman
70b17991 d3086550

+14 -21
+1 -1
drivers/staging/erofs/unzip_pagevec.h
··· 150 150 erofs_vtptr_t t; 151 151 152 152 if (unlikely(ctor->index >= ctor->nr)) { 153 - BUG_ON(ctor->next == NULL); 153 + DBG_BUGON(!ctor->next); 154 154 z_erofs_pagevec_ctor_pagedown(ctor, true); 155 155 } 156 156
+13 -20
drivers/staging/erofs/unzip_vle.c
··· 41 41 42 42 void z_erofs_exit_zip_subsystem(void) 43 43 { 44 - BUG_ON(!z_erofs_workqueue); 45 - BUG_ON(!z_erofs_workgroup_cachep); 46 - 47 44 destroy_workqueue(z_erofs_workqueue); 48 45 kmem_cache_destroy(z_erofs_workgroup_cachep); 49 46 } ··· 442 445 struct z_erofs_vle_work *work; 443 446 444 447 /* if multiref is disabled, grp should never be nullptr */ 445 - BUG_ON(grp); 448 + if (unlikely(grp)) { 449 + DBG_BUGON(1); 450 + return ERR_PTR(-EINVAL); 451 + } 446 452 447 453 /* no available workgroup, let's allocate one */ 448 454 grp = kmem_cache_alloc(z_erofs_workgroup_cachep, GFP_NOFS); ··· 836 836 bool cachemngd = false; 837 837 838 838 DBG_BUGON(PageUptodate(page)); 839 - BUG_ON(!page->mapping); 839 + DBG_BUGON(!page->mapping); 840 840 841 841 #ifdef EROFS_FS_HAS_MANAGED_CACHE 842 842 if (unlikely(!mc && !z_erofs_is_stagingpage(page))) { ··· 891 891 892 892 might_sleep(); 893 893 work = z_erofs_vle_grab_primary_work(grp); 894 - BUG_ON(!READ_ONCE(work->nr_pages)); 894 + DBG_BUGON(!READ_ONCE(work->nr_pages)); 895 895 896 896 mutex_lock(&work->lock); 897 897 nr_pages = work->nr_pages; ··· 940 940 else 941 941 pagenr = z_erofs_onlinepage_index(page); 942 942 943 - BUG_ON(pagenr >= nr_pages); 944 - BUG_ON(pages[pagenr]); 943 + DBG_BUGON(pagenr >= nr_pages); 944 + DBG_BUGON(pages[pagenr]); 945 945 946 946 pages[pagenr] = page; 947 947 } ··· 965 965 continue; 966 966 #ifdef EROFS_FS_HAS_MANAGED_CACHE 967 967 if (page->mapping == MNGD_MAPPING(sbi)) { 968 - BUG_ON(PageLocked(page)); 969 - BUG_ON(!PageUptodate(page)); 968 + DBG_BUGON(!PageUptodate(page)); 970 969 continue; 971 970 } 972 971 #endif ··· 973 974 /* only non-head page could be reused as a compressed page */ 974 975 pagenr = z_erofs_onlinepage_index(page); 975 976 976 - BUG_ON(pagenr >= nr_pages); 977 - BUG_ON(pages[pagenr]); 977 + DBG_BUGON(pagenr >= nr_pages); 978 + DBG_BUGON(pages[pagenr]); 978 979 ++sparsemem_pages; 979 980 pages[pagenr] = page; 980 981 ··· 984 985 llen = (nr_pages << PAGE_SHIFT) - work->pageofs; 985 986 986 987 if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) { 987 - /* FIXME! this should be fixed in the future */ 988 - BUG_ON(grp->llen != llen); 989 - 990 988 err = z_erofs_vle_plain_copy(compressed_pages, clusterpages, 991 989 pages, nr_pages, work->pageofs); 992 990 goto out; ··· 998 1002 if (err != -ENOTSUPP) 999 1003 goto out_percpu; 1000 1004 1001 - if (sparsemem_pages >= nr_pages) { 1002 - BUG_ON(sparsemem_pages > nr_pages); 1005 + if (sparsemem_pages >= nr_pages) 1003 1006 goto skip_allocpage; 1004 - } 1005 1007 1006 1008 for (i = 0; i < nr_pages; ++i) { 1007 1009 if (pages[i]) ··· 1092 1098 struct z_erofs_vle_unzip_io_sb, io.u.work); 1093 1099 LIST_HEAD(page_pool); 1094 1100 1095 - BUG_ON(iosb->io.head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); 1101 + DBG_BUGON(iosb->io.head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); 1096 1102 z_erofs_vle_unzip_all(iosb->sb, &iosb->io, &page_pool); 1097 1103 1098 1104 put_pages_list(&page_pool); ··· 1529 1535 continue; 1530 1536 } 1531 1537 1532 - BUG_ON(PagePrivate(page)); 1533 1538 set_page_private(page, (unsigned long)head); 1534 1539 head = page; 1535 1540 }