Hi Dave, On Wed, Apr 05, 2023 at 09:40:19AM +1000, Dave Chinner wrote: > On Tue, Apr 04, 2023 at 04:53:02PM +0200, Andrey Albershteyn wrote: > > Allow filesystem to make additional processing on verified pages > > instead of just dropping a reference. This will be used by XFS for > > internal buffer cache manipulation in further patches. The btrfs, > > ext4, and f2fs just drop the reference. > > > > Signed-off-by: Andrey Albershteyn <aalbersh@xxxxxxxxxx> > > --- > > fs/btrfs/verity.c | 12 ++++++++++++ > > fs/ext4/verity.c | 6 ++++++ > > fs/f2fs/verity.c | 6 ++++++ > > fs/verity/read_metadata.c | 4 ++-- > > fs/verity/verify.c | 6 +++--- > > include/linux/fsverity.h | 10 ++++++++++ > > 6 files changed, 39 insertions(+), 5 deletions(-) > > > > diff --git a/fs/btrfs/verity.c b/fs/btrfs/verity.c > > index c5ff16f9e9fa..4c2c09204bb4 100644 > > --- a/fs/btrfs/verity.c > > +++ b/fs/btrfs/verity.c > > @@ -804,10 +804,22 @@ static int btrfs_write_merkle_tree_block(struct inode *inode, const void *buf, > > pos, buf, size); > > } > > > > +/* > > + * fsverity op that releases the reference obtained by ->read_merkle_tree_page() > > + * > > + * @page: reference to the page which can be released > > + * > > + */ > > +static void btrfs_drop_page(struct page *page) > > +{ > > + put_page(page); > > +} > > + > > const struct fsverity_operations btrfs_verityops = { > > .begin_enable_verity = btrfs_begin_enable_verity, > > .end_enable_verity = btrfs_end_enable_verity, > > .get_verity_descriptor = btrfs_get_verity_descriptor, > > .read_merkle_tree_page = btrfs_read_merkle_tree_page, > > .write_merkle_tree_block = btrfs_write_merkle_tree_block, > > + .drop_page = &btrfs_drop_page, > > }; > > Ok, that's a generic put_page() call. > > .... > > diff --git a/fs/verity/verify.c b/fs/verity/verify.c > > index f50e3b5b52c9..c2fc4c86af34 100644 > > --- a/fs/verity/verify.c > > +++ b/fs/verity/verify.c > > @@ -210,7 +210,7 @@ verify_data_block(struct inode *inode, struct fsverity_info *vi, > > if (is_hash_block_verified(vi, hpage, hblock_idx)) { > > memcpy_from_page(_want_hash, hpage, hoffset, hsize); > > want_hash = _want_hash; > > - put_page(hpage); > > + inode->i_sb->s_vop->drop_page(hpage); > > goto descend; > > fsverity_drop_page(hpage); > > static inline void > fsverity_drop_page(struct inode *inode, struct page *page) > { > if (inode->i_sb->s_vop->drop_page) > inode->i_sb->s_vop->drop_page(page); > else > put_page(page); > } > > And then you don't need to add the functions to each of the > filesystems nor make an indirect call just to run put_page(). Sure, this makes more sense, thank you! -- - Andrey