blob: a8fa3620a16c0c675789808a7b2222ad3f221bd9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
|
#!/usr/bin/env bash
. $(dirname $(readlink -e "${BASH_SOURCE[0]}"))/bcachefs-test-libs.sh
config-scratch-devs 16G
config-scratch-devs 4G
test_snapshots_simple()
{
NR_SNAPS=1
bcachefs_antagonist
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
pushd /mnt
for i in `seq 0 $NR_SNAPS`; do
dd if=/dev/zero of=/mnt/foo bs=1M count=1 oflag=direct
bcachefs subvolume snapshot snap-$i
done
popd
umount /mnt
sleep 0.2
bcachefs fsck -n ${ktest_scratch_dev[0]}
exit
for i in `seq 0 $NR_SNAPS|sort -r`; do
umount /mnt
sleep 0.2
bcachefs fsck -n ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
echo "deleting snap-$i"
bcachefs subvolume delete /mnt/snap-$i
df -h /mnt
done
umount /mnt
sleep 0.2
mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt
umount /mnt
check_counters ${ktest_scratch_dev[0]}
}
test_files_many()
{
#bcachefs_antagonist
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
for i in $(seq 0 1000001); do
echo $i > /mnt/$i
done
umount /mnt
sleep 0.2
time mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt
umount /mnt
check_counters ${ktest_scratch_dev[0]}
}
d_test_snapshots_many()
{
#bcachefs_antagonist
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
cd /mnt
for i in $(seq 0 1000001); do
bcachefs subvolume snapshot "snap_$(date -u +%F-%H%M%_S%N)"
echo $i > snap_number
done
umount /mnt
sleep 0.2
mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt
umount /mnt
check_counters ${ktest_scratch_dev[0]}
}
test_dbench()
{
# so wait doesn't hang
[[ $(jobs -p) != "" ]] && kill $(jobs -p)
NR_SNAPS=10
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
(
cd /mnt
for i in `seq 0 $NR_SNAPS`; do
sleep 1
bcachefs subvolume snapshot snap-$i
done
) &
dbench -S -t $NR_SNAPS 1 -D /mnt/
wait
df -h /mnt
for i in `seq 0 $NR_SNAPS|sort -r`; do
echo "deleting snap-$i"
bcachefs subvolume delete /mnt/snap-$i
df -h /mnt
done
umount /mnt
sleep 0.2
#bcachefs fsck -n ${ktest_scratch_dev[0]}
mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt
df -h /mnt
umount /mnt
check_counters ${ktest_scratch_dev[0]}
}
test_reflink()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
pushd /mnt
cp -a /usr .
bcachefs subvolume snapshot snap-$i
cp -r --reflink usr usr2
popd
umount /mnt
check_counters ${ktest_scratch_dev[0]}
}
d_test_finsert()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
pushd /mnt
dd if=/dev/zero of=foo bs=1M count=8 oflag=direct
bcachefs subvolume snapshot snap-$i
xfs_io -c "finsert 1024 1024" foo
popd
umount /mnt
check_counters ${ktest_scratch_dev[0]}
}
d_test_snapshots_fio()
{
# so wait doesn't hang
[[ $(jobs -p) != "" ]] && kill $(jobs -p)
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
fallocate -l500M /mnt/fiotest
(
cd /mnt
for i in `seq 0 10`; do
sleep 2
bcachefs subvolume snapshot snap-$i
done
) &
fio --eta=always \
--eta-interval=1s \
--exitall_on_error=1 \
--randrepeat=0 \
--ioengine=libaio \
--iodepth=64 \
--iodepth_batch=16 \
--direct=1 \
--numjobs=1 \
--verify=crc32c \
--verify_fatal=1 \
--verify_async=1 \
--filename=/mnt/fiotest \
--filesize=1G \
--io_size=12G \
--fallocate=none \
--name=randwrite \
--rw=randwrite \
--bsrange=4k-32k || true
wait
df -h /mnt
for i in `seq 0 10`; do
fio --eta=always \
--eta-interval=1s \
--exitall_on_error=1 \
--randrepeat=0 \
--ioengine=libaio \
--iodepth=64 \
--iodepth_batch=16 \
--direct=1 \
--numjobs=1 \
--verify=crc32c \
--verify_only=1 \
--filename=/mnt/snap-$i/fiotest \
--filesize=1G \
--io_size=12G \
--fallocate=none \
--name=randwrite \
--rw=randwrite \
--bsrange=4k-32k || true
done
for i in `seq 0 10|sort -r`; do
umount /mnt
sleep 0.1
mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt
echo "deleting snap-$i"
cd /mnt
bcachefs subvolume delete snap-$i
df -h /mnt
cd /
done
umount /mnt
sleep 0.1
mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt
df -h /mnt
umount /mnt
check_counters ${ktest_scratch_dev[0]}
}
test_subvol_create()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/subvolume_1
touch /mnt/foo
mv /mnt/foo /mnt/subvolume_1
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
test_subvol_delete()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/subvolume_1
rm -rf /mnt/subvolume_1
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
test_subvol_create_delete()
{
bcachefs_antagonist
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/foo
dd if=/dev/zero of=/mnt/foo/bar bs=100M count=1 oflag=direct
bcachefs subvolume delete /mnt/foo
bcachefs subvolume create /mnt/foo
dd if=/dev/zero of=/mnt/foo/bar bs=100M count=1 oflag=direct
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
}
test_subvol_snapshot_create()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/subvolume_1
bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
test_subvol_snapshot_create_ro()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/subvolume_1
bcachefs subvolume snapshot -r /mnt/subvolume_1 /mnt/snapshot_1
! touch /mnt/snapshot_1/foo
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
test_subvol_snapshot_delete()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/subvolume_1
bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
bcachefs subvolume delete /mnt/snapshot_1
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
test_subvol_snapshot_delete_create()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/subvolume_1
bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
bcachefs subvolume delete /mnt/snapshot_1
bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
d_test_subvol_snapshot_rm()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/subvolume_1
bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
rm -r /mnt/snapshot_1
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
# Create a subvolume, then snapshot the parent subvolume, then move the child
# subvolume:
test_mkdir_mv_snapshot()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
mkdir /mnt/dir1
bcachefs subvolume snapshot /mnt/ /mnt/snap1
mv /mnt/dir1 /mnt/dir2
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
test_subvol_mv_snapshot()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/sub1
bcachefs subvolume snapshot /mnt/ /mnt/snap1
mv /mnt/sub1 /mnt/sub2
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
# Test moving a subvol to another subvol
test_subvol_mv_subvol()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/sub1
bcachefs subvolume create /mnt/sub2
mv /mnt/sub1 /mnt/sub2
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
test_subvol_snapshot_reuse_snapshot_name()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/subvolume_1
bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
bcachefs subvolume delete /mnt/snapshot_1
bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
test_subvol_delete_snapshot_of_deleted_subvol()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/subvolume_1
bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
rm -rf /mnt/subvolume_1
bcachefs subvolume delete /mnt/snapshot_1
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
test_subvol_snapshot_delete_repeat()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
for i in $(seq 1 64); do
bcachefs subvolume snapshot /mnt/$i
bcachefs subvolume delete /mnt/$i
done
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
test_subvol_snapshot_delete_fio()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
for i in $(seq 1 10); do
#run_fio_randrw --filesize=500M --bs=4k
dd if=/dev/zero of=/mnt/test bs=4k count=1024 oflag=direct
bcachefs subvolume snapshot /mnt/$i
done
for i in $(seq 1 10); do
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt
done
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
check_counters ${ktest_scratch_dev[0]}
}
test_snapshot_copygc()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
for i in $(seq 1 4); do
run_fio_randrw --filesize=1000M --loops=4 --bs=4k
bcachefs subvolume snapshot /mnt/$i
done
bcachefs fs usage -h /mnt
umount /mnt
check_counters ${ktest_scratch_dev[0]}
}
test_snapshot_many_overwrite()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
for i in $(seq 1 100); do
echo foo > /mnt/test
bcachefs subvolume snapshot /mnt/snap.$i
done
bcachefs fs usage -h /mnt
umount /mnt
check_counters ${ktest_scratch_dev[0]}
}
test_snapshot_prjquota()
{
run_quiet "" bcachefs format -f --errors=panic --prjquota ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
echo foo > /mnt/test
bcachefs subvolume snapshot /mnt/snap.$i
bcachefs fs usage -h /mnt
umount /mnt
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
umount /mnt
check_counters ${ktest_scratch_dev[0]}
}
md5sum_file()
{
md5sum $1|cut -d\ -f1
}
check_snapshot_md5sum()
{
local i=$1
local sum=/mnt/fiotest.sum.$i
echo "checking $sum"
if [[ ! $(<$sum) = $(md5sum_file /mnt/snap.$i/fiotest) ]]; then
echo "md5sums do not match for $sum and /mnt/snap.$i/fiotest"
echo $(<$sum)
md5sum_file /mnt/snap.$i/fiotest
return 1
fi
}
check_snapshot_md5sums()
{
local snap
for snap in $(ls /mnt|grep '^snap.' || true); do
echo "about to check $snap"
check_snapshot_md5sum ${snap##snap.}
done
}
run_snapshot_fio()
{
local filename=$1
shift
fio --exitall_on_error=1 \
--minimal \
--randrepeat=1 \
--ioengine=libaio \
--iodepth=64 \
--iodepth_batch=16 \
--direct=1 \
--numjobs=1 \
--thread \
--verify=meta \
--verify_fatal=1 \
--overwrite=1 \
--filesize=500M \
--io_size=200M \
--bsrange=4k-64k \
--name=randrw \
--stats=0 \
--disable_bw=1 \
--rw=randrw \
--filename=$filename \
"$@"
}
test_snapshot_sums()
{
run_quiet "" bcachefs format -f --errors=panic --prjquota ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
local i
for i in $(seq 0 10); do
run_snapshot_fio /mnt/fiotest
md5sum_file /mnt/fiotest > /mnt/fiotest.sum.$i
echo "creating snapshot $i"
bcachefs subvolume snapshot /mnt/snap.$i
done
check_snapshot_md5sums
local snap
for snap in $(echo /mnt/snap.*|sort -R); do
umount /mnt
mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume delete $snap
check_snapshot_md5sums
done
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
}
test_snapshot_rw()
{
run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
local i
for i in $(seq 0 10); do
[[ -f /mnt/fiotest ]] &&
run_snapshot_fio /mnt/fiotest --verify_only=1
run_snapshot_fio /mnt/fiotest
echo "creating snapshot $i"
bcachefs subvolume snapshot /mnt/snap.$i
md5sum_file /mnt/snap.$i/fiotest > /mnt/fiotest.sum.$i
for snap in /mnt/snap.*; do
local j=${snap##/mnt/snap.}
check_snapshot_md5sum $j
run_snapshot_fio /mnt/snap.$j/fiotest --verify_only=1
run_snapshot_fio /mnt/snap.$j/fiotest
md5sum_file /mnt/snap.$j/fiotest > /mnt/fiotest.sum.$j
done
done
check_snapshot_md5sums
local snap
for snap in $(echo /mnt/snap.*|sort -R); do
umount /mnt
mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume delete $snap
sleep 1
check_snapshot_md5sums
done
umount /mnt
bcachefs fsck -n ${ktest_scratch_dev[0]}
}
test_snapshot_implicit_source()
{
run_quiet "" bcachefs format -f ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
mkdir /mnt/d
bcachefs subvolume snapshot /mnt/d/snp1
umount /mnt
mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt
umount /mnt
}
test_delete_subvol_nested()
{
run_quiet "" bcachefs format -f ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/a
bcachefs subvolume create /mnt/a/b
! bcachefs subvolume delete /mnt/a
umount /mnt
bcachefs fsck -ny ${ktest_scratch_dev[0]}
}
test_snapshot_file_delete()
{
run_quiet "" bcachefs format -f --shard_inode_numbers=0 ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
#dd if=/dev/zero of=/mnt/foo bs=4k count=8 oflag=direct
touch /mnt/foo
bcachefs subvolume snapshot /mnt/snapshot
rm /mnt/snapshot/foo
rm /mnt/foo
umount /mnt
mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt
umount /mnt
}
test_subvol_mv()
{
run_quiet "" bcachefs format -f ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
bcachefs subvolume create /mnt/a
bcachefs subvolume create /mnt/a/b
mv /mnt/a/b /mnt
umount /mnt
bcachefs fsck ${ktest_scratch_dev[0]}
}
test_subvol_rmdir_empty_snapshot()
{
run_quiet "" bcachefs format -f ${ktest_scratch_dev[0]}
mount -t bcachefs ${ktest_scratch_dev[0]} /mnt
cd /mnt
bcachefs subvolume create ./sub
cd sub
bcachefs subvolume create ./sub2
bcachefs subvolume snapshot . ./snap
rmdir ./snap
cd /
umount /mnt
bcachefs fsck ${ktest_scratch_dev[0]}
}
test_snapshot_reflink()
{
run_quiet "" bcachefs format -f ${ktest_scratch_dev[0]}
mount -t bcachefs -o noinline_data ${ktest_scratch_dev[0]} /mnt
cp /bin/cp /mnt/file
#echo Test > /mnt/file
bcachefs subvolume snapshot /mnt/snapshot
cp --reflink=always /mnt/snapshot/file /mnt/file1
rm /mnt/file
cp --reflink=always /mnt/snapshot/file /mnt/file2
md5sum /mnt/file* /mnt/snapshot/file /bin/cp
umount /mnt
mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt
umount /mnt
}
main "$@"
|