Commit 9a6a676e authored by Gao Xiang's avatar Gao Xiang Committed by Greg Kroah-Hartman

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

commit 70b17991 upstream.

remove all redundant BUG_ONs, and turn the rest
useful usages to DBG_BUGONs.
Signed-off-by: default avatarGao Xiang <gaoxiang25@huawei.com>
Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bea01ea0
...@@ -150,7 +150,7 @@ z_erofs_pagevec_ctor_dequeue(struct z_erofs_pagevec_ctor *ctor, ...@@ -150,7 +150,7 @@ z_erofs_pagevec_ctor_dequeue(struct z_erofs_pagevec_ctor *ctor,
erofs_vtptr_t t; erofs_vtptr_t t;
if (unlikely(ctor->index >= ctor->nr)) { if (unlikely(ctor->index >= ctor->nr)) {
BUG_ON(ctor->next == NULL); DBG_BUGON(!ctor->next);
z_erofs_pagevec_ctor_pagedown(ctor, true); z_erofs_pagevec_ctor_pagedown(ctor, true);
} }
......
...@@ -18,9 +18,6 @@ static struct kmem_cache *z_erofs_workgroup_cachep __read_mostly; ...@@ -18,9 +18,6 @@ static struct kmem_cache *z_erofs_workgroup_cachep __read_mostly;
void z_erofs_exit_zip_subsystem(void) void z_erofs_exit_zip_subsystem(void)
{ {
BUG_ON(z_erofs_workqueue == NULL);
BUG_ON(z_erofs_workgroup_cachep == NULL);
destroy_workqueue(z_erofs_workqueue); destroy_workqueue(z_erofs_workqueue);
kmem_cache_destroy(z_erofs_workgroup_cachep); kmem_cache_destroy(z_erofs_workgroup_cachep);
} }
...@@ -363,7 +360,10 @@ z_erofs_vle_work_register(struct super_block *sb, ...@@ -363,7 +360,10 @@ z_erofs_vle_work_register(struct super_block *sb,
struct z_erofs_vle_work *work; struct z_erofs_vle_work *work;
/* if multiref is disabled, grp should never be nullptr */ /* if multiref is disabled, grp should never be nullptr */
BUG_ON(grp != NULL); if (unlikely(grp)) {
DBG_BUGON(1);
return ERR_PTR(-EINVAL);
}
/* no available workgroup, let's allocate one */ /* no available workgroup, let's allocate one */
grp = kmem_cache_zalloc(z_erofs_workgroup_cachep, GFP_NOFS); grp = kmem_cache_zalloc(z_erofs_workgroup_cachep, GFP_NOFS);
...@@ -742,7 +742,7 @@ static inline void z_erofs_vle_read_endio(struct bio *bio) ...@@ -742,7 +742,7 @@ static inline void z_erofs_vle_read_endio(struct bio *bio)
bool cachemngd = false; bool cachemngd = false;
DBG_BUGON(PageUptodate(page)); DBG_BUGON(PageUptodate(page));
BUG_ON(page->mapping == NULL); DBG_BUGON(!page->mapping);
#ifdef EROFS_FS_HAS_MANAGED_CACHE #ifdef EROFS_FS_HAS_MANAGED_CACHE
if (unlikely(mngda == NULL && !z_erofs_is_stagingpage(page))) { if (unlikely(mngda == NULL && !z_erofs_is_stagingpage(page))) {
...@@ -800,7 +800,7 @@ static int z_erofs_vle_unzip(struct super_block *sb, ...@@ -800,7 +800,7 @@ static int z_erofs_vle_unzip(struct super_block *sb,
might_sleep(); might_sleep();
work = z_erofs_vle_grab_primary_work(grp); work = z_erofs_vle_grab_primary_work(grp);
BUG_ON(!READ_ONCE(work->nr_pages)); DBG_BUGON(!READ_ONCE(work->nr_pages));
mutex_lock(&work->lock); mutex_lock(&work->lock);
nr_pages = work->nr_pages; nr_pages = work->nr_pages;
...@@ -849,8 +849,8 @@ static int z_erofs_vle_unzip(struct super_block *sb, ...@@ -849,8 +849,8 @@ static int z_erofs_vle_unzip(struct super_block *sb,
else else
pagenr = z_erofs_onlinepage_index(page); pagenr = z_erofs_onlinepage_index(page);
BUG_ON(pagenr >= nr_pages); DBG_BUGON(pagenr >= nr_pages);
BUG_ON(pages[pagenr] != NULL); DBG_BUGON(pages[pagenr]);
pages[pagenr] = page; pages[pagenr] = page;
} }
...@@ -873,9 +873,8 @@ static int z_erofs_vle_unzip(struct super_block *sb, ...@@ -873,9 +873,8 @@ static int z_erofs_vle_unzip(struct super_block *sb,
if (z_erofs_is_stagingpage(page)) if (z_erofs_is_stagingpage(page))
continue; continue;
#ifdef EROFS_FS_HAS_MANAGED_CACHE #ifdef EROFS_FS_HAS_MANAGED_CACHE
else if (page->mapping == mngda) { if (page->mapping == mngda) {
BUG_ON(PageLocked(page)); DBG_BUGON(!PageUptodate(page));
BUG_ON(!PageUptodate(page));
continue; continue;
} }
#endif #endif
...@@ -883,8 +882,8 @@ static int z_erofs_vle_unzip(struct super_block *sb, ...@@ -883,8 +882,8 @@ static int z_erofs_vle_unzip(struct super_block *sb,
/* only non-head page could be reused as a compressed page */ /* only non-head page could be reused as a compressed page */
pagenr = z_erofs_onlinepage_index(page); pagenr = z_erofs_onlinepage_index(page);
BUG_ON(pagenr >= nr_pages); DBG_BUGON(pagenr >= nr_pages);
BUG_ON(pages[pagenr] != NULL); DBG_BUGON(pages[pagenr]);
++sparsemem_pages; ++sparsemem_pages;
pages[pagenr] = page; pages[pagenr] = page;
...@@ -894,9 +893,6 @@ static int z_erofs_vle_unzip(struct super_block *sb, ...@@ -894,9 +893,6 @@ static int z_erofs_vle_unzip(struct super_block *sb,
llen = (nr_pages << PAGE_SHIFT) - work->pageofs; llen = (nr_pages << PAGE_SHIFT) - work->pageofs;
if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) { if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) {
/* FIXME! this should be fixed in the future */
BUG_ON(grp->llen != llen);
err = z_erofs_vle_plain_copy(compressed_pages, clusterpages, err = z_erofs_vle_plain_copy(compressed_pages, clusterpages,
pages, nr_pages, work->pageofs); pages, nr_pages, work->pageofs);
goto out; goto out;
...@@ -911,10 +907,8 @@ static int z_erofs_vle_unzip(struct super_block *sb, ...@@ -911,10 +907,8 @@ static int z_erofs_vle_unzip(struct super_block *sb,
if (err != -ENOTSUPP) if (err != -ENOTSUPP)
goto out_percpu; goto out_percpu;
if (sparsemem_pages >= nr_pages) { if (sparsemem_pages >= nr_pages)
BUG_ON(sparsemem_pages > nr_pages);
goto skip_allocpage; goto skip_allocpage;
}
for (i = 0; i < nr_pages; ++i) { for (i = 0; i < nr_pages; ++i) {
if (pages[i] != NULL) if (pages[i] != NULL)
...@@ -1007,7 +1001,7 @@ static void z_erofs_vle_unzip_wq(struct work_struct *work) ...@@ -1007,7 +1001,7 @@ static void z_erofs_vle_unzip_wq(struct work_struct *work)
struct z_erofs_vle_unzip_io_sb, io.u.work); struct z_erofs_vle_unzip_io_sb, io.u.work);
LIST_HEAD(page_pool); LIST_HEAD(page_pool);
BUG_ON(iosb->io.head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); DBG_BUGON(iosb->io.head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED);
z_erofs_vle_unzip_all(iosb->sb, &iosb->io, &page_pool); z_erofs_vle_unzip_all(iosb->sb, &iosb->io, &page_pool);
put_pages_list(&page_pool); put_pages_list(&page_pool);
...@@ -1336,7 +1330,6 @@ static inline int __z_erofs_vle_normalaccess_readpages( ...@@ -1336,7 +1330,6 @@ static inline int __z_erofs_vle_normalaccess_readpages(
continue; continue;
} }
BUG_ON(PagePrivate(page));
set_page_private(page, (unsigned long)head); set_page_private(page, (unsigned long)head);
head = page; head = page;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment