From patchwork Thu Dec 27 23:17:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1913881 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 17A01DF2A2 for ; Thu, 27 Dec 2012 23:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752323Ab2L0XRz (ORCPT ); Thu, 27 Dec 2012 18:17:55 -0500 Received: from mail-ia0-f171.google.com ([209.85.210.171]:50237 "EHLO mail-ia0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752040Ab2L0XRz (ORCPT ); Thu, 27 Dec 2012 18:17:55 -0500 Received: by mail-ia0-f171.google.com with SMTP id k27so8382359iad.2 for ; Thu, 27 Dec 2012 15:17:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=/U/t8ryMqaYKoa6vz6vZfzZRKXCkcEdcnxhdG5K7XoY=; b=ELE9EIl0HZl3pBEfNopkcfuZv+h248myumzCHzCYuxa7vcd32crjAl7zMPUm2RjAzX CApy2O/pwAXojdX+OGEvkiMuMoCOav+2xrEG7hMigYZN7/LlEsg0nyms2K2iAlZVSo61 989O8h9MQXqpO1VfNJajQBbR6mE7XfVPrIq1vWKFJwaVkpfEucFFFtl6g1+ikSzqu/2N DpTlSM2YtySFc5lzQk5KTLf1q/gm4BNxusxlMljlNVyqmSxUcG6JAwKW/adkamLfEWqU EQJLPc1JTH9IYP2JI4EYdyGAtB11ZDwehXKi0TilUS2lYYQ6ABjPcaIw8MokQbz1pLyE QnNA== X-Received: by 10.50.152.243 with SMTP id vb19mr27786663igb.16.1356650274833; Thu, 27 Dec 2012 15:17:54 -0800 (PST) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPS id b13sm25224312igp.7.2012.12.27.15.17.53 (version=SSLv3 cipher=OTHER); Thu, 27 Dec 2012 15:17:54 -0800 (PST) Message-ID: <50DCD720.4070909@inktank.com> Date: Thu, 27 Dec 2012 17:17:52 -0600 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 3/3] libceph: WARN, don't BUG on unexpected connection states References: <50DCD544.8000602@inktank.com> In-Reply-To: <50DCD544.8000602@inktank.com> X-Gm-Message-State: ALoCoQmfTFYNiBl6TesnrcyOyR38WckO7dzRxxdOAZRD2wObiI2NNrk4bS7Td9wvIAruHEKO4t1P Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org A number of assertions in the ceph messenger are implemented with BUG_ON(), killing the system if connection's state doesn't match what's expected. At this point our state model is (evidently) not well understood enough for these assertions to trigger a BUG(). Convert all BUG_ON(con->state...) calls to be WARN_ON(con->state...) so we learn about these issues without killing the machine. We now recognize that a connection fault can occur due to a socket closure at any time, regardless of the state of the connection. So there is really nothing we can assert about the state of the connection at that point so eliminate that assertion. Reported-by: Ugis Tested-by: Ugis Signed-off-by: Alex Elder --- net/ceph/messenger.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) con->peer_global_seq = le32_to_cpu(con->in_reply.global_seq); @@ -2132,7 +2132,6 @@ more: if (ret < 0) goto out; - BUG_ON(con->state != CON_STATE_CONNECTING); con->state = CON_STATE_NEGOTIATING; /* @@ -2160,7 +2159,7 @@ more: goto more; } - BUG_ON(con->state != CON_STATE_OPEN); + WARN_ON(con->state != CON_STATE_OPEN); if (con->in_base_pos < 0) { /* @@ -2382,10 +2381,6 @@ static void ceph_fault(struct ceph_connection *con) dout("fault %p state %lu to peer %s\n", con, con->state, ceph_pr_addr(&con->peer_addr.in_addr)); - BUG_ON(con->state != CON_STATE_CONNECTING && - con->state != CON_STATE_NEGOTIATING && - con->state != CON_STATE_OPEN); - con_close_socket(con); if (test_bit(CON_FLAG_LOSSYTX, &con->flags)) { diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 4d111fd..075b9fd 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -561,7 +561,7 @@ void ceph_con_open(struct ceph_connection *con, mutex_lock(&con->mutex); dout("con_open %p %s\n", con, ceph_pr_addr(&addr->in_addr)); - BUG_ON(con->state != CON_STATE_CLOSED); + WARN_ON(con->state != CON_STATE_CLOSED); con->state = CON_STATE_PREOPEN; con->peer_name.type = (__u8) entity_type; @@ -1509,7 +1509,7 @@ static int process_banner(struct ceph_connection *con) static void fail_protocol(struct ceph_connection *con) { reset_connection(con); - BUG_ON(con->state != CON_STATE_NEGOTIATING); + WARN_ON(con->state != CON_STATE_NEGOTIATING); con->state = CON_STATE_CLOSED; } @@ -1635,7 +1635,7 @@ static int process_connect(struct ceph_connection *con) return -1; } - BUG_ON(con->state != CON_STATE_NEGOTIATING); + WARN_ON(con->state != CON_STATE_NEGOTIATING); con->state = CON_STATE_OPEN;