[PATCH V4 1/5] cachefiles: introduce object ondemand state
Jia Zhu
zhujia.zj at bytedance.com
Wed Mar 29 14:33:32 AEDT 2023
Hi David,
Thanks for reviewing.
在 2023/3/28 21:52, David Howells 写道:
> 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?
I'll revise it in next version.
>
>> @@ -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.
Actually there is one more state <reopening> will be introduced in
patch3 and 30+ loc for repeated functions will be added if we drop the
macro.
Shall I keep using the macro or replace it?
> David
More information about the Linux-erofs
mailing list