qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, qemu-devel@nongnu.org
Cc: Kyle Evans <kevans@freebsd.org>, Ed Maste <emaste@freebsd.org>,
	Li-Wen Hsu <lwhsu@freebsd.org>,
	qemu-block@nongnu.org,
	Fabrice Fontaine <fontaine.fabrice@gmail.com>
Subject: Re: [PATCH v2 2/3] block/export/fuse: Extract fuse_fallocate_zero_range()
Date: Tue, 25 Jan 2022 12:28:40 +0100	[thread overview]
Message-ID: <b54be5b8-29e9-ca08-553a-a0635f0ebb83@redhat.com> (raw)
In-Reply-To: <20220124220357.74017-3-f4bug@amsat.org>

On 24/01/2022 23.03, Philippe Mathieu-Daudé via wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   block/export/fuse.c | 48 +++++++++++++++++++++++++++++----------------
>   1 file changed, 31 insertions(+), 17 deletions(-)
> 
> diff --git a/block/export/fuse.c b/block/export/fuse.c
> index 31cb0503adc..3a158342c75 100644
> --- a/block/export/fuse.c
> +++ b/block/export/fuse.c
> @@ -603,6 +603,35 @@ static void fuse_write(fuse_req_t req, fuse_ino_t inode, const char *buf,
>       }
>   }
>   
> +static bool fuse_fallocate_punch_hole(fuse_req_t req, fuse_ino_t inode,
> +                                      int mode, int64_t blk_len,
> +                                      off_t offset, off_t *length)
> +{
> +    FuseExport *exp = fuse_req_userdata(req);
> +
> +    if (mode & FALLOC_FL_KEEP_SIZE) {
> +        *length = MIN(*length, blk_len - offset);
> +    }
> +
> +    if (mode & FALLOC_FL_PUNCH_HOLE) {
> +        int ret;
> +
> +        if (!(mode & FALLOC_FL_KEEP_SIZE)) {
> +            fuse_reply_err(req, EINVAL);
> +            return false;
> +        }
> +
> +        do {
> +            int size = MIN(*length, BDRV_REQUEST_MAX_BYTES);
> +
> +            ret = blk_pdiscard(exp->common.blk, offset, size);
> +            offset += size;
> +            *length -= size;
> +        } while (ret == 0 && *length > 0);
> +    }
> +    return true;
> +}
> +
>   static bool fuse_fallocate_zero_range(fuse_req_t req, fuse_ino_t inode,
>                                         int mode, int64_t blk_len,
>                                         off_t offset, off_t *length)
> @@ -657,23 +686,8 @@ static void fuse_fallocate(fuse_req_t req, fuse_ino_t inode, int mode,
>           return;
>       }
>   
> -    if (mode & FALLOC_FL_KEEP_SIZE) {
> -        length = MIN(length, blk_len - offset);
> -    }
> -
> -    if (mode & FALLOC_FL_PUNCH_HOLE) {
> -        if (!(mode & FALLOC_FL_KEEP_SIZE)) {
> -            fuse_reply_err(req, EINVAL);
> -            return;
> -        }
> -
> -        do {
> -            int size = MIN(length, BDRV_REQUEST_MAX_BYTES);
> -
> -            ret = blk_pdiscard(exp->common.blk, offset, size);
> -            offset += size;
> -            length -= size;
> -        } while (ret == 0 && length > 0);
> +    if (!fuse_fallocate_punch_hole(req, inode, mode, blk_len, offset, &length)) {
> +        return;

Same issue as with the previous patch? If the do-while loop has been 
executed, the else branches below should not be called...

  Thomas

>       } else if (!fuse_fallocate_zero_range(req, inode, blk_len, mode, offset, &length)) {
>           return;
>       } else if (!mode) {



  reply	other threads:[~2022-01-25 11:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24 22:03 [PATCH v2 0/3] block/export/fuse: Fix build failure on FreeBSD Philippe Mathieu-Daudé via
2022-01-24 22:03 ` [PATCH v2 1/3] block/export/fuse: Extract fuse_fallocate_punch_hole() Philippe Mathieu-Daudé via
2022-01-25 11:10   ` Thomas Huth
2022-01-25 16:02     ` Philippe Mathieu-Daudé via
2022-01-24 22:03 ` [PATCH v2 2/3] block/export/fuse: Extract fuse_fallocate_zero_range() Philippe Mathieu-Daudé via
2022-01-25 11:28   ` Thomas Huth [this message]
2022-01-24 22:03 ` [PATCH v2 3/3] block/export/fuse: Fix build failure on FreeBSD Philippe Mathieu-Daudé via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b54be5b8-29e9-ca08-553a-a0635f0ebb83@redhat.com \
    --to=thuth@redhat.com \
    --cc=emaste@freebsd.org \
    --cc=f4bug@amsat.org \
    --cc=fontaine.fabrice@gmail.com \
    --cc=kevans@freebsd.org \
    --cc=lwhsu@freebsd.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).