From 5d15ffdaf1ebba9bbd2caee3d17c4054a149416f Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 1 Sep 2003 07:52:34 +0000 Subject: [PATCH] Cache path in tree.c git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@681 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/ReleaseNotes | 132 ++++++----------------------------- bacula/kernstodo | 3 + bacula/src/dird/ua_restore.c | 3 +- bacula/src/dird/ua_tree.c | 4 +- bacula/src/lib/tree.c | 24 +++++-- bacula/src/lib/tree.h | 8 ++- 6 files changed, 52 insertions(+), 122 deletions(-) diff --git a/bacula/ReleaseNotes b/bacula/ReleaseNotes index adf0f153d7..80cf6b305b 100644 --- a/bacula/ReleaseNotes +++ b/bacula/ReleaseNotes @@ -1,121 +1,31 @@ - Release Notes for Bacula 1.31 + Release Notes for Bacula 1.32 - Bacula code: Total files = 258 Total lines = 76,681 (*.h *.c *.in) + Bacula code: Total files = 259 Total lines = 76,690 (*.h *.c *.in) Major Changes this Release: -- Implemented a new job scheduling algorithm with priorities. -- The database format has changed from version 1.30a. Please see below. -- Support to save and restore all files on WinNT/2K/XP systems - including the permissions. Unfortunately files that are in use by another - program cannot be saved -- complain to Microsoft about this. -- Support for Win95 systems (untested since I don't have Win95). -- Heartbeat every 20 minutes between daemons to prevent network - timeouts. The heartbeat interval can be set. -- Volume names may now only contain letters, numbers, colon, period, dash, - and underscore. -- Added readline to depkgs (removed from depkgs1) and fixed configuration if - it is not installed in your system libraries. -- Implemented generalized tape label formats including counter variables - for automatic naming of Volumes. -- Multiple simultaneous jobs now work. However, I still don't - using recommend it. -- Implemented tape block rejection, which means that restores with - several incremental backups will run orders of magnitude faster. +- Fixed gnome-console to compile with RH9 (Gnome 2.0) +- Implemented a single routine to read_records. +- Implemented forward space file/block whenever possible. +- Added SDConnectTimeout to FD. Other Changes this Release: -- New Priority record in Jobs for setting job priorities. -- The name of Recycle Oldest Volume has now become Purge Oldest Volume. -- Implemented a Recycle Oldest Volume, which respects Retention periods. -- Implemented a Recycle Current Volume, which respects Retention periods. -- Restore checks block numbers to ensure that no block is lost. -- The new console var command allows testing variable expansion - used in automatic tape name generation. -- The new console estimate command allows you to test FileSets - to see how many files and bytes will be saved and optionally - to have an "ls -l" style listing of the files. -- During a normal restore (replace = yes), any existing file is deleted - and the restored file is then created. This corrects links and other - wierd files that changed between the backup and the restore. -- Preliminary support for BSDi. -- Use smtp instead of mail to send the traceback message. -- Fixed a race condition in the "list" command while a backup is - in progress. -- Improvements to gnome-console. -- Prune orphaned jobs (no files saved, no Volume used). -- Added non-fatal errors to Job reports and statistics from both - the FD and SD for backups. -- Eliminate need for SubsysDirectory in each daemon -- please remove - these records from your .conf files. -- Add a lot more "command line" options to console commands. -- More info in traceback (database type, ...). -- Better handling of errors with autochangers during restore. -- Better cancellation of jobs in Storage daemon (doesn't try - to cleanup twice). -- Better cancellation of File daemon (except on Cygwin systems). -- SD error messages such as autochanger errors are now properly - directed back to Console -- previously some were lost. -- A Storage daemon crash on FreeBSD systems (due to a different FreeBSD - pthreads implementation) is fixed. -- Better Job termination report particularly for Verify and Restore jobs. -- Update Verify VolumeToCatalog to use new BSR records. -- Fixed list last 20 jobs in restore command (previously reported any - 20 jobs). -- Gnome command line history works better. -- Better messages if a job is upgraded from Diff or Inc to Full. -- Replaced FileSet MD5 with date created -- more aestetic and readable. -- Fixed a FD crash on long directory names (Win32 specific). -- Added backup script to the examples directory. This allows one command - to backup any client. For Win32, the release now contains CygwinBackup.bat - and Backup.bat, as well as backup. The bat files call the backup file. - By placing an icon on your desktop, you can double click and backup - your client. +- Lots of doc enhancements +- Fixed a PurgeOldestVolume bug (VolStatus not returned) +- Don't crash if DB address record not specified. +- Return VolStatus on find_next_volume. +- Use alist for incexe name_list. +- Use bget_dirmsg() everywhere possible when talking to FD. +- Delete old semaphore job and workq job scheduling code. +- edit_run_codes in one place (/lib) Add Job name +- Update query.sql to find current backups correctly. +- Correct ambiguous SQL statement for prunning. +- Set heartbeat interval to zero by default. +- Fix a possible race condition in stopping the + heartbeat thread. +- Eliminate gnome2-console directory. Everything is in gnome-console +- Enhanced "packet too big" message to indicate who sent it. Items to note: !!!!! -- Recycle Oldest Volume has changed to be Purge Oldest Volume - Please change your Director's .conf file. Recycle Oldest Volume - still works but respects retention periods. - -- The default time interval is now days instead of seconds. Please - check your .conf files! - -- For MySQL users, you must have the thread safe client libraries - available. If you build MySQL yourself, add the --enable-thread-safe-client - option on the ./configure. You will most likely need to do an ldconfig. - Please see the installation documentation for building MySQL. -- Version 1.31 and 1.30 daemons/Director are not compatible. You must - upgrade all or nothing. - -- The format of the catalog database has changed, so you must either - re-initialize your database (losing all the old info) with: - - ./drop_bacula_tables - ./make_bacula_tables - - or you can use the appropriate script (you must choose the name according - to which database you have) in the /src/cats directory. - - BEFORE APPLYING THE ALTER SCRIPT PLEASE BACKUP YOUR DATABASE. - If you have previously upgraded to version 1.31, please do not run - this procedure a second time. Do one of the following only if you - wish to keep your old tables (not doing the re-initialize documented - above), and do this only after configuring an building the new Bacula, - but before trying to run it: - - MySQL: - cd working-directory (or where you want to backup the catalog) - mysqladmin -f --opt bacula >bacula.sql - cd /src/cats - ./alter_mysql_tables - - SQLite: - cd working-directory - echo '.dump' sqlite bacula.db >bacula.sql - cd /src/cats - ./alter_sqlite_tables - - When you are sure that Bacula is running with your upgraded database, - please delete the bacula.sql copy you made. - diff --git a/bacula/kernstodo b/bacula/kernstodo index c6d646a1a5..71eebb5e4b 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -27,6 +27,9 @@ Testing to do: (painful) - Figure out how to use ssh or stunnel to protect Bacula communications. For 1.32: +- Look at libkse (man kse) for FreeBSD threading. +- Look into Microsoft Volume Shadowcopy Service VSS for backing + up system state components (Active Directory, System Volume, ...) - Add ExhautiveRestoreSearch and use repositioning at the beginning of the tape. - Add Machine type (Linux/Windows) to Status report for daemons. diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 3ffffe1ef2..a7565991fe 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -410,7 +410,8 @@ static int user_select_jobids(UAContext *ua, JOBIDS *ji) bsendmsg(ua, _("No Jobs selected.\n")); return 0; } - bsendmsg(ua, _("You have selected the following JobId: %s\n"), ji->JobIds); + bsendmsg(ua, _("You have selected the following JobId%s: %s\n"), + strchr(ji->JobIds,',')?"s":"",ji->JobIds); memset(&jr, 0, sizeof(JOB_DBR)); diff --git a/bacula/src/dird/ua_tree.c b/bacula/src/dird/ua_tree.c index a09ffdff0d..9713505283 100644 --- a/bacula/src/dird/ua_tree.c +++ b/bacula/src/dird/ua_tree.c @@ -136,7 +136,7 @@ int insert_tree_handler(void *ctx, int num_fields, char **row) int type; strip_trailing_junk(row[1]); - if (*row[1] == 0) { + if (*row[1] == 0) { /* no filename => directory */ if (*row[0] != '/') { /* Must be Win32 directory */ type = TN_DIR_NLS; } else { @@ -145,7 +145,7 @@ int insert_tree_handler(void *ctx, int num_fields, char **row) } else { type = TN_FILE; } - bsnprintf(fname, sizeof(fname), "%s%s", row[0]?row[0]:"", row[1]?row[1]:""); + bsnprintf(fname, sizeof(fname), "%s%s", row[0], row[1]); if (tree->avail_node) { node = tree->avail_node; } else { diff --git a/bacula/src/lib/tree.c b/bacula/src/lib/tree.c index a30b072d2c..1927f26ba7 100755 --- a/bacula/src/lib/tree.c +++ b/bacula/src/lib/tree.c @@ -72,6 +72,7 @@ TREE_ROOT *new_tree(int count) } Dmsg2(400, "count=%d size=%d\n", count, size); malloc_buf(root, size); + root->cached_path = get_pool_memory(PM_FNAME); return root; } @@ -126,6 +127,9 @@ void free_tree(TREE_ROOT *root) mem = mem->next; free(rel); } + if (root->cached_path) { + free_pool_memory(root->cached_path); + } free(root); return; } @@ -136,7 +140,8 @@ void free_tree(TREE_ROOT *root) * Insert a node in the tree * */ -TREE_NODE *insert_tree_node(char *path, TREE_NODE *node, TREE_ROOT *root, TREE_NODE *parent) +TREE_NODE *insert_tree_node(char *path, TREE_NODE *node, + TREE_ROOT *root, TREE_NODE *parent) { TREE_NODE *sibling; char *p, *q, *fname; @@ -159,12 +164,20 @@ TREE_NODE *insert_tree_node(char *path, TREE_NODE *node, TREE_ROOT *root, TREE_N p = strrchr(path, '/'); /* separate path and filename */ if (p) { fname = p + 1; - if (!parent) { + if (!parent) { /* if no parent, we need to make one */ *p = 0; /* terminate path */ Dmsg1(100, "make_tree_path for %s\n", path); - parent = make_tree_path(path, root); + if ((int)strlen(path) == root->cached_path_len && + strcmp(path, root->cached_path) == 0) { + parent = root->cached_parent; + } else { + root->cached_path_len = strlen(path); + pm_strcpy(&root->cached_path, path); + parent = make_tree_path(path, root); + root->cached_parent = parent; + } Dmsg1(100, "parent=%s\n", parent->fname); - *p = '/'; /* restore full name */ + *p = '/'; /* restore full path */ } } else { fname = path; @@ -186,7 +199,6 @@ TREE_NODE *insert_tree_node(char *path, TREE_NODE *node, TREE_ROOT *root, TREE_N } } - append_tree_node(fname, node, root, parent); Dmsg1(100, "insert_tree_node: parent=%s\n", parent->fname); if (q) { /* if trailing slash on entry */ @@ -210,7 +222,7 @@ TREE_NODE *make_tree_path(char *path, TREE_ROOT *root) Dmsg0(100, "make_tree_path: parent=*root*\n"); return (TREE_NODE *)root; } - p = strrchr(path, '/'); /* separate path and filename */ + p = strrchr(path, '/'); /* get last dir component of path */ if (p) { fname = p + 1; *p = 0; /* terminate path */ diff --git a/bacula/src/lib/tree.h b/bacula/src/lib/tree.h index f106ded880..2fd3386b02 100644 --- a/bacula/src/lib/tree.h +++ b/bacula/src/lib/tree.h @@ -59,6 +59,9 @@ struct s_tree_root { struct s_tree_node *first; /* first entry in the tree */ struct s_tree_node *last; /* last entry in tree */ struct s_mem *mem; /* tree memory */ + int cached_path_len; /* length of cached path */ + char *cached_path; /* cached current path */ + TREE_NODE *cached_parent; /* cached parent for above path */ }; typedef struct s_tree_root TREE_ROOT; @@ -71,13 +74,14 @@ typedef struct s_tree_root TREE_ROOT; TREE_ROOT *new_tree(int count); TREE_NODE *new_tree_node(TREE_ROOT *root, int type); -TREE_NODE *insert_tree_node(char *path, TREE_NODE *node, TREE_ROOT *root, TREE_NODE *parent); +TREE_NODE *insert_tree_node(char *fname, TREE_NODE *node, + TREE_ROOT *root, TREE_NODE *parent); TREE_NODE *make_tree_path(char *path, TREE_ROOT *root); TREE_NODE *first_tree_node(TREE_ROOT *root); TREE_NODE *next_tree_node(TREE_NODE *node); TREE_NODE *tree_cwd(char *path, TREE_ROOT *root, TREE_NODE *node); TREE_NODE *tree_relcwd(char *path, TREE_ROOT *root, TREE_NODE *node); -void append_tree_node(char *fname, TREE_NODE *node, TREE_ROOT *root, TREE_NODE *parent); +void append_tree_node(char *path, TREE_NODE *node, TREE_ROOT *root, TREE_NODE *parent); void print_tree(char *path, TREE_NODE *root); void free_tree(TREE_ROOT *root); int tree_getpath(TREE_NODE *node, char *buf, int buf_size); -- 2.39.5