Re: [PATCH v9 1/9] iov_iter: add copy_struct_from_iter()

2021-04-02 Thread Omar Sandoval
On Fri, Apr 02, 2021 at 10:04:23AM +0200, Christian Brauner wrote: > On Fri, Apr 02, 2021 at 12:33:20AM -0700, Omar Sandoval wrote: > > On Thu, Apr 01, 2021 at 09:05:22AM -0700, Linus Torvalds wrote: > > > On Wed, Mar 31, 2021 at 11:51 PM Omar Sand

Re: [PATCH v9 1/9] iov_iter: add copy_struct_from_iter()

2021-04-02 Thread Omar Sandoval
On Thu, Apr 01, 2021 at 09:05:22AM -0700, Linus Torvalds wrote: > On Wed, Mar 31, 2021 at 11:51 PM Omar Sandoval wrote: > > > > + * > > + * The recommended usage is something like the following: > > + * > > + * if (usize > PAGE_SIZE) > > + * ret

[PATCH v9 9/9] btrfs: implement RWF_ENCODED writes

2021-03-31 Thread Omar Sandoval
From: Omar Sandoval The implementation resembles direct I/O: we have to flush any ordered extents, invalidate the page cache, and do the io tree/delalloc/extent map/ordered extent dance. From there, we can reuse the compression code with a minor modification to distinguish the write from

[PATCH v9 7/9] btrfs: optionally extend i_size in cow_file_range_inline()

2021-03-31 Thread Omar Sandoval
From: Omar Sandoval Currently, an inline extent is always created after i_size is extended from btrfs_dirty_pages(). However, for encoded writes, we only want to update i_size after we successfully created the inline extent. Add an update_i_size parameter to cow_file_range_inline() and

[PATCH v9 6/9] btrfs: support different disk extent size for delalloc

