Linux内核中unsigned three = 1

前端之家收集整理的这篇文章主要介绍了Linux内核中unsigned three = 1前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
this link(懒惰的相关功能粘贴在下面).
  1. /*
  2. * Check that all of the backup GDT blocks are held in the primary GDT block.
  3. * It is assumed that they are stored in group order. Returns the number of
  4. * groups in current filesystem that have BACKUPS,or -ve error code.
  5. */
  6. static int verify_reserved_gdb(struct super_block *sb,ext4_group_t end,struct buffer_head *primary)
  7. {
  8. const ext4_fsblk_t blk = primary->b_blocknr;
  9. unsigned three = 1;
  10. unsigned five = 5;
  11. unsigned seven = 7;
  12. unsigned grp;
  13. __le32 *p = (__le32 *)primary->b_data;
  14. int gdbackups = 0;
  15.  
  16. while ((grp = ext4_list_backups(sb,&three,&five,&seven)) < end) {
  17. if (le32_to_cpu(*p++) !=
  18. grp * EXT4_BLOCKS_PER_GROUP(sb) + blk){
  19. ext4_warning(sb,"reserved GDT %llu"
  20. " missing grp %d (%llu)",blk,grp,grp *
  21. (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) +
  22. blk);
  23. return -EINVAL;
  24. }
  25. if (++gdbackups > EXT4_ADDR_PER_BLOCK(sb))
  26. return -EFBIG;
  27. }
  28.  
  29. return gdbackups;
  30. }

有人可以向我解释为什么这个变量是这样初始化的,这个函数在做什么?

解决方法

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

总之,在我看来应该将三个初始化为1来启用函数ext4_list_backups返回1.

猜你在找的Linux相关文章