-
Notifications
You must be signed in to change notification settings - Fork 290
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
Adjust min-free-space-percent config option to accept specfic size #1616
Conversation
src/libostree/ostree-repo-commit.c
Outdated
|
||
char unit = dup_str[i]; | ||
dup_str[i] = '\0'; | ||
gint size = g_ascii_strtoull (dup_str, NULL, 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guint64
again.
src/libostree/ostree-repo-private.h
Outdated
@@ -150,7 +150,7 @@ struct OstreeRepo { | |||
uid_t owner_uid; /* Cache of repo's owner uid */ | |||
uid_t target_owner_uid; /* Ensure files are chowned to this uid/gid */ | |||
gid_t target_owner_gid; | |||
guint min_free_space_percent; /* See the min-free-space-percent config option */ | |||
const char *min_free_space_str; /* See the min-free-space config option */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor of adding min-free-space
as an alias for min-free-space-percent
, but AFAICS this patch isn't doing that yet.
src/libostree/ostree-repo.c
Outdated
min_free_space_str_validate (char *min_free_space_str) | ||
{ | ||
GRegex *percent_regex = g_regex_new ("^([0-9]|[1-9][0-9])%$" , 0,0, NULL); | ||
GRegex *size_regex = g_regex_new ("^[0-9]+(G|M|T)B$", 0,0, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
g_autoptr()
here - these are leaked currently. (Also we tend to use g_once_init...()
for regexps, see elsewhere in the code)
src/libostree/ostree-repo.c
Outdated
/* If changing this, be sure to change the man page too */ | ||
const char *default_min_free_space = "3"; | ||
const char *default_min_free_space = "3%"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well...but we have a backcompat hazard here as we didn't previously require %
. So perhaps it is best to introduce a new config option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or interpret a bare number as a percentage for the back compat case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ramcq Won't it give a wrong idea? For e.g.
(i) min-free-space-percent=3
(ii) min-free-space-percent=150MB
or am I missing something?
I wonder if adding an alias and introducing new config option are same thing? Do we have an exisitng alias case which I can look-up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if adding an alias and introducing new config option are same thing
They're different. I was leaning towards an alias at first, but I think we need to add a new option to sanely differentiate. We could in theory require G|M|T
for sizes but...it's ugly to have the option named -percent
when it's not.
If we have two options, an interesting question arises if we want to support setting both simultaneously - I'd be fine trying to do so, I'd also be fine making it an error for now.
I want to be clear here: Is this just an idea of yours or are you planning to actually ship a non-zero min-free-space
in EndlessOS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have two options, an interesting question arises if we want to support setting both simultaneously - I'd be fine trying to do so, I'd also be fine making it an error for now.
I think, making it an error sounds logical to me here.
I want to be clear here: Is this just an idea of yours or are you planning to actually ship a non-zero min-free-space in EndlessOS?
It's not just an idea but a step in direction of #1602 (comment) . Also, min-free-space (% or specific size) should guard against possibility of hitting ENOSPC
. So yes, Endless would be very much interesting in this as it provides a bit more fine tuning of the config option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Endless certainly wants to ship something that does this kind of thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cgwalters Quick question: If both min-free-space
and min-free-space-percent
are specified in the config file(for some odd reasons), do we error that out, or treat one of them as default (say min-free-space
) and proceed ahead with discarding the other one ?
src/libostree/ostree-repo.c
Outdated
@@ -2771,18 +2784,22 @@ reload_core_config (OstreeRepo *self, | |||
self->zlib_compression_level = OSTREE_ARCHIVE_DEFAULT_COMPRESSION_LEVEL; | |||
} | |||
|
|||
{ g_autofree char *min_free_space_percent_str = NULL; | |||
{ g_autofree char *min_free_space_str = NULL; | |||
self->min_free_space_str = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
g_clear_pointer (&self->min_free_space_str, g_free)
src/libostree/ostree-repo.c
Outdated
if (self->min_free_space_percent > 99) | ||
return glnx_throw (error, "Invalid min-free-space-percent '%s'", min_free_space_percent_str); | ||
if (min_free_space_str_validate (min_free_space_str)) | ||
self->min_free_space_str = g_strdup (min_free_space_str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self->min_free_space_str = g_steal_pointer (&min_free_space_str);
and avoid an extra strdup.
src/libostree/ostree-repo.c
Outdated
GRegex *size_regex = g_regex_new ("^[0-9]+(G|M|T)B$", 0,0, NULL); | ||
|
||
if (g_regex_match (percent_regex, min_free_space_str, 0, NULL) || | ||
g_regex_match (size_regex, min_free_space_str, 0, NULL)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to use regexps it feels like we might as well use capture groups to get the data out, then min_free_space_str_parse()
would just need to handle a (G|M|T)B
suffix.
src/libostree/ostree-repo-commit.c
Outdated
break; | ||
default: | ||
g_warning ("Should not be reached, min_free_space_parse\n"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation seems off in various places like this.
Also can you add commit messages to your commits? |
Similar to min-free-space-percent but it supports specific sizes (in MB, GB or TB). Also, making min-free-space-percent and -size mutually exclusive. min-free-space-percent does not give a fine tuning of the free disk space that a user might decide to keep. It can translate to very large size (e.g. 1% = ~10GB on 1TB HDD) or very small (e.g. 1% = ~330MB on 32GB system like Endless devices). Hence, it makes sense to introduce a config option to honor specific size as per the user.
a752d3c
to
665b1d2
Compare
Updated the PR. I have kept the same |
This looks sane to me. I added a test to |
☀️ Test successful - status-atomicjenkins |
No description provided.