From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796199911; b=TC6B0aiV4qFjJ4ulQT15Ax5dfBVRzAD+hWAYYT/uRpcjFPmX3iViFWKCfBbX5/hYP9Ib 1w36akaUQBkoyXulGjthZ7j31VL2eJT/tAceKFrphYmm1srmimpJYgePwY4c47+H9OZGU WVL5n2Lz5YyHdJpXjxh4zlnGWo52PrXpXDGJrE/9KCrOgg83nMiM/W6/muiVwmzYNGO6v 8HwTQfuXccVY764Cm9apUGJLywuPpaccZetDzRsQrCUXyCzNEgdZJe3+Et6HIO+7+XaRF 59UQJdZ/YQ1oxH3zKSd73A6Bef0mXPlJPASnhqLycF1e8ZT8b35cvMtb840TSvYxq0Q== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796199911; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=OyOa+i7M4NjeVj+UWAynUim0SCsXZoPxMQ697E1pmg8=; b=dwetGncTgJQ4gLId/yG93ZWjVYTn6oM0DIMEPG/6pj2SzcRk+FnOlFvl4zj97vyuTEDP 1iZtAUI+xOjj8nt9pLab0UF/Bj8FKHEUHs56IxpMcdZlNKqcDbVdQ63mJznqRbH37YWYZ S92NR6C6hK6DuEvodf7d1LF2/lo1OgdM4G4c11RdMOyGafVu6j5wrS4LlU73cnAe1POyQ 4PF/vx+nllQ71dRNz7QxKIQB3rjQwNslF+uzfEd9UnbIkjivk+VK8zDJXYnTeAnWfIWlc QrVGFkbO6vY/UT7fH5sm6ntU0NZzHQhdQodY/3oGWcMr6e5Qrgba66AnWvqFRLQyfAw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jyBcZfbN; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1E4F606A330; Wed, 2 Dec 2026 08:25:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jyBcZfbN Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796199911; b=mCfaHkQtM4pohZfXt2c/xLjMjUrhKyPreXVsLHZdk2qILCPOoSxNnRhSGoz4nLlmvWJk nPcw9SPR/OUhCBBa9orGO57IeviPyS9LYEbUulMNSZKzazZcmwu+WOK3SydQnn0ph+Koa BtArRxV3OU/XCnz/rQKmSwhDndS2OGQuc1q4AXPJMs1zUDmhK04S3xp5uOs9B9ggUBHQC chSzI/l8geL0xwjZdYwDcuu2SBJ2xWJVJ+u9LrH3m8LfLZYUoj0HJR/48Zbc5M41TNFjV LjgW44zMRpuxOpgXkZrmgUF82MDb51odwMvgyjTKNR7u/jnXV2qEy124k4eKqPEsWZQ== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796199911; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=OyOa+i7M4NjeVj+UWAynUim0SCsXZoPxMQ697E1pmg8=; b=BgD6LKLZ+f2A15/uPG2NmxGrVtqX7MvwASc2y6SFyKHUKzq9vBuFKIqYFlda0zrwgOle 97goOMkUSazqws8jzACD+TuyO0QSfyKkWokMhPtUFu9GXd/bjnC6ImVX/ODMlUY7BnsuX 6I6elHRgGvBEw97IMV+wHAj8VIRY+dmx/WUx8KA6Bk2uOpCN2ca+6MfMQOSZnNl/5Y8yl Bc0dfwMQerWoJ5BbqtS3oPDorUaF9PU86hJkhHVZ1ltYmjwhIlREzRmHvLLf8CgvgV55E OwHSAxTqJ1GfAnhS7MA4SgqRmB78uisRkO4K2cAIS2H4CFZ2S5jUT1Dc60bbHVJn+Yw== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 7AF4B1F0089A; Wed, 2 Dec 2026 08:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796199911; bh=OyOa+i7M4NjeVj+UWAynUim0SCsXZoPxMQ697E1pmg8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=jyBcZfbNHdedZCbxp3akgjDMaQ8ecNRvi9ZzWisKaFHFLFEjPKrYUHuyJiti9GxXf vnYmeeKEu/E/eQc56qmW6ZElCrxFH4zIhFtlm98RcoPwdgLCF2sm5q6qvjxlEwLr+v rAj23SvnZ/+5pNWlvqqJ6rptenMeZBXa6hxqi/4NeeL92vNfYroqx6Hhzvo6av7F/x 1j8nJg3sGcmE59HyYQdm2pNwCaLfd2dBEtMRuEhWsm8hJxe8aaPa9vF3LQdP7ptSw+ FqBlRQn825RX2PA7vXTL+2dbZau5JD3PpLT6/8ZBqn/tBO14lV3C6Yri0dvSHKR6Vg AFMZZQlKZPegw== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id BC9094F30D; Wed, 2 Dec 2026 08:24:49 +0000 (UTC) From: Xiubo Li via B4 Relay Date: Wed, 02 Dec 2026 09:24:45 +0100 Subject: [PATCH v9 4/5] ceph: move mdsc->mutex into __do_request() X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261202-ceph-mdsc-mutex-optimization-v9-4-f7719b7c4f57@clyso.com> References: <20261202-ceph-mdsc-mutex-optimization-v9-0-f7719b7c4f57@clyso.com> In-Reply-To: <20261202-ceph-mdsc-mutex-optimization-v9-0-f7719b7c4f57@clyso.com> To: Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Xiubo Li X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796199886; l=15463; i=xiubo.li@clyso.com; s=20260625; h=from:subject:message-id; bh=TLxHIc49IcdFO2KY4Q9Svwh63LmS8TLStU656zknmB0=; b=vNpS5hXE7NKaJyQlkI3SZiwDc5bPjcIiBaM2j75mJdiZ8tCnKDfHaZeBbn1yIQBKKd8EOuDbD BTgOQBNWoHZA+b9qxbqeew2KLCGdAuOJQUPrPz+IAYREim+Pvkg8Jc1 X-Developer-Key: i=xiubo.li@clyso.com; a=ed25519; pk=V3NGr0AgAopiUhaLY51ipBkLN5LlcLhjOEfLEq1RoZ8= X-Endpoint-Received: by B4 Relay for xiubo.li@clyso.com/20260625 with auth_id=840 X-Original-From: Xiubo Li Reply-To: xiubo.li@clyso.com Content-Transfer-Encoding: 8bit From: Xiubo Li Currently every caller must hold mdsc->mutex when invoking the request-send machinery. Move the mutex acquisition inside __do_request() so that callers can fire off a request without first serializing on the global lock. The mutex is released before the network send phase and re-acquired only for cleanup, so dentry traversal and message construction run concurrently across CPUs. This is the primary source of the observed 2x stat throughput improvement: the per-request send path shrinks from hundreds of microseconds to tens of microseconds once it no longer waits on the mutex. Wait-list draining, session-state wake-ups, and request kicking are reworked to either use the new wait-list spinlock or collect candidates under the mutex and process them outside it. mdsc->mdsmap may be replaced and freed by a new map as soon as the mutex is dropped. __do_request() therefore saves the epoch to encode in r_send_mdsmap_epoch before it unlocks, and create_request_message() encodes that copy instead of reading mdsc->mdsmap. ceph_mdsc_handle_mdsmap() likewise takes the epoch for ceph_monc_got_map() under the mutex, now that it wakes the waiters after unlocking. Signed-off-by: Xiubo Li --- fs/ceph/mds_client.c | 132 ++++++++++++++++++++++++++++++++++++--------------- fs/ceph/mds_client.h | 2 + 2 files changed, 97 insertions(+), 37 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 381df8dc1f5a..06aa04946243 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -2868,6 +2868,7 @@ ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode) init_completion(&req->r_completion); init_completion(&req->r_safe_completion); INIT_LIST_HEAD(&req->r_unsafe_item); + INIT_LIST_HEAD(&req->r_aux_item); ktime_get_coarse_real_ts64(&req->r_stamp); @@ -3469,7 +3470,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, end = msg->front.iov_base + msg->front.iov_len; - lhead->mdsmap_epoch = cpu_to_le32(mdsc->mdsmap->m_epoch); + lhead->mdsmap_epoch = cpu_to_le32(req->r_send_mdsmap_epoch); lhead->op = cpu_to_le32(req->r_op); lhead->caller_uid = cpu_to_le32(from_kuid(&init_user_ns, caller_fsuid)); @@ -3587,20 +3588,23 @@ static int __prepare_send_request(struct ceph_mds_session *session, * Avoid infinite retrying after overflow. The client will * increase the retry count and if the MDS is old version, * so we limit to retry at most 256 times. + * + * r_attempts was already incremented under mdsc->mutex by the + * caller (__do_request or replay_unsafe_requests), so the + * actual retry count is r_attempts - 1 and we skip the check + * on the first dispatch (r_attempts == 1). */ - if (req->r_attempts) { - old_max_retry = sizeof_field(struct ceph_mds_request_head, - num_retry); - old_max_retry = 1 << (old_max_retry * BITS_PER_BYTE); - if ((old_version && req->r_attempts >= old_max_retry) || - ((uint32_t)req->r_attempts >= U32_MAX)) { + if (req->r_attempts > 1) { + old_max_retry = sizeof_field(struct ceph_mds_request_head, + num_retry); + old_max_retry = 1 << (old_max_retry * BITS_PER_BYTE); + if ((old_version && (req->r_attempts - 1) >= old_max_retry) || + ((uint32_t)(req->r_attempts - 1) >= U32_MAX)) { pr_warn_ratelimited_client(cl, "request tid %llu seq overflow\n", req->r_tid); return -EMULTIHOP; - } + } } - - req->r_attempts++; if (req->r_inode) { struct ceph_cap *cap = ceph_get_cap_for_mds(ceph_inode(req->r_inode), mds); @@ -3712,9 +3716,36 @@ static void __do_request(struct ceph_mds_client *mdsc, int err = 0; bool random; + mutex_lock(&mdsc->mutex); + + /* + * r_attempts is bumped under mdsc->mutex just before the mutex + * is dropped to send the request, and it is only ever written + * back to 0 by the forward handler or cleanup_session_requests() + * (both under the mutex) before re-dispatching through a new + * __do_request() call. Consequently, r_attempts > 0 at this + * point always means another __do_request() instance has already + * passed the point of no return for this request, i.e. a racing + * kick_requests() or __wake_requests() picked up the same + * request from the xarray or a wait list and is about to send + * it. Bail out to prevent a double dispatch. + * + * Note: kick_requests() also filters on r_attempts > 0 during + * its collection pass, but that is a one-time snapshot taken + * under the mutex. Between that snapshot and the actual + * __do_request() call the mutex is dropped and re-acquired, so + * the protection is not atomic — this per-request gate closes + * the remaining window. + */ + if (req->r_attempts > 0) { + mutex_unlock(&mdsc->mutex); + return; + } + if (req->r_err || test_bit(CEPH_MDS_R_GOT_RESULT, &req->r_req_flags)) { if (test_bit(CEPH_MDS_R_ABORTED, &req->r_req_flags)) __unregister_request(mdsc, req); + mutex_unlock(&mdsc->mutex); return; } @@ -3747,6 +3778,7 @@ static void __do_request(struct ceph_mds_client *mdsc, spin_lock(&mdsc->wait_list_lock); list_add(&req->r_wait, &mdsc->waiting_for_map); spin_unlock(&mdsc->wait_list_lock); + mutex_unlock(&mdsc->mutex); return; } if (!(mdsc->fsc->mount_options->flags & @@ -3772,6 +3804,7 @@ static void __do_request(struct ceph_mds_client *mdsc, spin_lock(&mdsc->wait_list_lock); list_add(&req->r_wait, &mdsc->waiting_for_map); spin_unlock(&mdsc->wait_list_lock); + mutex_unlock(&mdsc->mutex); return; } @@ -3845,6 +3878,15 @@ static void __do_request(struct ceph_mds_client *mdsc, goto out_session; } + req->r_attempts++; + /* + * The message is built without mdsc->mutex, and a new mdsmap + * may replace and free mdsc->mdsmap meanwhile: take the epoch + * to encode now. + */ + req->r_send_mdsmap_epoch = mdsc->mdsmap->m_epoch; + mutex_unlock(&mdsc->mutex); + /* send request */ req->r_resend_mds = -1; /* forget any previous mds hint */ @@ -3875,6 +3917,7 @@ static void __do_request(struct ceph_mds_client *mdsc, err = wait_on_bit(&di->flags, CEPH_DENTRY_ASYNC_CREATE_BIT, TASK_KILLABLE); if (err) { + mutex_lock(&mdsc->mutex); mutex_lock(&req->r_fill_mutex); set_bit(CEPH_MDS_R_ABORTED, &req->r_req_flags); mutex_unlock(&req->r_fill_mutex); @@ -3912,6 +3955,8 @@ static void __do_request(struct ceph_mds_client *mdsc, err = __send_request(session, req, false); + mutex_lock(&mdsc->mutex); + out_session: ceph_put_mds_session(session); finish: @@ -3921,12 +3966,10 @@ static void __do_request(struct ceph_mds_client *mdsc, complete_request(mdsc, req); __unregister_request(mdsc, req); } + mutex_unlock(&mdsc->mutex); return; } -/* - * called under mdsc->mutex - */ static void __wake_requests(struct ceph_mds_client *mdsc, struct list_head *head) { @@ -3956,10 +3999,14 @@ static void __wake_requests(struct ceph_mds_client *mdsc, static void kick_requests(struct ceph_mds_client *mdsc, int mds) { struct ceph_client *cl = mdsc->fsc->client; - struct ceph_mds_request *req; + struct ceph_mds_request *req, *nreq; unsigned long idx; + LIST_HEAD(kick_list); doutc(cl, "kick_requests mds%d\n", mds); + + /* collect matching requests under the mutex */ + mutex_lock(&mdsc->mutex); idx = 0; xa_for_each(&mdsc->request_tree, idx, req) { if (test_bit(CEPH_MDS_R_GOT_UNSAFE, &req->r_req_flags)) @@ -3968,14 +4015,23 @@ static void kick_requests(struct ceph_mds_client *mdsc, int mds) continue; /* only new requests */ if (req->r_session && req->r_session->s_mds == mds) { - doutc(cl, " kicking tid %llu\n", req->r_tid); + ceph_mdsc_get_request(req); spin_lock(&mdsc->wait_list_lock); list_del_init(&req->r_wait); spin_unlock(&mdsc->wait_list_lock); - trace_ceph_mdsc_resume_request(mdsc, req); - __do_request(mdsc, req); + list_add_tail(&req->r_aux_item, &kick_list); } } + mutex_unlock(&mdsc->mutex); + + /* replay without the mutex */ + list_for_each_entry_safe(req, nreq, &kick_list, r_aux_item) { + doutc(cl, " kicking tid %llu\n", req->r_tid); + trace_ceph_mdsc_resume_request(mdsc, req); + list_del_init(&req->r_aux_item); + __do_request(mdsc, req); + ceph_mdsc_put_request(req); + } } int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, @@ -4035,10 +4091,11 @@ int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, doutc(cl, "submit_request on %p for inode %p\n", req, dir); mutex_lock(&mdsc->mutex); __register_request(mdsc, req, dir); + mutex_unlock(&mdsc->mutex); + trace_ceph_mdsc_submit_request(mdsc, req); __do_request(mdsc, req); err = req->r_err; - mutex_unlock(&mdsc->mutex); return err; } @@ -4475,13 +4532,14 @@ static void handle_forward(struct ceph_mds_client *mdsc, req->r_num_fwd = fwd_seq; req->r_resend_mds = next_mds; put_request_session(req); - __do_request(mdsc, req); } mutex_unlock(&mdsc->mutex); /* kick calling process */ if (aborted) complete_request(mdsc, req); + else if (!test_bit(CEPH_MDS_R_ABORTED, &req->r_req_flags)) + __do_request(mdsc, req); ceph_mdsc_put_request(req); return; @@ -4809,11 +4867,9 @@ static void handle_session(struct ceph_mds_session *session, mutex_unlock(&session->s_mutex); if (wake) { - mutex_lock(&mdsc->mutex); __wake_requests(mdsc, &session->s_waiting); if (wake == 2) kick_requests(mdsc, mds); - mutex_unlock(&mdsc->mutex); } if (op == CEPH_SESSION_CLOSE) ceph_put_mds_session(session); @@ -4869,8 +4925,11 @@ static void replay_unsafe_requests(struct ceph_mds_client *mdsc, doutc(mdsc->fsc->client, "mds%d\n", session->s_mds); mutex_lock(&mdsc->mutex); - list_for_each_entry_safe(req, nreq, &session->s_unsafe, r_unsafe_item) + list_for_each_entry_safe(req, nreq, &session->s_unsafe, r_unsafe_item) { + req->r_attempts++; + req->r_send_mdsmap_epoch = mdsc->mdsmap->m_epoch; __send_request(session, req, true); + } /* * also re-send old requests when MDS enters reconnect stage. So that MDS @@ -4889,6 +4948,8 @@ static void replay_unsafe_requests(struct ceph_mds_client *mdsc, ceph_mdsc_release_dir_caps_async(req); + req->r_attempts++; + req->r_send_mdsmap_epoch = mdsc->mdsmap->m_epoch; __send_request(session, req, true); } mutex_unlock(&mdsc->mutex); @@ -5449,9 +5510,7 @@ static int send_mds_reconnect(struct ceph_mds_client *mdsc, mutex_unlock(&session->s_mutex); - mutex_lock(&mdsc->mutex); __wake_requests(mdsc, &session->s_waiting); - mutex_unlock(&mdsc->mutex); up_read(&mdsc->snap_rwsem); ceph_pagelist_release(recon_state.pagelist); @@ -5876,8 +5935,8 @@ static void ceph_mdsc_reset_workfn(struct work_struct *work) } sessions[i]->s_state = CEPH_MDS_SESSION_CLOSED; __unregister_session(mdsc, sessions[i]); - __wake_requests(mdsc, &sessions[i]->s_waiting); mutex_unlock(&mdsc->mutex); + __wake_requests(mdsc, &sessions[i]->s_waiting); mutex_lock(&sessions[i]->s_mutex); cleanup_session_requests(mdsc, sessions[i]); @@ -5888,9 +5947,7 @@ static void ceph_mdsc_reset_workfn(struct work_struct *work) ceph_put_mds_session(sessions[i]); - mutex_lock(&mdsc->mutex); kick_requests(mdsc, mds); - mutex_unlock(&mdsc->mutex); torn_down++; pr_info_client(cl, "mds%d session reset complete\n", mds); @@ -6006,8 +6063,8 @@ static void check_new_map(struct ceph_mds_client *mdsc, /* force close session for stopped mds */ ceph_get_mds_session(s); __unregister_session(mdsc, s); - __wake_requests(mdsc, &s->s_waiting); mutex_unlock(&mdsc->mutex); + __wake_requests(mdsc, &s->s_waiting); mutex_lock(&s->s_mutex); cleanup_session_requests(mdsc, s); @@ -6016,8 +6073,8 @@ static void check_new_map(struct ceph_mds_client *mdsc, ceph_put_mds_session(s); - mutex_lock(&mdsc->mutex); kick_requests(mdsc, i); + mutex_lock(&mdsc->mutex); continue; } @@ -6065,9 +6122,9 @@ static void check_new_map(struct ceph_mds_client *mdsc, oldstate != CEPH_MDS_STATE_STARTING) pr_info_client(cl, "mds%d recovery completed\n", s->s_mds); - kick_requests(mdsc, i); ceph_get_mds_session(s); mutex_unlock(&mdsc->mutex); + kick_requests(mdsc, i); mutex_lock(&s->s_mutex); mutex_lock(&mdsc->mutex); ceph_put_mds_session(s); @@ -6991,8 +7048,8 @@ void ceph_mdsc_force_umount(struct ceph_mds_client *mdsc) if (session->s_state == CEPH_MDS_SESSION_REJECTED) __unregister_session(mdsc, session); - __wake_requests(mdsc, &session->s_waiting); mutex_unlock(&mdsc->mutex); + __wake_requests(mdsc, &session->s_waiting); mutex_lock(&session->s_mutex); __close_session(mdsc, session); @@ -7003,11 +7060,11 @@ void ceph_mdsc_force_umount(struct ceph_mds_client *mdsc) mutex_unlock(&session->s_mutex); ceph_put_mds_session(session); - mutex_lock(&mdsc->mutex); kick_requests(mdsc, mds); + mutex_lock(&mdsc->mutex); } - __wake_requests(mdsc, &mdsc->waiting_for_map); mutex_unlock(&mdsc->mutex); + __wake_requests(mdsc, &mdsc->waiting_for_map); } static void ceph_mdsc_stop(struct ceph_mds_client *mdsc) @@ -7151,8 +7208,8 @@ void ceph_mdsc_handle_fsmap(struct ceph_mds_client *mdsc, struct ceph_msg *msg) err_out: mutex_lock(&mdsc->mutex); mdsc->mdsmap_err = err; - __wake_requests(mdsc, &mdsc->waiting_for_map); mutex_unlock(&mdsc->mutex); + __wake_requests(mdsc, &mdsc->waiting_for_map); } /* @@ -7202,12 +7259,13 @@ void ceph_mdsc_handle_mdsmap(struct ceph_mds_client *mdsc, struct ceph_msg *msg) } mdsc->fsc->max_file_size = min((loff_t)mdsc->mdsmap->m_max_file_size, MAX_LFS_FILESIZE); + /* a newer map may free this one once the mutex is dropped */ + epoch = mdsc->mdsmap->m_epoch; + mutex_unlock(&mdsc->mutex); __wake_requests(mdsc, &mdsc->waiting_for_map); - ceph_monc_got_map(&mdsc->fsc->client->monc, CEPH_SUB_MDSMAP, - mdsc->mdsmap->m_epoch); + ceph_monc_got_map(&mdsc->fsc->client->monc, CEPH_SUB_MDSMAP, epoch); - mutex_unlock(&mdsc->mutex); schedule_delayed(mdsc, 0); return; diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index ce28e696cd12..72048568db8a 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -421,6 +421,7 @@ struct ceph_mds_request { int r_attempts; /* resend attempts */ int r_num_fwd; /* number of forward attempts */ int r_resend_mds; /* mds to resend to next, if any*/ + u32 r_send_mdsmap_epoch; /* mdsmap epoch to encode */ u32 r_sent_on_mseq; /* cap mseq request was sent at*/ u64 r_deleg_ino; @@ -429,6 +430,7 @@ struct ceph_mds_request { struct completion r_safe_completion; ceph_mds_request_callback_t r_callback; struct list_head r_unsafe_item; /* per-session unsafe list item */ + struct list_head r_aux_item; /* auxiliary local list item */ long long r_dir_release_cnt; long long r_dir_ordered_cnt; -- 2.53.0