ReactOS 0.4.15-dev-7928-g68a8619
group.h File Reference

Go to the source code of this file.

Macros

#define ext4_free_blocks_after_init(sb, group, desc)    ext4_init_block_bitmap(sb, NULL, group, desc)
 

Functions

__le16 ext4_group_desc_csum (struct ext4_sb_info *sbi, __u32 group, struct ext4_group_desc *gdp)
 
int ext4_group_desc_csum_verify (struct ext4_sb_info *sbi, __u32 group, struct ext4_group_desc *gdp)
 
struct buffer_headext4_read_block_bitmap (struct super_block *sb, ext4_group_t block_group)
 
unsigned ext4_init_block_bitmap (struct super_block *sb, struct buffer_head *bh, ext4_group_t group, struct ext4_group_desc *desc)
 
unsigned ext4_init_inode_bitmap (struct super_block *sb, struct buffer_head *bh, ext4_group_t group, struct ext4_group_desc *desc)
 
void mark_bitmap_end (int start_bit, int end_bit, char *bitmap)
 

Macro Definition Documentation

◆ ext4_free_blocks_after_init

#define ext4_free_blocks_after_init (   sb,
  group,
  desc 
)     ext4_init_block_bitmap(sb, NULL, group, desc)

Definition at line 22 of file group.h.

Function Documentation

◆ ext4_group_desc_csum()

__le16 ext4_group_desc_csum ( struct ext4_sb_info sbi,
__u32  group,
struct ext4_group_desc gdp 
)

◆ ext4_group_desc_csum_verify()

int ext4_group_desc_csum_verify ( struct ext4_sb_info sbi,
__u32  group,
struct ext4_group_desc gdp 
)

◆ ext4_init_block_bitmap()

unsigned ext4_init_block_bitmap ( struct super_block sb,
struct buffer_head bh,
ext4_group_t  group,
struct ext4_group_desc desc 
)

Definition at line 2877 of file generic.c.

