[PATCH V4 1/5] cachefiles: introduce object ondemand state

David Howells dhowells at redhat.com
Wed Mar 29 00:52:11 AEDT 2023


Jia Zhu <zhujia.zj at bytedance.com> wrote:

> +enum cachefiles_object_state {
> +	CACHEFILES_ONDEMAND_OBJSTATE_close, /* Anonymous fd closed by daemon or initial state */
> +	CACHEFILES_ONDEMAND_OBJSTATE_open, /* Anonymous fd associated with object is available */

That looks weird.  Maybe make them all-lowercase?

> @@ -296,6 +302,21 @@ extern void cachefiles_ondemand_clean_object(struct cachefiles_object *object);
>  extern int cachefiles_ondemand_read(struct cachefiles_object *object,
>  				    loff_t pos, size_t len);
>  
> +#define CACHEFILES_OBJECT_STATE_FUNCS(_state)	\
> +static inline bool								\
> +cachefiles_ondemand_object_is_##_state(const struct cachefiles_object *object) \
> +{												\
> +	return object->state == CACHEFILES_ONDEMAND_OBJSTATE_##_state; \
> +}												\
> +												\
> +static inline void								\
> +cachefiles_ondemand_set_object_##_state(struct cachefiles_object *object) \
> +{												\
> +	object->state = CACHEFILES_ONDEMAND_OBJSTATE_##_state; \
> +}
> +
> +CACHEFILES_OBJECT_STATE_FUNCS(open);
> +CACHEFILES_OBJECT_STATE_FUNCS(close);

Or just get rid of the macroisation?  If there are only two states, it doesn't
save you that much and it means that "make TAGS" won't generate refs for those
functions and grep won't find them.

David



More information about the Linux-erofs mailing list