* [RFC PATCH] block/export/fuse: Fix build failure on FreeBSD
@ 2022-01-22 13:49 Philippe Mathieu-Daudé via
2022-01-27 16:15 ` Kevin Wolf
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-01-22 13:49 UTC (permalink / raw)
To: qemu-devel
Cc: Hanna Reitz, Fabrice Fontaine, qemu-block, Ed Maste, Li-Wen Hsu,
Kevin Wolf, Kyle Evans, Philippe Mathieu-Daudé
When building on FreeBSD we get:
[816/6851] Compiling C object libblockdev.fa.p/block_export_fuse.c.o
../block/export/fuse.c:628:16: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE'
if (mode & FALLOC_FL_KEEP_SIZE) {
^
../block/export/fuse.c:632:16: error: use of undeclared identifier 'FALLOC_FL_PUNCH_HOLE'
if (mode & FALLOC_FL_PUNCH_HOLE) {
^
../block/export/fuse.c:633:22: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE'
if (!(mode & FALLOC_FL_KEEP_SIZE)) {
^
3 errors generated.
FAILED: libblockdev.fa.p/block_export_fuse.c.o
Meson indeed reported FALLOC_FL_PUNCH_HOLE is not available:
C compiler for the host machine: cc (clang 10.0.1 "FreeBSD clang version 10.0.1")
Checking for function "fallocate" : NO
Checking for function "posix_fallocate" : YES
Header <linux/falloc.h> has symbol "FALLOC_FL_PUNCH_HOLE" : NO
Header <linux/falloc.h> has symbol "FALLOC_FL_ZERO_RANGE" : NO
...
Similarly to commit 304332039 ("block/export/fuse.c: fix musl build"),
guard the code requiring FALLOC_FL_KEEP_SIZE / FALLOC_FL_PUNCH_HOLE
definitions under CONFIG_FALLOCATE_PUNCH_HOLE #ifdef'ry.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Fragile #ifdef'ry... Any clever idea?
ERROR: else should follow close brace '}'
#17: FILE: block/export/fuse.c:647:
}
+ else
ERROR: else should follow close brace '}'
#29: FILE: block/export/fuse.c:670:
}
+ else
total: 2 errors, 0 warnings, 28 lines checked
---
block/export/fuse.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/block/export/fuse.c b/block/export/fuse.c
index 6710d8aed86..d8bad0e53df 100644
--- a/block/export/fuse.c
+++ b/block/export/fuse.c
@@ -625,6 +625,7 @@ static void fuse_fallocate(fuse_req_t req, fuse_ino_t inode, int mode,
return;
}
+#ifdef CONFIG_FALLOCATE_PUNCH_HOLE
if (mode & FALLOC_FL_KEEP_SIZE) {
length = MIN(length, blk_len - offset);
}
@@ -643,8 +644,10 @@ static void fuse_fallocate(fuse_req_t req, fuse_ino_t inode, int mode,
length -= size;
} while (ret == 0 && length > 0);
}
+ else
+#endif /* CONFIG_FALLOCATE_PUNCH_HOLE */
#ifdef CONFIG_FALLOCATE_ZERO_RANGE
- else if (mode & FALLOC_FL_ZERO_RANGE) {
+ if (mode & FALLOC_FL_ZERO_RANGE) {
if (!(mode & FALLOC_FL_KEEP_SIZE) && offset + length > blk_len) {
/* No need for zeroes, we are going to write them ourselves */
ret = fuse_do_truncate(exp, offset + length, false,
@@ -664,8 +667,9 @@ static void fuse_fallocate(fuse_req_t req, fuse_ino_t inode, int mode,
length -= size;
} while (ret == 0 && length > 0);
}
+ else
#endif /* CONFIG_FALLOCATE_ZERO_RANGE */
- else if (!mode) {
+ if (!mode) {
/* We can only fallocate at the EOF with a truncate */
if (offset < blk_len) {
fuse_reply_err(req, EOPNOTSUPP);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] block/export/fuse: Fix build failure on FreeBSD
2022-01-22 13:49 [RFC PATCH] block/export/fuse: Fix build failure on FreeBSD Philippe Mathieu-Daudé via
@ 2022-01-27 16:15 ` Kevin Wolf
2022-02-01 11:14 ` Philippe Mathieu-Daudé via
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2022-01-27 16:15 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Ed Maste, qemu-block, Kyle Evans, qemu-devel, Fabrice Fontaine,
Hanna Reitz, Li-Wen Hsu
Am 22.01.2022 um 14:49 hat Philippe Mathieu-Daudé geschrieben:
> When building on FreeBSD we get:
>
> [816/6851] Compiling C object libblockdev.fa.p/block_export_fuse.c.o
> ../block/export/fuse.c:628:16: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE'
> if (mode & FALLOC_FL_KEEP_SIZE) {
> ^
> ../block/export/fuse.c:632:16: error: use of undeclared identifier 'FALLOC_FL_PUNCH_HOLE'
> if (mode & FALLOC_FL_PUNCH_HOLE) {
> ^
> ../block/export/fuse.c:633:22: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE'
> if (!(mode & FALLOC_FL_KEEP_SIZE)) {
> ^
> 3 errors generated.
> FAILED: libblockdev.fa.p/block_export_fuse.c.o
>
> Meson indeed reported FALLOC_FL_PUNCH_HOLE is not available:
>
> C compiler for the host machine: cc (clang 10.0.1 "FreeBSD clang version 10.0.1")
> Checking for function "fallocate" : NO
> Checking for function "posix_fallocate" : YES
> Header <linux/falloc.h> has symbol "FALLOC_FL_PUNCH_HOLE" : NO
> Header <linux/falloc.h> has symbol "FALLOC_FL_ZERO_RANGE" : NO
> ...
>
> Similarly to commit 304332039 ("block/export/fuse.c: fix musl build"),
> guard the code requiring FALLOC_FL_KEEP_SIZE / FALLOC_FL_PUNCH_HOLE
> definitions under CONFIG_FALLOCATE_PUNCH_HOLE #ifdef'ry.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> Fragile #ifdef'ry... Any clever idea?
I guess we could reorder things. The last case (!mode) is mutually
exclusive with the other conditions, so checking it first doesn't make a
difference, and then you can #ifdef things out more cleanly.
> ERROR: else should follow close brace '}'
> #17: FILE: block/export/fuse.c:647:
> }
> + else
>
> ERROR: else should follow close brace '}'
> #29: FILE: block/export/fuse.c:670:
> }
> + else
>
> total: 2 errors, 0 warnings, 28 lines checked
On the other hand, I'm not really worried about these either. The only
way this could fail in the future is build errors, which are obvious and
quick to fix.
If you hadn't marked this an RFC, I think I would just have applied it.
Kevin
> ---
> block/export/fuse.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/block/export/fuse.c b/block/export/fuse.c
> index 6710d8aed86..d8bad0e53df 100644
> --- a/block/export/fuse.c
> +++ b/block/export/fuse.c
> @@ -625,6 +625,7 @@ static void fuse_fallocate(fuse_req_t req, fuse_ino_t inode, int mode,
> return;
> }
>
> +#ifdef CONFIG_FALLOCATE_PUNCH_HOLE
> if (mode & FALLOC_FL_KEEP_SIZE) {
> length = MIN(length, blk_len - offset);
> }
> @@ -643,8 +644,10 @@ static void fuse_fallocate(fuse_req_t req, fuse_ino_t inode, int mode,
> length -= size;
> } while (ret == 0 && length > 0);
> }
> + else
> +#endif /* CONFIG_FALLOCATE_PUNCH_HOLE */
> #ifdef CONFIG_FALLOCATE_ZERO_RANGE
> - else if (mode & FALLOC_FL_ZERO_RANGE) {
> + if (mode & FALLOC_FL_ZERO_RANGE) {
> if (!(mode & FALLOC_FL_KEEP_SIZE) && offset + length > blk_len) {
> /* No need for zeroes, we are going to write them ourselves */
> ret = fuse_do_truncate(exp, offset + length, false,
> @@ -664,8 +667,9 @@ static void fuse_fallocate(fuse_req_t req, fuse_ino_t inode, int mode,
> length -= size;
> } while (ret == 0 && length > 0);
> }
> + else
> #endif /* CONFIG_FALLOCATE_ZERO_RANGE */
> - else if (!mode) {
> + if (!mode) {
> /* We can only fallocate at the EOF with a truncate */
> if (offset < blk_len) {
> fuse_reply_err(req, EOPNOTSUPP);
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] block/export/fuse: Fix build failure on FreeBSD
2022-01-27 16:15 ` Kevin Wolf
@ 2022-02-01 11:14 ` Philippe Mathieu-Daudé via
0 siblings, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-01 11:14 UTC (permalink / raw)
To: Kevin Wolf
Cc: qemu-devel, Hanna Reitz, Fabrice Fontaine, qemu-block, Ed Maste,
Li-Wen Hsu, Kyle Evans
On 1/27/22 17:15, Kevin Wolf wrote:
> Am 22.01.2022 um 14:49 hat Philippe Mathieu-Daudé geschrieben:
>> When building on FreeBSD we get:
>>
>> [816/6851] Compiling C object libblockdev.fa.p/block_export_fuse.c.o
>> ../block/export/fuse.c:628:16: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE'
>> if (mode & FALLOC_FL_KEEP_SIZE) {
>> ^
>> ../block/export/fuse.c:632:16: error: use of undeclared identifier 'FALLOC_FL_PUNCH_HOLE'
>> if (mode & FALLOC_FL_PUNCH_HOLE) {
>> ^
>> ../block/export/fuse.c:633:22: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE'
>> if (!(mode & FALLOC_FL_KEEP_SIZE)) {
>> ^
>> 3 errors generated.
>> FAILED: libblockdev.fa.p/block_export_fuse.c.o
>>
>> Meson indeed reported FALLOC_FL_PUNCH_HOLE is not available:
>>
>> C compiler for the host machine: cc (clang 10.0.1 "FreeBSD clang version 10.0.1")
>> Checking for function "fallocate" : NO
>> Checking for function "posix_fallocate" : YES
>> Header <linux/falloc.h> has symbol "FALLOC_FL_PUNCH_HOLE" : NO
>> Header <linux/falloc.h> has symbol "FALLOC_FL_ZERO_RANGE" : NO
>> ...
>>
>> Similarly to commit 304332039 ("block/export/fuse.c: fix musl build"),
>> guard the code requiring FALLOC_FL_KEEP_SIZE / FALLOC_FL_PUNCH_HOLE
>> definitions under CONFIG_FALLOCATE_PUNCH_HOLE #ifdef'ry.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> Fragile #ifdef'ry... Any clever idea?
>
> I guess we could reorder things. The last case (!mode) is mutually
> exclusive with the other conditions, so checking it first doesn't make a
> difference, and then you can #ifdef things out more cleanly.
This is indeed clever, thanks! v3 soon.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-01 11:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-22 13:49 [RFC PATCH] block/export/fuse: Fix build failure on FreeBSD Philippe Mathieu-Daudé via
2022-01-27 16:15 ` Kevin Wolf
2022-02-01 11:14 ` Philippe Mathieu-Daudé via
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).