[svsm-devel] [PATCH v3 12/14] fs/configfs: Add a callback to determine attribute visibility
Dan Williams
dan.j.williams at intel.com
Tue Apr 16 22:03:51 CEST 2024
Tom Lendacky wrote:
> On 4/16/24 13:25, Dan Williams wrote:
> > Tom Lendacky wrote:
> >> On 4/16/24 00:46, Dan Williams wrote:
> >>> Tom Lendacky wrote:
> >>>> In order to support dynamic decisions as to whether an attribute should be
> >>>> created, add a callback that returns a bool to indicate whether the
> >>>> attribute should be display. If no callback is registered, the attribute
> > [..]
> >>>> Cc: Joel Becker <jlbec at evilplan.org>
> >>>> Cc: Christoph Hellwig <hch at lst.de>
> >>>> Signed-off-by: Tom Lendacky <thomas.lendacky at amd.com>
> >>>> ---
> >>>> fs/configfs/file.c | 7 +++
> >>>> include/linux/configfs.h | 111 +++++++++++++++++++++++++++------------
> >>>> 2 files changed, 84 insertions(+), 34 deletions(-)
> >>>>
> > [..]
> >>>> diff --git a/include/linux/configfs.h b/include/linux/configfs.h
> >>>> index 2606711adb18..c836d7bc7c9e 100644
> >>>> --- a/include/linux/configfs.h
> >>>> +++ b/include/linux/configfs.h
> >>>> @@ -116,35 +116,57 @@ struct configfs_attribute {
> >>>> const char *ca_name;
> >>>> struct module *ca_owner;
> >>>> umode_t ca_mode;
> >>>> + bool (*is_visible)(const struct config_item *, const struct configfs_attribute *);
> >>>> ssize_t (*show)(struct config_item *, char *);
> >>>> ssize_t (*store)(struct config_item *, const char *, size_t);
> >>>> };
> >>>>
> >>>> -#define CONFIGFS_ATTR(_pfx, _name) \
> >>>> +#define __CONFIGFS_ATTR(_pfx, _name, _vis) \
> >>>> static struct configfs_attribute _pfx##attr_##_name = { \
> >>>> .ca_name = __stringify(_name), \
> >>>> .ca_mode = S_IRUGO | S_IWUSR, \
> >>>> .ca_owner = THIS_MODULE, \
> >>>> + .is_visible = _vis, \
> >>>> .show = _pfx##_name##_show, \
> >>>> .store = _pfx##_name##_store, \
> >>>
> >>> Shouldn't this operation live in configfs_group_operations? That would
> >>> mirror the sysfs organization, and likely saves some memory.
> >>
> >> I suppose it can, but then you lose the grouping of attributes within
> >> the same directory, right? A configfs group will result in moving the
> >> entries into a subdirectory, right? If we go with the group level, then
> >> we will be moving the existing TSM extra attributes and the new TSM SVSM
> >> attributes into new, separate sub-directories.
> >
> > I am not following the concern about "losing the grouping"? Here is what
> > I was thinking with having the visibility routines in group operations.
> > This is just the broard strokes, it compiles, but still needs the finer
> > detail work to make tdx-guest skip all the attributes that do not apply
> > to it. Might need to be broken up a bit more, but hopefully conveys the
> > idea. Does this address your grouping concern?
>
> Yes and no. Basically the is_visible()/is_bin_visible() callback will
> have to check every index value for a "group" against the passed in
> value. I was trying to group the values together using an enum in order
> to make it a bit easier and more readable in the callback. Adding
> another attribute to the group requires updates in multiple places. But
> thats just how I was looking at it. I can also see where you might want
> to selectively hide/show entries and this method works well for that.
>
> I'll follow this approach (add you as Co-developed-by: or Suggested-by:,
> whichever you prefer) and submit a v4.
Sure, you can add:
Co-developed-by: Dan Williams <dan.j.williams at intel.com>
Signed-off-by: Dan Williams <dan.j.williams at intel.com>
...if you want to reuse any of this sample patch.
More information about the Svsm-devel
mailing list