2021-03-31 Thread Omar Sandoval
From: Omar Sandoval Currently, we always reserve the same extent size in the file and extent size on disk for delalloc because the former is the worst case for the latter. For RWF_ENCODED writes, we know the exact size of the extent on disk, which may be less than or greater than (for bookends

[PATCH v9 8/9] btrfs: implement RWF_ENCODED reads

2021-03-31 Thread Omar Sandoval
From: Omar Sandoval There are 4 main cases: 1. Inline extents: we copy the data straight out of the extent buffer. 2. Hole/preallocated extents: we fill in zeroes. 3. Regular, uncompressed extents: we read the sectors we need directly from disk. 4. Regular, compressed extents: we read the

[PATCH v9 5/9] btrfs: add ram_bytes and offset to btrfs_ordered_extent

2021-03-31 Thread Omar Sandoval
From: Omar Sandoval 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 these fields through the ordered extent infrastructure and pass

[PATCH v9 3/9] fs: add RWF_ENCODED for reading/writing compressed data

2021-03-31 Thread Omar Sandoval
From: Omar Sandoval Btrfs supports transparent compression: data written by the user can be compressed when written to disk and decompressed when read back. However, we'd like to add an interface to write pre-compressed data directly to the filesystem, and the matching interface to

[PATCH v9 4/9] btrfs: don't advance offset for compressed bios in btrfs_csum_one_bio()

2021-03-31 Thread Omar Sandoval
From: Omar Sandoval btrfs_csum_one_bio() loops over each filesystem block in the bio while keeping a cursor of its current logical position in the file in order to look up the ordered extent to add the checksums to. However, this doesn't make much sense for compressed extents, as a sect

[PATCH v9 2/9] fs: add O_ALLOW_ENCODED open flag

2021-03-31 Thread Omar Sandoval
From: Omar Sandoval The upcoming RWF_ENCODED operation introduces some security concerns: 1. Compressed writes will pass arbitrary data to decompression algorithms in the kernel. 2. Compressed reads can leak truncated/hole punched data. Therefore, we need to require privilege for

[PATCH v9 0/9] fs: interface for directly reading/writing compressed data

2021-03-31 Thread Omar Sandoval
From: Omar Sandoval This series adds an API for reading compressed data on a filesystem without decompressing it as well as support for writing compressed data directly to the filesystem. I have test cases (including fsstress support) and example programs which I'll send up once the dust se

[PATCH v9 1/9] iov_iter: add copy_struct_from_iter()

2021-03-31 Thread Omar Sandoval
From: Omar Sandoval This is essentially copy_struct_from_user() but for an iov_iter. Suggested-by: Aleksa Sarai Reviewed-by: Josef Bacik Signed-off-by: Omar Sandoval --- include/linux/uio.h | 1 + lib/iov_iter.c | 91 + 2 files changed, 92

Re: [PATCH v8 00/10] fs: interface for directly reading/writing compressed data

2021-03-20 Thread Omar Sandoval
On Fri, Mar 19, 2021 at 05:31:18PM -0700, Linus Torvalds wrote: > On Fri, Mar 19, 2021 at 3:46 PM Omar Sandoval wrote: > > > > Not much shorter, but it is easier to follow. > > Yeah, that looks about right to me. > > You should probably use kmap_local_page() rather

Re: [PATCH v8 00/10] fs: interface for directly reading/writing compressed data

2021-03-19 Thread Omar Sandoval
On Fri, Mar 19, 2021 at 02:47:03PM -0700, Linus Torvalds wrote: > On Fri, Mar 19, 2021 at 2:12 PM Omar Sandoval wrote: > > > > After spending a few minutes trying to simplify copy_struct_from_iter(), > > it's honestly easier to just use the iterate_all_kinds() craziness

Re: [PATCH v8 00/10] fs: interface for directly reading/writing compressed data

2021-03-19 Thread Omar Sandoval
On Fri, Mar 19, 2021 at 01:55:18PM -0700, Linus Torvalds wrote: > On Fri, Mar 19, 2021 at 1:27 PM Omar Sandoval wrote: > > > > For RWF_ENCODED, iov[0] is always used as the entirety of the struct. I > > made the helper more generic to support other use cases, but if that

Re: [PATCH v8 00/10] fs: interface for directly reading/writing compressed data

2021-03-19 Thread Omar Sandoval
On Fri, Mar 19, 2021 at 01:08:05PM -0700, Linus Torvalds wrote: > On Fri, Mar 19, 2021 at 11:21 AM Josef Bacik wrote: > > > > Can we get some movement on this? Omar is sort of spinning his wheels here > > trying to get this stuff merged, no major changes have been done in a few > > postings. > >

Re: [PATCH 0/1] btrfs-progs: libbtrfsutil: Relicense to LGPLv2.1+

2021-03-17 Thread Omar Sandoval
> 17 files changed, 495 insertions(+), 832 deletions(-) > delete mode 100644 libbtrfsutil/COPYING.LESSER Acked-by: Omar Sandoval

Re: [PATCH v8 01/10] iov_iter: add copy_struct_from_iter()

2021-03-17 Thread Omar Sandoval
On Wed, Mar 17, 2021 at 06:56:11PM +0100, Christian Brauner wrote: > On Tue, Mar 16, 2021 at 12:42:57PM -0700, Omar Sandoval wrote: > > From: Omar Sandoval > > > > This is essentially copy_struct_from_user() but for an iov_iter. > > > > Suggested-by: Aleksa Sa

Re: [PATCH v8 04/10] btrfs: fix check_data_csum() error message for direct I/O

2021-03-17 Thread Omar Sandoval
On Wed, Mar 17, 2021 at 07:21:46PM +0800, Qu Wenruo wrote: > > > On 2021/3/17 上午3:43, Omar Sandoval wrote: > > From: Omar Sandoval > > > > Commit 1dae796aabf6 ("btrfs: inode: sink parameter start and len to > > check_data_csum()") replaced the st

[PATCH v4 11/11] btrfs-progs: receive: add tests for basic encoded_write send/receive

2021-03-16 Thread Omar Sandoval
From: Boris Burkov Adapt the existing send/receive tests by passing '-o --force-compress' to the mount commands in a new test. After writing a few files in the various compression formats, send/receive them with and without --force-decompress to test both the encoded_write path and the fallback t

[PATCH v4 08/11] btrfs-progs: receive: process fallocate commands

2021-03-16 Thread Omar Sandoval
From: Boris Burkov Send stream v2 can emit fallocate commands, so receive must support them as well. The implementation simply passes along the arguments to the syscall. Note that mode is encoded as a u32 in send stream but fallocate takes an int, so there is a unsigned->signed conversion there.

[PATCH v4 10/11] btrfs-progs: send: stream v2 ioctl flags

2021-03-16 Thread Omar Sandoval
From: Boris Burkov To make the btrfs send ioctl use the stream v2 format requires passing BTRFS_SEND_FLAG_STREAM_V2 in flags. Further, to cause the ioctl to emit encoded_write commands for encoded extents, we must set that flag as well as BTRFS_SEND_FLAG_COMPRESSED. Finally, we bump up the versio

[PATCH v4 09/11] btrfs-progs: receive: process setflags ioctl commands

2021-03-16 Thread Omar Sandoval
From: Boris Burkov In send stream v2, send can emit a command for setting inode flags via the setflags ioctl. Pass the flags attribute through to the ioctl call in receive. Signed-off-by: Boris Burkov --- cmds/receive-dump.c | 6 ++ cmds/receive.c | 24 com

[PATCH v4 06/11] btrfs-progs: receive: process encoded_write commands

2021-03-16 Thread Omar Sandoval
From: Boris Burkov Add a new btrfs_send_op and support for both dumping and proper receive processing which does actual encoded writes. Encoded writes are only allowed on a file descriptor opened with an extra flag that allows encoded writes, so we also add support for this flag when opening or

[PATCH v4 07/11] btrfs-progs: receive: encoded_write fallback to explicit decode and write

2021-03-16 Thread Omar Sandoval
From: Boris Burkov An encoded_write can fail if the file system it is being applied to does not support encoded writes or if it can't find enough contiguous space to accommodate the encoded extent. In those cases, we can likely still process an encoded_write by explicitly decoding the data and do

[PATCH v4 5/5] btrfs: send: enable support for stream v2 and compressed writes

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval Now that the new support is implemented, allow the ioctl to accept the flags and update the version in sysfs. Signed-off-by: Omar Sandoval --- fs/btrfs/send.c| 10 +- fs/btrfs/send.h| 2 +- include/uapi/linux/btrfs.h | 4 +++- 3 files

[PATCH v4 05/11] btrfs-progs: receive: add stub implementation for pwritev2

2021-03-16 Thread Omar Sandoval
From: Boris Burkov Encoded writes in receive will use pwritev2. It is possible that the system libc does not export this function, so we stub it out and detect whether to build the stub code with autoconf. This syscall has special semantics in x32 (no hi lo, just takes loff_t) so we have to dete

[PATCH v4 04/11] btrfs-progs: receive: add send stream v2 cmds and attrs to send.h

2021-03-16 Thread Omar Sandoval
From: Boris Burkov Send stream v2 adds three commands and several attributes associated to those commands. Before we implement processing them, add all the commands and attributes. This avoids leaving the enums in an intermediate state that doesn't correspond to any version of send stream. Signe

[PATCH v4 2/5] btrfs: send: write larger chunks when using stream v2

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval The length field of the send stream TLV header is 16 bits. This means that the maximum amount of data that can be sent for one write is 64k minus one. However, encoded writes must be able to send the maximum compressed extent (128k) in one command. To support this, send

[PATCH v4 03/11] btrfs-progs: receive: support v2 send stream DATA tlv format

2021-03-16 Thread Omar Sandoval
From: Boris Burkov The new format privileges the BTRFS_SEND_A_DATA attribute by guaranteeing it will always be the last attribute in any command that needs it, and by implicitly encoding the data length as the difference between the total command length in the command header and the sizes of the

[PATCH v4 4/5] btrfs: send: send compressed extents with encoded writes

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval Now that all of the pieces are in place, we can use the ENCODED_WRITE command to send compressed extents when appropriate. Signed-off-by: Omar Sandoval --- fs/btrfs/ctree.h | 4 + fs/btrfs/inode.c | 6 +- fs/btrfs/send.c | 230

[PATCH v4 3/5] btrfs: send: allocate send buffer with alloc_page() and vmap() for v2

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval For encoded writes, we need the raw pages for reading compressed data directly via a bio. So, replace kvmalloc() with vmap() so we have access to the raw pages. 144k is large enough that it usually gets allocated with vmalloc(), anyways. Signed-off-by: Omar Sandoval --- fs

[PATCH v4 02/11] btrfs-progs: receive: dynamically allocate sctx->read_buf

2021-03-16 Thread Omar Sandoval
From: Boris Burkov In send stream v2, write commands can now be an arbitrary size. For that reason, we can no longer allocate a fixed array in sctx for read_cmd. Instead, read_cmd dynamically allocates sctx->read_buf. To avoid needless reallocations, we reuse read_buf between read_cmd calls by al

[PATCH v8 10/10] btrfs: implement RWF_ENCODED writes

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval The implementation resembles direct I/O: we have to flush any ordered extents, invalidate the page cache, and do the io tree/delalloc/extent map/ordered extent dance. From there, we can reuse the compression code with a minor modification to distinguish the write from

[PATCH v4 1/5] btrfs: add send stream v2 definitions

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval This adds the definitions of the new commands for send stream version 2 and their respective attributes: fallocate, FS_IOC_SETFLAGS (a.k.a. chattr), and encoded writes. It also documents two changes to the send stream format in v2: the receiver shouldn't assume a ma

[PATCH v4 01/11] btrfs-progs: receive: support v2 send stream larger tlv_len

2021-03-16 Thread Omar Sandoval
From: Boris Burkov An encoded extent can be up to 128K in length, which exceeds the largest value expressible by the current send stream format's 16 bit tlv_len field. Since encoded writes cannot be split into multiple writes by btrfs send, the send stream format must change to accommodate encode

[PATCH v8 09/10] btrfs: implement RWF_ENCODED reads

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval There are 4 main cases: 1. Inline extents: we copy the data straight out of the extent buffer. 2. Hole/preallocated extents: we fill in zeroes. 3. Regular, uncompressed extents: we read the sectors we need directly from disk. 4. Regular, compressed extents: we read the

[PATCH v4 0/5] btrfs: implement send/receive of compressed extents without decompressing

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval This series uses the interface added in "fs: interface for directly reading/writing compressed data" to send and receive compressed data without wastefully decompressing and recompressing it. It does so by 1. Bumping the send stream protocol version to 2. 2. Ad

[PATCH v8 08/10] btrfs: optionally extend i_size in cow_file_range_inline()

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval Currently, an inline extent is always created after i_size is extended from btrfs_dirty_pages(). However, for encoded writes, we only want to update i_size after we successfully created the inline extent. Add an update_i_size parameter to cow_file_range_inline() and

[PATCH v8 07/10] btrfs: support different disk extent size for delalloc

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval Currently, we always reserve the same extent size in the file and extent size on disk for delalloc because the former is the worst case for the latter. For RWF_ENCODED writes, we know the exact size of the extent on disk, which may be less than or greater than (for bookends

[PATCH v8 06/10] btrfs: add ram_bytes and offset to btrfs_ordered_extent

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval 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 these fields through the ordered extent infrastructure and pass

[PATCH v8 05/10] btrfs: don't advance offset for compressed bios in btrfs_csum_one_bio()

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval btrfs_csum_one_bio() loops over each filesystem block in the bio while keeping a cursor of its current logical position in the file in order to look up the ordered extent to add the checksums to. However, this doesn't make much sense for compressed extents, as a sect

[PATCH v8 04/10] btrfs: fix check_data_csum() error message for direct I/O

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval Commit 1dae796aabf6 ("btrfs: inode: sink parameter start and len to check_data_csum()") replaced the start parameter to check_data_csum() with page_offset(), but page_offset() is not meaningful for direct I/O pages. Bring back the start parameter. Fixes: 265d4ac03f

[PATCH v8 02/10] fs: add O_ALLOW_ENCODED open flag

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval The upcoming RWF_ENCODED operation introduces some security concerns: 1. Compressed writes will pass arbitrary data to decompression algorithms in the kernel. 2. Compressed reads can leak truncated/hole punched data. Therefore, we need to require privilege for

[PATCH v8 03/10] fs: add RWF_ENCODED for reading/writing compressed data

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval Btrfs supports transparent compression: data written by the user can be compressed when written to disk and decompressed when read back. However, we'd like to add an interface to write pre-compressed data directly to the filesystem, and the matching interface to

[PATCH man-pages v8] Document encoded I/O

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval This adds a new page, encoded_io(7), providing an overview of encoded I/O and updates fcntl(2), open(2), and preadv2(2)/pwritev2(2) to reference it. Signed-off-by: Omar Sandoval --- man2/fcntl.2 | 8 + man2/open.2 | 13 ++ man2/readv.2 | 69

[PATCH v8 01/10] iov_iter: add copy_struct_from_iter()

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval This is essentially copy_struct_from_user() but for an iov_iter. Suggested-by: Aleksa Sarai Reviewed-by: Josef Bacik Signed-off-by: Omar Sandoval --- include/linux/uio.h | 2 ++ lib/iov_iter.c | 82 + 2 files changed, 84

[PATCH v8 00/10] fs: interface for directly reading/writing compressed data

2021-03-16 Thread Omar Sandoval
From: Omar Sandoval This series adds an API for reading compressed data on a filesystem without decompressing it as well as support for writing compressed data directly to the filesystem. As with the previous submissions, I've included a man page patch describing the API. I have test

Re: [PATCH v7 00/10] fs: interface for directly reading/writing compressed data

2021-02-03 Thread Omar Sandoval
On Fri, Jan 29, 2021 at 11:32:06AM -0500, Josef Bacik wrote: > On 1/22/21 3:46 PM, Omar Sandoval wrote: > > From: Omar Sandoval > > > > This series adds an API for reading compressed data on a filesystem > > without decompressing it as well as support for writing comp

[PATCH man-pages v7] Document encoded I/O

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval This adds a new page, encoded_io(7), providing an overview of encoded I/O and updates fcntl(2), open(2), and preadv2(2)/pwritev2(2) to reference it. Cc: Michael Kerrisk Cc: linux-man Signed-off-by: Omar Sandoval --- man2/fcntl.2 | 8 + man2/open.2 | 13

[PATCH v7 01/10] iov_iter: add copy_struct_from_iter()

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval This is essentially copy_struct_from_user() but for an iov_iter. Suggested-by: Aleksa Sarai Reviewed-by: Josef Bacik Signed-off-by: Omar Sandoval --- include/linux/uio.h | 2 ++ lib/iov_iter.c | 82 + 2 files changed, 84

[PATCH v7 02/10] fs: add O_ALLOW_ENCODED open flag

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval The upcoming RWF_ENCODED operation introduces some security concerns: 1. Compressed writes will pass arbitrary data to decompression algorithms in the kernel. 2. Compressed reads can leak truncated/hole punched data. Therefore, we need to require privilege for

[PATCH v7 05/10] btrfs: don't advance offset for compressed bios in btrfs_csum_one_bio()

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval btrfs_csum_one_bio() loops over each filesystem block in the bio while keeping a cursor of its current logical position in the file in order to look up the ordered extent to add the checksums to. However, this doesn't make much sense for compressed extents, as a sect

[PATCH v7 03/10] fs: add RWF_ENCODED for reading/writing compressed data

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval Btrfs supports transparent compression: data written by the user can be compressed when written to disk and decompressed when read back. However, we'd like to add an interface to write pre-compressed data directly to the filesystem, and the matching interface to

[PATCH v7 07/10] btrfs: support different disk extent size for delalloc

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval Currently, we always reserve the same extent size in the file and extent size on disk for delalloc because the former is the worst case for the latter. For RWF_ENCODED writes, we know the exact size of the extent on disk, which may be less than or greater than (for bookends

[PATCH v7 06/10] btrfs: add ram_bytes and offset to btrfs_ordered_extent

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval 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 these fields through the ordered extent infrastructure and pass

[PATCH v7 10/10] btrfs: implement RWF_ENCODED writes

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval The implementation resembles direct I/O: we have to flush any ordered extents, invalidate the page cache, and do the io tree/delalloc/extent map/ordered extent dance. From there, we can reuse the compression code with a minor modification to distinguish the write from

[PATCH v7 13/15] btrfs: send: allocate send buffer with alloc_page() and vmap() for v2

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval For encoded writes, we need the raw pages for reading compressed data directly via a bio. So, replace kvmalloc() with vmap() so we have access to the raw pages. 144k is large enough that it usually gets allocated with vmalloc(), anyways. Signed-off-by: Omar Sandoval --- fs

[PATCH v3 05/11] btrfs-progs: receive: add stub implementation for pwritev2

2021-01-22 Thread Omar Sandoval
From: Boris Burkov Encoded writes in receive will use pwritev2. It is possible that the system libc does not export this function, so we stub it out and detect whether to build the stub code with autoconf. This syscall has special semantics in x32 (no hi lo, just takes loff_t) so we have to dete

[PATCH v3 4/5] btrfs: send: send compressed extents with encoded writes

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval Now that all of the pieces are in place, we can use the ENCODED_WRITE command to send compressed extents when appropriate. Signed-off-by: Omar Sandoval --- fs/btrfs/ctree.h | 4 + fs/btrfs/inode.c | 6 +- fs/btrfs/send.c | 230

[PATCH v3 5/5] btrfs: send: enable support for stream v2 and compressed writes

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval Now that the new support is implemented, allow the ioctl to accept the flags and update the version in sysfs. Signed-off-by: Omar Sandoval --- fs/btrfs/send.c| 10 +- fs/btrfs/send.h| 2 +- include/uapi/linux/btrfs.h | 4 +++- 3 files

[PATCH v3 06/11] btrfs-progs: receive: process encoded_write commands

2021-01-22 Thread Omar Sandoval
From: Boris Burkov Add a new btrfs_send_op and support for both dumping and proper receive processing which does actual encoded writes. Encoded writes are only allowed on a file descriptor opened with an extra flag that allows encoded writes, so we also add support for this flag when opening or

[PATCH v3 08/11] btrfs-progs: receive: process fallocate commands

2021-01-22 Thread Omar Sandoval
From: Boris Burkov Send stream v2 can emit fallocate commands, so receive must support them as well. The implementation simply passes along the arguments to the syscall. Note that mode is encoded as a u32 in send stream but fallocate takes an int, so there is a unsigned->signed conversion there.

[PATCH v3 07/11] btrfs-progs: receive: encoded_write fallback to explicit decode and write

2021-01-22 Thread Omar Sandoval
From: Boris Burkov An encoded_write can fail if the file system it is being applied to does not support encoded writes or if it can't find enough contiguous space to accommodate the encoded extent. In those cases, we can likely still process an encoded_write by explicitly decoding the data and do

[PATCH v3 09/11] btrfs-progs: receive: process setflags ioctl commands

2021-01-22 Thread Omar Sandoval
From: Boris Burkov In send stream v2, send can emit a command for setting inode flags via the setflags ioctl. Pass the flags attribute through to the ioctl call in receive. Signed-off-by: Boris Burkov --- cmds/receive-dump.c | 6 ++ cmds/receive.c | 24 com

[PATCH v3 10/11] btrfs-progs: send: stream v2 ioctl flags

2021-01-22 Thread Omar Sandoval
From: Boris Burkov To make the btrfs send ioctl use the stream v2 format requires passing BTRFS_SEND_FLAG_STREAM_V2 in flags. Further, to cause the ioctl to emit encoded_write commands for encoded extents, we must set that flag as well as BTRFS_SEND_FLAG_COMPRESSED. Finally, we bump up the versio

Re: [PATCH v7 11/15] btrfs: add send stream v2 definitions

2021-01-22 Thread Omar Sandoval
Please ignore 11-15. I fat fingered format-patch, these are part of the other series.

[PATCH v3 11/11] btrfs-progs: receive: add tests for basic encoded_write send/receive

2021-01-22 Thread Omar Sandoval
From: Boris Burkov Adapt the existing send/receive tests by passing '-o --force-compress' to the mount commands in a new test. After writing a few files in the various compression formats, send/receive them with and without --force-decompress to test both the encoded_write path and the fallback t

[PATCH v7 15/15] btrfs: send: enable support for stream v2 and compressed writes

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval Now that the new support is implemented, allow the ioctl to accept the flags and update the version in sysfs. Signed-off-by: Omar Sandoval --- fs/btrfs/send.c| 10 +- fs/btrfs/send.h| 2 +- include/uapi/linux/btrfs.h | 4 +++- 3 files

[PATCH v3 3/5] btrfs: send: allocate send buffer with alloc_page() and vmap() for v2

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval For encoded writes, we need the raw pages for reading compressed data directly via a bio. So, replace kvmalloc() with vmap() so we have access to the raw pages. 144k is large enough that it usually gets allocated with vmalloc(), anyways. Signed-off-by: Omar Sandoval --- fs

[PATCH v3 04/11] btrfs-progs: receive: add send stream v2 cmds and attrs to send.h

2021-01-22 Thread Omar Sandoval
From: Boris Burkov Send stream v2 adds three commands and several attributes associated to those commands. Before we implement processing them, add all the commands and attributes. This avoids leaving the enums in an intermediate state that doesn't correspond to any version of send stream. Signe

[PATCH v3 03/11] btrfs-progs: receive: support v2 send stream DATA tlv format

2021-01-22 Thread Omar Sandoval
From: Boris Burkov The new format privileges the BTRFS_SEND_A_DATA attribute by guaranteeing it will always be the last attribute in any command that needs it, and by implicitly encoding the data length as the difference between the total command length in the command header and the sizes of the

[PATCH v3 2/5] btrfs: send: write larger chunks when using stream v2

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval The length field of the send stream TLV header is 16 bits. This means that the maximum amount of data that can be sent for one write is 64k minus one. However, encoded writes must be able to send the maximum compressed extent (128k) in one command. To support this, send

[PATCH v3 02/11] btrfs-progs: receive: dynamically allocate sctx->read_buf

2021-01-22 Thread Omar Sandoval
From: Boris Burkov In send stream v2, write commands can now be an arbitrary size. For that reason, we can no longer allocate a fixed array in sctx for read_cmd. Instead, read_cmd dynamically allocates sctx->read_buf. To avoid needless reallocations, we reuse read_buf between read_cmd calls by al

[PATCH v7 14/15] btrfs: send: send compressed extents with encoded writes

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval Now that all of the pieces are in place, we can use the ENCODED_WRITE command to send compressed extents when appropriate. Signed-off-by: Omar Sandoval --- fs/btrfs/ctree.h | 4 + fs/btrfs/inode.c | 6 +- fs/btrfs/send.c | 230

[PATCH v3 01/11] btrfs-progs: receive: support v2 send stream larger tlv_len

2021-01-22 Thread Omar Sandoval
From: Boris Burkov An encoded extent can be up to 128K in length, which exceeds the largest value expressible by the current send stream format's 16 bit tlv_len field. Since encoded writes cannot be split into multiple writes by btrfs send, the send stream format must change to accommodate encode

[PATCH v3 0/5] btrfs: implement send/receive of compressed extents without decompressing

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval This series uses the interface added in "fs: interface for directly reading/writing compressed data" to send and receive compressed data without wastefully decompressing and recompressing it. It does so by 1. Bumping the send stream protocol version to 2. 2. Ad

[PATCH v3 1/5] btrfs: add send stream v2 definitions

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval This adds the definitions of the new commands for send stream version 2 and their respective attributes: fallocate, FS_IOC_SETFLAGS (a.k.a. chattr), and encoded writes. It also documents two changes to the send stream format in v2: the receiver shouldn't assume a ma

[PATCH v7 11/15] btrfs: add send stream v2 definitions

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval This adds the definitions of the new commands for send stream version 2 and their respective attributes: fallocate, FS_IOC_SETFLAGS (a.k.a. chattr), and encoded writes. It also documents two changes to the send stream format in v2: the receiver shouldn't assume a ma

[PATCH v7 12/15] btrfs: send: write larger chunks when using stream v2

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval The length field of the send stream TLV header is 16 bits. This means that the maximum amount of data that can be sent for one write is 64k minus one. However, encoded writes must be able to send the maximum compressed extent (128k) in one command. To support this, send

[PATCH v7 09/10] btrfs: implement RWF_ENCODED reads

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval There are 4 main cases: 1. Inline extents: we copy the data straight out of the extent buffer. 2. Hole/preallocated extents: we fill in zeroes. 3. Regular, uncompressed extents: we read the sectors we need directly from disk. 4. Regular, compressed extents: we read the

[PATCH v7 08/10] btrfs: optionally extend i_size in cow_file_range_inline()

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval Currently, an inline extent is always created after i_size is extended from btrfs_dirty_pages(). However, for encoded writes, we only want to update i_size after we successfully created the inline extent. Add an update_i_size parameter to cow_file_range_inline() and

[PATCH v7 04/10] btrfs: fix check_data_csum() error message for direct I/O

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval Commit 1dae796aabf6 ("btrfs: inode: sink parameter start and len to check_data_csum()") replaced the start parameter to check_data_csum() with page_offset(), but page_offset() is not meaningful for direct I/O pages. Bring back the start parameter. Fixes: 265d4ac03f

[PATCH v7 00/10] fs: interface for directly reading/writing compressed data

2021-01-22 Thread Omar Sandoval
From: Omar Sandoval This series adds an API for reading compressed data on a filesystem without decompressing it as well as support for writing compressed data directly to the filesystem. As with the previous submissions, I've included a man page patch describing the API. I have test

Re: Ping: [PATCH man-pages v6] Document encoded I/O

2021-01-11 Thread Omar Sandoval
On Fri, Dec 18, 2020 at 11:32:17AM +0100, Alejandro Colomar (man-pages) wrote: > Hi Omar, > > Linux 5.10 has been recently released. > Do you have any updates for this patch? > > Thanks, > > Alex Hi, Alex, Now that the holidays are over I'm revisiting this series and plan to send a new version

Re: [PATCH v6 03/11] fs: add RWF_ENCODED for reading/writing compressed data

2021-01-11 Thread Omar Sandoval
On Thu, Nov 19, 2020 at 09:38:17AM +0200, Amir Goldstein wrote: > On Wed, Nov 18, 2020 at 9:18 PM Omar Sandoval wrote: > > > > From: Omar Sandoval > > > > Btrfs supports transparent compression: data written by the user can be > > compressed when written to dis

Re: [PATCH v6 10/11] btrfs: implement RWF_ENCODED reads

2021-01-11 Thread Omar Sandoval
On Mon, Jan 11, 2021 at 03:35:24PM -0500, Josef Bacik wrote: > On 1/11/21 3:21 PM, Omar Sandoval wrote: > > On Thu, Dec 03, 2020 at 09:32:37AM -0500, Josef Bacik wrote: > > > On 11/18/20 2:18 PM, Omar Sandoval wrote: > > > > From: Omar Sandoval > >

Re: [PATCH v6 10/11] btrfs: implement RWF_ENCODED reads

2021-01-11 Thread Omar Sandoval
On Thu, Dec 03, 2020 at 09:32:37AM -0500, Josef Bacik wrote: > On 11/18/20 2:18 PM, Omar Sandoval wrote: > > From: Omar Sandoval > > > > There are 4 main cases: > > > > 1. Inline extents: we copy the data straight out of the extent buffer. > > 2. Hole/

Re: [RFC PATCH v2 2/5] fs: add RWF_ENCODED for reading/writing compressed data

2019-10-21 Thread Omar Sandoval
On Mon, Oct 21, 2019 at 11:28:06AM -0700, Darrick J. Wong wrote: > On Tue, Oct 15, 2019 at 11:42:40AM -0700, Omar Sandoval wrote: > > From: Omar Sandoval > > > > Btrfs supports transparent compression: data written by the user can be > > compressed when written to disk

Re: [RFC PATCH v2 0/5] fs: interface for directly reading/writing compressed data

2019-10-21 Thread Omar Sandoval
On Mon, Oct 21, 2019 at 10:05:01AM +1100, Dave Chinner wrote: > On Tue, Oct 15, 2019 at 11:42:38AM -0700, Omar Sandoval wrote: > > From: Omar Sandoval > > > > Hello, > > > > This series adds an API for reading compressed data on a filesystem > > without

Re: [PATCH man-pages] Document encoded I/O

2019-10-21 Thread Omar Sandoval
posed API? I wasn't aware of these patches, thanks for pointing them out. Ted, do you have any thoughts about making this API work for fscrypt? > On Wed, Oct 16, 2019 at 12:29 AM Omar Sandoval wrote: > > > > From: Omar Sandoval > > > > This adds a new page,

Re: [RFC PATCH v2 5/5] btrfs: implement RWF_ENCODED writes

2019-10-21 Thread Omar Sandoval
On Mon, Oct 21, 2019 at 03:14:52PM +0200, David Sterba wrote: > On Fri, Oct 18, 2019 at 03:55:13PM -0700, Omar Sandoval wrote: > > > > + nr_pages = (disk_num_bytes + PAGE_SIZE - 1) >> PAGE_SHIFT; > > > > > > nit: nr_pages = DIV_ROUND_UP(disk_num_bytes

Re: [RFC PATCH v2 5/5] btrfs: implement RWF_ENCODED writes

2019-10-18 Thread Omar Sandoval
On Fri, Oct 18, 2019 at 03:55:13PM -0700, Omar Sandoval wrote: > On Wed, Oct 16, 2019 at 01:44:56PM +0300, Nikolay Borisov wrote: > > > > > > On 15.10.19 г. 21:42 ч., Omar Sandoval wrote: > > > From: Omar Sandoval > > > > > > The implement

Re: [RFC PATCH v2 5/5] btrfs: implement RWF_ENCODED writes

2019-10-18 Thread Omar Sandoval
On Wed, Oct 16, 2019 at 01:44:56PM +0300, Nikolay Borisov wrote: > > > On 15.10.19 г. 21:42 ч., Omar Sandoval wrote: > > From: Omar Sandoval > > > > The implementation resembles direct I/O: we have to flush any ordered > > extents, invalidate the page cache, a

Re: [RFC PATCH v2 4/5] btrfs: implement RWF_ENCODED reads

2019-10-18 Thread Omar Sandoval
On Wed, Oct 16, 2019 at 02:10:10PM +0300, Nikolay Borisov wrote: > > > On 15.10.19 г. 21:42 ч., Omar Sandoval wrote: > > From: Omar Sandoval > > > > There are 4 main cases: > > > > 1. Inline extents: we copy the data straight out of the extent buffe

Re: [RFC PATCH v2 2/5] fs: add RWF_ENCODED for reading/writing compressed data

2019-10-18 Thread Omar Sandoval
On Wed, Oct 16, 2019 at 12:50:48PM +0300, Nikolay Borisov wrote: > > > On 15.10.19 г. 21:42 ч., Omar Sandoval wrote: > > From: Omar Sandoval > > > > Btrfs supports transparent compression: data written by the user can be > > compressed when written to dis

Re: [RFC PATCH v2 3/5] btrfs: generalize btrfs_lookup_bio_sums_dio()

2019-10-18 Thread Omar Sandoval
On Wed, Oct 16, 2019 at 12:22:33PM +0300, Nikolay Borisov wrote: > > > On 15.10.19 г. 21:42 ч., Omar Sandoval wrote: > > From: Omar Sandoval > > > > This isn't actually dio-specific; it just looks up the csums starting at > > the given offset instead

[RFC PATCH v2 1/5] fs: add O_ENCODED open flag

2019-10-15 Thread Omar Sandoval
From: Omar Sandoval The upcoming RWF_ENCODED operation introduces some security concerns: 1. Compressed writes will pass arbitrary data to decompression algorithms in the kernel. 2. Compressed reads can leak truncated/hole punched data. Therefore, we need to require privilege for

[RFC PATCH v2 0/5] fs: interface for directly reading/writing compressed data

2019-10-15 Thread Omar Sandoval
From: Omar Sandoval Hello, This series adds an API for reading compressed data on a filesystem without decompressing it as well as support for writing compressed data directly to the filesystem. It is based on my previous series which added a Btrfs-specific ioctl [1], but it is now an extension

[RFC PATCH v2 5/5] btrfs: implement RWF_ENCODED writes

2019-10-15 Thread Omar Sandoval
From: Omar Sandoval The implementation resembles direct I/O: we have to flush any ordered extents, invalidate the page cache, and do the io tree/delalloc/extent map/ordered extent dance. From there, we can reuse the compression code with a minor modification to distinguish the write from

  1   2   3   4   5   6   7   8   9   10   >