From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Yu Kuai <yukuai3@huawei.com>
Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
yi.zhang@huawei.com, zhangxiaoxu5@huawei.com
Subject: Re: [PATCH] xfs: return corresponding errcode if xfs_initialize_perag() fail
Date: Wed, 18 Nov 2020 09:17:23 -0800 [thread overview]
Message-ID: <20201118171723.GC9695@magnolia> (raw)
In-Reply-To: <20201118111531.455814-1-yukuai3@huawei.com>
On Wed, Nov 18, 2020 at 07:15:31PM +0800, Yu Kuai wrote:
> In xfs_initialize_perag(), if kmem_zalloc(), xfs_buf_hash_init(), or
> radix_tree_preload() failed, the returned value 'error' is not set
> accordingly.
>
> Fixes: commit 8b26c5825e02 ("xfs: handle ENOMEM correctly during initialisation of perag structures")
/me suspects you really want
Fixes: 9b2471797942 ("xfs: cache unlinked pointers in an rhashtable")
but otherwise this is legit.
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
> fs/xfs/xfs_mount.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 150ee5cb8645..7110507a2b6b 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -194,20 +194,25 @@ xfs_initialize_perag(
> }
>
> pag = kmem_zalloc(sizeof(*pag), KM_MAYFAIL);
> - if (!pag)
> + if (!pag) {
> + error = -ENOMEM;
> goto out_unwind_new_pags;
> + }
> pag->pag_agno = index;
> pag->pag_mount = mp;
> spin_lock_init(&pag->pag_ici_lock);
> INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC);
> - if (xfs_buf_hash_init(pag))
> +
> + error = xfs_buf_hash_init(pag);
> + if (error)
> goto out_free_pag;
> init_waitqueue_head(&pag->pagb_wait);
> spin_lock_init(&pag->pagb_lock);
> pag->pagb_count = 0;
> pag->pagb_tree = RB_ROOT;
>
> - if (radix_tree_preload(GFP_NOFS))
> + error = radix_tree_preload(GFP_NOFS);
> + if (error)
> goto out_hash_destroy;
>
> spin_lock(&mp->m_perag_lock);
> --
> 2.25.4
>
prev parent reply other threads:[~2020-11-18 17:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 11:15 [PATCH] xfs: return corresponding errcode if xfs_initialize_perag() fail Yu Kuai
2020-11-18 17:17 ` Darrick J. Wong [this message]
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=20201118171723.GC9695@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
--cc=zhangxiaoxu5@huawei.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