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

DAOS-15388 tools: daos fs copy: error when src is dst #13962

Merged
merged 4 commits into from
Apr 19, 2024

Conversation

daltonbohning
Copy link
Contributor

Features: daos_fs_copy

Check if the source and destination are the same.
Check if the source is a subset of the destination.

Required-githooks: true

Before requesting gatekeeper:

  • Two review approvals and any prior change requests have been resolved.
  • Testing is complete and all tests passed or there is a reason documented in the PR why it should be force landed and forced-landing tag is set.
  • Features: (or Test-tag*) commit pragma was used or there is a reason documented that there are no appropriate tags for this PR.
  • Commit messages follows the guidelines outlined here.
  • Any tests skipped by the ticket being addressed have been run and passed in the PR.

Gatekeeper:

  • You are the appropriate gatekeeper to be landing the patch.
  • The PR has 2 reviews by people familiar with the code, including appropriate owners.
  • Githooks were used. If not, request that user install them and check copyright dates.
  • Checkpatch issues are resolved. Pay particular attention to ones that will show up on future PRs.
  • All builds have passed. Check non-required builds for any new compiler warnings.
  • Sufficient testing is done. Check feature pragmas and test tags and that tests skipped for the ticket are run and now pass with the changes.
  • If applicable, the PR has addressed any potential version compatibility issues.
  • Check the target branch. If it is master branch, should the PR go to a feature branch? If it is a release branch, does it have merge approval in the JIRA ticket.
  • Extra checks if forced landing is requested
    • Review comments are sufficiently resolved, particularly by prior reviewers that requested changes.
    • No new NLT or valgrind warnings. Check the classic view.
    • Quick-build or Quick-functional is not used.
  • Fix the commit message upon landing. Check the standard here. Edit it to create a single commit. If necessary, ask submitter for a new summary.

@daltonbohning daltonbohning self-assigned this Mar 8, 2024
Copy link

github-actions bot commented Mar 8, 2024

Ticket title is 'daos fs copy should detect copying a directory into itself'
Status is 'In Progress'
Labels: 'scrubbed,triaged'
https://daosio.atlassian.net/browse/DAOS-15388

@daosbuild1
Copy link
Collaborator

Test stage Functional Hardware Medium completed with status FAILURE. https://build.hpdd.intel.com/job/daos-stack/job/daos/job/PR-13962/2/display/redirect

@daosbuild1
Copy link
Collaborator

Test stage Functional Hardware Medium Verbs Provider completed with status FAILURE. https://build.hpdd.intel.com/job/daos-stack/job/daos/job/PR-13962/2/display/redirect

@daosbuild1
Copy link
Collaborator

Test stage Functional Hardware Medium Verbs Provider completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-13962/5/execution/node/836/log

@daosbuild1
Copy link
Collaborator

Test stage Functional on EL 8.8 completed with status UNSTABLE. https://build.hpdd.intel.com/job/daos-stack/job/daos//view/change-requests/job/PR-13962/6/testReport/

@daltonbohning daltonbohning force-pushed the dbohning/daos-15388 branch 3 times, most recently from e0ba885 to 2d0870f Compare April 4, 2024 16:28
@daosbuild1
Copy link
Collaborator

Test stage Functional Hardware Medium completed with status UNSTABLE. https://build.hpdd.intel.com/job/daos-stack/job/daos//view/change-requests/job/PR-13962/9/testReport/

@daosbuild1
Copy link
Collaborator

Test stage Functional Hardware Medium Verbs Provider completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-13962/9/execution/node/1540/log

Features: daos_fs_copy

Check if the source and destination are the same.
Check if the source is a subset of the destination.

Required-githooks: true

Signed-off-by: Dalton Bohning <dalton.bohning@intel.com>
@daosbuild1
Copy link
Collaborator

Test stage Functional Hardware Medium Verbs Provider completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-13962/10/execution/node/1435/log

@daltonbohning daltonbohning marked this pull request as ready for review April 16, 2024 16:37
@daltonbohning daltonbohning requested review from a team as code owners April 16, 2024 16:37
} else {
char *tmp_src = NULL;

D_ASPRINTF(tmp_src, "%s/", src_path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should check tmp_src != NULL, but do you really need an extra allocation and a tmp string here?
why not just compare:
(strncmp(src_path, dst_path, src_path_len) == 0 && dst_path[src_path_len] == "/") ?

im not sure though if this is correct though, because consider
what if src == dst == /d1/d2
I see that the same as
src == /d1/d2 and dst == /d1/d2/
but the result is different in this case, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively you could stat the src and dest and if the st_dev and st_ino fields are the same then they two are the same. This has the advantage that it'll work if you access the same tree via different paths, full vs relative or in the presence of symlinks etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just compare:
(strncmp(src_path, dst_path, src_path_len) == 0 && dst_path[src_path_len] == "/") ?

You're right. I tested locally and that works the same (with minor tweaks).

Per my other comment to @wiliamhuang: #13962 (comment)

At this point, dst_path is either /, has a / at the same location as src_path, or src_path is not a subpath of dst_path.

For my previous implementation and your suggestion, all four of these error as expected:

daos fs copy --src src  --dst src
daos fs copy --src src  --dst src/
daos fs copy --src src/ --dst src/
daos fs copy --src src/ --dst src

I pushed your suggestion and added more comments here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively you could stat the src and dest and if the st_dev and st_ino fields are the same

That would be more complete, but I think we'd have to do some recursive parse + stat to detect subpaths. E.g.

src_path = /some/deep/dir
dst_path = /some/deep/dir/that/keeps/going

We'd have to stat like this to figure it out (unless I'm missing something)

src - /some/deep/dir
dst - /some/deep/dir/that/keeps/going
dst - /some/deep/dir/that/keeps
dst - /some/deep/dir/that
dst - /some/deep/dir

Features: daos_fs_copy

Required-githooks: true

Signed-off-by: Dalton Bohning <dalton.bohning@intel.com>
Features: daos_fs_copy

Required-githooks: true

Signed-off-by: Dalton Bohning <dalton.bohning@intel.com>
Features: daos_fs_copy

Required-githooks: true

Signed-off-by: Dalton Bohning <dalton.bohning@intel.com>
@daosbuild1
Copy link
Collaborator

Test stage Functional Hardware Medium completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-13962/14/execution/node/616/log

@daltonbohning daltonbohning requested a review from a team April 19, 2024 16:13
@daltonbohning daltonbohning added the forced-landing The PR has known failures or has intentionally reduced testing, but should still be landed. label Apr 19, 2024
@daltonbohning daltonbohning merged commit 9c808a0 into master Apr 19, 2024
49 of 51 checks passed
@daltonbohning daltonbohning deleted the dbohning/daos-15388 branch April 19, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forced-landing The PR has known failures or has intentionally reduced testing, but should still be landed.
Development

Successfully merging this pull request may close these issues.

5 participants