Message ID | 172230941003.1544039.14396399914334113330.stgit@frogsfrogsfrogs (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
Series | [1/3] libfrog: define a self_healing filesystem property | expand |
self-healing sounds a little imposterous :) The code itself looks fine though.
On Tue, Jul 30, 2024 at 02:56:50PM -0700, Christoph Hellwig wrote: > self-healing sounds a little imposterous :) Do you have a better suggestion? "auto_fsck"? "auto_unf***"? ;) "background_fsck"? "background_scrub"? "patrol_scrub"? <ugh> > The code itself looks fine though. --D
On Tue, Jul 30, 2024 at 04:51:03PM -0700, Darrick J. Wong wrote: > On Tue, Jul 30, 2024 at 02:56:50PM -0700, Christoph Hellwig wrote: > > self-healing sounds a little imposterous :) > > Do you have a better suggestion? Heh. Maybe actually make it to separate ones? auto_scrub and auto_repair?
On Wed, Jul 31, 2024 at 08:43:19AM -0700, Christoph Hellwig wrote: > On Tue, Jul 30, 2024 at 04:51:03PM -0700, Darrick J. Wong wrote: > > On Tue, Jul 30, 2024 at 02:56:50PM -0700, Christoph Hellwig wrote: > > > self-healing sounds a little imposterous :) > > > > Do you have a better suggestion? > > Heh. Maybe actually make it to separate ones? > auto_scrub and auto_repair? I don't want multiple attributes because that enables sysadmins to give us mixed messages. What happens if we encounter this: auto_scrub=no auto_repair=yes auto_optimize=paula ? Better just to have one attribute and make them pick the one they want. How about auto_fsck={none,check,optimize,repair} ? --D
On Wed, Jul 31, 2024 at 10:45:31AM -0700, Darrick J. Wong wrote: > Better just to have one attribute and make them pick the one they want. > > How about auto_fsck={none,check,optimize,repair} ? Sounds good.
diff --git a/libfrog/fsproperties.c b/libfrog/fsproperties.c index c317d15c1de0..4ccd0edd8453 100644 --- a/libfrog/fsproperties.c +++ b/libfrog/fsproperties.c @@ -29,11 +29,49 @@ __fsprops_lookup( #define fsprops_lookup(values, value) \ __fsprops_lookup((values), ARRAY_SIZE(values), (value)) +/* Self-healing fs property */ + +static const char *fsprop_self_healing_values[] = { + [FSPROP_SELFHEAL_UNSET] = NULL, + [FSPROP_SELFHEAL_NONE] = "none", + [FSPROP_SELFHEAL_CHECK] = "check", + [FSPROP_SELFHEAL_OPTIMIZE] = "optimize", + [FSPROP_SELFHEAL_REPAIR] = "repair", +}; + +/* Convert the self_healing property enum to a string. */ +const char * +fsprop_write_self_healing( + enum fsprop_self_healing x) +{ + if (x <= FSPROP_SELFHEAL_UNSET || + x >= ARRAY_SIZE(fsprop_self_healing_values)) + return NULL; + return fsprop_self_healing_values[x]; +} + +/* + * Turn a self_healing value string into an enumerated value, or _UNSET if it's + * not recognized. + */ +enum fsprop_self_healing +fsprop_read_self_healing( + const char *value) +{ + int ret = fsprops_lookup(fsprop_self_healing_values, value); + if (ret < 0) + return FSPROP_SELFHEAL_UNSET; + return ret; +} + /* Return true if a fs property name=value tuple is allowed. */ bool fsprop_validate( const char *name, const char *value) { + if (!strcmp(name, FSPROP_SELF_HEALING_NAME)) + return fsprops_lookup(fsprop_self_healing_values, value) >= 0; + return true; } diff --git a/libfrog/fsproperties.h b/libfrog/fsproperties.h index 6dee8259a437..7004d339715a 100644 --- a/libfrog/fsproperties.h +++ b/libfrog/fsproperties.h @@ -47,4 +47,17 @@ bool fsprop_validate(const char *name, const char *value); /* Specific Filesystem Properties */ +#define FSPROP_SELF_HEALING_NAME "self_healing" + +enum fsprop_self_healing { + FSPROP_SELFHEAL_UNSET = 0, /* do not set property */ + FSPROP_SELFHEAL_NONE, /* no background scrubs */ + FSPROP_SELFHEAL_CHECK, /* allow only background checking */ + FSPROP_SELFHEAL_OPTIMIZE, /* allow background optimization */ + FSPROP_SELFHEAL_REPAIR, /* allow background repair & optimization */ +}; + +const char *fsprop_write_self_healing(enum fsprop_self_healing x); +enum fsprop_self_healing fsprop_read_self_healing(const char *value); + #endif /* __LIBFROG_FSPROPERTIES_H__ */