fs/f2fs/extent_cache.c

Source file repositories/reference/linux-study-clean/fs/f2fs/extent_cache.c

File Facts

System
Linux kernel
Corpus path
fs/f2fs/extent_cache.c
Extension
.c
Size
32399 bytes
Lines
1259
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

if (devi == 0) {
			f2fs_warn(sbi,
			    "%s: inode (ino=%llx) is an alias of meta device",
			    __func__, inode->i_ino);
			return false;
		}

		if (bdev_is_zoned(FDEV(devi).bdev)) {
			f2fs_warn(sbi,
			    "%s: device alias inode (ino=%llx)'s extent info "
			    "[%u, %u, %u] maps to zoned block device",
			    __func__, inode->i_ino, ei.blk, ei.fofs, ei.len);
			return false;
		}
		return true;
	}

	f2fs_warn(sbi, "%s: device alias inode (ino=%llx)'s extent info "
			"[%u, %u, %u] is inconsistent w/ any devices",
			__func__, inode->i_ino, ei.blk, ei.fofs, ei.len);
	return false;
}

static void __set_extent_info(struct extent_info *ei,
				unsigned int fofs, unsigned int len,
				block_t blk, bool keep_clen,
				unsigned long age, unsigned long last_blocks,
				enum extent_type type)
{
	ei->fofs = fofs;
	ei->len = len;

	if (type == EX_READ) {
		ei->blk = blk;
		if (keep_clen)
			return;
#ifdef CONFIG_F2FS_FS_COMPRESSION
		ei->c_len = 0;
#endif
	} else if (type == EX_BLOCK_AGE) {
		ei->age = age;
		ei->last_blocks = last_blocks;
	}
}

static bool __init_may_extent_tree(struct inode *inode, enum extent_type type)
{
	if (type == EX_READ)
		return test_opt(F2FS_I_SB(inode), READ_EXTENT_CACHE) &&
			S_ISREG(inode->i_mode);
	if (type == EX_BLOCK_AGE)
		return test_opt(F2FS_I_SB(inode), AGE_EXTENT_CACHE) &&
			(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode));
	return false;
}

static bool __may_extent_tree(struct inode *inode, enum extent_type type)
{
	if (IS_DEVICE_ALIASING(inode) && type == EX_READ)
		return true;

	/*
	 * for recovered files during mount do not create extents
	 * if shrinker is not registered.
	 */
	if (list_empty(&F2FS_I_SB(inode)->s_list))
		return false;

	if (!__init_may_extent_tree(inode, type))
		return false;

	if (is_inode_flag_set(inode, FI_NO_EXTENT))
		return false;

	if (type == EX_READ) {
		if (is_inode_flag_set(inode, FI_COMPRESSED_FILE) &&
				 !f2fs_sb_has_readonly(F2FS_I_SB(inode)))
			return false;
	} else if (type == EX_BLOCK_AGE) {
		if (is_inode_flag_set(inode, FI_COMPRESSED_FILE))
			return false;
		if (file_is_cold(inode))
			return false;
	}
	return true;
}

static void __try_update_largest_extent(struct extent_tree *et,
						struct extent_node *en)
{

Annotation

Implementation Notes