Added some HLINK debugging output and enabled it for hardlink tests.

This commit is contained in:
Wayne Davison
2008-07-17 07:43:11 -07:00
parent 6d56efa6ea
commit 0c096e29aa
5 changed files with 37 additions and 11 deletions

22
flist.c
View File

@@ -399,7 +399,9 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
static gid_t gid;
static const char *user_name, *group_name;
static char lastname[MAXPATHLEN];
#ifdef SUPPORT_HARD_LINKS
int first_hlink_ndx = -1;
#endif
int l1, l2;
int xflags;
@@ -472,6 +474,12 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
np->data = (void*)(long)(first_ndx + ndx + 1);
xflags |= XMIT_HLINK_FIRST;
}
if (DEBUG_GTE(HLINK, 1)) {
rprintf(FINFO, "found %s dev:inode %s:%s (#%ld)\n",
xflags & XMIT_HLINK_FIRST ? "first" : "matching",
big_num(tmp_dev, 0), big_num(tmp_ino, 0),
(long)np->data - 1);
}
} else {
if (tmp_dev == dev) {
if (protocol_version >= 28)
@@ -518,11 +526,16 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
write_byte(f, l2);
write_buf(f, fname + l1, l2);
#ifdef SUPPORT_HARD_LINKS
if (first_hlink_ndx >= 0) {
write_varint(f, first_hlink_ndx);
if (first_hlink_ndx >= first_ndx)
if (first_hlink_ndx >= first_ndx) {
if (DEBUG_GTE(HLINK, 2))
rprintf(FINFO, "sending abbr. entry\n");
goto the_end;
}
}
#endif
write_varlong30(f, F_LENGTH(file), 3);
if (!(xflags & XMIT_SAME_TIME)) {
@@ -609,7 +622,9 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
write_buf(f, sum, checksum_len);
}
#ifdef SUPPORT_HARD_LINKS
the_end:
#endif
strlcpy(lastname, fname, MAXPATHLEN);
if (S_ISREG(mode) || S_ISLNK(mode))
@@ -713,6 +728,11 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
first_hlink_ndx, flist->ndx_start + flist->used);
exit_cleanup(RERR_PROTOCOL);
}
if (DEBUG_GTE(HLINK, 2)) {
rprintf(FINFO, "hard-link reference #%d (%sabbr.)\n",
first_hlink_ndx,
first_hlink_ndx >= flist->ndx_start ? "" : "un");
}
if (first_hlink_ndx >= flist->ndx_start) {
struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start];
file_length = F_LENGTH(first);

View File

@@ -41,7 +41,7 @@ struct hashtable *hashtable_create(int size, int key64)
tbl->size = size;
tbl->entries = 0;
tbl->node_size = node_size;
tbl->key64 = key64;
tbl->key64 = (short)key64;
return tbl;
}

View File

@@ -68,8 +68,14 @@ struct ht_int64_node *idev_find(int64 dev, int64 ino)
if (!dev_node || dev_node->key != dev) {
/* We keep a separate hash table of inodes for every device. */
dev_node = hashtable_find(dev_tbl, dev, 1);
if (!(tbl = dev_node->data))
if (!(tbl = dev_node->data)) {
tbl = dev_node->data = hashtable_create(512, SIZEOF_INT64 == 8);
if (DEBUG_GTE(HLINK, 1)) {
rprintf(FINFO,
"created inode hashtable for dev %s\n",
big_num(dev, 0));
}
}
} else
tbl = dev_node->data;

View File

@@ -551,7 +551,7 @@ struct hashtable {
void *nodes;
int32 size, entries;
uint32 node_size;
int key64;
short key64;
};
struct ht_int32_node {

View File

@@ -33,11 +33,11 @@ ln "$name2" "$name3" || fail "Can't create hardlink"
cp "$name2" "$name4" || fail "Can't copy file"
cat $srcdir/*.c >"$fromdir/text"
checkit "$RSYNC -aHivv '$fromdir/' '$todir/'" "$fromdir" "$todir"
checkit "$RSYNC -aHivv --debug=hlink5 '$fromdir/' '$todir/'" "$fromdir" "$todir"
echo "extra extra" >>"$todir/name1"
checkit "$RSYNC -aHivv --no-whole-file '$fromdir/' '$todir/'" "$fromdir" "$todir"
checkit "$RSYNC -aHivv --debug=hlink5 --no-whole-file '$fromdir/' '$todir/'" "$fromdir" "$todir"
# Add a new link in a new subdirectory to test that we don't try to link
# the files before the directory gets created. We also create a bunch of
@@ -56,27 +56,27 @@ done
ln "$name1" "$fromdir/subdir/down/deep/new-file"
rm "$todir/text"
checkit "$RSYNC -aHivve '$SSH' --rsync-path='$RSYNC' '$fromdir/' localhost:'$todir/'" "$fromdir" "$todir"
checkit "$RSYNC -aHivve '$SSH' --debug=hlink5 --rsync-path='$RSYNC' '$fromdir/' localhost:'$todir/'" "$fromdir" "$todir"
# Do some duplicate copies using --link-dest and --copy-dest to test that
# we hard-link all locally-inherited items.
checkit "$RSYNC -aHivv --link-dest='$todir' '$fromdir/' '$chkdir/'" "$todir" "$chkdir"
checkit "$RSYNC -aHivv --debug=hlink5 --link-dest='$todir' '$fromdir/' '$chkdir/'" "$todir" "$chkdir"
rm -rf "$chkdir"
checkit "$RSYNC -aHivv --copy-dest='$todir' '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
checkit "$RSYNC -aHivv --debug=hlink5 --copy-dest='$todir' '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
# Create a hard link that has only one part in the hierarchy.
echo "This is another file" >"$fromdir/solo"
ln "$fromdir/solo" "$chkdir/solo" || fail "Can't create hardlink"
# Make sure that the checksum data doesn't slide due to an HLINK_BUMP() change.
$RSYNC -aHivc "$fromdir/" "$chkdir/" | tee "$outfile"
$RSYNC -aHivc --debug=hlink5 "$fromdir/" "$chkdir/" | tee "$outfile"
grep solo "$outfile" && test_fail "Erroneous copy of solo file occurred!"
# Make sure there's nothing wrong with sending a single file with -H
# enabled (this has broken twice so far, so we need this test).
rm -rf "$todir"
$RSYNC -aHivv "$name1" "$todir/"
$RSYNC -aHivv --debug=hlink5 "$name1" "$todir/"
diff $diffopt "$name1" "$todir" || test_fail "solo copy of name1 failed"
# The script would have aborted on error, so getting here means we've won.