aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/fs/nfsserver/nfs_nfsdkrpc.c3
-rw-r--r--sys/kern/kern_exit.c3
-rw-r--r--sys/kern/kern_thread.c2
-rw-r--r--sys/kern/subr_trap.c6
-rw-r--r--sys/sys/proc.h9
-rw-r--r--sys/sys/systm.h2
-rw-r--r--sys/ufs/ffs/ffs_softdep.c10
7 files changed, 22 insertions, 13 deletions
diff --git a/sys/fs/nfsserver/nfs_nfsdkrpc.c b/sys/fs/nfsserver/nfs_nfsdkrpc.c
index 3c6d0b3ffba7d..fc34969b9596b 100644
--- a/sys/fs/nfsserver/nfs_nfsdkrpc.c
+++ b/sys/fs/nfsserver/nfs_nfsdkrpc.c
@@ -304,8 +304,7 @@ nfssvc_program(struct svc_req *rqst, SVCXPRT *xprt)
svc_freereq(rqst);
out:
- if (softdep_ast_cleanup != NULL)
- softdep_ast_cleanup();
+ td_softdep_cleanup(curthread);
NFSEXITCODE(0);
}
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 3e56ae3bef759..c524fe5df372d 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -207,8 +207,7 @@ exit1(struct thread *td, int rval, int signo)
/*
* Deref SU mp, since the thread does not return to userspace.
*/
- if (softdep_ast_cleanup != NULL)
- softdep_ast_cleanup();
+ td_softdep_cleanup(td);
/*
* MUST abort all other threads before proceeding past here.
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index 0c8365a96ad07..c3763ca2b33c9 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -192,6 +192,8 @@ thread_dtor(void *mem, int size, void *arg)
#endif
/* Free all OSD associated to this thread. */
osd_thread_exit(td);
+ td_softdep_cleanup(td);
+ MPASS(td->td_su == NULL);
EVENTHANDLER_INVOKE(thread_dtor, td);
tid_free(td->td_tid);
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index 14a9e856fed98..d86d5db2ceb72 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -86,7 +86,7 @@ __FBSDID("$FreeBSD$");
#include <security/mac/mac_framework.h>
-void (*softdep_ast_cleanup)(void);
+void (*softdep_ast_cleanup)(struct thread *);
/*
* Define the code needed before returning to user mode, for trap and
@@ -128,8 +128,8 @@ userret(struct thread *td, struct trapframe *frame)
#ifdef KTRACE
KTRUSERRET(td);
#endif
- if (softdep_ast_cleanup != NULL)
- softdep_ast_cleanup();
+ td_softdep_cleanup(td);
+ MPASS(td->td_su == NULL);
/*
* If this thread tickled GEOM, we need to wait for the giggling to
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index da2a87a2ca34c..210cb30f85dbd 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1114,6 +1114,15 @@ td_get_sched(struct thread *td)
return ((struct td_sched *)&td[1]);
}
+extern void (*softdep_ast_cleanup)(struct thread *);
+static __inline void
+td_softdep_cleanup(struct thread *td)
+{
+
+ if (td->td_su != NULL && softdep_ast_cleanup != NULL)
+ softdep_ast_cleanup(td);
+}
+
#endif /* _KERNEL */
#endif /* !_SYS_PROC_H_ */
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index d9b5c14940827..721bbd1a6077d 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -452,8 +452,6 @@ void free_unr(struct unrhdr *uh, u_int item);
void intr_prof_stack_use(struct thread *td, struct trapframe *frame);
-extern void (*softdep_ast_cleanup)(void);
-
void counted_warning(unsigned *counter, const char *msg);
__NULLABILITY_PRAGMA_POP
diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index ea0242d03e80f..be7f00680677e 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -902,7 +902,7 @@ static int pagedep_find(struct pagedep_hashhead *, ino_t, ufs_lbn_t,
static void pause_timer(void *);
static int request_cleanup(struct mount *, int);
static void schedule_cleanup(struct mount *);
-static void softdep_ast_cleanup_proc(void);
+static void softdep_ast_cleanup_proc(struct thread *);
static int process_worklist_item(struct mount *, int, int);
static void process_removes(struct vnode *);
static void process_truncates(struct vnode *);
@@ -13445,15 +13445,13 @@ schedule_cleanup(struct mount *mp)
}
static void
-softdep_ast_cleanup_proc(void)
+softdep_ast_cleanup_proc(struct thread *td)
{
- struct thread *td;
struct mount *mp;
struct ufsmount *ump;
int error;
bool req;
- td = curthread;
while ((mp = td->td_su) != NULL) {
td->td_su = NULL;
error = vfs_busy(mp, MBF_NOWAIT);
@@ -13491,6 +13489,10 @@ softdep_ast_cleanup_proc(void)
}
vfs_unbusy(mp);
}
+ if ((mp = td->td_su) != NULL) {
+ td->td_su = NULL;
+ vfs_rel(mp);
+ }
}
/*