* [osandov:btrfs-send-encoded 13/15] fs/btrfs/send.c:7548 btrfs_ioctl_send() error: we previously assumed 'sctx->send_buf_pages' could be null (see line 7319)
@ 2021-03-17 17:14 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-03-17 17:14 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 29234 bytes --]
CC: kbuild-all(a)lists.01.org
CC: Omar Sandoval <osandov@osandov.com>
TO: Omar Sandoval <osandov@fb.com>
tree: https://github.com/osandov/linux.git btrfs-send-encoded
head: e0cd3910d8cb650fed229e4df7eca97d29c95639
commit: c26e115488f26c8c41a769f164252ce941369fdc [13/15] btrfs: send: allocate send buffer with alloc_page() and vmap() for v2
:::::: branch date: 22 hours ago
:::::: commit date: 22 hours ago
config: x86_64-randconfig-m001-20210317 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
fs/btrfs/send.c:7548 btrfs_ioctl_send() error: we previously assumed 'sctx->send_buf_pages' could be null (see line 7319)
vim +7548 fs/btrfs/send.c
62d54f3a7fa27ef Filipe Manana 2019-04-22 7225
2351f431f727223 Josef Bacik 2017-09-27 7226 long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg)
31db9f7c23fbf7e Alexander Block 2012-07-25 7227 {
31db9f7c23fbf7e Alexander Block 2012-07-25 7228 int ret = 0;
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 7229 struct btrfs_root *send_root = BTRFS_I(file_inode(mnt_file))->root;
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 7230 struct btrfs_fs_info *fs_info = send_root->fs_info;
31db9f7c23fbf7e Alexander Block 2012-07-25 7231 struct btrfs_root *clone_root;
31db9f7c23fbf7e Alexander Block 2012-07-25 7232 struct send_ctx *sctx = NULL;
31db9f7c23fbf7e Alexander Block 2012-07-25 7233 u32 i;
c26e115488f26c8 Omar Sandoval 2020-05-01 7234 u32 send_buf_num_pages = 0;
31db9f7c23fbf7e Alexander Block 2012-07-25 7235 u64 *clone_sources_tmp = NULL;
2c68653787f91c6 David Sterba 2013-12-16 7236 int clone_sources_to_rollback = 0;
bae12df966f0e1a Denis Efremov 2020-09-21 7237 size_t alloc_size;
896c14f97f700ae Wang Shilong 2014-01-07 7238 int sort_clone_roots = 0;
31db9f7c23fbf7e Alexander Block 2012-07-25 7239
31db9f7c23fbf7e Alexander Block 2012-07-25 7240 if (!capable(CAP_SYS_ADMIN))
31db9f7c23fbf7e Alexander Block 2012-07-25 7241 return -EPERM;
31db9f7c23fbf7e Alexander Block 2012-07-25 7242
2c68653787f91c6 David Sterba 2013-12-16 7243 /*
2c68653787f91c6 David Sterba 2013-12-16 7244 * The subvolume must remain read-only during send, protect against
521e0546c970c3d David Sterba 2014-04-15 7245 * making it RW. This also protects against deletion.
2c68653787f91c6 David Sterba 2013-12-16 7246 */
2c68653787f91c6 David Sterba 2013-12-16 7247 spin_lock(&send_root->root_item_lock);
62d54f3a7fa27ef Filipe Manana 2019-04-22 7248 if (btrfs_root_readonly(send_root) && send_root->dedupe_in_progress) {
62d54f3a7fa27ef Filipe Manana 2019-04-22 7249 dedupe_in_progress_warn(send_root);
62d54f3a7fa27ef Filipe Manana 2019-04-22 7250 spin_unlock(&send_root->root_item_lock);
62d54f3a7fa27ef Filipe Manana 2019-04-22 7251 return -EAGAIN;
62d54f3a7fa27ef Filipe Manana 2019-04-22 7252 }
2c68653787f91c6 David Sterba 2013-12-16 7253 send_root->send_in_progress++;
2c68653787f91c6 David Sterba 2013-12-16 7254 spin_unlock(&send_root->root_item_lock);
2c68653787f91c6 David Sterba 2013-12-16 7255
2c68653787f91c6 David Sterba 2013-12-16 7256 /*
2c68653787f91c6 David Sterba 2013-12-16 7257 * Userspace tools do the checks and warn the user if it's
2c68653787f91c6 David Sterba 2013-12-16 7258 * not RO.
2c68653787f91c6 David Sterba 2013-12-16 7259 */
2c68653787f91c6 David Sterba 2013-12-16 7260 if (!btrfs_root_readonly(send_root)) {
2c68653787f91c6 David Sterba 2013-12-16 7261 ret = -EPERM;
2c68653787f91c6 David Sterba 2013-12-16 7262 goto out;
2c68653787f91c6 David Sterba 2013-12-16 7263 }
2c68653787f91c6 David Sterba 2013-12-16 7264
457ae7268b29c33 Dan Carpenter 2017-03-17 7265 /*
457ae7268b29c33 Dan Carpenter 2017-03-17 7266 * Check that we don't overflow at later allocations, we request
457ae7268b29c33 Dan Carpenter 2017-03-17 7267 * clone_sources_count + 1 items, and compare to unsigned long inside
457ae7268b29c33 Dan Carpenter 2017-03-17 7268 * access_ok.
457ae7268b29c33 Dan Carpenter 2017-03-17 7269 */
f5ecec3ce21f706 Dan Carpenter 2016-04-13 7270 if (arg->clone_sources_count >
457ae7268b29c33 Dan Carpenter 2017-03-17 7271 ULONG_MAX / sizeof(struct clone_root) - 1) {
f5ecec3ce21f706 Dan Carpenter 2016-04-13 7272 ret = -EINVAL;
f5ecec3ce21f706 Dan Carpenter 2016-04-13 7273 goto out;
f5ecec3ce21f706 Dan Carpenter 2016-04-13 7274 }
f5ecec3ce21f706 Dan Carpenter 2016-04-13 7275
c2c71324ecb471c Stefan Behrens 2013-04-10 7276 if (arg->flags & ~BTRFS_SEND_FLAG_MASK) {
cb95e7bf7ba481c Mark Fasheh 2013-02-04 7277 ret = -EINVAL;
cb95e7bf7ba481c Mark Fasheh 2013-02-04 7278 goto out;
cb95e7bf7ba481c Mark Fasheh 2013-02-04 7279 }
cb95e7bf7ba481c Mark Fasheh 2013-02-04 7280
e780b0d1c1523ec David Sterba 2016-01-18 7281 sctx = kzalloc(sizeof(struct send_ctx), GFP_KERNEL);
31db9f7c23fbf7e Alexander Block 2012-07-25 7282 if (!sctx) {
31db9f7c23fbf7e Alexander Block 2012-07-25 7283 ret = -ENOMEM;
31db9f7c23fbf7e Alexander Block 2012-07-25 7284 goto out;
31db9f7c23fbf7e Alexander Block 2012-07-25 7285 }
31db9f7c23fbf7e Alexander Block 2012-07-25 7286
31db9f7c23fbf7e Alexander Block 2012-07-25 7287 INIT_LIST_HEAD(&sctx->new_refs);
31db9f7c23fbf7e Alexander Block 2012-07-25 7288 INIT_LIST_HEAD(&sctx->deleted_refs);
e780b0d1c1523ec David Sterba 2016-01-18 7289 INIT_RADIX_TREE(&sctx->name_cache, GFP_KERNEL);
31db9f7c23fbf7e Alexander Block 2012-07-25 7290 INIT_LIST_HEAD(&sctx->name_cache_list);
31db9f7c23fbf7e Alexander Block 2012-07-25 7291
cb95e7bf7ba481c Mark Fasheh 2013-02-04 7292 sctx->flags = arg->flags;
cb95e7bf7ba481c Mark Fasheh 2013-02-04 7293
31db9f7c23fbf7e Alexander Block 2012-07-25 7294 sctx->send_filp = fget(arg->send_fd);
ecc7ada77b5cd1a Tsutomu Itoh 2013-04-19 7295 if (!sctx->send_filp) {
ecc7ada77b5cd1a Tsutomu Itoh 2013-04-19 7296 ret = -EBADF;
31db9f7c23fbf7e Alexander Block 2012-07-25 7297 goto out;
31db9f7c23fbf7e Alexander Block 2012-07-25 7298 }
31db9f7c23fbf7e Alexander Block 2012-07-25 7299
31db9f7c23fbf7e Alexander Block 2012-07-25 7300 sctx->send_root = send_root;
521e0546c970c3d David Sterba 2014-04-15 7301 /*
521e0546c970c3d David Sterba 2014-04-15 7302 * Unlikely but possible, if the subvolume is marked for deletion but
521e0546c970c3d David Sterba 2014-04-15 7303 * is slow to remove the directory entry, send can still be started
521e0546c970c3d David Sterba 2014-04-15 7304 */
521e0546c970c3d David Sterba 2014-04-15 7305 if (btrfs_root_dead(sctx->send_root)) {
521e0546c970c3d David Sterba 2014-04-15 7306 ret = -EPERM;
521e0546c970c3d David Sterba 2014-04-15 7307 goto out;
521e0546c970c3d David Sterba 2014-04-15 7308 }
521e0546c970c3d David Sterba 2014-04-15 7309
31db9f7c23fbf7e Alexander Block 2012-07-25 7310 sctx->clone_roots_cnt = arg->clone_sources_count;
31db9f7c23fbf7e Alexander Block 2012-07-25 7311
9f56f9901144d0b Omar Sandoval 2020-05-13 7312 if (sctx->flags & BTRFS_SEND_FLAG_STREAM_V2) {
9f56f9901144d0b Omar Sandoval 2020-05-13 7313 sctx->send_max_size = ALIGN(SZ_16K + BTRFS_MAX_COMPRESSED,
9f56f9901144d0b Omar Sandoval 2020-05-13 7314 PAGE_SIZE);
c26e115488f26c8 Omar Sandoval 2020-05-01 7315 send_buf_num_pages = sctx->send_max_size >> PAGE_SHIFT;
c26e115488f26c8 Omar Sandoval 2020-05-01 7316 sctx->send_buf_pages = kcalloc(send_buf_num_pages,
c26e115488f26c8 Omar Sandoval 2020-05-01 7317 sizeof(*sctx->send_buf_pages),
c26e115488f26c8 Omar Sandoval 2020-05-01 7318 GFP_KERNEL);
c26e115488f26c8 Omar Sandoval 2020-05-01 7319 if (!sctx->send_buf_pages) {
c26e115488f26c8 Omar Sandoval 2020-05-01 7320 send_buf_num_pages = 0;
c26e115488f26c8 Omar Sandoval 2020-05-01 7321 ret = -ENOMEM;
c26e115488f26c8 Omar Sandoval 2020-05-01 7322 goto out;
c26e115488f26c8 Omar Sandoval 2020-05-01 7323 }
c26e115488f26c8 Omar Sandoval 2020-05-01 7324 for (i = 0; i < send_buf_num_pages; i++) {
c26e115488f26c8 Omar Sandoval 2020-05-01 7325 sctx->send_buf_pages[i] = alloc_page(GFP_KERNEL);
c26e115488f26c8 Omar Sandoval 2020-05-01 7326 if (!sctx->send_buf_pages[i]) {
c26e115488f26c8 Omar Sandoval 2020-05-01 7327 ret = -ENOMEM;
c26e115488f26c8 Omar Sandoval 2020-05-01 7328 goto out;
c26e115488f26c8 Omar Sandoval 2020-05-01 7329 }
c26e115488f26c8 Omar Sandoval 2020-05-01 7330 }
c26e115488f26c8 Omar Sandoval 2020-05-01 7331 sctx->send_buf = vmap(sctx->send_buf_pages, send_buf_num_pages,
c26e115488f26c8 Omar Sandoval 2020-05-01 7332 VM_MAP, PAGE_KERNEL);
9f56f9901144d0b Omar Sandoval 2020-05-13 7333 } else {
e2cd011b1f061a1 Omar Sandoval 2020-05-12 7334 sctx->send_max_size = BTRFS_SEND_BUF_SIZE_V1;
752ade68cbd81d0 Michal Hocko 2017-05-08 7335 sctx->send_buf = kvmalloc(sctx->send_max_size, GFP_KERNEL);
c26e115488f26c8 Omar Sandoval 2020-05-01 7336 }
31db9f7c23fbf7e Alexander Block 2012-07-25 7337 if (!sctx->send_buf) {
31db9f7c23fbf7e Alexander Block 2012-07-25 7338 ret = -ENOMEM;
31db9f7c23fbf7e Alexander Block 2012-07-25 7339 goto out;
31db9f7c23fbf7e Alexander Block 2012-07-25 7340 }
31db9f7c23fbf7e Alexander Block 2012-07-25 7341
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7342 sctx->pending_dir_moves = RB_ROOT;
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7343 sctx->waiting_dir_moves = RB_ROOT;
9dc442143b9874b Filipe Manana 2014-02-19 7344 sctx->orphan_dirs = RB_ROOT;
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7345
bae12df966f0e1a Denis Efremov 2020-09-21 7346 sctx->clone_roots = kvcalloc(sizeof(*sctx->clone_roots),
bae12df966f0e1a Denis Efremov 2020-09-21 7347 arg->clone_sources_count + 1,
bae12df966f0e1a Denis Efremov 2020-09-21 7348 GFP_KERNEL);
31db9f7c23fbf7e Alexander Block 2012-07-25 7349 if (!sctx->clone_roots) {
31db9f7c23fbf7e Alexander Block 2012-07-25 7350 ret = -ENOMEM;
31db9f7c23fbf7e Alexander Block 2012-07-25 7351 goto out;
31db9f7c23fbf7e Alexander Block 2012-07-25 7352 }
31db9f7c23fbf7e Alexander Block 2012-07-25 7353
bae12df966f0e1a Denis Efremov 2020-09-21 7354 alloc_size = array_size(sizeof(*arg->clone_sources),
bae12df966f0e1a Denis Efremov 2020-09-21 7355 arg->clone_sources_count);
e55d1153dbf4848 David Sterba 2016-04-11 7356
31db9f7c23fbf7e Alexander Block 2012-07-25 7357 if (arg->clone_sources_count) {
752ade68cbd81d0 Michal Hocko 2017-05-08 7358 clone_sources_tmp = kvmalloc(alloc_size, GFP_KERNEL);
31db9f7c23fbf7e Alexander Block 2012-07-25 7359 if (!clone_sources_tmp) {
31db9f7c23fbf7e Alexander Block 2012-07-25 7360 ret = -ENOMEM;
31db9f7c23fbf7e Alexander Block 2012-07-25 7361 goto out;
31db9f7c23fbf7e Alexander Block 2012-07-25 7362 }
31db9f7c23fbf7e Alexander Block 2012-07-25 7363
31db9f7c23fbf7e Alexander Block 2012-07-25 7364 ret = copy_from_user(clone_sources_tmp, arg->clone_sources,
e55d1153dbf4848 David Sterba 2016-04-11 7365 alloc_size);
31db9f7c23fbf7e Alexander Block 2012-07-25 7366 if (ret) {
31db9f7c23fbf7e Alexander Block 2012-07-25 7367 ret = -EFAULT;
31db9f7c23fbf7e Alexander Block 2012-07-25 7368 goto out;
31db9f7c23fbf7e Alexander Block 2012-07-25 7369 }
31db9f7c23fbf7e Alexander Block 2012-07-25 7370
31db9f7c23fbf7e Alexander Block 2012-07-25 7371 for (i = 0; i < arg->clone_sources_count; i++) {
56e9357a1e81671 David Sterba 2020-05-15 7372 clone_root = btrfs_get_fs_root(fs_info,
56e9357a1e81671 David Sterba 2020-05-15 7373 clone_sources_tmp[i], true);
31db9f7c23fbf7e Alexander Block 2012-07-25 7374 if (IS_ERR(clone_root)) {
31db9f7c23fbf7e Alexander Block 2012-07-25 7375 ret = PTR_ERR(clone_root);
31db9f7c23fbf7e Alexander Block 2012-07-25 7376 goto out;
31db9f7c23fbf7e Alexander Block 2012-07-25 7377 }
2c68653787f91c6 David Sterba 2013-12-16 7378 spin_lock(&clone_root->root_item_lock);
5cc2b17e80cf577 Filipe Manana 2015-03-02 7379 if (!btrfs_root_readonly(clone_root) ||
5cc2b17e80cf577 Filipe Manana 2015-03-02 7380 btrfs_root_dead(clone_root)) {
2c68653787f91c6 David Sterba 2013-12-16 7381 spin_unlock(&clone_root->root_item_lock);
0024652895e3479 Josef Bacik 2020-01-24 7382 btrfs_put_root(clone_root);
2c68653787f91c6 David Sterba 2013-12-16 7383 ret = -EPERM;
2c68653787f91c6 David Sterba 2013-12-16 7384 goto out;
2c68653787f91c6 David Sterba 2013-12-16 7385 }
62d54f3a7fa27ef Filipe Manana 2019-04-22 7386 if (clone_root->dedupe_in_progress) {
62d54f3a7fa27ef Filipe Manana 2019-04-22 7387 dedupe_in_progress_warn(clone_root);
62d54f3a7fa27ef Filipe Manana 2019-04-22 7388 spin_unlock(&clone_root->root_item_lock);
0024652895e3479 Josef Bacik 2020-01-24 7389 btrfs_put_root(clone_root);
62d54f3a7fa27ef Filipe Manana 2019-04-22 7390 ret = -EAGAIN;
62d54f3a7fa27ef Filipe Manana 2019-04-22 7391 goto out;
62d54f3a7fa27ef Filipe Manana 2019-04-22 7392 }
2f1f465ae6da244 Filipe Manana 2015-03-02 7393 clone_root->send_in_progress++;
2c68653787f91c6 David Sterba 2013-12-16 7394 spin_unlock(&clone_root->root_item_lock);
18f687d53844937 Wang Shilong 2014-01-07 7395
31db9f7c23fbf7e Alexander Block 2012-07-25 7396 sctx->clone_roots[i].root = clone_root;
2f1f465ae6da244 Filipe Manana 2015-03-02 7397 clone_sources_to_rollback = i + 1;
31db9f7c23fbf7e Alexander Block 2012-07-25 7398 }
2f91306a3780990 David Sterba 2016-04-11 7399 kvfree(clone_sources_tmp);
31db9f7c23fbf7e Alexander Block 2012-07-25 7400 clone_sources_tmp = NULL;
31db9f7c23fbf7e Alexander Block 2012-07-25 7401 }
31db9f7c23fbf7e Alexander Block 2012-07-25 7402
31db9f7c23fbf7e Alexander Block 2012-07-25 7403 if (arg->parent_root) {
56e9357a1e81671 David Sterba 2020-05-15 7404 sctx->parent_root = btrfs_get_fs_root(fs_info, arg->parent_root,
56e9357a1e81671 David Sterba 2020-05-15 7405 true);
b1b195969fe6d93 Stefan Behrens 2013-05-13 7406 if (IS_ERR(sctx->parent_root)) {
b1b195969fe6d93 Stefan Behrens 2013-05-13 7407 ret = PTR_ERR(sctx->parent_root);
31db9f7c23fbf7e Alexander Block 2012-07-25 7408 goto out;
31db9f7c23fbf7e Alexander Block 2012-07-25 7409 }
18f687d53844937 Wang Shilong 2014-01-07 7410
2c68653787f91c6 David Sterba 2013-12-16 7411 spin_lock(&sctx->parent_root->root_item_lock);
2c68653787f91c6 David Sterba 2013-12-16 7412 sctx->parent_root->send_in_progress++;
521e0546c970c3d David Sterba 2014-04-15 7413 if (!btrfs_root_readonly(sctx->parent_root) ||
521e0546c970c3d David Sterba 2014-04-15 7414 btrfs_root_dead(sctx->parent_root)) {
2c68653787f91c6 David Sterba 2013-12-16 7415 spin_unlock(&sctx->parent_root->root_item_lock);
2c68653787f91c6 David Sterba 2013-12-16 7416 ret = -EPERM;
2c68653787f91c6 David Sterba 2013-12-16 7417 goto out;
2c68653787f91c6 David Sterba 2013-12-16 7418 }
62d54f3a7fa27ef Filipe Manana 2019-04-22 7419 if (sctx->parent_root->dedupe_in_progress) {
62d54f3a7fa27ef Filipe Manana 2019-04-22 7420 dedupe_in_progress_warn(sctx->parent_root);
62d54f3a7fa27ef Filipe Manana 2019-04-22 7421 spin_unlock(&sctx->parent_root->root_item_lock);
62d54f3a7fa27ef Filipe Manana 2019-04-22 7422 ret = -EAGAIN;
62d54f3a7fa27ef Filipe Manana 2019-04-22 7423 goto out;
62d54f3a7fa27ef Filipe Manana 2019-04-22 7424 }
2c68653787f91c6 David Sterba 2013-12-16 7425 spin_unlock(&sctx->parent_root->root_item_lock);
31db9f7c23fbf7e Alexander Block 2012-07-25 7426 }
31db9f7c23fbf7e Alexander Block 2012-07-25 7427
31db9f7c23fbf7e Alexander Block 2012-07-25 7428 /*
31db9f7c23fbf7e Alexander Block 2012-07-25 7429 * Clones from send_root are allowed, but only if the clone source
31db9f7c23fbf7e Alexander Block 2012-07-25 7430 * is behind the current send position. This is checked while searching
31db9f7c23fbf7e Alexander Block 2012-07-25 7431 * for possible clone sources.
31db9f7c23fbf7e Alexander Block 2012-07-25 7432 */
6f9a3da5da9e7e5 Josef Bacik 2020-01-24 7433 sctx->clone_roots[sctx->clone_roots_cnt++].root =
0024652895e3479 Josef Bacik 2020-01-24 7434 btrfs_grab_root(sctx->send_root);
31db9f7c23fbf7e Alexander Block 2012-07-25 7435
31db9f7c23fbf7e Alexander Block 2012-07-25 7436 /* We do a bsearch later */
31db9f7c23fbf7e Alexander Block 2012-07-25 7437 sort(sctx->clone_roots, sctx->clone_roots_cnt,
31db9f7c23fbf7e Alexander Block 2012-07-25 7438 sizeof(*sctx->clone_roots), __clone_root_cmp_sort,
31db9f7c23fbf7e Alexander Block 2012-07-25 7439 NULL);
896c14f97f700ae Wang Shilong 2014-01-07 7440 sort_clone_roots = 1;
31db9f7c23fbf7e Alexander Block 2012-07-25 7441
9f89d5de8631c79 Filipe Manana 2019-04-15 7442 ret = flush_delalloc_roots(sctx);
9f89d5de8631c79 Filipe Manana 2019-04-15 7443 if (ret)
9f89d5de8631c79 Filipe Manana 2019-04-15 7444 goto out;
9f89d5de8631c79 Filipe Manana 2019-04-15 7445
e5fa8f865b3324a Filipe Manana 2014-10-21 7446 ret = ensure_commit_roots_uptodate(sctx);
e5fa8f865b3324a Filipe Manana 2014-10-21 7447 if (ret)
e5fa8f865b3324a Filipe Manana 2014-10-21 7448 goto out;
e5fa8f865b3324a Filipe Manana 2014-10-21 7449
9e967495e0e0ae8 Filipe Manana 2019-04-22 7450 mutex_lock(&fs_info->balance_mutex);
9e967495e0e0ae8 Filipe Manana 2019-04-22 7451 if (test_bit(BTRFS_FS_BALANCE_RUNNING, &fs_info->flags)) {
9e967495e0e0ae8 Filipe Manana 2019-04-22 7452 mutex_unlock(&fs_info->balance_mutex);
9e967495e0e0ae8 Filipe Manana 2019-04-22 7453 btrfs_warn_rl(fs_info,
9e967495e0e0ae8 Filipe Manana 2019-04-22 7454 "cannot run send because a balance operation is in progress");
9e967495e0e0ae8 Filipe Manana 2019-04-22 7455 ret = -EAGAIN;
9e967495e0e0ae8 Filipe Manana 2019-04-22 7456 goto out;
9e967495e0e0ae8 Filipe Manana 2019-04-22 7457 }
9e967495e0e0ae8 Filipe Manana 2019-04-22 7458 fs_info->send_in_progress++;
9e967495e0e0ae8 Filipe Manana 2019-04-22 7459 mutex_unlock(&fs_info->balance_mutex);
9e967495e0e0ae8 Filipe Manana 2019-04-22 7460
2755a0de6469350 David Sterba 2014-07-31 7461 current->journal_info = BTRFS_SEND_TRANS_STUB;
31db9f7c23fbf7e Alexander Block 2012-07-25 7462 ret = send_subvol(sctx);
a26e8c9f75b0bfd Josef Bacik 2014-03-28 7463 current->journal_info = NULL;
9e967495e0e0ae8 Filipe Manana 2019-04-22 7464 mutex_lock(&fs_info->balance_mutex);
9e967495e0e0ae8 Filipe Manana 2019-04-22 7465 fs_info->send_in_progress--;
9e967495e0e0ae8 Filipe Manana 2019-04-22 7466 mutex_unlock(&fs_info->balance_mutex);
31db9f7c23fbf7e Alexander Block 2012-07-25 7467 if (ret < 0)
31db9f7c23fbf7e Alexander Block 2012-07-25 7468 goto out;
31db9f7c23fbf7e Alexander Block 2012-07-25 7469
c2c71324ecb471c Stefan Behrens 2013-04-10 7470 if (!(sctx->flags & BTRFS_SEND_FLAG_OMIT_END_CMD)) {
31db9f7c23fbf7e Alexander Block 2012-07-25 7471 ret = begin_cmd(sctx, BTRFS_SEND_C_END);
31db9f7c23fbf7e Alexander Block 2012-07-25 7472 if (ret < 0)
31db9f7c23fbf7e Alexander Block 2012-07-25 7473 goto out;
31db9f7c23fbf7e Alexander Block 2012-07-25 7474 ret = send_cmd(sctx);
31db9f7c23fbf7e Alexander Block 2012-07-25 7475 if (ret < 0)
31db9f7c23fbf7e Alexander Block 2012-07-25 7476 goto out;
c2c71324ecb471c Stefan Behrens 2013-04-10 7477 }
31db9f7c23fbf7e Alexander Block 2012-07-25 7478
31db9f7c23fbf7e Alexander Block 2012-07-25 7479 out:
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7480 WARN_ON(sctx && !ret && !RB_EMPTY_ROOT(&sctx->pending_dir_moves));
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7481 while (sctx && !RB_EMPTY_ROOT(&sctx->pending_dir_moves)) {
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7482 struct rb_node *n;
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7483 struct pending_dir_move *pm;
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7484
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7485 n = rb_first(&sctx->pending_dir_moves);
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7486 pm = rb_entry(n, struct pending_dir_move, node);
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7487 while (!list_empty(&pm->list)) {
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7488 struct pending_dir_move *pm2;
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7489
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7490 pm2 = list_first_entry(&pm->list,
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7491 struct pending_dir_move, list);
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7492 free_pending_move(sctx, pm2);
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7493 }
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7494 free_pending_move(sctx, pm);
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7495 }
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7496
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7497 WARN_ON(sctx && !ret && !RB_EMPTY_ROOT(&sctx->waiting_dir_moves));
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7498 while (sctx && !RB_EMPTY_ROOT(&sctx->waiting_dir_moves)) {
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7499 struct rb_node *n;
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7500 struct waiting_dir_move *dm;
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7501
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7502 n = rb_first(&sctx->waiting_dir_moves);
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7503 dm = rb_entry(n, struct waiting_dir_move, node);
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7504 rb_erase(&dm->node, &sctx->waiting_dir_moves);
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7505 kfree(dm);
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7506 }
9f03740a956d7ac Filipe David Borba Manana 2014-01-22 7507
9dc442143b9874b Filipe Manana 2014-02-19 7508 WARN_ON(sctx && !ret && !RB_EMPTY_ROOT(&sctx->orphan_dirs));
9dc442143b9874b Filipe Manana 2014-02-19 7509 while (sctx && !RB_EMPTY_ROOT(&sctx->orphan_dirs)) {
9dc442143b9874b Filipe Manana 2014-02-19 7510 struct rb_node *n;
9dc442143b9874b Filipe Manana 2014-02-19 7511 struct orphan_dir_info *odi;
9dc442143b9874b Filipe Manana 2014-02-19 7512
9dc442143b9874b Filipe Manana 2014-02-19 7513 n = rb_first(&sctx->orphan_dirs);
9dc442143b9874b Filipe Manana 2014-02-19 7514 odi = rb_entry(n, struct orphan_dir_info, node);
9dc442143b9874b Filipe Manana 2014-02-19 7515 free_orphan_dir_info(sctx, odi);
9dc442143b9874b Filipe Manana 2014-02-19 7516 }
9dc442143b9874b Filipe Manana 2014-02-19 7517
896c14f97f700ae Wang Shilong 2014-01-07 7518 if (sort_clone_roots) {
6f9a3da5da9e7e5 Josef Bacik 2020-01-24 7519 for (i = 0; i < sctx->clone_roots_cnt; i++) {
896c14f97f700ae Wang Shilong 2014-01-07 7520 btrfs_root_dec_send_in_progress(
896c14f97f700ae Wang Shilong 2014-01-07 7521 sctx->clone_roots[i].root);
0024652895e3479 Josef Bacik 2020-01-24 7522 btrfs_put_root(sctx->clone_roots[i].root);
6f9a3da5da9e7e5 Josef Bacik 2020-01-24 7523 }
896c14f97f700ae Wang Shilong 2014-01-07 7524 } else {
6f9a3da5da9e7e5 Josef Bacik 2020-01-24 7525 for (i = 0; sctx && i < clone_sources_to_rollback; i++) {
896c14f97f700ae Wang Shilong 2014-01-07 7526 btrfs_root_dec_send_in_progress(
896c14f97f700ae Wang Shilong 2014-01-07 7527 sctx->clone_roots[i].root);
0024652895e3479 Josef Bacik 2020-01-24 7528 btrfs_put_root(sctx->clone_roots[i].root);
6f9a3da5da9e7e5 Josef Bacik 2020-01-24 7529 }
896c14f97f700ae Wang Shilong 2014-01-07 7530
896c14f97f700ae Wang Shilong 2014-01-07 7531 btrfs_root_dec_send_in_progress(send_root);
896c14f97f700ae Wang Shilong 2014-01-07 7532 }
6f9a3da5da9e7e5 Josef Bacik 2020-01-24 7533 if (sctx && !IS_ERR_OR_NULL(sctx->parent_root)) {
66ef7d65c3fc6e5 David Sterba 2013-12-17 7534 btrfs_root_dec_send_in_progress(sctx->parent_root);
0024652895e3479 Josef Bacik 2020-01-24 7535 btrfs_put_root(sctx->parent_root);
6f9a3da5da9e7e5 Josef Bacik 2020-01-24 7536 }
2c68653787f91c6 David Sterba 2013-12-16 7537
2f91306a3780990 David Sterba 2016-04-11 7538 kvfree(clone_sources_tmp);
31db9f7c23fbf7e Alexander Block 2012-07-25 7539
31db9f7c23fbf7e Alexander Block 2012-07-25 7540 if (sctx) {
31db9f7c23fbf7e Alexander Block 2012-07-25 7541 if (sctx->send_filp)
31db9f7c23fbf7e Alexander Block 2012-07-25 7542 fput(sctx->send_filp);
31db9f7c23fbf7e Alexander Block 2012-07-25 7543
c03d01f34042827 David Sterba 2016-04-11 7544 kvfree(sctx->clone_roots);
c26e115488f26c8 Omar Sandoval 2020-05-01 7545 if (sctx->flags & BTRFS_SEND_FLAG_STREAM_V2) {
c26e115488f26c8 Omar Sandoval 2020-05-01 7546 vunmap(sctx->send_buf);
c26e115488f26c8 Omar Sandoval 2020-05-01 7547 for (i = 0; i < send_buf_num_pages; i++) {
c26e115488f26c8 Omar Sandoval 2020-05-01 @7548 if (sctx->send_buf_pages[i])
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34575 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-17 17:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17 17:14 [osandov:btrfs-send-encoded 13/15] fs/btrfs/send.c:7548 btrfs_ioctl_send() error: we previously assumed 'sctx->send_buf_pages' could be null (see line 7319) kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.