linux/fs/erofs/internal.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2017-2018 HUAWEI, Inc.
 *             https://www.huawei.com/
 * Copyright (C) 2021, Alibaba Cloud
 */
#ifndef __EROFS_INTERNAL_H
#define __EROFS_INTERNAL_H

#include <linux/fs.h>
#include <linux/dax.h>
#include <linux/dcache.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/pagemap.h>
#include <linux/bio.h>
#include <linux/magic.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/iomap.h>
#include "erofs_fs.h"

/* redefine pr_fmt "erofs: " */
#undef pr_fmt
#define pr_fmt(fmt)

__printf(3, 4) void _erofs_err(struct super_block *sb,
			       const char *function, const char *fmt, ...);
#define erofs_err(sb, fmt, ...)
__printf(3, 4) void _erofs_info(struct super_block *sb,
			       const char *function, const char *fmt, ...);
#define erofs_info(sb, fmt, ...)
#ifdef CONFIG_EROFS_FS_DEBUG
#define DBG_BUGON
#else
#define DBG_BUGON
#endif	/* !CONFIG_EROFS_FS_DEBUG */

/* EROFS_SUPER_MAGIC_V1 to represent the whole file system */
#define EROFS_SUPER_MAGIC

erofs_nid_t;
erofs_off_t;
/* data type for filesystem-wide blocks number */
erofs_blk_t;

struct erofs_device_info {};

enum {};

struct erofs_mount_opts {};

struct erofs_dev_context {};

/* all filesystem-wide lz4 configurations */
struct erofs_sb_lz4_info {};

struct erofs_domain {};

struct erofs_fscache {};

struct erofs_xattr_prefix_item {};

struct erofs_sb_info {};

#define EROFS_SB(sb)
#define EROFS_I_SB(inode)

/* Mount flags set via mount options or defaults */
#define EROFS_MOUNT_XATTR_USER
#define EROFS_MOUNT_POSIX_ACL
#define EROFS_MOUNT_DAX_ALWAYS
#define EROFS_MOUNT_DAX_NEVER

#define clear_opt(opt, option)
#define set_opt(opt, option)
#define test_opt(opt, option)

static inline bool erofs_is_fscache_mode(struct super_block *sb)
{}

enum {};

/* basic unit of the workstation of a super_block */
struct erofs_workgroup {};

enum erofs_kmap_type {};

struct erofs_buf {};
#define __EROFS_BUF_INITIALIZER

#define erofs_blknr(sb, addr)
#define erofs_blkoff(sb, addr)
#define erofs_pos(sb, blk)
#define erofs_iblks(i)

#define EROFS_FEATURE_FUNCS(name, compat, feature)

EROFS_FEATURE_FUNCS()
EROFS_FEATURE_FUNCS()
EROFS_FEATURE_FUNCS()
EROFS_FEATURE_FUNCS()
EROFS_FEATURE_FUNCS()
EROFS_FEATURE_FUNCS()
EROFS_FEATURE_FUNCS()
EROFS_FEATURE_FUNCS()
EROFS_FEATURE_FUNCS()
EROFS_FEATURE_FUNCS()
EROFS_FEATURE_FUNCS()
EROFS_FEATURE_FUNCS()

/* atomic flag definitions */
#define EROFS_I_EA_INITED_BIT
#define EROFS_I_Z_INITED_BIT

/* bitlock definitions (arranged in reverse order) */
#define EROFS_I_BL_XATTR_BIT
#define EROFS_I_BL_Z_BIT

struct erofs_inode {};

#define EROFS_I(ptr)

static inline erofs_off_t erofs_iloc(struct inode *inode)
{}

static inline unsigned int erofs_inode_version(unsigned int ifmt)
{}

static inline unsigned int erofs_inode_datalayout(unsigned int ifmt)
{}

/* reclaiming is never triggered when allocating new folios. */
static inline struct folio *erofs_grab_folio_nowait(struct address_space *as,
						    pgoff_t index)
{}

/* Has a disk mapping */
#define EROFS_MAP_MAPPED
/* Located in metadata (could be copied from bd_inode) */
#define EROFS_MAP_META
/* The extent is encoded */
#define EROFS_MAP_ENCODED
/* The length of extent is full */
#define EROFS_MAP_FULL_MAPPED
/* Located in the special packed inode */
#define EROFS_MAP_FRAGMENT
/* The extent refers to partial decompressed data */
#define EROFS_MAP_PARTIAL_REF

struct erofs_map_blocks {};

/*
 * Used to get the exact decompressed length, e.g. fiemap (consider lookback
 * approach instead if possible since it's more metadata lightweight.)
 */
#define EROFS_GET_BLOCKS_FIEMAP
/* Used to map the whole extent if non-negligible data is requested for LZMA */
#define EROFS_GET_BLOCKS_READMORE
/* Used to map tail extent for tailpacking inline or fragment pcluster */
#define EROFS_GET_BLOCKS_FINDTAIL

enum {};

struct erofs_map_dev {};

extern const struct super_operations erofs_sops;

extern const struct address_space_operations erofs_raw_access_aops;
extern const struct address_space_operations z_erofs_aops;
extern const struct address_space_operations erofs_fscache_access_aops;

