From: Nikolay Borisov <nborisov@suse.com>
To: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 3/4] btrfs: remove redundant csum buffer in btrfs_io_bio
Date: Thu, 22 Nov 2018 18:20:59 +0200 [thread overview]
Message-ID: <12d025e9-fb24-a96f-b3a2-f55df4830e22@suse.com> (raw)
In-Reply-To: <8eeb7eb407bf3d0d8defffd5564b45da1eb3da07.1542902890.git.dsterba@suse.com>
On 22.11.18 г. 18:16 ч., David Sterba wrote:
> The io_bio tracks checksums and has an inline buffer or an allocated
> one. And there's a third member that points to the right one, but we
> don't need to use an extra pointer for that. Let btrfs_io_bio::csum
> point to the right buffer and check that the inline buffer is not
> accidentally freed.
>
> This shrinks struct btrfs_io_bio by 8 bytes.
>
> Signed-off-by: David Sterba <dsterba@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/file-item.c | 12 +++++++-----
> fs/btrfs/volumes.h | 1 -
> 2 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
> index ba74827beb32..1f2d0a6ab634 100644
> --- a/fs/btrfs/file-item.c
> +++ b/fs/btrfs/file-item.c
> @@ -144,7 +144,10 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
>
> static void btrfs_io_bio_endio_readpage(struct btrfs_io_bio *bio, int err)
> {
> - kfree(bio->csum_allocated);
> + if (bio->csum != bio->csum_inline) {
> + kfree(bio->csum);
> + bio->csum = NULL;
> + }
> }
>
> static blk_status_t __btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
> @@ -175,13 +178,12 @@ static blk_status_t __btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio
> nblocks = bio->bi_iter.bi_size >> inode->i_sb->s_blocksize_bits;
> if (!dst) {
> if (nblocks * csum_size > BTRFS_BIO_INLINE_CSUM_SIZE) {
> - btrfs_bio->csum_allocated = kmalloc_array(nblocks,
> - csum_size, GFP_NOFS);
> - if (!btrfs_bio->csum_allocated) {
> + btrfs_bio->csum = kmalloc_array(nblocks, csum_size,
> + GFP_NOFS);
> + if (!btrfs_bio->csum) {
> btrfs_free_path(path);
> return BLK_STS_RESOURCE;
> }
> - btrfs_bio->csum = btrfs_bio->csum_allocated;
> btrfs_bio->end_io = btrfs_io_bio_endio_readpage;
> } else {
> btrfs_bio->csum = btrfs_bio->csum_inline;
> diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
> index 1d936ce282c3..9a764f2d462e 100644
> --- a/fs/btrfs/volumes.h
> +++ b/fs/btrfs/volumes.h
> @@ -274,7 +274,6 @@ struct btrfs_io_bio {
> u64 logical;
> u8 *csum;
> u8 csum_inline[BTRFS_BIO_INLINE_CSUM_SIZE];
> - u8 *csum_allocated;
> btrfs_io_bio_end_io_t *end_io;
> struct bvec_iter iter;
> /*
>
next prev parent reply other threads:[~2018-11-22 16:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-22 16:16 [PATCH 0/4] Minor helper and struct member cleanups David Sterba
2018-11-22 16:16 ` [PATCH 1/4] btrfs: merge btrfs_submit_bio_done to its caller David Sterba
2018-11-22 16:18 ` Nikolay Borisov
2018-11-23 8:27 ` Johannes Thumshirn
2018-11-22 16:16 ` [PATCH 2/4] btrfs: replace async_cow::root with fs_info David Sterba
2018-11-22 16:19 ` Nikolay Borisov
2018-11-23 8:25 ` Johannes Thumshirn
2018-11-22 16:16 ` [PATCH 3/4] btrfs: remove redundant csum buffer in btrfs_io_bio David Sterba
2018-11-22 16:20 ` Nikolay Borisov [this message]
2018-11-23 8:23 ` Johannes Thumshirn
2018-11-22 16:16 ` [PATCH 4/4] btrfs: replace btrfs_io_bio::end_io with a simple helper David Sterba
2018-11-22 16:22 ` Nikolay Borisov
2018-11-23 8:19 ` Johannes Thumshirn
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=12d025e9-fb24-a96f-b3a2-f55df4830e22@suse.com \
--to=nborisov@suse.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/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).