lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210512144944.GY26415@redhat.com>
Date:   Wed, 12 May 2021 15:49:44 +0100
From:   "Richard W.M. Jones" <rjones@...hat.com>
To:     Shachar Sharon <synarete@...il.com>
Cc:     miklos@...redi.hu, linux-fsdevel@...r.kernel.org,
        linux-kernel@...r.kernel.org, eblake@...hat.com,
        libguestfs@...hat.com
Subject: Re: [PATCH v2] fuse: Allow fallocate(FALLOC_FL_ZERO_RANGE)

On Wed, May 12, 2021 at 05:27:22PM +0300, Shachar Sharon wrote:
> On Wed, May 12, 2021 at 11:37:04AM +0100, Richard W.M. Jones wrote:
> >libnbd's nbdfuse utility would like to translate fallocate zero
> >requests into NBD_CMD_WRITE_ZEROES.  Currently the fuse module filters
> >these out, returning -EOPNOTSUPP.  This commit treats these almost the
> >same way as FALLOC_FL_PUNCH_HOLE except not calling
> >truncate_pagecache_range.
> >
> Why don't you call 'truncate_pagecache_range' ?

Very good point.  I just assumed that it would only be useful when
hole-punching, but now I actually read the description of the function
I see we need it.

Also looking at other filesystems that also support FALLOC_FL_ZERO_RANGE:

  ext4_zero_range -> calls truncate_pagecache_range
  f2fs_zero_range -> calls it
  xfs -> calls it indirectly
  btrfs_zero_range -> does not call it (?)

I'll add this, and retest everything.

> >A way to test this is with the following script:

In my next version I'll also address this script which is rather
long-winded.  I think there's an easier way for people to test this:

> >--------------------
> > #!/bin/bash
> > # Requires fuse >= 3, nbdkit >= 1.8, and latest nbdfuse from
> > # https://gitlab.com/nbdkit/libnbd/-/tree/master/fuse
> > set -e
> > set -x
> >
> > export output=$PWD/output
> > rm -f test.img $output
> >
> > # Create an nbdkit instance that prints the NBD requests seen.
> > nbdkit sh - <<'EOF'
> > case "$1" in
> >   get_size) echo 1M ;;
> >   can_write|can_trim|can_zero|can_fast_zero) ;;
> >   pread) echo "$@" >>$output; dd if=/dev/zero count=$3 iflag=count_bytes ;;
> >   pwrite) echo "$@" >>$output; cat >/dev/null ;;
> >   trim|zero) echo "$@" >>$output ;;
> >   *) exit 2 ;;
> > esac
[etc]
> >diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> >index 09ef2a4d25ed..22e8e88c78d4 100644
> >--- a/fs/fuse/file.c
> >+++ b/fs/fuse/file.c
> >@@ -2907,11 +2907,13 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
> >	};
> >	int err;
> >	bool lock_inode = !(mode & FALLOC_FL_KEEP_SIZE) ||
> >-			   (mode & FALLOC_FL_PUNCH_HOLE);
> >+			   (mode & FALLOC_FL_PUNCH_HOLE) ||
> >+			   (mode & FALLOC_FL_ZERO_RANGE);
> To stay aligned with existing code style, consider:
> -			   (mode & FALLOC_FL_PUNCH_HOLE);
> +»      »       »          (mode & (FALLOC_FL_PUNCH_HOLE |
> +»      »       »       »           FALLOC_FL_ZERO_RANGE));

Good idea.

Thanks for the quick review.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