Thread (30 messages) 30 messages, 3 authors, 2020-08-25

Re: [PATCH v5 9/9] btrfs: implement RWF_ENCODED writes

From: Josef Bacik <josef@toxicpanda.com>
Date: 2020-08-24 20:30:58
Also in: linux-btrfs, linux-fsdevel

On 8/21/20 3:38 AM, Omar Sandoval wrote:
From: Omar Sandoval <redacted>

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 writeback. This
also creates inline extents when possible.

Now that read and write are implemented, this also sets the
FMODE_ENCODED_IO flag in btrfs_file_open().

Signed-off-by: Omar Sandoval <redacted>
---
  fs/btrfs/compression.c  |   7 +-
  fs/btrfs/compression.h  |   6 +-
  fs/btrfs/ctree.h        |   2 +
  fs/btrfs/file.c         |  40 +++++--
  fs/btrfs/inode.c        | 246 +++++++++++++++++++++++++++++++++++++++-
  fs/btrfs/ordered-data.c |  12 +-
  fs/btrfs/ordered-data.h |   2 +
  7 files changed, 298 insertions(+), 17 deletions(-)
<snip>
+
+	ret = btrfs_alloc_data_chunk_ondemand(BTRFS_I(inode), disk_num_bytes);
+	if (ret)
+		goto out_unlock;
+	ret = btrfs_qgroup_reserve_data(BTRFS_I(inode), &data_reserved, start,
+					num_bytes);
+	if (ret)
+		goto out_free_data_space;
+	ret = btrfs_delalloc_reserve_metadata(BTRFS_I(inode), num_bytes,
+					      disk_num_bytes);
+	if (ret)
+		goto out_qgroup_free_data;
This can just be btrfs_delalloc_reserve_space() and that way the error handling 
is much cleaner.

<snip>
+
+out_free_reserved:
+	btrfs_dec_block_group_reservations(fs_info, ins.objectid);
+	btrfs_free_reserved_extent(fs_info, ins.objectid, ins.offset, 1);
+out_delalloc_release:
+	btrfs_delalloc_release_extents(BTRFS_I(inode), num_bytes);
+	btrfs_delalloc_release_metadata(BTRFS_I(inode), disk_num_bytes,
+					ret < 0);
Likewise this can all just be btrfs_free_reserved_data_space().  Thanks,

Josef
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help