[PATCH vfs.all 20/26] block: factor out a helper init_bdev_file()

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

 



From: Yu Kuai <yukuai3@xxxxxxxxxx>

There are no functional changes, the helper will be used in later
patches to initialize stashed bdev_file as well.

Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
---
 block/bdev.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/block/bdev.c b/block/bdev.c
index 4335df6d1266..82fb1688f4c9 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -832,6 +832,20 @@ static void bdev_yield_write_access(struct file *bdev_file)
 		bdev->bd_writers--;
 }
 
+static void init_bdev_file(struct file *bdev_file, struct block_device *bdev,
+			   blk_mode_t mode, void *holder)
+{
+	bdev_file->f_flags |= O_LARGEFILE;
+	bdev_file->f_mode |= FMODE_CAN_ODIRECT;
+	if (bdev_nowait(bdev))
+		bdev_file->f_mode |= FMODE_NOWAIT;
+	if (mode & BLK_OPEN_RESTRICT_WRITES)
+		bdev_file->f_mode |= FMODE_WRITE_RESTRICTED;
+	bdev_file->f_mapping = bdev_mapping(bdev);
+	bdev_file->f_wb_err = filemap_sample_wb_err(bdev_file->f_mapping);
+	bdev_file->private_data = holder;
+}
+
 /**
  * bdev_open - open a block device
  * @bdev: block device to open
@@ -905,15 +919,7 @@ int bdev_open(struct block_device *bdev, blk_mode_t mode, void *holder,
 	if (unblock_events)
 		disk_unblock_events(disk);
 
-	bdev_file->f_flags |= O_LARGEFILE;
-	bdev_file->f_mode |= FMODE_CAN_ODIRECT;
-	if (bdev_nowait(bdev))
-		bdev_file->f_mode |= FMODE_NOWAIT;
-	if (mode & BLK_OPEN_RESTRICT_WRITES)
-		bdev_file->f_mode |= FMODE_WRITE_RESTRICTED;
-	bdev_file->f_mapping = bdev_mapping(bdev);
-	bdev_file->f_wb_err = filemap_sample_wb_err(bdev_file->f_mapping);
-	bdev_file->private_data = holder;
+	init_bdev_file(bdev_file, bdev, mode, holder);
 
 	return 0;
 put_module:
-- 
2.39.2





[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