From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: linux-erofs@lists.ozlabs.org
Cc: LKML <linux-kernel@vger.kernel.org>,
Gao Xiang <hsiangkao@linux.alibaba.com>
Subject: [PATCH] erofs: use inode_set_cached_link()
Date: Wed, 28 Jan 2026 12:58:54 +0800 [thread overview]
Message-ID: <20260128045854.2266287-1-hsiangkao@linux.alibaba.com> (raw)
Symlink lengths are now cached in in-memory inodes directly so that
readlink can be sped up.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
fs/erofs/inode.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 2e02d4b466ce..6afe487eb9be 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -8,21 +8,23 @@
#include <linux/compat.h>
#include <trace/events/erofs.h>
-static int erofs_fill_symlink(struct inode *inode, void *kaddr,
- unsigned int m_pofs)
+static int erofs_fill_symlink(struct inode *inode, void *bptr, unsigned int ofs)
{
struct erofs_inode *vi = EROFS_I(inode);
- loff_t off;
-
- m_pofs += vi->xattr_isize;
- /* check if it cannot be handled with fast symlink scheme */
- if (vi->datalayout != EROFS_INODE_FLAT_INLINE ||
- check_add_overflow(m_pofs, inode->i_size, &off) ||
- off > i_blocksize(inode))
- return 0;
-
- inode->i_link = kmemdup_nul(kaddr + m_pofs, inode->i_size, GFP_KERNEL);
- return inode->i_link ? 0 : -ENOMEM;
+ char *link;
+ loff_t end;
+
+ ofs += vi->xattr_isize;
+ /* check whether the symlink data is small enough to be inlined */
+ if (vi->datalayout == EROFS_INODE_FLAT_INLINE &&
+ !check_add_overflow(ofs, inode->i_size, &end) &&
+ end <= i_blocksize(inode)) {
+ link = kmemdup_nul(bptr + ofs, inode->i_size, GFP_KERNEL);
+ if (!link)
+ return -ENOMEM;
+ inode_set_cached_link(inode, link, inode->i_size);
+ }
+ return 0;
}
static int erofs_read_inode(struct inode *inode)
--
2.43.5
next reply other threads:[~2026-01-28 4:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 4:58 Gao Xiang [this message]
2026-02-03 2:31 ` [PATCH v2] " Gao Xiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260128045854.2266287-1-hsiangkao@linux.alibaba.com \
--to=hsiangkao@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®