mirror of
https://github.com/versity/scoutfs.git
synced 2026-01-03 02:45:20 +00:00
scoutfs: add scoutfs_block_zero_from()
We already have a function that zeros the end of a block starting at a given offset. Some callers have a pointer to the byte to zero from so let's add a convenience function that calculates the offset from the pointer. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
@@ -476,6 +476,9 @@ void scoutfs_block_set_crc(struct buffer_head *bh)
|
||||
hdr->crc = cpu_to_le32(scoutfs_crc_block(hdr));
|
||||
}
|
||||
|
||||
/*
|
||||
* Zero the block from the given byte to the end of the block.
|
||||
*/
|
||||
void scoutfs_block_zero(struct buffer_head *bh, size_t off)
|
||||
{
|
||||
if (WARN_ON_ONCE(off > SCOUTFS_BLOCK_SIZE))
|
||||
@@ -485,6 +488,14 @@ void scoutfs_block_zero(struct buffer_head *bh, size_t off)
|
||||
memset((char *)bh->b_data + off, 0, SCOUTFS_BLOCK_SIZE - off);
|
||||
}
|
||||
|
||||
/*
|
||||
* Zero the block from the given byte to the end of the block.
|
||||
*/
|
||||
void scoutfs_block_zero_from(struct buffer_head *bh, void *ptr)
|
||||
{
|
||||
return scoutfs_block_zero(bh, (char *)ptr - (char *)bh->b_data);
|
||||
}
|
||||
|
||||
void scoutfs_block_set_lock_class(struct buffer_head *bh,
|
||||
struct lock_class_key *class)
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ int scoutfs_block_write_dirty(struct super_block *sb);
|
||||
|
||||
void scoutfs_block_set_crc(struct buffer_head *bh);
|
||||
void scoutfs_block_zero(struct buffer_head *bh, size_t off);
|
||||
void scoutfs_block_zero_from(struct buffer_head *bh, void *ptr);
|
||||
|
||||
void scoutfs_block_set_lock_class(struct buffer_head *bh,
|
||||
struct lock_class_key *class);
|
||||
|
||||
Reference in New Issue
Block a user