[PATCH 21/29] erofs: Convert to use bdev_open_by_path()

2023-09-27 Thread Jan Kara
Convert erofs to use bdev_open_by_path() and pass the handle around.

CC: Gao Xiang 
CC: Chao Yu 
CC: linux-erofs@lists.ozlabs.org
Acked-by: Christoph Hellwig 
Acked-by: Gao Xiang 
Reviewed-by: Christian Brauner 
Signed-off-by: Jan Kara 
---
 fs/erofs/data.c |  4 ++--
 fs/erofs/internal.h |  2 +-
 fs/erofs/super.c| 20 ++--
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 0c2c99c58b5e..f6a0a1748521 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -222,7 +222,7 @@ int erofs_map_dev(struct super_block *sb, struct 
erofs_map_dev *map)
up_read(>rwsem);
return 0;
}
-   map->m_bdev = dif->bdev;
+   map->m_bdev = dif->bdev_handle->bdev;
map->m_daxdev = dif->dax_dev;
map->m_dax_part_off = dif->dax_part_off;
map->m_fscache = dif->fscache;
@@ -240,7 +240,7 @@ int erofs_map_dev(struct super_block *sb, struct 
erofs_map_dev *map)
if (map->m_pa >= startoff &&
map->m_pa < startoff + length) {
map->m_pa -= startoff;
-   map->m_bdev = dif->bdev;
+   map->m_bdev = dif->bdev_handle->bdev;
map->m_daxdev = dif->dax_dev;
map->m_dax_part_off = dif->dax_part_off;
map->m_fscache = dif->fscache;
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 4ff88d0dd980..cf04e21bfda2 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -47,7 +47,7 @@ typedef u32 erofs_blk_t;
 struct erofs_device_info {
char *path;
struct erofs_fscache *fscache;
-   struct block_device *bdev;
+   struct bdev_handle *bdev_handle;
struct dax_device *dax_dev;
u64 dax_part_off;
 
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 44a24d573f1f..2bf6dac83025 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -227,7 +227,7 @@ static int erofs_init_device(struct erofs_buf *buf, struct 
super_block *sb,
struct erofs_sb_info *sbi = EROFS_SB(sb);
struct erofs_fscache *fscache;
struct erofs_deviceslot *dis;
-   struct block_device *bdev;
+   struct bdev_handle *bdev_handle;
void *ptr;
 
ptr = erofs_read_metabuf(buf, sb, erofs_blknr(sb, *pos), EROFS_KMAP);
@@ -251,13 +251,13 @@ static int erofs_init_device(struct erofs_buf *buf, 
struct super_block *sb,
return PTR_ERR(fscache);
dif->fscache = fscache;
} else if (!sbi->devs->flatdev) {
-   bdev = blkdev_get_by_path(dif->path, BLK_OPEN_READ, sb->s_type,
- NULL);
-   if (IS_ERR(bdev))
-   return PTR_ERR(bdev);
-   dif->bdev = bdev;
-   dif->dax_dev = fs_dax_get_by_bdev(bdev, >dax_part_off,
- NULL, NULL);
+   bdev_handle = bdev_open_by_path(dif->path, BLK_OPEN_READ,
+   sb->s_type, NULL);
+   if (IS_ERR(bdev_handle))
+   return PTR_ERR(bdev_handle);
+   dif->bdev_handle = bdev_handle;
+   dif->dax_dev = fs_dax_get_by_bdev(bdev_handle->bdev,
+   >dax_part_off, NULL, NULL);
}
 
dif->blocks = le32_to_cpu(dis->blocks);
@@ -806,8 +806,8 @@ static int erofs_release_device_info(int id, void *ptr, 
void *data)
struct erofs_device_info *dif = ptr;
 
fs_put_dax(dif->dax_dev, NULL);
-   if (dif->bdev)
-   blkdev_put(dif->bdev, _fs_type);
+   if (dif->bdev_handle)
+   bdev_release(dif->bdev_handle);
erofs_fscache_unregister_cookie(dif->fscache);
dif->fscache = NULL;
kfree(dif->path);
-- 
2.35.3



Re: [PATCH 21/29] erofs: Convert to use bdev_open_by_path()

2023-08-25 Thread Christian Brauner
On Wed, Aug 23, 2023 at 12:48:32PM +0200, Jan Kara wrote:
> Convert erofs to use bdev_open_by_path() and pass the handle around.
> 
> CC: Gao Xiang 
> CC: Chao Yu 
> CC: linux-erofs@lists.ozlabs.org
> Acked-by: Christoph Hellwig 
> Acked-by: Gao Xiang 
> Signed-off-by: Jan Kara 
> ---

Looks good to me,
Reviewed-by: Christian Brauner 


[PATCH 21/29] erofs: Convert to use bdev_open_by_path()

2023-08-23 Thread Jan Kara
Convert erofs to use bdev_open_by_path() and pass the handle around.

CC: Gao Xiang 
CC: Chao Yu 
CC: linux-erofs@lists.ozlabs.org
Acked-by: Christoph Hellwig 
Acked-by: Gao Xiang 
Signed-off-by: Jan Kara 
---
 fs/erofs/data.c |  4 ++--
 fs/erofs/internal.h |  2 +-
 fs/erofs/super.c| 20 ++--
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index db5e4b7636ec..1fa60cfff267 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -222,7 +222,7 @@ int erofs_map_dev(struct super_block *sb, struct 
erofs_map_dev *map)
up_read(>rwsem);
return 0;
}
-   map->m_bdev = dif->bdev;
+   map->m_bdev = dif->bdev_handle->bdev;
map->m_daxdev = dif->dax_dev;
map->m_dax_part_off = dif->dax_part_off;
map->m_fscache = dif->fscache;
@@ -240,7 +240,7 @@ int erofs_map_dev(struct super_block *sb, struct 
erofs_map_dev *map)
if (map->m_pa >= startoff &&
map->m_pa < startoff + length) {
map->m_pa -= startoff;
-   map->m_bdev = dif->bdev;
+   map->m_bdev = dif->bdev_handle->bdev;
map->m_daxdev = dif->dax_dev;
map->m_dax_part_off = dif->dax_part_off;
map->m_fscache = dif->fscache;
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 36e32fa542f0..fabd3bb0c194 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -47,7 +47,7 @@ typedef u32 erofs_blk_t;
 struct erofs_device_info {
char *path;
struct erofs_fscache *fscache;
-   struct block_device *bdev;
+   struct bdev_handle *bdev_handle;
struct dax_device *dax_dev;
u64 dax_part_off;
 
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 566f68ddfa36..366a46fe7fdc 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -230,7 +230,7 @@ static int erofs_init_device(struct erofs_buf *buf, struct 
super_block *sb,
struct erofs_sb_info *sbi = EROFS_SB(sb);
struct erofs_fscache *fscache;
struct erofs_deviceslot *dis;
-   struct block_device *bdev;
+   struct bdev_handle *bdev_handle;
void *ptr;
 
ptr = erofs_read_metabuf(buf, sb, erofs_blknr(sb, *pos), EROFS_KMAP);
@@ -254,13 +254,13 @@ static int erofs_init_device(struct erofs_buf *buf, 
struct super_block *sb,
return PTR_ERR(fscache);
dif->fscache = fscache;
} else if (!sbi->devs->flatdev) {
-   bdev = blkdev_get_by_path(dif->path, BLK_OPEN_READ, sb->s_type,
- NULL);
-   if (IS_ERR(bdev))
-   return PTR_ERR(bdev);
-   dif->bdev = bdev;
-   dif->dax_dev = fs_dax_get_by_bdev(bdev, >dax_part_off,
- NULL, NULL);
+   bdev_handle = bdev_open_by_path(dif->path, BLK_OPEN_READ,
+   sb->s_type, NULL);
+   if (IS_ERR(bdev_handle))
+   return PTR_ERR(bdev_handle);
+   dif->bdev_handle = bdev_handle;
+   dif->dax_dev = fs_dax_get_by_bdev(bdev_handle->bdev,
+   >dax_part_off, NULL, NULL);
}
 
dif->blocks = le32_to_cpu(dis->blocks);
@@ -815,8 +815,8 @@ static int erofs_release_device_info(int id, void *ptr, 
void *data)
struct erofs_device_info *dif = ptr;
 
fs_put_dax(dif->dax_dev, NULL);
-   if (dif->bdev)
-   blkdev_put(dif->bdev, _fs_type);
+   if (dif->bdev_handle)
+   bdev_release(dif->bdev_handle);
erofs_fscache_unregister_cookie(dif->fscache);
dif->fscache = NULL;
kfree(dif->path);
-- 
2.35.3



[PATCH 21/29] erofs: Convert to use bdev_open_by_path()

2023-08-11 Thread Jan Kara
Convert erofs to use bdev_open_by_path() and pass the handle around.

CC: Gao Xiang 
CC: Chao Yu 
CC: linux-erofs@lists.ozlabs.org
Acked-by: Gao Xiang 
Signed-off-by: Jan Kara 
---
 fs/erofs/data.c |  4 ++--
 fs/erofs/internal.h |  2 +-
 fs/erofs/super.c| 20 ++--
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index db5e4b7636ec..1fa60cfff267 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -222,7 +222,7 @@ int erofs_map_dev(struct super_block *sb, struct 
erofs_map_dev *map)
up_read(>rwsem);
return 0;
}
-   map->m_bdev = dif->bdev;
+   map->m_bdev = dif->bdev_handle->bdev;
map->m_daxdev = dif->dax_dev;
map->m_dax_part_off = dif->dax_part_off;
map->m_fscache = dif->fscache;
@@ -240,7 +240,7 @@ int erofs_map_dev(struct super_block *sb, struct 
erofs_map_dev *map)
if (map->m_pa >= startoff &&
map->m_pa < startoff + length) {
map->m_pa -= startoff;
-   map->m_bdev = dif->bdev;
+   map->m_bdev = dif->bdev_handle->bdev;
map->m_daxdev = dif->dax_dev;
map->m_dax_part_off = dif->dax_part_off;
map->m_fscache = dif->fscache;
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 36e32fa542f0..fabd3bb0c194 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -47,7 +47,7 @@ typedef u32 erofs_blk_t;
 struct erofs_device_info {
char *path;
struct erofs_fscache *fscache;
-   struct block_device *bdev;
+   struct bdev_handle *bdev_handle;
struct dax_device *dax_dev;
u64 dax_part_off;
 
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 9d6a3c6158bd..ce163b456d4a 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -230,7 +230,7 @@ static int erofs_init_device(struct erofs_buf *buf, struct 
super_block *sb,
struct erofs_sb_info *sbi = EROFS_SB(sb);
struct erofs_fscache *fscache;
struct erofs_deviceslot *dis;
-   struct block_device *bdev;
+   struct bdev_handle *bdev_handle;
void *ptr;
 
ptr = erofs_read_metabuf(buf, sb, erofs_blknr(sb, *pos), EROFS_KMAP);
@@ -254,13 +254,13 @@ static int erofs_init_device(struct erofs_buf *buf, 
struct super_block *sb,
return PTR_ERR(fscache);
dif->fscache = fscache;
} else if (!sbi->devs->flatdev) {
-   bdev = blkdev_get_by_path(dif->path, BLK_OPEN_READ, sb->s_type,
- NULL);
-   if (IS_ERR(bdev))
-   return PTR_ERR(bdev);
-   dif->bdev = bdev;
-   dif->dax_dev = fs_dax_get_by_bdev(bdev, >dax_part_off,
- NULL, NULL);
+   bdev_handle = bdev_open_by_path(dif->path, BLK_OPEN_READ,
+   sb->s_type, NULL);
+   if (IS_ERR(bdev_handle))
+   return PTR_ERR(bdev_handle);
+   dif->bdev_handle = bdev_handle;
+   dif->dax_dev = fs_dax_get_by_bdev(bdev_handle->bdev,
+   >dax_part_off, NULL, NULL);
}
 
dif->blocks = le32_to_cpu(dis->blocks);
@@ -815,8 +815,8 @@ static int erofs_release_device_info(int id, void *ptr, 
void *data)
struct erofs_device_info *dif = ptr;
 
fs_put_dax(dif->dax_dev, NULL);
-   if (dif->bdev)
-   blkdev_put(dif->bdev, _fs_type);
+   if (dif->bdev_handle)
+   bdev_release(dif->bdev_handle);
erofs_fscache_unregister_cookie(dif->fscache);
dif->fscache = NULL;
kfree(dif->path);
-- 
2.35.3