CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Qu Wenruo <[email protected]>
TO: [email protected]

Hi Qu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kdave/for-next]
[also build test WARNING on v5.14-rc4 next-20210805]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    
https://github.com/0day-ci/linux/commits/Qu-Wenruo/btrfs-defrag-rework-to-support-sector-perfect-defrag/20210806-161501
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
:::::: branch date: 7 hours ago
:::::: commit date: 7 hours ago
config: h8300-randconfig-m031-20210804 (attached as .config)
compiler: h8300-linux-gcc (GCC) 10.3.0

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

New smatch warnings:
fs/btrfs/ioctl.c:1649 defrag_one_range() warn: should 'start_index << 12' be a 
64 bit type?

Old smatch warnings:
fs/btrfs/ioctl.c:816 create_snapshot() warn: '&pending_snapshot->list' not 
removed from list
fs/btrfs/ioctl.c:1216 defrag_prepare_one_page() warn: should 'index << 12' be a 
64 bit type?
fs/btrfs/ioctl.c:1677 defrag_one_range() warn: should 'start_index << 12' be a 
64 bit type?
fs/btrfs/ioctl.c:1875 btrfs_defrag_file() warn: should 'ret << 12' be a 64 bit 
type?

vim +1649 fs/btrfs/ioctl.c

