@@ -790,9 +790,11 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode,
*
* Returns 0 on success or negative error code on failure
*/
-static int btrfs_write_merkle_tree_block(struct inode *inode, const void *buf,
- u64 pos, unsigned int size)
+static int btrfs_write_merkle_tree_block(const struct fsverity_writemerkle *req,
+ const void *buf, u64 pos,
+ unsigned int size)
{
+ struct inode *inode = req->inode;
loff_t merkle_pos = merkle_file_pos(inode);
if (merkle_pos < 0)
@@ -382,9 +382,12 @@ static struct page *ext4_read_merkle_tree_page(struct inode *inode,
return folio_file_page(folio, index);
}
-static int ext4_write_merkle_tree_block(struct inode *inode, const void *buf,
- u64 pos, unsigned int size)
+static int ext4_write_merkle_tree_block(const struct fsverity_writemerkle *req,
+ const void *buf, u64 pos,
+ unsigned int size)
{
+ struct inode *inode = req->inode;
+
pos += ext4_verity_metadata_pos(inode);
return pagecache_write(inode, buf, size, pos);
@@ -279,9 +279,12 @@ static struct page *f2fs_read_merkle_tree_page(struct inode *inode,
return folio_file_page(folio, index);
}
-static int f2fs_write_merkle_tree_block(struct inode *inode, const void *buf,
- u64 pos, unsigned int size)
+static int f2fs_write_merkle_tree_block(const struct fsverity_writemerkle *req,
+ const void *buf, u64 pos,
+ unsigned int size)
{
+ struct inode *inode = req->inode;
+
pos += f2fs_verity_metadata_pos(inode);
return pagecache_write(inode, buf, size, pos);
@@ -50,10 +50,13 @@ static int write_merkle_tree_block(struct inode *inode, const u8 *buf,
unsigned long index,
const struct merkle_tree_params *params)
{
+ struct fsverity_writemerkle req = {
+ .inode = inode,
+ };
u64 pos = (u64)index << params->log_blocksize;
int err;
- err = inode->i_sb->s_vop->write_merkle_tree_block(inode, buf, pos,
+ err = inode->i_sb->s_vop->write_merkle_tree_block(&req, buf, pos,
params->block_size);
if (err)
fsverity_err(inode, "Error %d writing Merkle tree block %lu",
@@ -73,6 +73,14 @@ struct fsverity_readmerkle {
#define FSVERITY_STREAMING_READ (-1)
+/**
+ * struct fsverity_writemerkle - Request to write a Merkle Tree block buffer
+ * @inode: the inode to read
+ */
+struct fsverity_writemerkle {
+ struct inode *inode;
+};
+
/* Verity operations for filesystems */
struct fsverity_operations {
@@ -183,7 +191,7 @@ struct fsverity_operations {
/**
* Write a Merkle tree block to the given inode.
*
- * @inode: the inode for which the Merkle tree is being built
+ * @req: write request; see struct fsverity_writemerkle
* @buf: the Merkle tree block to write
* @pos: the position of the block in the Merkle tree (in bytes)
* @size: the Merkle tree block size (in bytes)
@@ -193,8 +201,9 @@ struct fsverity_operations {
*
* Return: 0 on success, -errno on failure
*/
- int (*write_merkle_tree_block)(struct inode *inode, const void *buf,
- u64 pos, unsigned int size);
+ int (*write_merkle_tree_block)(const struct fsverity_writemerkle *req,
+ const void *buf, u64 pos,
+ unsigned int size);
/**
* Release the reference to a Merkle tree block