summaryrefslogtreecommitdiff
path: root/fs/erofs/fscache.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/erofs/fscache.c')
-rw-r--r--fs/erofs/fscache.c40
1 files changed, 13 insertions, 27 deletions
diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index ce3d8737df85..685c68774379 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -3,7 +3,6 @@
* Copyright (C) 2022, Alibaba Cloud
* Copyright (C) 2022, Bytedance Inc. All rights reserved.
*/
-#include <linux/pseudo_fs.h>
#include <linux/fscache.h>
#include "internal.h"
@@ -13,18 +12,6 @@ static LIST_HEAD(erofs_domain_list);
static LIST_HEAD(erofs_domain_cookies_list);
static struct vfsmount *erofs_pseudo_mnt;
-static int erofs_anon_init_fs_context(struct fs_context *fc)
-{
- return init_pseudo(fc, EROFS_SUPER_MAGIC) ? 0 : -ENOMEM;
-}
-
-static struct file_system_type erofs_anon_fs_type = {
- .owner = THIS_MODULE,
- .name = "pseudo_erofs",
- .init_fs_context = erofs_anon_init_fs_context,
- .kill_sb = kill_anon_super,
-};
-
struct erofs_fscache_io {
struct netfs_cache_resources cres;
struct iov_iter iter;
@@ -83,7 +70,7 @@ static void erofs_fscache_req_put(struct erofs_fscache_rq *req)
static struct erofs_fscache_rq *erofs_fscache_req_alloc(struct address_space *mapping,
loff_t start, size_t len)
{
- struct erofs_fscache_rq *req = kzalloc(sizeof(*req), GFP_KERNEL);
+ struct erofs_fscache_rq *req = kzalloc_obj(*req);
if (!req)
return NULL;
@@ -102,8 +89,7 @@ static void erofs_fscache_req_io_put(struct erofs_fscache_io *io)
erofs_fscache_req_put(req);
}
-static void erofs_fscache_req_end_io(void *priv,
- ssize_t transferred_or_error, bool was_async)
+static void erofs_fscache_req_end_io(void *priv, ssize_t transferred_or_error)
{
struct erofs_fscache_io *io = priv;
struct erofs_fscache_rq *req = io->private;
@@ -115,7 +101,7 @@ static void erofs_fscache_req_end_io(void *priv,
static struct erofs_fscache_io *erofs_fscache_req_io_alloc(struct erofs_fscache_rq *req)
{
- struct erofs_fscache_io *io = kzalloc(sizeof(*io), GFP_KERNEL);
+ struct erofs_fscache_io *io = kzalloc_obj(*io);
if (!io)
return NULL;
@@ -180,14 +166,13 @@ struct erofs_fscache_bio {
struct bio_vec bvecs[BIO_MAX_VECS];
};
-static void erofs_fscache_bio_endio(void *priv,
- ssize_t transferred_or_error, bool was_async)
+static void erofs_fscache_bio_endio(void *priv, ssize_t transferred_or_error)
{
struct erofs_fscache_bio *io = priv;
if (IS_ERR_VALUE(transferred_or_error))
io->bio.bi_status = errno_to_blk_status(transferred_or_error);
- io->bio.bi_end_io(&io->bio);
+ bio_endio(&io->bio);
BUILD_BUG_ON(offsetof(struct erofs_fscache_bio, io) != 0);
erofs_fscache_io_put(&io->io);
}
@@ -196,7 +181,7 @@ struct bio *erofs_fscache_bio_alloc(struct erofs_map_dev *mdev)
{
struct erofs_fscache_bio *io;
- io = kmalloc(sizeof(*io), GFP_KERNEL | __GFP_NOFAIL);
+ io = kmalloc_obj(*io, GFP_KERNEL | __GFP_NOFAIL);
bio_init(&io->bio, NULL, io->bvecs, BIO_MAX_VECS, REQ_OP_READ);
io->io.private = mdev->m_dif->fscache->cookie;
io->io.end_io = erofs_fscache_bio_endio;
@@ -218,7 +203,7 @@ void erofs_fscache_submit_bio(struct bio *bio)
if (!ret)
return;
bio->bi_status = errno_to_blk_status(ret);
- bio->bi_end_io(bio);
+ bio_endio(bio);
}
static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
@@ -276,7 +261,8 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_rq *req)
size_t size = map.m_llen;
void *src;
- src = erofs_read_metabuf(&buf, sb, map.m_pa, EROFS_KMAP);
+ src = erofs_read_metabuf(&buf, sb, map.m_pa,
+ erofs_inode_in_metabox(inode));
if (IS_ERR(src))
return PTR_ERR(src);
@@ -393,7 +379,7 @@ static void erofs_fscache_domain_put(struct erofs_domain *domain)
}
fscache_relinquish_volume(domain->volume, NULL, false);
mutex_unlock(&erofs_domain_list_lock);
- kfree(domain->domain_id);
+ kfree_sensitive(domain->domain_id);
kfree(domain);
return;
}
@@ -431,7 +417,7 @@ static int erofs_fscache_init_domain(struct super_block *sb)
struct erofs_domain *domain;
struct erofs_sb_info *sbi = EROFS_SB(sb);
- domain = kzalloc(sizeof(struct erofs_domain), GFP_KERNEL);
+ domain = kzalloc_obj(struct erofs_domain);
if (!domain)
return -ENOMEM;
@@ -460,7 +446,7 @@ static int erofs_fscache_init_domain(struct super_block *sb)
sbi->domain = domain;
return 0;
out:
- kfree(domain->domain_id);
+ kfree_sensitive(domain->domain_id);
kfree(domain);
return err;
}
@@ -496,7 +482,7 @@ static struct erofs_fscache *erofs_fscache_acquire_cookie(struct super_block *sb
struct inode *inode;
int ret;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx);
if (!ctx)
return ERR_PTR(-ENOMEM);
INIT_LIST_HEAD(&ctx->node);