*-s*, *--minimum-size* _size_::
The minimum size to consider. By default this is 1, so empty files will not be linked. The _size_ argument may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB").
-*-S*, *--buffer-size* _size_::
-The size of read buffer used when comparing file contents (default: 8KiB). This
-costs some additional memory but potentially reduces the amount of seek
-operations and therefore improve performance, especially with mechanic disk
-drives. Optional factor suffixes are supported, like with the *-s* option. This is mostly efficient with other filters (i.e. with *-f* or *-X*) and can be less efficient with *-top* options.
-
+*-b*, *--io-size* _size_::
+The size of read or sendfile buffer used when comparing file contents. The
+_size_ argument may be followed by the multiplicative suffixes KiB, MiB, etc.
+The "iB" is optional, e.g., "K" has the same meaning as "KiB". The default is
+8KiB for memcmp method and 1MiB for the other methods. The only memcmp method
+uses process memory for the buffer, other methods use zero-copy way and I/O
+operation is done in kernel.
== ARGUMENTS
JLOG_VERBOSE2
};
-#ifndef DEF_SCAN_BUFSIZ
-# define DEF_SCAN_BUFSIZ 8192
-#endif
-
/**
* struct statistic - Statistics about the file
* @started: Whether we are post command-line processing
unsigned int keep_oldest:1;
unsigned int dry_run:1;
uintmax_t min_size;
- size_t bufsiz;
+ size_t io_size;
} opts = {
/* default setting */
.method = "sha256",
.respect_time = TRUE,
.respect_xattrs = FALSE,
.keep_oldest = FALSE,
- .min_size = 1,
- .bufsiz = DEF_SCAN_BUFSIZ
+ .min_size = 1
};
/*
if (!nnodes)
continue;
memsiz = (10*1024*1024)/nnodes;
- /* filesiz, readsiz, memsiz */
- ul_fileeq_set_size(&fileeq, master->st.st_size, 1024*1024, memsiz);
+ /* filesiz, readsiz, memsiz */
+ ul_fileeq_set_size(&fileeq, master->st.st_size, opts.io_size, memsiz);
for (other = master->next; other != NULL; other = other->next) {
int eq;
fputs(_(" -x, --exclude <regex> regular expression to exclude files\n"), out);
fputs(_(" -i, --include <regex> regular expression to include files/dirs\n"), out);
fputs(_(" -s, --minimum-size <size> minimum size for files.\n"), out);
- fputs(_(" -S, --buffer-size <size> buffer size for file reading (speedup, using more RAM)\n"), out);
+ fputs(_(" -b, --io-size <size> I/O buffer size for file reading (speedup, using more RAM)\n"), out);
fputs(_(" -c, --content compare only file contents, same as -pot\n"), out);
fputs(USAGE_SEPARATOR, out);
*/
static int parse_options(int argc, char *argv[])
{
- static const char optstr[] = "VhvnfpotXcmMOx:y:i:s:S:q";
+ static const char optstr[] = "VhvnfpotXcmMOx:y:i:s:b:q";
static const struct option long_options[] = {
{"version", no_argument, NULL, 'V'},
{"help", no_argument, NULL, 'h'},
{"include", required_argument, NULL, 'i'},
{"method", required_argument, NULL, 'y' },
{"minimum-size", required_argument, NULL, 's'},
- {"buffer-size", required_argument, NULL, 'S'},
+ {"io-size", required_argument, NULL, 'b'},
{"content", no_argument, NULL, 'c'},
{"quiet", no_argument, NULL, 'q'},
{NULL, 0, NULL, 0}
case 's':
opts.min_size = strtosize_or_err(optarg, _("failed to parse size"));
break;
- case 'S':
- opts.bufsiz = strtosize_or_err(optarg, _("failed to parse size"));
+ case 'b':
+ opts.io_size = strtosize_or_err(optarg, _("failed to parse I/O size"));
break;
case 'h':
usage();
if (rc < 0)
err(EXIT_FAILURE, _("failed to initialize files comparior"));
+ /* defautl I/O size */
+ if (!opts.io_size) {
+ if (strcmp(opts.method, "memcmp") == 0)
+ opts.io_size = 8*1024;
+ else
+ opts.io_size = 1024*1024;
+ }
+
stats.started = TRUE;
jlog(JLOG_VERBOSE2, _("Scanning [device/inode/links]:"));