[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [PATCH 26/39] backup-files: Quick exit when unlinking is not
From: |
Jean Delvare |
Subject: |
[Quilt-dev] [PATCH 26/39] backup-files: Quick exit when unlinking is not needed |
Date: |
Sat, 19 Mar 2011 10:52:56 +0100 |
User-agent: |
quilt/0.48-17.1 |
The "check for hard links" use case is almost always a no-op. Check
if any work is needed at all first, and only if this is the case,
walk the list of files and unlink the faulty files. This approach
results in a huge performance gain in the most common case, and a
very small performance loss in the uncommon case.
Signed-off-by: Jean Delvare <address@hidden>
Reviewed-by: Raphael Hertzog <address@hidden>
---
quilt/scripts/backup-files.in | 14 ++++++++++++++
1 file changed, 14 insertions(+)
--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -187,6 +187,13 @@ noop_nolinks()
fi
}
+# Test if some backed up files have a link count greater than 1
+some_files_have_links()
+{
+ (cd "$OPT_PREFIX" && find . -type f -print0) \
+ | xargs -0 stat @STAT_HARDLINK@ 2> /dev/null | grep -qv '^1$'
+}
+
ECHO=echo
while [ $# -gt 0 ]; do
@@ -258,6 +265,13 @@ if [ "$1" = - ]; then
exit
fi
+ # We typically expect the link count of backed up files to be 1
+ # already, so check quickly that this is the case, and only if not,
+ # take the slow path and walk the file list in search of files to fix.
+ if [ "$OPT_WHAT" = noop_nolinks ] && ! some_files_have_links; then
+ exit
+ fi
+
find "$OPT_PREFIX" -type f -print \
| while read
do
- [Quilt-dev] [PATCH 00/39] Reimplement backup-files in bash, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 03/39] BSD compatibility: cp, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 02/39] BSD compatibility: stat, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 21/39] backup-files: Drop curly braces, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 07/39] backup-files: Skip test for file presence, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 18/39] backup-files: Make input methods mutually exclusive, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 25/39] backup-files: Separate function restore_all, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 26/39] backup-files: Quick exit when unlinking is not needed,
Jean Delvare <=
- [Quilt-dev] [PATCH 13/39] backup-files: Split code to sparate functions, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 24/39] backup-files: Avoid negations, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 14/39] backup-files: Mass reindent, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 01/39] Make backup-files a shell script, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 22/39] backup-files: Check if backup exists, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 12/39] backup-files: Simplify find loop, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 15/39] backup-files: Optimize restore, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 23/39] backup-files: Optimize noop, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 27/39] backup-files: Remember the list of files, Jean Delvare, 2011/03/19