Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3967764img; Mon, 25 Mar 2019 23:45:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwH8cdeYnhjiiAr8e5FsPvDVZ876e3L5XzZUBf/28YcjzJDeGnd2J9MBcf88GuV6O64uOyH X-Received: by 2002:a62:bd13:: with SMTP id a19mr28073995pff.222.1553582703437; Mon, 25 Mar 2019 23:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553582703; cv=none; d=google.com; s=arc-20160816; b=G8viRRbxBoihFpjKLQSlAnCazuBVn3UpkWiU9wPkqU/0JvhueOIODaKNELj9jn3Q+d +7yZS9nepYa5HPFClktj/7td7lPBzydwfDhyZsT3rC/VSinFwQ1YU7zrdaYcXquVjXam hByy3K445FyRjcNDrHtmkbdqkeGuOXTFcW2EOyKvEGMpAEStjg42trwl1P+c6HlQYWWV r9P1fBcBZPHSBRUD/IcI/bzLUvnBihFAXwznaLi9Be13KMwOqZGiAxindLwd6VL6Ebad vRiCpNkCCjalw5Ue+wscbWxZXwYsjy1WfO7fnJNvV6wwlgUOiTuSDErpZ43hnsLngYkI nT+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SBYnZQkgwlS5lPCwEu+eMv/00p2/ep0NoUtsyBH6044=; b=k7gkHUMgGe8LDJBXUvLdskENKsSJTrhm04GpMNBOgWGEj4eDvvPyZrOOk0tez5DTzL UR5WJ+oRfWfr0LufrD4AIKpRdaH7uBTdjPgBCd7UBhsdG0Ys5GNBDSWfk1h2HCTOzoE8 SjS8cHyEccPKbzPJdp1qaygjy55a8EmZl0QJ4jyFS0qKjy/b7VS/TT7mmLc/h7T+9nYs PyuW0kJ92bAskMcvsC5IUUaqFrx8/vWgXK4fB0PcVrvWxzIONt5cYTBo0BdhQrMWRsf3 obBoUtiN4EOmSWuTOEiRZUB4Mzns7VfqLylyJu1yNIhIRLxw/39LDlWAzoemZ59s15qr syLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OIrYhojj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r198si15002261pgr.519.2019.03.25.23.44.48; Mon, 25 Mar 2019 23:45:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OIrYhojj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732152AbfCZGgK (ORCPT + 99 others); Tue, 26 Mar 2019 02:36:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:48364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732141AbfCZGgG (ORCPT ); Tue, 26 Mar 2019 02:36:06 -0400 Received: from localhost (unknown [104.132.152.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2485420823; Tue, 26 Mar 2019 06:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553582165; bh=+wt6X4yFi9ylEUAOVBZ6g5Rn+eKa18mvplRd1O3cdnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OIrYhojjgSo+2i7/LHc1CtcoY0ql1H9cX5mHPupcZnjDll/0VtfUIabhYy6RKwI/n VUA0QS8HodjZy+fYqiy13BUDrxD44QbKpUypMxVcC3/tUwMi6rPKvo2IEzz0Z6c+jg qYNL0FpVNso7thgnwSvFNbiVfwEfxUAydLD2XaKY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Dryomov , Jason Dillaman Subject: [PATCH 4.19 09/45] libceph: wait for latest osdmap in ceph_monc_blacklist_add() Date: Tue, 26 Mar 2019 15:29:52 +0900 Message-Id: <20190326042703.162116636@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190326042702.565683325@linuxfoundation.org> References: <20190326042702.565683325@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ilya Dryomov commit bb229bbb3bf63d23128e851a1f3b85c083178fa1 upstream. Because map updates are distributed lazily, an OSD may not know about the new blacklist for quite some time after "osd blacklist add" command is completed. This makes it possible for a blacklisted but still alive client to overwrite a post-blacklist update, resulting in data corruption. Waiting for latest osdmap in ceph_monc_blacklist_add() and thus using the post-blacklist epoch for all post-blacklist requests ensures that all such requests "wait" for the blacklist to come into force on their respective OSDs. Cc: stable@vger.kernel.org Fixes: 6305a3b41515 ("libceph: support for blacklisting clients") Signed-off-by: Ilya Dryomov Reviewed-by: Jason Dillaman Signed-off-by: Greg Kroah-Hartman --- include/linux/ceph/libceph.h | 2 ++ net/ceph/ceph_common.c | 18 +++++++++++++++++- net/ceph/mon_client.c | 9 +++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) --- a/include/linux/ceph/libceph.h +++ b/include/linux/ceph/libceph.h @@ -292,6 +292,8 @@ extern void ceph_destroy_client(struct c extern int __ceph_open_session(struct ceph_client *client, unsigned long started); extern int ceph_open_session(struct ceph_client *client); +int ceph_wait_for_latest_osdmap(struct ceph_client *client, + unsigned long timeout); /* pagevec.c */ extern void ceph_release_page_vector(struct page **pages, int num_pages); --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c @@ -729,7 +729,6 @@ int __ceph_open_session(struct ceph_clie } EXPORT_SYMBOL(__ceph_open_session); - int ceph_open_session(struct ceph_client *client) { int ret; @@ -745,6 +744,23 @@ int ceph_open_session(struct ceph_client } EXPORT_SYMBOL(ceph_open_session); +int ceph_wait_for_latest_osdmap(struct ceph_client *client, + unsigned long timeout) +{ + u64 newest_epoch; + int ret; + + ret = ceph_monc_get_version(&client->monc, "osdmap", &newest_epoch); + if (ret) + return ret; + + if (client->osdc.osdmap->epoch >= newest_epoch) + return 0; + + ceph_osdc_maybe_request_map(&client->osdc); + return ceph_monc_wait_osdmap(&client->monc, newest_epoch, timeout); +} +EXPORT_SYMBOL(ceph_wait_for_latest_osdmap); static int __init init_ceph_lib(void) { --- a/net/ceph/mon_client.c +++ b/net/ceph/mon_client.c @@ -922,6 +922,15 @@ int ceph_monc_blacklist_add(struct ceph_ mutex_unlock(&monc->mutex); ret = wait_generic_request(req); + if (!ret) + /* + * Make sure we have the osdmap that includes the blacklist + * entry. This is needed to ensure that the OSDs pick up the + * new blacklist before processing any future requests from + * this client. + */ + ret = ceph_wait_for_latest_osdmap(monc->client, 0); + out: put_generic_request(req); return ret;