CC: [email protected]
CC: [email protected]
BCC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Nikolay Borisov <[email protected]>
TO: [email protected]
CC: Nikolay Borisov <[email protected]>

Hi Nikolay,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kdave/for-next]
[also build test WARNING on next-20220503]
[cannot apply to v5.18-rc5]
[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/intel-lab-lkp/linux/commits/Nikolay-Borisov/Refactor-btrfs_ioctl_balance/20220503-163837
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
:::::: branch date: 15 hours ago
:::::: commit date: 15 hours ago
config: riscv-randconfig-c006-20220501 
(https://download.01.org/0day-ci/archive/20220504/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 
363b3a645a1e30011cc8da624f13dac5fd915628)
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 riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # 
https://github.com/intel-lab-lkp/linux/commit/c696e46e6ec2b391d6e350b4323ef7e7bafa7bca
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review 
Nikolay-Borisov/Refactor-btrfs_ioctl_balance/20220503-163837
        git checkout c696e46e6ec2b391d6e350b4323ef7e7bafa7bca
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 
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 >>)
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:4333:2: note: Call to function 'memcpy' is insecure as it 
does not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memcpy_s' in case of C11
           memcpy(&bargs->stat, &bctl->stat, sizeof(bargs->stat));
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:4463:2: warning: Call to function 'memcpy' is insecure as 
it does not provide security checks introduced in the C11 standard. Replace 
with analogous functions that support length arguments or provides boundary 
checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memcpy(&bctl->data, &bargs->data, sizeof(bctl->data));
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:4463:2: note: Call to function 'memcpy' is insecure as it 
does not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memcpy_s' in case of C11
           memcpy(&bctl->data, &bargs->data, sizeof(bctl->data));
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:4464:2: warning: Call to function 'memcpy' is insecure as 
it does not provide security checks introduced in the C11 standard. Replace 
with analogous functions that support length arguments or provides boundary 
checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memcpy(&bctl->meta, &bargs->meta, sizeof(bctl->meta));
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:4464:2: note: Call to function 'memcpy' is insecure as it 
does not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memcpy_s' in case of C11
           memcpy(&bctl->meta, &bargs->meta, sizeof(bctl->meta));
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:4465:2: warning: Call to function 'memcpy' is insecure as 
it does not provide security checks introduced in the C11 standard. Replace 
with analogous functions that support length arguments or provides boundary 
checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memcpy(&bctl->sys, &bargs->sys, sizeof(bctl->sys));
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:4465:2: note: Call to function 'memcpy' is insecure as it 
does not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memcpy_s' in case of C11
           memcpy(&bctl->sys, &bargs->sys, sizeof(bctl->sys));
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
>> fs/btrfs/ioctl.c:4493:2: warning: Attempt to free released memory 
>> [clang-analyzer-unix.Malloc]
           kfree(bargs);
           ^
   fs/btrfs/ioctl.c:5426:2: note: Control jumps to 'case 3288372256:'  at line 
