From nobody Fri Oct 3 12:12:11 2025 Received: from e2i440.smtp2go.com (e2i440.smtp2go.com [103.2.141.184]) (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 7029A1DF252 for ; Sun, 31 Aug 2025 19:18:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.2.141.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756667892; cv=none; b=m6GeYn85IlWGgk8o6lyHVL9hozVBWHiJ1pul6zGb45+3pmZUzVlu+pBJz3K+pngao+HHSnxqtopF8vYJ8iSe207r+iw7ZGQyZCBcPB+5kCmiIqAz1UZUzQVXTg5UsyTHLFoqUoUt78rUDWUHDsfGSnhMgIH6vJ2lY50E/emoA1s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756667892; c=relaxed/simple; bh=7Y5KqttihI+r+eIyOPXHXseKUiV7iTVerANDkbrxnys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uw4TQI0q2IZB6k695DbUWtguRquqx3DXYOLhNWBETvlV1lBYqFD1eflfntHIWtIo2thG75OEWYgkiE/hvMvDVKNV5S+HWvuBperGeB6FLy3H9pdbbRPJ6ltW35KX1t/GTwPXxbRY7miDe6o3Jixjo/Lx3YcYV8OnZdvU4g6n2dg= 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=fail (0-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b=sUr156Rk reason="unknown key version"; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b=aO4HUeH3; arc=none smtp.client-ip=103.2.141.184 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=fail reason="unknown key version" (0-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b="sUr156Rk"; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b="aO4HUeH3" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=maxzs0.a1-4.dyn; x=1756668790; h=Feedback-ID: X-Smtpcorp-Track:Message-ID:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe:List-Unsubscribe-Post; bh=+gS5MCHjHXroUzVHejQaS9odp4wq+hOBaBf9jbC5Dyw=; b=sUr156Rk9pNfzrZP9hgHMC63tk RiLPhXpc6jYxXFBvZTsMxQuUipS9OAEU1L5QfqglBaS1MYgporkvD8Qg8k4OGUFjpAOTE+Wtgeq8D h7BeWaSdRxzXMvzQAzzO8DQmuTrLAYDhLrz0DIHrOSmwTGIlPl4Snk1j3y+zew0N2r1eic0BaQx3I IWiVyf2Pln7++BjzNoM71vocvRtYuL/BCbeBtwmFSgJKDGaXN45hFaG/LzVYfwbUx1CRkcAQW91s9 bsL7fRwmcW3e9STk2jHHqm676bnoz4KfLzGb15qrBRu68oW40Ku7+br8Ta/XoY1PJlus2Uadvv1ct xHwyClrA==; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triplefau.lt; i=@triplefau.lt; q=dns/txt; s=s510616; t=1756667890; h=from : subject : to : message-id : date; bh=+gS5MCHjHXroUzVHejQaS9odp4wq+hOBaBf9jbC5Dyw=; b=aO4HUeH37ycwAAmaWKufGdS9AmqhkVR29ygvH6UAdh3FsI2qR58aCtqoeelewza1JOh1O mBwstb32gBJqdTTODwvRD/hdKbI0lTlLGBqsHtcqURW+lGm+i7ioisgrTglfpIGobDORKSY 7MwR5uMMAHzGKGQsm0/fABcjCtGWxCKniNYfg0YPkgdfz65tkOW7asNWHC2ic9xLksN1s6S DdYNKPHXuWqVUYT9TPwZawcfOU3zDSwbFIG8HkHxddyGe5ghXq/5pvGUEkpVSfHds9Zgwpn DQ61PKBH6z+MG/luI2XBduNHarWBxEXSgxMFjMhXf8gGipAYwqhWcBHhdAeA== Received: from [10.139.162.187] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2-S2G) (envelope-from ) id 1usnYq-TRk4FT-AD; Sun, 31 Aug 2025 19:17:56 +0000 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.98.1-S2G) (envelope-from ) id 1usnYq-4o5NDgrhYf4-kAZD; Sun, 31 Aug 2025 19:17:56 +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: [RFC PATCH 1/5] 9p: Cache negative dentries for lookup performance Date: Sun, 31 Aug 2025 21:03:39 +0200 Message-ID: <0bd395b21e556734ce242d55e1fbf5b4bc0936ac.1756635044.git.repk@triplefau.lt> X-Mailer: git-send-email 2.50.1 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-Smtpcorp-Track: SSMWBs9zgejO.aum2NN7troby.wbIFlwVDXMd Feedback-ID: 510616m:510616apGKSTK:510616sgLZ4k01cp X-Report-Abuse: Please forward a copy of this message, including all headers, to Content-Type: text/plain; charset="utf-8" Not caching negative dentries can result in poor performance for workloads that repeatedly look up non-existent paths. Each such lookup triggers a full 9P transaction with the server, adding unnecessary overhead. A typical example is source compilation, where multiple cc1 processes are spawned and repeatedly search for the same missing header files over and over again. This change enables caching of negative dentries, so that lookups for known non-existent paths do not require a full 9P transaction. The cached negative dentries are retained for a configurable duration (expressed in milliseconds), as specified by the ndentry_timeout field in struct v9fs_session_info. If set to -1, negative dentries are cached indefinitely. This optimization reduces lookup overhead and improves performance for workloads involving frequent access to non-existent paths. Signed-off-by: Remi Pommarel --- fs/9p/fid.c | 11 ++--- fs/9p/v9fs.c | 1 + fs/9p/v9fs.h | 2 + fs/9p/v9fs_vfs.h | 15 +++++++ fs/9p/vfs_dentry.c | 109 +++++++++++++++++++++++++++++++++++++++------ fs/9p/vfs_inode.c | 7 +-- 6 files changed, 123 insertions(+), 22 deletions(-) diff --git a/fs/9p/fid.c b/fs/9p/fid.c index f84412290a30..76242d450aa7 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c @@ -20,7 +20,9 @@ =20 static inline void __add_fid(struct dentry *dentry, struct p9_fid *fid) { - hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata); + struct v9fs_dentry *v9fs_dentry =3D to_v9fs_dentry(dentry); + + hlist_add_head(&fid->dlist, &v9fs_dentry->head); } =20 =20 @@ -112,6 +114,7 @@ void v9fs_open_fid_add(struct inode *inode, struct p9_f= id **pfid) =20 static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int= any) { + struct v9fs_dentry *v9fs_dentry =3D to_v9fs_dentry(dentry); struct p9_fid *fid, *ret; =20 p9_debug(P9_DEBUG_VFS, " dentry: %pd (%p) uid %d any %d\n", @@ -119,11 +122,9 @@ static struct p9_fid *v9fs_fid_find(struct dentry *den= try, kuid_t uid, int any) any); ret =3D NULL; /* we'll recheck under lock if there's anything to look in */ - if (dentry->d_fsdata) { - struct hlist_head *h =3D (struct hlist_head *)&dentry->d_fsdata; - + if (!hlist_empty(&v9fs_dentry->head)) { spin_lock(&dentry->d_lock); - hlist_for_each_entry(fid, h, dlist) { + hlist_for_each_entry(fid, &v9fs_dentry->head, dlist) { if (any || uid_eq(fid->uid, uid)) { ret =3D fid; p9_fid_get(ret); diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 77e9c4387c1d..422bd720d165 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -171,6 +171,7 @@ static int v9fs_parse_options(struct v9fs_session_info = *v9ses, char *opts) =20 /* setup defaults */ v9ses->afid =3D ~0; + v9ses->ndentry_timeout =3D 0; v9ses->debug =3D 0; v9ses->cache =3D CACHE_NONE; #ifdef CONFIG_9P_FSCACHE diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index f28bc763847a..8c5fa0f7ba71 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h @@ -88,6 +88,7 @@ enum p9_cache_bits { * @debug: debug level * @afid: authentication handle * @cache: cache mode of type &p9_cache_bits + * @ndentry_timeout: Negative dentry lookup cache retention time in ms * @cachetag: the tag of the cache associated with this session * @fscache: session cookie associated with FS-Cache * @uname: string user name to mount hierarchy as @@ -113,6 +114,7 @@ struct v9fs_session_info { unsigned short debug; unsigned int afid; unsigned int cache; + unsigned int ndentry_timeout; #ifdef CONFIG_9P_FSCACHE char *cachetag; struct fscache_volume *fscache; diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index d3aefbec4de6..7e6e8881081c 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h @@ -28,6 +28,19 @@ /* flags for v9fs_stat2inode() & v9fs_stat2inode_dotl() */ #define V9FS_STAT2INODE_KEEP_ISIZE 1 =20 +/** + * struct v9fs_dentry - v9fs specific dentry data + * @head: List of fid associated with this dentry + * @expire_time: Lookup cache expiration time for negative dentries + * @rcu: used by kfree_rcu to schedule clean up job + */ +struct v9fs_dentry { + struct hlist_head head; + u64 expire_time; + struct rcu_head rcu; +}; +#define to_v9fs_dentry(d) ((struct v9fs_dentry *)((d)->d_fsdata)) + extern struct file_system_type v9fs_fs_type; extern const struct address_space_operations v9fs_addr_operations; extern const struct file_operations v9fs_file_operations; @@ -35,6 +48,8 @@ extern const struct file_operations v9fs_file_operations_= dotl; extern const struct file_operations v9fs_dir_operations; extern const struct file_operations v9fs_dir_operations_dotl; extern const struct dentry_operations v9fs_dentry_operations; +extern void v9fs_dentry_refresh(struct dentry *dentry); +extern void v9fs_dentry_fid_remove(struct dentry *dentry); extern const struct dentry_operations v9fs_cached_dentry_operations; extern struct kmem_cache *v9fs_inode_cache; =20 diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c index 04795508a795..5035b8c749e2 100644 --- a/fs/9p/vfs_dentry.c +++ b/fs/9p/vfs_dentry.c @@ -23,6 +23,46 @@ #include "v9fs_vfs.h" #include "fid.h" =20 +/** + * v9fs_dentry_is_expired - Check if dentry lookup has expired + * + * This should be called to know if a negative dentry should be removed fr= om + * cache. + * + * @dentry: dentry in question + * + */ +static bool v9fs_dentry_is_expired(struct dentry const *dentry) +{ + struct v9fs_session_info *v9ses =3D v9fs_dentry2v9ses(dentry); + struct v9fs_dentry *v9fs_dentry =3D to_v9fs_dentry(dentry); + + if (v9ses->ndentry_timeout =3D=3D -1) + return false; + + return time_before_eq64(v9fs_dentry->expire_time, get_jiffies_64()); +} + +/** + * v9fs_dentry_refresh - Refresh dentry lookup cache timeout + * + * This should be called when a look up yields a negative entry. + * + * @dentry: dentry in question + * + */ +void v9fs_dentry_refresh(struct dentry *dentry) +{ + struct v9fs_session_info *v9ses =3D v9fs_dentry2v9ses(dentry); + struct v9fs_dentry *v9fs_dentry =3D to_v9fs_dentry(dentry); + + if (v9ses->ndentry_timeout =3D=3D -1) + return; + + v9fs_dentry->expire_time =3D get_jiffies_64() + + msecs_to_jiffies(v9ses->ndentry_timeout); +} + /** * v9fs_cached_dentry_delete - called when dentry refcount equals 0 * @dentry: dentry in question @@ -33,20 +73,15 @@ static int v9fs_cached_dentry_delete(const struct dentr= y *dentry) p9_debug(P9_DEBUG_VFS, " dentry: %pd (%p)\n", dentry, dentry); =20 - /* Don't cache negative dentries */ - if (d_really_is_negative(dentry)) - return 1; - return 0; -} + if (!d_really_is_negative(dentry)) + return 0; =20 -/** - * v9fs_dentry_release - called when dentry is going to be freed - * @dentry: dentry that is being release - * - */ + return v9fs_dentry_is_expired(dentry); +} =20 -static void v9fs_dentry_release(struct dentry *dentry) +static void __v9fs_dentry_fid_remove(struct dentry *dentry) { + struct v9fs_dentry *v9fs_dentry =3D to_v9fs_dentry(dentry); struct hlist_node *p, *n; struct hlist_head head; =20 @@ -54,15 +89,57 @@ static void v9fs_dentry_release(struct dentry *dentry) dentry, dentry); =20 spin_lock(&dentry->d_lock); - hlist_move_list((struct hlist_head *)&dentry->d_fsdata, &head); + hlist_move_list(&v9fs_dentry->head, &head); spin_unlock(&dentry->d_lock); =20 hlist_for_each_safe(p, n, &head) p9_fid_put(hlist_entry(p, struct p9_fid, dlist)); } =20 +/** + * v9fs_dentry_fid_remove - Release all dentry's fid + * @dentry: dentry in question + * + */ +void v9fs_dentry_fid_remove(struct dentry *dentry) +{ + __v9fs_dentry_fid_remove(dentry); +} + +/** + * v9fs_dentry_init - Initialize v9fs dentry data + * @dentry: dentry in question + * + */ +static int v9fs_dentry_init(struct dentry *dentry) +{ + struct v9fs_dentry *v9fs_dentry =3D kzalloc(sizeof(*v9fs_dentry), + GFP_KERNEL); + + if (!v9fs_dentry) + return -ENOMEM; + + INIT_HLIST_HEAD(&v9fs_dentry->head); + dentry->d_fsdata =3D (void *)v9fs_dentry; + return 0; +} + +/** + * v9fs_dentry_release - called when dentry is going to be freed + * @dentry: dentry that is being release + * + */ +static void v9fs_dentry_release(struct dentry *dentry) +{ + struct v9fs_dentry *v9fs_dentry =3D to_v9fs_dentry(dentry); + + __v9fs_dentry_fid_remove(dentry); + kfree_rcu(v9fs_dentry, rcu); +} + static int __v9fs_lookup_revalidate(struct dentry *dentry, unsigned int fl= ags) { + struct v9fs_session_info *v9ses; struct p9_fid *fid; struct inode *inode; struct v9fs_inode *v9inode; @@ -70,9 +147,11 @@ static int __v9fs_lookup_revalidate(struct dentry *dent= ry, unsigned int flags) if (flags & LOOKUP_RCU) return -ECHILD; =20 + v9ses =3D v9fs_dentry2v9ses(dentry); + inode =3D d_inode(dentry); if (!inode) - goto out_valid; + return !v9fs_dentry_is_expired(dentry); =20 v9inode =3D V9FS_I(inode); if (v9inode->cache_validity & V9FS_INO_INVALID_ATTR) { @@ -95,7 +174,7 @@ static int __v9fs_lookup_revalidate(struct dentry *dentr= y, unsigned int flags) if (retval < 0) return retval; } -out_valid: + return 1; } =20 @@ -121,12 +200,14 @@ const struct dentry_operations v9fs_cached_dentry_ope= rations =3D { .d_revalidate =3D v9fs_lookup_revalidate, .d_weak_revalidate =3D __v9fs_lookup_revalidate, .d_delete =3D v9fs_cached_dentry_delete, + .d_init =3D v9fs_dentry_init, .d_release =3D v9fs_dentry_release, .d_unalias_trylock =3D v9fs_dentry_unalias_trylock, .d_unalias_unlock =3D v9fs_dentry_unalias_unlock, }; =20 const struct dentry_operations v9fs_dentry_operations =3D { + .d_init =3D v9fs_dentry_init, .d_release =3D v9fs_dentry_release, .d_unalias_trylock =3D v9fs_dentry_unalias_trylock, .d_unalias_unlock =3D v9fs_dentry_unalias_unlock, diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 399d455d50d6..89eeb2b3ba43 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -549,7 +549,7 @@ static int v9fs_remove(struct inode *dir, struct dentry= *dentry, int flags) =20 /* invalidate all fids associated with dentry */ /* NOTE: This will not include open fids */ - dentry->d_op->d_release(dentry); + v9fs_dentry_fid_remove(dentry); } return retval; } @@ -732,9 +732,10 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, stru= ct dentry *dentry, name =3D dentry->d_name.name; fid =3D p9_client_walk(dfid, 1, &name, 1); p9_fid_put(dfid); - if (fid =3D=3D ERR_PTR(-ENOENT)) + if (fid =3D=3D ERR_PTR(-ENOENT)) { inode =3D NULL; - else if (IS_ERR(fid)) + v9fs_dentry_refresh(dentry); + } else if (IS_ERR(fid)) inode =3D ERR_CAST(fid); else if (v9ses->cache & (CACHE_META|CACHE_LOOSE)) inode =3D v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); --=20 2.50.1 From nobody Fri Oct 3 12:12:11 2025 Received: from e2i440.smtp2go.com (e2i440.smtp2go.com [103.2.141.184]) (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 A9B7E2765C0 for ; Sun, 31 Aug 2025 19:18:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.2.141.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756667892; cv=none; b=t2P/48MPEKjBkfOtNJbepb8V+Az7xhJ+kMsa9ekgzsw6VZ+m9VVaBYrC3croxx+mo6a6nwT3MgVleE25mCImWEaa4bsjpkdk0PrJc06XFJmsDSIZOskcI2xo1LVisyk3fBYzojfzTSaB5d1c07EQvqpC3o7WaGVZqZbzc6PyXX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756667892; c=relaxed/simple; bh=DRcLIFuIOSuESQ2ofaXfG+0PDFNlbm73jo++sagk/94=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gwg2jA+vjMJJ8oogt70uGxn9UZhmyVGZ6/buv19UfFKe+Z5pZymn00G1gWVlLnfHOc2QGQEFLLTMPw/e27hb0Y8kRt9wNYwtJI4xuRlmk2UTeTmUrSe2NknmZd6ZkRIwV1ArE13sw6nKLQKSRSJr2VvWvRBN6BJMrs2q0maLtOg= 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=fail (0-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b=YmlUHOWC reason="unknown key version"; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b=cldfSgBU; arc=none smtp.client-ip=103.2.141.184 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=fail reason="unknown key version" (0-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b="YmlUHOWC"; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b="cldfSgBU" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=maxzs0.a1-4.dyn; x=1756668790; h=Feedback-ID: X-Smtpcorp-Track:Message-ID:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe:List-Unsubscribe-Post; bh=yB6pbMXYcls8l8+6f9uwrMKHsQgjD3KAY1Ts8L0/mj4=; b=YmlUHOWCN8SnHhfnMU6+3okeiK xFxC5SIjzF6HOjD8w6vkrNs/attasnfylrL7MaJbxt8+d7fZnsJOlBhjN7w6vpPzNq3WBxz0ELUsK BD/cvsBHYl6h2ghoHUnQoTMsjhEU7DMqdp1FAYtqMrQDvLxJX0gO7dgwkT7bWMPQLVYxMvXfvBj11 CBysuEan6L6zDgDi+ZhjkQmfz9meOeGbdgA0Xf8mla9i8Sb+MH/yb9227cxoxBWd7b+5meHKUtmwf HPZO4PSw5e+jQknXklAbVRXdLgjEy3cdCJq0HeZPWJIaDCJnAFZsXq9kp8dL4Jg0X3ha1I8bYmo0u TXbMFxSw==; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triplefau.lt; i=@triplefau.lt; q=dns/txt; s=s510616; t=1756667890; h=from : subject : to : message-id : date; bh=yB6pbMXYcls8l8+6f9uwrMKHsQgjD3KAY1Ts8L0/mj4=; b=cldfSgBUC0YITv0FHUzkYCSarjbeju/L7WKk/RKlqfmxSlIpjn4rGlm+xhSb5j+Mb5ZW+ O1WTPoNoklxK5Ci+BAKeJ8x8ZAdi0/norXnHKxgeayPgV72Eiz6doGoPA1JScFlRm71Requ VGu4haCfI9oedw3Poy+ikT16k25bIQGht1rT4MN3OEwWD12I4YEjFIMsY1hyIjdNEXB0x62 HBc7cdwj4CdKt5g8EUuZRy4o2JcXpnml46XbVlmRoG6HKf9rMDN+2oody0LdLBtF5kyEcd3 CIYMqOWnBui45PRyrGXgUvH8CWj7PMuaJRrm9sx0pGguzddumXpnbGgZuoGw== Received: from [10.172.233.45] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2-S2G) (envelope-from ) id 1usnYr-TRk4Kv-5d; Sun, 31 Aug 2025 19:17:57 +0000 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.98.1-S2G) (envelope-from ) id 1usnYq-AIkwcC8vNym-KDcR; Sun, 31 Aug 2025 19:17:56 +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: [RFC PATCH 2/5] 9p: Introduce option for negative dentry cache retention time Date: Sun, 31 Aug 2025 21:03:40 +0200 Message-ID: <18f109c2d62d0529511957f3c2a492374d01e63d.1756635044.git.repk@triplefau.lt> X-Mailer: git-send-email 2.50.1 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-Smtpcorp-Track: -IKmwD02fNdQ.ewGxnBPR3Vb2.IIQE8QEqUj5 Feedback-ID: 510616m:510616apGKSTK:510616sJVlOeeiTz X-Report-Abuse: Please forward a copy of this message, including all headers, to Content-Type: text/plain; charset="utf-8" Add support for a new mount option in v9fs that allows users to specify the duration for which negative dentries are retained in the cache. The retention time can be set in milliseconds using the ndentrytmo option. For the same 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 --- fs/9p/v9fs.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 422bd720d165..7c0c2201b151 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -34,7 +34,7 @@ struct kmem_cache *v9fs_inode_cache; =20 enum { /* Options that take integer arguments */ - Opt_debug, Opt_dfltuid, Opt_dfltgid, Opt_afid, + Opt_debug, Opt_dfltuid, Opt_dfltgid, Opt_afid, Opt_ndentrytmo, /* String options */ Opt_uname, Opt_remotename, Opt_cache, Opt_cachetag, /* Options that take no arguments */ @@ -52,6 +52,7 @@ static const match_table_t tokens =3D { {Opt_dfltuid, "dfltuid=3D%u"}, {Opt_dfltgid, "dfltgid=3D%u"}, {Opt_afid, "afid=3D%u"}, + {Opt_ndentrytmo, "ndentrytmo=3D%d"}, {Opt_uname, "uname=3D%s"}, {Opt_remotename, "aname=3D%s"}, {Opt_nodevmap, "nodevmap"}, @@ -110,6 +111,8 @@ 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->ndentry_timeout !=3D 0) + seq_printf(m, ",ndentrytmo=3D%d", v9ses->ndentry_timeout); if (strcmp(v9ses->uname, V9FS_DEFUSER) !=3D 0) seq_printf(m, ",uname=3D%s", v9ses->uname); if (strcmp(v9ses->aname, V9FS_DEFANAME) !=3D 0) @@ -251,6 +254,16 @@ static int v9fs_parse_options(struct v9fs_session_info= *v9ses, char *opts) v9ses->afid =3D option; } break; + case Opt_ndentrytmo: + r =3D match_int(&args[0], &option); + if (r < 0) { + p9_debug(P9_DEBUG_ERROR, + "integer field, but no integer?\n"); + ret =3D r; + } else { + v9ses->ndentry_timeout =3D option; + } + break; case Opt_uname: kfree(v9ses->uname); v9ses->uname =3D match_strdup(&args[0]); --=20 2.50.1 From nobody Fri Oct 3 12:12:11 2025 Received: from e2i440.smtp2go.com (e2i440.smtp2go.com [103.2.141.184]) (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 0A59A2765CF for ; Sun, 31 Aug 2025 19:18:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.2.141.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756667892; cv=none; b=PhcTEGLkmcTSf/LakQOp4QITwDB/UZCCwOWThGmFoV1jtMe3ldsgtDL5JeEV5ughuY2ETtQ3eoiI8WIWf+8rEcQ0HWqRgAJMektl3MtIFZPhy8JTjt+PRVaNiorZPnz5hP7yYNKitrIyLGY4dXr5/vNeLidKLrfOiwJWQ3EPKIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756667892; c=relaxed/simple; bh=noS+kgMmxX8muhCHIL4ebldoM9H0GvBRTQfjg8aEObA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rAChl0hcZ0TZW3S1uvWwuRAXkbUJ6qxZPBcgKa/Zrd+kOo/HmjPMPt+OXK236ubkuv5RCgyUESR0He5lGrttb9jyX9IPCq70M6Jxbb+0qUfkZ58Qr/qkw6QAf26clJptOkf2z6/MAa2eRZomzj8a9mhS8U/RPg1LfyIyjiKrcj8= 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=fail (0-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b=FcU/8u0a reason="unknown key version"; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b=c9+p4grr; arc=none smtp.client-ip=103.2.141.184 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=fail reason="unknown key version" (0-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b="FcU/8u0a"; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b="c9+p4grr" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=maxzs0.a1-4.dyn; x=1756668791; h=Feedback-ID: X-Smtpcorp-Track:Message-ID:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe:List-Unsubscribe-Post; bh=AuxgjfyP3UBc+gUkj22v5jGjbDAYXrisj6AZ7faAvo0=; b=FcU/8u0aZ0W+pP0GusvL8AEkby YJ/oHjwj2LfRFUziqkfE+TW1ygVcd4BF9bQOEW8zRRcctBs3qaA6EXJyeefgFyQv0gVWeh4imGq8I MktFq24f8W7FaC5SCHuYChPp4C7qy1YJywXINsvW5bylhnxkzBBG04tKfDnnqhQrZxD2O87sLzVgl Cu7r20vWtR/CRsnW9V7HdoFbQQJKCq0hYN4SCVjHboJsjAEOmkFpzTOEl1Bkgppq66XhSaby7kBb/ LbllkLhjI9o37XxVo7+/9ab+y11DdFNjhw2QfxnF2zMFqnitpY4lZDxcZVoz8rc6/zT8rGVCrNBbn ArcxFECg==; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triplefau.lt; i=@triplefau.lt; q=dns/txt; s=s510616; t=1756667891; h=from : subject : to : message-id : date; bh=AuxgjfyP3UBc+gUkj22v5jGjbDAYXrisj6AZ7faAvo0=; b=c9+p4grrbRcdJnzc9JygixYE576mkZqwl5b2ZqlaUh1ZR3RNddNLLvWKtefhxQ7AmC3LB UfZoO52ugcq41slaufFmduw02ls8O3U2g1TdJ9hx0PNfFiGB75vesfLqUYjfI3zIuA3j+FH MsqLf9YsDn+Hz9q3kBIqeuQ0gkwevsbnZ+nez93q72IhYGlSkhaErTInv/IrMiNQYRbWvvi MTNJZ5JqWrumbgWRtmI7PKSWiTvmr+E8MfdRNE2pQqKt6dzsNvVAegaQCURVCUIJjMwPrYt M0soPseBcDR9XeTDhlmamxV3Qzac8CyOmGq+gAL5l4GlTWgtBmNMK6UqDzyQ== Received: from [10.172.233.58] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2-S2G) (envelope-from ) id 1usnYs-TRk4P7-3h; Sun, 31 Aug 2025 19:17:58 +0000 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.98.1-S2G) (envelope-from ) id 1usnYr-FnQW0hPx3P7-nSON; Sun, 31 Aug 2025 19:17:57 +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: [RFC PATCH 3/5] 9p: Enable symlink caching in page cache Date: Sun, 31 Aug 2025 21:03:41 +0200 Message-ID: <52e0e743e006801cb4bcf8322e80704964cf6e25.1756635044.git.repk@triplefau.lt> X-Mailer: git-send-email 2.50.1 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-Smtpcorp-Track: 2M6nbK3eKMXE.uJVbJ8JZOjW4.GMVGSgDBV1N Feedback-ID: 510616m:510616apGKSTK:510616sApJDVklct X-Report-Abuse: Please forward a copy of this message, including all headers, to Content-Type: text/plain; charset="utf-8" Currently, when cache=3Dloose is enabled, file reads are cached in the page cache, but symlink reads are not. This patch allows the results of p9_client_readlink() to be stored in the page cache, eliminating the need for repeated 9P transactions on subsequent symlink accesses. This change improves performance for workloads that involve frequent symlink resolution. Signed-off-by: Remi Pommarel --- fs/9p/v9fs.h | 1 + fs/9p/vfs_inode.c | 7 +++- fs/9p/vfs_inode_dotl.c | 94 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 90 insertions(+), 12 deletions(-) diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index 8c5fa0f7ba71..f48a85b610e3 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h @@ -186,6 +186,7 @@ extern struct inode *v9fs_inode_from_fid(struct v9fs_se= ssion_info *v9ses, struct super_block *sb, int new); extern const struct inode_operations v9fs_dir_inode_operations_dotl; extern const struct inode_operations v9fs_file_inode_operations_dotl; +extern const struct address_space_operations v9fs_symlink_aops_dotl; extern const struct inode_operations v9fs_symlink_inode_operations_dotl; extern const struct netfs_request_ops v9fs_req_ops; extern struct inode *v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9= ses, diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 89eeb2b3ba43..362e39b3e7eb 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -302,10 +302,13 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses, goto error; } =20 - if (v9fs_proto_dotl(v9ses)) + if (v9fs_proto_dotl(v9ses)) { inode->i_op =3D &v9fs_symlink_inode_operations_dotl; - else + inode->i_mapping->a_ops =3D &v9fs_symlink_aops_dotl; + inode_nohighmem(inode); + } else { inode->i_op =3D &v9fs_symlink_inode_operations; + } =20 break; case S_IFDIR: diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 5b5fda617b80..2e2119be1d49 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -126,8 +126,10 @@ static struct inode *v9fs_qid_iget_dotl(struct super_b= lock *sb, goto error; =20 v9fs_stat2inode_dotl(st, inode, 0); - v9fs_set_netfs_context(inode); - v9fs_cache_inode_get_cookie(inode); + if (inode->i_mapping->a_ops =3D=3D &v9fs_addr_operations) { + v9fs_set_netfs_context(inode); + v9fs_cache_inode_get_cookie(inode); + } retval =3D v9fs_get_acl(inode, fid); if (retval) goto error; @@ -858,24 +860,23 @@ v9fs_vfs_mknod_dotl(struct mnt_idmap *idmap, struct i= node *dir, } =20 /** - * v9fs_vfs_get_link_dotl - follow a symlink path + * v9fs_vfs_get_link_nocache_dotl - Resolve a symlink directly. + * + * To be used when symlink caching is not enabled. + * * @dentry: dentry for symlink * @inode: inode for symlink * @done: destructor for return value */ - static const char * -v9fs_vfs_get_link_dotl(struct dentry *dentry, - struct inode *inode, - struct delayed_call *done) +v9fs_vfs_get_link_nocache_dotl(struct dentry *dentry, + struct inode *inode, + struct delayed_call *done) { struct p9_fid *fid; char *target; int retval; =20 - if (!dentry) - return ERR_PTR(-ECHILD); - p9_debug(P9_DEBUG_VFS, "%pd\n", dentry); =20 fid =3D v9fs_fid_lookup(dentry); @@ -889,6 +890,75 @@ v9fs_vfs_get_link_dotl(struct dentry *dentry, return target; } =20 +/** + * v9fs_symlink_read_folio_dotl - Fetch a symlink path and store it in buf= fer + * cache. + * @file: file associated to symlink (NULL) + * @folio: folio where to store the symlink resolve result + */ +static int v9fs_symlink_read_folio_dotl(struct file *file, + struct folio *folio) +{ + struct inode *inode =3D folio->mapping->host; + struct dentry *dentry; + struct p9_fid *fid; + char *target; + size_t len; + int ret =3D -EIO; + + /* Does not expect symlink inode to have a fid as it as not been + * opened> + */ + dentry =3D d_find_alias(inode); + if (!dentry) + goto out; + + fid =3D v9fs_fid_lookup(dentry); + dput(dentry); + if (IS_ERR(fid)) { + ret =3D PTR_ERR(fid); + goto out; + } + + ret =3D p9_client_readlink(fid, &target); + p9_fid_put(fid); + if (ret) + goto out; + + len =3D strnlen(target, PAGE_SIZE - 1); + target[len] =3D '\0'; + memcpy_to_folio(folio, 0, target, len); + kfree(target); + + ret =3D 0; +out: + folio_end_read(folio, ret =3D=3D 0); + return ret; +} + +/** + * v9fs_vfs_get_link_dotl - follow a symlink path + * @dentry: dentry for symlink + * @inode: inode for symlink + * @done: destructor for return value + */ +static const char * +v9fs_vfs_get_link_dotl(struct dentry *dentry, + struct inode *inode, + struct delayed_call *done) +{ + struct v9fs_session_info *v9ses; + + if (!dentry) + return ERR_PTR(-ECHILD); + + v9ses =3D v9fs_inode2v9ses(inode); + if (v9ses->cache & (CACHE_META|CACHE_LOOSE)) + return page_get_link(dentry, inode, done); + + return v9fs_vfs_get_link_nocache_dotl(dentry, inode, done); +} + int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode) { struct p9_stat_dotl *st; @@ -945,6 +1015,10 @@ const struct inode_operations v9fs_file_inode_operati= ons_dotl =3D { .set_acl =3D v9fs_iop_set_acl, }; =20 +const struct address_space_operations v9fs_symlink_aops_dotl =3D { + .read_folio =3D v9fs_symlink_read_folio_dotl, +}; + const struct inode_operations v9fs_symlink_inode_operations_dotl =3D { .get_link =3D v9fs_vfs_get_link_dotl, .getattr =3D v9fs_vfs_getattr_dotl, --=20 2.50.1 From nobody Fri Oct 3 12:12:11 2025 Received: from e2i440.smtp2go.com (e2i440.smtp2go.com [103.2.141.184]) (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 501C31F5413 for ; Sun, 31 Aug 2025 19:18:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.2.141.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756667894; cv=none; b=OihNucUFqDNWCR01g6B683CJt7Ew+ratu/WwZvO3sQgyT7NVcfIM1ZPGPlphV7/mlaBctKTwirMVNxrCW9NU+LBFGz4bKE5tPwOGBZAin5qOp9EaBgHtCoaAbGBOxoOU2zmE5fJu93cuNTmZ5rxndypJyIXQW35F+/mNk7jdhjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756667894; c=relaxed/simple; bh=ABm7sCuXnVGTUvJ3oYj/x/myV+euHTB1ShT8xKihbqo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i0gsoz23juiUK73q05BVmtpg9JSIYg5XWnFTipoT6jQlcdCfKS2dNnxT27udVhsfn5y0ZajnL2mVGRwuW0zElnYgaEtT6J3K8YVIIQSklBwnSjadJ/C0LptlaZznl36L6SU5BSn1vIJ7gFOHPfMgx+QLiyZ95nYLpaJypGwR8Og= 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=fail (0-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b=lV8wR3Z/ reason="unknown key version"; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b=fF+S5Ouu; arc=none smtp.client-ip=103.2.141.184 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=fail reason="unknown key version" (0-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b="lV8wR3Z/"; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b="fF+S5Ouu" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=maxzs0.a1-4.dyn; x=1756668792; h=Feedback-ID: X-Smtpcorp-Track:Message-ID:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe:List-Unsubscribe-Post; bh=ZQf10//JpnrdeYz7kQCzI/aqQ6NoOTIPSKaQVv4vqlM=; b=lV8wR3Z/3CkZ3RuWrtn193wR5R ky7A5bZblEHL1jLnYtEdREgDDoPoxTmAehrffZl7V3/OXfGlsMH7cXdzSOTb/iLjFMSlOSe4OCNyc 3JGWz1b4sTRE9slRoEN5RHJOzOl0TJT2wYuQKWIFkzfcLlk0sgy+BLpS8vFqprWLRC/3+IED1Ggvv vJIlg/1fl87uAI9PHDExarOiVFGJZ6rRCwhOLHbP/eZn+Pa9nQaLkryLKdwtFCA+EzSnszZVjpkay bhYn5s2uPCBahk6LbqE3/rQQqtELRUF78l91hcqoGs5JZWcqt4kdCWA5tLxC0yah7HWfTPO2PZnqA QWEygt0Q==; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triplefau.lt; i=@triplefau.lt; q=dns/txt; s=s510616; t=1756667892; h=from : subject : to : message-id : date; bh=ZQf10//JpnrdeYz7kQCzI/aqQ6NoOTIPSKaQVv4vqlM=; b=fF+S5OuuZBQe/HuSW61M0rqHK87SgUx0TySImf4Ey7PHuCX6gSGdKIzgkLJixnNZ0YJEU fudQPtPNboWkn4JI502qMX1VboXE/uf3cM9Ipm3/olOLA+v5pcg0pVSDxLxunGjcWQYaH1r cZSontJAkvFcJHJBGq4nQChdCKoyfx2qY1eVvIio9q1986d8Ut9EFd/N2EpWmYMI4z0IUTh CSyuSWQV6XCXjkrihSU/U/ytLGCAoBKYqcuPNkRNf1CCLZ6HK3+BNnxfwGtQ8zg/mKpcWUQ EkFnwbyFD7DkGHK64NK7xWsfaCIfu4y+L9OKaU6Ld/8M6yriLGcrT+CiHYCA== Received: from [10.176.58.103] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2-S2G) (envelope-from ) id 1usnYt-TRk4VS-H5; Sun, 31 Aug 2025 19:17:59 +0000 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.98.1-S2G) (envelope-from ) id 1usnYt-4o5NDgrprk4-pPNu; Sun, 31 Aug 2025 19:17:59 +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: [RFC PATCH 4/5] wait: Introduce io_wait_event_killable() Date: Sun, 31 Aug 2025 21:03:42 +0200 Message-ID: <370180ef235d9e183c93bfb9677e8a35e4ca27f2.1756635044.git.repk@triplefau.lt> X-Mailer: git-send-email 2.50.1 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-Smtpcorp-Track: cWjWg_oTebCA.D3ajaYoA8Yn8.cP3ilwdJEdI Feedback-ID: 510616m:510616apGKSTK:510616s1xwnvTvE6 X-Report-Abuse: Please forward a copy of this message, including all headers, to Content-Type: text/plain; charset="utf-8" Add io_wait_event_killable(), a variant of wait_event_killable() that uses io_schedule() instead of schedule(). This is to be used in situation where waiting time is to be accounted as IO wait time. Signed-off-by: Remi Pommarel --- include/linux/wait.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/wait.h b/include/linux/wait.h index 09855d819418..cfeb1adee973 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -937,6 +937,21 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_= queue_entry_t *); __ret; \ }) =20 +#define __io_wait_event_killable(wq, condition) \ + ___wait_event(wq, condition, TASK_KILLABLE, 0, 0, io_schedule()) + +/* + * wait_event_killable() - link wait_event_killable but with io_schedule() + */ +#define io_wait_event_killable(wq_head, condition) \ +({ \ + int __ret =3D 0; \ + might_sleep(); \ + if (!(condition)) \ + __ret =3D __io_wait_event_killable(wq_head, condition); \ + __ret; \ +}) + #define __wait_event_state(wq, condition, state) \ ___wait_event(wq, condition, state, 0, 0, schedule()) =20 --=20 2.50.1 From nobody Fri Oct 3 12:12:11 2025 Received: from e2i440.smtp2go.com (e2i440.smtp2go.com [103.2.141.184]) (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 50225221275 for ; Sun, 31 Aug 2025 19:18:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.2.141.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756667894; cv=none; b=b9hVUUZVzG6+/VXUWEOxDWzDjdCJ9naoL7i0YGQkHsOYkUR5DsZlMMs4S2Y+59wQNodHCQt8g6Q8PaOHP1DRt7nMIdekcY1Kq5a6FIo+Uq7blfvmPQXcqIMV0sbO5a+VxFS4lxiZCtxTSydK3021W8jZSGNc0jSWonZbGwzQBBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756667894; c=relaxed/simple; bh=7D3KwNWJoC6p1VF2zcIsFrvHRGbh4rZ3AUloKNQr7YQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lcVP6l0xtgetNrlxT0ZMiIIZTME7Qe++W9xLfsn/MLwArZ9W3iZJ+A28I1Lmj8ltX+cIsDANS0srA8YodLbnhEz+G3ovz3i/uIwkoqBsqttn27q7E61muqkZODHRs+Jqv+QCcs78+7blF14L02KdfivujbrhWIoUFTccwuDjB4g= 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=fail (0-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b=2JSeaLru reason="unknown key version"; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b=aazivrjU; arc=none smtp.client-ip=103.2.141.184 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=fail reason="unknown key version" (0-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b="2JSeaLru"; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b="aazivrjU" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=maxzs0.a1-4.dyn; x=1756668792; h=Feedback-ID: X-Smtpcorp-Track:Message-ID:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe:List-Unsubscribe-Post; bh=XTOQ9/bbRBmTKIaXSYEBEdp9Uyv1R7EscXEwjs/sOsY=; b=2JSeaLrumPYpLTAQOtDbLejeR2 tCsT7/85RIulIbZfr6DnCyOINKzyEbMRFqeFIcXLJYi6HsZwr2MuVZUwBwyMrqB/FMyFckR90HALy NfxlY+Xjm2lTjHy57VKlDRMc9rTifCpoDtHB43Kcdl+Dm1Ul7bfgi4uIkl6og366o/OOvAQdPl6im 6g55sTKpzTgydDNPnW6ANkn0cMaMhRw75Qw4IJmw8pSSd9346/CmFb6x1pjlAiDKkYAw0lU9BZxqO lV7ujydn7mcJN6CvxB0dQon3npxf4XeM7qfwsiDq0d+q3iTAfMOnh1x7qtSr+yOGk2VjCoMpkpnQr jhYd0Sdw==; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triplefau.lt; i=@triplefau.lt; q=dns/txt; s=s510616; t=1756667892; h=from : subject : to : message-id : date; bh=XTOQ9/bbRBmTKIaXSYEBEdp9Uyv1R7EscXEwjs/sOsY=; b=aazivrjUIAnUHPbQXKm/+ydnhUtclD9XyGkvrYaUvNTIgvTJPTkr9jZBFYcIvLYp6/E3d A20zblz29fu3IOdm9tVwwlsdoE21VYDJgZvjIg/yajEqdt5VhqNRSMR2ThacICn6RA150Q1 Saae8F2f4cfuQi+I053g3X4Rfcyouf4EJCDOO04JU6GOqpfP+uUz57Gt/NvCej/Xfn6IMzm 51LFwA2UXH3frYFurlHF0Td4o1HuCQE/PJ/gH+kBCWAEgJNQGPzq7WibU5zLJhL0wbWPAfu ESqner43KLfiv3WfOj59PZrJWXigTGS4bT6TUM4daKY2CJB19qdil+GRf/cQ== Received: from [10.139.162.187] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2-S2G) (envelope-from ) id 1usnYt-TRk4XF-Tb; Sun, 31 Aug 2025 19:17:59 +0000 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.98.1-S2G) (envelope-from ) id 1usnYt-4o5NDgrhYfw-mjHk; Sun, 31 Aug 2025 19:17:59 +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: [RFC PATCH 5/5] 9p: Track 9P RPC waiting time as IO Date: Sun, 31 Aug 2025 21:03:43 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 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-Smtpcorp-Track: RczFNjPfh5-k.CymStYCYNnlH.lqbE2AkkXtC Feedback-ID: 510616m:510616apGKSTK:510616svxP-T_CuV X-Report-Abuse: Please forward a copy of this message, including all headers, to Content-Type: text/plain; charset="utf-8" Use io_wait_event_killable() to ensure that time spent waiting for 9P RPC transactions is accounted as IO wait time. Signed-off-by: Remi Pommarel --- net/9p/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/9p/client.c b/net/9p/client.c index 5c1ca57ccd28..3f0f4d6efc00 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -713,8 +713,8 @@ p9_client_rpc(struct p9_client *c, int8_t type, const c= har *fmt, ...) } again: /* Wait for the response */ - err =3D wait_event_killable(req->wq, - READ_ONCE(req->status) >=3D REQ_STATUS_RCVD); + err =3D io_wait_event_killable(req->wq, + READ_ONCE(req->status) >=3D REQ_STATUS_RCVD); =20 /* Make sure our req is coherent with regard to updates in other * threads - echoes to wmb() in the callback --=20 2.50.1