From bdd6b77e1fbecf07a793c4d4e59337f4239c8b7a Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Thu, 6 Dec 2018 01:04:56 +0000 Subject: [PATCH] If the vfs.ffs.dotrimcons sysctl option is enabled while a file deletion is active, specifically after a call to ffs_blkrelease_start() but before the call to ffs_blkrelease_finish(), ffs_blkrelease_start() will have handed out SINGLETON_KEY rather than starting a collection sequence. Thus if we get a SINGLETON_KEY passed to ffs_blkrelease_finish(), we just return rather than trying to finish the nonexistent sequence. Reported by: Warner Losh (imp@) Sponsored by: Netflix --- sys/ufs/ffs/ffs_alloc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index e82605af09e..cb2205bd4aa 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -2536,6 +2536,23 @@ ffs_blkrelease_finish(ump, key) if (((ump->um_flags & UM_CANDELETE) == 0) || dotrimcons == 0) return; + /* + * If the vfs.ffs.dotrimcons sysctl option is enabled while + * a file deletion is active, specifically after a call + * to ffs_blkrelease_start() but before the call to + * ffs_blkrelease_finish(), ffs_blkrelease_start() will + * have handed out SINGLETON_KEY rather than starting a + * collection sequence. Thus if we get a SINGLETON_KEY + * passed to ffs_blkrelease_finish(), we just return rather + * than trying to finish the nonexistent sequence. + */ + if (key == SINGLETON_KEY) { +#ifdef INVARIANTS + printf("%s: vfs.ffs.dotrimcons enabled on active filesystem\n", + ump->um_mountp->mnt_stat.f_mntonname); +#endif + return; + } /* * We are done with sending blocks using this key. Look up the key * using the DONE alloctype (in tp) to request that it be unhashed