* [bcachefs:bcachefs-testing 6/6] fs/bcachefs/dirent.c:436:2: error: a label can only be part of a statement and a declaration is not a statement
@ 2024-01-22 11:49 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-01-22 11:49 UTC (permalink / raw)
To: Kent Overstreet; +Cc: oe-kbuild-all, Kent Overstreet
tree: https://evilpiepirate.org/git/bcachefs.git bcachefs-testing
head: 05b33431c0012466dd40e9949d475adfd45dfc9b
commit: 05b33431c0012466dd40e9949d475adfd45dfc9b [6/6] bcachefs: Subvolumes may now be renamed
config: i386-randconfig-012-20240122 (https://download.01.org/0day-ci/archive/20240122/202401221931.LiA3136x-lkp@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240122/202401221931.LiA3136x-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401221931.LiA3136x-lkp@intel.com/
All errors (new ones prefixed by >>):
fs/bcachefs/dirent.c: In function 'bch2_dirent_rename':
>> fs/bcachefs/dirent.c:436:2: error: a label can only be part of a statement and a declaration is not a statement
436 | bool delete_src = bkey_s_c_to_dirent(old_src).v->d_type == DT_SUBVOL &&
| ^~~~
>> fs/bcachefs/dirent.c:439:2: error: expected expression before 'bool'
439 | bool delete_dst = old_dst.k &&
| ^~~~
>> fs/bcachefs/dirent.c:457:6: error: 'delete_dst' undeclared (first use in this function); did you mean 'delete_src'?
457 | if (delete_dst) {
| ^~~~~~~~~~
| delete_src
fs/bcachefs/dirent.c:457:6: note: each undeclared identifier is reported only once for each function it appears in
vim +436 fs/bcachefs/dirent.c
282
283 int bch2_dirent_rename(struct btree_trans *trans,
284 subvol_inum src_dir, struct bch_hash_info *src_hash,
285 subvol_inum dst_dir, struct bch_hash_info *dst_hash,
286 const struct qstr *src_name, subvol_inum *src_inum, u64 *src_offset,
287 const struct qstr *dst_name, subvol_inum *dst_inum, u64 *dst_offset,
288 enum bch_rename_mode mode)
289 {
290 struct btree_iter src_iter = { NULL };
291 struct btree_iter dst_iter = { NULL };
292 struct bkey_s_c old_src, old_dst = bkey_s_c_null;
293 struct bkey_i_dirent *new_src = NULL, *new_dst = NULL;
294 struct bpos dst_pos =
295 POS(dst_dir.inum, bch2_dirent_hash(dst_hash, dst_name));
296 unsigned src_update_flags = 0;
297 int ret = 0;
298
299 memset(src_inum, 0, sizeof(*src_inum));
300 memset(dst_inum, 0, sizeof(*dst_inum));
301
302 /* Lookup src: */
303 ret = bch2_hash_lookup(trans, &src_iter, bch2_dirent_hash_desc,
304 src_hash, src_dir, src_name,
305 BTREE_ITER_INTENT);
306 if (ret)
307 goto out;
308
309 old_src = bch2_btree_iter_peek_slot(&src_iter);
310 ret = bkey_err(old_src);
311 if (ret)
312 goto out;
313
314 ret = bch2_dirent_read_target(trans, src_dir,
315 bkey_s_c_to_dirent(old_src), src_inum);
316 if (ret)
317 goto out;
318
319 /* Lookup dst: */
320 if (mode == BCH_RENAME) {
321 /*
322 * Note that we're _not_ checking if the target already exists -
323 * we're relying on the VFS to do that check for us for
324 * correctness:
325 */
326 ret = bch2_hash_hole(trans, &dst_iter, bch2_dirent_hash_desc,
327 dst_hash, dst_dir, dst_name);
328 if (ret)
329 goto out;
330 } else {
331 ret = bch2_hash_lookup(trans, &dst_iter, bch2_dirent_hash_desc,
332 dst_hash, dst_dir, dst_name,
333 BTREE_ITER_INTENT);
334 if (ret)
335 goto out;
336
337 old_dst = bch2_btree_iter_peek_slot(&dst_iter);
338 ret = bkey_err(old_dst);
339 if (ret)
340 goto out;
341
342 ret = bch2_dirent_read_target(trans, dst_dir,
343 bkey_s_c_to_dirent(old_dst), dst_inum);
344 if (ret)
345 goto out;
346 }
347
348 if (mode != BCH_RENAME_EXCHANGE)
349 *src_offset = dst_iter.pos.offset;
350
351 /* Create new dst key: */
352 new_dst = dirent_create_key(trans, dst_dir, 0, dst_name, 0);
353 ret = PTR_ERR_OR_ZERO(new_dst);
354 if (ret)
355 goto out;
356
357 dirent_copy_target(new_dst, bkey_s_c_to_dirent(old_src));
358 new_dst->k.p = dst_iter.pos;
359
360 /* Create new src key: */
361 if (mode == BCH_RENAME_EXCHANGE) {
362 new_src = dirent_create_key(trans, src_dir, 0, src_name, 0);
363 ret = PTR_ERR_OR_ZERO(new_src);
364 if (ret)
365 goto out;
366
367 dirent_copy_target(new_src, bkey_s_c_to_dirent(old_dst));
368 new_src->k.p = src_iter.pos;
369 } else {
370 new_src = bch2_trans_kmalloc(trans, sizeof(struct bkey_i));
371 ret = PTR_ERR_OR_ZERO(new_src);
372 if (ret)
373 goto out;
374
375 bkey_init(&new_src->k);
376 new_src->k.p = src_iter.pos;
377
378 if (bkey_le(dst_pos, src_iter.pos) &&
379 bkey_lt(src_iter.pos, dst_iter.pos)) {
380 /*
381 * We have a hash collision for the new dst key,
382 * and new_src - the key we're deleting - is between
383 * new_dst's hashed slot and the slot we're going to be
384 * inserting it into - oops. This will break the hash
385 * table if we don't deal with it:
386 */
387 if (mode == BCH_RENAME) {
388 /*
389 * If we're not overwriting, we can just insert
390 * new_dst at the src position:
391 */
392 new_src = new_dst;
393 new_src->k.p = src_iter.pos;
394 goto out_set_src;
395 } else {
396 /* If we're overwriting, we can't insert new_dst
397 * at a different slot because it has to
398 * overwrite old_dst - just make sure to use a
399 * whiteout when deleting src:
400 */
401 new_src->k.type = KEY_TYPE_hash_whiteout;
402 }
403 } else {
404 /* Check if we need a whiteout to delete src: */
405 ret = bch2_hash_needs_whiteout(trans, bch2_dirent_hash_desc,
406 src_hash, &src_iter);
407 if (ret < 0)
408 goto out;
409
410 if (ret)
411 new_src->k.type = KEY_TYPE_hash_whiteout;
412 }
413 }
414
415 if (new_dst->v.d_type == DT_SUBVOL)
416 new_dst->v.d_parent_subvol = cpu_to_le32(dst_dir.subvol);
417
418 if ((mode == BCH_RENAME_EXCHANGE) &&
419 new_src->v.d_type == DT_SUBVOL)
420 new_src->v.d_parent_subvol = cpu_to_le32(src_dir.subvol);
421
422 ret = bch2_trans_update(trans, &dst_iter, &new_dst->k_i, 0);
423 if (ret)
424 goto out;
425 out_set_src:
426 /*
427 * If we're deleting a subvolume we need to really delete the dirent,
428 * not just emit a whiteout in the current snapshot - there can only be
429 * single dirent that points to a given subvolume.
430 *
431 * IOW, we don't maintain multiple versions in different snapshots of
432 * dirents that point to subvolumes - dirents that point to subvolumes
433 * are only visible in one particular subvolume so it's not necessary,
434 * and it would be particularly confusing for fsck to have to deal with.
435 */
> 436 bool delete_src = bkey_s_c_to_dirent(old_src).v->d_type == DT_SUBVOL &&
437 new_src->k.p.snapshot != old_src.k->p.snapshot;
438
> 439 bool delete_dst = old_dst.k &&
440 bkey_s_c_to_dirent(old_dst).v->d_type == DT_SUBVOL &&
441 new_dst->k.p.snapshot != old_dst.k->p.snapshot;
442
443 if (!delete_src || !bkey_deleted(&new_src->k)) {
444 ret = bch2_trans_update(trans, &src_iter, &new_src->k_i, src_update_flags);
445 if (ret)
446 goto out;
447 }
448
449 if (delete_src) {
450 bch2_btree_iter_set_snapshot(&src_iter, old_src.k->p.snapshot);
451 ret = bch2_btree_iter_traverse(&src_iter) ?:
452 bch2_btree_delete_at(trans, &src_iter, BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE);
453 if (ret)
454 goto out;
455 }
456
> 457 if (delete_dst) {
458 bch2_btree_iter_set_snapshot(&dst_iter, old_dst.k->p.snapshot);
459 ret = bch2_btree_iter_traverse(&dst_iter) ?:
460 bch2_btree_delete_at(trans, &dst_iter, BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE);
461 if (ret)
462 goto out;
463 }
464
465 if (mode == BCH_RENAME_EXCHANGE)
466 *src_offset = new_src->k.p.offset;
467 *dst_offset = new_dst->k.p.offset;
468 out:
469 bch2_trans_iter_exit(trans, &src_iter);
470 bch2_trans_iter_exit(trans, &dst_iter);
471 return ret;
472 }
473
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-22 11:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-22 11:49 [bcachefs:bcachefs-testing 6/6] fs/bcachefs/dirent.c:436:2: error: a label can only be part of a statement and a declaration is not a statement 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.