From patchwork Tue Jun 29 04:42:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 468394 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 999B6C11F66 for ; Tue, 29 Jun 2021 04:42:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7508261D91 for ; Tue, 29 Jun 2021 04:42:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230283AbhF2EpX (ORCPT ); Tue, 29 Jun 2021 00:45:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58643 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbhF2EpX (ORCPT ); Tue, 29 Jun 2021 00:45:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624941776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=86Hy0iwAkoq+jSN8Fi74X61T43Ge8xJ127MRKB6HoHY=; b=UpQhTVaqKtM5wWK+x1fqVjzxrvw6KmCrEbcc+JzDVryK7FwvoqeXN2clKDVJzAAjHr/HSj NBZg082QDA7dbYq0a5OnQE1Hhp+JQX3EY1SStDoAS4jGreExYDRq0Up6jOHxOGIAwMq/CP cD/8yVhlsd4oqkonmMbiPXqtpbB9UTU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-57-939lqvm7Ok-c4iWcY53uQw-1; Tue, 29 Jun 2021 00:42:50 -0400 X-MC-Unique: 939lqvm7Ok-c4iWcY53uQw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33FE7804141; Tue, 29 Jun 2021 04:42:49 +0000 (UTC) Received: from lxbceph1.gsslab.pek2.redhat.com (unknown [10.72.47.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54B295D9DC; Tue, 29 Jun 2021 04:42:47 +0000 (UTC) From: xiubli@redhat.com To: jlayton@kernel.org Cc: idryomov@gmail.com, pdonnell@redhat.com, ceph-devel@vger.kernel.org, Xiubo Li Subject: [PATCH 1/5] ceph: export ceph_create_session_msg Date: Tue, 29 Jun 2021 12:42:37 +0800 Message-Id: <20210629044241.30359-2-xiubli@redhat.com> In-Reply-To: <20210629044241.30359-1-xiubli@redhat.com> References: <20210629044241.30359-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li Signed-off-by: Xiubo Li --- fs/ceph/mds_client.c | 15 ++++++++------- fs/ceph/mds_client.h | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 2d7dcd295bb9..e49d3e230712 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -1150,7 +1150,7 @@ static int __choose_mds(struct ceph_mds_client *mdsc, /* * session messages */ -static struct ceph_msg *create_session_msg(u32 op, u64 seq) +struct ceph_msg *ceph_create_session_msg(u32 op, u64 seq) { struct ceph_msg *msg; struct ceph_mds_session_head *h; @@ -1158,7 +1158,7 @@ static struct ceph_msg *create_session_msg(u32 op, u64 seq) msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h), GFP_NOFS, false); if (!msg) { - pr_err("create_session_msg ENOMEM creating msg\n"); + pr_err("ceph_create_session_msg ENOMEM creating msg\n"); return NULL; } h = msg->front.iov_base; @@ -1289,7 +1289,7 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6 msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h) + extra_bytes, GFP_NOFS, false); if (!msg) { - pr_err("create_session_msg ENOMEM creating msg\n"); + pr_err("ceph_create_session_msg ENOMEM creating msg\n"); return ERR_PTR(-ENOMEM); } p = msg->front.iov_base; @@ -1801,8 +1801,8 @@ static int send_renew_caps(struct ceph_mds_client *mdsc, dout("send_renew_caps to mds%d (%s)\n", session->s_mds, ceph_mds_state_name(state)); - msg = create_session_msg(CEPH_SESSION_REQUEST_RENEWCAPS, - ++session->s_renew_seq); + msg = ceph_create_session_msg(CEPH_SESSION_REQUEST_RENEWCAPS, + ++session->s_renew_seq); if (!msg) return -ENOMEM; ceph_con_send(&session->s_con, msg); @@ -1816,7 +1816,7 @@ static int send_flushmsg_ack(struct ceph_mds_client *mdsc, dout("send_flushmsg_ack to mds%d (%s)s seq %lld\n", session->s_mds, ceph_session_state_name(session->s_state), seq); - msg = create_session_msg(CEPH_SESSION_FLUSHMSG_ACK, seq); + msg = ceph_create_session_msg(CEPH_SESSION_FLUSHMSG_ACK, seq); if (!msg) return -ENOMEM; ceph_con_send(&session->s_con, msg); @@ -1868,7 +1868,8 @@ static int request_close_session(struct ceph_mds_session *session) dout("request_close_session mds%d state %s seq %lld\n", session->s_mds, ceph_session_state_name(session->s_state), session->s_seq); - msg = create_session_msg(CEPH_SESSION_REQUEST_CLOSE, session->s_seq); + msg = ceph_create_session_msg(CEPH_SESSION_REQUEST_CLOSE, + session->s_seq); if (!msg) return -ENOMEM; ceph_con_send(&session->s_con, msg); diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index bf99c5ba47fc..bf2683f0ba43 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -523,6 +523,7 @@ static inline void ceph_mdsc_put_request(struct ceph_mds_request *req) kref_put(&req->r_kref, ceph_mdsc_release_request); } +extern struct ceph_msg *ceph_create_session_msg(u32 op, u64 seq); extern void __ceph_queue_cap_release(struct ceph_mds_session *session, struct ceph_cap *cap); extern void ceph_flush_cap_releases(struct ceph_mds_client *mdsc, From patchwork Tue Jun 29 04:42:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 468393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30FDCC11F67 for ; Tue, 29 Jun 2021 04:43:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EACD61D91 for ; Tue, 29 Jun 2021 04:43:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231719AbhF2Ep1 (ORCPT ); Tue, 29 Jun 2021 00:45:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28957 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230416AbhF2EpY (ORCPT ); Tue, 29 Jun 2021 00:45:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624941777; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HjTp3SqeZLzVNTfWTv2ZJZ8pFh7Wb4ShbTqkja49wTs=; b=XkdVWRys9iEm+WCZbikSkhE83PLq33vxHqtL6jZCjY0TOjscb58jDBqqPZvG2g6gGhlR2v tQrOzoZ/ZUZP52PRNbIjwAjKecS424ocJvtsu3FTKMPuX4gY7AhrmImIWU3fTGUn7Wes5j tEJ6m/Wt1vjU3pqr9meoA8ADkkEQNSQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-5pN_5luzPO-tLPggCJjIzA-1; Tue, 29 Jun 2021 00:42:55 -0400 X-MC-Unique: 5pN_5luzPO-tLPggCJjIzA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F076E804140; Tue, 29 Jun 2021 04:42:53 +0000 (UTC) Received: from lxbceph1.gsslab.pek2.redhat.com (unknown [10.72.47.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AF155D9DC; Tue, 29 Jun 2021 04:42:51 +0000 (UTC) From: xiubli@redhat.com To: jlayton@kernel.org Cc: idryomov@gmail.com, pdonnell@redhat.com, ceph-devel@vger.kernel.org, Xiubo Li Subject: [PATCH 3/5] ceph: flush mdlog before umounting Date: Tue, 29 Jun 2021 12:42:39 +0800 Message-Id: <20210629044241.30359-4-xiubli@redhat.com> In-Reply-To: <20210629044241.30359-1-xiubli@redhat.com> References: <20210629044241.30359-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li Signed-off-by: Xiubo Li --- fs/ceph/mds_client.c | 29 +++++++++++++++++++++++++++++ fs/ceph/mds_client.h | 1 + include/linux/ceph/ceph_fs.h | 1 + 3 files changed, 31 insertions(+) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 96bef289f58f..2db87a5c68d4 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -4689,6 +4689,34 @@ static void wait_requests(struct ceph_mds_client *mdsc) dout("wait_requests done\n"); } +static void send_flush_mdlog(struct ceph_mds_session *s) +{ + u64 seq = s->s_seq; + struct ceph_msg *msg; + + /* + * For the MDS daemons lower than Luminous will crash when it + * saw this unknown session request. + */ + if (!CEPH_HAVE_FEATURE(s->s_con.peer_features, SERVER_LUMINOUS)) + return; + + dout("send_flush_mdlog to mds%d (%s)s seq %lld\n", + s->s_mds, ceph_session_state_name(s->s_state), seq); + msg = ceph_create_session_msg(CEPH_SESSION_REQUEST_FLUSH_MDLOG, seq); + if (!msg) { + pr_err("failed to send_flush_mdlog to mds%d (%s)s seq %lld\n", + s->s_mds, ceph_session_state_name(s->s_state), seq); + } else { + ceph_con_send(&s->s_con, msg); + } +} + +void flush_mdlog(struct ceph_mds_client *mdsc) +{ + ceph_mdsc_iterate_sessions(mdsc, send_flush_mdlog, true); +} + /* * called before mount is ro, and before dentries are torn down. * (hmm, does this still race with new lookups?) @@ -4698,6 +4726,7 @@ void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc) dout("pre_umount\n"); mdsc->stopping = 1; + flush_mdlog(mdsc); ceph_mdsc_iterate_sessions(mdsc, lock_unlock_session, false); ceph_flush_dirty_caps(mdsc); wait_requests(mdsc); diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index fca2cf427eaf..79d5b8ed62bf 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -537,6 +537,7 @@ extern int ceph_iterate_session_caps(struct ceph_mds_session *session, int (*cb)(struct inode *, struct ceph_cap *, void *), void *arg); +extern void flush_mdlog(struct ceph_mds_client *mdsc); extern void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc); static inline void ceph_mdsc_free_path(char *path, int len) diff --git a/include/linux/ceph/ceph_fs.h b/include/linux/ceph/ceph_fs.h index 57e5bd63fb7a..ae60696fe40b 100644 --- a/include/linux/ceph/ceph_fs.h +++ b/include/linux/ceph/ceph_fs.h @@ -300,6 +300,7 @@ enum { CEPH_SESSION_FLUSHMSG_ACK, CEPH_SESSION_FORCE_RO, CEPH_SESSION_REJECT, + CEPH_SESSION_REQUEST_FLUSH_MDLOG, }; extern const char *ceph_session_op_name(int op);