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 detects EOF poorly #528

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

--is-reflink detects EOF poorly #528

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

Comments

@cebtenzzre
Copy link
Collaborator

Description

rmlint --is-reflink ignores the physical offset of the last extent in a file, as long as there are at least two extents total, even if a fix for #527 is applied.

Steps to reproduce

Build rmlint from the develop branch with _RM_OFFSET_DEBUG=1 and a fix for #527 applied.

For testcase 1, run these commands:

$ dd if=/dev/urandom of=foo bs=100K oflag=sync count=1
$ dd if=/dev/urandom of=foo bs=100K oflag=sync count=1 seek=1
$ cp --reflink foo bar
$ dd if=/dev/urandom of=bar bs=100K oflag=sync count=1 seek=1
$ filefrag -vb1 foo bar
Filesystem type is: 9123683e
File size of foo is 204800 (204800 blocks of 1 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..  102399: 694036611072..694036713471: 102400:             shared
   1:   102400..  204799: 694077128704..694077231103: 102400: 694036713472: last,eof
foo: 2 extents found
File size of bar is 204800 (204800 blocks of 1 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..  102399: 694036611072..694036713471: 102400:             shared
   1:   102400..  204799: 694103236608..694103339007: 102400: 694036713472: last,eof
bar: 2 extents found
$ cmp foo bar
foo bar differ: byte 102401, line 408
$ 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=694036611072
DEBUG: Files are clones (share same data)
Link type for 'foo' and 'bar', result:
Reflink
$ echo $?
0

For testcase 2, run these commands:

$ dd if=/dev/urandom of=foo bs=100K oflag=sync count=1
$ truncate -s 200K foo
$ cp --reflink foo bar
$ filefrag -vb1 foo bar
Filesystem type is: 9123683e
File size of foo is 204800 (204800 blocks of 1 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..  102399: 676477960192..676478062591: 102400:             last,shared
foo: 1 extent found
File size of bar is 204800 (204800 blocks of 1 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..  102399: 676477960192..676478062591: 102400:             last,shared
bar: 1 extent found
$ 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=4, n_extents=1, file_offset=0
DEBUG: Offsets match at fd1=3, fd2=4, logical=0, physical=676477960192
DEBUG: rm_offset_get_fiemap: fd=3, n_extents=1, file_offset=102400
INFO: rm_offset_get_fiemap: got no extents for 3
DEBUG: rm_offset_get_fiemap: fd=4, n_extents=1, file_offset=102400
INFO: rm_offset_get_fiemap: got no extents for 4
DEBUG: Can't determine whether files are clones
Link type for 'foo' and 'bar', result:
An error occurred during checking
$ echo $?
1

Actual result

Testcase 1

rmlint prints "Reflink" and exits with status 0.
It checks the first extent's offset, but ignores the second.

Testcase 2

rmlint prints "An error occurred during checking" and exits with status 1.
It reports "got no extents" twice.

Expected result

Testcase 1

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

Testcase 2

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=4, n_extents=1, file_offset=0
DEBUG: Offsets match at fd1=3, fd2=4, logical=0, physical=676477960192
DEBUG: Files are clones (share same data)
Link type for 'foo' and 'bar', result:
Reflink
$ echo $?
0

rmlint prints "Reflink" and exits with status 0.
There should be only one rm_offset_get_fiemap call per file.

Versions

rmlint version 2.10.1 built from develop commit bdb591f, with _RM_OFFSET_DEBUG=1 and a fix for #527 applied.

cebtenzzre added a commit to cebtenzzre/rmlint that referenced this issue Sep 16, 2021
There were two EOF checks in rm_reflink_type_from_fd. One of them caused
the last extent to be ignored in files with at least two extents. The
other mishandled files that end with a hole.

In rm_offset_get_from_fd, always warn about no extents at a nonzero file
offset, since calling code should stop after the last extent.

Fixes sahib#528
cebtenzzre added a commit to cebtenzzre/rmlint that referenced this issue Sep 25, 2021
There were two EOF checks in rm_reflink_type_from_fd. One of them caused
the last extent to be ignored in files with at least two extents. The
other mishandled files that end with a hole.

In rm_offset_get_from_fd, always warn about no extents at a nonzero file
offset, since calling code should stop after the last extent.

Fixes sahib#528
cebtenzzre added a commit to cebtenzzre/rmlint that referenced this issue Sep 28, 2021
There were two EOF checks in rm_reflink_type_from_fd. One of them caused
the last extent to be ignored in files with at least two extents. The
other mishandled files that end with a hole.

In rm_offset_get_from_fd, always warn about no extents at a nonzero file
offset, since calling code should stop after the last extent.

Fixes sahib#528
cebtenzzre added a commit to cebtenzzre/rmlint that referenced this issue Aug 7, 2022
There were two EOF checks in rm_reflink_type_from_fd. One of them caused
the last extent to be ignored in files with at least two extents. The
other mishandled files that end with a hole.

In rm_offset_get_from_fd, always warn about no extents at a nonzero file
offset, since calling code should stop after the last extent.

Fixes sahib#528
@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
There were two EOF checks in rm_reflink_type_from_fd. One of them caused
the last extent to be ignored in files with at least two extents. The
other mishandled files that end with a hole.

In rm_offset_get_from_fd, always warn about no extents at a nonzero file
offset, since calling code should stop after the last extent.

Fixes sahib#528
cebtenzzre added a commit to cebtenzzre/rmlint that referenced this issue Feb 24, 2023
There were two EOF checks in rm_util_link_type. One of them caused the
last extent to be ignored in files with at least two extents. The other
mishandled files that end with a hole.

In rm_offset_get_from_fd, always warn about no extents at a nonzero file
offset, since calling code should stop after the last extent.

Fixes sahib#528
intelfx pushed a commit to intelfx/rmlint that referenced this issue Mar 9, 2023
There were two EOF checks in rm_reflink_type_from_fd. One of them caused
the last extent to be ignored in files with at least two extents. The
other mishandled files that end with a hole.

In rm_offset_get_from_fd, always warn about no extents at a nonzero file
offset, since calling code should stop after the last extent.

Fixes sahib#528
intelfx pushed a commit to intelfx/rmlint that referenced this issue Mar 9, 2023
There were two EOF checks in rm_reflink_type_from_fd. One of them caused
the last extent to be ignored in files with at least two extents. The
other mishandled files that end with a hole.

In rm_offset_get_from_fd, always warn about no extents at a nonzero file
offset, since calling code should stop after the last extent.

Fixes sahib#528
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