Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up path processing #319

Open
wants to merge 37 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ff9a53d
Use explicit types for some integer constants
mfwitten Oct 1, 2018
d085572
lib/cmdline.c: Fix error message
mfwitten Oct 15, 2018
63bc4be
Miscellaneous improvements
mfwitten Oct 15, 2018
a3e9d5c
lib/cfg.*: Clean up `rm_cfg_free_paths()'
mfwitten Oct 3, 2018
93541fc
lib/cfg.*: `rm_cfg_add_path()' now returns `bool'
mfwitten Sep 29, 2018
9c51e9d
lib/cmdline.c: return the status of `rm_cfg_add_path()'
mfwitten Sep 30, 2018
f8629f1
lib/cfg.*: Refactor `rm_cfg_add_path()'
mfwitten Oct 1, 2018
3539636
lib/cfg.*: Refactor `rm_cfg_add_path()'
mfwitten Oct 1, 2018
fb1ba2d
lib/cmdline.c: Move `rm_cmd_read_paths_from_stdin()'
mfwitten Oct 4, 2018
ee9b9a0
lib/cmdline.c: Simplify size in call to `malloc()'
mfwitten Oct 16, 2018
f8cea9f
lib/cmdline.c: Replace `RmSession' with `RmCfg' in `rm_cmd_set_paths*()'
mfwitten Sep 29, 2018
25db8f6
lib/cmdline.c: Abstract out struct `rm_cmd_set_paths_vars'
mfwitten Oct 16, 2018
1e81e41
lib/cmdline.c: Add error handling to `rm_cmd_set_paths_from_stdin()'
mfwitten Oct 15, 2018
fb31ce0
lib/cfg.h: Remove member `read_stdin'
mfwitten Sep 29, 2018
d4f7805
lib/cmdline.c: Consolidate the logic around whether to read paths fro…
mfwitten Sep 29, 2018
13304f7
lib/cmdline.c: Move constant loop condition (`paths') out of the loop
mfwitten Oct 3, 2018
a9f4de0
lib/cmdline.c: Indent code to reflect the fact that it's in a block
mfwitten Oct 3, 2018
05191ee
lib/cmdline.c: Use a pointer rather than an index integer for looping
mfwitten Oct 3, 2018
4f14e8a
lib/cmdline.c: Free each command-line path as it is processed.
mfwitten Oct 3, 2018
5dafe3a
lib/cfg-funcs.h: Move `cfg->replay' and `cfg->path_count++'
mfwitten Oct 4, 2018
a5698fd
lib/path.h: s/idx/index/ in `RmPath'
mfwitten Oct 14, 2018
322d7cc
lib/cmdline.c: Move `cfg->replay' and `cfg->path_count++' out of loops
mfwitten Oct 4, 2018
67e0738
lib/path.h: s/treat_as_single_vol/single_volume/ in `RmPath'
mfwitten Oct 14, 2018
e39fa29
lib/cfg.h: Use `RmCfg::path_count' more purposefully
mfwitten Oct 15, 2018
2f72e34
lib/cfg.c: git mv lib/cfg.c lib/cfg-funcs.h
mfwitten Oct 4, 2018
eb09ea9
lib/cfg.*: Rename `rm_cfg_add_path' to `rm_cfg_prepend_path()'
mfwitten Oct 3, 2018
bc825f3
lib/cmdline.c: Abstract out `rm_cmd_set_paths_from_cmdline()'
mfwitten Oct 4, 2018
74daf3b
lib/cfg-funcs.h: Complete `git mv lib/cfg.c lib/cfg-funcs.h'
mfwitten Oct 4, 2018
6dcbfde
lib/cfg.*: rm_cfg_prepend_path(): swap parameters `preferred' and `path'
mfwitten Oct 3, 2018
4182c59
lib/cmdline.c: Replace `strcmp()' with direct character comparisons
mfwitten Oct 7, 2018
605b5a9
lib/cfg.c -> lib/cfg-funcs.h: Make functions inlinable
mfwitten Oct 4, 2018
a4e4b88
lib/cmdline.c: Tell compiler to optimize for the value of `replay'
mfwitten Oct 4, 2018
30e7156
lib/cfg-funcs.h: Insert `g_assert(cfg);' into `rm_cfg_set_default()'
mfwitten Oct 15, 2018
2c24f77
lib/cmdline.c: INLINE `rm_cmd_set_paths()'
mfwitten Oct 16, 2018
3b1098c
lib/cfg.c -> lib/cfg-funcs.h: Refactor functions
mfwitten Oct 6, 2018
c0ba1b5
lib/cmdline.c: Refactor `rm_cmd_set_paths*()'
mfwitten Oct 6, 2018
0d332c9
Merge 'develop' into 'mfwitten/0007/prepend-paths'
mfwitten Jan 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ void rm_cfg_set_default(RmCfg *cfg) {
* 32k => 15.8 seconds */
cfg->read_buf_len = 16 * 1024;

cfg->total_mem = (RmOff)1024 * 1024 * 1024;
cfg->sweep_size = 1024 * 1024 * 1024;
cfg->total_mem = 1024L * 1024 * 1024;
cfg->sweep_size = 1024L * 1024 * 1024;
mfwitten marked this conversation as resolved.
Show resolved Hide resolved
cfg->sweep_count = 1024 * 16;

cfg->skip_start_factor = 0.0;
Expand Down
2 changes: 1 addition & 1 deletion lib/formats/progressbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static char *rm_fmt_progress_get_cached_eta(

gint64 now = g_get_real_time();
if(self->last_eta[0] != 0) {
if(ABS(now - self->last_eta_update) <= 500 * 1000) {
if(ABS(now - self->last_eta_update) <= 500L * 1000) {
return self->last_eta;
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/hash-utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ int rm_hasher_main(int argc, const char **argv) {
/* Digest type */
tag.digest_type = RM_DEFAULT_DIGEST;
gint threads = 8;
gint64 buffer_mbytes = 256;
guint64 buffer_mbytes = 256;
guint64 increment = 4096;

////////////// Option Parsing ///////////////
Expand Down Expand Up @@ -213,7 +213,7 @@ int rm_hasher_main(int argc, const char **argv) {
threads,
FALSE,
increment,
1024 * 1024 * buffer_mbytes,
1024L * 1024 * buffer_mbytes,
(RmHasherCallback)rm_hasher_callback,
&tag);

Expand Down
4 changes: 2 additions & 2 deletions lib/md-scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
* debug messages by continually recycling back to the joiner.
*/
#if _RM_MDS_DEBUG
#define MDS_EMPTYQUEUE_SLEEP_US (60 * 1000 * 1000) /* 60 seconds */
#define MDS_EMPTYQUEUE_SLEEP_US (60L * 1000 * 1000) /* 60 seconds */
#else
#define MDS_EMPTYQUEUE_SLEEP_US (50 * 1000) /* 0.05 second */
#define MDS_EMPTYQUEUE_SLEEP_US (50L * 1000) /* 0.05 second */
#endif

///////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion lib/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ int rm_session_dedupe_main(RmCfg *cfg) {
/* clang-format on */

/* a poorly-documented limit for dedupe ioctl's */
static const gint64 max_dedupe_chunk = 16 * 1024 * 1024;
static const gint64 max_dedupe_chunk = 16L * 1024 * 1024;

/* how fine a resolution to use once difference detected;
* use btrfs default node size (16k): */
Expand Down
8 changes: 4 additions & 4 deletions lib/shredder.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,14 @@
#define SHRED_PAGE_SIZE (sysconf(_SC_PAGESIZE))

#define SHRED_MAX_READ_FACTOR \
((256 * 1024 * 1024) / SHRED_BALANCED_PAGES / SHRED_PAGE_SIZE)
((256L * 1024 * 1024) / SHRED_BALANCED_PAGES / SHRED_PAGE_SIZE)

/* Maximum increment size for paranoid digests. This is smaller than for other
* digest types due to memory management issues.
* 16MB should be big enough buffer size to make seek time fairly insignificant
* relative to sequential read time, eg 16MB read at typical 100 MB/s read
* rate = 160ms read vs typical seek time 10ms*/
#define SHRED_PARANOID_BYTES (16 * 1024 * 1024)
#define SHRED_PARANOID_BYTES (16L * 1024 * 1024)

/* When paranoid hashing, if a file increments is larger
* than SHRED_PREMATCH_THRESHOLD, we take a guess at the likely
Expand All @@ -296,7 +296,7 @@
#define SHRED_AVERAGE_MEM_PER_FILE (100)

/* Maximum number of bytes before worth_waiting becomes false */
#define SHRED_TOO_MANY_BYTES_TO_WAIT (64 * 1024 * 1024)
#define SHRED_TOO_MANY_BYTES_TO_WAIT (64L * 1024 * 1024)

///////////////////////////////////////////////////////////////////////
// INTERNAL STRUCTURES, WITH THEIR INITIALISERS AND DESTROYERS //
Expand Down Expand Up @@ -1742,7 +1742,7 @@ void rm_shred_run(RmSession *session) {
/* estimate mem used for RmFiles and allocate any leftovers to read buffer and/or
* paranoid mem */
RmOff mem_used = SHRED_AVERAGE_MEM_PER_FILE * session->shred_files_remaining;
RmOff read_buffer_mem = MAX(1024 * 1024, (gint64)cfg->total_mem - (gint64)mem_used);
RmOff read_buffer_mem = MAX(1024L * 1024, cfg->total_mem - mem_used);

if(cfg->checksum_type == RM_DIGEST_PARANOID) {
/* allocate any spare mem for paranoid hashing */
Expand Down
6 changes: 3 additions & 3 deletions lib/utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ char *rm_util_get_groupname(void) {
void rm_util_size_to_human_readable(RmOff num, char *in, gsize len) {
if(num < 512) {
snprintf(in, len, "%" LLU " B", num);
} else if(num < 512 * 1024) {
} else if(num < 512L * 1024) {
snprintf(in, len, "%.2f KB", num / 1024.0);
} else if(num < 512 * 1024 * 1024) {
} else if(num < 512L * 1024 * 1024) {
snprintf(in, len, "%.2f MB", num / (1024.0 * 1024.0));
} else {
snprintf(in, len, "%.2f GB", num / (1024.0 * 1024.0 * 1024.0));
Expand Down Expand Up @@ -1342,7 +1342,7 @@ bool rm_iso8601_format(time_t stamp, char *buf, gsize buf_size) {
return false;
}

#define SECONDS_PER_DAY (24 * 60 * 60)
#define SECONDS_PER_DAY (24L * 60 * 60)
#define SECONDS_PER_HOUR (60 * 60)
#define SECONDS_PER_MINUTE (60)

Expand Down