ReactOS  0.4.15-dev-341-g17c5fb8
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 2810 of file generic.c.

2812 {
2813  int bit, bit_max;
2814  unsigned free_blocks, group_blocks;
2815  struct ext3_sb_info *sbi = EXT3_SB(sb);
2816 
2817  if (bh) {
2818  mark_buffer_dirty(bh);
2819  /* If checksum is bad mark all blocks used to prevent allocation
2820  * essentially implementing a per-group read-only flag. */
2821  if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
2823  "Checksum bad for group %u", block_group);
2824  ext4_free_blks_set(sb, gdp, 0);
2825  ext4_free_inodes_set(sb, gdp, 0);
2826  ext4_itable_unused_set(sb, gdp, 0);
2827  memset(bh->b_data, 0xff, sb->s_blocksize);
2828  return 0;
2829  }
2830  memset(bh->b_data, 0, sb->s_blocksize);
2831  }
2832 
2833  /* Check for superblock and gdt backups in this group */
2834  bit_max = ext3_bg_has_super(sb, block_group);
2835 
2837  block_group < le32_to_cpu(sbi->s_es->s_first_meta_bg) *
2838  sbi->s_desc_per_block) {
2839  if (bit_max) {
2840  bit_max += ext4_bg_num_gdb(sb, block_group);
2841  bit_max +=
2842  le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks);
2843  }
2844  } else { /* For META_BG_BLOCK_GROUPS */
2845  bit_max += ext4_bg_num_gdb(sb, block_group);
2846  }
2847 
2848  if (block_group == sbi->s_groups_count - 1) {
2849  /*
2850  * Even though mke2fs always initialize first and last group
2851  * if some other tool enabled the EXT4_BG_BLOCK_UNINIT we need
2852  * to make sure we calculate the right free blocks
2853  */
2854  group_blocks = (unsigned int)(ext3_blocks_count(sbi->s_es) -
2855  le32_to_cpu(sbi->s_es->s_first_data_block) -
2856  (EXT4_BLOCKS_PER_GROUP(sb) * (sbi->s_groups_count - 1)));
2857  } else {
2858  group_blocks = EXT4_BLOCKS_PER_GROUP(sb);
2859  }
2860 
2861  free_blocks = group_blocks - bit_max;
2862 
2863  if (bh) {
2864  ext4_fsblk_t start, tmp;
2865  int flex_bg = 0;
2866 
2867  for (bit = 0; bit < bit_max; bit++)
2868  ext4_set_bit(bit, bh->b_data);
2869 
2870  start = ext3_group_first_block_no(sb, block_group);
2871 
2874  flex_bg = 1;
2875 
2876  /* Set bits for block and inode bitmaps, and inode table */
2877  tmp = ext4_block_bitmap(sb, gdp);
2878  if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
2879  ext4_set_bit(tmp - start, bh->b_data);
2880 
2881  tmp = ext4_inode_bitmap(sb, gdp);
2882  if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
2883  ext4_set_bit(tmp - start, bh->b_data);
2884 
2885  tmp = ext4_inode_table(sb, gdp);
2886  for (; tmp < ext4_inode_table(sb, gdp) +
2887  sbi->s_itb_per_group; tmp++) {
2888  if (!flex_bg ||
2889  ext4_block_in_group(sb, tmp, block_group))
2890  ext4_set_bit(tmp - start, bh->b_data);
2891  }
2892  /*
2893  * Also if the number of blocks within the group is
2894  * less than the blocksize * 8 ( which is the size
2895  * of bitmap ), set rest of the block bitmap to 1
2896  */
2897  mark_bitmap_end(group_blocks, sb->s_blocksize * 8, bh->b_data);
2898  }
2899  return free_blocks - ext4_group_used_meta_blocks(sb, block_group);
2900 }
void ext4_free_inodes_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2480
unsigned long ext4_bg_num_gdb(struct super_block *sb, ext4_group_t group)
Definition: generic.c:2655
superblock * sb
Definition: btrfs.c:4220
void ext4_free_blks_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2472
void ext4_itable_unused_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2496
#define EXT4_FEATURE_INCOMPAT_META_BG
Definition: ext3_fs.h:708
#define le16_to_cpu
Definition: module.h:149
int ext4_group_desc_csum_verify(struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2581
void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
Definition: generic.c:2704
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:2400
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:2775
#define le32_to_cpu
Definition: module.h:147
#define EXT4_FEATURE_INCOMPAT_FLEX_BG
Definition: ext3_fs.h:712
struct ext3_super_block * s_es
Definition: ext3_fs_sb.h:61
#define ext4_set_bit(n, p)
Definition: generic.c:2687
ext4_fsblk_t ext4_inode_table(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2408
#define EXT3_HAS_INCOMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:649
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:906
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:2392
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:2765
int ext3_bg_has_super(struct super_block *sb, ext3_group_t group)
Definition: generic.c:2619
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 2719 of file generic.c.

2722 {
2723  struct ext3_sb_info *sbi = EXT3_SB(sb);
2724 
2725  mark_buffer_dirty(bh);
2726 
2727  /* If checksum is bad mark all blocks and inodes use to prevent
2728  * allocation, essentially implementing a per-group read-only flag. */
2729  if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
2730  ext4_error(sb, __FUNCTION__, "Checksum bad for group %u",
2731  block_group);
2732  ext4_free_blks_set(sb, gdp, 0);
2733  ext4_free_inodes_set(sb, gdp, 0);
2734  ext4_itable_unused_set(sb, gdp, 0);
2735  memset(bh->b_data, 0xff, sb->s_blocksize);
2736  return 0;
2737  }
2738 
2739  memset(bh->b_data, 0, (EXT4_INODES_PER_GROUP(sb) + 7) / 8);
2740  mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8,
2741  bh->b_data);
2742  ext4_itable_unused_set(sb, gdp, EXT4_INODES_PER_GROUP(sb));
2743 
2744  return EXT4_INODES_PER_GROUP(sb);
2745 }
void ext4_free_inodes_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2480
superblock * sb
Definition: btrfs.c:4220
void ext4_free_blks_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2472
void ext4_itable_unused_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2496
int ext4_group_desc_csum_verify(struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2581
void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
Definition: generic.c:2704
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 2704 of file generic.c.

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

Referenced by ext4_init_block_bitmap(), and ext4_init_inode_bitmap().