All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 3/7] btrfs: remove redundant member async_cow::root
Date: Fri, 20 Jul 2018 16:59:19 +0200	[thread overview]
Message-ID: <20180720145919.GD26141@twin.jikos.cz> (raw)
In-Reply-To: <1c08372d35f29610eed55f77ddcfbe10c8a952f5.1531996240.git.dsterba@suse.com>

On Thu, Jul 19, 2018 at 01:05:14PM +0200, David Sterba wrote:
> The root is only used to get fs_info out of it, but the same can be
> retrieved from the inode that's in async_cow.
> 
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
>  fs/btrfs/inode.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 564ec00c765b..36b323b27dbf 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -358,7 +358,6 @@ struct async_extent {
>  
>  struct async_cow {
>  	struct inode *inode;
> -	struct btrfs_root *root;
>  	struct page *locked_page;
>  	u64 start;
>  	u64 end;
> @@ -1144,13 +1143,11 @@ static noinline void async_cow_submit(struct btrfs_work *work)
>  {
>  	struct btrfs_fs_info *fs_info;
>  	struct async_cow *async_cow;
> -	struct btrfs_root *root;
>  	unsigned long nr_pages;
>  
>  	async_cow = container_of(work, struct async_cow, work);
>  
> -	root = async_cow->root;
> -	fs_info = root->fs_info;
> +	fs_info = BTRFS_I(async_cow->inode)->root->fs_info;

This crashes if the inode is NULL, which can happen in async_cow_start
if compress_file_range returns 0 in num_added. The inode is moved to
delayed iputs and async_cow->inode zeroed.

Patch removed for now. We can reach the inode via the
async_cow::locked_page, but it's 5 pointers to chase and I want to have a
second thought on that if the 8 bytes in the structure is not cheaper.

--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1143,11 +1143,13 @@ static noinline void async_cow_submit(struct btrfs_work *work)
 {
        struct btrfs_fs_info *fs_info;
        struct async_cow *async_cow;
+       struct inode *inode;
        unsigned long nr_pages;
 
        async_cow = container_of(work, struct async_cow, work);
 
-       fs_info = BTRFS_I(async_cow->inode)->root->fs_info;
+       inode = async_cow->locked_page->mapping->host;
+       fs_info = BTRFS_I(inode)->root->fs_info;
        nr_pages = (async_cow->end - async_cow->start + PAGE_SIZE) >>
                PAGE_SHIFT;
 
---


  reply	other threads:[~2018-07-20 15:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-19 11:05 [PATCH 0/7] Structure and callback cleanups David Sterba
2018-07-19 11:05 ` [PATCH 1/7] btrfs: remove unused member async_submit_bio::fs_info David Sterba
2018-07-19 11:05 ` [PATCH 2/7] btrfs: remove unused member async_submit_bio::bio_flags David Sterba
2018-07-19 11:05 ` [PATCH 3/7] btrfs: remove redundant member async_cow::root David Sterba
2018-07-20 14:59   ` David Sterba [this message]
2018-07-19 11:05 ` [PATCH 4/7] btrfs: unify end_io callbacks of async_submit_bio David Sterba
2018-07-19 11:05 ` [PATCH 5/7] btrfs: drop extent_io_ops::tree_fs_info callback David Sterba
2018-07-19 11:05 ` [PATCH 6/7] btrfs: drop extent_io_ops::merge_bio_hook callback David Sterba
2018-07-19 12:02   ` Nikolay Borisov
2018-07-19 12:48     ` David Sterba
2018-07-19 11:05 ` [PATCH 7/7] btrfs: drop extent_io_ops::set_range_writeback callback David Sterba
2018-07-19 12:04 ` [PATCH 0/7] Structure and callback cleanups Nikolay Borisov

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=20180720145919.GD26141@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.