CC: [email protected]
CC: [email protected]
CC: Linux Memory Management List <[email protected]>
TO: "Matthew Wilcox (Oracle)" <[email protected]>
CC: Christoph Hellwig <[email protected]>
CC: William Kucharski <[email protected]>
CC: David Howells <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
master
head:   42d0b5f52c9b633a10626da27786049c76d4ea75
commit: 8c02d1a1387610edb84cd5f5fcbc78adcd0591cf [2247/3590] mm: Add folio flag 
manipulation functions
:::::: branch date: 7 hours ago
:::::: commit date: 7 days ago
config: x86_64-randconfig-c001-20210727 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 
c658b472f3e61e1818e1909bf02f3d65470018a5)
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=8c02d1a1387610edb84cd5f5fcbc78adcd0591cf
        git remote add linux-next 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
        git fetch --no-tags linux-next master
        git checkout 8c02d1a1387610edb84cd5f5fcbc78adcd0591cf
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 
clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


clang-analyzer warnings: (new ones prefixed by >>)
           ^
   fs/ext4/mballoc.c:1521:6: note: Assuming 'page' is equal to NULL
           if (page == NULL || !PageUptodate(page)) {
               ^~~~~~~~~~~~
   fs/ext4/mballoc.c:1521:19: note: Left side of '||' is true
           if (page == NULL || !PageUptodate(page)) {
                            ^
   fs/ext4/mballoc.c:1522:7: note: 'page' is null
                   if (page)
                       ^~~~
   fs/ext4/mballoc.c:1522:3: note: Taking false branch
                   if (page)
                   ^
   fs/ext4/mballoc.c:1533:7: note: Assuming 'page' is non-null
                   if (page) {
                       ^~~~
   fs/ext4/mballoc.c:1533:3: note: Taking true branch
                   if (page) {
                   ^
   fs/ext4/mballoc.c:1534:11: note: Assuming field 'mapping' is equal to field 
'i_mapping'
                           BUG_ON(page->mapping != inode->i_mapping);
                                  ^
   include/asm-generic/bug.h:65:45: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                                               ^~~~~~~~~
   include/linux/compiler.h:48:41: note: expanded from macro 'unlikely'
   #  define unlikely(x)   (__branch_check__(x, 0, __builtin_constant_p(x)))
                                             ^
   include/linux/compiler.h:33:34: note: expanded from macro '__branch_check__'
                           ______r = __builtin_expect(!!(x), expect);      \
                                                         ^
   fs/ext4/mballoc.c:1534:17: note: Field 'mapping' is equal to field 
'i_mapping'
                           BUG_ON(page->mapping != inode->i_mapping);
                                        ^
   fs/ext4/mballoc.c:1534:4: note: Taking false branch
                           BUG_ON(page->mapping != inode->i_mapping);
                           ^
   include/asm-generic/bug.h:65:32: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                                  ^
   fs/ext4/mballoc.c:1534:4: note: Loop condition is false.  Exiting loop
                           BUG_ON(page->mapping != inode->i_mapping);
                           ^
   include/asm-generic/bug.h:65:27: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                             ^
   fs/ext4/mballoc.c:1535:4: note: Taking true branch
                           if (!PageUptodate(page)) {
                           ^
   fs/ext4/mballoc.c:1536:11: note: Calling 'ext4_mb_init_cache'
                                   ret = ext4_mb_init_cache(page, NULL, gfp);
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:1203:2: note: Taking false branch
           mb_debug(sb, "init page %lu\n", page->index);
           ^
   fs/ext4/mballoc.h:31:2: note: expanded from macro 'mb_debug'
           pr_debug("[%s/%d] EXT4-fs (%s): (%s, %d): %s: " fmt,            \
           ^
   include/linux/printk.h:477:2: note: expanded from macro 'pr_debug'
           no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
           ^
   include/linux/printk.h:140:2: note: expanded from macro 'no_printk'
           if (0)                                          \
           ^
   fs/ext4/mballoc.c:1206:6: note: Assuming 'groups_per_page' is not equal to 0
           if (groups_per_page == 0)
               ^~~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:1206:2: note: Taking false branch
           if (groups_per_page == 0)
           ^
   fs/ext4/mballoc.c:1210:6: note: Assuming 'groups_per_page' is <= 1
           if (groups_per_page > 1) {
               ^~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:1210:2: note: Taking false branch
           if (groups_per_page > 1) {
           ^
   fs/ext4/mballoc.c:1223:35: note: Assuming 'i' is < 'groups_per_page'
           for (i = 0, group = first_group; i < groups_per_page; i++, group++) {
                                            ^~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:1223:2: note: Loop condition is true.  Entering loop body
           for (i = 0, group = first_group; i < groups_per_page; i++, group++) {
           ^
   fs/ext4/mballoc.c:1224:7: note: Assuming 'group' is >= 'ngroups'
                   if (group >= ngroups)
                       ^~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:1224:3: note: Taking true branch
                   if (group >= ngroups)
                   ^
   fs/ext4/mballoc.c:1225:4: note:  Execution continues on line 1248
                           break;
                           ^
   fs/ext4/mballoc.c:1248:7: note: The value 0 is assigned to 'i'
           for (i = 0, group = first_group; i < groups_per_page; i++, group++) {
                ^~~~~
   fs/ext4/mballoc.c:1248:2: note: Loop condition is true.  Entering loop body
           for (i = 0, group = first_group; i < groups_per_page; i++, group++) {
           ^
   fs/ext4/mballoc.c:1251:7: note: Branch condition evaluates to a garbage value
                   if (!bh[i])
                       ^~~~~~
>> fs/ext4/mballoc.c:1333:4: warning: 1st function call argument is an 
>> uninitialized value [clang-analyzer-core.CallAndMessage]
                           brelse(bh[i]);
                           ^
   fs/ext4/mballoc.c:6341:6: note: Assuming 'minlen' is <= field 
's_clusters_per_group'
           if (minlen > EXT4_CLUSTERS_PER_GROUP(sb) ||
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:6341:6: note: Left side of '||' is false
   fs/ext4/mballoc.c:6342:6: note: Assuming 'start' is < 'max_blks'
               start >= max_blks ||
               ^~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:6341:6: note: Left side of '||' is false
           if (minlen > EXT4_CLUSTERS_PER_GROUP(sb) ||
               ^
   fs/ext4/mballoc.c:6343:6: note: Assuming field 'len' is >= field 
's_blocksize'
               range->len < sb->s_blocksize)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:6341:2: note: Taking false branch
           if (minlen > EXT4_CLUSTERS_PER_GROUP(sb) ||
           ^
   fs/ext4/mballoc.c:6345:6: note: Assuming 'end' is < 'max_blks'
           if (end >= max_blks)
               ^~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:6345:2: note: Taking false branch
           if (end >= max_blks)
           ^
   fs/ext4/mballoc.c:6347:6: note: Assuming 'end' is > 'first_data_blk'
           if (end <= first_data_blk)
               ^~~~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:6347:2: note: Taking false branch
           if (end <= first_data_blk)
           ^
   fs/ext4/mballoc.c:6349:6: note: Assuming 'start' is >= 'first_data_blk'
           if (start < first_data_blk)
               ^~~~~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:6349:2: note: Taking false branch
           if (start < first_data_blk)
           ^
   fs/ext4/mballoc.c:6361:28: note: Assuming 'group' is <= 'last_group'
           for (group = first_group; group <= last_group; group++) {
                                     ^~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:6361:2: note: Loop condition is true.  Entering loop body
           for (group = first_group; group <= last_group; group++) {
           ^
   fs/ext4/mballoc.c:6364:7: note: Assuming the condition is false
                   if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) {
                       ^
   include/linux/compiler.h:48:24: note: expanded from macro 'unlikely'
   #  define unlikely(x)   (__branch_check__(x, 0, __builtin_constant_p(x)))
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:23:50: note: expanded from macro '__branch_check__'
   #define __branch_check__(x, expect, is_constant) ({                     \
                                                    ^~~~~~~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:6364:3: note: Taking false branch
                   if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) {
                   ^
   fs/ext4/mballoc.c:6376:7: note: Assuming 'group' is not equal to 'last_group'
                   if (group == last_group)
                       ^~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:6376:3: note: Taking false branch
                   if (group == last_group)
                   ^
   fs/ext4/mballoc.c:6379:7: note: Assuming 'minlen' is <= field 'bb_free'
                   if (grp->bb_free >= minlen) {
                       ^~~~~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:6379:3: note: Taking true branch
                   if (grp->bb_free >= minlen) {
                   ^
   fs/ext4/mballoc.c:6380:10: note: Calling 'ext4_trim_all_free'
                           cnt = ext4_trim_all_free(sb, group, first_cluster,
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:6251:8: note: Calling 'ext4_mb_load_buddy'
           ret = ext4_mb_load_buddy(sb, group, &e4b);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:1612:9: note: Calling 'ext4_mb_load_buddy_gfp'
           return ext4_mb_load_buddy_gfp(sb, group, e4b, GFP_NOFS);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/ext4/mballoc.c:1486:2: note: Loop condition is false.  Exiting loop
           might_sleep();
           ^
   include/linux/kernel.h:132:2: note: expanded from macro 'might_sleep'
           do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while 
(0)
           ^
   fs/ext4/mballoc.c:1487:2: note: Taking false branch
           mb_debug(sb, "load group %u\n", group);
           ^
   fs/ext4/mballoc.h:31:2: note: expanded from macro 'mb_debug'
           pr_debug("[%s/%d] EXT4-fs (%s): (%s, %d): %s: " fmt,            \
           ^
   include/linux/printk.h:477:2: note: expanded from macro 'pr_debug'
           no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
           ^
   include/linux/printk.h:140:2: note: expanded from macro 'no_printk'
           if (0)                                          \
           ^
   fs/ext4/mballoc.c:1499:6: note: Assuming the condition is true
           if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) {
               ^
   include/linux/compiler.h:48:24: note: expanded from macro 'unlikely'
   #  define unlikely(x)   (__branch_check__(x, 0, __builtin_constant_p(x)))
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:23:50: note: expanded from macro '__branch_check__'

vim +1333 fs/ext4/mballoc.c

c9de560ded61fa Alex Tomas            2008-01-29  1158  
c9de560ded61fa Alex Tomas            2008-01-29  1159  /* The buddy information 
is attached the buddy cache inode
c9de560ded61fa Alex Tomas            2008-01-29  1160   * for convenience. The 
information regarding each group
c9de560ded61fa Alex Tomas            2008-01-29  1161   * is loaded via 
ext4_mb_load_buddy. The information involve
c9de560ded61fa Alex Tomas            2008-01-29  1162   * block bitmap and 
buddy information. The information are
c9de560ded61fa Alex Tomas            2008-01-29  1163   * stored in the inode as
c9de560ded61fa Alex Tomas            2008-01-29  1164   *
c9de560ded61fa Alex Tomas            2008-01-29  1165   * {                     
   page                        }
c3a326a657562d Aneesh Kumar K.V      2008-11-25  1166   * [ group 0 bitmap][ 
group 0 buddy] [group 1][ group 1]...
c9de560ded61fa Alex Tomas            2008-01-29  1167   *
c9de560ded61fa Alex Tomas            2008-01-29  1168   *
c9de560ded61fa Alex Tomas            2008-01-29  1169   * one block each for 
bitmap and buddy information.
c9de560ded61fa Alex Tomas            2008-01-29  1170   * So for each group we 
take up 2 blocks. A page can
ea1754a084760e Kirill A. Shutemov    2016-04-01  1171   * contain 
blocks_per_page (PAGE_SIZE / blocksize)  blocks.
c9de560ded61fa Alex Tomas            2008-01-29  1172   * So it can have 
information regarding groups_per_page which
c9de560ded61fa Alex Tomas            2008-01-29  1173   * is blocks_per_page/2
8a57d9d61a6e36 Curt Wohlgemuth       2010-05-16  1174   *
8a57d9d61a6e36 Curt Wohlgemuth       2010-05-16  1175   * Locking note:  This 
routine takes the block group lock of all groups
8a57d9d61a6e36 Curt Wohlgemuth       2010-05-16  1176   * for this page; do not 
hold this lock when calling this routine!
c9de560ded61fa Alex Tomas            2008-01-29  1177   */
c9de560ded61fa Alex Tomas            2008-01-29  1178  
adb7ef600cc9d9 Konstantin Khlebnikov 2016-03-13  1179  static int 
ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
c9de560ded61fa Alex Tomas            2008-01-29  1180  {
8df9675f8b498d Theodore Ts'o         2009-05-01  1181   ext4_group_t ngroups;
c9de560ded61fa Alex Tomas            2008-01-29  1182   int blocksize;
c9de560ded61fa Alex Tomas            2008-01-29  1183   int blocks_per_page;
c9de560ded61fa Alex Tomas            2008-01-29  1184   int groups_per_page;
c9de560ded61fa Alex Tomas            2008-01-29  1185   int err = 0;
c9de560ded61fa Alex Tomas            2008-01-29  1186   int i;
813e57276fd909 Theodore Ts'o         2012-02-20  1187   ext4_group_t 
first_group, group;
c9de560ded61fa Alex Tomas            2008-01-29  1188   int first_block;
c9de560ded61fa Alex Tomas            2008-01-29  1189   struct super_block *sb;
c9de560ded61fa Alex Tomas            2008-01-29  1190   struct buffer_head *bhs;
fa77dcfafeaa6b Darrick J. Wong       2012-04-29  1191   struct buffer_head **bh 
= NULL;
c9de560ded61fa Alex Tomas            2008-01-29  1192   struct inode *inode;
c9de560ded61fa Alex Tomas            2008-01-29  1193   char *data;
c9de560ded61fa Alex Tomas            2008-01-29  1194   char *bitmap;
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1195   struct ext4_group_info 
*grinfo;
c9de560ded61fa Alex Tomas            2008-01-29  1196  
c9de560ded61fa Alex Tomas            2008-01-29  1197   inode = 
page->mapping->host;
c9de560ded61fa Alex Tomas            2008-01-29  1198   sb = inode->i_sb;
8df9675f8b498d Theodore Ts'o         2009-05-01  1199   ngroups = 
ext4_get_groups_count(sb);
93407472a21b82 Fabian Frederick      2017-02-27  1200   blocksize = 
i_blocksize(inode);
09cbfeaf1a5a67 Kirill A. Shutemov    2016-04-01  1201   blocks_per_page = 
PAGE_SIZE / blocksize;
c9de560ded61fa Alex Tomas            2008-01-29  1202  
d3df14535f4a5b Ritesh Harjani        2020-05-10  1203   mb_debug(sb, "init page 
%lu\n", page->index);
d3df14535f4a5b Ritesh Harjani        2020-05-10  1204  
c9de560ded61fa Alex Tomas            2008-01-29  1205   groups_per_page = 
blocks_per_page >> 1;
c9de560ded61fa Alex Tomas            2008-01-29  1206   if (groups_per_page == 
0)
c9de560ded61fa Alex Tomas            2008-01-29  1207           groups_per_page 
= 1;
c9de560ded61fa Alex Tomas            2008-01-29  1208  
c9de560ded61fa Alex Tomas            2008-01-29  1209   /* allocate 
buffer_heads to read bitmaps */
c9de560ded61fa Alex Tomas            2008-01-29  1210   if (groups_per_page > 
1) {
c9de560ded61fa Alex Tomas            2008-01-29  1211           i = 
sizeof(struct buffer_head *) * groups_per_page;
adb7ef600cc9d9 Konstantin Khlebnikov 2016-03-13  1212           bh = kzalloc(i, 
gfp);
813e57276fd909 Theodore Ts'o         2012-02-20  1213           if (bh == NULL) 
{
813e57276fd909 Theodore Ts'o         2012-02-20  1214                   err = 
-ENOMEM;
c9de560ded61fa Alex Tomas            2008-01-29  1215                   goto 
out;
813e57276fd909 Theodore Ts'o         2012-02-20  1216           }
c9de560ded61fa Alex Tomas            2008-01-29  1217   } else
c9de560ded61fa Alex Tomas            2008-01-29  1218           bh = &bhs;
c9de560ded61fa Alex Tomas            2008-01-29  1219  
c9de560ded61fa Alex Tomas            2008-01-29  1220   first_group = 
page->index * blocks_per_page / 2;
c9de560ded61fa Alex Tomas            2008-01-29  1221  
c9de560ded61fa Alex Tomas            2008-01-29  1222   /* read all groups the 
page covers into the cache */
813e57276fd909 Theodore Ts'o         2012-02-20  1223   for (i = 0, group = 
first_group; i < groups_per_page; i++, group++) {
813e57276fd909 Theodore Ts'o         2012-02-20  1224           if (group >= 
ngroups)
c9de560ded61fa Alex Tomas            2008-01-29  1225                   break;
c9de560ded61fa Alex Tomas            2008-01-29  1226  
813e57276fd909 Theodore Ts'o         2012-02-20  1227           grinfo = 
ext4_get_group_info(sb, group);
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1228           /*
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1229            * If page is 
uptodate then we came here after online resize
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1230            * which added 
some new uninitialized group info structs, so
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1231            * we must skip 
all initialized uptodate buddies on the page,
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1232            * which may be 
currently in use by an allocating task.
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1233            */
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1234           if 
(PageUptodate(page) && !EXT4_MB_GRP_NEED_INIT(grinfo)) {
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1235                   bh[i] = 
NULL;
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1236                   
continue;
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1237           }
cfd73237722135 Alex Zhuravlev        2020-04-21  1238           bh[i] = 
ext4_read_block_bitmap_nowait(sb, group, false);
9008a58e5dcee0 Darrick J. Wong       2015-10-17  1239           if 
(IS_ERR(bh[i])) {
9008a58e5dcee0 Darrick J. Wong       2015-10-17  1240                   err = 
PTR_ERR(bh[i]);
9008a58e5dcee0 Darrick J. Wong       2015-10-17  1241                   bh[i] = 
NULL;
c9de560ded61fa Alex Tomas            2008-01-29  1242                   goto 
out;
2ccb5fb9f113da Aneesh Kumar K.V      2009-01-05  1243           }
d3df14535f4a5b Ritesh Harjani        2020-05-10  1244           mb_debug(sb, 
"read bitmap for group %u\n", group);
c9de560ded61fa Alex Tomas            2008-01-29  1245   }
c9de560ded61fa Alex Tomas            2008-01-29  1246  
c9de560ded61fa Alex Tomas            2008-01-29  1247   /* wait for I/O 
completion */
813e57276fd909 Theodore Ts'o         2012-02-20  1248   for (i = 0, group = 
first_group; i < groups_per_page; i++, group++) {
9008a58e5dcee0 Darrick J. Wong       2015-10-17  1249           int err2;
9008a58e5dcee0 Darrick J. Wong       2015-10-17  1250  
9008a58e5dcee0 Darrick J. Wong       2015-10-17  1251           if (!bh[i])
9008a58e5dcee0 Darrick J. Wong       2015-10-17  1252                   
continue;
9008a58e5dcee0 Darrick J. Wong       2015-10-17  1253           err2 = 
ext4_wait_block_bitmap(sb, group, bh[i]);
9008a58e5dcee0 Darrick J. Wong       2015-10-17  1254           if (!err)
9008a58e5dcee0 Darrick J. Wong       2015-10-17  1255                   err = 
err2;
813e57276fd909 Theodore Ts'o         2012-02-20  1256   }
c9de560ded61fa Alex Tomas            2008-01-29  1257  
c9de560ded61fa Alex Tomas            2008-01-29  1258   first_block = 
page->index * blocks_per_page;
c9de560ded61fa Alex Tomas            2008-01-29  1259   for (i = 0; i < 
blocks_per_page; i++) {
c9de560ded61fa Alex Tomas            2008-01-29  1260           group = 
(first_block + i) >> 1;
8df9675f8b498d Theodore Ts'o         2009-05-01  1261           if (group >= 
ngroups)
c9de560ded61fa Alex Tomas            2008-01-29  1262                   break;
c9de560ded61fa Alex Tomas            2008-01-29  1263  
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1264           if (!bh[group - 
first_group])
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1265                   /* skip 
initialized uptodate buddy */
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1266                   
continue;
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1267  
bbdc322f2c6006 Lukas Czerner         2015-06-08  1268           if 
(!buffer_verified(bh[group - first_group]))
bbdc322f2c6006 Lukas Czerner         2015-06-08  1269                   /* Skip 
faulty bitmaps */
bbdc322f2c6006 Lukas Czerner         2015-06-08  1270                   
continue;
bbdc322f2c6006 Lukas Czerner         2015-06-08  1271           err = 0;
bbdc322f2c6006 Lukas Czerner         2015-06-08  1272  
c9de560ded61fa Alex Tomas            2008-01-29  1273           /*
c9de560ded61fa Alex Tomas            2008-01-29  1274            * data carry 
information regarding this
c9de560ded61fa Alex Tomas            2008-01-29  1275            * particular 
group in the format specified
c9de560ded61fa Alex Tomas            2008-01-29  1276            * above
c9de560ded61fa Alex Tomas            2008-01-29  1277            *
c9de560ded61fa Alex Tomas            2008-01-29  1278            */
c9de560ded61fa Alex Tomas            2008-01-29  1279           data = 
page_address(page) + (i * blocksize);
c9de560ded61fa Alex Tomas            2008-01-29  1280           bitmap = 
bh[group - first_group]->b_data;
c9de560ded61fa Alex Tomas            2008-01-29  1281  
c9de560ded61fa Alex Tomas            2008-01-29  1282           /*
c9de560ded61fa Alex Tomas            2008-01-29  1283            * We place the 
buddy block and bitmap block
c9de560ded61fa Alex Tomas            2008-01-29  1284            * close 
together
c9de560ded61fa Alex Tomas            2008-01-29  1285            */
c9de560ded61fa Alex Tomas            2008-01-29  1286           if 
((first_block + i) & 1) {
c9de560ded61fa Alex Tomas            2008-01-29  1287                   /* this 
is block of buddy */
c9de560ded61fa Alex Tomas            2008-01-29  1288                   
BUG_ON(incore == NULL);
d3df14535f4a5b Ritesh Harjani        2020-05-10  1289                   
mb_debug(sb, "put buddy for group %u in page %lu/%x\n",
c9de560ded61fa Alex Tomas            2008-01-29  1290                           
group, page->index, i * blocksize);
f307333e14f6b1 Theodore Ts'o         2010-05-17  1291                   
trace_ext4_mb_buddy_bitmap_load(sb, group);
c9de560ded61fa Alex Tomas            2008-01-29  1292                   grinfo 
= ext4_get_group_info(sb, group);
c9de560ded61fa Alex Tomas            2008-01-29  1293                   
grinfo->bb_fragments = 0;
c9de560ded61fa Alex Tomas            2008-01-29  1294                   
memset(grinfo->bb_counters, 0,
1927805e6599d8 Eric Sandeen          2009-08-25  1295                          
sizeof(*grinfo->bb_counters) *
4b68f6df105966 Harshad Shirwadkar    2021-04-01  1296                          
(MB_NUM_ORDERS(sb)));
c9de560ded61fa Alex Tomas            2008-01-29  1297                   /*
c9de560ded61fa Alex Tomas            2008-01-29  1298                    * 
incore got set to the group block bitmap below
c9de560ded61fa Alex Tomas            2008-01-29  1299                    */
7a2fcbf7f85737 Aneesh Kumar K.V      2009-01-05  1300                   
ext4_lock_group(sb, group);
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1301                   /* init 
the buddy */
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1302                   
memset(data, 0xff, blocksize);
c9de560ded61fa Alex Tomas            2008-01-29  1303                   
ext4_mb_generate_buddy(sb, data, incore, group);
7a2fcbf7f85737 Aneesh Kumar K.V      2009-01-05  1304                   
ext4_unlock_group(sb, group);
c9de560ded61fa Alex Tomas            2008-01-29  1305                   incore 
= NULL;
c9de560ded61fa Alex Tomas            2008-01-29  1306           } else {
c9de560ded61fa Alex Tomas            2008-01-29  1307                   /* this 
is block of bitmap */
c9de560ded61fa Alex Tomas            2008-01-29  1308                   
BUG_ON(incore != NULL);
d3df14535f4a5b Ritesh Harjani        2020-05-10  1309                   
mb_debug(sb, "put bitmap for group %u in page %lu/%x\n",
c9de560ded61fa Alex Tomas            2008-01-29  1310                           
group, page->index, i * blocksize);
f307333e14f6b1 Theodore Ts'o         2010-05-17  1311                   
trace_ext4_mb_bitmap_load(sb, group);
c9de560ded61fa Alex Tomas            2008-01-29  1312  
c9de560ded61fa Alex Tomas            2008-01-29  1313                   /* see 
comments in ext4_mb_put_pa() */
c9de560ded61fa Alex Tomas            2008-01-29  1314                   
ext4_lock_group(sb, group);
c9de560ded61fa Alex Tomas            2008-01-29  1315                   
memcpy(data, bitmap, blocksize);
c9de560ded61fa Alex Tomas            2008-01-29  1316  
c9de560ded61fa Alex Tomas            2008-01-29  1317                   /* mark 
all preallocated blks used in in-core bitmap */
c9de560ded61fa Alex Tomas            2008-01-29  1318                   
ext4_mb_generate_from_pa(sb, data, group);
7a2fcbf7f85737 Aneesh Kumar K.V      2009-01-05  1319                   
ext4_mb_generate_from_freelist(sb, data, group);
c9de560ded61fa Alex Tomas            2008-01-29  1320                   
ext4_unlock_group(sb, group);
c9de560ded61fa Alex Tomas            2008-01-29  1321  
c9de560ded61fa Alex Tomas            2008-01-29  1322                   /* set 
incore so that the buddy information can be
c9de560ded61fa Alex Tomas            2008-01-29  1323                    * 
generated using this
c9de560ded61fa Alex Tomas            2008-01-29  1324                    */
c9de560ded61fa Alex Tomas            2008-01-29  1325                   incore 
= data;
c9de560ded61fa Alex Tomas            2008-01-29  1326           }
c9de560ded61fa Alex Tomas            2008-01-29  1327   }
c9de560ded61fa Alex Tomas            2008-01-29  1328   SetPageUptodate(page);
c9de560ded61fa Alex Tomas            2008-01-29  1329  
c9de560ded61fa Alex Tomas            2008-01-29  1330  out:
c9de560ded61fa Alex Tomas            2008-01-29  1331   if (bh) {
9b8b7d353f5f9b Amir Goldstein        2011-05-09  1332           for (i = 0; i < 
groups_per_page; i++)
c9de560ded61fa Alex Tomas            2008-01-29 @1333                   
brelse(bh[i]);
c9de560ded61fa Alex Tomas            2008-01-29  1334           if (bh != &bhs)
c9de560ded61fa Alex Tomas            2008-01-29  1335                   
kfree(bh);
c9de560ded61fa Alex Tomas            2008-01-29  1336   }
c9de560ded61fa Alex Tomas            2008-01-29  1337   return err;
c9de560ded61fa Alex Tomas            2008-01-29  1338  }
c9de560ded61fa Alex Tomas            2008-01-29  1339  

:::::: The code at line 1333 was first introduced by commit
:::::: c9de560ded61faa5b754137b7753da252391c55a ext4: Add multi block allocator 
for ext4

:::::: TO: Alex Tomas <[email protected]>
:::::: CC: Theodore Ts'o <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to