zram: cosmetic zram_bvec_write() cleanup
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Thu, 25 Jun 2015 22:00:27 +0000 (15:00 -0700)
committerDanny Wood <danwood76@gmail.com>
Tue, 14 Sep 2021 19:01:35 +0000 (20:01 +0100)
`bool locked' local variable tells us if we should perform
zcomp_strm_release() or not (jumped to `out' label before
zcomp_strm_find() occurred), which is equivalent to `zstrm' being or not
being NULL.  remove `locked' and check `zstrm' instead.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Change-Id: Id55b0c47aa6b508ac5138f90fafd92a82d2fe9d8

drivers/block/zram/zram_drv.c

index f9605860f86ef00620280da92a2e5ac6f2cf7b82..a61a749828dc8d39f3bef00364e53c0daa1df37b 100644 (file)
@@ -585,8 +585,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
        struct page *page;
        unsigned char *user_mem, *cmem, *src, *uncmem = NULL;
        struct zram_meta *meta = zram->meta;
-       struct zcomp_strm *zstrm;
-       bool locked = false;
+       struct zcomp_strm *zstrm = NULL;
        unsigned long alloced_pages;
 
        page = bvec->bv_page;
@@ -606,7 +605,6 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
        }
 
        zstrm = zcomp_strm_find(zram->comp);
-       locked = true;
        user_mem = kmap_atomic(page);
 
        if (is_partial_io(bvec)) {
@@ -678,7 +676,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
        }
 
        zcomp_strm_release(zram->comp, zstrm);
-       locked = false;
+       zstrm = NULL;
        zs_unmap_object(meta->mem_pool, handle);
 
        /*
@@ -696,7 +694,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
        atomic64_add(clen, &zram->stats.compr_data_size);
        atomic64_inc(&zram->stats.pages_stored);
 out:
-       if (locked)
+       if (zstrm)
                zcomp_strm_release(zram->comp, zstrm);
        if (is_partial_io(bvec))
                kfree(uncmem);