summaryrefslogtreecommitdiffstats
path: root/debian/patches-rt/0025-NFSv4-replace-seqcount_t-with-a-seqlock_t.patch
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 01:02:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 01:02:38 +0000
commit08b74a000942a380fe028845f92cd3a0dee827d5 (patch)
treeaa78b4e12607c3e1fcce8d5cc42df4330792f118 /debian/patches-rt/0025-NFSv4-replace-seqcount_t-with-a-seqlock_t.patch
parentAdding upstream version 4.19.249. (diff)
downloadlinux-08b74a000942a380fe028845f92cd3a0dee827d5.tar.xz
linux-08b74a000942a380fe028845f92cd3a0dee827d5.zip
Adding debian version 4.19.249-2.debian/4.19.249-2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/patches-rt/0025-NFSv4-replace-seqcount_t-with-a-seqlock_t.patch')
-rw-r--r--debian/patches-rt/0025-NFSv4-replace-seqcount_t-with-a-seqlock_t.patch136
1 files changed, 136 insertions, 0 deletions
diff --git a/debian/patches-rt/0025-NFSv4-replace-seqcount_t-with-a-seqlock_t.patch b/debian/patches-rt/0025-NFSv4-replace-seqcount_t-with-a-seqlock_t.patch
new file mode 100644
index 000000000..837bf02da
--- /dev/null
+++ b/debian/patches-rt/0025-NFSv4-replace-seqcount_t-with-a-seqlock_t.patch
@@ -0,0 +1,136 @@
+From a21527d57f8b1d303be3a91b055080f68bd83448 Mon Sep 17 00:00:00 2001
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 28 Oct 2016 23:05:11 +0200
+Subject: [PATCH 025/347] NFSv4: replace seqcount_t with a seqlock_t
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.246-rt110.tar.xz
+
+The raw_write_seqcount_begin() in nfs4_reclaim_open_state() bugs me
+because it maps to preempt_disable() in -RT which I can't have at this
+point. So I took a look at the code.
+It the lockdep part was removed in commit abbec2da13f0 ("NFS: Use
+raw_write_seqcount_begin/end int nfs4_reclaim_open_state") because
+lockdep complained. The whole seqcount thing was introduced in commit
+c137afabe330 ("NFSv4: Allow the state manager to mark an open_owner as
+being recovered").
+The recovery threads runs only once.
+write_seqlock() does not work on !RT because it disables preemption and it the
+writer side is preemptible (has to remain so despite the fact that it will
+block readers).
+
+Reported-by: kernel test robot <xiaolong.ye@intel.com>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ fs/nfs/delegation.c | 4 ++--
+ fs/nfs/nfs4_fs.h | 2 +-
+ fs/nfs/nfs4proc.c | 4 ++--
+ fs/nfs/nfs4state.c | 22 ++++++++++++++++------
+ 4 files changed, 21 insertions(+), 11 deletions(-)
+
+diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
+index b0c0c2fc2fba..26565ba05dc1 100644
+--- a/fs/nfs/delegation.c
++++ b/fs/nfs/delegation.c
+@@ -162,11 +162,11 @@ static int nfs_delegation_claim_opens(struct inode *inode,
+ sp = state->owner;
+ /* Block nfs4_proc_unlck */
+ mutex_lock(&sp->so_delegreturn_mutex);
+- seq = raw_seqcount_begin(&sp->so_reclaim_seqcount);
++ seq = read_seqbegin(&sp->so_reclaim_seqlock);
+ err = nfs4_open_delegation_recall(ctx, state, stateid);
+ if (!err)
+ err = nfs_delegation_claim_locks(state, stateid);
+- if (!err && read_seqcount_retry(&sp->so_reclaim_seqcount, seq))
++ if (!err && read_seqretry(&sp->so_reclaim_seqlock, seq))
+ err = -EAGAIN;
+ mutex_unlock(&sp->so_delegreturn_mutex);
+ put_nfs_open_context(ctx);
+diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
+index 5ac7bf24c507..b15a7a2f64fe 100644
+--- a/fs/nfs/nfs4_fs.h
++++ b/fs/nfs/nfs4_fs.h
+@@ -114,7 +114,7 @@ struct nfs4_state_owner {
+ unsigned long so_flags;
+ struct list_head so_states;
+ struct nfs_seqid_counter so_seqid;
+- seqcount_t so_reclaim_seqcount;
++ seqlock_t so_reclaim_seqlock;
+ struct mutex so_delegreturn_mutex;
+ };
+
+diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
+index 759c834b60fd..256a4b0c4407 100644
+--- a/fs/nfs/nfs4proc.c
++++ b/fs/nfs/nfs4proc.c
+@@ -2874,7 +2874,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
+ unsigned int seq;
+ int ret;
+
+- seq = raw_seqcount_begin(&sp->so_reclaim_seqcount);
++ seq = raw_seqcount_begin(&sp->so_reclaim_seqlock.seqcount);
+
+ ret = _nfs4_proc_open(opendata, ctx);
+ if (ret != 0)
+@@ -2915,7 +2915,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
+
+ if (d_inode(dentry) == state->inode) {
+ nfs_inode_attach_open_context(ctx);
+- if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq))
++ if (read_seqretry(&sp->so_reclaim_seqlock, seq))
+ nfs4_schedule_stateid_recovery(server, state);
+ }
+
+diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
+index 30576a10a1f4..e0b94cbce3bf 100644
+--- a/fs/nfs/nfs4state.c
++++ b/fs/nfs/nfs4state.c
+@@ -516,7 +516,7 @@ nfs4_alloc_state_owner(struct nfs_server *server,
+ nfs4_init_seqid_counter(&sp->so_seqid);
+ atomic_set(&sp->so_count, 1);
+ INIT_LIST_HEAD(&sp->so_lru);
+- seqcount_init(&sp->so_reclaim_seqcount);
++ seqlock_init(&sp->so_reclaim_seqlock);
+ mutex_init(&sp->so_delegreturn_mutex);
+ return sp;
+ }
+@@ -1584,8 +1584,12 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
+ * recovering after a network partition or a reboot from a
+ * server that doesn't support a grace period.
+ */
++#ifdef CONFIG_PREEMPT_RT_FULL
++ write_seqlock(&sp->so_reclaim_seqlock);
++#else
++ write_seqcount_begin(&sp->so_reclaim_seqlock.seqcount);
++#endif
+ spin_lock(&sp->so_lock);
+- raw_write_seqcount_begin(&sp->so_reclaim_seqcount);
+ restart:
+ list_for_each_entry(state, &sp->so_states, open_states) {
+ if (!test_and_clear_bit(ops->state_flag_bit, &state->flags))
+@@ -1672,14 +1676,20 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
+ spin_lock(&sp->so_lock);
+ goto restart;
+ }
+- raw_write_seqcount_end(&sp->so_reclaim_seqcount);
+ spin_unlock(&sp->so_lock);
++#ifdef CONFIG_PREEMPT_RT_FULL
++ write_sequnlock(&sp->so_reclaim_seqlock);
++#else
++ write_seqcount_end(&sp->so_reclaim_seqlock.seqcount);
++#endif
+ return 0;
+ out_err:
+ nfs4_put_open_state(state);
+- spin_lock(&sp->so_lock);
+- raw_write_seqcount_end(&sp->so_reclaim_seqcount);
+- spin_unlock(&sp->so_lock);
++#ifdef CONFIG_PREEMPT_RT_FULL
++ write_sequnlock(&sp->so_reclaim_seqlock);
++#else
++ write_seqcount_end(&sp->so_reclaim_seqlock.seqcount);
++#endif
+ return status;
+ }
+
+--
+2.36.1
+