All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rjones@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH 6/9] ssh: Support BDRV_REQ_ZERO_WRITE for truncate
Date: Wed, 29 Apr 2020 10:01:12 +0100	[thread overview]
Message-ID: <20200429090112.GQ3888@redhat.com> (raw)
In-Reply-To: <20200428202905.770727-7-eblake@redhat.com>

On Tue, Apr 28, 2020 at 03:29:02PM -0500, Eric Blake wrote:
> Our .bdrv_has_zero_init_truncate can detect when the remote side
> always zero fills; we can reuse that same knowledge to implement
> BDRV_REQ_ZERO_WRITE by ignoring it when the server gives it to us for
> free.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  block/ssh.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/block/ssh.c b/block/ssh.c
> index 9eb33df8598c..f9e08a490069 100644
> --- a/block/ssh.c
> +++ b/block/ssh.c
> @@ -883,6 +883,10 @@ static int ssh_file_open(BlockDriverState *bs, QDict *options, int bdrv_flags,
>      /* Go non-blocking. */
>      ssh_set_blocking(s->session, 0);
> 
> +    if (s->attrs->type == SSH_FILEXFER_TYPE_REGULAR) {
> +        bs->supported_truncate_flags = BDRV_REQ_ZERO_WRITE;
> +    }
> +

As the libssh sftp API is written this is all fine, so ACK:

Reviewed-by: Richard W.M. Jones <rjones@redhat.com>

On the other hand the actual openssh / libssh code is a bit hairy.
Openssh simply copies the st_mode field onto the wire (with
byte-swapping).  Libssh assumes that S_IFREG == 0100000 and translates
this bit to SSH_FILEXFER_TYPE_REGULAR.  This happens to be true on
Linux and *BSD but as far as I can tell isn't defined in POSIX.
Anyway I guess it'll work in all places that we care about.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top



  reply	other threads:[~2020-04-29  9:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 20:28 [PATCH 0/9] More truncate improvements Eric Blake
2020-04-28 20:28 ` [PATCH 1/9] gluster: Drop useless has_zero_init callback Eric Blake
2020-04-28 20:28 ` [PATCH 2/9] file-win32: Support BDRV_REQ_ZERO_WRITE for truncate Eric Blake
2020-04-28 20:28 ` [PATCH 3/9] nfs: " Eric Blake
2020-04-28 20:29 ` [PATCH 4/9] rbd: " Eric Blake
2020-04-28 20:29 ` [PATCH 5/9] sheepdog: " Eric Blake
2020-04-28 20:29 ` [PATCH 6/9] ssh: " Eric Blake
2020-04-29  9:01   ` Richard W.M. Jones [this message]
2020-04-28 20:29 ` [PATCH 7/9] parallels: Rework truncation logic Eric Blake
2020-05-07 11:14   ` Denis V. Lunev
2020-04-28 20:29 ` [PATCH 8/9] vhdx: " Eric Blake
2020-04-28 20:29 ` [PATCH 9/9] block: Drop unused .bdrv_has_zero_init_truncate Eric Blake
2020-04-29  9:02   ` Richard W.M. Jones
2020-04-29  2:24 ` [PATCH 0/9] More truncate improvements no-reply
2020-04-29 13:14   ` Eric Blake
2020-04-29  2:24 ` no-reply
2020-05-06 13:03 ` Eric Blake
2020-05-07 10:15 ` Kevin Wolf
2020-05-07 14:29   ` Eric Blake
2020-05-07 14:32     ` Kevin Wolf

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=20200429090112.GQ3888@redhat.com \
    --to=rjones@redhat.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.