shithub: lwext4

Download patch

ref: 183e464de184a73d18ca6d8833f87f8e86471b07
parent: 4b53a65e1ad2d404253b641fd857f533203fa519
author: gkostka <[email protected]>
date: Wed Dec 9 07:44:25 EST 2015

ext4_blockdev: move bread/bwrite counters to ext4_blockdev_iface

--- a/fs_test/common/test_lwext4.c
+++ b/fs_test/common/test_lwext4.c
@@ -127,8 +127,8 @@
 
 	printf("********************\n");
 	printf("ext4 blockdev stats\n");
-	printf("bdev->bread_ctr = %" PRIu32 "\n", bd->bread_ctr);
-	printf("bdev->bwrite_ctr = %" PRIu32 "\n", bd->bwrite_ctr);
+	printf("bdev->bread_ctr = %" PRIu32 "\n", bd->bdif->bread_ctr);
+	printf("bdev->bwrite_ctr = %" PRIu32 "\n", bd->bdif->bwrite_ctr);
 
 	printf("bcache->ref_blocks = %" PRIu32 "\n", bc->ref_blocks);
 	printf("bcache->max_ref_blocks = %" PRIu32 "\n", bc->max_ref_blocks);
--- a/lwext4/ext4_blockdev.c
+++ b/lwext4/ext4_blockdev.c
@@ -65,6 +65,7 @@
 {
 	ext4_bdif_lock(bdev);
 	int r = bdev->bdif->bread(bdev, buf, blk_id, blk_cnt);
+	bdev->bdif->bread_ctr++;
 	ext4_bdif_unlock(bdev);
 	return r;
 }
@@ -74,6 +75,7 @@
 {
 	ext4_bdif_lock(bdev);
 	int r = bdev->bdif->bwrite(bdev, buf, blk_id, blk_cnt);
+	bdev->bdif->bwrite_ctr++;
 	ext4_bdif_unlock(bdev);
 	return r;
 }
@@ -259,7 +261,6 @@
 	pba = (lba * bdev->lg_bsize + bdev->part_offset) / bdev->bdif->ph_bsize;
 	pb_cnt = bdev->lg_bsize / bdev->bdif->ph_bsize;
 
-	bdev->bread_ctr++;
 	return ext4_bdif_bread(bdev, buf, pba, pb_cnt * cnt);
 }
 
@@ -274,7 +275,6 @@
 	pba = (lba * bdev->lg_bsize + bdev->part_offset) / bdev->bdif->ph_bsize;
 	pb_cnt = bdev->lg_bsize / bdev->bdif->ph_bsize;
 
-	bdev->bwrite_ctr++;
 	return ext4_bdif_bwrite(bdev, buf, pba, pb_cnt * cnt);
 }
 
--- a/lwext4/ext4_blockdev.h
+++ b/lwext4/ext4_blockdev.h
@@ -92,6 +92,12 @@
 
 	/**@brief   Reference counter to block device interface*/
 	uint32_t ph_refctr;
+
+	/**@brief   Physical read counter*/
+	uint32_t bread_ctr;
+
+	/**@brief   Physical write counter*/
+	uint32_t bwrite_ctr;
 };
 
 /**@brief   Definition of the simple block device.*/
@@ -116,12 +122,6 @@
 
 	/**@brief   Cache write back mode reference counter*/
 	uint32_t cache_write_back;
-
-	/**@brief   Physical read counter*/
-	uint32_t bread_ctr;
-
-	/**@brief   Physical write counter*/
-	uint32_t bwrite_ctr;
 };
 
 /**@brief   Static initialization of the block device.*/