Automatically Striping Created Files on advfs Filesystems (Code Provided)
David Sisson
dsisson at av.com
Sat Dec 14 04:09:00 EST 2002
Here is a modification that calls the advfs stripe command (available
via Digital Unix) to set a file to be striped across X drives when created.
It can only be specified on the command line, but a proper implementation
would support rsyncd.conf configuration as well. This should be useful if
you are going to copy files over to a machine where you need the data spread
across the drives for performance reasons.
Use at your own risk -- there are no checks added to the writing code to
deal with "disk full" errors when a stripe cannot be performed to
misbalancing of a drive (see your advfs documentation for more information).
Also, the creation of the stripe command to execute could be implemented
in a way that doesn't create a buffer overrun situation. I would ideally
replace this with the appropriate call to libmsfs.so, but I don't have the
kernel header files for Digital Unix, so I didn't want to risk making a call
to a system call I'm not sure of (advfs_set_bf_attributes which works on a
vnode).
diff -c -r rsync-2.5.5.orig/options.c rsync-2.5.5/options.c
*** rsync-2.5.5.orig/options.c Tue Mar 19 12:16:42 2002
--- rsync-2.5.5/options.c Fri Dec 13 14:02:40 2002
***************
*** 47,52 ****
--- 47,53 ----
int update_only = 0;
int cvs_exclude = 0;
int dry_run=0;
+ int stripe=0;
int local_server=0;
int ignore_times=0;
int delete_mode=0;
***************
*** 222,227 ****
--- 223,229 ----
rprintf(F," -t, --times preserve times\n");
rprintf(F," -S, --sparse handle sparse files
efficiently\n");
rprintf(F," -n, --dry-run show what would have been
transferred\n");
+ rprintf(F," --stripe=NUMDISKS stripe across X disks when
writing\n");
rprintf(F," -W, --whole-file copy whole files, no incremental
checks\n");
rprintf(F," --no-whole-file turn off --whole-file\n");
rprintf(F," -x, --one-file-system don't cross filesystem
boundaries\n");
***************
*** 314,319 ****
--- 316,322 ----
{"help", 'h', POPT_ARG_NONE, 0, 'h', 0, 0 },
{"backup", 'b', POPT_ARG_NONE, &make_backups , 0, 0, 0 },
{"dry-run", 'n', POPT_ARG_NONE, &dry_run , 0, 0, 0 },
+ {"stripe", 0, POPT_ARG_INT, &stripe , 0, 0, 0 },
{"sparse", 'S', POPT_ARG_NONE, &sparse_files , 0, 0, 0 },
{"cvs-exclude", 'C', POPT_ARG_NONE, &cvs_exclude , 0, 0, 0 },
{"update", 'u', POPT_ARG_NONE, &update_only , 0, 0, 0 },
diff -c -r rsync-2.5.5.orig/syscall.c rsync-2.5.5/syscall.c
*** rsync-2.5.5.orig/syscall.c Sun Mar 24 19:51:17 2002
--- rsync-2.5.5/syscall.c Fri Dec 13 19:31:37 2002
***************
*** 27,32 ****
--- 27,33 ----
#include "rsync.h"
extern int dry_run;
+ extern int stripe;
extern int read_only;
extern int list_only;
***************
*** 80,85 ****
--- 81,90 ----
int do_open(char *pathname, int flags, mode_t mode)
{
+ //FILE *mylog;
+ //mylog = fopen("/web_index/rsync_test/mylogfile", "at");
+ //fprintf(mylog, "do_open(%s, %d, %d) [%d]\n", pathname, flags, mode,
stripe);
+ //fclose(mylog);
if (flags != O_RDONLY) {
if (dry_run) return -1;
CHECK_RO
***************
*** 91,96 ****
--- 96,118 ----
/* some systems can't handle a double / */
if (pathname[0] == '/' && pathname[1] == '/') pathname++;
+ if (flags & (O_CREAT|O_EXCL|O_TRUNC) > 0) {
+ if (stripe > 0)
+ {
+ char stripe_command[8192];
+
+ /* Create the file, then stripe it. */
+ int fds = open(pathname, flags, mode);
+ close(fds);
+
+ sprintf(stripe_command, "/usr/sbin/stripe -n %d %s", stripe,
pathname);
+
+ system(stripe_command);
+
+ flags = flags & ~(O_CREAT|O_EXCL|O_TRUNC);
+ }
+ }
+
return open(pathname, flags, mode);
}
***************
*** 154,159 ****
--- 176,194 ----
close(fd);
unlink(template);
return -1;
+ }
+ if (stripe > 0)
+ {
+ char stripe_command[8192];
+
+ /* Close the file, then stripe it. */
+ close(fd);
+
+ sprintf(stripe_command, "/usr/sbin/stripe -n %d %s",
stripe, template);
+
+ system(stripe_command);
+
+ return do_open(template, O_RDWR, perms);
}
return fd;
}
More information about the rsync
mailing list