Re: [PATCH v10 04/14] btrfs: add ram_bytes and offset to btrfs_ordered_extent

Omar Sandoval
2021-08-20T17:43:36Z

On Fri, Aug 20, 2021 at 11:34:17AM +0300, Nikolay Borisov wrote:
>
>
> On 18.08.21 г. 0:06, Omar Sandoval wrote:
> > From: Omar Sandoval <osandov@fb.com>
> >
> > Currently, we only create ordered extents when ram_bytes == num_bytes
> > and offset == 0. However, RWF_ENCODED writes may create extents which
> > only refer to a subset of the full unencoded extent, so we need to plumb
>
> Can you give an example of such a case?

It happens whenever we have bookend extents. Here's an easy example:

$ dd if=/dev/zero of=file bs=12k count=1
1+0 records in
1+0 records out
12288 bytes (12 kB, 12 KiB) copied, 0.000202106 s, 60.8 MB/s
$ sync
$ truncate -s 8k file
$ sync
$ sudo ~/repos/osandov-linux/scripts/btrfs_map_physical ./file | column -ts$'\t'
FILE OFFSET FILE SIZE EXTENT OFFSET EXTENT TYPE LOGICAL SIZE LOGICAL OFFSET PHYSICAL SIZE DEVID PHYSICAL OFFSET
0 8192 0 regular,compression=zstd 12288 217173213184 4096 1 217173213184

The decompressed data is 12k, but we only use 8k for the file.