ReactOS  0.4.15-dev-4603-gb922b6d
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 2803 of file generic.c.

2805 {
2806  int bit, bit_max;
2807  unsigned free_blocks, group_blocks;
2808  struct ext3_sb_info *sbi = EXT3_SB(sb);
2809 
2810  if (bh) {
2811  mark_buffer_dirty(bh);
2812  /* If checksum is bad mark all blocks used to prevent allocation
2813  * essentially implementing a per-group read-only flag. */
2814  if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
2816  "Checksum bad for group %u", block_group);
2817  ext4_free_blks_set(sb, gdp, 0);
2818  ext4_free_inodes_set(sb, gdp, 0);
2819  ext4_itable_unused_set(sb, gdp, 0);
2820  memset(bh->b_data, 0xff, sb->s_blocksize);
2821  return 0;
2822  }
2823  memset(bh->b_data, 0, sb->s_blocksize);
2824  }
2825 
2826  /* Check for superblock and gdt backups in this group */
2827  bit_max = ext3_bg_has_super(sb, block_group);
2828 
2830  block_group < le32_to_cpu(sbi->s_es->s_first_meta_bg) *
2831  sbi->s_desc_per_block) {
2832  if (bit_max) {
2833  bit_max += ext4_bg_num_gdb(sb, block_group);
2834  bit_max +=
2835  le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks);
2836  }
2837  } else { /* For META_BG_BLOCK_GROUPS */
2838  bit_max += ext4_bg_num_gdb(sb, block_group);
2839  }
2840 
2841  if (block_group == sbi->s_groups_count - 1) {
2842  /*
2843  * Even though mke2fs always initialize first and last group
2844  * if some other tool enabled the EXT4_BG_BLOCK_UNINIT we need
2845  * to make sure we calculate the right free blocks
2846  */
2847  group_blocks = (unsigned int)(ext3_blocks_count(sbi->s_es) -
2848  le32_to_cpu(sbi->s_es->s_first_data_block) -
2849  (EXT4_BLOCKS_PER_GROUP(sb) * (sbi->s_groups_count - 1)));
2850  } else {
2851  group_blocks = EXT4_BLOCKS_PER_GROUP(sb);
2852  }
2853 
2854  free_blocks = group_blocks - bit_max;
2855 
2856  if (bh) {
2857  ext4_fsblk_t start, tmp;
2858  int flex_bg = 0;
2859 
2860  for (bit = 0; bit < bit_max; bit++)
2861  ext4_set_bit(bit, bh->b_data);
2862 
2863  start = ext3_group_first_block_no(sb, block_group);
2864 
2867  flex_bg = 1;
2868 
2869  /* Set bits for block and inode bitmaps, and inode table */
2870  tmp = ext4_block_bitmap(sb, gdp);
2871  if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
2872  ext4_set_bit(tmp - start, bh->b_data);
2873 
2874  tmp = ext4_inode_bitmap(sb, gdp);
2875  if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
2876  ext4_set_bit(tmp - start, bh->b_data);
2877 
2878  tmp = ext4_inode_table(sb, gdp);
2879  for (; tmp < ext4_inode_table(sb, gdp) +
2880  sbi->s_itb_per_group; tmp++) {
2881  if (!flex_bg ||
2882  ext4_block_in_group(sb, tmp, block_group))
2883  ext4_set_bit(tmp - start, bh->b_data);
2884  }
2885  /*
2886  * Also if the number of blocks within the group is
2887  * less than the blocksize * 8 ( which is the size
2888  * of bitmap ), set rest of the block bitmap to 1
2889  */
2890  mark_bitmap_end(group_blocks, sb->s_blocksize * 8, bh->b_data);
2891  }
2892  return free_blocks - ext4_group_used_meta_blocks(sb, block_group);
2893 }
#define le32_to_cpu
Definition: module.h:147
void ext4_free_inodes_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2473
unsigned long ext4_bg_num_gdb(struct super_block *sb, ext4_group_t group)
Definition: generic.c:2648
superblock * sb
Definition: btrfs.c:4230
void ext4_free_blks_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2465
void ext4_itable_unused_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2489
#define EXT4_FEATURE_INCOMPAT_META_BG
Definition: ext3_fs.h:708
int ext4_group_desc_csum_verify(struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2574
void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
Definition: generic.c:2697
unsigned long s_desc_per_block
Definition: ext3_fs_sb.h:39
ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2393
unsigned long long ext4_fsblk_t
Definition: ext3_fs_i.h:27
static int ext4_group_used_meta_blocks(struct super_block *sb, ext4_group_t block_group)
Definition: generic.c:2768
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:906
#define EXT4_FEATURE_INCOMPAT_FLEX_BG
Definition: ext3_fs.h:712
#define le16_to_cpu
Definition: module.h:149
struct ext3_super_block * s_es
Definition: ext3_fs_sb.h:61
#define ext4_set_bit(n, p)
Definition: generic.c:2680
ext4_fsblk_t ext4_inode_table(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2401
#define EXT3_HAS_INCOMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:649
char * b_data
Definition: module.h:725
ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2385
GLuint start
Definition: gl.h:1545
unsigned long s_itb_per_group
Definition: ext3_fs_sb.h:44
static int ext4_block_in_group(struct super_block *sb, ext4_fsblk_t block, ext4_group_t block_group)
Definition: generic.c:2758
int ext3_bg_has_super(struct super_block *sb, ext3_group_t group)
Definition: generic.c:2612
unsigned long s_groups_count
Definition: ext3_fs_sb.h:43
static ext3_fsblk_t ext3_blocks_count(struct ext3_super_block *es)
Definition: ext2fs.h:1692
#define __FUNCTION__
Definition: types.h:112
#define memset(x, y, z)
Definition: compat.h:39
#define ext4_error
Definition: ext2fs.h:2476
#define EXT3_SB(sb)
Definition: ext3_fs.h:615
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

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 2712 of file generic.c.

2715 {
2716  struct ext3_sb_info *sbi = EXT3_SB(sb);
2717 
2718  mark_buffer_dirty(bh);
2719 
2720  /* If checksum is bad mark all blocks and inodes use to prevent
2721  * allocation, essentially implementing a per-group read-only flag. */
2722  if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
2723  ext4_error(sb, __FUNCTION__, "Checksum bad for group %u",
2724  block_group);
2725  ext4_free_blks_set(sb, gdp, 0);
2726  ext4_free_inodes_set(sb, gdp, 0);
2727  ext4_itable_unused_set(sb, gdp, 0);
2728  memset(bh->b_data, 0xff, sb->s_blocksize);
2729  return 0;
2730  }
2731 
2732  memset(bh->b_data, 0, (EXT4_INODES_PER_GROUP(sb) + 7) / 8);
2733  mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8,
2734  bh->b_data);
2735  ext4_itable_unused_set(sb, gdp, EXT4_INODES_PER_GROUP(sb));
2736 
2737  return EXT4_INODES_PER_GROUP(sb);
2738 }
void ext4_free_inodes_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2473
superblock * sb
Definition: btrfs.c:4230
void ext4_free_blks_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2465
void ext4_itable_unused_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2489
int ext4_group_desc_csum_verify(struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2574
void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
Definition: generic.c:2697
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:906
char * b_data
Definition: module.h:725
#define __FUNCTION__
Definition: types.h:112
#define memset(x, y, z)
Definition: compat.h:39
#define ext4_error
Definition: ext2fs.h:2476
#define EXT3_SB(sb)
Definition: ext3_fs.h:615

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 2697 of file generic.c.

2698 {
2699  int i;
2700 
2701  if (start_bit >= end_bit)
2702  return;
2703 
2704  DEBUG(DL_INF, ("mark end bits +%d through +%d used\n", start_bit, end_bit));
2705  for (i = start_bit; (unsigned)i < ((start_bit + 7) & ~7UL); i++)
2706  ext4_set_bit(i, bitmap);
2707  if (i < end_bit)
2708  memset(bitmap + (i >> 3), 0xff, (end_bit - i) >> 3);
2709 }
Definition: uimain.c:88
#define DL_INF
Definition: ext2fs.h:1399
#define ext4_set_bit(n, p)
Definition: generic.c:2680
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
#define DEBUG(args)
Definition: rdesktop.h:129
#define memset(x, y, z)
Definition: compat.h:39
#define UL
Definition: tui.h:148
static unsigned(__cdecl *hash_bstr)(bstr_t s)

Referenced by ext4_init_block_bitmap(), and ext4_init_inode_bitmap().