lvmteam/lvm2

lvchange doesn't support dm-writecache pause_writeback setting

Closed this issue · 3 comments

Background

Running on Ubuntu Focal 20.04.5 with "linux-image-generic-hwe-20.04"

Kernel version: 5.15.0-56-generic #62~20.04.1-Ubuntu

LVM version:

# lvm version
  LVM version:     2.03.11(2) (2021-01-08)
  Library version: 1.02.175 (2021-01-08)
  Driver version:  4.45.0
  Configuration:   ./configure --build=x86_64-linux-gnu --prefix=/usr --includedir=${prefix}/include --mandir=${prefix}/share/man --infodir=${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir=${prefix}/lib/x86_64-linux-gnu --runstatedir=/run --disable-maintainer-mode --disable-dependency-tracking --libdir=/lib/x86_64-linux-gnu --sbindir=/sbin --with-usrlibdir=/usr/lib/x86_64-linux-gnu --with-optimisation=-O2 --with-cache=internal --with-device-uid=0 --with-device-gid=6 --with-device-mode=0660 --with-default-pid-dir=/run --with-default-run-dir=/run/lvm --with-default-locking-dir=/run/lock/lvm --with-thin=internal --with-thin-check=/usr/sbin/thin_check --with-thin-dump=/usr/sbin/thin_dump --with-thin-repair=/usr/sbin/thin_repair --with-udev-prefix=/ --enable-applib --enable-blkid_wiping --enable-cmdlib --enable-dmeventd --enable-editline --enable-lvmlockd-dlm --enable-lvmlockd-sanlock --enable-lvmpolld --enable-notify-dbus --enable-pkgconfig --enable-udev_rules --enable-udev_sync --disable-readline

Problem

There is a new setting "pause_writeback" in dm-writecache that allows adjusting the frequency of writebacks

Trying to use the new setting with lvchange but it doesn't seem to be applying the config in the dm table:

# lvchange --cachesettings 'low_watermark=10 high_watermark=20 writeback_jobs=65536 pause_writeback=1000' /dev/vg_z292blqd/data
  Unrecognized writecache setting "pause_writeback" may cause activation failure.
Use unrecognized writecache setting? [y/n]: y
  Using unrecognized writecache setting: pause_writeback = 1000.
  Logical volume vg_z292blqd/data changed.
#  dmsetup table vg_z292blqd-data
0 5839511552 writecache s 253:4 253:3 512 6 high_watermark 20 low_watermark 10 writeback_jobs 65536

While reloading via dmsetup is setting the new settings correctly:

# dmsetup suspend vg_z292blqd-data
# dmsetup reload vg_z292blqd-data --table "0 5839511552 writecache s 253:1 253:0 512 8 high_watermark 20 low_watermark 10 writeback_jobs 65536 pause_writeback 1000"
# dmsetup resume vg_z292blqd-data

# dmsetup table vg_z292blqd-data
0 5839511552 writecache s 253:1 253:0 512 8 high_watermark 20 low_watermark 10 writeback_jobs 65536 pause_writeback 1000

However, a reboot will be reverting the settings back to:

#  dmsetup table vg_z292blqd-data
0 5839511552 writecache s 253:4 253:3 512 6 high_watermark 20 low_watermark 10 writeback_jobs 65536

Can I check:

  1. If it is possible to persist this settings (Setup via dmsetup reload) so that it is applied after a reboot ?
  2. If possible, to consider adding this new setting "pause_writeback" for dm-writecache so that it can be applied with lvchange ?

Thank you

I hadn't noticed this addition, I'll add it to lvm's recognized settings for writecache. As you've shown, lvm does attempt to apply settings that it doesn't recognize (to handle new kernel features like this), but apparently this isn't working.

This is actually working for me with the current version of lvm if I include the setting when attaching the writecache:

$ lvs test
LV   VG   Attr       LSize
fast test -wi------- 256.00m
main test -wi------- 512.00m

$ lvconvert --type writecache --cachesettings 'pause_writeback=1000' --cachevol fast test/main
Erase all existing data on test/fast? [y/n]: y
  Unrecognized writecache setting "pause_writeback" may cause activation failure.
Use unrecognized writecache setting? [y/n]: y
  Using unrecognized writecache setting: pause_writeback = 1000.
  Logical volume test/main now has writecache.

$ lvchange -ay test/main

$ dmsetup table test-main
0 1048576 writecache s 253:3 253:2 512 2 pause_writeback 1000

$ lvchange -an test/main

$ lvs -o cachesettings test/main
  CacheSettings       
  pause_writeback=1000

$ lvchange -ay test/main

$ dmsetup table test-main
0 1048576 writecache s 253:3 253:2 512 2 pause_writeback 1000

But it doesn't work using lvchange on an existing writecache. The lvchange removes it from the settings. It will apply other settings you include, or no settings (which is equivalent to clearing existing settings.)

$ lvchange --cachesettings 'pause_writeback=1000 low_watermark=50' test/main
  Unrecognized writecache setting "pause_writeback" may cause activation failure.
Use unrecognized writecache setting? [y/n]: y
  Using unrecognized writecache setting: pause_writeback = 1000.
  Logical volume test/main changed.
$ dmsetup table test-main
0 1048576 writecache s 253:3 253:2 512 2 low_watermark 50

$ lvchange --cachesettings 'pause_writeback=1000' test/main
  Unrecognized writecache setting "pause_writeback" may cause activation failure.
Use unrecognized writecache setting? [y/n]: y
  Using unrecognized writecache setting: pause_writeback = 1000.
Clear all writecache settings? n
  No settings changed.
  Logical volume test/main changed.

It looks like I need to make it recognize this new setting and fix the way lvchange handles unrecognized settings.