]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: port block device access to files
authorChristian Brauner <brauner@kernel.org>
Tue, 23 Jan 2024 13:26:24 +0000 (14:26 +0100)
committerChristian Brauner <brauner@kernel.org>
Sun, 25 Feb 2024 11:05:23 +0000 (12:05 +0100)
Link: https://lore.kernel.org/r/20240123-vfs-bdev-file-v2-7-adbd023e19cc@kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/xfs/xfs_buf.c
fs/xfs/xfs_buf.h
fs/xfs/xfs_super.c

index 8e5bd50d29feb34b50a5a85dca9110648a6bf69e..01b41fabbe3c7ba89d2f59c6dad15e49dfe781c5 100644 (file)
@@ -1951,7 +1951,7 @@ xfs_free_buftarg(
        fs_put_dax(btp->bt_daxdev, btp->bt_mount);
        /* the main block device is closed by kill_block_super */
        if (btp->bt_bdev != btp->bt_mount->m_super->s_bdev)
-               bdev_release(btp->bt_bdev_handle);
+               fput(btp->bt_bdev_file);
 
        kmem_free(btp);
 }
@@ -1994,7 +1994,7 @@ xfs_setsize_buftarg_early(
 struct xfs_buftarg *
 xfs_alloc_buftarg(
        struct xfs_mount        *mp,
-       struct bdev_handle      *bdev_handle)
+       struct file             *bdev_file)
 {
        xfs_buftarg_t           *btp;
        const struct dax_holder_operations *ops = NULL;
@@ -2005,9 +2005,9 @@ xfs_alloc_buftarg(
        btp = kmem_zalloc(sizeof(*btp), KM_NOFS);
 
        btp->bt_mount = mp;
-       btp->bt_bdev_handle = bdev_handle;
-       btp->bt_dev = bdev_handle->bdev->bd_dev;
-       btp->bt_bdev = bdev_handle->bdev;
+       btp->bt_bdev_file = bdev_file;
+       btp->bt_bdev = file_bdev(bdev_file);
+       btp->bt_dev = btp->bt_bdev->bd_dev;
        btp->bt_daxdev = fs_dax_get_by_bdev(btp->bt_bdev, &btp->bt_dax_part_off,
                                            mp, ops);
 
index b470de08a46ca8e6e7c3b4dfe7e85110037f3949..304e858d04fb3cfca71d4378f2878293f7462d8b 100644 (file)
@@ -98,7 +98,7 @@ typedef unsigned int xfs_buf_flags_t;
  */
 typedef struct xfs_buftarg {
        dev_t                   bt_dev;
-       struct bdev_handle      *bt_bdev_handle;
+       struct file             *bt_bdev_file;
        struct block_device     *bt_bdev;
        struct dax_device       *bt_daxdev;
        u64                     bt_dax_part_off;
@@ -366,7 +366,7 @@ xfs_buf_update_cksum(struct xfs_buf *bp, unsigned long cksum_offset)
  *     Handling of buftargs.
  */
 struct xfs_buftarg *xfs_alloc_buftarg(struct xfs_mount *mp,
-               struct bdev_handle *bdev_handle);
+               struct file *bdev_file);
 extern void xfs_free_buftarg(struct xfs_buftarg *);
 extern void xfs_buftarg_wait(struct xfs_buftarg *);
 extern void xfs_buftarg_drain(struct xfs_buftarg *);
index e5ac0e59ede9de46ccb881fc4057af13cd0dd3ed..3814d7371169144ff0af829d6fc245bf23c235e8 100644 (file)
@@ -362,16 +362,16 @@ STATIC int
 xfs_blkdev_get(
        xfs_mount_t             *mp,
        const char              *name,
-       struct bdev_handle      **handlep)
+       struct file             **bdev_filep)
 {
        int                     error = 0;
 
-       *handlep = bdev_open_by_path(name,
+       *bdev_filep = bdev_file_open_by_path(name,
                BLK_OPEN_READ | BLK_OPEN_WRITE | BLK_OPEN_RESTRICT_WRITES,
                mp->m_super, &fs_holder_ops);
-       if (IS_ERR(*handlep)) {
-               error = PTR_ERR(*handlep);
-               *handlep = NULL;
+       if (IS_ERR(*bdev_filep)) {
+               error = PTR_ERR(*bdev_filep);
+               *bdev_filep = NULL;
                xfs_warn(mp, "Invalid device [%s], error=%d", name, error);
        }
 
@@ -436,26 +436,26 @@ xfs_open_devices(
 {
        struct super_block      *sb = mp->m_super;
        struct block_device     *ddev = sb->s_bdev;
-       struct bdev_handle      *logdev_handle = NULL, *rtdev_handle = NULL;
+       struct file             *logdev_file = NULL, *rtdev_file = NULL;
        int                     error;
 
        /*
         * Open real time and log devices - order is important.
         */
        if (mp->m_logname) {
-               error = xfs_blkdev_get(mp, mp->m_logname, &logdev_handle);
+               error = xfs_blkdev_get(mp, mp->m_logname, &logdev_file);
                if (error)
                        return error;
        }
 
        if (mp->m_rtname) {
-               error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev_handle);
+               error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev_file);
                if (error)
                        goto out_close_logdev;
 
-               if (rtdev_handle->bdev == ddev ||
-                   (logdev_handle &&
-                    rtdev_handle->bdev == logdev_handle->bdev)) {
+               if (file_bdev(rtdev_file) == ddev ||
+                   (logdev_file &&
+                    file_bdev(rtdev_file) == file_bdev(logdev_file))) {
                        xfs_warn(mp,
        "Cannot mount filesystem with identical rtdev and ddev/logdev.");
                        error = -EINVAL;
@@ -467,25 +467,25 @@ xfs_open_devices(
         * Setup xfs_mount buffer target pointers
         */
        error = -ENOMEM;
-       mp->m_ddev_targp = xfs_alloc_buftarg(mp, sb_bdev_handle(sb));
+       mp->m_ddev_targp = xfs_alloc_buftarg(mp, sb->s_bdev_file);
        if (!mp->m_ddev_targp)
                goto out_close_rtdev;
 
-       if (rtdev_handle) {
-               mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev_handle);
+       if (rtdev_file) {
+               mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev_file);
                if (!mp->m_rtdev_targp)
                        goto out_free_ddev_targ;
        }
 
-       if (logdev_handle && logdev_handle->bdev != ddev) {
-               mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev_handle);
+       if (logdev_file && file_bdev(logdev_file) != ddev) {
+               mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev_file);
                if (!mp->m_logdev_targp)
                        goto out_free_rtdev_targ;
        } else {
                mp->m_logdev_targp = mp->m_ddev_targp;
                /* Handle won't be used, drop it */
-               if (logdev_handle)
-                       bdev_release(logdev_handle);
+               if (logdev_file)
+                       fput(logdev_file);
        }
 
        return 0;
@@ -496,11 +496,11 @@ xfs_open_devices(
  out_free_ddev_targ:
        xfs_free_buftarg(mp->m_ddev_targp);
  out_close_rtdev:
-        if (rtdev_handle)
-               bdev_release(rtdev_handle);
+        if (rtdev_file)
+               fput(rtdev_file);
  out_close_logdev:
-       if (logdev_handle)
-               bdev_release(logdev_handle);
+       if (logdev_file)
+               fput(logdev_file);
        return error;
 }