verity: remove write_cb
Now that there are no users we can remove the write_cb infrastructure.
BUG=chromium-os:19952
TEST=Ran unit tests from dm-verity.git.
Ran platform_DMVerityCorruption and platform_DMVerityBitCorruption.
TESTED_ON=Alex
Change-Id: I1614ff03385769dfac477f80c4a31e3787910322
Reviewed-on: http://gerrit.chromium.org/gerrit/7103
Reviewed-by: Mandeep Singh Baines <msb@chromium.org>
Tested-by: Mandeep Singh Baines <msb@chromium.org>
diff --git a/dm-bht.c b/dm-bht.c
index cd50ce0..2a2b49a 100644
--- a/dm-bht.c
+++ b/dm-bht.c
@@ -138,9 +138,6 @@
static int dm_bht_read_callback_stub(void *ctx, sector_t start, u8 *dst,
sector_t count,
struct dm_bht_entry *entry);
-static int dm_bht_write_callback_stub(void *ctx, sector_t start,
- u8 *dst, sector_t count,
- struct dm_bht_entry *entry);
/**
* dm_bht_create - prepares @bht for us
@@ -236,9 +233,8 @@
goto bad_level_alloc;
}
- /* Setup callback stubs */
+ /* Setup read callback stub */
bht->read_cb = &dm_bht_read_callback_stub;
- bht->write_cb = &dm_bht_write_callback_stub;
status = dm_bht_initialize_entries(bht);
if (status)
@@ -343,15 +339,6 @@
return -EIO;
}
-static int dm_bht_write_callback_stub(void *ctx, sector_t start,
- u8 *dst, sector_t count,
- struct dm_bht_entry *entry)
-{
- DMCRIT("dm_bht_write_callback_stub called!");
- dm_bht_write_completed(entry, -EIO);
- return -EIO;
-}
-
/**
* dm_bht_read_completed
* @entry: pointer to the entry that's been loaded
@@ -372,24 +359,6 @@
}
EXPORT_SYMBOL(dm_bht_read_completed);
-/**
- * dm_bht_write_completed
- * @entry: pointer to the entry that's been loaded
- * @status: I/O status. Non-zero is failure.
- * Should be called after a write_cb completes. Currently only catches
- * errors which more writers don't care about.
- */
-void dm_bht_write_completed(struct dm_bht_entry *entry, int status)
-{
- if (status) {
- DMCRIT("an I/O error occurred while writing entry");
- atomic_set(&entry->state, DM_BHT_ENTRY_ERROR_IO);
- /* entry->nodes will be freed later */
- return;
- }
-}
-EXPORT_SYMBOL(dm_bht_write_completed);
-
/* dm_bht_verify_path
* Verifies the path. Returns 0 on ok.
*/
@@ -653,17 +622,6 @@
EXPORT_SYMBOL(dm_bht_set_read_cb);
/**
- * dm_bht_set_write_cb - set write callback
- * @bht: pointer to a dm_bht_create()d bht
- * @write_cb: callback function used for all write requests by @bht
- */
-void dm_bht_set_write_cb(struct dm_bht *bht, dm_bht_callback write_cb)
-{
- bht->write_cb = write_cb;
-}
-EXPORT_SYMBOL(dm_bht_set_write_cb);
-
-/**
* dm_bht_set_root_hexdigest - sets an unverified root digest hash from hex
* @bht: pointer to a dm_bht_create()d bht
* @hexdigest: array of u8s containing the new digest in binary
diff --git a/dm-bht.h b/dm-bht.h
index 2387c66..923a5f1 100644
--- a/dm-bht.h
+++ b/dm-bht.h
@@ -103,9 +103,8 @@
/* bool verified; Full tree is verified */
u8 root_digest[DM_BHT_MAX_DIGEST_SIZE];
struct dm_bht_level *levels; /* in reverse order */
- /* Callbacks for reading and/or writing to the hash device */
+ /* Callback for reading from the hash device */
dm_bht_callback read_cb;
- dm_bht_callback write_cb;
};
/* Constructor for struct dm_bht instances. */
@@ -118,7 +117,6 @@
/* Basic accessors for struct dm_bht */
sector_t dm_bht_sectors(const struct dm_bht *bht);
void dm_bht_set_read_cb(struct dm_bht *bht, dm_bht_callback read_cb);
-void dm_bht_set_write_cb(struct dm_bht *bht, dm_bht_callback write_cb);
int dm_bht_set_root_hexdigest(struct dm_bht *bht, const u8 *hexdigest);
int dm_bht_root_hexdigest(struct dm_bht *bht, u8 *hexdigest, int available);
void dm_bht_set_salt(struct dm_bht *bht, const char *hexsalt);
@@ -142,7 +140,6 @@
int dm_bht_zeroread_callback(void *ctx, sector_t start, u8 *dst, sector_t count,
struct dm_bht_entry *entry);
void dm_bht_read_completed(struct dm_bht_entry *entry, int status);
-void dm_bht_write_completed(struct dm_bht_entry *entry, int status);
/* Functions for converting indices to nodes. */
diff --git a/file_hasher.cc b/file_hasher.cc
index c9bda99..a6282a6 100644
--- a/file_hasher.cc
+++ b/file_hasher.cc
@@ -26,23 +26,6 @@
return false;
}
-int FileHasher::WriteCallback(void *file,
- sector_t start,
- u8 *dst,
- sector_t count,
- struct dm_bht_entry *entry) {
- simple_file::File *f = reinterpret_cast<simple_file::File *>(file);
- int offset = static_cast<int>(to_bytes(start));
- LOG_IF(FATAL, (static_cast<sector_t>(offset) != to_bytes(start)))
- << "cast to bytes truncated value";
- if (!f->WriteAt(to_bytes(count), dst, offset)) {
- dm_bht_write_completed(entry, -EIO);
- return -1;
- }
- dm_bht_write_completed(entry, 0);
- return 0;
-}
-
bool FileHasher::Initialize(simple_file::File *source,
simple_file::File *destination,
unsigned int blocks,
@@ -82,7 +65,6 @@
sectors_ = dm_bht_sectors(&tree_);
hash_data_ = new u8[to_bytes(sectors_)];
- dm_bht_set_write_cb(&tree_, FileHasher::WriteCallback);
// No reading is needed.
dm_bht_set_read_cb(&tree_, dm_bht_zeroread_callback);
dm_bht_set_buffer(&tree_, hash_data_);