5508
           switch (cmd) {
           ^
   fs/btrfs/ioctl.c:5509:10: note: Calling 'btrfs_ioctl_balance'
                   return btrfs_ioctl_balance(file, argp);
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:4412:6: note: Assuming the condition is false
           if (!capable(CAP_SYS_ADMIN))
               ^~~~~~~~~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:4412:2: note: Taking false branch
           if (!capable(CAP_SYS_ADMIN))
           ^
   fs/btrfs/ioctl.c:4416:6: note: Assuming 'ret' is 0
           if (ret)
               ^~~
   fs/btrfs/ioctl.c:4416:2: note: Taking false branch
           if (ret)
           ^
   fs/btrfs/ioctl.c:4420:2: note: Taking false branch
           if (IS_ERR(bargs)) {
           ^
   fs/btrfs/ioctl.c:4427:6: note: 'ret' is 8
           if (ret)
               ^~~
   fs/btrfs/ioctl.c:4427:2: note: Taking true branch
           if (ret)
           ^
   fs/btrfs/ioctl.c:4428:3: note: Control jumps to line 4491
                   goto out;
                   ^
   fs/btrfs/ioctl.c:4491:2: note: Memory is released
           kfree(bargs);
           ^~~~~~~~~~~~
   fs/btrfs/ioctl.c:4493:2: note: Attempt to free released memory
           kfree(bargs);
           ^~~~~~~~~~~~
   fs/btrfs/ioctl.c:4856:2: warning: Call to function 'memcpy' is insecure as 
it does not provide security checks introduced in the C11 standard. Replace 
with analogous functions that support length arguments or provides boundary 
checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memcpy(root_item->received_uuid, sa->uuid, BTRFS_UUID_SIZE);
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:4856:2: note: Call to function 'memcpy' is insecure as it 
does not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memcpy_s' in case of C11
           memcpy(root_item->received_uuid, sa->uuid, BTRFS_UUID_SIZE);
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:4970:2: warning: Call to function 'memcpy' is insecure as 
it does not provide security checks introduced in the C11 standard. Replace 
with analogous functions that support length arguments or provides boundary 
checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memcpy(label, fs_info->super_copy->label, BTRFS_LABEL_SIZE);
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:4970:2: note: Call to function 'memcpy' is insecure as it 
does not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memcpy_s' in case of C11
           memcpy(label, fs_info->super_copy->label, BTRFS_LABEL_SIZE);
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:5020:2: warning: Call to function 'strcpy' is insecure as 
it does not provide bounding of the memory buffer. Replace unbounded copy 
functions with analogous functions that support length arguments such as 
'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcpy(super_block->label, label);
           ^~~~~~
   fs/btrfs/ioctl.c:5020:2: note: Call to function 'strcpy' is insecure as it 
does not provide bounding of the memory buffer. Replace unbounded copy 
functions with analogous functions that support length arguments such as 
'strlcpy'. CWE-119
           strcpy(super_block->label, label);
           ^~~~~~
   Suppressed 56 warnings (56 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   38 warnings generated.
   Suppressed 38 warnings (38 in non-user code).

vim +4493 fs/btrfs/ioctl.c

d383145190e87f Nikolay Borisov      2022-05-03  4402  
9ba1f6e44ed7a1 Liu Bo               2012-05-11  4403  static long 
btrfs_ioctl_balance(struct file *file, void __user *arg)
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4404  {
496ad9aa8ef448 Al Viro              2013-01-23  4405    struct btrfs_root *root 
= BTRFS_I(file_inode(file))->root;
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4406    struct btrfs_fs_info 
*fs_info = root->fs_info;
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4407    struct 
btrfs_ioctl_balance_args *bargs;
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4408    struct 
btrfs_balance_control *bctl;
c696e46e6ec2b3 Nikolay Borisov      2022-05-03  4409    bool need_unlock = 
true; /* for mut. excl. ops lock */
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4410    int ret;
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4411  
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4412    if 
(!capable(CAP_SYS_ADMIN))
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4413            return -EPERM;
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4414  
e54bfa31044d60 Liu Bo               2012-06-29  4415    ret = 
mnt_want_write_file(file);
9ba1f6e44ed7a1 Liu Bo               2012-05-11  4416    if (ret)
9ba1f6e44ed7a1 Liu Bo               2012-05-11  4417            return ret;
9ba1f6e44ed7a1 Liu Bo               2012-05-11  4418  
c746db1b6ed99f Nikolay Borisov      2022-03-30  4419    bargs = 
memdup_user(arg, sizeof(*bargs));
c746db1b6ed99f Nikolay Borisov      2022-03-30  4420    if (IS_ERR(bargs)) {
c746db1b6ed99f Nikolay Borisov      2022-03-30  4421            ret = 
PTR_ERR(bargs);
c746db1b6ed99f Nikolay Borisov      2022-03-30  4422            bargs = NULL;
c746db1b6ed99f Nikolay Borisov      2022-03-30  4423            goto out;
c746db1b6ed99f Nikolay Borisov      2022-03-30  4424    }
c746db1b6ed99f Nikolay Borisov      2022-03-30  4425  
c696e46e6ec2b3 Nikolay Borisov      2022-05-03  4426    ret = 
btrfs_try_lock_balance(fs_info, &need_unlock);
c696e46e6ec2b3 Nikolay Borisov      2022-05-03  4427    if (ret)
ed0fb78fb6aa29 Ilya Dryomov         2013-01-20  4428            goto out;
ed0fb78fb6aa29 Ilya Dryomov         2013-01-20  4429  
c696e46e6ec2b3 Nikolay Borisov      2022-05-03  4430    
lockdep_assert_held(&fs_info->balance_mutex);
c696e46e6ec2b3 Nikolay Borisov      2022-05-03  4431  
de322263d3a6d4 Ilya Dryomov         2012-01-16  4432    if (bargs->flags & 
BTRFS_BALANCE_RESUME) {
de322263d3a6d4 Ilya Dryomov         2012-01-16  4433            if 
(!fs_info->balance_ctl) {
de322263d3a6d4 Ilya Dryomov         2012-01-16  4434                    ret = 
-ENOTCONN;
c746db1b6ed99f Nikolay Borisov      2022-03-30  4435                    goto 
out_unlock;
de322263d3a6d4 Ilya Dryomov         2012-01-16  4436            }
de322263d3a6d4 Ilya Dryomov         2012-01-16  4437  
de322263d3a6d4 Ilya Dryomov         2012-01-16  4438            bctl = 
fs_info->balance_ctl;
de322263d3a6d4 Ilya Dryomov         2012-01-16  4439            
spin_lock(&fs_info->balance_lock);
de322263d3a6d4 Ilya Dryomov         2012-01-16  4440            bctl->flags |= 
BTRFS_BALANCE_RESUME;
de322263d3a6d4 Ilya Dryomov         2012-01-16  4441            
spin_unlock(&fs_info->balance_lock);
efc0e69c2feab8 Nikolay Borisov      2021-11-25  4442            
btrfs_exclop_balance(fs_info, BTRFS_EXCLOP_BALANCE);
de322263d3a6d4 Ilya Dryomov         2012-01-16  4443  
de322263d3a6d4 Ilya Dryomov         2012-01-16  4444            goto do_balance;
de322263d3a6d4 Ilya Dryomov         2012-01-16  4445    }
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4446  
c746db1b6ed99f Nikolay Borisov      2022-03-30  4447    if (bargs->flags & 
~(BTRFS_BALANCE_ARGS_MASK | BTRFS_BALANCE_TYPE_MASK)) {
c746db1b6ed99f Nikolay Borisov      2022-03-30  4448            ret = -EINVAL;
c746db1b6ed99f Nikolay Borisov      2022-03-30  4449            goto out_unlock;
c746db1b6ed99f Nikolay Borisov      2022-03-30  4450    }
c746db1b6ed99f Nikolay Borisov      2022-03-30  4451  
ed0fb78fb6aa29 Ilya Dryomov         2013-01-20  4452    if 
(fs_info->balance_ctl) {
837d5b6e46d1a4 Ilya Dryomov         2012-01-16  4453            ret = 
-EINPROGRESS;
c746db1b6ed99f Nikolay Borisov      2022-03-30  4454            goto out_unlock;
837d5b6e46d1a4 Ilya Dryomov         2012-01-16  4455    }
837d5b6e46d1a4 Ilya Dryomov         2012-01-16  4456  
8d2db7855e7b65 David Sterba         2015-11-04  4457    bctl = 
kzalloc(sizeof(*bctl), GFP_KERNEL);
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4458    if (!bctl) {
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4459            ret = -ENOMEM;
c746db1b6ed99f Nikolay Borisov      2022-03-30  4460            goto out_unlock;
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4461    }
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4462  
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4463    memcpy(&bctl->data, 
&bargs->data, sizeof(bctl->data));
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4464    memcpy(&bctl->meta, 
&bargs->meta, sizeof(bctl->meta));
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4465    memcpy(&bctl->sys, 
&bargs->sys, sizeof(bctl->sys));
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4466  
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4467    bctl->flags = 
bargs->flags;
de322263d3a6d4 Ilya Dryomov         2012-01-16  4468  do_balance:
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4469    /*
c3e1f96c37d0f8 Goldwyn Rodrigues    2020-08-25  4470     * Ownership of bctl 
and exclusive operation goes to btrfs_balance.
c3e1f96c37d0f8 Goldwyn Rodrigues    2020-08-25  4471     * bctl is freed in 
reset_balance_state, or, if restriper was paused
c3e1f96c37d0f8 Goldwyn Rodrigues    2020-08-25  4472     * all the way until 
unmount, in free_fs_info.  The flag should be
c3e1f96c37d0f8 Goldwyn Rodrigues    2020-08-25  4473     * cleared after 
reset_balance_state.
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4474     */
ed0fb78fb6aa29 Ilya Dryomov         2013-01-20  4475    need_unlock = false;
ed0fb78fb6aa29 Ilya Dryomov         2013-01-20  4476  
6fcf6e2bffb6cf David Sterba         2018-05-07  4477    ret = 
btrfs_balance(fs_info, bctl, bargs);
0f89abf56abbd0 Christian Engelmayer 2015-10-21  4478    bctl = NULL;
ed0fb78fb6aa29 Ilya Dryomov         2013-01-20  4479  
70430fe3604144 Nikolay Borisov      2022-03-30  4480    if (ret == 0 || ret == 
-ECANCELED) {
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4481            if 
(copy_to_user(arg, bargs, sizeof(*bargs)))
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4482                    ret = 
-EFAULT;
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4483    }
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4484  
0f89abf56abbd0 Christian Engelmayer 2015-10-21  4485    kfree(bctl);
ed0fb78fb6aa29 Ilya Dryomov         2013-01-20  4486  out_unlock:
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4487    
mutex_unlock(&fs_info->balance_mutex);
ed0fb78fb6aa29 Ilya Dryomov         2013-01-20  4488    if (need_unlock)
c3e1f96c37d0f8 Goldwyn Rodrigues    2020-08-25  4489            
btrfs_exclop_finish(fs_info);
ed0fb78fb6aa29 Ilya Dryomov         2013-01-20  4490  out:
c696e46e6ec2b3 Nikolay Borisov      2022-05-03  4491    kfree(bargs);
e54bfa31044d60 Liu Bo               2012-06-29  4492    
mnt_drop_write_file(file);
c746db1b6ed99f Nikolay Borisov      2022-03-30 @4493    kfree(bargs);
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4494    return ret;
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4495  }
c9e9f97bdfb64d Ilya Dryomov         2012-01-16  4496  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to