/* we use a local lock file to limit how many files we are migrating
across simultaneously
*/
-#define FILE_MIGRATE_MAX_CONCURRENT 1000
#define FILE_MIGRATE_LIMITER_DIR "/var/lib/remote-cache"
#define FILE_MIGRATE_LIMITER "/var/lib/remote-cache/lockfile"
*/
static int direct_io = 0;
+/* maximum number of concurrent migrations
+ do nor spawn more than this number of concurrent rsync processes to pull
+ files into the cache
+*/
+static int file_migrate_max_concurrent = 1000;
+
static int sigchild_initialized = 0;
static int debug_initialized = 0;
static int log_fd = -1;
llock.l_type = F_WRLCK;
llock.l_whence = SEEK_SET;
- llock.l_start = random()%FILE_MIGRATE_MAX_CONCURRENT;
+ llock.l_start = (random()&0x00ffffff)%file_migrate_max_concurrent;
llock.l_len = 1;
llock.l_pid = getpid();
- if (fcntl(lfd, F_SETLK, &llock) != 0 || fail < 2) {
+ if (fcntl(lfd, F_SETLK, &llock) != 0) {
DEBUG(DEBUG_ERR, (__location__ " Failed to get migration lock. Too many concurrent migrations. File might be migrated on next read instead.\n"));
perror("error ");
close(lfd);
{ "debug", 'd', POPT_ARG_INT, &debug_level, 0, "debug level", "integer" },
{ "file-check-parent-mtime", 0, POPT_ARG_NONE, &file_check_parent_mtime, 0, "check mtime of remote file instead of parent directory mtime", NULL },
{ "read-write", 0, POPT_ARG_NONE, &read_write, 0, "read/write cache", NULL },
- { "direct_io", 0, POPT_ARG_NONE, &direct_io, 0, "Use direct_io for better write performance (not kNFSd compatible)", NULL },
+ { "direct-io", 0, POPT_ARG_NONE, &direct_io, 0, "Use direct_io for better write performance (not kNFSd compatible)", NULL },
+ { "file-migrate-max-concurrent", 0, POPT_ARG_INT, &file_migrate_max_concurrent, 0, "maximum number of concurrent rsync migrations", "integer" },
POPT_TABLEEND
};