tree:
https://git.kernel.org/pub/scm/linux/kernel/git/sashal/linux-stable.git
queue-4.19
head: 9e0a13e7641ee6031e5d210f1f81fd731a3bf3e1
commit: 10ee8b8d6462a56a3788ab91e595e78e2ca755b0 [180/184] ext4: adjust reserved cluster
count when removing extents
config: i386-randconfig-s002-20200622 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-dirty
git checkout 10ee8b8d6462a56a3788ab91e595e78e2ca755b0
# save the attached .config to linux build tree
make W=1 C=1 ARCH=i386 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All errors (new ones prefixed by >>):
fs/ext4/extents.c:1005:13: sparse: sparse: Using plain integer as NULL pointer
fs/ext4/extents.c:1056:13: sparse: sparse: Using plain integer as NULL pointer
fs/ext4/extents.c:1060:34: sparse: sparse: Using plain integer as NULL pointer
fs/ext4/extents.c:1132:13: sparse: sparse: Using plain integer as NULL pointer
fs/ext4/extents.c:1206:21: sparse: sparse: Using plain integer as NULL pointer
fs/ext4/extents.c:1215:21: sparse: sparse: Using plain integer as NULL pointer
fs/ext4/extents.c:1216:17: sparse: sparse: Using plain integer as NULL pointer
fs/ext4/extents.c:2545:9: sparse: sparse: undefined identifier
'ext4_remove_pending'
fs/ext4/extents.c:2593:29: sparse: sparse: undefined identifier
'ext4_is_pending'
fs/ext4/extents.c:2619:21: sparse: sparse: undefined identifier
'ext4_is_pending'
fs/ext4/extents.c:2854:29: sparse: sparse: undefined identifier
'ext4_is_pending'
fs/ext4/extents.c:3117:21: sparse: sparse: undefined identifier
'ext4_is_pending'
fs/ext4/extents.c: In function 'ext4_rereserve_cluster':
> fs/ext4/extents.c:2545:2: error: implicit declaration of function
'ext4_remove_pending'; did you mean 'ext4_resize_end'?
[-Werror=implicit-function-declaration]
2545 | ext4_remove_pending(inode,
lblk);
| ^~~~~~~~~~~~~~~~~~~
| ext4_resize_end
fs/ext4/extents.c: In function 'ext4_remove_blocks':
> fs/ext4/extents.c:2593:8: error: implicit declaration of function
'ext4_is_pending' [-Werror=implicit-function-declaration]
2593 | if
(ext4_is_pending(inode, partial->lblk))
| ^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
fs/ext4/extents.c: In function 'ext4_rereserve_cluster':
> fs/ext4/extents.c:2545:2: error: implicit declaration of function
'ext4_remove_pending'; did you mean 'ext4_resize_end'?
[-Werror=implicit-function-declaration]
2545 | ext4_remove_pending(inode,
lblk);
| ^~~~~~~~~~~~~~~~~~~
| ext4_resize_end
fs/ext4/extents.c: In function 'ext4_remove_blocks':
> fs/ext4/extents.c:2593:8: error: implicit declaration of function
'ext4_is_pending' [-Werror=implicit-function-declaration]
2593 | if
(ext4_is_pending(inode, partial->lblk))
| ^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +2545 fs/ext4/extents.c
2516
2517 /*
2518 * ext4_rereserve_cluster - increment the reserved cluster count when
2519 * freeing a cluster with a pending reservation
2520 *
2521 * @inode - file containing the cluster
2522 * @lblk - logical block in cluster to be reserved
2523 *
2524 * Increments the reserved cluster count and adjusts quota in a bigalloc
2525 * file system when freeing a partial cluster containing at least one
2526 * delayed and unwritten block. A partial cluster meeting that
2527 * requirement will have a pending reservation. If so, the
2528 * RERESERVE_CLUSTER flag is used when calling ext4_free_blocks() to
2529 * defer reserved and allocated space accounting to a subsequent call
2530 * to this function.
2531 */
2532 static void ext4_rereserve_cluster(struct inode *inode, ext4_lblk_t lblk)
2533 {
2534 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
2535 struct ext4_inode_info *ei = EXT4_I(inode);
2536
2537 dquot_reclaim_block(inode, EXT4_C2B(sbi, 1));
2538
2539 spin_lock(&ei->i_block_reservation_lock);
2540 ei->i_reserved_data_blocks++;
2541 percpu_counter_add(&sbi->s_dirtyclusters_counter, 1);
2542 spin_unlock(&ei->i_block_reservation_lock);
2543
2544 percpu_counter_add(&sbi->s_freeclusters_counter, 1);
2545 ext4_remove_pending(inode, lblk);
2546 }
2547
2548 static int ext4_remove_blocks(handle_t *handle, struct inode *inode,
2549 struct ext4_extent *ex,
2550 struct partial_cluster *partial,
2551 ext4_lblk_t from, ext4_lblk_t to)
2552 {
2553 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
2554 unsigned short ee_len = ext4_ext_get_actual_len(ex);
2555 ext4_fsblk_t last_pblk, pblk;
2556 ext4_lblk_t num;
2557 int flags;
2558
2559 /* only extent tail removal is allowed */
2560 if (from < le32_to_cpu(ex->ee_block) ||
2561 to != le32_to_cpu(ex->ee_block) + ee_len - 1) {
2562 ext4_error(sbi->s_sb,
2563 "strange request: removal(2) %u-%u from %u:%u",
2564 from, to, le32_to_cpu(ex->ee_block), ee_len);
2565 return 0;
2566 }
2567
2568 #ifdef EXTENTS_STATS
2569 spin_lock(&sbi->s_ext_stats_lock);
2570 sbi->s_ext_blocks += ee_len;
2571 sbi->s_ext_extents++;
2572 if (ee_len < sbi->s_ext_min)
2573 sbi->s_ext_min = ee_len;
2574 if (ee_len > sbi->s_ext_max)
2575 sbi->s_ext_max = ee_len;
2576 if (ext_depth(inode) > sbi->s_depth_max)
2577 sbi->s_depth_max = ext_depth(inode);
2578 spin_unlock(&sbi->s_ext_stats_lock);
2579 #endif
2580
2581 trace_ext4_remove_blocks(inode, ex, from, to, partial);
2582
2583 /*
2584 * if we have a partial cluster, and it's different from the
2585 * cluster of the last block in the extent, we free it
2586 */
2587 last_pblk = ext4_ext_pblock(ex) + ee_len - 1;
2588
2589 if (partial->state != initial &&
2590 partial->pclu != EXT4_B2C(sbi, last_pblk)) {
2591 if (partial->state == tofree) {
2592 flags = get_default_free_blocks_flags(inode);
2593 if (ext4_is_pending(inode, partial->lblk))
2594 flags |= EXT4_FREE_BLOCKS_RERESERVE_CLUSTER;
2595 ext4_free_blocks(handle, inode, NULL,
2596 EXT4_C2B(sbi, partial->pclu),
2597 sbi->s_cluster_ratio, flags);
2598 if (flags & EXT4_FREE_BLOCKS_RERESERVE_CLUSTER)
2599 ext4_rereserve_cluster(inode, partial->lblk);
2600 }
2601 partial->state = initial;
2602 }
2603
2604 num = le32_to_cpu(ex->ee_block) + ee_len - from;
2605 pblk = ext4_ext_pblock(ex) + ee_len - num;
2606
2607 /*
2608 * We free the partial cluster at the end of the extent (if any),
2609 * unless the cluster is used by another extent (partial_cluster
2610 * state is nofree). If a partial cluster exists here, it must be
2611 * shared with the last block in the extent.
2612 */
2613 flags = get_default_free_blocks_flags(inode);
2614
2615 /* partial, left end cluster aligned, right end unaligned */
2616 if ((EXT4_LBLK_COFF(sbi, to) != sbi->s_cluster_ratio - 1) &&
2617 (EXT4_LBLK_CMASK(sbi, to) >= from) &&
2618 (partial->state != nofree)) {
2619 if (ext4_is_pending(inode, to))
2620 flags |= EXT4_FREE_BLOCKS_RERESERVE_CLUSTER;
2621 ext4_free_blocks(handle, inode, NULL,
2622 EXT4_PBLK_CMASK(sbi, last_pblk),
2623 sbi->s_cluster_ratio, flags);
2624 if (flags & EXT4_FREE_BLOCKS_RERESERVE_CLUSTER)
2625 ext4_rereserve_cluster(inode, to);
2626 partial->state = initial;
2627 flags = get_default_free_blocks_flags(inode);
2628 }
2629
2630 flags |= EXT4_FREE_BLOCKS_NOFREE_LAST_CLUSTER;
2631
2632 /*
2633 * For bigalloc file systems, we never free a partial cluster
2634 * at the beginning of the extent. Instead, we check to see if we
2635 * need to free it on a subsequent call to ext4_remove_blocks,
2636 * or at the end of ext4_ext_rm_leaf or ext4_ext_remove_space.
2637 */
2638 flags |= EXT4_FREE_BLOCKS_NOFREE_FIRST_CLUSTER;
2639 ext4_free_blocks(handle, inode, NULL, pblk, num, flags);
2640
2641 /* reset the partial cluster if we've freed past it */
2642 if (partial->state != initial && partial->pclu != EXT4_B2C(sbi,
pblk))
2643 partial->state = initial;
2644
2645 /*
2646 * If we've freed the entire extent but the beginning is not left
2647 * cluster aligned and is not marked as ineligible for freeing we
2648 * record the partial cluster at the beginning of the extent. It
2649 * wasn't freed by the preceding ext4_free_blocks() call, and we
2650 * need to look farther to the left to determine if it's to be freed
2651 * (not shared with another extent). Else, reset the partial
2652 * cluster - we're either done freeing or the beginning of the
2653 * extent is left cluster aligned.
2654 */
2655 if (EXT4_LBLK_COFF(sbi, from) && num == ee_len) {
2656 if (partial->state == initial) {
2657 partial->pclu = EXT4_B2C(sbi, pblk);
2658 partial->lblk = from;
2659 partial->state = tofree;
2660 }
2661 } else {
2662 partial->state = initial;
2663 }
2664
2665 return 0;
2666 }
2667
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org