VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
f51667685749e fs/ext4/ext4_extents.h          (Theodore Ts'o        2017-12-17 22:00:59 -0500   1) // SPDX-License-Identifier: GPL-2.0
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700   2) /*
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700   3)  * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700   4)  * Written by Alex Tomas <alex@clusterfs.com>
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700   5)  */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700   6) 
3dcf54515aa49 fs/ext4/ext4_extents.h          (Christoph Hellwig    2008-04-29 18:13:32 -0400   7) #ifndef _EXT4_EXTENTS
3dcf54515aa49 fs/ext4/ext4_extents.h          (Christoph Hellwig    2008-04-29 18:13:32 -0400   8) #define _EXT4_EXTENTS
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700   9) 
3dcf54515aa49 fs/ext4/ext4_extents.h          (Christoph Hellwig    2008-04-29 18:13:32 -0400  10) #include "ext4.h"
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  11) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  12) /*
bbf2f9fb1c723 include/linux/ext4_fs_extents.h (Robert P. J. Day     2007-02-17 19:20:16 +0100  13)  * With AGGRESSIVE_TEST defined, the capacity of index/leaf blocks
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  14)  * becomes very small, so index split, in-depth growing and
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  15)  * other hard changes happen much more often.
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  16)  * This is for debug purposes only.
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  17)  */
bbf2f9fb1c723 include/linux/ext4_fs_extents.h (Robert P. J. Day     2007-02-17 19:20:16 +0100  18) #define AGGRESSIVE_TEST_
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  19) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  20) /*
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  21)  * With EXTENTS_STATS defined, the number of blocks and extents
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  22)  * are collected in the truncate path. They'll be shown at
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  23)  * umount time.
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  24)  */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  25) #define EXTENTS_STATS__
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  26) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  27) /*
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  28)  * If CHECK_BINSEARCH is defined, then the results of the binary search
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  29)  * will also be checked by linear search.
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  30)  */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  31) #define CHECK_BINSEARCH__
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  32) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  33) /*
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  34)  * If EXT_STATS is defined then stats numbers are collected.
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  35)  * These number will be displayed at umount time.
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  36)  */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  37) #define EXT_STATS_
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  38) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  39) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  40) /*
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  41)  * ext4_inode has i_block array (60 bytes total).
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  42)  * The first 12 bytes store ext4_extent_header;
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  43)  * the remainder stores an array of ext4_extent.
e615391896064 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:23:10 -0400  44)  * For non-inode extent blocks, ext4_extent_tail
e615391896064 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:23:10 -0400  45)  * follows the array.
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  46)  */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  47) 
e615391896064 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:23:10 -0400  48) /*
e615391896064 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:23:10 -0400  49)  * This is the extent tail on-disk structure.
e615391896064 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:23:10 -0400  50)  * All other extent structures are 12 bytes long.  It turns out that
e615391896064 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:23:10 -0400  51)  * block_size % 12 >= 4 for at least all powers of 2 greater than 512, which
e615391896064 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:23:10 -0400  52)  * covers all valid ext4 block sizes.  Therefore, this tail structure can be
e615391896064 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:23:10 -0400  53)  * crammed into the end of the block without having to rebalance the tree.
e615391896064 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:23:10 -0400  54)  */
e615391896064 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:23:10 -0400  55) struct ext4_extent_tail {
e615391896064 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:23:10 -0400  56) 	__le32	et_checksum;	/* crc32c(uuid+inum+extent_block) */
e615391896064 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:23:10 -0400  57) };
e615391896064 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:23:10 -0400  58) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  59) /*
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  60)  * This is the extent on-disk structure.
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  61)  * It's used at the bottom of the tree.
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  62)  */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  63) struct ext4_extent {
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  64) 	__le32	ee_block;	/* first logical block extent covers */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  65) 	__le16	ee_len;		/* number of blocks covered by extent */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  66) 	__le16	ee_start_hi;	/* high 16 bits of physical block */
b377611d11aba include/linux/ext4_fs_extents.h (Aneesh Kumar K.V     2007-10-16 18:38:25 -0400  67) 	__le32	ee_start_lo;	/* low 32 bits of physical block */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  68) };
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  69) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  70) /*
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  71)  * This is index on-disk structure.
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  72)  * It's used at all the levels except the bottom.
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  73)  */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  74) struct ext4_extent_idx {
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  75) 	__le32	ei_block;	/* index covers logical blocks from 'block' */
d8dd0b45438d6 include/linux/ext4_fs_extents.h (Aneesh Kumar K.V     2007-10-16 18:38:25 -0400  76) 	__le32	ei_leaf_lo;	/* pointer to the physical block of the next *
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  77) 				 * level. leaf or next index could be there */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  78) 	__le16	ei_leaf_hi;	/* high 16 bits of physical block */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  79) 	__u16	ei_unused;
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  80) };
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  81) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  82) /*
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  83)  * Each block (leaves and indexes), even inode-stored has header.
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  84)  */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  85) struct ext4_extent_header {
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  86) 	__le16	eh_magic;	/* probably will support different formats */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  87) 	__le16	eh_entries;	/* number of valid entries */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  88) 	__le16	eh_max;		/* capacity of store in entries */
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700  89) 	__le16	eh_depth;	/* has tree real underlying blocks? */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  90) 	__le32	eh_generation;	/* generation of the tree */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  91) };
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  92) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  93) #define EXT4_EXT_MAGIC		cpu_to_le16(0xf30a)
bc890a6024717 fs/ext4/ext4_extents.h          (Theodore Ts'o        2018-06-14 12:55:10 -0400  94) #define EXT4_MAX_EXTENT_DEPTH 5
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700  95) 
7ac5990d5a3e2 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:37:10 -0400  96) #define EXT4_EXTENT_TAIL_OFFSET(hdr) \
7ac5990d5a3e2 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:37:10 -0400  97) 	(sizeof(struct ext4_extent_header) + \
7ac5990d5a3e2 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:37:10 -0400  98) 	 (sizeof(struct ext4_extent) * le16_to_cpu((hdr)->eh_max)))
7ac5990d5a3e2 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:37:10 -0400  99) 
7ac5990d5a3e2 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:37:10 -0400 100) static inline struct ext4_extent_tail *
7ac5990d5a3e2 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:37:10 -0400 101) find_ext4_extent_tail(struct ext4_extent_header *eh)
7ac5990d5a3e2 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:37:10 -0400 102) {
7ac5990d5a3e2 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:37:10 -0400 103) 	return (struct ext4_extent_tail *)(((void *)eh) +
7ac5990d5a3e2 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:37:10 -0400 104) 					   EXT4_EXTENT_TAIL_OFFSET(eh));
7ac5990d5a3e2 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:37:10 -0400 105) }
7ac5990d5a3e2 fs/ext4/ext4_extents.h          (Darrick J. Wong      2012-04-29 18:37:10 -0400 106) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 107) /*
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700 108)  * Array of ext4_ext_path contains path to some extent.
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700 109)  * Creation/lookup routines use it for traversal/splitting/etc.
d0d856e8bd6e6 include/linux/ext4_fs_extents.h (Randy Dunlap         2006-10-11 01:21:07 -0700 110)  * Truncate uses it to simulate recursive walking.
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 111)  */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 112) struct ext4_ext_path {
f65e6fba163df include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:05 -0700 113) 	ext4_fsblk_t			p_block;
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 114) 	__u16				p_depth;
10809df84a4d8 fs/ext4/ext4_extents.h          (Theodore Ts'o        2014-09-01 14:40:09 -0400 115) 	__u16				p_maxdepth;
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 116) 	struct ext4_extent		*p_ext;
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 117) 	struct ext4_extent_idx		*p_idx;
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 118) 	struct ext4_extent_header	*p_hdr;
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 119) 	struct buffer_head		*p_bh;
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 120) };
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 121) 
9fe671496b6c2 fs/ext4/ext4_extents.h          (Eric Whitney         2018-10-01 14:25:08 -0400 122) /*
9fe671496b6c2 fs/ext4/ext4_extents.h          (Eric Whitney         2018-10-01 14:25:08 -0400 123)  * Used to record a portion of a cluster found at the beginning or end
9fe671496b6c2 fs/ext4/ext4_extents.h          (Eric Whitney         2018-10-01 14:25:08 -0400 124)  * of an extent while traversing the extent tree during space removal.
9fe671496b6c2 fs/ext4/ext4_extents.h          (Eric Whitney         2018-10-01 14:25:08 -0400 125)  * A partial cluster may be removed if it does not contain blocks shared
9fe671496b6c2 fs/ext4/ext4_extents.h          (Eric Whitney         2018-10-01 14:25:08 -0400 126)  * with extents that aren't being deleted (tofree state).  Otherwise,
9fe671496b6c2 fs/ext4/ext4_extents.h          (Eric Whitney         2018-10-01 14:25:08 -0400 127)  * it cannot be removed (nofree state).
9fe671496b6c2 fs/ext4/ext4_extents.h          (Eric Whitney         2018-10-01 14:25:08 -0400 128)  */
9fe671496b6c2 fs/ext4/ext4_extents.h          (Eric Whitney         2018-10-01 14:25:08 -0400 129) struct partial_cluster {
9fe671496b6c2 fs/ext4/ext4_extents.h          (Eric Whitney         2018-10-01 14:25:08 -0400 130) 	ext4_fsblk_t pclu;  /* physical cluster number */
9fe671496b6c2 fs/ext4/ext4_extents.h          (Eric Whitney         2018-10-01 14:25:08 -0400 131) 	ext4_lblk_t lblk;   /* logical block number within logical cluster */
9fe671496b6c2 fs/ext4/ext4_extents.h          (Eric Whitney         2018-10-01 14:25:08 -0400 132) 	enum {initial, tofree, nofree} state;
9fe671496b6c2 fs/ext4/ext4_extents.h          (Eric Whitney         2018-10-01 14:25:08 -0400 133) };
9fe671496b6c2 fs/ext4/ext4_extents.h          (Eric Whitney         2018-10-01 14:25:08 -0400 134) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 135) /*
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 136)  * structure for external API
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 137)  */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 138) 
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 139) /*
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 140)  * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 141)  * initialized extent. This is 2^15 and not (2^16 - 1), since we use the
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 142)  * MSB of ee_len field in the extent datastructure to signify if this
556615dcbf38b fs/ext4/ext4_extents.h          (Lukas Czerner        2014-04-20 23:45:47 -0400 143)  * particular extent is an initialized extent or an unwritten (i.e.
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 144)  * preallocated).
556615dcbf38b fs/ext4/ext4_extents.h          (Lukas Czerner        2014-04-20 23:45:47 -0400 145)  * EXT_UNWRITTEN_MAX_LEN is the maximum number of blocks we can have in an
556615dcbf38b fs/ext4/ext4_extents.h          (Lukas Czerner        2014-04-20 23:45:47 -0400 146)  * unwritten extent.
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 147)  * If ee_len is <= 0x8000, it is an initialized extent. Otherwise, it is an
556615dcbf38b fs/ext4/ext4_extents.h          (Lukas Czerner        2014-04-20 23:45:47 -0400 148)  * unwritten one. In other words, if MSB of ee_len is set, it is an
556615dcbf38b fs/ext4/ext4_extents.h          (Lukas Czerner        2014-04-20 23:45:47 -0400 149)  * unwritten extent with only one special scenario when ee_len = 0x8000.
556615dcbf38b fs/ext4/ext4_extents.h          (Lukas Czerner        2014-04-20 23:45:47 -0400 150)  * In this case we can not have an unwritten extent of zero length and
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 151)  * thus we make it as a special case of initialized extent with 0x8000 length.
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 152)  * This way we get better extent-to-group alignment for initialized extents.
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 153)  * Hence, the maximum number of blocks we can have in an *initialized*
556615dcbf38b fs/ext4/ext4_extents.h          (Lukas Czerner        2014-04-20 23:45:47 -0400 154)  * extent is 2^15 (32768) and in an *unwritten* extent is 2^15-1 (32767).
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 155)  */
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 156) #define EXT_INIT_MAX_LEN	(1UL << 15)
556615dcbf38b fs/ext4/ext4_extents.h          (Lukas Czerner        2014-04-20 23:45:47 -0400 157) #define EXT_UNWRITTEN_MAX_LEN	(EXT_INIT_MAX_LEN - 1)
471d4011a9862 include/linux/ext4_fs_extents.h (Suparna Bhattacharya 2006-10-11 01:21:06 -0700 158) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 159) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 160) #define EXT_FIRST_EXTENT(__hdr__) \
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 161) 	((struct ext4_extent *) (((char *) (__hdr__)) +		\
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 162) 				 sizeof(struct ext4_extent_header)))
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 163) #define EXT_FIRST_INDEX(__hdr__) \
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 164) 	((struct ext4_extent_idx *) (((char *) (__hdr__)) +	\
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 165) 				     sizeof(struct ext4_extent_header)))
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 166) #define EXT_HAS_FREE_INDEX(__path__) \
8c55e20411c94 include/linux/ext4_fs_extents.h (Dave Kleikamp        2007-05-24 13:04:54 -0400 167) 	(le16_to_cpu((__path__)->p_hdr->eh_entries) \
8c55e20411c94 include/linux/ext4_fs_extents.h (Dave Kleikamp        2007-05-24 13:04:54 -0400 168) 				     < le16_to_cpu((__path__)->p_hdr->eh_max))
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 169) #define EXT_LAST_EXTENT(__hdr__) \
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 170) 	(EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 171) #define EXT_LAST_INDEX(__hdr__) \
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 172) 	(EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
c36a71b4e35ab fs/ext4/ext4_extents.h          (Harshad Shirwadkar   2020-04-20 19:39:59 -0700 173) #define EXT_MAX_EXTENT(__hdr__)	\
c36a71b4e35ab fs/ext4/ext4_extents.h          (Harshad Shirwadkar   2020-04-20 19:39:59 -0700 174) 	((le16_to_cpu((__hdr__)->eh_max)) ? \
c36a71b4e35ab fs/ext4/ext4_extents.h          (Harshad Shirwadkar   2020-04-20 19:39:59 -0700 175) 	((EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)) \
c36a71b4e35ab fs/ext4/ext4_extents.h          (Harshad Shirwadkar   2020-04-20 19:39:59 -0700 176) 					: 0)
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 177) #define EXT_MAX_INDEX(__hdr__) \
c36a71b4e35ab fs/ext4/ext4_extents.h          (Harshad Shirwadkar   2020-04-20 19:39:59 -0700 178) 	((le16_to_cpu((__hdr__)->eh_max)) ? \
c36a71b4e35ab fs/ext4/ext4_extents.h          (Harshad Shirwadkar   2020-04-20 19:39:59 -0700 179) 	((EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)) : 0)
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 180) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 181) static inline struct ext4_extent_header *ext_inode_hdr(struct inode *inode)
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 182) {
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 183) 	return (struct ext4_extent_header *) EXT4_I(inode)->i_data;
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 184) }
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 185) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 186) static inline struct ext4_extent_header *ext_block_hdr(struct buffer_head *bh)
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 187) {
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 188) 	return (struct ext4_extent_header *) bh->b_data;
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 189) }
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 190) 
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 191) static inline unsigned short ext_depth(struct inode *inode)
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 192) {
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 193) 	return le16_to_cpu(ext_inode_hdr(inode)->eh_depth);
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 194) }
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 195) 
556615dcbf38b fs/ext4/ext4_extents.h          (Lukas Czerner        2014-04-20 23:45:47 -0400 196) static inline void ext4_ext_mark_unwritten(struct ext4_extent *ext)
a2df2a6340780 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-17 21:42:41 -0400 197) {
556615dcbf38b fs/ext4/ext4_extents.h          (Lukas Czerner        2014-04-20 23:45:47 -0400 198) 	/* We can not have an unwritten extent of zero length! */
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 199) 	BUG_ON((le16_to_cpu(ext->ee_len) & ~EXT_INIT_MAX_LEN) == 0);
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 200) 	ext->ee_len |= cpu_to_le16(EXT_INIT_MAX_LEN);
a2df2a6340780 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-17 21:42:41 -0400 201) }
a2df2a6340780 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-17 21:42:41 -0400 202) 
556615dcbf38b fs/ext4/ext4_extents.h          (Lukas Czerner        2014-04-20 23:45:47 -0400 203) static inline int ext4_ext_is_unwritten(struct ext4_extent *ext)
a2df2a6340780 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-17 21:42:41 -0400 204) {
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 205) 	/* Extent with ee_len of 0x8000 is treated as an initialized extent */
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 206) 	return (le16_to_cpu(ext->ee_len) > EXT_INIT_MAX_LEN);
a2df2a6340780 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-17 21:42:41 -0400 207) }
a2df2a6340780 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-17 21:42:41 -0400 208) 
a2df2a6340780 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-17 21:42:41 -0400 209) static inline int ext4_ext_get_actual_len(struct ext4_extent *ext)
a2df2a6340780 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-17 21:42:41 -0400 210) {
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 211) 	return (le16_to_cpu(ext->ee_len) <= EXT_INIT_MAX_LEN ?
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 212) 		le16_to_cpu(ext->ee_len) :
749269facaf87 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-18 09:02:56 -0400 213) 		(le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN));
a2df2a6340780 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-17 21:42:41 -0400 214) }
a2df2a6340780 include/linux/ext4_fs_extents.h (Amit Arora           2007-07-17 21:42:41 -0400 215) 
0031462b5b392 fs/ext4/ext4_extents.h          (Mingming Cao         2009-09-28 15:49:08 -0400 216) static inline void ext4_ext_mark_initialized(struct ext4_extent *ext)
0031462b5b392 fs/ext4/ext4_extents.h          (Mingming Cao         2009-09-28 15:49:08 -0400 217) {
0031462b5b392 fs/ext4/ext4_extents.h          (Mingming Cao         2009-09-28 15:49:08 -0400 218) 	ext->ee_len = cpu_to_le16(ext4_ext_get_actual_len(ext));
0031462b5b392 fs/ext4/ext4_extents.h          (Mingming Cao         2009-09-28 15:49:08 -0400 219) }
0031462b5b392 fs/ext4/ext4_extents.h          (Mingming Cao         2009-09-28 15:49:08 -0400 220) 
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 221) /*
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 222)  * ext4_ext_pblock:
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 223)  * combine low and high parts of physical block number into ext4_fsblk_t
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 224)  */
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 225) static inline ext4_fsblk_t ext4_ext_pblock(struct ext4_extent *ex)
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 226) {
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 227) 	ext4_fsblk_t block;
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 228) 
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 229) 	block = le32_to_cpu(ex->ee_start_lo);
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 230) 	block |= ((ext4_fsblk_t) le16_to_cpu(ex->ee_start_hi) << 31) << 1;
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 231) 	return block;
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 232) }
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 233) 
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 234) /*
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 235)  * ext4_idx_pblock:
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 236)  * combine low and high parts of a leaf physical block number into ext4_fsblk_t
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 237)  */
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 238) static inline ext4_fsblk_t ext4_idx_pblock(struct ext4_extent_idx *ix)
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 239) {
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 240) 	ext4_fsblk_t block;
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 241) 
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 242) 	block = le32_to_cpu(ix->ei_leaf_lo);
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 243) 	block |= ((ext4_fsblk_t) le16_to_cpu(ix->ei_leaf_hi) << 31) << 1;
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 244) 	return block;
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 245) }
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 246) 
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 247) /*
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 248)  * ext4_ext_store_pblock:
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 249)  * stores a large physical block number into an extent struct,
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 250)  * breaking it into parts
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 251)  */
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 252) static inline void ext4_ext_store_pblock(struct ext4_extent *ex,
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 253) 					 ext4_fsblk_t pb)
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 254) {
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 255) 	ex->ee_start_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 256) 	ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) &
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 257) 				      0xffff);
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 258) }
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 259) 
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 260) /*
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 261)  * ext4_idx_store_pblock:
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 262)  * stores a large physical block number into an index struct,
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 263)  * breaking it into parts
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 264)  */
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 265) static inline void ext4_idx_store_pblock(struct ext4_extent_idx *ix,
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 266) 					 ext4_fsblk_t pb)
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 267) {
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 268) 	ix->ei_leaf_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 269) 	ix->ei_leaf_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) &
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 270) 				     0xffff);
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 271) }
bf89d16f6ef53 fs/ext4/ext4_extents.h          (Theodore Ts'o        2010-10-27 21:30:14 -0400 272) 
3dcf54515aa49 fs/ext4/ext4_extents.h          (Christoph Hellwig    2008-04-29 18:13:32 -0400 273) #endif /* _EXT4_EXTENTS */
a86c61812637c include/linux/ext4_fs_extents.h (Alex Tomas           2006-10-11 01:21:03 -0700 274)