All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Xiubo Li <xiubli@redhat.com>,
	Milind Changire <mchangir@redhat.com>,
	Ilya Dryomov <idryomov@gmail.com>,
	Sasha Levin <sashal@kernel.org>,
	ceph-devel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.7 21/26] ceph: add ceph_cap_unlink_work to fire check_caps() immediately
Date: Thu, 29 Feb 2024 10:48:40 -0500	[thread overview]
Message-ID: <20240229154851.2849367-21-sashal@kernel.org> (raw)
In-Reply-To: <20240229154851.2849367-1-sashal@kernel.org>

From: Xiubo Li <xiubli@redhat.com>

[ Upstream commit dbc347ef7f0c53aa4a5383238a804d7ebbb0b5ca ]

When unlinking a file the check caps could be delayed for more than
5 seconds, but in MDS side it maybe waiting for the clients to
release caps.

This will use the cap_wq work queue and a dedicated list to help
fire the check_caps() and dirty buffer flushing immediately.

Link: https://tracker.ceph.com/issues/50223
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Milind Changire <mchangir@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/ceph/caps.c       | 17 +++++++++++++++-
 fs/ceph/mds_client.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
 fs/ceph/mds_client.h |  5 +++++
 3 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index ad4d5387aa1c8..b19cb515683dd 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -4777,7 +4777,22 @@ int ceph_drop_caps_for_unlink(struct inode *inode)
 		if (__ceph_caps_dirty(ci)) {
 			struct ceph_mds_client *mdsc =
 				ceph_inode_to_fs_client(inode)->mdsc;
-			__cap_delay_requeue_front(mdsc, ci);
+
+			doutc(mdsc->fsc->client, "%p %llx.%llx\n", inode,
+			      ceph_vinop(inode));
+			spin_lock(&mdsc->cap_unlink_delay_lock);
+			ci->i_ceph_flags |= CEPH_I_FLUSH;
+			if (!list_empty(&ci->i_cap_delay_list))
+				list_del_init(&ci->i_cap_delay_list);
+			list_add_tail(&ci->i_cap_delay_list,
+				      &mdsc->cap_unlink_delay_list);
+			spin_unlock(&mdsc->cap_unlink_delay_lock);
+
+			/*
+			 * Fire the work immediately, because the MDS maybe
+			 * waiting for caps release.
+			 */
+			ceph_queue_cap_unlink_work(mdsc);
 		}
 	}
 	spin_unlock(&ci->i_ceph_lock);
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 558c3af44449c..4d29fe4f42869 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -2470,6 +2470,50 @@ void ceph_reclaim_caps_nr(struct ceph_mds_client *mdsc, int nr)
 	}
 }
 
+void ceph_queue_cap_unlink_work(struct ceph_mds_client *mdsc)
+{
+	struct ceph_client *cl = mdsc->fsc->client;
+	if (mdsc->stopping)
+		return;
+
+        if (queue_work(mdsc->fsc->cap_wq, &mdsc->cap_unlink_work)) {
+                doutc(cl, "caps unlink work queued\n");
+        } else {
+                doutc(cl, "failed to queue caps unlink work\n");
+        }
+}
+
+static void ceph_cap_unlink_work(struct work_struct *work)
+{
+	struct ceph_mds_client *mdsc =
+		container_of(work, struct ceph_mds_client, cap_unlink_work);
+	struct ceph_client *cl = mdsc->fsc->client;
+
+	doutc(cl, "begin\n");
+	spin_lock(&mdsc->cap_unlink_delay_lock);
+	while (!list_empty(&mdsc->cap_unlink_delay_list)) {
+		struct ceph_inode_info *ci;
+		struct inode *inode;
+
+		ci = list_first_entry(&mdsc->cap_unlink_delay_list,
+				      struct ceph_inode_info,
+				      i_cap_delay_list);
+		list_del_init(&ci->i_cap_delay_list);
+
+		inode = igrab(&ci->netfs.inode);
+		if (inode) {
+			spin_unlock(&mdsc->cap_unlink_delay_lock);
+			doutc(cl, "on %p %llx.%llx\n", inode,
+			      ceph_vinop(inode));
+			ceph_check_caps(ci, CHECK_CAPS_FLUSH);
+			iput(inode);
+			spin_lock(&mdsc->cap_unlink_delay_lock);
+		}
+	}
+	spin_unlock(&mdsc->cap_unlink_delay_lock);
+	doutc(cl, "done\n");
+}
+
 /*
  * requests
  */
@@ -5346,6 +5390,8 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
 	INIT_LIST_HEAD(&mdsc->cap_delay_list);
 	INIT_LIST_HEAD(&mdsc->cap_wait_list);
 	spin_lock_init(&mdsc->cap_delay_lock);
+	INIT_LIST_HEAD(&mdsc->cap_unlink_delay_list);
+	spin_lock_init(&mdsc->cap_unlink_delay_lock);
 	INIT_LIST_HEAD(&mdsc->snap_flush_list);
 	spin_lock_init(&mdsc->snap_flush_lock);
 	mdsc->last_cap_flush_tid = 1;
@@ -5354,6 +5400,7 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
 	spin_lock_init(&mdsc->cap_dirty_lock);
 	init_waitqueue_head(&mdsc->cap_flushing_wq);
 	INIT_WORK(&mdsc->cap_reclaim_work, ceph_cap_reclaim_work);
