[PATCH 5/5] zram: don't overload blk_idx variable in writeback_store()

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

 



From: Pankaj Raghav <p.raghav@xxxxxxxxxxx>

Instead of overloading blk_idx variable to find if it was allocated and
used, add a new boolean variable blk_allocated.

No functional changes.

Signed-off-by: Pankaj Raghav <p.raghav@xxxxxxxxxxx>
---
 drivers/block/zram/zram_drv.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 27313c2d781d..7c1420e92c6a 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -747,6 +747,7 @@ static ssize_t writeback_store(struct device *dev,
 	ssize_t ret = len;
 	int mode, err;
 	unsigned long blk_idx = 0;
+	bool blk_allocated = false;
 	unsigned int io_pages;
 	u64 bd_wb_limit_pages = ULONG_MAX;
 	struct index_mapping map = {};
@@ -803,7 +804,7 @@ static ssize_t writeback_store(struct device *dev,
 		}
 		spin_unlock(&zram->wb_limit_lock);
 
-		if (!blk_idx) {
+		if (!blk_allocated) {
 			io_pages = min(1UL << order, nr_pages);
 			io_pages = min_t(u64, bd_wb_limit_pages, io_pages);
 
@@ -812,6 +813,7 @@ static ssize_t writeback_store(struct device *dev,
 				ret = -ENOSPC;
 				break;
 			}
+			blk_allocated = true;
 		}
 
 		if (!writeback_prep_or_skip_index(zram, mode, index)) {
@@ -850,12 +852,12 @@ static ssize_t writeback_store(struct device *dev,
 		 * the unused blocks after looping through all indices.
 		 */
 		if (map.nr_of_entries == io_pages) {
-			blk_idx = 0;
+			blk_allocated = false;
 			map.nr_of_entries = 0;
 		}
 	}
 
-	if (blk_idx)
+	if (blk_allocated)
 		free_block_bdev_range(zram, blk_idx + map.nr_of_entries,
 				      io_pages - map.nr_of_entries);
 	folio_put(folio);
-- 
2.40.1




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux