Re: [RFC 4/9] dm: add llseek(SEEK_HOLE/SEEK_DATA) support

2024-04-03 Thread Eric Blake
through dm.c, and > into dm-linear.c to see how to make things clearest. Although I would > like to have the same semantics for every seek function, maybe in the > end your suggestion will make the code clearer. Let's see. Keeping lseek semantics may require a couple more lines

Re: [RFC 4/9] dm: add llseek(SEEK_HOLE/SEEK_DATA) support

2024-04-03 Thread Eric Blake
On Wed, Apr 03, 2024 at 10:11:47AM -0400, Stefan Hajnoczi wrote: ... > > > +static loff_t dm_blk_do_seek_hole_data(struct dm_table *table, loff_t > > > offset, > > > + int whence) > > > +{ > > > + struct dm_target *ti; > > > + loff_t end; > > > + > > > + /* Loop when the end of a target is

Re: [RFC 0/9] block: add llseek(SEEK_HOLE/SEEK_DATA) support

2024-04-02 Thread Eric Blake
her the community would be open to introducing new SEEK_* constants to allow orthogonality between searching for zeroes (known to read as zero, whether or not it was allocated) vs. sparseness (known to be unallocated, whether or not it reads as zero), where the existing SEEK_HOLE seeks for both p

Re: [RFC 3/9] selftests: block_seek_hole: add loop block driver tests

2024-03-29 Thread Eric Blake
would prove that even though block devices generally operate on a minimum granularity of a sector, lseek() still gives byte-accurate results for a random offset that falls in the middle of a sector, and doesn't accidentally round down reporting an offset less than the value passed in to the request. -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org

Re: [RFC 8/9] dm thin: add llseek(SEEK_HOLE/SEEK_DATA) support

2024-03-28 Thread Eric Blake
antics you have in 4/9 (although in 6/9 I argue that having all of the dm callbacks return ti->begin + ti->len instead of -ENXIO might make logic easier for iterating through consecutive ti, and then convert to -ENXIO only in the caller). > +} > + > static struct target_type thin_ta

Re: [RFC 7/9] selftests: block_seek_hole: add dm-linear test

2024-03-28 Thread Eric Blake
e second), but without that in place, I worry that you are missing logic bugs for when there is more than one table in the overall dm (as evidenced by my review in 4/9). -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org

Re: [RFC 6/9] dm-linear: add llseek(SEEK_HOLE/SEEK_DATA) support

2024-03-28 Thread Eric Blake
ess = linear_dax_direct_access, > .dax_zero_page_range = linear_dax_zero_page_range, > .dax_recovery_write = linear_dax_recovery_write, > + .seek_hole_data = linear_seek_hole_data, > }; > > int __init dm_linear_init(void) > -- > 2.44.0 > -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org

Re: [RFC 4/9] dm: add llseek(SEEK_HOLE/SEEK_DATA) support

2024-03-28 Thread Eric Blake
equivalent of lseek(dm, 0, SEEK_END). If you make my above suggested changes, we will iterate through the do loop once more at EOF, and dm_table_find_target() will then fail to match at which point we do get the desired -ENXIO for both SEEK_HOLE and SEEK_DATA. > + > + return offset; > +} > + -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org

Re: [RFC 3/9] selftests: block_seek_hole: add loop block driver tests

2024-03-28 Thread Eric Blake
clean, even on a 32-bit system where lseek is different than lseek64? (I honestly have no idea if python always uses 64-bit seek even on 32-bit systems, although I would be surprised if it were not) -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org

Re: [RFC 2/9] loop: add llseek(SEEK_HOLE/SEEK_DATA) support

2024-03-28 Thread Eric Blake
> return -EINVAL; > } > - > + > /* Hide this loop device for serialization. */ > ret = mutex_lock_killable(&loop_ctl_mutex); > if (ret) Unrelated whitespace change? -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org

Re: [RFC 1/9] block: add llseek(SEEK_HOLE/SEEK_DATA) support

2024-03-28 Thread Eric Blake
t; Signed-off-by: Stefan Hajnoczi > --- > include/linux/blkdev.h | 7 +++ > block/fops.c | 43 +- > 2 files changed, 49 insertions(+), 1 deletion(-) > -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org

Re: [RFC 0/9] block: add llseek(SEEK_HOLE/SEEK_DATA) support

2024-03-28 Thread Eric Blake
Replying to myself, On Thu, Mar 28, 2024 at 05:17:18PM -0500, Eric Blake wrote: > On Thu, Mar 28, 2024 at 04:39:01PM -0400, Stefan Hajnoczi wrote: > > cp(1) and backup tools use llseek(SEEK_HOLE/SEEK_DATA) to skip holes in > > files. > > > > > In the block

Re: [RFC 5/9] selftests: block_seek_hole: add dm-zero test

2024-03-28 Thread Eric Blake
set, while an in-range SEEK_DATA returns the device size)? -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org

Re: [RFC 0/9] block: add llseek(SEEK_HOLE/SEEK_DATA) support

2024-03-28 Thread Eric Blake
ate mode 100644 tools/testing/selftests/block_seek_hole/config > create mode 100755 tools/testing/selftests/block_seek_hole/dm_thin.sh > create mode 100755 tools/testing/selftests/block_seek_hole/dm_zero.sh > create mode 100755 tools/testing/selftests/block_seek_hole/map_holes.py > create mode 100755 tools/testing/selftests/block_seek_hole/test.py > > -- > 2.44.0 > -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org