From patchwork Sat Dec 7 18:59:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Campos Guadamuz X-Patchwork-Id: 3304891 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D9988C0D4A for ; Sat, 7 Dec 2013 11:01:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A4E7920220 for ; Sat, 7 Dec 2013 11:01:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 791A9201F4 for ; Sat, 7 Dec 2013 11:01:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754125Ab3LGLBA (ORCPT ); Sat, 7 Dec 2013 06:01:00 -0500 Received: from mail-ee0-f47.google.com ([74.125.83.47]:47485 "EHLO mail-ee0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754066Ab3LGLBA (ORCPT ); Sat, 7 Dec 2013 06:01:00 -0500 Received: by mail-ee0-f47.google.com with SMTP id e51so711104eek.34 for ; Sat, 07 Dec 2013 03:00:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=9vcksL7+5VjMpbqHMFMfFqzLCobwlwC8kpHBJZo3nko=; b=1IqBXoAl8aRT1gr5hTSKTHSf/9ssfpfAzW/vVP7FNsayEF+wqIf2IFOCmnYKJSVQDf iHtvRbg4+byVMkyMXiPp2RbafPxYNcPAtKj0vS+CnRyhU4daj8WNfMNYkf0/0/tO4mjk G9Ut9Zc9EUbpP/MyOoqeumk/X2McCMu0z9w7EIig5O6bDbQGPmrKXwoZAplUWwIvdgzN s9w4WsCmjBEjT9Q+W9djKaFXrA00DqUZ+0bh8B983vVemC4RmXGTWxZjr6Ql7NgaJqMw EkUXpdecLuZQ68C3GbY9mjwR/OG5WilVibdcZnj/OznCvNpXFFndNmrft70F9sB0qkHW juHg== X-Received: by 10.15.108.73 with SMTP id cc49mr339292eeb.93.1386414058812; Sat, 07 Dec 2013 03:00:58 -0800 (PST) Received: from localhost.localdomain ([178.125.40.126]) by mx.google.com with ESMTPSA id v7sm5325671eel.2.2013.12.07.03.00.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Dec 2013 03:00:58 -0800 (PST) From: Mikhail Campos Guadamuz To: ceph-devel@vger.kernel.org Cc: Mikhail Campos Guadamuz Subject: [PATCH 1/2] No MDS mount error fix Date: Sat, 7 Dec 2013 13:59:19 -0500 Message-Id: <1b8c4b9c49deb956e9d065b0677bfeaf17c968d2.1386442053.git.plageat90@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 For http://tracker.ceph.com/issues/4386 It determines situation, when a user is trying to mount CephFS with no MDS present. Return ECOMM from open_root_dentry which can be analyzed then by ceph.mount Signed-off-by: Mikhail Campos Guadamuz --- fs/ceph/mdsmap.c | 19 ++++++++++++++++--- fs/ceph/super.c | 10 +++++++++- include/linux/ceph/mdsmap.h | 1 + 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/fs/ceph/mdsmap.c b/fs/ceph/mdsmap.c index 132b64e..3a6ba8a 100644 --- a/fs/ceph/mdsmap.c +++ b/fs/ceph/mdsmap.c @@ -12,6 +12,20 @@ #include "super.h" +/* + * count active mds's + */ +int ceph_mdsmap_active_mds_count(struct ceph_mdsmap *m) +{ + int n = 0; + int i; + + for(i = 0; i < m->m_max_mds; ++i) + if(m->m_info[i].state > 0) + ++n; + + return n; +} /* * choose a random mds that is "up" (i.e. has a state > 0), or -1. @@ -26,9 +40,8 @@ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m) return 0; /* count */ - for (i = 0; i < m->m_max_mds; i++) - if (m->m_info[i].state > 0) - n++; + n = ceph_mdsmap_active_mds_count(m); + if (n == 0) return -1; diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 6627b26..4d33d68 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -674,7 +674,15 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc, struct ceph_mds_request *req = NULL; int err; struct dentry *root; - + + /* check for mds*/ + if( 0 == ceph_mdsmap_active_mds_count(mdsc->mdsmap) ) + { + pr_info("active mds not found, possible not exist\n"); + root = ERR_PTR( -ECOMM ); + return root; + } + /* open dir */ dout("open_root_inode opening '%s'\n", path); req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_GETATTR, USE_ANY_MDS); diff --git a/include/linux/ceph/mdsmap.h b/include/linux/ceph/mdsmap.h index 87ed09f..4d7d502 100644 --- a/include/linux/ceph/mdsmap.h +++ b/include/linux/ceph/mdsmap.h @@ -56,6 +56,7 @@ static inline bool ceph_mdsmap_is_laggy(struct ceph_mdsmap *m, int w) return false; } +extern int ceph_mdsmap_active_mds_count(struct ceph_mdsmap *m); extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m); extern struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end); extern void ceph_mdsmap_destroy(struct ceph_mdsmap *m);