5f3808c60f9869 Qu Wenruo 2021-08-06  1611  
3d1f5d08b3072f Qu Wenruo 2021-08-06  1612  static int defrag_one_range(struct 
btrfs_inode *inode,
3d1f5d08b3072f Qu Wenruo 2021-08-06  1613                           u64 start, 
u32 len,
3d1f5d08b3072f Qu Wenruo 2021-08-06  1614                           u32 
extent_thresh, u64 newer_than,
3d1f5d08b3072f Qu Wenruo 2021-08-06  1615                           bool 
do_compress)
3d1f5d08b3072f Qu Wenruo 2021-08-06  1616  {
3d1f5d08b3072f Qu Wenruo 2021-08-06  1617       struct extent_state 
*cached_state = NULL;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1618       struct defrag_target_range 
*entry;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1619       struct defrag_target_range *tmp;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1620       LIST_HEAD(target_list);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1621       struct page **pages;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1622       const u32 sectorsize = 
inode->root->fs_info->sectorsize;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1623       unsigned long last_index = 
(start + len - 1) >> PAGE_SHIFT;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1624       unsigned long start_index = 
start >> PAGE_SHIFT;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1625       unsigned int nr_pages = 
last_index - start_index + 1;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1626       int ret = 0;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1627       int i;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1628  
3d1f5d08b3072f Qu Wenruo 2021-08-06  1629       ASSERT(nr_pages <= CLUSTER_SIZE 
/ PAGE_SIZE);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1630       ASSERT(IS_ALIGNED(start, 
sectorsize) && IS_ALIGNED(len, sectorsize));
3d1f5d08b3072f Qu Wenruo 2021-08-06  1631  
3d1f5d08b3072f Qu Wenruo 2021-08-06  1632       pages = kcalloc(nr_pages, 
sizeof(struct page *), GFP_NOFS);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1633       if (!pages)
3d1f5d08b3072f Qu Wenruo 2021-08-06  1634               return -ENOMEM;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1635  
3d1f5d08b3072f Qu Wenruo 2021-08-06  1636       /* Prepare all pages */
3d1f5d08b3072f Qu Wenruo 2021-08-06  1637       for (i = 0; i < nr_pages; i++) {
3d1f5d08b3072f Qu Wenruo 2021-08-06  1638               pages[i] = 
defrag_prepare_one_page(inode, start_index + i);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1639               if (IS_ERR(pages[i])) {
3d1f5d08b3072f Qu Wenruo 2021-08-06  1640                       ret = 
PTR_ERR(pages[i]);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1641                       pages[i] = NULL;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1642                       goto free_pages;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1643               }
3d1f5d08b3072f Qu Wenruo 2021-08-06  1644       }
3d1f5d08b3072f Qu Wenruo 2021-08-06  1645       for (i = 0; i < nr_pages; i++)
3d1f5d08b3072f Qu Wenruo 2021-08-06  1646               
wait_on_page_writeback(pages[i]);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1647  
3d1f5d08b3072f Qu Wenruo 2021-08-06  1648       /* Also lock the pages range */
3d1f5d08b3072f Qu Wenruo 2021-08-06 @1649       
lock_extent_bits(&inode->io_tree, start_index << PAGE_SHIFT,
3d1f5d08b3072f Qu Wenruo 2021-08-06  1650                        (last_index << 
PAGE_SHIFT) + PAGE_SIZE - 1,
3d1f5d08b3072f Qu Wenruo 2021-08-06  1651                        &cached_state);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1652       /*
3d1f5d08b3072f Qu Wenruo 2021-08-06  1653        * Now we have a consistent 
view about the extent map, re-check
3d1f5d08b3072f Qu Wenruo 2021-08-06  1654        * which range really needs to 
be defragged.
3d1f5d08b3072f Qu Wenruo 2021-08-06  1655        *
3d1f5d08b3072f Qu Wenruo 2021-08-06  1656        * And this time we have extent 
locked already, pass @locked = true
3d1f5d08b3072f Qu Wenruo 2021-08-06  1657        * so that we won't re-lock the 
extent range and cause deadlock.
3d1f5d08b3072f Qu Wenruo 2021-08-06  1658        */
3d1f5d08b3072f Qu Wenruo 2021-08-06  1659       ret = 
defrag_collect_targets(inode, start, len, extent_thresh,
3d1f5d08b3072f Qu Wenruo 2021-08-06  1660                                    
newer_than, do_compress, true,
3d1f5d08b3072f Qu Wenruo 2021-08-06  1661                                    
&target_list);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1662       if (ret < 0)
3d1f5d08b3072f Qu Wenruo 2021-08-06  1663               goto unlock_extent;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1664  
3d1f5d08b3072f Qu Wenruo 2021-08-06  1665       list_for_each_entry(entry, 
&target_list, list) {
3d1f5d08b3072f Qu Wenruo 2021-08-06  1666               ret = 
defrag_one_locked_target(inode, entry, pages, nr_pages,
3d1f5d08b3072f Qu Wenruo 2021-08-06  1667                                       
       &cached_state);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1668               if (ret < 0)
3d1f5d08b3072f Qu Wenruo 2021-08-06  1669                       break;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1670       }
3d1f5d08b3072f Qu Wenruo 2021-08-06  1671  
3d1f5d08b3072f Qu Wenruo 2021-08-06  1672       list_for_each_entry_safe(entry, 
tmp, &target_list, list) {
3d1f5d08b3072f Qu Wenruo 2021-08-06  1673               
list_del_init(&entry->list);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1674               kfree(entry);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1675       }
3d1f5d08b3072f Qu Wenruo 2021-08-06  1676  unlock_extent:
3d1f5d08b3072f Qu Wenruo 2021-08-06  1677       
unlock_extent_cached(&inode->io_tree, start_index << PAGE_SHIFT,
3d1f5d08b3072f Qu Wenruo 2021-08-06  1678                            
(last_index << PAGE_SHIFT) + PAGE_SIZE - 1,
3d1f5d08b3072f Qu Wenruo 2021-08-06  1679                            
&cached_state);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1680  free_pages:
3d1f5d08b3072f Qu Wenruo 2021-08-06  1681       for (i = 0; i < nr_pages; i++) {
3d1f5d08b3072f Qu Wenruo 2021-08-06  1682               if (pages[i]) {
3d1f5d08b3072f Qu Wenruo 2021-08-06  1683                       
unlock_page(pages[i]);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1684                       
put_page(pages[i]);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1685               }
3d1f5d08b3072f Qu Wenruo 2021-08-06  1686       }
3d1f5d08b3072f Qu Wenruo 2021-08-06  1687       kfree(pages);
3d1f5d08b3072f Qu Wenruo 2021-08-06  1688       return ret;
3d1f5d08b3072f Qu Wenruo 2021-08-06  1689  }
3d1f5d08b3072f Qu Wenruo 2021-08-06  1690  

---
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