From: Jeff Layton <jlayton@kernel.org>
To: Ilya Dryomov <idryomov@gmail.com>, ceph-devel@vger.kernel.org
Cc: Magnus Harlander <magnus@harlan.de>
Subject: Re: [PATCH] libceph: allow addrvecs with a single NONE/blank address
Date: Tue, 04 May 2021 09:21:14 -0400 [thread overview]
Message-ID: <f389505b985f2bad7e56acd8113917cb6f06a4c6.camel@kernel.org> (raw)
In-Reply-To: <20210504105408.6035-1-idryomov@gmail.com>
On Tue, 2021-05-04 at 12:54 +0200, Ilya Dryomov wrote:
> Normally, an unused OSD id/slot is represented by an empty addrvec.
> However, it also appears to be possible to generate an osdmap where
> an unused OSD id/slot has an addrvec with a single blank address of
> type NONE. Allow such addrvecs and make the end result be exactly
> the same as for the empty addrvec case -- leave addr intact.
>
> Cc: stable@vger.kernel.org # 5.11+
> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
> ---
> net/ceph/decode.c | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/net/ceph/decode.c b/net/ceph/decode.c
> index b44f7651be04..bc109a1a4616 100644
> --- a/net/ceph/decode.c
> +++ b/net/ceph/decode.c
> @@ -4,6 +4,7 @@
> #include <linux/inet.h>
>
> #include <linux/ceph/decode.h>
> +#include <linux/ceph/messenger.h> /* for ceph_pr_addr() */
>
> static int
> ceph_decode_entity_addr_versioned(void **p, void *end,
> @@ -110,6 +111,7 @@ int ceph_decode_entity_addrvec(void **p, void *end, bool msgr2,
> }
>
> ceph_decode_32_safe(p, end, addr_cnt, e_inval);
> + dout("%s addr_cnt %d\n", __func__, addr_cnt);
>
> found = false;
> for (i = 0; i < addr_cnt; i++) {
> @@ -117,6 +119,7 @@ int ceph_decode_entity_addrvec(void **p, void *end, bool msgr2,
> if (ret)
> return ret;
>
> + dout("%s i %d addr %s\n", __func__, i, ceph_pr_addr(&tmp_addr));
> if (tmp_addr.type == my_type) {
> if (found) {
> pr_err("another match of type %d in addrvec\n",
> @@ -128,13 +131,18 @@ int ceph_decode_entity_addrvec(void **p, void *end, bool msgr2,
> found = true;
> }
> }
> - if (!found && addr_cnt != 0) {
> - pr_err("no match of type %d in addrvec\n",
> - le32_to_cpu(my_type));
> - return -ENOENT;
> - }
>
> - return 0;
> + if (found)
> + return 0;
> +
> + if (!addr_cnt)
> + return 0; /* normal -- e.g. unused OSD id/slot */
> +
> + if (addr_cnt == 1 && !memchr_inv(&tmp_addr, 0, sizeof(tmp_addr)))
> + return 0; /* weird but effectively the same as !addr_cnt */
> +
> + pr_err("no match of type %d in addrvec\n", le32_to_cpu(my_type));
> + return -ENOENT;
>
> e_inval:
> return -EINVAL;
Reviewed-by: Jeff Layton <jlayton@kernel.org>
prev parent reply other threads:[~2021-05-04 13:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-04 10:54 [PATCH] libceph: allow addrvecs with a single NONE/blank address Ilya Dryomov
2021-05-04 13:21 ` Jeff Layton [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=f389505b985f2bad7e56acd8113917cb6f06a4c6.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=ceph-devel@vger.kernel.org \
--cc=idryomov@gmail.com \
--cc=magnus@harlan.de \
/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).