[PATCH v2 33/34] block: expose bdev_file_inode()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now that we open block devices as files we don't need to rely on
bd_inode to get to the correct inode. Use the helper.

We could use bdev_file->f_inode directly here since we know that
@f_inode refers to a bdev fs inode but it is generically correct to use
bdev_file->f_mapping->host since that will also work for bdev_files
opened from userspace.

Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
---
 block/bdev.c           | 2 +-
 block/fops.c           | 5 -----
 include/linux/blkdev.h | 5 +++++
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/block/bdev.c b/block/bdev.c
index 4b47003d8082..185c43ebeea5 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -51,7 +51,7 @@ EXPORT_SYMBOL(I_BDEV);
 
 struct block_device *file_bdev(struct file *bdev_file)
 {
-	return I_BDEV(bdev_file->f_mapping->host);
+	return I_BDEV(bdev_file_inode(bdev_file));
 }
 EXPORT_SYMBOL(file_bdev);
 
diff --git a/block/fops.c b/block/fops.c
index a0bff2c0d88d..240d968c281c 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -19,11 +19,6 @@
 #include <linux/module.h>
 #include "blk.h"
 
-static inline struct inode *bdev_file_inode(struct file *file)
-{
-	return file->f_mapping->host;
-}
-
 static blk_opf_t dio_bio_write_op(struct kiocb *iocb)
 {
 	blk_opf_t opf = REQ_OP_WRITE | REQ_SYNC | REQ_IDLE;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 2f5dbde23094..4b7080e56e44 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1490,6 +1490,11 @@ void blkdev_put_no_open(struct block_device *bdev);
 struct block_device *I_BDEV(struct inode *inode);
 struct block_device *file_bdev(struct file *bdev_file);
 
+static inline struct inode *bdev_file_inode(struct file *file)
+{
+	return file->f_mapping->host;
+}
+
 #ifdef CONFIG_BLOCK
 void invalidate_bdev(struct block_device *bdev);
 int sync_blockdev(struct block_device *bdev);

-- 
2.43.0





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux