All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gao Xiang <gaoxiang25@huawei.com>
To: <stable@vger.kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Chao Yu <yuchao0@huawei.com>, <linux-erofs@lists.ozlabs.org>,
	<miaoxie@huawei.com>, Chen Gong <gongchen4@huawei.com>,
	Gao Xiang <gaoxiang25@huawei.com>
Subject: [PATCH for-4.19 03/12] staging: erofs: replace BUG_ON with DBG_BUGON in data.c
Date: Wed, 20 Feb 2019 17:18:45 +0800	[thread overview]
Message-ID: <20190220091854.19242-4-gaoxiang25@huawei.com> (raw)
In-Reply-To: <20190220091854.19242-1-gaoxiang25@huawei.com>

From: Chen Gong <gongchen4@huawei.com>

commit 9141b60cf6a53c99f8a9309bf8e1c6650a6785c1 upstream.

This patch replace BUG_ON with DBG_BUGON in data.c, and add necessary
error handler.

Signed-off-by: Chen Gong <gongchen4@huawei.com>
Reviewed-by: Gao Xiang <gaoxiang25@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/data.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c
index ac263a180253..894e60ecebe2 100644
--- a/drivers/staging/erofs/data.c
+++ b/drivers/staging/erofs/data.c
@@ -25,7 +25,7 @@ static inline void read_endio(struct bio *bio)
 		struct page *page = bvec->bv_page;
 
 		/* page is already locked */
-		BUG_ON(PageUptodate(page));
+		DBG_BUGON(PageUptodate(page));
 
 		if (unlikely(err))
 			SetPageError(page);
@@ -91,12 +91,12 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
 	struct erofs_map_blocks *map,
 	int flags)
 {
+	int err = 0;
 	erofs_blk_t nblocks, lastblk;
 	u64 offset = map->m_la;
 	struct erofs_vnode *vi = EROFS_V(inode);
 
 	trace_erofs_map_blocks_flatmode_enter(inode, map, flags);
-	BUG_ON(is_inode_layout_compression(inode));
 
 	nblocks = DIV_ROUND_UP(inode->i_size, PAGE_SIZE);
 	lastblk = nblocks - is_inode_layout_inline(inode);
@@ -123,18 +123,27 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
 		map->m_plen = inode->i_size - offset;
 
 		/* inline data should locate in one meta block */
-		BUG_ON(erofs_blkoff(map->m_pa) + map->m_plen > PAGE_SIZE);
+		if (erofs_blkoff(map->m_pa) + map->m_plen > PAGE_SIZE) {
+			DBG_BUGON(1);
+			err = -EIO;
+			goto err_out;
+		}
+
 		map->m_flags |= EROFS_MAP_META;
 	} else {
 		errln("internal error @ nid: %llu (size %llu), m_la 0x%llx",
 			vi->nid, inode->i_size, map->m_la);
-		BUG();
+		DBG_BUGON(1);
+		err = -EIO;
+		goto err_out;
 	}
 
 out:
 	map->m_llen = map->m_plen;
+
+err_out:
 	trace_erofs_map_blocks_flatmode_exit(inode, map, flags, 0);
-	return 0;
+	return err;
 }
 
 #ifdef CONFIG_EROFS_FS_ZIP
@@ -190,7 +199,7 @@ static inline struct bio *erofs_read_raw_page(
 	erofs_off_t current_block = (erofs_off_t)page->index;
 	int err;
 
-	BUG_ON(!nblocks);
+	DBG_BUGON(!nblocks);
 
 	if (PageUptodate(page)) {
 		err = 0;
@@ -233,7 +242,7 @@ static inline struct bio *erofs_read_raw_page(
 		}
 
 		/* for RAW access mode, m_plen must be equal to m_llen */
-		BUG_ON(map.m_plen != map.m_llen);
+		DBG_BUGON(map.m_plen != map.m_llen);
 
 		blknr = erofs_blknr(map.m_pa);
 		blkoff = erofs_blkoff(map.m_pa);
@@ -243,7 +252,7 @@ static inline struct bio *erofs_read_raw_page(
 			void *vsrc, *vto;
 			struct page *ipage;
 
-			BUG_ON(map.m_plen > PAGE_SIZE);
+			DBG_BUGON(map.m_plen > PAGE_SIZE);
 
 			ipage = erofs_get_meta_page(inode->i_sb, blknr, 0);
 
@@ -270,7 +279,7 @@ static inline struct bio *erofs_read_raw_page(
 		}
 
 		/* pa must be block-aligned for raw reading */
-		BUG_ON(erofs_blkoff(map.m_pa) != 0);
+		DBG_BUGON(erofs_blkoff(map.m_pa));
 
 		/* max # of continuous pages */
 		if (nblocks > DIV_ROUND_UP(map.m_plen, PAGE_SIZE))
@@ -331,7 +340,7 @@ static int erofs_raw_access_readpage(struct file *file, struct page *page)
 	if (IS_ERR(bio))
 		return PTR_ERR(bio);
 
-	BUG_ON(bio != NULL);	/* since we have only one bio -- must be NULL */
+	DBG_BUGON(bio);	/* since we have only one bio -- must be NULL */
 	return 0;
 }
 
@@ -369,7 +378,7 @@ static int erofs_raw_access_readpages(struct file *filp,
 		/* pages could still be locked */
 		put_page(page);
 	}
-	BUG_ON(!list_empty(pages));
+	DBG_BUGON(!list_empty(pages));
 
 	/* the rare case (end in gaps) */
 	if (unlikely(bio != NULL))
-- 
2.14.4


WARNING: multiple messages have this Message-ID (diff)
From: gaoxiang25@huawei.com (Gao Xiang)
Subject: [PATCH for-4.19 03/12] staging: erofs: replace BUG_ON with DBG_BUGON in data.c
Date: Wed, 20 Feb 2019 17:18:45 +0800	[thread overview]
Message-ID: <20190220091854.19242-4-gaoxiang25@huawei.com> (raw)
In-Reply-To: <20190220091854.19242-1-gaoxiang25@huawei.com>

From: Chen Gong <gongchen4@huawei.com>

commit 9141b60cf6a53c99f8a9309bf8e1c6650a6785c1 upstream.

This patch replace BUG_ON with DBG_BUGON in data.c, and add necessary
error handler.

Signed-off-by: Chen Gong <gongchen4 at huawei.com>
Reviewed-by: Gao Xiang <gaoxiang25 at huawei.com>
Reviewed-by: Chao Yu <yuchao0 at huawei.com>
Signed-off-by: Gao Xiang <gaoxiang25 at huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
Signed-off-by: Gao Xiang <gaoxiang25 at huawei.com>
---
 drivers/staging/erofs/data.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c
index ac263a180253..894e60ecebe2 100644
--- a/drivers/staging/erofs/data.c
+++ b/drivers/staging/erofs/data.c
@@ -25,7 +25,7 @@ static inline void read_endio(struct bio *bio)
 		struct page *page = bvec->bv_page;
 
 		/* page is already locked */
-		BUG_ON(PageUptodate(page));
+		DBG_BUGON(PageUptodate(page));
 
 		if (unlikely(err))
 			SetPageError(page);
@@ -91,12 +91,12 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
 	struct erofs_map_blocks *map,
 	int flags)
 {
+	int err = 0;
 	erofs_blk_t nblocks, lastblk;
 	u64 offset = map->m_la;
 	struct erofs_vnode *vi = EROFS_V(inode);
 
 	trace_erofs_map_blocks_flatmode_enter(inode, map, flags);
-	BUG_ON(is_inode_layout_compression(inode));
 
 	nblocks = DIV_ROUND_UP(inode->i_size, PAGE_SIZE);
 	lastblk = nblocks - is_inode_layout_inline(inode);
@@ -123,18 +123,27 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
 		map->m_plen = inode->i_size - offset;
 
 		/* inline data should locate in one meta block */
-		BUG_ON(erofs_blkoff(map->m_pa) + map->m_plen > PAGE_SIZE);
+		if (erofs_blkoff(map->m_pa) + map->m_plen > PAGE_SIZE) {
+			DBG_BUGON(1);
+			err = -EIO;
+			goto err_out;
+		}
+
 		map->m_flags |= EROFS_MAP_META;
 	} else {
 		errln("internal error @ nid: %llu (size %llu), m_la 0x%llx",
 			vi->nid, inode->i_size, map->m_la);
-		BUG();
+		DBG_BUGON(1);
+		err = -EIO;
+		goto err_out;
 	}
 
 out:
 	map->m_llen = map->m_plen;
+
+err_out:
 	trace_erofs_map_blocks_flatmode_exit(inode, map, flags, 0);
-	return 0;
+	return err;
 }
 
 #ifdef CONFIG_EROFS_FS_ZIP