extern const struct inode_operations erofs_generic_iops;
extern const struct inode_operations erofs_symlink_iops;
extern const struct inode_operations erofs_fast_symlink_iops;
extern const struct inode_operations erofs_dir_iops;

extern const struct file_operations erofs_file_fops;
extern const struct file_operations erofs_dir_fops;

extern const struct iomap_ops z_erofs_iomap_report_ops;

/* flags for erofs_fscache_register_cookie() */
#define EROFS_REG_COOKIE_SHARE
#define EROFS_REG_COOKIE_NEED_NOEXIST

void *erofs_read_metadata(struct super_block *sb, struct erofs_buf *buf,
			  erofs_off_t *offset, int *lengthp);
void erofs_unmap_metabuf(struct erofs_buf *buf);
void erofs_put_metabuf(struct erofs_buf *buf);
void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset,
		  enum erofs_kmap_type type);
void erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb);
void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,
			 erofs_off_t offset, enum erofs_kmap_type type);
int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *dev);
int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
		 u64 start, u64 len);
int erofs_map_blocks(struct inode *inode, struct erofs_map_blocks *map);
struct inode *erofs_iget(struct super_block *sb, erofs_nid_t nid);
int erofs_getattr(struct mnt_idmap *idmap, const struct path *path,
		  struct kstat *stat, u32 request_mask,
		  unsigned int query_flags);
int erofs_namei(struct inode *dir, const struct qstr *name,
		erofs_nid_t *nid, unsigned int *d_type);

static inline void *erofs_vm_map_ram(struct page **pages, unsigned int count)
{}

int erofs_register_sysfs(struct super_block *sb);
void erofs_unregister_sysfs(struct super_block *sb);
int __init erofs_init_sysfs(void);
void erofs_exit_sysfs(void);

struct page *__erofs_allocpage(struct page **pagepool, gfp_t gfp, bool tryrsv);
static inline struct page *erofs_allocpage(struct page **pagepool, gfp_t gfp)
{}
static inline void erofs_pagepool_add(struct page **pagepool, struct page *page)
{}
void erofs_release_pages(struct page **pagepool);

#ifdef CONFIG_EROFS_FS_ZIP
void erofs_workgroup_put(struct erofs_workgroup *grp);
struct erofs_workgroup *erofs_find_workgroup(struct super_block *sb,
					     pgoff_t index);
struct erofs_workgroup *erofs_insert_workgroup(struct super_block *sb,
					       struct erofs_workgroup *grp);
void erofs_workgroup_free_rcu(struct erofs_workgroup *grp);
void erofs_shrinker_register(struct super_block *sb);
void erofs_shrinker_unregister(struct super_block *sb);
int __init erofs_init_shrinker(void);
void erofs_exit_shrinker(void);
int __init z_erofs_init_subsystem(void);
void z_erofs_exit_subsystem(void);
int erofs_try_to_free_all_cached_folios(struct erofs_sb_info *sbi,
					struct erofs_workgroup *egrp);
int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *map,
			    int flags);
void *z_erofs_get_gbuf(unsigned int requiredpages);
void z_erofs_put_gbuf(void *ptr);
int z_erofs_gbuf_growsize(unsigned int nrpages);
int __init z_erofs_gbuf_init(void);
void z_erofs_gbuf_exit(void);
int erofs_init_managed_cache(struct super_block *sb);
int z_erofs_parse_cfgs(struct super_block *sb, struct erofs_super_block *dsb);
#else
static inline void erofs_shrinker_register(struct super_block *sb) {}
static inline void erofs_shrinker_unregister(struct super_block *sb) {}
static inline int erofs_init_shrinker(void) { return 0; }
static inline void erofs_exit_shrinker(void) {}
static inline int z_erofs_init_subsystem(void) { return 0; }
static inline void z_erofs_exit_subsystem(void) {}
static inline int erofs_init_managed_cache(struct super_block *sb) { return 0; }
#endif	/* !CONFIG_EROFS_FS_ZIP */

#ifdef CONFIG_EROFS_FS_ONDEMAND
int erofs_fscache_register_fs(struct super_block *sb);
void erofs_fscache_unregister_fs(struct super_block *sb);

struct erofs_fscache *erofs_fscache_register_cookie(struct super_block *sb,
					char *name, unsigned int flags);
void erofs_fscache_unregister_cookie(struct erofs_fscache *fscache);
struct bio *erofs_fscache_bio_alloc(struct erofs_map_dev *mdev);
void erofs_fscache_submit_bio(struct bio *bio);
#else
static inline int erofs_fscache_register_fs(struct super_block *sb)
{
	return -EOPNOTSUPP;
}
static inline void erofs_fscache_unregister_fs(struct super_block *sb) {}

static inline
struct erofs_fscache *erofs_fscache_register_cookie(struct super_block *sb,
					char *name, unsigned int flags)
{
	return ERR_PTR(-EOPNOTSUPP);
}

static inline void erofs_fscache_unregister_cookie(struct erofs_fscache *fscache)
{
}
static inline struct bio *erofs_fscache_bio_alloc(struct erofs_map_dev *mdev) { return NULL; }
static inline void erofs_fscache_submit_bio(struct bio *bio) {}
#endif

#define EFSCORRUPTED

#endif	/* __EROFS_INTERNAL_H */