fs/nilfs2/bmap.h

Source file repositories/reference/linux-study-clean/fs/nilfs2/bmap.h

File Facts

System
Linux kernel
Corpus path
fs/nilfs2/bmap.h
Extension
.h
Size
8694 bytes
Lines
284
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

struct nilfs_bmap_stats {
	unsigned int bs_nblocks;
};

/**
 * struct nilfs_bmap_operations - bmap operation table
 * @bop_lookup:               single block search operation
 * @bop_lookup_contig:        consecutive block search operation
 * @bop_insert:               block insertion operation
 * @bop_delete:               block delete operation
 * @bop_clear:                block mapping resource release operation
 * @bop_propagate:            operation to propagate dirty state towards the
 *                            mapping root
 * @bop_lookup_dirty_buffers: operation to collect dirty block buffers
 * @bop_assign:               disk block address assignment operation
 * @bop_mark:                 operation to mark in-use blocks as dirty for
 *                            relocation by GC
 * @bop_seek_key:             find valid block key operation
 * @bop_last_key:             find last valid block key operation
 */
struct nilfs_bmap_operations {
	int (*bop_lookup)(const struct nilfs_bmap *, __u64, int, __u64 *);
	int (*bop_lookup_contig)(const struct nilfs_bmap *, __u64, __u64 *,
				 unsigned int);
	int (*bop_insert)(struct nilfs_bmap *, __u64, __u64);
	int (*bop_delete)(struct nilfs_bmap *, __u64);
	void (*bop_clear)(struct nilfs_bmap *);

	int (*bop_propagate)(struct nilfs_bmap *, struct buffer_head *);
	void (*bop_lookup_dirty_buffers)(struct nilfs_bmap *,
					 struct list_head *);

	int (*bop_assign)(struct nilfs_bmap *,
			  struct buffer_head **,
			  sector_t,
			  union nilfs_binfo *);
	int (*bop_mark)(struct nilfs_bmap *, __u64, int);

	int (*bop_seek_key)(const struct nilfs_bmap *, __u64, __u64 *);
	int (*bop_last_key)(const struct nilfs_bmap *, __u64 *);

	/* private: internal use only */
	int (*bop_check_insert)(const struct nilfs_bmap *, __u64);
	int (*bop_check_delete)(struct nilfs_bmap *, __u64);
	int (*bop_gather_data)(struct nilfs_bmap *, __u64 *, __u64 *, int);
};


#define NILFS_BMAP_SIZE		(NILFS_INODE_BMAP_SIZE * sizeof(__le64))
#define NILFS_BMAP_KEY_BIT	BITS_PER_LONG
#define NILFS_BMAP_NEW_PTR_INIT	(1UL << (BITS_PER_LONG - 1))

static inline int nilfs_bmap_is_new_ptr(unsigned long ptr)
{
	return !!(ptr & NILFS_BMAP_NEW_PTR_INIT);
}


/**
 * struct nilfs_bmap - bmap structure
 * @b_u: raw data
 * @b_sem: semaphore
 * @b_inode: owner of bmap
 * @b_ops: bmap operation table
 * @b_last_allocated_key: last allocated key for data block
 * @b_last_allocated_ptr: last allocated ptr for data block
 * @b_ptr_type: pointer type
 * @b_state: state
 * @b_nchildren_per_block: maximum number of child nodes for non-root nodes
 */
struct nilfs_bmap {
	union {
		__u8 u_flags;
		__le64 u_data[NILFS_BMAP_SIZE / sizeof(__le64)];
	} b_u;
	struct rw_semaphore b_sem;
	struct inode *b_inode;
	const struct nilfs_bmap_operations *b_ops;
	__u64 b_last_allocated_key;
	__u64 b_last_allocated_ptr;
	int b_ptr_type;
	int b_state;
	__u16 b_nchildren_per_block;
};

/* pointer type */
#define NILFS_BMAP_PTR_P	0	/* physical block number (i.e. LBN) */
#define NILFS_BMAP_PTR_VS	1	/*
					 * virtual block number (single
					 * version)

Annotation

Implementation Notes