Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--is-reflink skips every second extent #527

Closed
cebtenzzre opened this issue Sep 16, 2021 · 0 comments · May be fixed by #531
Closed

--is-reflink skips every second extent #527

cebtenzzre opened this issue Sep 16, 2021 · 0 comments · May be fixed by #531
Labels

Comments

@cebtenzzre
Copy link
Collaborator

cebtenzzre commented Sep 16, 2021

Description

rmlint --is-reflink completely skips every second extent.

Steps to reproduce

Build rmlint from the develop branch with _RM_OFFSET_DEBUG=1.
Then run these commands:

$ dd if=/dev/urandom of=foo bs=100K oflag=sync count=9
$ cp --reflink foo bar
$ dd if=/dev/urandom of=bar bs=100K oflag=sync count=1 seek=1 conv=notrunc
$ filefrag -vb1 foo bar
Filesystem type is: 9123683e
File size of foo is 921600 (921600 blocks of 1 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..  102399: 672928833536..672928935935: 102400:             shared
   1:   102400..  204799: 673052336128..673052438527: 102400: 672928935936: shared
   2:   204800..  307199: 686491369472..686491471871: 102400: 673052438528: shared
   3:   307200..  409599: 690860650496..690860752895: 102400: 686491471872: shared
   4:   409600..  511999: 691562287104..691562389503: 102400: 690860752896: shared
   5:   512000..  614399: 699126407168..699126509567: 102400: 691562389504: shared
   6:   614400..  716799: 699169431552..699169533951: 102400: 699126509568: shared
   7:   716800..  819199: 699183190016..699183292415: 102400: 699169533952: shared
   8:   819200..  921599: 699530420224..699530522623: 102400: 699183292416: last,shared,eof
foo: 9 extents found
File size of bar is 921600 (921600 blocks of 1 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..  102399: 672928833536..672928935935: 102400:             shared
   1:   102400..  204799: 682882265088..682882367487: 102400: 672928935936:
   2:   204800..  307199: 686491369472..686491471871: 102400: 682882367488: shared
   3:   307200..  409599: 690860650496..690860752895: 102400: 686491471872: shared
   4:   409600..  511999: 691562287104..691562389503: 102400: 690860752896: shared
   5:   512000..  614399: 699126407168..699126509567: 102400: 691562389504: shared
   6:   614400..  716799: 699169431552..699169533951: 102400: 699126509568: shared
   7:   716800..  819199: 699183190016..699183292415: 102400: 699169533952: shared
   8:   819200..  921599: 699530420224..699530522623: 102400: 699183292416: last,shared,eof
bar: 9 extents found
$ cmp foo bar
foo bar differ: byte 102401, line 406
$ rmlint --is-reflink -vv foo bar
DEBUG: Testing if foo is clone of bar
DEBUG: Checking link type for foo vs bar
DEBUG: rm_offset_get_fiemap: fd=3, n_extents=1, file_offset=0
DEBUG: rm_offset_get_fiemap: fd=3, n_extents=1, file_offset=102400
DEBUG: rm_offset_get_fiemap: fd=4, n_extents=1, file_offset=0
DEBUG: rm_offset_get_fiemap: fd=4, n_extents=1, file_offset=102400
DEBUG: Offsets match at fd1=3, fd2=4, logical=0, physical=672928833536
DEBUG: rm_offset_get_fiemap: fd=3, n_extents=1, file_offset=204800
DEBUG: rm_offset_get_fiemap: fd=3, n_extents=1, file_offset=307200
DEBUG: rm_offset_get_fiemap: fd=4, n_extents=1, file_offset=204800
DEBUG: rm_offset_get_fiemap: fd=4, n_extents=1, file_offset=307200
DEBUG: Offsets match at fd1=3, fd2=4, logical=204800, physical=686491369472
DEBUG: rm_offset_get_fiemap: fd=3, n_extents=1, file_offset=409600
DEBUG: rm_offset_get_fiemap: fd=3, n_extents=1, file_offset=512000
DEBUG: rm_offset_get_fiemap: fd=4, n_extents=1, file_offset=409600
DEBUG: rm_offset_get_fiemap: fd=4, n_extents=1, file_offset=512000
DEBUG: Offsets match at fd1=3, fd2=4, logical=409600, physical=691562287104
DEBUG: rm_offset_get_fiemap: fd=3, n_extents=1, file_offset=614400
DEBUG: rm_offset_get_fiemap: fd=3, n_extents=1, file_offset=716800
DEBUG: rm_offset_get_fiemap: fd=4, n_extents=1, file_offset=614400
DEBUG: rm_offset_get_fiemap: fd=4, n_extents=1, file_offset=716800
DEBUG: Offsets match at fd1=3, fd2=4, logical=614400, physical=699169431552
DEBUG: rm_offset_get_fiemap: fd=3, n_extents=1, file_offset=819200
DEBUG: rm_offset_get_fiemap: fd=4, n_extents=1, file_offset=819200
Link type for 'foo' and 'bar', result:
Reflink
$ echo $?
0

Actual result

rmlint prints "Reflink" and exits with status 0.
It compares four pairs of physical offsets, despite the files having nine extents each.

Expected result

rmlint prints "Not linked" and exits with status 11.
There should be a message like DEBUG: Physical offsets differ at byte 102400: 673052336128<> 682882265088.

Versions

rmlint version 2.10.1 built from develop commit bdb591f with _RM_OFFSET_DEBUG=1.

cebtenzzre added a commit to cebtenzzre/rmlint that referenced this issue Sep 16, 2021
Completing the current loop iteration if the current extent is not
contiguous with the last means the extent flags and file offset are
updated as if the extents *were* contiguous. In general, this causes
calling code to skip every second extent!

Also remove a redundant write to file_offset_next that is always
clobbered after the loop exits.

Fixes sahib#527
cebtenzzre added a commit to cebtenzzre/rmlint that referenced this issue Sep 28, 2021
Completing the current loop iteration if the current extent is not
contiguous with the last means the extent flags and file offset are
updated as if the extents *were* contiguous. In general, this causes
calling code to skip every second extent!

Also remove a redundant write to file_offset_next that is always
clobbered after the loop exits.

Fixes sahib#527
cebtenzzre added a commit to cebtenzzre/rmlint that referenced this issue Aug 7, 2022
Completing the current loop iteration if the current extent is not
contiguous with the last means the extent flags and file offset are
updated as if the extents *were* contiguous. In general, this causes
calling code to skip every second extent!

Also remove a redundant write to file_offset_next that is always
clobbered after the loop exits.

Fixes sahib#527
@cebtenzzre cebtenzzre linked a pull request Aug 9, 2022 that will close this issue
@cebtenzzre cebtenzzre removed the has-pr label Aug 9, 2022
cebtenzzre added a commit to cebtenzzre/rmlint that referenced this issue Sep 18, 2022
Completing the current loop iteration if the current extent is not
contiguous with the last means the extent flags and file offset are
updated as if the extents *were* contiguous. In general, this causes
calling code to skip every second extent!

Also remove a redundant write to file_offset_next that is always
clobbered after the loop exits.

Fixes sahib#527
cebtenzzre added a commit to cebtenzzre/rmlint that referenced this issue Feb 24, 2023
Completing the current loop iteration if the current extent is not
contiguous with the last means the extent flags and file offset are
updated as if the extents *were* contiguous. In general, this causes
calling code to skip every second extent!

Also remove a redundant write to file_offset_next that is always
clobbered after the loop exits.

Fixes sahib#527
intelfx pushed a commit to intelfx/rmlint that referenced this issue Mar 9, 2023
Completing the current loop iteration if the current extent is not
contiguous with the last means the extent flags and file offset are
updated as if the extents *were* contiguous. In general, this causes
calling code to skip every second extent!

Also remove a redundant write to file_offset_next that is always
clobbered after the loop exits.

Fixes sahib#527
intelfx pushed a commit to intelfx/rmlint that referenced this issue Mar 9, 2023
Completing the current loop iteration if the current extent is not
contiguous with the last means the extent flags and file offset are
updated as if the extents *were* contiguous. In general, this causes
calling code to skip every second extent!

Also remove a redundant write to file_offset_next that is always
clobbered after the loop exits.

Fixes sahib#527
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant