Re: [PATCH] zswap: change BUG to WARN in zswap_writeback_entry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On (01/18/17 23:20), Dan Streetman wrote:
> Change the BUG calls to WARN, and return error.
> 
> There's no need to call BUG from this function, as it can safely return
> the error.  The only caller of this function is the zpool that zswap is
> using, when zswap is trying to reduce the zpool size.  While the error
> does indicate a bug, as none of the WARN conditions should ever happen,
> the zpool implementation can recover by trying to evict another page
> or zswap will recover by sending the new page to the swap disk.
> 
> This was reported in kernel bug 192571:
> https://bugzilla.kernel.org/show_bug.cgi?id=192571
> 
> Reported-by: Gluzskiy Alexandr <sss123next@xxxxxxx>
> Signed-off-by: Dan Streetman <ddstreet@xxxxxxxx>
> ---
>  mm/zswap.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/zswap.c b/mm/zswap.c
> index 067a0d6..60c4e6f 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -787,7 +787,10 @@ static int zswap_writeback_entry(struct zpool *pool, unsigned long handle)
>  		return 0;
>  	}
>  	spin_unlock(&tree->lock);
> -	BUG_ON(offset != entry->offset);
> +	if (WARN_ON(offset != entry->offset)) {
> +		ret = -EINVAL;
> +		goto fail;
> +	}
>  
>  	/* try to allocate swap cache page */
>  	switch (zswap_get_swap_cache_page(swpentry, &page)) {
> @@ -813,8 +816,13 @@ static int zswap_writeback_entry(struct zpool *pool, unsigned long handle)
>  		put_cpu_ptr(entry->pool->tfm);
>  		kunmap_atomic(dst);
>  		zpool_unmap_handle(entry->pool->zpool, entry->handle);
> -		BUG_ON(ret);
> -		BUG_ON(dlen != PAGE_SIZE);
> +		if (WARN(ret, "error decompressing page: %d\n", ret))
> +			goto fail;
> +		if (WARN(dlen != PAGE_SIZE,
> +			 "decompressed page only %x bytes\n", dlen)) {
> +			ret = -EINVAL;
> +			goto fail;
> +		}
>  
>  		/* page is up to date */
>  		SetPageUptodate(page);


+ zswap_frontswap_load() I suppose.

diff --git a/mm/zswap.c b/mm/zswap.c
index 067a0d62f318..e2743687a202 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -1023,13 +1023,13 @@ static int zswap_frontswap_load(unsigned type, pgoff_t offset,
        put_cpu_ptr(entry->pool->tfm);
        kunmap_atomic(dst);
        zpool_unmap_handle(entry->pool->zpool, entry->handle);
-       BUG_ON(ret);
+       WARN(ret, "error decompressing page: %d\n", ret);
 
        spin_lock(&tree->lock);
        zswap_entry_put(tree, entry);
        spin_unlock(&tree->lock);
 
-       return 0;
+       return ret;
 }

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]