null_blk: cleanup discard handling
authorDamien Le Moal <damien.lemoal@wdc.com>
Fri, 20 Nov 2020 01:55:16 +0000 (10:55 +0900)
committerJens Axboe <axboe@kernel.dk>
Tue, 8 Dec 2020 00:36:03 +0000 (17:36 -0700)
commit49c7089f3ded981fcea387f853fa394788e60fb2
tree32f6627c5425a895fbe528cf6b4398a46dbb2f19
parent2e8c6e0e1d2d65562c637940747cfa30559f976a
null_blk: cleanup discard handling

null_handle_discard() is called from both null_handle_rq() and
null_handle_bio(). As these functions are only passed a nullb_cmd
structure, this forces pointer dereferences to identiify the discard
operation code and to access the sector range to be discarded.
Simplify all this by changing the interface of the functions
null_handle_discard() and null_handle_memory_backed() to pass along
the operation code, operation start sector and number of sectors. With
this change null_handle_discard() can be called directly from
null_handle_memory_backed().

Also add a message warning that the discard configuration attribute has
no effect when memory backing is disabled.

No functional change is introduced by this patch.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/null_blk_main.c