History

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

Wayne Davison committed 18 years ago

Commit 0c096e21 parent 6d56efa5 files · +37 −11Browse files

Unified · Split

5 files
  1. flist.c +21 −1
  2. hashtable.c +1 −1
  3. hlink.c +7 −1
  4. rsync.h +1 −1
  5. testsuite/hardlinks.test +7 −7
flist.c+21−1
@@ -399,7 +399,9 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file, · 398 unmodified lines
399399 static gid_t gid;
400400 static const char *user_name, *group_name;
401401 static char lastname[MAXPATHLEN];
402+#ifdef SUPPORT_HARD_LINKS
402403 int first_hlink_ndx = -1;
404+#endif
403405 int l1, l2;
404406 int xflags;
405407
@@ -472,6 +474,12 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file, · 66 unmodified lines
472474 np->data = (void*)(long)(first_ndx + ndx + 1);
473475 xflags |= XMIT_HLINK_FIRST;
474476 }
477+ if (DEBUG_GTE(HLINK, 1)) {
478+ rprintf(FINFO, "found %s dev:inode %s:%s (#%ld)\n",
479+ xflags & XMIT_HLINK_FIRST ? "first" : "matching",
480+ big_num(tmp_dev, 0), big_num(tmp_ino, 0),
481+ (long)np->data - 1);
482+ }
475483 } else {
476484 if (tmp_dev == dev) {
477485 if (protocol_version >= 28)
@@ -518,11 +526,16 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file, · 40 unmodified lines
518526 write_byte(f, l2);
519527 write_buf(f, fname + l1, l2);
520528
529+#ifdef SUPPORT_HARD_LINKS
521530 if (first_hlink_ndx >= 0) {
522531 write_varint(f, first_hlink_ndx);
523− if (first_hlink_ndx >= first_ndx)
532+ if (first_hlink_ndx >= first_ndx) {
533+ if (DEBUG_GTE(HLINK, 2))
534+ rprintf(FINFO, "sending abbr. entry\n");
524535 goto the_end;
536+ }
525537 }
538+#endif
526539
527540 write_varlong30(f, F_LENGTH(file), 3);
528541 if (!(xflags & XMIT_SAME_TIME)) {
@@ -609,7 +622,9 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file, · 80 unmodified lines
609622 write_buf(f, sum, checksum_len);
610623 }
611624
625+#ifdef SUPPORT_HARD_LINKS
612626 the_end:
627+#endif
613628 strlcpy(lastname, fname, MAXPATHLEN);
614629
615630 if (S_ISREG(mode) || S_ISLNK(mode))
@@ -713,6 +728,11 @@ static struct file_struct *recv_file_entry(struct file_list *flist, · 97 unmodified lines
713728 first_hlink_ndx, flist->ndx_start + flist->used);
714729 exit_cleanup(RERR_PROTOCOL);
715730 }
731+ if (DEBUG_GTE(HLINK, 2)) {
732+ rprintf(FINFO, "hard-link reference #%d (%sabbr.)\n",
733+ first_hlink_ndx,
734+ first_hlink_ndx >= flist->ndx_start ? "" : "un");
735+ }
716736 if (first_hlink_ndx >= flist->ndx_start) {
717737 struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start];
718738 file_length = F_LENGTH(first);
hashtable.c+1−1
@@ -41,7 +41,7 @@ struct hashtable *hashtable_create(int size, int key64) · 40 unmodified lines
4141 tbl->size = size;
4242 tbl->entries = 0;
4343 tbl->node_size = node_size;
44− tbl->key64 = key64;
44+ tbl->key64 = (short)key64;
4545
4646 return tbl;
4747 }
hlink.c+7−1
@@ -68,8 +68,14 @@ struct ht_int64_node *idev_find(int64 dev, int64 ino) · 67 unmodified lines
6868 if (!dev_node || dev_node->key != dev) {
6969 /* We keep a separate hash table of inodes for every device. */
7070 dev_node = hashtable_find(dev_tbl, dev, 1);
71− if (!(tbl = dev_node->data))
71+ if (!(tbl = dev_node->data)) {
7272 tbl = dev_node->data = hashtable_create(512, SIZEOF_INT64 == 8);
73+ if (DEBUG_GTE(HLINK, 1)) {
74+ rprintf(FINFO,
75+ "created inode hashtable for dev %s\n",
76+ big_num(dev, 0));
77+ }
78+ }
7379 } else
7480 tbl = dev_node->data;
7581
rsync.h+1−1
@@ -551,7 +551,7 @@ struct hashtable { · 550 unmodified lines
551551 void *nodes;
552552 int32 size, entries;
553553 uint32 node_size;
554− int key64;
554+ short key64;
555555 };
556556
557557 struct ht_int32_node {
testsuite/hardlinks.test+7−7
@@ -33,11 +33,11 @@ ln "$name2" "$name3" || fail "Can't create hardlink" · 32 unmodified lines
3333 cp "$name2" "$name4" || fail "Can't copy file"
3434 cat $srcdir/*.c >"$fromdir/text"
3535
36−checkit "$RSYNC -aHivv '$fromdir/' '$todir/'" "$fromdir" "$todir"
36+checkit "$RSYNC -aHivv --debug=hlink5 '$fromdir/' '$todir/'" "$fromdir" "$todir"
3737
3838 echo "extra extra" >>"$todir/name1"
3939
40−checkit "$RSYNC -aHivv --no-whole-file '$fromdir/' '$todir/'" "$fromdir" "$todir"
40+checkit "$RSYNC -aHivv --debug=hlink5 --no-whole-file '$fromdir/' '$todir/'" "$fromdir" "$todir"
4141
4242 # Add a new link in a new subdirectory to test that we don't try to link
4343 # the files before the directory gets created. We also create a bunch of
@@ -56,27 +56,27 @@ done · 12 unmodified lines
5656 ln "$name1" "$fromdir/subdir/down/deep/new-file"
5757 rm "$todir/text"
5858
59−checkit "$RSYNC -aHivve '$SSH' --rsync-path='$RSYNC' '$fromdir/' localhost:'$todir/'" "$fromdir" "$todir"
59+checkit "$RSYNC -aHivve '$SSH' --debug=hlink5 --rsync-path='$RSYNC' '$fromdir/' localhost:'$todir/'" "$fromdir" "$todir"
6060
6161 # Do some duplicate copies using --link-dest and --copy-dest to test that
6262 # we hard-link all locally-inherited items.
63−checkit "$RSYNC -aHivv --link-dest='$todir' '$fromdir/' '$chkdir/'" "$todir" "$chkdir"
63+checkit "$RSYNC -aHivv --debug=hlink5 --link-dest='$todir' '$fromdir/' '$chkdir/'" "$todir" "$chkdir"
6464
6565 rm -rf "$chkdir"
66−checkit "$RSYNC -aHivv --copy-dest='$todir' '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
66+checkit "$RSYNC -aHivv --debug=hlink5 --copy-dest='$todir' '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
6767
6868 # Create a hard link that has only one part in the hierarchy.
6969 echo "This is another file" >"$fromdir/solo"
7070 ln "$fromdir/solo" "$chkdir/solo" || fail "Can't create hardlink"
7171
7272 # Make sure that the checksum data doesn't slide due to an HLINK_BUMP() change.
73−$RSYNC -aHivc "$fromdir/" "$chkdir/" | tee "$outfile"
73+$RSYNC -aHivc --debug=hlink5 "$fromdir/" "$chkdir/" | tee "$outfile"
7474 grep solo "$outfile" && test_fail "Erroneous copy of solo file occurred!"
7575
7676 # Make sure there's nothing wrong with sending a single file with -H
7777 # enabled (this has broken twice so far, so we need this test).
7878 rm -rf "$todir"
79−$RSYNC -aHivv "$name1" "$todir/"
79+$RSYNC -aHivv --debug=hlink5 "$name1" "$todir/"
8080 diff $diffopt "$name1" "$todir" || test_fail "solo copy of name1 failed"
8181
8282 # The script would have aborted on error, so getting here means we've won.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t