Skip to contentSkip to conversation

zram: cosmetic zram_bvec_write() cleanup

PATCH In review Sergey Senozhatsky 2 participants 2 messages May 17, 2015 – May 18, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 zram: cosmetic zram_bvec_write() cleanup

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.

---
 drivers/block/zram/zram_drv.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/block/zram/zram_drv.c +3 -5
index 8dcbced..e917d36 100644
@@ -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);
Signature · 1 line
2.4.1.168.g1ea28e1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Sergey Senozhatsky

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.

Signature · 2 lines
Kind regards,
Minchan Kim