From nobody Sun Apr 5 13:06:21 2026 Received: from e3i468.smtp2go.com (e3i468.smtp2go.com [158.120.85.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C69DE326D75 for ; Tue, 24 Mar 2026 20:13:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=158.120.85.212 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774383239; cv=none; b=dJRDvrGwibZBanVHy+lP/MyrYJv1NkwCl31RFg4M7O4MDHAz9OTwDY7kE508/luOf7l+/opc9U52lI1ZFbS3hBNIZvgyhg9wPV0MCLqzOGnoynA1sYPlpTzyXbrDLaAiBhDWVEBehwTafLRBVkd5Pcn3TqGE0LeRioKkr5DPYhE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774383239; c=relaxed/simple; bh=PpthaMt4M8TfguJcX/ojcJ3Mw1tPeuNFcQca8b9OF5M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LVkNYYZnkcoveXtEUoX6AOuNjdfRaaJtUzu3qtkE2XEeBuu8MtXuBJYUgIV1gonJawYtfE9x4QUbVNt83sB2GEXULsrpBzMEnMHWqMtYHCRk6+ESl39It04BrrLr9BrIFhuI5jE/AH73QNGAmLmP15choQW2aAyb1PPnfZ+G4xU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=triplefau.lt; spf=pass smtp.mailfrom=em510616.triplefau.lt; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b=lJ/oeZkF; arc=none smtp.client-ip=158.120.85.212 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=triplefau.lt Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=em510616.triplefau.lt Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b="lJ/oeZkF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triplefau.lt; i=@triplefau.lt; q=dns/txt; s=s510616; t=1774382620; h=from : subject : to : message-id : date; bh=/mCP6me0zJdgQcjVym3S63MAWyj6d6QBpzdmIIJfV3U=; b=lJ/oeZkF0pNLrxZ/6Zsb1jt6yPac+5KDO2Fw/mUn3jioEMAcCZ7gSix7arDe5bT5aGFCT HqjJntIWgOXLgwz33jpIjPVZV7kdpn3eG5zAJEWMsKv9OF4eP/GFdviYPzDHrGlqrRkoMJE huMw7wjJJgGPZ0FQ6swVd0y1xlBkzvqPyZh30DCyD3kiFJJzHRnIyJC6iJnjZBeCZLXc8BA mq3Kkdl4PAhwfxrsuG8Y/8na+6e1IBHiU51JbbJCsM62YtDB7kAblvujTz6Y1E7Y6f560JH U7F+IdaYfksonlUI5WI9BtCO31XHBWJ1HXxknDJ0djGvUR0y3hKGiZVYmjAg== Received: from [10.12.239.196] (helo=localhost) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.99.1-S2G) (envelope-from ) id 1w57yT-4o5NDgrftkf-lx6o; Tue, 24 Mar 2026 20:03:37 +0000 From: Remi Pommarel To: v9fs@lists.linux.dev Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , Remi Pommarel Subject: [PATCH v4 2/4] 9p: Add mount option for negative dentry cache retention Date: Tue, 24 Mar 2026 20:43:32 +0100 Message-ID: <4f51032ea3329c1a3b7c0f00bb2885e8d104c6c5.1774380535.git.repk@triplefau.lt> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please forward a copy of this message, including all headers, to Feedback-ID: 510616m:510616apGKSTK:510616sgeYS19s-d X-smtpcorp-track: FD-PUSE2tD_s.YE2g1i5LyU5P.hqmKcgf_hgr Content-Type: text/plain; charset="utf-8" Introduce a new mount option, negtimeout, for v9fs that allows users to specify how long negative dentries are retained in the cache. The retention time can be set in milliseconds (e.g. negtimeout=3D10000 for a 10secs retention time) or a negative value (e.g. negtimeout=3D-1) to keep negative entries until the buffer cache management removes them. For consistency reasons, this option should only be used in exclusive or read-only mount scenarios, aligning with the cache=3Dloose usage. Signed-off-by: Remi Pommarel --- Documentation/filesystems/9p.rst | 5 +++++ fs/9p/v9fs.c | 16 +++++++++++++++- fs/9p/v9fs.h | 23 +++++++++++++---------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/Documentation/filesystems/9p.rst b/Documentation/filesystems/9= p.rst index be3504ca034a..b014c7aabba4 100644 --- a/Documentation/filesystems/9p.rst +++ b/Documentation/filesystems/9p.rst @@ -238,6 +238,11 @@ Options cachetag cache tag to use the specified persistent cache. cache tags for existing cache sessions can be listed at /sys/fs/9p/caches. (applies only to cache=3Dfscache) + + negtimeout the duration (in milliseconds) that negative dentries (pat= hs + that do not actually exist) are retained in the cache. If + set to a negative value, those entries are kept indefinite= ly + until evicted by the buffer cache management system =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =20 Behavior diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index c5dca81a553e..f16517be7fc2 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -39,7 +39,7 @@ enum { * source if we rejected it as EINVAL */ Opt_source, /* Options that take integer arguments */ - Opt_debug, Opt_dfltuid, Opt_dfltgid, Opt_afid, + Opt_debug, Opt_dfltuid, Opt_dfltgid, Opt_afid, Opt_negtimeout, /* String options */ Opt_uname, Opt_remotename, Opt_cache, Opt_cachetag, /* Options that take no arguments */ @@ -93,6 +93,7 @@ const struct fs_parameter_spec v9fs_param_spec[] =3D { fsparam_string ("access", Opt_access), fsparam_flag ("posixacl", Opt_posixacl), fsparam_u32 ("locktimeout", Opt_locktimeout), + fsparam_s32 ("negtimeout", Opt_negtimeout), =20 /* client options */ fsparam_u32 ("msize", Opt_msize), @@ -159,6 +160,9 @@ int v9fs_show_options(struct seq_file *m, struct dentry= *root) from_kgid_munged(&init_user_ns, v9ses->dfltgid)); if (v9ses->afid !=3D ~0) seq_printf(m, ",afid=3D%u", v9ses->afid); + if (v9ses->flags & V9FS_NDENTRY_TIMEOUT_SET) + seq_printf(m, ",negtimeout=3D%d", + (int)v9ses->ndentry_timeout_ms); if (strcmp(v9ses->uname, V9FS_DEFUSER) !=3D 0) seq_printf(m, ",uname=3D%s", v9ses->uname); if (strcmp(v9ses->aname, V9FS_DEFANAME) !=3D 0) @@ -337,6 +341,16 @@ int v9fs_parse_param(struct fs_context *fc, struct fs_= parameter *param) session_opts->session_lock_timeout =3D (long)result.uint_32 * HZ; break; =20 + case Opt_negtimeout: + session_opts->flags |=3D V9FS_NDENTRY_TIMEOUT_SET; + if (result.int_32 < 0) { + session_opts->ndentry_timeout_ms =3D + NDENTRY_TIMEOUT_NEVER; + } else { + session_opts->ndentry_timeout_ms =3D result.int_32; + } + break; + /* Options for client */ case Opt_msize: if (result.uint_32 < 4096) { diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index e630c5111d74..32179f64a603 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h @@ -24,6 +24,8 @@ * @V9FS_ACCESS_ANY: use a single attach for all users * @V9FS_ACCESS_MASK: bit mask of different ACCESS options * @V9FS_POSIX_ACL: POSIX ACLs are enforced + * @V9FS_NDENTRY_TIMEOUT_SET: Has negative dentry timeout retention time b= een + * overridden by ndentrycache mount option * * Session flags reflect options selected by users at mount time */ @@ -34,16 +36,17 @@ #define V9FS_ACL_MASK V9FS_POSIX_ACL =20 enum p9_session_flags { - V9FS_PROTO_2000U =3D 0x01, - V9FS_PROTO_2000L =3D 0x02, - V9FS_ACCESS_SINGLE =3D 0x04, - V9FS_ACCESS_USER =3D 0x08, - V9FS_ACCESS_CLIENT =3D 0x10, - V9FS_POSIX_ACL =3D 0x20, - V9FS_NO_XATTR =3D 0x40, - V9FS_IGNORE_QV =3D 0x80, /* ignore qid.version for cache hints */ - V9FS_DIRECT_IO =3D 0x100, - V9FS_SYNC =3D 0x200 + V9FS_PROTO_2000U =3D 0x01, + V9FS_PROTO_2000L =3D 0x02, + V9FS_ACCESS_SINGLE =3D 0x04, + V9FS_ACCESS_USER =3D 0x08, + V9FS_ACCESS_CLIENT =3D 0x10, + V9FS_POSIX_ACL =3D 0x20, + V9FS_NO_XATTR =3D 0x40, + V9FS_IGNORE_QV =3D 0x80, /* ignore qid.version for cache hints = */ + V9FS_DIRECT_IO =3D 0x100, + V9FS_SYNC =3D 0x200, + V9FS_NDENTRY_TIMEOUT_SET =3D 0x400, }; =20 /** --=20 2.52.0