+	INIT_WORK(&mdsc->cap_unlink_work, ceph_cap_unlink_work);
 	err = ceph_metric_init(&mdsc->metric);
 	if (err)
 		goto err_mdsmap;
@@ -5627,6 +5674,7 @@ void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc)
 	ceph_cleanup_global_and_empty_realms(mdsc);
 
 	cancel_work_sync(&mdsc->cap_reclaim_work);
+	cancel_work_sync(&mdsc->cap_unlink_work);
 	cancel_delayed_work_sync(&mdsc->delayed_work); /* cancel timer */
 
 	doutc(cl, "done\n");
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
index 2e6ddaa13d725..714360536ad4a 100644
--- a/fs/ceph/mds_client.h
+++ b/fs/ceph/mds_client.h
@@ -462,6 +462,8 @@ struct ceph_mds_client {
 	unsigned long    last_renew_caps;  /* last time we renewed our caps */
 	struct list_head cap_delay_list;   /* caps with delayed release */
 	spinlock_t       cap_delay_lock;   /* protects cap_delay_list */
+	struct list_head cap_unlink_delay_list;  /* caps with delayed release for unlink */
+	spinlock_t       cap_unlink_delay_lock;  /* protects cap_unlink_delay_list */
 	struct list_head snap_flush_list;  /* cap_snaps ready to flush */
 	spinlock_t       snap_flush_lock;
 
@@ -475,6 +477,8 @@ struct ceph_mds_client {
 	struct work_struct cap_reclaim_work;
 	atomic_t	   cap_reclaim_pending;
 
+	struct work_struct cap_unlink_work;
+
 	/*
 	 * Cap reservations
 	 *
@@ -574,6 +578,7 @@ extern void ceph_flush_cap_releases(struct ceph_mds_client *mdsc,
 				    struct ceph_mds_session *session);
 extern void ceph_queue_cap_reclaim_work(struct ceph_mds_client *mdsc);
 extern void ceph_reclaim_caps_nr(struct ceph_mds_client *mdsc, int nr);
+extern void ceph_queue_cap_unlink_work(struct ceph_mds_client *mdsc);
 extern int ceph_iterate_session_caps(struct ceph_mds_session *session,
 				     int (*cb)(struct inode *, int mds, void *),
 				     void *arg);
-- 
2.43.0


  parent reply	other threads:[~2024-02-29 15:49 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 15:48 [PATCH AUTOSEL 6.7 01/26] media: Revert "media: rkisp1: Drop IRQF_SHARED" Sasha Levin
2024-02-29 15:48 ` Sasha Levin
2024-02-29 15:48 ` Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 02/26] media: rkisp1: Fix IRQ handling due to shared interrupts Sasha Levin
2024-02-29 15:48   ` Sasha Levin
2024-02-29 15:48   ` Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 03/26] Revert "drm/msm/gpu: Push gpu lock down past runpm" Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 04/26] HID: logitech-hidpp: Do not flood kernel log Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 05/26] ASoC: cs42l43: Handle error from devm_pm_runtime_enable Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 06/26] wifi: iwlwifi: mvm: use correct address 3 in A-MSDU Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 07/26] arm64: jump_label: use constraints "Si" instead of "i" Sasha Levin
2024-02-29 15:48   ` Sasha Levin
2024-02-29 15:56   ` Mark Rutland
2024-02-29 15:56     ` Mark Rutland
2024-03-18 13:24     ` Sasha Levin
2024-03-18 13:24       ` Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 08/26] perf/arm-cmn: Workaround AmpereOneX errata AC04_MESH_1 (incorrect child count) Sasha Levin
2024-02-29 15:48   ` Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 09/26] btrfs: add and use helper to check if block group is used Sasha Levin
2024-02-29 15:52   ` David Sterba
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 10/26] selftests: openvswitch: Add validation for the recursion test Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 11/26] net: tls: factor out tls_*crypt_async_wait() Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 12/26] selftests: tls: use exact comparison in recv_partial Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 13/26] ASoC: rt5645: Make LattePanda board DMI match more precise Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 14/26] spi: omap2-mcspi: Revert FIFO support without DMA Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 15/26] spi: intel-pci: Add support for Lunar Lake-M SPI serial flash Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 16/26] regmap: kunit: Ensure that changed bytes are actually different Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 17/26] ASoC: amd: yc: Fix non-functional mic on Lenovo 82UU Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 18/26] x86/xen: Add some null pointer checking to smp.c Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 19/26] MIPS: Clear Cause.BD in instruction_pointer_set Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 20/26] ceph: always queue a writeback when revoking the Fb caps Sasha Levin
2024-02-29 15:48 ` Sasha Levin [this message]
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 22/26] HID: multitouch: Add required quirk for Synaptics 0xcddc device Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 23/26] ASoC: SOF: ipc4-pcm: Workaround for crashed firmware on system suspend Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 24/26] ALSA: hda/realtek: cs35l41: Add internal speaker support for ASUS UM3402 with missing DSD Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 25/26] gen_compile_commands: fix invalid escape sequence warning Sasha Levin
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 26/26] arm64/sve: Lower the maximum allocation for the SVE ptrace regset Sasha Levin
2024-02-29 15:48   ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240229154851.2849367-21-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchangir@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=xiubli@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.