From nobody Sun Apr 5 13:06:20 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 9C1EC336884 for ; Tue, 24 Mar 2026 20:08:48 +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=1774382934; cv=none; b=mIuvBr/3K+2TvQTatkwChjQEsod5Vb5xyKJ/8pPqyXeGQ73Ul9bPgfUZQ4ga7TNTVyLxjJ9Vd/6eVxQZFrcNaE74wjngXTU00b8rgHTnEjbCoKmHAW4Zf5gsMAk4YIuHR9pr+K+lFaUkOXvoOd9XNtci1QgS7T5R38CXtn9nZCU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774382934; c=relaxed/simple; bh=04rlqeEDoFEVDEw1hjLSM2BNdr4PY2iqAtJpuU8Gc1w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tARvNfaJ2Lri+SXDxEe+bpzKjokmJZvrdu3OcIONqH8fA/QrQ9O5CI2VnL5XQSWd60PwJwbO5pgJXNmUQjIiEIIaASBAokpU9VwprLx1REpse86JwU5m1Sb19Uju2PogJUrnee+dOdp0F6DqWjwlfVIIHWfBar41UogyFt2G/+U= 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=W4D8MN+0; 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="W4D8MN+0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triplefau.lt; i=@triplefau.lt; q=dns/txt; s=s510616; t=1774382626; h=from : subject : to : message-id : date; bh=6+CrdPGc6TTLNXNf+K/wu2w06OOSgORyO3HZ/p6Hwnw=; b=W4D8MN+0WPSOPP+rztFm9ltPfnSSX+c+5ery35ZTYVQ+mmWrg/YwMeqINyRSuFWMggmEH aZRfuLB7yv232w8eHcBwbqdHmDr/9o+92mLcvyMOuQEDWOBKTxEiOSJNC5oK4+nY2YiMzt+ R0LmguqBIZWyOvrGyMxrlscYKs8dAiW5DTAFcMMiFosUBtB0usFbYR4ezdK9wnyavD8nUEl oapoeC4um3hz7T+HOaniH3vcHRvU/nbGLPPAVkCW8OMdbkV2OY5TqHkNNw4ria+IDdRVLDq 8nw6mOTfsTdHg1Q4dR534LGg73dftY6DiQs9JXb+N89ZqwPhYtEUUoULHSHw== 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 1w57yV-FnQW0hPytxt-nY1Y; Tue, 24 Mar 2026 20:03:39 +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 4/4] 9p: Enable symlink caching in page cache Date: Tue, 24 Mar 2026 20:43:34 +0100 Message-ID: <66244aac405ec1b61aab52ed80070b3cdcc7788b.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:510616suuub604Ee X-smtpcorp-track: p_dP0l158EJa.TqwYolU4VStT.yvcE1gzcVoZ 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/vfs_addr.c | 29 +++++++++++++++-- fs/9p/vfs_inode.c | 6 ++-- fs/9p/vfs_inode_dotl.c | 72 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 94 insertions(+), 13 deletions(-) diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c index 862164181bac..339f0cfdcb7b 100644 --- a/fs/9p/vfs_addr.c +++ b/fs/9p/vfs_addr.c @@ -70,10 +70,24 @@ static void v9fs_issue_read(struct netfs_io_subrequest = *subreq) { struct netfs_io_request *rreq =3D subreq->rreq; struct p9_fid *fid =3D rreq->netfs_priv; + char *target; unsigned long long pos =3D subreq->start + subreq->transferred; - int total, err; - - total =3D p9_client_read(fid, pos, &subreq->io_iter, &err); + int total, err, len, n; + + if (S_ISLNK(rreq->inode->i_mode)) { + /* p9_client_readlink() must not be called for legacy protocols + * 9p2000 or 9p2000.u. + */ + BUG_ON(!p9_is_proto_dotl(fid->clnt)); + err =3D p9_client_readlink(fid, &target); + len =3D strnlen(target, PAGE_SIZE - 1); + n =3D copy_to_iter(target, len, &subreq->io_iter); + if (n !=3D len) + err =3D -EFAULT; + total =3D i_size_read(rreq->inode); + } else { + total =3D p9_client_read(fid, pos, &subreq->io_iter, &err); + } =20 /* if we just extended the file size, any portion not in * cache won't be on server and is zeroes */ @@ -99,6 +113,7 @@ static void v9fs_issue_read(struct netfs_io_subrequest *= subreq) static int v9fs_init_request(struct netfs_io_request *rreq, struct file *f= ile) { struct p9_fid *fid; + struct dentry *dentry; bool writing =3D (rreq->origin =3D=3D NETFS_READ_FOR_WRITE || rreq->origin =3D=3D NETFS_WRITETHROUGH || rreq->origin =3D=3D NETFS_UNBUFFERED_WRITE || @@ -115,6 +130,14 @@ static int v9fs_init_request(struct netfs_io_request *= rreq, struct file *file) if (!fid) goto no_fid; p9_fid_get(fid); + } else if (S_ISLNK(rreq->inode->i_mode)) { + dentry =3D d_find_alias(rreq->inode); + if (!dentry) + goto no_fid; + fid =3D v9fs_fid_lookup(dentry); + dput(dentry); + if (IS_ERR(fid)) + goto no_fid; } else { fid =3D v9fs_fid_find_inode(rreq->inode, writing, INVALID_UID, true); if (!fid) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index c82db6fe0c39..98644f27d6f1 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -302,10 +302,12 @@ 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_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 643e759eacb2..a286a078d6a6 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -686,9 +686,13 @@ v9fs_vfs_symlink_dotl(struct mnt_idmap *idmap, struct = inode *dir, int err; kgid_t gid; const unsigned char *name; + umode_t mode; + struct v9fs_session_info *v9ses; struct p9_qid qid; struct p9_fid *dfid; struct p9_fid *fid =3D NULL; + struct inode *inode; + struct posix_acl *dacl =3D NULL, *pacl =3D NULL; =20 name =3D dentry->d_name.name; p9_debug(P9_DEBUG_VFS, "%lu,%s,%s\n", dir->i_ino, name, symname); @@ -702,6 +706,14 @@ v9fs_vfs_symlink_dotl(struct mnt_idmap *idmap, struct = inode *dir, =20 gid =3D v9fs_get_fsgid_for_create(dir); =20 + /* Update mode based on ACL value */ + err =3D v9fs_acl_mode(dir, &mode, &dacl, &pacl); + if (err) { + p9_debug(P9_DEBUG_VFS, "Failed to get acl values in mknod %d\n", + err); + goto error; + } + /* Server doesn't alter fid on TSYMLINK. Hence no need to clone it. */ err =3D p9_client_symlink(dfid, name, symname, gid, &qid); =20 @@ -712,8 +724,30 @@ v9fs_vfs_symlink_dotl(struct mnt_idmap *idmap, struct = inode *dir, =20 v9fs_invalidate_inode_attr(dir); =20 + /* instantiate inode and assign the unopened fid to the dentry */ + fid =3D p9_client_walk(dfid, 1, &name, 1); + if (IS_ERR(fid)) { + err =3D PTR_ERR(fid); + p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", + err); + goto error; + } + + v9ses =3D v9fs_inode2v9ses(dir); + inode =3D v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); + if (IS_ERR(inode)) { + err =3D PTR_ERR(inode); + p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", + err); + goto error; + } + v9fs_set_create_acl(inode, fid, dacl, pacl); + v9fs_fid_add(dentry, &fid); + d_instantiate(dentry, inode); + err =3D 0; error: p9_fid_put(fid); + v9fs_put_acl(dacl, pacl); p9_fid_put(dfid); return err; } @@ -853,24 +887,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); @@ -884,6 +917,29 @@ v9fs_vfs_get_link_dotl(struct dentry *dentry, return target; } =20 +/** + * 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; --=20 2.52.0