ext2_extents.h revision 311232
11558Srgrimes/*- 21558Srgrimes * Copyright (c) 2012, 2010 Zheng Liu <lz@freebsd.org> 31558Srgrimes * All rights reserved. 41558Srgrimes * 51558Srgrimes * Redistribution and use in source and binary forms, with or without 61558Srgrimes * modification, are permitted provided that the following conditions 71558Srgrimes * are met: 81558Srgrimes * 1. Redistributions of source code must retain the above copyright 91558Srgrimes * notice, this list of conditions and the following disclaimer. 101558Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111558Srgrimes * notice, this list of conditions and the following disclaimer in the 121558Srgrimes * documentation and/or other materials provided with the distribution. 131558Srgrimes * 141558Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 151558Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 161558Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 171558Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 181558Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 191558Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 201558Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 211558Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 221558Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 231558Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 241558Srgrimes * SUCH DAMAGE. 251558Srgrimes * 261558Srgrimes * $FreeBSD: stable/10/sys/fs/ext2fs/ext2_extents.h 311232 2017-01-04 02:43:33Z pfg $ 271558Srgrimes */ 281558Srgrimes#ifndef _FS_EXT2FS_EXT2_EXTENTS_H_ 291558Srgrimes#define _FS_EXT2FS_EXT2_EXTENTS_H_ 30102411Scharnier 311558Srgrimes#include <sys/types.h> 3223675Speter 33102411Scharnier#define EXT4_EXT_MAGIC 0xf30a 3441477Sjulian 35102411Scharnier#define EXT4_EXT_CACHE_NO 0 36102411Scharnier#define EXT4_EXT_CACHE_GAP 1 37102411Scharnier#define EXT4_EXT_CACHE_IN 2 381558Srgrimes 3974556Smckusick/* 4023675Speter * Ext4 file system extent on disk. 411558Srgrimes */ 421558Srgrimesstruct ext4_extent { 4323799Sbde uint32_t e_blk; /* first logical block */ 4423675Speter uint16_t e_len; /* number of blocks */ 45142123Sdelphij uint16_t e_start_hi; /* high 16 bits of physical block */ 46103949Smike uint32_t e_start_lo; /* low 32 bits of physical block */ 471558Srgrimes}; 48207141Sjeff 4923675Speter/* 501558Srgrimes * Extent index on disk. 511558Srgrimes */ 52224059Smckusickstruct ext4_extent_index { 53224059Smckusick uint32_t ei_blk; /* indexes logical blocks */ 54221233Sdes uint32_t ei_leaf_lo; /* points to physical block of the 55221233Sdes * next level */ 567585Sbde uint16_t ei_leaf_hi; /* high 16 bits of physical block */ 5792839Simp uint16_t ei_unused; 581558Srgrimes}; 5998542Smckusick 6074556Smckusick/* 6123675Speter * Extent tree header. 62221233Sdes */ 63224059Smckusickstruct ext4_extent_header { 641558Srgrimes uint16_t eh_magic; /* magic number: 0xf30a */ 6598542Smckusick uint16_t eh_ecount; /* number of valid entries */ 661558Srgrimes uint16_t eh_max; /* capacity of store in entries */ 671558Srgrimes uint16_t eh_depth; /* the depth of extent tree */ 68248658Smckusick uint32_t eh_gen; /* generation of extent tree */ 69248658Smckusick}; 701558Srgrimes 7141474Sjulian/* 7223675Speter * Save cached extent. 731558Srgrimes */ 7423675Speterstruct ext4_extent_cache { 751558Srgrimes daddr_t ec_start; /* extent start */ 761558Srgrimes uint32_t ec_blk; /* logical block */ 771558Srgrimes uint32_t ec_len; 781558Srgrimes uint32_t ec_type; 791558Srgrimes}; 8096483Sphk 811558Srgrimes/* 821558Srgrimes * Save path to some extent. 831558Srgrimes */ 841558Srgrimesstruct ext4_extent_path { 85100935Sphk uint16_t ep_depth; 861558Srgrimes struct buf *ep_bp; 871558Srgrimes struct ext4_extent *ep_ext; 881558Srgrimes struct ext4_extent_index *ep_index; 891558Srgrimes struct ext4_extent_header *ep_header; 901558Srgrimes}; 911558Srgrimes 921558Srgrimesstruct inode; 931558Srgrimesstruct m_ext2fs; 941558Srgrimesint ext4_ext_in_cache(struct inode *, daddr_t, struct ext4_extent *); 951558Srgrimesvoid ext4_ext_put_cache(struct inode *, struct ext4_extent *, int); 961558Srgrimesstruct ext4_extent_path * 9774556Smckusickext4_ext_find_extent(struct m_ext2fs *fs, 981558Srgrimes struct inode *, daddr_t, struct ext4_extent_path *); 991558Srgrimes 1001558Srgrimes#endif /* !_FS_EXT2FS_EXT2_EXTENTS_H_ */ 1011558Srgrimes