From: Liu Bo <bo.li.liu@oracle.com>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/2] btrfs: Remove invalid null checks from btrfs_cleanup_dirty_bgs
Date: Thu, 8 Feb 2018 10:57:11 -0800 [thread overview]
Message-ID: <20180208185710.GB9008@lim.localdomain> (raw)
In-Reply-To: <1518107118-15137-1-git-send-email-nborisov@suse.com>
On Thu, Feb 08, 2018 at 06:25:17PM +0200, Nikolay Borisov wrote:
> list_first_entry is essentially a wrapper over cotnainer_of. The latter
> can never return null even if it's working on inconsistent list since it
> will either crash or return some offset in the wrong struct.
> Additionally, for the dirty_bgs list the iteration is done under
> dirty_bgs_lock which ensures consistency of the list.
>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
-liubo
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/disk-io.c | 9 ---------
> 1 file changed, 9 deletions(-)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index aca906971abe..1b3989c54d7c 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -4323,11 +4323,6 @@ void btrfs_cleanup_dirty_bgs(struct btrfs_transaction *cur_trans,
> cache = list_first_entry(&cur_trans->dirty_bgs,
> struct btrfs_block_group_cache,
> dirty_list);
> - if (!cache) {
> - btrfs_err(fs_info, "orphan block group dirty_bgs list");
> - spin_unlock(&cur_trans->dirty_bgs_lock);
> - return;
> - }
>
> if (!list_empty(&cache->io_list)) {
> spin_unlock(&cur_trans->dirty_bgs_lock);
> @@ -4351,10 +4346,6 @@ void btrfs_cleanup_dirty_bgs(struct btrfs_transaction *cur_trans,
> cache = list_first_entry(&cur_trans->io_bgs,
> struct btrfs_block_group_cache,
> io_list);
> - if (!cache) {
> - btrfs_err(fs_info, "orphan block group on io_bgs list");
> - return;
> - }
>
> list_del_init(&cache->io_list);
> spin_lock(&cache->lock);
> --
> 2.7.4
>
next prev parent reply other threads:[~2018-02-08 19:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-08 16:25 [PATCH 1/2] btrfs: Remove invalid null checks from btrfs_cleanup_dirty_bgs Nikolay Borisov
2018-02-08 16:25 ` [PATCH 2/2] btrfs: Document consistency of transaction->io_bgs list Nikolay Borisov
2018-02-08 18:57 ` Liu Bo [this message]
2018-02-13 18:05 ` [PATCH 1/2] btrfs: Remove invalid null checks from btrfs_cleanup_dirty_bgs David Sterba
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=20180208185710.GB9008@lim.localdomain \
--to=bo.li.liu@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.com \
/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).