Skip to content

Commit 313771e

Browse files
committed
libceph, rbd: ignore addr->type while comparing in some cases
For libceph, this ensures that libceph instance sharing (share option) continues to work. For rbd, this avoids blocklisting alive lock owners (locker addr is always LEGACY, while watcher addr is ANY in nautilus). Signed-off-by: Ilya Dryomov <[email protected]>
1 parent a5cbd5f commit 313771e

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

drivers/block/rbd.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3957,8 +3957,12 @@ static int find_watcher(struct rbd_device *rbd_dev,
39573957

39583958
sscanf(locker->id.cookie, RBD_LOCK_COOKIE_PREFIX " %llu", &cookie);
39593959
for (i = 0; i < num_watchers; i++) {
3960-
if (!memcmp(&watchers[i].addr, &locker->info.addr,
3961-
sizeof(locker->info.addr)) &&
3960+
/*
3961+
* Ignore addr->type while comparing. This mimics
3962+
* entity_addr_t::get_legacy_str() + strcmp().
3963+
*/
3964+
if (ceph_addr_equal_no_type(&watchers[i].addr,
3965+
&locker->info.addr) &&
39623966
watchers[i].cookie == cookie) {
39633967
struct rbd_client_id cid = {
39643968
.gid = le64_to_cpu(watchers[i].name.num),

include/linux/ceph/msgr.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,18 @@ extern const char *ceph_entity_type_name(int type);
5252
* entity_addr -- network address
5353
*/
5454
struct ceph_entity_addr {
55-
__le32 type;
55+
__le32 type; /* CEPH_ENTITY_ADDR_TYPE_* */
5656
__le32 nonce; /* unique id for process (e.g. pid) */
5757
struct sockaddr_storage in_addr;
5858
} __attribute__ ((packed));
5959

60+
static inline bool ceph_addr_equal_no_type(const struct ceph_entity_addr *lhs,
61+
const struct ceph_entity_addr *rhs)
62+
{
63+
return !memcmp(&lhs->in_addr, &rhs->in_addr, sizeof(lhs->in_addr)) &&
64+
lhs->nonce == rhs->nonce;
65+
}
66+
6067
struct ceph_entity_inst {
6168
struct ceph_entity_name name;
6269
struct ceph_entity_addr addr;

net/ceph/mon_client.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ int ceph_monmap_contains(struct ceph_monmap *m, struct ceph_entity_addr *addr)
161161
{
162162
int i;
163163

164-
for (i = 0; i < m->num_mon; i++)
165-
if (memcmp(addr, &m->mon_inst[i].addr, sizeof(*addr)) == 0)
164+
for (i = 0; i < m->num_mon; i++) {
165+
if (ceph_addr_equal_no_type(addr, &m->mon_inst[i].addr))
166166
return 1;
167+
}
168+
167169
return 0;
168170
}
169171

0 commit comments

Comments
 (0)