diff mbox series

[RFC,v4,linux-next,07/19] erofs: prevent direct access of bd_inode

Message ID 20240222124555.2049140-8-yukuai1@huaweicloud.com (mailing list archive)
State New
Headers show
Series fs & block: remove bdev->bd_inode | expand

Commit Message

Yu Kuai Feb. 22, 2024, 12:45 p.m. UTC
From: Yu Kuai <yukuai3@huawei.com>

Now that all filesystems stash the bdev file, it's ok to get inode
for the file.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 fs/erofs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Kara March 15, 2024, 2:45 p.m. UTC | #1
On Thu 22-02-24 20:45:43, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> Now that all filesystems stash the bdev file, it's ok to get inode
> for the file.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/erofs/data.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> index 433fc39ba423..dc2d43abe8c5 100644
> --- a/fs/erofs/data.c
> +++ b/fs/erofs/data.c
> @@ -70,7 +70,7 @@ void erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb)
>  	if (erofs_is_fscache_mode(sb))
>  		buf->inode = EROFS_SB(sb)->s_fscache->inode;
>  	else
> -		buf->inode = sb->s_bdev->bd_inode;
> +		buf->inode = file_inode(sb->s_bdev_file);
>  }
>  
>  void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,
> -- 
> 2.39.2
>
Christoph Hellwig March 17, 2024, 9:24 p.m. UTC | #2
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Gao Xiang March 18, 2024, 2:39 a.m. UTC | #3
On 2024/2/22 20:45, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> Now that all filesystems stash the bdev file, it's ok to get inode
> for the file.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>

(BTW, it'd be better to +Cc EROFS mailing list for this patch.)

Thanks,
Gao Xiang

> ---
>   fs/erofs/data.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> index 433fc39ba423..dc2d43abe8c5 100644
> --- a/fs/erofs/data.c
> +++ b/fs/erofs/data.c
> @@ -70,7 +70,7 @@ void erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb)
>   	if (erofs_is_fscache_mode(sb))
>   		buf->inode = EROFS_SB(sb)->s_fscache->inode;
>   	else
> -		buf->inode = sb->s_bdev->bd_inode;
> +		buf->inode = file_inode(sb->s_bdev_file);
>   }
>   
>   void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,
diff mbox series

Patch

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 433fc39ba423..dc2d43abe8c5 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -70,7 +70,7 @@  void erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb)
 	if (erofs_is_fscache_mode(sb))
 		buf->inode = EROFS_SB(sb)->s_fscache->inode;
 	else
-		buf->inode = sb->s_bdev->bd_inode;
+		buf->inode = file_inode(sb->s_bdev_file);
 }
 
 void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,