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

RFE: support reflinking directories #618

Open
intelfx opened this issue Mar 10, 2023 · 0 comments · May be fixed by #619
Open

RFE: support reflinking directories #618

intelfx opened this issue Mar 10, 2023 · 0 comments · May be fixed by #619
Labels

Comments

@intelfx
Copy link

intelfx commented Mar 10, 2023

existing behavior

Currently, rmlint -T df -Dj -o sh:rmlint.sh -c sh:handler=reflink will not do anything for any duplicate directories:

# mkdir dir1 dir2
# for n in {1..10}; do dd if=/dev/urandom of=dir1/file$n bs=1M count=1024; done
# cp -a --reflink=never dir1 -T dir2
# rmlint -T df -Dj -c sh:handler=reflink dir1 dir2                                                                                                                                                                                                            

# Duplicate Directorie(s):
    ls -la '/home/intelfx/tmp/test/dir1'
    rm -rf '/home/intelfx/tmp/test/dir2'
WARNING: Unexpected return code 3 from rm_util_link_type()

==> Note: Please use the saved script below for removal, not the above output.
==> In total 20 files, whereof 10 are duplicates in 10 groups.
==> This equals 10,00 GB of duplicates which could be removed.
==> 2 other suspicious item(s) found, which may vary in size.
==> Scanning took in total 21,112s.

Wrote a sh file to: /home/intelfx/tmp/test/rmlint.sh
Wrote a json file to: /home/intelfx/tmp/test/rmlint.json
rmlint -T df -Dj -c sh:handler=reflink dir1 dir2  51,30s user 15,04s system 314% cpu 21,121 total

# sed -n '/START OF AUTOGENERATED/,/END OF AUTOGENERATED/p' rmlint.sh
######### START OF AUTOGENERATED OUTPUT #########


original_cmd  '/home/intelfx/tmp/test/dir1' # original directory



######### END OF AUTOGENERATED OUTPUT #########

(Note the "Unexpected return code 3", which stands for RM_LINK_NOT_FILE.)

suggested behavior

In the shell script, reflinks are created with cp -a --reflink=always. There is nothing preventing the same command from being used to reflink-copy an entire directory. It might make sense to support that.

intelfx added a commit to intelfx/rmlint that referenced this issue Mar 10, 2023
…tory pairs)

- modify rm_util_link_type() to specifically detect directory pairs
- modify sh output generator to emit cp_reflink for directory pairs
- modify sh template to support reflinking directories and extend
  stampfile code to preserve attributes recursively

Fixes sahib#618.
intelfx added a commit to intelfx/rmlint that referenced this issue Mar 10, 2023
- modify rm_util_link_type() to specifically detect directory pairs
- modify sh output generator to emit cp_reflink for directory pairs
- modify sh template to support reflinking directories and extend
  stampfile code to preserve attributes recursively

Fixes sahib#618.
@intelfx intelfx linked a pull request Mar 10, 2023 that will close this issue
@cebtenzzre cebtenzzre linked a pull request Mar 16, 2023 that will close this issue
intelfx added a commit to intelfx/rmlint that referenced this issue Mar 27, 2023
- modify rm_util_link_type() to specifically detect directory pairs
- modify sh output generator to emit cp_reflink for directory pairs
- modify sh template to support reflinking directories and extend
  stampfile code to preserve attributes recursively

Fixes sahib#618.
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.

2 participants