CC: kbuild-...@lists.01.org
CC: Omar Sandoval <osan...@osandov.com>
CC: linux-ker...@vger.kernel.org
TO: Omar Sandoval <osan...@fb.com>
CC: Nikolay Borisov <nbori...@suse.com>

tree:   https://github.com/osandov/linux.git btrfs-send-encoded
head:   ec062ce505d22f204218f91a940b55fb38d66b07
commit: 57cd63d9f970d529c3cc9b80612cffd71b3186b9 [15/17] btrfs: send: allocate 
send buffer with alloc_page() and vmap() for v2
:::::: branch date: 27 hours ago
:::::: commit date: 27 hours ago
config: nios2-randconfig-m031-20220124 
(https://download.01.org/0day-ci/archive/20220127/202201270814.2gid9lnj-...@intel.com/config)
compiler: nios2-linux-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <l...@intel.com>
Reported-by: Dan Carpenter <dan.carpen...@oracle.com>

New smatch warnings:
fs/btrfs/send.c:7806 btrfs_ioctl_send() error: we previously assumed 
'sctx->send_buf_pages' could be null (see line 7593)

Old smatch warnings:
arch/nios2/include/asm/thread_info.h:71 current_thread_info() error: 
uninitialized symbol 'sp'.

vim +7806 fs/btrfs/send.c

62d54f3a7fa27e Filipe Manana             2019-04-22  7488  
786e6838d278ed Sahil Kang                2022-01-15  7489  long 
btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg)
31db9f7c23fbf7 Alexander Block           2012-07-25  7490  {
31db9f7c23fbf7 Alexander Block           2012-07-25  7491       int ret = 0;
786e6838d278ed Sahil Kang                2022-01-15  7492       struct 
btrfs_root *send_root = BTRFS_I(inode)->root;
0b246afa62b0cf Jeff Mahoney              2016-06-22  7493       struct 
btrfs_fs_info *fs_info = send_root->fs_info;
31db9f7c23fbf7 Alexander Block           2012-07-25  7494       struct 
btrfs_root *clone_root;
31db9f7c23fbf7 Alexander Block           2012-07-25  7495       struct send_ctx 
*sctx = NULL;
31db9f7c23fbf7 Alexander Block           2012-07-25  7496       u32 i;
57cd63d9f970d5 Omar Sandoval             2020-05-01  7497       u32 
send_buf_num_pages = 0;
31db9f7c23fbf7 Alexander Block           2012-07-25  7498       u64 
*clone_sources_tmp = NULL;
2c68653787f91c David Sterba              2013-12-16  7499       int 
clone_sources_to_rollback = 0;
bae12df966f0e1 Denis Efremov             2020-09-21  7500       size_t 
alloc_size;
896c14f97f700a Wang Shilong              2014-01-07  7501       int 
sort_clone_roots = 0;
31db9f7c23fbf7 Alexander Block           2012-07-25  7502  
31db9f7c23fbf7 Alexander Block           2012-07-25  7503       if 
(!capable(CAP_SYS_ADMIN))
31db9f7c23fbf7 Alexander Block           2012-07-25  7504               return 
-EPERM;
31db9f7c23fbf7 Alexander Block           2012-07-25  7505  
2c68653787f91c David Sterba              2013-12-16  7506       /*
2c68653787f91c David Sterba              2013-12-16  7507        * The 
subvolume must remain read-only during send, protect against
521e0546c970c3 David Sterba              2014-04-15  7508        * making it 
RW. This also protects against deletion.
2c68653787f91c David Sterba              2013-12-16  7509        */
2c68653787f91c David Sterba              2013-12-16  7510       
spin_lock(&send_root->root_item_lock);
62d54f3a7fa27e Filipe Manana             2019-04-22  7511       if 
(btrfs_root_readonly(send_root) && send_root->dedupe_in_progress) {
62d54f3a7fa27e Filipe Manana             2019-04-22  7512               
dedupe_in_progress_warn(send_root);
62d54f3a7fa27e Filipe Manana             2019-04-22  7513               
spin_unlock(&send_root->root_item_lock);
62d54f3a7fa27e Filipe Manana             2019-04-22  7514               return 
-EAGAIN;
62d54f3a7fa27e Filipe Manana             2019-04-22  7515       }
2c68653787f91c David Sterba              2013-12-16  7516       
send_root->send_in_progress++;
2c68653787f91c David Sterba              2013-12-16  7517       
spin_unlock(&send_root->root_item_lock);
2c68653787f91c David Sterba              2013-12-16  7518  
2c68653787f91c David Sterba              2013-12-16  7519       /*
2c68653787f91c David Sterba              2013-12-16  7520        * Userspace 
tools do the checks and warn the user if it's
2c68653787f91c David Sterba              2013-12-16  7521        * not RO.
2c68653787f91c David Sterba              2013-12-16  7522        */
2c68653787f91c David Sterba              2013-12-16  7523       if 
(!btrfs_root_readonly(send_root)) {
2c68653787f91c David Sterba              2013-12-16  7524               ret = 
-EPERM;
2c68653787f91c David Sterba              2013-12-16  7525               goto 
out;
2c68653787f91c David Sterba              2013-12-16  7526       }
2c68653787f91c David Sterba              2013-12-16  7527  
457ae7268b29c3 Dan Carpenter             2017-03-17  7528       /*
457ae7268b29c3 Dan Carpenter             2017-03-17  7529        * Check that 
we don't overflow at later allocations, we request
457ae7268b29c3 Dan Carpenter             2017-03-17  7530        * 
clone_sources_count + 1 items, and compare to unsigned long inside
457ae7268b29c3 Dan Carpenter             2017-03-17  7531        * access_ok.
457ae7268b29c3 Dan Carpenter             2017-03-17  7532        */
f5ecec3ce21f70 Dan Carpenter             2016-04-13  7533       if 
(arg->clone_sources_count >
457ae7268b29c3 Dan Carpenter             2017-03-17  7534           ULONG_MAX / 
sizeof(struct clone_root) - 1) {
f5ecec3ce21f70 Dan Carpenter             2016-04-13  7535               ret = 
-EINVAL;
f5ecec3ce21f70 Dan Carpenter             2016-04-13  7536               goto 
out;
f5ecec3ce21f70 Dan Carpenter             2016-04-13  7537       }
f5ecec3ce21f70 Dan Carpenter             2016-04-13  7538  
c2c71324ecb471 Stefan Behrens            2013-04-10  7539       if (arg->flags 
& ~BTRFS_SEND_FLAG_MASK) {
cb95e7bf7ba481 Mark Fasheh               2013-02-04  7540               ret = 
-EINVAL;
cb95e7bf7ba481 Mark Fasheh               2013-02-04  7541               goto 
out;
cb95e7bf7ba481 Mark Fasheh               2013-02-04  7542       }
cb95e7bf7ba481 Mark Fasheh               2013-02-04  7543  
e780b0d1c1523e David Sterba              2016-01-18  7544       sctx = 
kzalloc(sizeof(struct send_ctx), GFP_KERNEL);
31db9f7c23fbf7 Alexander Block           2012-07-25  7545       if (!sctx) {
31db9f7c23fbf7 Alexander Block           2012-07-25  7546               ret = 
-ENOMEM;
31db9f7c23fbf7 Alexander Block           2012-07-25  7547               goto 
out;
31db9f7c23fbf7 Alexander Block           2012-07-25  7548       }
31db9f7c23fbf7 Alexander Block           2012-07-25  7549  
31db9f7c23fbf7 Alexander Block           2012-07-25  7550       
INIT_LIST_HEAD(&sctx->new_refs);
31db9f7c23fbf7 Alexander Block           2012-07-25  7551       
INIT_LIST_HEAD(&sctx->deleted_refs);
e780b0d1c1523e David Sterba              2016-01-18  7552       
INIT_RADIX_TREE(&sctx->name_cache, GFP_KERNEL);
31db9f7c23fbf7 Alexander Block           2012-07-25  7553       
INIT_LIST_HEAD(&sctx->name_cache_list);
31db9f7c23fbf7 Alexander Block           2012-07-25  7554  
cb95e7bf7ba481 Mark Fasheh               2013-02-04  7555       sctx->flags = 
arg->flags;
cb95e7bf7ba481 Mark Fasheh               2013-02-04  7556  
e77fbf990316d4 David Sterba              2021-10-22  7557       if (arg->flags 
& BTRFS_SEND_FLAG_VERSION) {
e77fbf990316d4 David Sterba              2021-10-22  7558               if 
(arg->version > BTRFS_SEND_STREAM_VERSION) {
e77fbf990316d4 David Sterba              2021-10-22  7559                       
ret = -EPROTO;
e77fbf990316d4 David Sterba              2021-10-22  7560                       
goto out;
e77fbf990316d4 David Sterba              2021-10-22  7561               }
e77fbf990316d4 David Sterba              2021-10-22  7562               /* Zero 
means "use the highest version" */
e77fbf990316d4 David Sterba              2021-10-22  7563               
sctx->proto = arg->version ?: BTRFS_SEND_STREAM_VERSION;
e77fbf990316d4 David Sterba              2021-10-22  7564       } else {
e77fbf990316d4 David Sterba              2021-10-22  7565               
sctx->proto = 1;
e77fbf990316d4 David Sterba              2021-10-22  7566       }
e77fbf990316d4 David Sterba              2021-10-22  7567  
31db9f7c23fbf7 Alexander Block           2012-07-25  7568       sctx->send_filp 
= fget(arg->send_fd);
ecc7ada77b5cd1 Tsutomu Itoh              2013-04-19  7569       if 
(!sctx->send_filp) {
ecc7ada77b5cd1 Tsutomu Itoh              2013-04-19  7570               ret = 
-EBADF;
31db9f7c23fbf7 Alexander Block           2012-07-25  7571               goto 
out;
31db9f7c23fbf7 Alexander Block           2012-07-25  7572       }
31db9f7c23fbf7 Alexander Block           2012-07-25  7573  
31db9f7c23fbf7 Alexander Block           2012-07-25  7574       sctx->send_root 
= send_root;
521e0546c970c3 David Sterba              2014-04-15  7575       /*
521e0546c970c3 David Sterba              2014-04-15  7576        * Unlikely but 
possible, if the subvolume is marked for deletion but
521e0546c970c3 David Sterba              2014-04-15  7577        * is slow to 
remove the directory entry, send can still be started
521e0546c970c3 David Sterba              2014-04-15  7578        */
521e0546c970c3 David Sterba              2014-04-15  7579       if 
(btrfs_root_dead(sctx->send_root)) {
521e0546c970c3 David Sterba              2014-04-15  7580               ret = 
-EPERM;
521e0546c970c3 David Sterba              2014-04-15  7581               goto 
out;
521e0546c970c3 David Sterba              2014-04-15  7582       }
521e0546c970c3 David Sterba              2014-04-15  7583  
31db9f7c23fbf7 Alexander Block           2012-07-25  7584       
sctx->clone_roots_cnt = arg->clone_sources_count;
31db9f7c23fbf7 Alexander Block           2012-07-25  7585  
1d067d274b5d5c Omar Sandoval             2020-05-13  7586       if (sctx->proto 
>= 2) {
1d067d274b5d5c Omar Sandoval             2020-05-13  7587               
sctx->send_max_size = ALIGN(SZ_16K + BTRFS_MAX_COMPRESSED,
1d067d274b5d5c Omar Sandoval             2020-05-13  7588                       
                    PAGE_SIZE);
57cd63d9f970d5 Omar Sandoval             2020-05-01  7589               
send_buf_num_pages = sctx->send_max_size >> PAGE_SHIFT;
57cd63d9f970d5 Omar Sandoval             2020-05-01  7590               
sctx->send_buf_pages = kcalloc(send_buf_num_pages,
57cd63d9f970d5 Omar Sandoval             2020-05-01  7591                       
                       sizeof(*sctx->send_buf_pages),
57cd63d9f970d5 Omar Sandoval             2020-05-01  7592                       
                       GFP_KERNEL);
57cd63d9f970d5 Omar Sandoval             2020-05-01  7593               if 
(!sctx->send_buf_pages) {
57cd63d9f970d5 Omar Sandoval             2020-05-01  7594                       
send_buf_num_pages = 0;
57cd63d9f970d5 Omar Sandoval             2020-05-01  7595                       
ret = -ENOMEM;
57cd63d9f970d5 Omar Sandoval             2020-05-01  7596                       
goto out;
57cd63d9f970d5 Omar Sandoval             2020-05-01  7597               }
57cd63d9f970d5 Omar Sandoval             2020-05-01  7598               for (i 
= 0; i < send_buf_num_pages; i++) {
57cd63d9f970d5 Omar Sandoval             2020-05-01  7599                       
sctx->send_buf_pages[i] = alloc_page(GFP_KERNEL);
57cd63d9f970d5 Omar Sandoval             2020-05-01  7600                       
if (!sctx->send_buf_pages[i]) {
57cd63d9f970d5 Omar Sandoval             2020-05-01  7601                       
        ret = -ENOMEM;
57cd63d9f970d5 Omar Sandoval             2020-05-01  7602                       
        goto out;
57cd63d9f970d5 Omar Sandoval             2020-05-01  7603                       
}
57cd63d9f970d5 Omar Sandoval             2020-05-01  7604               }
57cd63d9f970d5 Omar Sandoval             2020-05-01  7605               
sctx->send_buf = vmap(sctx->send_buf_pages, send_buf_num_pages,
57cd63d9f970d5 Omar Sandoval             2020-05-01  7606                       
              VM_MAP, PAGE_KERNEL);
1d067d274b5d5c Omar Sandoval             2020-05-13  7607       } else {
ddb13e7a6baea8 Omar Sandoval             2020-05-12  7608               
sctx->send_max_size = BTRFS_SEND_BUF_SIZE_V1;
752ade68cbd81d Michal Hocko              2017-05-08  7609               
sctx->send_buf = kvmalloc(sctx->send_max_size, GFP_KERNEL);
57cd63d9f970d5 Omar Sandoval             2020-05-01  7610       }
31db9f7c23fbf7 Alexander Block           2012-07-25  7611       if 
(!sctx->send_buf) {
31db9f7c23fbf7 Alexander Block           2012-07-25  7612               ret = 
-ENOMEM;
31db9f7c23fbf7 Alexander Block           2012-07-25  7613               goto 
out;
31db9f7c23fbf7 Alexander Block           2012-07-25  7614       }
31db9f7c23fbf7 Alexander Block           2012-07-25  7615  
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7616       
sctx->pending_dir_moves = RB_ROOT;
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7617       
sctx->waiting_dir_moves = RB_ROOT;
9dc442143b9874 Filipe Manana             2014-02-19  7618       
sctx->orphan_dirs = RB_ROOT;
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7619  
bae12df966f0e1 Denis Efremov             2020-09-21  7620       
sctx->clone_roots = kvcalloc(sizeof(*sctx->clone_roots),
bae12df966f0e1 Denis Efremov             2020-09-21  7621                       
             arg->clone_sources_count + 1,
bae12df966f0e1 Denis Efremov             2020-09-21  7622                       
             GFP_KERNEL);
31db9f7c23fbf7 Alexander Block           2012-07-25  7623       if 
(!sctx->clone_roots) {
31db9f7c23fbf7 Alexander Block           2012-07-25  7624               ret = 
-ENOMEM;
31db9f7c23fbf7 Alexander Block           2012-07-25  7625               goto 
out;
31db9f7c23fbf7 Alexander Block           2012-07-25  7626       }
31db9f7c23fbf7 Alexander Block           2012-07-25  7627  
bae12df966f0e1 Denis Efremov             2020-09-21  7628       alloc_size = 
array_size(sizeof(*arg->clone_sources),
bae12df966f0e1 Denis Efremov             2020-09-21  7629                       
        arg->clone_sources_count);
e55d1153dbf484 David Sterba              2016-04-11  7630  
31db9f7c23fbf7 Alexander Block           2012-07-25  7631       if 
(arg->clone_sources_count) {
752ade68cbd81d Michal Hocko              2017-05-08  7632               
clone_sources_tmp = kvmalloc(alloc_size, GFP_KERNEL);
31db9f7c23fbf7 Alexander Block           2012-07-25  7633               if 
(!clone_sources_tmp) {
31db9f7c23fbf7 Alexander Block           2012-07-25  7634                       
ret = -ENOMEM;
31db9f7c23fbf7 Alexander Block           2012-07-25  7635                       
goto out;
31db9f7c23fbf7 Alexander Block           2012-07-25  7636               }
31db9f7c23fbf7 Alexander Block           2012-07-25  7637  
31db9f7c23fbf7 Alexander Block           2012-07-25  7638               ret = 
copy_from_user(clone_sources_tmp, arg->clone_sources,
e55d1153dbf484 David Sterba              2016-04-11  7639                       
        alloc_size);
31db9f7c23fbf7 Alexander Block           2012-07-25  7640               if 
(ret) {
31db9f7c23fbf7 Alexander Block           2012-07-25  7641                       
ret = -EFAULT;
31db9f7c23fbf7 Alexander Block           2012-07-25  7642                       
goto out;
31db9f7c23fbf7 Alexander Block           2012-07-25  7643               }
31db9f7c23fbf7 Alexander Block           2012-07-25  7644  
31db9f7c23fbf7 Alexander Block           2012-07-25  7645               for (i 
= 0; i < arg->clone_sources_count; i++) {
56e9357a1e8167 David Sterba              2020-05-15  7646                       
clone_root = btrfs_get_fs_root(fs_info,
56e9357a1e8167 David Sterba              2020-05-15  7647                       
                        clone_sources_tmp[i], true);
31db9f7c23fbf7 Alexander Block           2012-07-25  7648                       
if (IS_ERR(clone_root)) {
31db9f7c23fbf7 Alexander Block           2012-07-25  7649                       
        ret = PTR_ERR(clone_root);
31db9f7c23fbf7 Alexander Block           2012-07-25  7650                       
        goto out;
31db9f7c23fbf7 Alexander Block           2012-07-25  7651                       
}
2c68653787f91c David Sterba              2013-12-16  7652                       
spin_lock(&clone_root->root_item_lock);
5cc2b17e80cf57 Filipe Manana             2015-03-02  7653                       
if (!btrfs_root_readonly(clone_root) ||
5cc2b17e80cf57 Filipe Manana             2015-03-02  7654                       
    btrfs_root_dead(clone_root)) {
2c68653787f91c David Sterba              2013-12-16  7655                       
        spin_unlock(&clone_root->root_item_lock);
0024652895e347 Josef Bacik               2020-01-24  7656                       
        btrfs_put_root(clone_root);
2c68653787f91c David Sterba              2013-12-16  7657                       
        ret = -EPERM;
2c68653787f91c David Sterba              2013-12-16  7658                       
        goto out;
2c68653787f91c David Sterba              2013-12-16  7659                       
}
62d54f3a7fa27e Filipe Manana             2019-04-22  7660                       
if (clone_root->dedupe_in_progress) {
62d54f3a7fa27e Filipe Manana             2019-04-22  7661                       
        dedupe_in_progress_warn(clone_root);
62d54f3a7fa27e Filipe Manana             2019-04-22  7662                       
        spin_unlock(&clone_root->root_item_lock);
0024652895e347 Josef Bacik               2020-01-24  7663                       
        btrfs_put_root(clone_root);
62d54f3a7fa27e Filipe Manana             2019-04-22  7664                       
        ret = -EAGAIN;
62d54f3a7fa27e Filipe Manana             2019-04-22  7665                       
        goto out;
62d54f3a7fa27e Filipe Manana             2019-04-22  7666                       
}
2f1f465ae6da24 Filipe Manana             2015-03-02  7667                       
clone_root->send_in_progress++;
2c68653787f91c David Sterba              2013-12-16  7668                       
spin_unlock(&clone_root->root_item_lock);
18f687d5384493 Wang Shilong              2014-01-07  7669  
31db9f7c23fbf7 Alexander Block           2012-07-25  7670                       
sctx->clone_roots[i].root = clone_root;
2f1f465ae6da24 Filipe Manana             2015-03-02  7671                       
clone_sources_to_rollback = i + 1;
31db9f7c23fbf7 Alexander Block           2012-07-25  7672               }
2f91306a378099 David Sterba              2016-04-11  7673               
kvfree(clone_sources_tmp);
31db9f7c23fbf7 Alexander Block           2012-07-25  7674               
clone_sources_tmp = NULL;
31db9f7c23fbf7 Alexander Block           2012-07-25  7675       }
31db9f7c23fbf7 Alexander Block           2012-07-25  7676  
31db9f7c23fbf7 Alexander Block           2012-07-25  7677       if 
(arg->parent_root) {
56e9357a1e8167 David Sterba              2020-05-15  7678               
sctx->parent_root = btrfs_get_fs_root(fs_info, arg->parent_root,
56e9357a1e8167 David Sterba              2020-05-15  7679                       
                              true);
b1b195969fe6d9 Stefan Behrens            2013-05-13  7680               if 
(IS_ERR(sctx->parent_root)) {
b1b195969fe6d9 Stefan Behrens            2013-05-13  7681                       
ret = PTR_ERR(sctx->parent_root);
31db9f7c23fbf7 Alexander Block           2012-07-25  7682                       
goto out;
31db9f7c23fbf7 Alexander Block           2012-07-25  7683               }
18f687d5384493 Wang Shilong              2014-01-07  7684  
2c68653787f91c David Sterba              2013-12-16  7685               
spin_lock(&sctx->parent_root->root_item_lock);
2c68653787f91c David Sterba              2013-12-16  7686               
sctx->parent_root->send_in_progress++;
521e0546c970c3 David Sterba              2014-04-15  7687               if 
(!btrfs_root_readonly(sctx->parent_root) ||
521e0546c970c3 David Sterba              2014-04-15  7688                       
        btrfs_root_dead(sctx->parent_root)) {
2c68653787f91c David Sterba              2013-12-16  7689                       
spin_unlock(&sctx->parent_root->root_item_lock);
2c68653787f91c David Sterba              2013-12-16  7690                       
ret = -EPERM;
2c68653787f91c David Sterba              2013-12-16  7691                       
goto out;
2c68653787f91c David Sterba              2013-12-16  7692               }
62d54f3a7fa27e Filipe Manana             2019-04-22  7693               if 
(sctx->parent_root->dedupe_in_progress) {
62d54f3a7fa27e Filipe Manana             2019-04-22  7694                       
dedupe_in_progress_warn(sctx->parent_root);
62d54f3a7fa27e Filipe Manana             2019-04-22  7695                       
spin_unlock(&sctx->parent_root->root_item_lock);
62d54f3a7fa27e Filipe Manana             2019-04-22  7696                       
ret = -EAGAIN;
62d54f3a7fa27e Filipe Manana             2019-04-22  7697                       
goto out;
62d54f3a7fa27e Filipe Manana             2019-04-22  7698               }
2c68653787f91c David Sterba              2013-12-16  7699               
spin_unlock(&sctx->parent_root->root_item_lock);
31db9f7c23fbf7 Alexander Block           2012-07-25  7700       }
31db9f7c23fbf7 Alexander Block           2012-07-25  7701  
31db9f7c23fbf7 Alexander Block           2012-07-25  7702       /*
31db9f7c23fbf7 Alexander Block           2012-07-25  7703        * Clones from 
send_root are allowed, but only if the clone source
31db9f7c23fbf7 Alexander Block           2012-07-25  7704        * is behind 
the current send position. This is checked while searching
31db9f7c23fbf7 Alexander Block           2012-07-25  7705        * for possible 
clone sources.
31db9f7c23fbf7 Alexander Block           2012-07-25  7706        */
6f9a3da5da9e7e Josef Bacik               2020-01-24  7707       
sctx->clone_roots[sctx->clone_roots_cnt++].root =
0024652895e347 Josef Bacik               2020-01-24  7708               
btrfs_grab_root(sctx->send_root);
31db9f7c23fbf7 Alexander Block           2012-07-25  7709  
31db9f7c23fbf7 Alexander Block           2012-07-25  7710       /* We do a 
bsearch later */
31db9f7c23fbf7 Alexander Block           2012-07-25  7711       
sort(sctx->clone_roots, sctx->clone_roots_cnt,
31db9f7c23fbf7 Alexander Block           2012-07-25  7712                       
sizeof(*sctx->clone_roots), __clone_root_cmp_sort,
31db9f7c23fbf7 Alexander Block           2012-07-25  7713                       
NULL);
896c14f97f700a Wang Shilong              2014-01-07  7714       
sort_clone_roots = 1;
31db9f7c23fbf7 Alexander Block           2012-07-25  7715  
9f89d5de8631c7 Filipe Manana             2019-04-15  7716       ret = 
flush_delalloc_roots(sctx);
9f89d5de8631c7 Filipe Manana             2019-04-15  7717       if (ret)
9f89d5de8631c7 Filipe Manana             2019-04-15  7718               goto 
out;
9f89d5de8631c7 Filipe Manana             2019-04-15  7719  
e5fa8f865b3324 Filipe Manana             2014-10-21  7720       ret = 
ensure_commit_roots_uptodate(sctx);
e5fa8f865b3324 Filipe Manana             2014-10-21  7721       if (ret)
e5fa8f865b3324 Filipe Manana             2014-10-21  7722               goto 
out;
e5fa8f865b3324 Filipe Manana             2014-10-21  7723  
31db9f7c23fbf7 Alexander Block           2012-07-25  7724       ret = 
send_subvol(sctx);
31db9f7c23fbf7 Alexander Block           2012-07-25  7725       if (ret < 0)
31db9f7c23fbf7 Alexander Block           2012-07-25  7726               goto 
out;
31db9f7c23fbf7 Alexander Block           2012-07-25  7727  
c2c71324ecb471 Stefan Behrens            2013-04-10  7728       if 
(!(sctx->flags & BTRFS_SEND_FLAG_OMIT_END_CMD)) {
31db9f7c23fbf7 Alexander Block           2012-07-25  7729               ret = 
begin_cmd(sctx, BTRFS_SEND_C_END);
31db9f7c23fbf7 Alexander Block           2012-07-25  7730               if (ret 
< 0)
31db9f7c23fbf7 Alexander Block           2012-07-25  7731                       
goto out;
31db9f7c23fbf7 Alexander Block           2012-07-25  7732               ret = 
send_cmd(sctx);
31db9f7c23fbf7 Alexander Block           2012-07-25  7733               if (ret 
< 0)
31db9f7c23fbf7 Alexander Block           2012-07-25  7734                       
goto out;
c2c71324ecb471 Stefan Behrens            2013-04-10  7735       }
31db9f7c23fbf7 Alexander Block           2012-07-25  7736  
31db9f7c23fbf7 Alexander Block           2012-07-25  7737  out:
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7738       WARN_ON(sctx && 
!ret && !RB_EMPTY_ROOT(&sctx->pending_dir_moves));
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7739       while (sctx && 
!RB_EMPTY_ROOT(&sctx->pending_dir_moves)) {
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7740               struct 
rb_node *n;
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7741               struct 
pending_dir_move *pm;
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7742  
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7743               n = 
rb_first(&sctx->pending_dir_moves);
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7744               pm = 
rb_entry(n, struct pending_dir_move, node);
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7745               while 
(!list_empty(&pm->list)) {
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7746                       
struct pending_dir_move *pm2;
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7747  
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7748                       
pm2 = list_first_entry(&pm->list,
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7749                       
                       struct pending_dir_move, list);
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7750                       
free_pending_move(sctx, pm2);
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7751               }
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7752               
free_pending_move(sctx, pm);
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7753       }
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7754  
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7755       WARN_ON(sctx && 
!ret && !RB_EMPTY_ROOT(&sctx->waiting_dir_moves));
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7756       while (sctx && 
!RB_EMPTY_ROOT(&sctx->waiting_dir_moves)) {
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7757               struct 
rb_node *n;
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7758               struct 
waiting_dir_move *dm;
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7759  
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7760               n = 
rb_first(&sctx->waiting_dir_moves);
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7761               dm = 
rb_entry(n, struct waiting_dir_move, node);
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7762               
rb_erase(&dm->node, &sctx->waiting_dir_moves);
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7763               
kfree(dm);
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7764       }
9f03740a956d7a Filipe David Borba Manana 2014-01-22  7765  
9dc442143b9874 Filipe Manana             2014-02-19  7766       WARN_ON(sctx && 
!ret && !RB_EMPTY_ROOT(&sctx->orphan_dirs));
9dc442143b9874 Filipe Manana             2014-02-19  7767       while (sctx && 
!RB_EMPTY_ROOT(&sctx->orphan_dirs)) {
9dc442143b9874 Filipe Manana             2014-02-19  7768               struct 
rb_node *n;
9dc442143b9874 Filipe Manana             2014-02-19  7769               struct 
orphan_dir_info *odi;
9dc442143b9874 Filipe Manana             2014-02-19  7770  
9dc442143b9874 Filipe Manana             2014-02-19  7771               n = 
rb_first(&sctx->orphan_dirs);
9dc442143b9874 Filipe Manana             2014-02-19  7772               odi = 
rb_entry(n, struct orphan_dir_info, node);
9dc442143b9874 Filipe Manana             2014-02-19  7773               
free_orphan_dir_info(sctx, odi);
9dc442143b9874 Filipe Manana             2014-02-19  7774       }
9dc442143b9874 Filipe Manana             2014-02-19  7775  
896c14f97f700a Wang Shilong              2014-01-07  7776       if 
(sort_clone_roots) {
6f9a3da5da9e7e Josef Bacik               2020-01-24  7777               for (i 
= 0; i < sctx->clone_roots_cnt; i++) {
896c14f97f700a Wang Shilong              2014-01-07  7778                       
btrfs_root_dec_send_in_progress(
896c14f97f700a Wang Shilong              2014-01-07  7779                       
                sctx->clone_roots[i].root);
0024652895e347 Josef Bacik               2020-01-24  7780                       
btrfs_put_root(sctx->clone_roots[i].root);
6f9a3da5da9e7e Josef Bacik               2020-01-24  7781               }
896c14f97f700a Wang Shilong              2014-01-07  7782       } else {
6f9a3da5da9e7e Josef Bacik               2020-01-24  7783               for (i 
= 0; sctx && i < clone_sources_to_rollback; i++) {
896c14f97f700a Wang Shilong              2014-01-07  7784                       
btrfs_root_dec_send_in_progress(
896c14f97f700a Wang Shilong              2014-01-07  7785                       
                sctx->clone_roots[i].root);
0024652895e347 Josef Bacik               2020-01-24  7786                       
btrfs_put_root(sctx->clone_roots[i].root);
6f9a3da5da9e7e Josef Bacik               2020-01-24  7787               }
896c14f97f700a Wang Shilong              2014-01-07  7788  
896c14f97f700a Wang Shilong              2014-01-07  7789               
btrfs_root_dec_send_in_progress(send_root);
896c14f97f700a Wang Shilong              2014-01-07  7790       }
6f9a3da5da9e7e Josef Bacik               2020-01-24  7791       if (sctx && 
!IS_ERR_OR_NULL(sctx->parent_root)) {
66ef7d65c3fc6e David Sterba              2013-12-17  7792               
btrfs_root_dec_send_in_progress(sctx->parent_root);
0024652895e347 Josef Bacik               2020-01-24  7793               
btrfs_put_root(sctx->parent_root);
6f9a3da5da9e7e Josef Bacik               2020-01-24  7794       }
2c68653787f91c David Sterba              2013-12-16  7795  
2f91306a378099 David Sterba              2016-04-11  7796       
kvfree(clone_sources_tmp);
31db9f7c23fbf7 Alexander Block           2012-07-25  7797  
31db9f7c23fbf7 Alexander Block           2012-07-25  7798       if (sctx) {
31db9f7c23fbf7 Alexander Block           2012-07-25  7799               if 
(sctx->send_filp)
31db9f7c23fbf7 Alexander Block           2012-07-25  7800                       
fput(sctx->send_filp);
31db9f7c23fbf7 Alexander Block           2012-07-25  7801  
c03d01f3404282 David Sterba              2016-04-11  7802               
kvfree(sctx->clone_roots);
57cd63d9f970d5 Omar Sandoval             2020-05-01  7803               if 
(sctx->proto >= 2) {
57cd63d9f970d5 Omar Sandoval             2020-05-01  7804                       
vunmap(sctx->send_buf);
57cd63d9f970d5 Omar Sandoval             2020-05-01  7805                       
for (i = 0; i < send_buf_num_pages; i++) {
57cd63d9f970d5 Omar Sandoval             2020-05-01 @7806                       
        if (sctx->send_buf_pages[i])

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to