mbox series

[ndctl,v2,00/12] Policy based reconfiguration for daxctl

Message ID 20211206222830.2266018-1-vishal.l.verma@intel.com (mailing list archive)
Headers show
Series Policy based reconfiguration for daxctl | expand

Message

Verma, Vishal L Dec. 6, 2021, 10:28 p.m. UTC
Changes since v1[1]:
- Collect review tags
- Fix 'make clean' removing the reconfigure script from the source tree
  (Fenghua, Qi)
- Documentation wordsmithing (Dan)
- Fix line break after declarations in parse-configs.c (Dan)
- Move daxctl config files to its own directory, /etc/daxctl/ (Dan)
- Improve failure mode in the absence of a configs directory
- Rename {nd,dax}ctl_{get|set}_configs to
  {nd,dax}ctl_{get|set}_configs_dir
- Exit with success if -C is specified, but no matching config section
  is found.
- Refuse to proceed if CLI options are passed in along with -C (Dan)
- In the config file, rename: s/[auto-online foo]/[reconfigure-device foo/
  and s/uuid/nvdimm.uuid/ (Dan)
- Teach device.c to accept /dev/daxX.Y instead of only daxX.Y and thus
  remove the need for a wrapper script that systemd invokes (Dan)

These patches add policy (config file) support to daxctl. The
introductory user is daxctl-reconfigure-device. Sysadmins may wish to
use daxctl devices as system-ram, but it may be cumbersome to automate
the reconfiguration step for every device upon boot.

Introduce a new option for daxctl-reconfigure-device, --check-config.
This is at the heart of policy based reconfiguration, as it allows
daxctl to look up reconfiguration parameters for a given device from the
config system instead of the command line.

Some systemd and udev glue then automates this for every new dax device
that shows up, providing a way for the administrator to simply list all
the 'system-ram' UUIDs in a config file, and not have to worry about
anything else.

An example config file can be:

  # cat /etc/ndctl/daxctl.conf

  [reconfigure-device unique_identifier_foo]
  nvdimm.uuid = 48d8e42c-a2f0-4312-9e70-a837faafe862
  mode = system-ram
  online = true
  movable = false

Any file under '/etc/ndctl/' can be used - all files with a '.conf' suffix
will be considered when looking for matches.

These patches depend on the initial config file support from Qi Fuli[2].

I've re-rolled Qi's original patches as the first five patches in this
series because of a change I made for graceful handling in the case of a
missing configs directory, and also to incorporate review feedback that
applied to the dependant patches. Patch 6 onwards is the actual v2 of
the daxctl policy work.

A branch containing these patches is available at [3].

[1]: https://lore.kernel.org/nvdimm/20210831090459.2306727-1-vishal.l.verma@intel.com/
[2]: https://lore.kernel.org/nvdimm/20210824095106.104808-1-qi.fuli@fujitsu.com/
[3]: https://github.com/pmem/ndctl/tree/vv/daxctl_config_v2

QI Fuli (5):
  ndctl, util: add iniparser helper
  ndctl, util: add parse-configs helper
  ndctl: make ndctl support configuration files
  ndctl, config: add the default ndctl configuration file
  ndctl, monitor: refator monitor for supporting multiple config files

Vishal Verma (7):
  ndctl: Update ndctl.spec.in for 'ndctl.conf'
  daxctl: Documentation updates for persistent reconfiguration
  util/parse-config: refactor filter_conf_files into util/
  daxctl: add basic config parsing support
  util/parse-configs: add a key/value search helper
  daxctl/device.c: add an option for getting params from a config file
  daxctl: add systemd service and udev rule for automatic
    reconfiguration

 .../daxctl/daxctl-reconfigure-device.txt      |  75 ++
 Documentation/ndctl/ndctl-monitor.txt         |   8 +-
 configure.ac                                  |  18 +-
 Makefile.am                                   |   8 +-
 ndctl/lib/private.h                           |   1 +
 daxctl/lib/libdaxctl.c                        |  39 +
 ndctl/lib/libndctl.c                          |  39 +
 daxctl/libdaxctl.h                            |   2 +
 ndctl/libndctl.h                              |   2 +
 util/dictionary.h                             | 175 ++++
 util/iniparser.h                              | 360 ++++++++
 util/parse-configs.h                          |  53 ++
 daxctl/daxctl.c                               |   1 +
 daxctl/device.c                               | 174 +++-
 ndctl/monitor.c                               |  73 +-
 ndctl/ndctl.c                                 |   1 +
 util/dictionary.c                             | 383 ++++++++
 util/iniparser.c                              | 838 ++++++++++++++++++
 util/parse-configs.c                          | 150 ++++
 Documentation/daxctl/Makefile.am              |  11 +-
 Documentation/ndctl/Makefile.am               |   2 +-
 daxctl/90-daxctl-device.rules                 |   1 +
 daxctl/Makefile.am                            |   9 +
 daxctl/daxdev-reconfigure@.service            |   8 +
 daxctl/lib/Makefile.am                        |   6 +
 daxctl/lib/libdaxctl.sym                      |   2 +
 ndctl.spec.in                                 |   4 +
 ndctl/Makefile.am                             |   9 +-
 ndctl/lib/Makefile.am                         |   6 +
 ndctl/lib/libndctl.sym                        |   2 +
 ndctl/ndctl.conf                              |  56 ++
 31 files changed, 2467 insertions(+), 49 deletions(-)
 create mode 100644 util/dictionary.h
 create mode 100644 util/iniparser.h
 create mode 100644 util/parse-configs.h
 create mode 100644 util/dictionary.c
 create mode 100644 util/iniparser.c
 create mode 100644 util/parse-configs.c
 create mode 100644 daxctl/90-daxctl-device.rules
 create mode 100644 daxctl/daxdev-reconfigure@.service
 create mode 100644 ndctl/ndctl.conf


base-commit: 4e646fa490ba4b782afa188dd8818b94c419924e

Comments

Verma, Vishal L Dec. 6, 2021, 11:10 p.m. UTC | #1
On Mon, 2021-12-06 at 15:28 -0700, Vishal Verma wrote:
> Changes since v1[1]:
> - Collect review tags
> - Fix 'make clean' removing the reconfigure script from the source tree
>   (Fenghua, Qi)
> - Documentation wordsmithing (Dan)
> - Fix line break after declarations in parse-configs.c (Dan)
> - Move daxctl config files to its own directory, /etc/daxctl/ (Dan)
> - Improve failure mode in the absence of a configs directory
> - Rename {nd,dax}ctl_{get|set}_configs to
>   {nd,dax}ctl_{get|set}_configs_dir
> - Exit with success if -C is specified, but no matching config section
>   is found.
> - Refuse to proceed if CLI options are passed in along with -C (Dan)
> - In the config file, rename: s/[auto-online foo]/[reconfigure-device foo/
>   and s/uuid/nvdimm.uuid/ (Dan)
> - Teach device.c to accept /dev/daxX.Y instead of only daxX.Y and thus
>   remove the need for a wrapper script that systemd invokes (Dan)
> 
> These patches add policy (config file) support to daxctl. The
> introductory user is daxctl-reconfigure-device. Sysadmins may wish to
> use daxctl devices as system-ram, but it may be cumbersome to automate
> the reconfiguration step for every device upon boot.
> 
> Introduce a new option for daxctl-reconfigure-device, --check-config.
> This is at the heart of policy based reconfiguration, as it allows
> daxctl to look up reconfiguration parameters for a given device from the
> config system instead of the command line.
> 
> Some systemd and udev glue then automates this for every new dax device
> that shows up, providing a way for the administrator to simply list all
> the 'system-ram' UUIDs in a config file, and not have to worry about
> anything else.
> 
> An example config file can be:
> 
>   # cat /etc/ndctl/daxctl.conf

Missed updating this, it should be /etc/daxctl/daxctl.conf

> 
>   [reconfigure-device unique_identifier_foo]
>   nvdimm.uuid = 48d8e42c-a2f0-4312-9e70-a837faafe862
>   mode = system-ram
>   online = true
>   movable = false
> 
> Any file under '/etc/ndctl/' can be used - all files with a '.conf' suffix

And this should be '/etc/daxctl/'

> will be considered when looking for matches.
> 
> These patches depend on the initial config file support from Qi Fuli[2].
> 
> I've re-rolled Qi's original patches as the first five patches in this
> series because of a change I made for graceful handling in the case of a
> missing configs directory, and also to incorporate review feedback that
> applied to the dependant patches. Patch 6 onwards is the actual v2 of
> the daxctl policy work.
> 
> A branch containing these patches is available at [3].
> 
> [1]: https://lore.kernel.org/nvdimm/20210831090459.2306727-1-vishal.l.verma@intel.com/
> [2]: https://lore.kernel.org/nvdimm/20210824095106.104808-1-qi.fuli@fujitsu.com/
> [3]: https://github.com/pmem/ndctl/tree/vv/daxctl_config_v2
> 
> QI Fuli (5):
>   ndctl, util: add iniparser helper
>   ndctl, util: add parse-configs helper
>   ndctl: make ndctl support configuration files
>   ndctl, config: add the default ndctl configuration file
>   ndctl, monitor: refator monitor for supporting multiple config files
> 
> Vishal Verma (7):
>   ndctl: Update ndctl.spec.in for 'ndctl.conf'
>   daxctl: Documentation updates for persistent reconfiguration
>   util/parse-config: refactor filter_conf_files into util/
>   daxctl: add basic config parsing support
>   util/parse-configs: add a key/value search helper
>   daxctl/device.c: add an option for getting params from a config file
>   daxctl: add systemd service and udev rule for automatic
>     reconfiguration
> 
>  .../daxctl/daxctl-reconfigure-device.txt      |  75 ++
>  Documentation/ndctl/ndctl-monitor.txt         |   8 +-
>  configure.ac                                  |  18 +-
>  Makefile.am                                   |   8 +-
>  ndctl/lib/private.h                           |   1 +
>  daxctl/lib/libdaxctl.c                        |  39 +
>  ndctl/lib/libndctl.c                          |  39 +
>  daxctl/libdaxctl.h                            |   2 +
>  ndctl/libndctl.h                              |   2 +
>  util/dictionary.h                             | 175 ++++
>  util/iniparser.h                              | 360 ++++++++
>  util/parse-configs.h                          |  53 ++
>  daxctl/daxctl.c                               |   1 +
>  daxctl/device.c                               | 174 +++-
>  ndctl/monitor.c                               |  73 +-
>  ndctl/ndctl.c                                 |   1 +
>  util/dictionary.c                             | 383 ++++++++
>  util/iniparser.c                              | 838 ++++++++++++++++++
>  util/parse-configs.c                          | 150 ++++
>  Documentation/daxctl/Makefile.am              |  11 +-
>  Documentation/ndctl/Makefile.am               |   2 +-
>  daxctl/90-daxctl-device.rules                 |   1 +
>  daxctl/Makefile.am                            |   9 +
>  daxctl/daxdev-reconfigure@.service            |   8 +
>  daxctl/lib/Makefile.am                        |   6 +
>  daxctl/lib/libdaxctl.sym                      |   2 +
>  ndctl.spec.in                                 |   4 +
>  ndctl/Makefile.am                             |   9 +-
>  ndctl/lib/Makefile.am                         |   6 +
>  ndctl/lib/libndctl.sym                        |   2 +
>  ndctl/ndctl.conf                              |  56 ++
>  31 files changed, 2467 insertions(+), 49 deletions(-)
>  create mode 100644 util/dictionary.h
>  create mode 100644 util/iniparser.h
>  create mode 100644 util/parse-configs.h
>  create mode 100644 util/dictionary.c
>  create mode 100644 util/iniparser.c
>  create mode 100644 util/parse-configs.c
>  create mode 100644 daxctl/90-daxctl-device.rules
>  create mode 100644 daxctl/daxdev-reconfigure@.service
>  create mode 100644 ndctl/ndctl.conf
> 
> 
> base-commit: 4e646fa490ba4b782afa188dd8818b94c419924e
qi.fuli@fujitsu.com Dec. 7, 2021, 11:24 a.m. UTC | #2
> Subject: Re: [ndctl PATCH v2 00/12] Policy based reconfiguration for daxctl
> 
> On Mon, 2021-12-06 at 15:28 -0700, Vishal Verma wrote:
> > Changes since v1[1]:
> > - Collect review tags
> > - Fix 'make clean' removing the reconfigure script from the source tree
> >   (Fenghua, Qi)
> > - Documentation wordsmithing (Dan)
> > - Fix line break after declarations in parse-configs.c (Dan)
> > - Move daxctl config files to its own directory, /etc/daxctl/ (Dan)
> > - Improve failure mode in the absence of a configs directory
> > - Rename {nd,dax}ctl_{get|set}_configs to
> >   {nd,dax}ctl_{get|set}_configs_dir
> > - Exit with success if -C is specified, but no matching config section
> >   is found.
> > - Refuse to proceed if CLI options are passed in along with -C (Dan)
> > - In the config file, rename: s/[auto-online foo]/[reconfigure-device foo/
> >   and s/uuid/nvdimm.uuid/ (Dan)
> > - Teach device.c to accept /dev/daxX.Y instead of only daxX.Y and thus
> >   remove the need for a wrapper script that systemd invokes (Dan)
> >
> > These patches add policy (config file) support to daxctl. The
> > introductory user is daxctl-reconfigure-device. Sysadmins may wish to
> > use daxctl devices as system-ram, but it may be cumbersome to automate
> > the reconfiguration step for every device upon boot.
> >
> > Introduce a new option for daxctl-reconfigure-device, --check-config.
> > This is at the heart of policy based reconfiguration, as it allows
> > daxctl to look up reconfiguration parameters for a given device from
> > the config system instead of the command line.
> >
> > Some systemd and udev glue then automates this for every new dax
> > device that shows up, providing a way for the administrator to simply
> > list all the 'system-ram' UUIDs in a config file, and not have to
> > worry about anything else.
> >
> > An example config file can be:
> >
> >   # cat /etc/ndctl/daxctl.conf
> 
> Missed updating this, it should be /etc/daxctl/daxctl.conf
> 
> >
> >   [reconfigure-device unique_identifier_foo]
> >   nvdimm.uuid = 48d8e42c-a2f0-4312-9e70-a837faafe862
> >   mode = system-ram
> >   online = true
> >   movable = false
> >
> > Any file under '/etc/ndctl/' can be used - all files with a '.conf'
> > suffix
> 
> And this should be '/etc/daxctl/'
> 
> > will be considered when looking for matches.
> >
> > These patches depend on the initial config file support from Qi Fuli[2].
> >
> > I've re-rolled Qi's original patches as the first five patches in this
> > series because of a change I made for graceful handling in the case of
> > a missing configs directory, and also to incorporate review feedback
> > that applied to the dependant patches. Patch 6 onwards is the actual
> > v2 of the daxctl policy work.
> >
> > A branch containing these patches is available at [3].
> >
> > [1]:
> > https://lore.kernel.org/nvdimm/20210831090459.2306727-1-vishal.l.verma
> > @intel.com/
> > [2]:
> > https://lore.kernel.org/nvdimm/20210824095106.104808-1-qi.fuli@fujitsu
> > .com/
> > [3]: https://github.com/pmem/ndctl/tree/vv/daxctl_config_v2
> >
> > QI Fuli (5):
> >   ndctl, util: add iniparser helper
> >   ndctl, util: add parse-configs helper
> >   ndctl: make ndctl support configuration files
> >   ndctl, config: add the default ndctl configuration file
> >   ndctl, monitor: refator monitor for supporting multiple config files

Hi Vishal,

Thank you very for the work.
I made a patch[1] to fix test/monitor.sh for the new style config file.
Could you please also pick it?

[1] https://lore.kernel.org/all/20210914024119.99711-1-qi.fuli@fujitsu.com/

Best,
QI Fuli

> >
> > Vishal Verma (7):
> >   ndctl: Update ndctl.spec.in for 'ndctl.conf'
> >   daxctl: Documentation updates for persistent reconfiguration
> >   util/parse-config: refactor filter_conf_files into util/
> >   daxctl: add basic config parsing support
> >   util/parse-configs: add a key/value search helper
> >   daxctl/device.c: add an option for getting params from a config file
> >   daxctl: add systemd service and udev rule for automatic
> >     reconfiguration
> >
> >  .../daxctl/daxctl-reconfigure-device.txt      |  75 ++
> >  Documentation/ndctl/ndctl-monitor.txt         |   8 +-
> >  configure.ac                                  |  18 +-
> >  Makefile.am                                   |   8 +-
> >  ndctl/lib/private.h                           |   1 +
> >  daxctl/lib/libdaxctl.c                        |  39 +
> >  ndctl/lib/libndctl.c                          |  39 +
> >  daxctl/libdaxctl.h                            |   2 +
> >  ndctl/libndctl.h                              |   2 +
> >  util/dictionary.h                             | 175 ++++
> >  util/iniparser.h                              | 360 ++++++++
> >  util/parse-configs.h                          |  53 ++
> >  daxctl/daxctl.c                               |   1 +
> >  daxctl/device.c                               | 174 +++-
> >  ndctl/monitor.c                               |  73 +-
> >  ndctl/ndctl.c                                 |   1 +
> >  util/dictionary.c                             | 383 ++++++++
> >  util/iniparser.c                              | 838
> ++++++++++++++++++
> >  util/parse-configs.c                          | 150 ++++
> >  Documentation/daxctl/Makefile.am              |  11 +-
> >  Documentation/ndctl/Makefile.am               |   2 +-
> >  daxctl/90-daxctl-device.rules                 |   1 +
> >  daxctl/Makefile.am                            |   9 +
> >  daxctl/daxdev-reconfigure@.service            |   8 +
> >  daxctl/lib/Makefile.am                        |   6 +
> >  daxctl/lib/libdaxctl.sym                      |   2 +
> >  ndctl.spec.in                                 |   4 +
> >  ndctl/Makefile.am                             |   9 +-
> >  ndctl/lib/Makefile.am                         |   6 +
> >  ndctl/lib/libndctl.sym                        |   2 +
> >  ndctl/ndctl.conf                              |  56 ++
> >  31 files changed, 2467 insertions(+), 49 deletions(-)  create mode
> > 100644 util/dictionary.h  create mode 100644 util/iniparser.h  create
> > mode 100644 util/parse-configs.h  create mode 100644 util/dictionary.c
> > create mode 100644 util/iniparser.c  create mode 100644
> > util/parse-configs.c  create mode 100644 daxctl/90-daxctl-device.rules
> > create mode 100644 daxctl/daxdev-reconfigure@.service
> >  create mode 100644 ndctl/ndctl.conf
> >
> >
> > base-commit: 4e646fa490ba4b782afa188dd8818b94c419924e