2879{
2880 int bit, bit_max;
2881 unsigned free_blocks, group_blocks;
2882 struct ext3_sb_info *sbi = EXT3_SB(sb);
2883
2884 if (bh) {
2886 /* If checksum is bad mark all blocks used to prevent allocation
2887 * essentially implementing a per-group read-only flag. */
2888 if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
2890 "Checksum bad for group %u", block_group);
2891 ext4_free_blks_set(sb, gdp, 0);
2892 ext4_free_inodes_set(sb, gdp, 0);
2893 ext4_itable_unused_set(sb, gdp, 0);
2894 memset(bh->b_data, 0xff, sb->s_blocksize);
2895 return 0;
2896 }
2897 memset(bh->b_data, 0, sb->s_blocksize);
2898 }
2899
2900 /* Check for superblock and gdt backups in this group */
2901 bit_max = ext3_bg_has_super(sb, block_group);
2902
2904 block_group < le32_to_cpu(sbi->s_es->s_first_meta_bg) *
2905 sbi->s_desc_per_block) {
2906 if (bit_max) {
2907 bit_max += ext4_bg_num_gdb(sb, block_group);
2908 bit_max +=
2909 le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks);
2910 }
2911 } else { /* For META_BG_BLOCK_GROUPS */
2912 bit_max += ext4_bg_num_gdb(sb, block_group);
2913 }
2914
2915 if (block_group == sbi->s_groups_count - 1) {
2916 /*
2917 * Even though mke2fs always initialize first and last group
2918 * if some other tool enabled the EXT4_BG_BLOCK_UNINIT we need
2919 * to make sure we calculate the right free blocks
2920 */
2921 group_blocks = (unsigned int)(ext3_blocks_count(sbi->s_es) -
2922 le32_to_cpu(sbi->s_es->s_first_data_block) -
2923 (EXT4_BLOCKS_PER_GROUP(sb) * (sbi->s_groups_count - 1)));
2924 } else {
2925 group_blocks = EXT4_BLOCKS_PER_GROUP(sb);
2926 }
2927
2928 free_blocks = group_blocks - bit_max;
2929
2930 if (bh) {
2931 ext4_fsblk_t start, tmp;
2932 int flex_bg = 0;
2933
2934 for (bit = 0; bit < bit_max; bit++)
2935 ext4_set_bit(bit, bh->b_data);
2936
2937 start = ext3_group_first_block_no(sb, block_group);
2938
2941 flex_bg = 1;
2942
2943 /* Set bits for block and inode bitmaps, and inode table */
2944 tmp = ext4_block_bitmap(sb, gdp);
2945 if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
2946 ext4_set_bit(tmp - start, bh->b_data);
2947
2948 tmp = ext4_inode_bitmap(sb, gdp);
2949 if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
2950 ext4_set_bit(tmp - start, bh->b_data);
2951
2952 tmp = ext4_inode_table(sb, gdp);
2953 for (; tmp < ext4_inode_table(sb, gdp) +
2954 sbi->s_itb_per_group; tmp++) {
2955 if (!flex_bg ||
2956 ext4_block_in_group(sb, tmp, block_group))
2957 ext4_set_bit(tmp - start, bh->b_data);
2958 }
2959 /*
2960 * Also if the number of blocks within the group is
2961 * less than the blocksize * 8 ( which is the size
2962 * of bitmap ), set rest of the block bitmap to 1
2963 */
2964 mark_bitmap_end(group_blocks, sb->s_blocksize * 8, bh->b_data);
2965 }
2966 return free_blocks - ext4_group_used_meta_blocks(sb, block_group);
2967}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
superblock * sb
Definition: btrfs.c:4261
#define __FUNCTION__
Definition: types.h:116
static ext3_fsblk_t ext3_blocks_count(struct ext3_super_block *es)
Definition: ext2fs.h:1745
#define ext4_error
Definition: ext2fs.h:2594
#define EXT3_SB(sb)
Definition: ext3_fs.h:615
#define EXT3_HAS_INCOMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:649
#define EXT4_FEATURE_INCOMPAT_FLEX_BG
Definition: ext3_fs.h:712
#define EXT4_FEATURE_INCOMPAT_META_BG
Definition: ext3_fs.h:708
unsigned long long ext4_fsblk_t
Definition: ext3_fs_i.h:27
ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2459
ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2467
static int ext4_group_used_meta_blocks(struct super_block *sb, ext4_group_t block_group)
Definition: generic.c:2842
ext4_fsblk_t ext4_inode_table(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2475
unsigned long ext4_bg_num_gdb(struct super_block *sb, ext4_group_t group)
Definition: generic.c:2722
void ext4_free_blks_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2539
int ext3_bg_has_super(struct super_block *sb, ext3_group_t group)
Definition: generic.c:2686
void ext4_itable_unused_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2563
int ext4_group_desc_csum_verify(struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2648
void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
Definition: generic.c:2771
void ext4_free_inodes_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2547
static int ext4_block_in_group(struct super_block *sb, ext4_fsblk_t block, ext4_group_t block_group)
Definition: generic.c:2832
#define ext4_set_bit(n, p)
Definition: generic.c:2754
GLuint start
Definition: gl.h:1545
#define le16_to_cpu
Definition: module.h:151
#define le32_to_cpu
Definition: module.h:149
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:914
#define memset(x, y, z)
Definition: compat.h:39
char * b_data
Definition: module.h:735
struct ext3_super_block * s_es
Definition: ext3_fs_sb.h:61
unsigned long s_itb_per_group
Definition: ext3_fs_sb.h:44
unsigned long s_desc_per_block
Definition: ext3_fs_sb.h:39
unsigned long s_groups_count
Definition: ext3_fs_sb.h:43

Referenced by Ext2NewBlock(), and Ext2NewInode().

◆ ext4_init_inode_bitmap()

unsigned ext4_init_inode_bitmap ( struct super_block sb,
struct buffer_head bh,
ext4_group_t  group,
struct ext4_group_desc desc 
)

Definition at line 2786 of file generic.c.

2789{
2790 struct ext3_sb_info *sbi = EXT3_SB(sb);
2791
2793
2794 /* If checksum is bad mark all blocks and inodes use to prevent
2795 * allocation, essentially implementing a per-group read-only flag. */
2796 if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
2797 ext4_error(sb, __FUNCTION__, "Checksum bad for group %u",
2798 block_group);
2799 ext4_free_blks_set(sb, gdp, 0);
2800 ext4_free_inodes_set(sb, gdp, 0);
2801 ext4_itable_unused_set(sb, gdp, 0);
2802 memset(bh->b_data, 0xff, sb->s_blocksize);
2803 return 0;
2804 }
2805
2806 memset(bh->b_data, 0, (EXT4_INODES_PER_GROUP(sb) + 7) / 8);
2807 mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8,
2808 bh->b_data);
2809 ext4_itable_unused_set(sb, gdp, EXT4_INODES_PER_GROUP(sb));
2810
2811 return EXT4_INODES_PER_GROUP(sb);
2812}

Referenced by Ext2NewInode().

◆ ext4_read_block_bitmap()

struct buffer_head * ext4_read_block_bitmap ( struct super_block sb,
ext4_group_t  block_group 
)

◆ mark_bitmap_end()

void mark_bitmap_end ( int  start_bit,
int  end_bit,
char bitmap 
)

Definition at line 2771 of file generic.c.

2772{
2773 int i;
2774
2775 if (start_bit >= end_bit)
2776 return;
2777
2778 DEBUG(DL_INF, ("mark end bits +%d through +%d used\n", start_bit, end_bit));
2779 for (i = start_bit; (unsigned)i < ((start_bit + 7) & ~7UL); i++)
2781 if (i < end_bit)
2782 memset(bitmap + (i >> 3), 0xff, (end_bit - i) >> 3);
2783}
#define DEBUG(args)
Definition: rdesktop.h:129
#define DL_INF
Definition: ext2fs.h:1436
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static unsigned(__cdecl *hash_bstr)(bstr_t s)
Definition: uimain.c:89

Referenced by ext4_init_block_bitmap(), and ext4_init_inode_bitmap().