[PATCH] gluster: stop using .bdrv_needs_filename

Stefan Hajnoczi posted 1 patch 1 year, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220811164905.430834-1-stefanha@redhat.com
Maintainers: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
block/gluster.c | 4 ----
1 file changed, 4 deletions(-)
[PATCH] gluster: stop using .bdrv_needs_filename
Posted by Stefan Hajnoczi 1 year, 7 months ago
The gluster protocol driver used to parse URIs (filenames) but was
extended with a richer JSON syntax in commit 6c7189bb29de
("block/gluster: add support for multiple gluster servers"). The gluster
drivers that have JSON parsing set .bdrv_needs_filename to false.

The gluster+unix and gluster+rdma drivers still to require a filename
even though the JSON parser is equipped to parse the same
volume/path/sockaddr details as the URI parser. Let's allow JSON parsing
for these drivers too.

Note that the gluster+rdma driver actually uses TCP because RDMA support
is not available, so the JSON server.type field must be "inet".

Drop .bdrv_needs_filename since both the filename and the JSON parsers
can handle gluster+unix and gluster+rdma. This change is in preparation
for eventually removing .bdrv_needs_filename across the entire codebase.

Cc: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
My motivation was to remove .bdrv_needs_filename across the entire
codebase, but my confidence in avoiding regressions is too low so I gave
up. There is too much magic around the filename. Most drivers don't want
a "filename" QDict entry although .bdrv_parse_filename() places the
filename string there temporarily. But file-posix does want a "filename"
QDict entry so it breaks when we remove .bdrv_needs_filename. I'm pretty
sure it's accidental complexity but it's hard to simplify without
breaking block drivers.

This gluster patch can be merged though, so I'm sending it.

 block/gluster.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/block/gluster.c b/block/gluster.c
index b60213ab80..bb1144cf6a 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -1555,7 +1555,6 @@ static BlockDriver bdrv_gluster = {
     .format_name                  = "gluster",
     .protocol_name                = "gluster",
     .instance_size                = sizeof(BDRVGlusterState),
-    .bdrv_needs_filename          = false,
     .bdrv_file_open               = qemu_gluster_open,
     .bdrv_reopen_prepare          = qemu_gluster_reopen_prepare,
     .bdrv_reopen_commit           = qemu_gluster_reopen_commit,
@@ -1585,7 +1584,6 @@ static BlockDriver bdrv_gluster_tcp = {
     .format_name                  = "gluster",
     .protocol_name                = "gluster+tcp",
     .instance_size                = sizeof(BDRVGlusterState),
-    .bdrv_needs_filename          = false,
     .bdrv_file_open               = qemu_gluster_open,
     .bdrv_reopen_prepare          = qemu_gluster_reopen_prepare,
     .bdrv_reopen_commit           = qemu_gluster_reopen_commit,
@@ -1615,7 +1613,6 @@ static BlockDriver bdrv_gluster_unix = {
     .format_name                  = "gluster",
     .protocol_name                = "gluster+unix",
     .instance_size                = sizeof(BDRVGlusterState),
-    .bdrv_needs_filename          = true,
     .bdrv_file_open               = qemu_gluster_open,
     .bdrv_reopen_prepare          = qemu_gluster_reopen_prepare,
     .bdrv_reopen_commit           = qemu_gluster_reopen_commit,
@@ -1651,7 +1648,6 @@ static BlockDriver bdrv_gluster_rdma = {
     .format_name                  = "gluster",
     .protocol_name                = "gluster+rdma",
     .instance_size                = sizeof(BDRVGlusterState),
-    .bdrv_needs_filename          = true,
     .bdrv_file_open               = qemu_gluster_open,
     .bdrv_reopen_prepare          = qemu_gluster_reopen_prepare,
     .bdrv_reopen_commit           = qemu_gluster_reopen_commit,
-- 
2.37.1
Re: [PATCH] gluster: stop using .bdrv_needs_filename
Posted by Kevin Wolf 1 year, 6 months ago
Am 11.08.2022 um 18:49 hat Stefan Hajnoczi geschrieben:
> The gluster protocol driver used to parse URIs (filenames) but was
> extended with a richer JSON syntax in commit 6c7189bb29de
> ("block/gluster: add support for multiple gluster servers"). The gluster
> drivers that have JSON parsing set .bdrv_needs_filename to false.
> 
> The gluster+unix and gluster+rdma drivers still to require a filename
> even though the JSON parser is equipped to parse the same
> volume/path/sockaddr details as the URI parser. Let's allow JSON parsing
> for these drivers too.
> 
> Note that the gluster+rdma driver actually uses TCP because RDMA support
> is not available, so the JSON server.type field must be "inet".
> 
> Drop .bdrv_needs_filename since both the filename and the JSON parsers
> can handle gluster+unix and gluster+rdma. This change is in preparation
> for eventually removing .bdrv_needs_filename across the entire codebase.
> 
> Cc: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

Thanks, applied to the block branch.

Kevin