@@ -190,7 +199,7 @@ static inline struct bio *erofs_read_raw_page(
 	erofs_off_t current_block = (erofs_off_t)page->index;
 	int err;
 
-	BUG_ON(!nblocks);
+	DBG_BUGON(!nblocks);
 
 	if (PageUptodate(page)) {
 		err = 0;
@@ -233,7 +242,7 @@ static inline struct bio *erofs_read_raw_page(
 		}
 
 		/* for RAW access mode, m_plen must be equal to m_llen */
-		BUG_ON(map.m_plen != map.m_llen);
+		DBG_BUGON(map.m_plen != map.m_llen);
 
 		blknr = erofs_blknr(map.m_pa);
 		blkoff = erofs_blkoff(map.m_pa);
@@ -243,7 +252,7 @@ static inline struct bio *erofs_read_raw_page(
 			void *vsrc, *vto;
 			struct page *ipage;
 
-			BUG_ON(map.m_plen > PAGE_SIZE);
+			DBG_BUGON(map.m_plen > PAGE_SIZE);
 
 			ipage = erofs_get_meta_page(inode->i_sb, blknr, 0);
 
@@ -270,7 +279,7 @@ static inline struct bio *erofs_read_raw_page(
 		}
 
 		/* pa must be block-aligned for raw reading */
-		BUG_ON(erofs_blkoff(map.m_pa) != 0);
+		DBG_BUGON(erofs_blkoff(map.m_pa));
 
 		/* max # of continuous pages */
 		if (nblocks > DIV_ROUND_UP(map.m_plen, PAGE_SIZE))
@@ -331,7 +340,7 @@ static int erofs_raw_access_readpage(struct file *file, struct page *page)
 	if (IS_ERR(bio))
 		return PTR_ERR(bio);
 
-	BUG_ON(bio != NULL);	/* since we have only one bio -- must be NULL */
+	DBG_BUGON(bio);	/* since we have only one bio -- must be NULL */
 	return 0;
 }
 
@@ -369,7 +378,7 @@ static int erofs_raw_access_readpages(struct file *filp,
 		/* pages could still be locked */
 		put_page(page);
 	}
-	BUG_ON(!list_empty(pages));
+	DBG_BUGON(!list_empty(pages));
 
 	/* the rare case (end in gaps) */
 	if (unlikely(bio != NULL))
-- 
2.14.4

  parent reply	other threads:[~2019-02-20  9:21 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-20  9:18 [PATCH for-4.19 00/12] erofs fixes for linux-4.19.y Gao Xiang
2019-02-20  9:18 ` Gao Xiang
2019-02-20  9:18 ` [PATCH for-4.19 01/12] staging: erofs: fix a bug when appling cache strategy Gao Xiang
2019-02-20  9:18   ` Gao Xiang
2019-02-20  9:18 ` [PATCH for-4.19 02/12] staging: erofs: complete error handing of z_erofs_do_read_page Gao Xiang
2019-02-20  9:18   ` Gao Xiang
2019-02-25 14:59   ` Greg Kroah-Hartman
2019-02-25 14:59     ` Greg Kroah-Hartman
2019-02-25 15:04     ` Gao Xiang
2019-02-25 15:04       ` Gao Xiang
2019-02-20  9:18 ` Gao Xiang [this message]
2019-02-20  9:18   ` [PATCH for-4.19 03/12] staging: erofs: replace BUG_ON with DBG_BUGON in data.c Gao Xiang
2019-02-20  9:18 ` [PATCH for-4.19 04/12] staging: erofs: drop multiref support temporarily Gao Xiang
2019-02-20  9:18   ` Gao Xiang
2019-02-20  9:18 ` [PATCH for-4.19 05/12] staging: erofs: remove the redundant d_rehash() for the root dentry Gao Xiang
2019-02-20  9:18   ` Gao Xiang
2019-02-20  9:18 ` [PATCH for-4.19 06/12] staging: erofs: fix race when the managed cache is enabled Gao Xiang
2019-02-20  9:18   ` Gao Xiang
2019-02-25 15:04   ` Greg Kroah-Hartman
2019-02-25 15:04     ` Greg Kroah-Hartman
2019-02-25 15:07     ` Gao Xiang
2019-02-25 15:07       ` Gao Xiang
2019-02-25 15:51       ` Greg Kroah-Hartman
2019-02-25 15:51         ` Greg Kroah-Hartman
2019-02-25 15:57         ` Gao Xiang
2019-02-25 15:57           ` Gao Xiang
2019-02-25 17:58         ` [PATCH for-4.19 1/2] xarray: Replace exceptional entries Gao Xiang
2019-02-25 17:58           ` Gao Xiang
2019-02-25 17:58           ` [PATCH for-4.19 2/2] staging: erofs: fix race when the managed cache is enabled Gao Xiang
2019-02-25 17:58             ` Gao Xiang
2019-02-25 18:27           ` [PATCH for-4.19 1/2] xarray: Replace exceptional entries Matthew Wilcox
2019-02-25 18:27             ` Matthew Wilcox
2019-02-26  1:21             ` Gao Xiang
2019-02-26  1:21               ` Gao Xiang
2019-02-26  5:14             ` [PATCH v2 " Gao Xiang
2019-02-26  5:14               ` Gao Xiang
2019-02-26  5:14               ` [PATCH v2 for-4.19 2/2] staging: erofs: fix race when the managed cache is enabled Gao Xiang
2019-02-26  5:14                 ` Gao Xiang
2019-02-26 12:43               ` [PATCH v2 for-4.19 1/2] xarray: Replace exceptional entries Gao Xiang
2019-02-26 12:43                 ` Gao Xiang
2019-03-04  5:13                 ` Gao Xiang
2019-03-04  5:13                   ` Gao Xiang
2019-03-13  9:18                   ` Gao Xiang
2019-03-13  9:18                     ` Gao Xiang
2019-02-25 15:25     ` [PATCH for-4.19 06/12] staging: erofs: fix race when the managed cache is enabled Matthew Wilcox
2019-02-25 15:25       ` Matthew Wilcox
2019-02-25 15:52       ` Greg Kroah-Hartman
2019-02-25 15:52         ` Greg Kroah-Hartman
2019-02-25 16:04         ` Matthew Wilcox
2019-02-25 16:04           ` Matthew Wilcox
2019-02-20  9:18 ` [PATCH for-4.19 07/12] staging: erofs: atomic_cond_read_relaxed on ref-locked workgroup Gao Xiang
2019-02-20  9:18   ` Gao Xiang
2019-02-20  9:18 ` [PATCH for-4.19 08/12] staging: erofs: fix `erofs_workgroup_{try_to_freeze, unfreeze}' Gao Xiang
2019-02-20  9:18   ` Gao Xiang
2019-02-20  9:18 ` [PATCH for-4.19 09/12] staging: erofs: add a full barrier in erofs_workgroup_unfreeze Gao Xiang
2019-02-20  9:18   ` Gao Xiang
2019-02-20  9:18 ` [PATCH for-4.19 10/12] staging: erofs: {dir,inode,super}.c: rectify BUG_ONs Gao Xiang
2019-02-20  9:18   ` [PATCH for-4.19 10/12] staging: erofs: {dir, inode, super}.c: " Gao Xiang
2019-02-20  9:18 ` [PATCH for-4.19 11/12] staging: erofs: unzip_{pagevec.h,vle.c}: " Gao Xiang
2019-02-20  9:18   ` [PATCH for-4.19 11/12] staging: erofs: unzip_{pagevec.h, vle.c}: " Gao Xiang
2019-02-20  9:18 ` [PATCH for-4.19 12/12] staging: erofs: unzip_vle_lz4.c,utils.c: " Gao Xiang
2019-02-20  9:18   ` [PATCH for-4.19 12/12] staging: erofs: unzip_vle_lz4.c, utils.c: " Gao Xiang
2019-02-22  8:35 ` [PATCH for-4.19 00/12] erofs fixes for linux-4.19.y Greg Kroah-Hartman
2019-02-22  8:35   ` Greg Kroah-Hartman
2019-02-22  9:03   ` Gao Xiang
2019-02-22  9:03     ` Gao Xiang
2019-02-25 15:28 ` Greg Kroah-Hartman
2019-02-25 15:28   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190220091854.19242-4-gaoxiang25@huawei.com \
    --to=gaoxiang25@huawei.com \
    --cc=gongchen4@huawei.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=miaoxie@huawei.com \
    --cc=stable@vger.kernel.org \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.