Skip to contentSkip to conversation

master - bcache: knock out err param.

PATCH Joe Thornber 1 participant 1 message May 10, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=67b80e2d9d9b437f18f909c9c09e4b286337b031
Commit:        67b80e2d9d9b437f18f909c9c09e4b286337b031
Parent:        2b96bb403c3aabe7c1593a87c07e774d9256e790
Author:        Joe Thornber <[email protected]>
AuthorDate:    Thu May 10 13:26:08 2018 +0100
Committer:     Joe Thornber <[email protected]>
CommitterDate: Thu May 10 13:26:08 2018 +0100

bcache: knock out err param.

Dave used this for debugging. Not needed in general.

---
 lib/device/bcache-utils.c  |   14 ++++----
 lib/device/bcache.c        |    6 +---
 lib/device/bcache.h        |    9 +-----
 lib/label/label.c          |    2 +-
 test/unit/bcache_t.c       |   68 ++++++++++++++++---------------------------
 test/unit/bcache_utils_t.c |    6 +--
 6 files changed, 37 insertions(+), 68 deletions(-)
lib/device/bcache-utils.c +7 -7
index 1487732..a533a66 100644
@@ -64,7 +64,7 @@ bool bcache_read_bytes(struct bcache *cache, int fd, uint64_t start, size_t len,
 	byte_range_to_block_range(cache, start, len, &bb, &be);
 
 	for (; bb != be; bb++) {
-        	if (!bcache_get(cache, fd, bb, 0, &b, NULL))
+        	if (!bcache_get(cache, fd, bb, 0, &b))
 			return false;
 
 		size_t blen = _min(block_size - block_offset, len);
@@ -146,7 +146,7 @@ static bool _write_partial(struct updater *u, int fd, block_address bb,
 {
 	struct block *b;
 
-	if (!bcache_get(u->cache, fd, bb, GF_DIRTY, &b, NULL))
+	if (!bcache_get(u->cache, fd, bb, GF_DIRTY, &b))
 		return false;
 
 	memcpy(((unsigned char *) b->data) + offset, u->data, len);
@@ -164,7 +164,7 @@ static bool _write_whole(struct updater *u, int fd, block_address bb, block_addr
 	for (; bb != be; bb++) {
         	// We don't need to read the block since we are overwriting
         	// it completely.
-		if (!bcache_get(u->cache, fd, bb, GF_ZERO, &b, NULL))
+		if (!bcache_get(u->cache, fd, bb, GF_ZERO, &b))
         		return false;
 		memcpy(b->data, u->data, block_size);
 		u->data = ((unsigned char *) u->data) + block_size;
@@ -192,7 +192,7 @@ static bool _zero_partial(struct updater *u, int fd, block_address bb, uint64_t
 {
 	struct block *b;
 
-	if (!bcache_get(u->cache, fd, bb, GF_DIRTY, &b, NULL))
+	if (!bcache_get(u->cache, fd, bb, GF_DIRTY, &b))
 		return false;
 
 	memset(((unsigned char *) b->data) + offset, 0, len);
@@ -206,7 +206,7 @@ static bool _zero_whole(struct updater *u, int fd, block_address bb, block_addre
 	struct block *b;
 
 	for (; bb != be; bb++) {
-		if (!bcache_get(u->cache, fd, bb, GF_ZERO, &b, NULL))
+		if (!bcache_get(u->cache, fd, bb, GF_ZERO, &b))
         		return false;
         	bcache_put(b);
 	}
@@ -233,7 +233,7 @@ static bool _set_partial(struct updater *u, int fd, block_address bb, uint64_t o
 	struct block *b;
 	uint8_t val = *((uint8_t *) u->data);
 
-	if (!bcache_get(u->cache, fd, bb, GF_DIRTY, &b, NULL))
+	if (!bcache_get(u->cache, fd, bb, GF_DIRTY, &b))
 		return false;
 
 	memset(((unsigned char *) b->data) + offset, val, len);
@@ -249,7 +249,7 @@ static bool _set_whole(struct updater *u, int fd, block_address bb, block_addres
         uint64_t len = bcache_block_sectors(u->cache) * 512;
 
 	for (; bb != be; bb++) {
-		if (!bcache_get(u->cache, fd, bb, GF_ZERO, &b, NULL))
+		if (!bcache_get(u->cache, fd, bb, GF_ZERO, &b))
         		return false;
         	memset((unsigned char *) b->data, val, len);
         	bcache_put(b);
lib/device/bcache.c +1 -5
index 6ea0349..62e99bd 100644
@@ -901,14 +901,13 @@ static void _recycle_block(struct bcache *cache, struct block *b)
 }
 
 bool bcache_get(struct bcache *cache, int fd, block_address i,
-	        unsigned flags, struct block **result, int *error)
+	        unsigned flags, struct block **result)
 {
 	struct block *b;
 
 	b = _lookup_or_read_block(cache, fd, i, flags);
 	if (b) {
 		if (b->error) {
-			*error = b->error;
 			if (b->io_dir == DIR_READ) {
 				// Now we know the read failed we can just forget
 				// about this block, since there's no dirty data to
@@ -928,9 +927,6 @@ bool bcache_get(struct bcache *cache, int fd, block_address i,
 
 	*result = NULL;
 
-	if (error)
-		*error = -BCACHE_NO_BLOCK;
-
 	log_error("bcache failed to get block %u fd %d", (uint32_t) i, fd);
 	return false;
 }
lib/device/bcache.h +1 -8
index 599b4c6..3084fa7 100644
@@ -29,13 +29,6 @@
 
 /*----------------------------------------------------------------*/
 
-/*
- * bcache-specific error numbers
- * These supplement standard -EXXX error numbers and
- * should not overlap.
- */
-#define BCACHE_NO_BLOCK 201
-
 enum dir {
 	DIR_READ,
 	DIR_WRITE
@@ -126,7 +119,7 @@ void bcache_prefetch(struct bcache *cache, int fd, block_address index);
  * Returns true on success.
  */
 bool bcache_get(struct bcache *cache, int fd, block_address index,
-	        unsigned flags, struct block **result, int *error);
+	        unsigned flags, struct block **result);
 void bcache_put(struct block *b);
 
 /*
lib/label/label.c +1 -1
index 8b60780..dcd92ce 100644
@@ -521,7 +521,7 @@ static int _scan_list(struct dm_list *devs, int *failed)
 		scan_failed = 0;
 		is_lvm_device = 0;
 
-		if (!bcache_get(scan_bcache, devl->dev->bcache_fd, 0, 0, &bb, &error)) {
+		if (!bcache_get(scan_bcache, devl->dev->bcache_fd, 0, 0, &bb)) {
 			log_debug_devs("Scan failed to read %s error %d.", dev_name(devl->dev), error);
 			scan_failed = 1;
 			scan_read_errors++;
test/unit/bcache_t.c +25 -43

272 lines not on this page · raw message

test/unit/bcache_utils_t.c +2 -4
index 255caff..b784c6f 100644
@@ -109,7 +109,6 @@ static uint64_t _min(uint64_t lhs, uint64_t rhs)
 
 static void _verify(struct fixture *f, uint64_t byte_b, uint64_t byte_e, uint8_t pat)
 {
-        int err;
 	struct block *b;
 	block_address bb = byte_b / T_BLOCK_SIZE;
 	block_address be = (byte_e + T_BLOCK_SIZE - 1) / T_BLOCK_SIZE;
@@ -128,7 +127,7 @@ static void _verify(struct fixture *f, uint64_t byte_b, uint64_t byte_e, uint8_t
 
 	// Verify again, driving bcache directly
 	for (; bb != be; bb++) {
-        	T_ASSERT(bcache_get(f->cache, f->fd, bb, 0, &b, &err));
+        	T_ASSERT(bcache_get(f->cache, f->fd, bb, 0, &b));
 
 		blen = _min(T_BLOCK_SIZE - offset, len);
         	_verify_bytes(b, bb * T_BLOCK_SIZE, offset, blen, pat);
@@ -142,7 +141,6 @@ static void _verify(struct fixture *f, uint64_t byte_b, uint64_t byte_e, uint8_t
 
 static void _verify_set(struct fixture *f, uint64_t byte_b, uint64_t byte_e, uint8_t val)
 {
-        int err;
         unsigned i;
 	struct block *b;
 	block_address bb = byte_b / T_BLOCK_SIZE;
@@ -151,7 +149,7 @@ static void _verify_set(struct fixture *f, uint64_t byte_b, uint64_t byte_e, uin
 	uint64_t blen, len = byte_e - byte_b;
 
 	for (; bb != be; bb++) {
-        	T_ASSERT(bcache_get(f->cache, f->fd, bb, 0, &b, &err));
+        	T_ASSERT(bcache_get(f->cache, f->fd, bb, 0, &b));
 
 		blen = _min(T_BLOCK_SIZE - offset, len);
 		for (i = 0; i < blen; i++)