On Tue, Oct 04, 2022 at 08:16:57PM -0700, Chaitanya Kulkarni wrote: > Add a helper functions to enable the REQ_OP_WRITE_ZEROES operations > when null_blk is configured with the membacked mode. > > Since write-zeroes is a non-trivial I/O operation we need this to > add a blktest so we can test the non-trivial I/O path from the > application to the block layer. > > Signed-off-by: Chaitanya Kulkarni <kch@xxxxxxxxxx> > --- > drivers/block/null_blk/main.c | 46 ++++++++++++++++++++++++++++++++++- > 1 file changed, 45 insertions(+), 1 deletion(-) > > diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c > index fc3e883f7b84..2d592b4eb815 100644 > --- a/drivers/block/null_blk/main.c > +++ b/drivers/block/null_blk/main.c ... > @@ -875,6 +877,24 @@ static void null_free_sector(struct nullb *nullb, sector_t sector, > } > } > > +static void null_zero_sector(struct nullb_device *d, sector_t sect, > + sector_t nr_sects, bool cache) > +{ Any reason to not just pass the tree root directly here instead of the cache boolean? It might make the callers more readable and also eliminates the need to pass the nullb_device. Brian > + struct radix_tree_root *root = cache ? &d->cache : &d->data; > + struct nullb_page *t_page; > + unsigned int offset; > + void *dest; > + > + t_page = radix_tree_lookup(root, sect >> PAGE_SECTORS_SHIFT); > + if (!t_page) > + return; > + > + offset = (sect & SECTOR_MASK) << SECTOR_SHIFT; > + dest = kmap_atomic(t_page->page); > + memset(dest + offset, 0, SECTOR_SIZE * nr_sects); > + kunmap_atomic(dest); > +} > + > static struct nullb_page *null_radix_tree_insert(struct nullb *nullb, u64 idx, > struct nullb_page *t_page, bool is_cache) > { ...