diff mbox series

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

Message ID 20240222124555.2049140-7-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 bdev mapping
from the file directly.

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

Comments

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

Looks good. Feel free to add:

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

								Honza

> ---
>  fs/cramfs/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
> index 39e75131fd5a..1df4dd89350e 100644
> --- a/fs/cramfs/inode.c
> +++ b/fs/cramfs/inode.c
> @@ -183,7 +183,7 @@ static int next_buffer;
>  static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
>  				unsigned int len)
>  {
> -	struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
> +	struct address_space *mapping = sb->s_bdev_file->f_mapping;
>  	struct file_ra_state ra = {};
>  	struct page *pages[BLKS_PER_BUF];
>  	unsigned i, blocknr, buffer;
> -- 
> 2.39.2
>
Christoph Hellwig March 17, 2024, 9:23 p.m. UTC | #2
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 39e75131fd5a..1df4dd89350e 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -183,7 +183,7 @@  static int next_buffer;
 static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
 				unsigned int len)
 {
-	struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
+	struct address_space *mapping = sb->s_bdev_file->f_mapping;
 	struct file_ra_state ra = {};
 	struct page *pages[BLKS_PER_BUF];
 	unsigned i, blocknr, buffer;