From: Josef Bacik <josef@toxicpanda.com>
To: Omar Sandoval <osandov@osandov.com>,
linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org,
Al Viro <viro@zeniv.linux.org.uk>,
Christoph Hellwig <hch@infradead.org>
Cc: Dave Chinner <david@fromorbit.com>, Jann Horn <jannh@google.com>,
Amir Goldstein <amir73il@gmail.com>,
Aleksa Sarai <cyphar@cyphar.com>,
linux-api@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v5 9/9] btrfs: implement RWF_ENCODED writes
Date: Mon, 24 Aug 2020 16:30:52 -0400 [thread overview]
Message-ID: <83d564d8-234c-a2b5-e261-80ea3b96f6d1@toxicpanda.com> (raw)
In-Reply-To: <07a61c2f9a07497c165c05106dd0f9ced5bbc4fc.1597993855.git.osandov@osandov.com>
On 8/21/20 3:38 AM, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
>
> 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 <osandov@fb.com>
> ---
> 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
next prev parent reply other threads:[~2020-08-24 20:31 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-21 7:38 [PATCH v5 0/9] fs: interface for directly reading/writing compressed data Omar Sandoval
2020-08-21 7:38 ` [PATCH man-pages v5] Document encoded I/O Omar Sandoval
2020-08-21 9:24 ` Amir Goldstein
2020-08-24 18:15 ` Omar Sandoval
2020-08-21 7:38 ` [PATCH v5 1/9] iov_iter: add copy_struct_from_iter() Omar Sandoval
2020-08-24 18:52 ` Josef Bacik
2020-08-24 21:09 ` Omar Sandoval
2020-08-21 7:38 ` [PATCH v5 2/9] fs: add O_ALLOW_ENCODED open flag Omar Sandoval
2020-08-24 18:28 ` Josef Bacik
2020-08-24 21:11 ` Omar Sandoval
2020-08-21 7:38 ` [PATCH v5 3/9] fs: add RWF_ENCODED for reading/writing compressed data Omar Sandoval
2020-08-21 8:47 ` Amir Goldstein
2020-08-24 23:49 ` Omar Sandoval
2020-08-25 8:25 ` Amir Goldstein
2020-08-25 17:20 ` Omar Sandoval
2020-08-24 19:07 ` Josef Bacik
2020-08-21 7:38 ` [PATCH v5 4/9] btrfs: don't advance offset for compressed bios in btrfs_csum_one_bio() Omar Sandoval
2020-08-24 19:17 ` Josef Bacik
2020-08-21 7:38 ` [PATCH v5 5/9] btrfs: add ram_bytes and offset to btrfs_ordered_extent Omar Sandoval
2020-08-24 19:23 ` Josef Bacik
2020-08-21 7:38 ` [PATCH v5 6/9] btrfs: support different disk extent size for delalloc Omar Sandoval
2020-08-24 19:26 ` Josef Bacik
2020-08-21 7:38 ` [PATCH v5 7/9] btrfs: optionally extend i_size in cow_file_range_inline() Omar Sandoval
2020-08-24 19:33 ` Josef Bacik
2020-08-21 7:38 ` [PATCH v5 8/9] btrfs: implement RWF_ENCODED reads Omar Sandoval
2020-08-24 19:54 ` Josef Bacik
2020-08-24 21:23 ` Omar Sandoval
2020-08-21 7:38 ` [PATCH v5 9/9] btrfs: implement RWF_ENCODED writes Omar Sandoval
2020-08-24 20:30 ` Josef Bacik [this message]
2020-08-24 21:30 ` Omar Sandoval
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83d564d8-234c-a2b5-e261-80ea3b96f6d1@toxicpanda.com \
--to=josef@toxicpanda.com \
--cc=amir73il@gmail.com \
--cc=cyphar@cyphar.com \
--cc=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=jannh@google.com \
--cc=kernel-team@fb.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=osandov@osandov.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).