From patchwork Sat Feb 6 07:00:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 8241711 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B52A99F1C0 for ; Sat, 6 Feb 2016 07:00:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E414D2022A for ; Sat, 6 Feb 2016 07:00:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C29D20225 for ; Sat, 6 Feb 2016 07:00:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751512AbcBFHAb (ORCPT ); Sat, 6 Feb 2016 02:00:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33900 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751133AbcBFHAa (ORCPT ); Sat, 6 Feb 2016 02:00:30 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 891BD8E254; Sat, 6 Feb 2016 07:00:30 +0000 (UTC) Received: from localhost.localdomain (vpn1-7-11.pek2.redhat.com [10.72.7.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1670FWq003708; Sat, 6 Feb 2016 02:00:28 -0500 From: "Yan, Zheng" To: ceph-devel@vger.kernel.org Cc: sweil@redhat.com, idryomov@gmail.com, "Yan, Zheng" Subject: [PATCH v2 4/6] libceph: make sure redirect does not change namespace Date: Sat, 6 Feb 2016 15:00:04 +0800 Message-Id: <1454742006-85706-5-git-send-email-zyan@redhat.com> In-Reply-To: <1454742006-85706-1-git-send-email-zyan@redhat.com> References: <1454742006-85706-1-git-send-email-zyan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Yan, Zheng --- net/ceph/osd_client.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 68e7f68..136245d 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -1722,10 +1722,23 @@ static int ceph_oloc_decode(void **p, void *end, } if (struct_v >= 5) { + bool changed = false; u32 ns_len = ceph_decode_32(p); if (ns_len > 0) { ceph_decode_need(p, end, ns_len, e_inval); + if (oloc->pool != -1 && + (!oloc->pool_ns || + ceph_compare_string(oloc->pool_ns, *p, ns_len))) + changed = true; *p += ns_len; + } else { + if (oloc->pool != -1 && oloc->pool_ns) + changed = true; + } + if (changed) { + /* redirect changes namespace */ + pr_warn("ceph_object_locator::nspace is changed\n"); + goto e_inval; } } @@ -1898,7 +1911,9 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg) } if (decode_redir) { + redir.oloc.pool_ns = req->r_target_oloc.pool_ns; err = ceph_redirect_decode(&p, end, &redir); + redir.oloc.pool_ns = NULL; if (err) goto bad_put; } else {