Unsigned three = 1 in the Linux kernel

See this link (corresponding function inserted below for lazy).

/* * Check that all of the backup GDT blocks are held in the primary GDT block. * It is assumed that they are stored in group order. Returns the number of * groups in current filesystem that have BACKUPS, or -ve error code. */ static int verify_reserved_gdb(struct super_block *sb, ext4_group_t end, struct buffer_head *primary) { const ext4_fsblk_t blk = primary->b_blocknr; unsigned three = 1; unsigned five = 5; unsigned seven = 7; unsigned grp; __le32 *p = (__le32 *)primary->b_data; int gdbackups = 0; while ((grp = ext4_list_backups(sb, &three, &five, &seven)) < end) { if (le32_to_cpu(*p++) != grp * EXT4_BLOCKS_PER_GROUP(sb) + blk){ ext4_warning(sb, "reserved GDT %llu" " missing grp %d (%llu)", blk, grp, grp * (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) + blk); return -EINVAL; } if (++gdbackups > EXT4_ADDR_PER_BLOCK(sb)) return -EFBIG; } return gdbackups; } 

Can someone explain to me why this variable is initialized this way and what this function does?

+7
linux linux-kernel
source share
1 answer

See line 00296 here . Comment says:

 00295 /* 00296 * Iterate through the groups which hold BACKUP superblock/GDT copies in an 00297 * ext4 filesystem. The counters should be initialized to 1, 5, and 7 before 00298 * calling this for the first time. In a sparse filesystem it will be the 00299 * sequence of powers of 3, 5, and 7: 1, 3, 5, 7, 9, 25, 27, 49, 81, ... 00300 * For a non-sparse filesystem it will be every group: 1, 2, 3, 4, ... 00301 */ 

In short, it seems to me that three should be initialized to 1 to enable the ext4_list_backups return 1 function.

+6
source share

All Articles