Re: [PATCH v2 1/3] block: cache bdev in struct file for raw bdev IO

From: Christoph Hellwig
Date: Wed Oct 13 2021 - 11:21:07 EST


On Wed, Oct 13, 2021 at 09:57:11AM +0100, Pavel Begunkov wrote:
> bdev = &BDEV_I(file->f_mapping->host)->bdev
>
> Getting struct block_device from a file requires 2 memory dereferences
> as illustrated above, that takes a toll on performance, so cache it in
> yet unused file->private_data. That gives a noticeable peak performance
> improvement.
>
> Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx>
> ---
> block/fops.c | 29 +++++++++++++----------------
> 1 file changed, 13 insertions(+), 16 deletions(-)
>
> diff --git a/block/fops.c b/block/fops.c
> index 7bb9581a146c..c71e91cd6bcb 100644
> --- a/block/fops.c
> +++ b/block/fops.c
> @@ -17,7 +17,7 @@
> #include <linux/fs.h>
> #include "blk.h"
>
> -static struct inode *bdev_file_inode(struct file *file)
> +static inline struct inode *bdev_file_inode(struct file *file)
> {
> return file->f_mapping->host;
> }

This is unrelated to the rest.

But the actual described change looks good:

Reviewed-by: Christoph Hellwig <hch@xxxxxx>