ref: 8f8f6a2297ba630dd1005564cc424ff1811e5545
parent: 2727c501045832e3bc8461f8ec75441a4eb8d808
author: gkostka <[email protected]>
date: Tue Nov 17 19:17:11 EST 2015
Code format in bcache & blockdev
--- a/lwext4/ext4_bcache.h
+++ b/lwext4/ext4_bcache.h
@@ -42,7 +42,8 @@
#include <stdint.h>
#include <stdbool.h>
-#define EXT4_BLOCK_ZERO() {.uptodate = 0, .dirty = 0, .lb_id = 0, .cache_id = 0, .data = 0}
+#define EXT4_BLOCK_ZERO() \
+ {.uptodate = 0, .dirty = 0, .lb_id = 0, .cache_id = 0, .data = 0}
/**@brief Single block descriptor*/
struct ext4_block {
--- a/lwext4/ext4_blockdev.c
+++ b/lwext4/ext4_blockdev.c
@@ -303,7 +303,6 @@
: (bdev->ph_bsize - unalg);
r = bdev->bread(bdev, bdev->ph_bbuf, block_idx, 1);
-
if (r != EOK)
return r;
@@ -321,7 +320,6 @@
/*Aligned data*/
blen = len / bdev->ph_bsize;
r = bdev->bwrite(bdev, p, block_idx, blen);
-
if (r != EOK)
return r;
@@ -339,7 +337,6 @@
memcpy(bdev->ph_bbuf, p, len);
r = bdev->bwrite(bdev, bdev->ph_bbuf, block_idx, 1);
-
if (r != EOK)
return r;
}
@@ -392,7 +389,6 @@
blen = len / bdev->ph_bsize;
r = bdev->bread(bdev, p, block_idx, blen);
-
if (r != EOK)
return r;
@@ -424,33 +420,35 @@
if (!on_off && bdev->cache_write_back)
bdev->cache_write_back--;
+
+ if (bdev->cache_write_back)
+ return EOK;
+
/*Flush all delayed cache blocks*/
- if (!bdev->cache_write_back) {
- for (i = 0; i < bdev->bc->cnt; ++i) {
+ for (i = 0; i < bdev->bc->cnt; ++i) {
- /*Check if buffer free was delayed.*/
- if (!bdev->bc->free_delay[i])
- continue;
+ /*Check if buffer free was delayed.*/
+ if (!bdev->bc->free_delay[i])
+ continue;
- /*Check reference counter.*/
- if (bdev->bc->refctr[i])
- continue;
+ /*Check reference counter.*/
+ if (bdev->bc->refctr[i])
+ continue;
- /*Buffer free was delayed and have no reference. Flush
- * it.*/
- r = ext4_blocks_set_direct(
- bdev, bdev->bc->data + bdev->bc->itemsize * i,
- bdev->bc->lba[i], 1);
- if (r != EOK)
- return r;
+ /*Buffer free was delayed and have no reference. Flush
+ * it.*/
+ r = ext4_blocks_set_direct(bdev, bdev->bc->data +
+ bdev->bc->itemsize * i, bdev->bc->lba[i], 1);
+ if (r != EOK)
+ return r;
- /*No delayed anymore*/
- bdev->bc->free_delay[i] = 0;
+ /*No delayed anymore*/
+ bdev->bc->free_delay[i] = 0;
- /*Reduce reference counter*/
- bdev->bc->ref_blocks--;
- }
+ /*Reduce reference counter*/
+ bdev->bc->ref_blocks--;
}
+
return EOK;
}