kdevops.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: kdevops@lists.linux.dev
Subject: [PATCH] nfsd: rework how we use storage
Date: Fri,  1 Mar 2024 14:14:43 -0500	[thread overview]
Message-ID: <20240301191444.88839-1-jlayton@kernel.org> (raw)

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 kconfigs/Kconfig.nfsd                  | 26 ++++++++++++--------------
 playbooks/roles/nfsd/defaults/main.yml |  2 ++
 playbooks/roles/nfsd/tasks/main.yml    | 11 ++++++++++-
 scripts/nfsd.Makefile                  |  4 ++--
 4 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/kconfigs/Kconfig.nfsd b/kconfigs/Kconfig.nfsd
index 946c2c101b58..db80d8c0981e 100644
--- a/kconfigs/Kconfig.nfsd
+++ b/kconfigs/Kconfig.nfsd
@@ -1,22 +1,20 @@
 # FIXME: need defaults for terraform hosts
-config NFSD_EXPORT_DEVICE_0
-	string "First device to be exported"
-	default "/dev/disk/by-id/nvme-QEMU_NVMe_Ctrl_kdevops2" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_NVME
-	default "/dev/disk/by-id/virtio-kdevops2" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_VIRTIO
-	default "/dev/disk/by-id/ata-QEMU_HARDDISK_kdevops2" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_IDE
+config NFSD_EXPORT_DEVICE_PREFIX
+	string "The device prefix to use for LVM PVs"
+	default "/dev/disk/by-id/nvme-QEMU_NVMe_Ctrl_kdevops" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_NVME
+	default "/dev/disk/by-id/virtio-kdevops" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_VIRTIO
+	default "/dev/disk/by-id/ata-QEMU_HARDDISK_kdevops" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_IDE
 	default ""
 	help
-	  To set up nfsd for testing, we give it filesystems to export. This
-	  block device is used as a PV for LVM, and volumes are provisioned from it.
+	  To set up nfsd for testing, we give it filesystems to export. This string
+	  will be the prefix for the block devices used as PVs for LVM.
 
-config NFSD_EXPORT_DEVICE_1
-	string "Second device to be exported"
-	default "/dev/disk/by-id/nvme-QEMU_NVMe_Ctrl_kdevops3" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_NVME
-	default "/dev/disk/by-id/virtio-kdevops3" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_VIRTIO
-	default "/dev/disk/by-id/ata-QEMU_HARDDISK_kdevops3" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_IDE
+config NFSD_EXPORT_DEVICE_COUNT
+	int "Number of devices to add as LVM PVs"
+	default 3 if LIBVIRT
 	help
-	  To set up nfsd for testing, we give it filesystems to export. This
-	  block device is used as a PV for LVM, and volumes are provisioned from it.
+	  The number of disk devices to dedicate as LVM PVs. In general, we
+	  avoid using device index 0 as that is used for /data.
 
 choice
 	prompt "Type of filesystem to export"
diff --git a/playbooks/roles/nfsd/defaults/main.yml b/playbooks/roles/nfsd/defaults/main.yml
index 4a72f4f0b048..c2a8044d8a46 100644
--- a/playbooks/roles/nfsd/defaults/main.yml
+++ b/playbooks/roles/nfsd/defaults/main.yml
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier GPL-2.0+
 ---
 # Our sensible defaults for the nfsd role.
+nfsd_export_device_prefix: ""
+nfsd_export_device_count: 0
 nfsd_export_label: "export"
 nfsd_export_fs_opts: ""
 nfsd_lease_time: "90"
diff --git a/playbooks/roles/nfsd/tasks/main.yml b/playbooks/roles/nfsd/tasks/main.yml
index e051d21bd819..e2a6b1b2afab 100644
--- a/playbooks/roles/nfsd/tasks/main.yml
+++ b/playbooks/roles/nfsd/tasks/main.yml
@@ -22,13 +22,22 @@
     group: root
     mode: 0644
 
+- name: Build string of devices to use as PVs
+  set_fact:
+    nfsd_lvm_pvs: "{{ nfsd_lvm_pvs + [ nfsd_export_device_prefix item ] }}"
+  with_items: "{{ range(1, nfsd_export_device_count) }}"
+
+- name: Print the PV list
+  ansible.builtin.debug:
+    var: nfsd_lvm_pvs
+
 - name: Create a new LVM VG
   become: yes
   become_flags: 'su - -c'
   become_method: sudo
   community.general.lvg:
     vg: "exports"
-    pvs: "{{ nfsd_export_device_0 }},{{ nfsd_export_device_1 }}"
+    pvs: "{{ nfsd_lvm_pvs | join(',') }}"
 
 - name: Create {{ nfsd_export_path }}
   become: yes
diff --git a/scripts/nfsd.Makefile b/scripts/nfsd.Makefile
index 40338ab93fce..d3549a29af84 100644
--- a/scripts/nfsd.Makefile
+++ b/scripts/nfsd.Makefile
@@ -1,5 +1,5 @@
-NFSD_EXTRA_ARGS += nfsd_export_device_0='$(subst ",,$(CONFIG_NFSD_EXPORT_DEVICE_0))'
-NFSD_EXTRA_ARGS += nfsd_export_device_1='$(subst ",,$(CONFIG_NFSD_EXPORT_DEVICE_1))'
+NFSD_EXTRA_ARGS += nfsd_export_device_prefix='$(subst ",,$(CONFIG_NFSD_EXPORT_DEVICE_PREFIX))'
+NFSD_EXTRA_ARGS += nfsd_export_device_count='$(subst ",,$(CONFIG_NFSD_EXPORT_DEVICE_COUNT))'
 NFSD_EXTRA_ARGS += nfsd_export_fstype='$(subst ",,$(CONFIG_NFSD_EXPORT_FSTYPE))'
 NFSD_EXTRA_ARGS += nfsd_export_path='$(subst ",,$(CONFIG_NFSD_EXPORT_PATH))'
 NFSD_EXTRA_ARGS += nfsd_export_options='$(subst ",,$(CONFIG_NFSD_EXPORT_OPTIONS))'
-- 
2.43.2


                 reply	other threads:[~2024-03-01 19:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240301191444.88839-1-jlayton@kernel.org \
    --to=jlayton@kernel.org \
    --cc=kdevops@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).