scoutfs: add scoutfs_block_forget()

The upcoming allocator changes have a need to forget dirty blocks so
they're not written.  It proabably won't be the only one.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2016-09-28 13:46:18 -07:00
parent 9d08b34791
commit 5601f8cef5
2 changed files with 25 additions and 0 deletions

View File

@@ -469,6 +469,29 @@ struct buffer_head *scoutfs_block_dirty_alloc(struct super_block *sb)
return bh;
}
/*
* Make sure that we don't have a dirty block at the given blkno. If we
* do we remove it from our tree of dirty blocks and clear the buffer
* dirty bit.
*
* XXX for now callers have only needed to forget blknos, maybe they'll
* have the bh some day.
*/
void scoutfs_block_forget(struct super_block *sb, u64 blkno)
{
struct block_bh_private *bhp;
struct buffer_head *bh;
bh = sb_find_get_block(sb, blkno);
if (bh) {
bhp = bh->b_private;
if (bhp) {
erase_bhp(bh);
bforget(bh);
}
}
}
void scoutfs_block_set_crc(struct buffer_head *bh)
{
struct scoutfs_block_header *hdr = bh_data(bh);

View File

@@ -25,6 +25,8 @@ void scoutfs_block_set_lock_class(struct buffer_head *bh,
void scoutfs_block_lock(struct buffer_head *bh, bool write, int subclass);
void scoutfs_block_unlock(struct buffer_head *bh, bool write);
void scoutfs_block_forget(struct super_block *sb, u64 blkno);
/* XXX seems like this should be upstream :) */
static inline void *bh_data(struct buffer_head *bh)
{