All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Cc: Jan Kara <jack@suse.cz>, Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org,
	Christoph Hellwig <hch@infradead.org>,
	Dan Williams <dan.j.williams@intel.com>,
	Laurent Dufour <ldufour@linux.vnet.ibm.com>,
	Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH 0/4 v2] BDI lifetime fix
Date: Tue, 7 Feb 2017 13:33:31 +0100	[thread overview]
Message-ID: <20170207123331.GD13524@quack2.suse.cz> (raw)
In-Reply-To: <1790906.I1Z25HtRf4@morokweng>

On Mon 06-02-17 13:26:53, Thiago Jung Bauermann wrote:
> Am Montag, 6. Februar 2017, 12:48:42 BRST schrieb Thiago Jung Bauermann:
> > 216 static inline void wb_get(struct bdi_writeback *wb)
> > 217 {
> > 218         if (wb != &wb->bdi->wb)
> > 219                 percpu_ref_get(&wb->refcnt);
> > 220 }
> > 
> > So it looks like wb->bdi is NULL.
> 
> Sorry, looking a little deeper, it's actually wb which is NULL:
> 
> ./include/linux/backing-dev.h:
> 371             return inode->i_wb;
>    0xc00000000037999c <+76>:    ld      r31,256(r29)
> 
> ./include/linux/backing-dev-defs.h:
> 218             if (wb != &wb->bdi->wb)
>    0xc0000000003799a0 <+80>:    ld      r9,0(r31)
>    0xc0000000003799a4 <+84>:    addi    r9,r9,88
>    0xc0000000003799a8 <+88>:    cmpld   cr7,r31,r9
>    0xc0000000003799ac <+92>:    beq     cr7,0xc0000000003799e0 
> <locked_inode_to_wb_and_lock_list+144>
> 
> We can see above that inode->i_wb is in r31, and the machine crashed at 
> 0xc0000000003799a0 so it was trying to dereference wb and crashed.
> r31 is NULL in the crash information.

Thanks for report and the analysis. After some looking into the code I see
where the problem is. Writeback code assumes inode->i_wb can never become
invalid once it is set however we still call inode_detach_wb() from
__blkdev_put(). So in a way this is a different problem but closely
related.

It seems to me that instead of calling inode_detach_wb() in __blkdev_put()
we may just switch blkdev inode to bdi->wb (it is now guaranteed to stay
around). That way bdi_unregister() can complete (destroying all writeback
structures except for bdi->wb) while block device inode can still live with
a valid i_wb structure.

CCed Tejun who is more familar with this code to verify my thoughts.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2017-02-07 12:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-31 12:54 [PATCH 0/4 v2] BDI lifetime fix Jan Kara
2017-01-31 12:54 ` [PATCH 1/4] block: Unhash block device inodes on gendisk destruction Jan Kara
2017-02-01  9:48   ` Christoph Hellwig
2017-01-31 12:54 ` [PATCH 2/4] block: Use pointer to backing_dev_info from request_queue Jan Kara
2017-02-01  9:48   ` Christoph Hellwig
2017-01-31 12:54 ` [PATCH 3/4] block: Dynamically allocate and refcount backing_dev_info Jan Kara
2017-02-01  9:50   ` Christoph Hellwig
2017-02-01 12:22     ` Jan Kara
2017-02-01 22:45       ` Jens Axboe
2017-02-02 13:32         ` Jan Kara
2017-01-31 12:54 ` [PATCH 4/4] block: Make blk_get_backing_dev_info() safe without open bdev Jan Kara
2017-02-01  9:53   ` Christoph Hellwig
2017-02-01 12:28     ` Jan Kara
2017-02-01 12:52       ` Christoph Hellwig
2017-02-01 19:25   ` Dan Williams
2017-02-06 14:48 ` [PATCH 0/4 v2] BDI lifetime fix Thiago Jung Bauermann
2017-02-06 15:26   ` Thiago Jung Bauermann
2017-02-07 12:33     ` Jan Kara [this message]
2017-02-07 17:21       ` Tejun Heo
2017-02-08  7:51         ` Jan Kara
2017-02-08 10:23           ` Jan Kara
2017-02-08 16:00             ` Dan Williams

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=20170207123331.GD13524@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=axboe@kernel.dk \
    --cc=bauerman@linux.vnet.ibm.com \
    --cc=dan.j.williams@intel.com \
    --cc=hch@infradead.org \
    --cc=ldufour@linux.vnet.ibm.com \
    --cc=linux-block@vger.kernel.org \
    --cc=tj@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.