From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3D6E39847 for ; Fri, 1 Mar 2024 19:31:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709321518; cv=none; b=nf594/QbybI1IRy3IGQuOWhBfm6TRWN3D03any2NlJchCO30xiCiODstRtrrMojld1oU1+/3F6myC2440Hg9grlSbmk7UYm5vNV8XOEVe1U0paRjEvRFXUVxPuRgwjNAefhTDWfwwMJA+re3oXoHi71sW9v62bjqhe/Tsm/sicc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709321518; c=relaxed/simple; bh=2y7A4g4r25UsQsPJ33aSpcTPz4msvSuOQLtR44us/CM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=CN8pm8S5nOFUESpKPDP0yyf8vP2H/kBwmWKeVv11E4OekUkVXABnk9Z3CoamUICiHMiBv8CBsw5Hi6ZzePBFN18tlwqCnKote56UULQwS2qpxgB9iD7yimdnpm0k3w81w0QeOPg17/BL8Ag6JTghqwULFIyfi1drBagbZE8kYbg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OSwe6uGr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OSwe6uGr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F872C433F1 for ; Fri, 1 Mar 2024 19:31:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709321517; bh=2y7A4g4r25UsQsPJ33aSpcTPz4msvSuOQLtR44us/CM=; h=From:To:Subject:Date:From; b=OSwe6uGr3Lwh0GAqvajlL8D24hmzct5eplIdmNPZt4TgRyKH9QvcINzGjADxKuvCx 9XzIeM38HoGTsO05h8S6YNrXoFeF+xfJ8Apvt7h4SknM//ZrmHp0FI/mFlP3lxrTsT 7/zcwH/gMV0/V0gXf/vY8KmMviIt9G4EtXoVbEl8NUsHNaHfh424i1nCI82t5+pX2l umK4N2K4RqWTjXMPEUEEpNHHkb/qxnhKvyfeqsjVGgOV9P8QX0XoDBWOsCF+LVf+MZ rF8CzS/yn0vJlbmk45EHCMjWeOUyARD5ZvLUCDkp0wWYVn9vMLxGiAnr6xSHoAMuir 8mKF3BJ/TJrow== From: Jeff Layton To: kdevops@lists.linux.dev Subject: [PATCH v2] nfsd: rework how storage is allocated to the LVM VG Date: Fri, 1 Mar 2024 14:31:56 -0500 Message-ID: <20240301193156.91590-1-jlayton@kernel.org> X-Mailer: git-send-email 2.43.2 Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Currently we require the user to put in two different path strings, and they have to reset that if the configuration changes. This is limiting, since we need to add the ability to suck in a 3rd disk. Rework it to take a device prefix string and a count. "count" number of devices will be added to the VG, starting at index 1. Signed-off-by: Jeff Layton --- kconfigs/Kconfig.nfsd | 26 ++++++++++++-------------- playbooks/roles/nfsd/defaults/main.yml | 3 +++ playbooks/roles/nfsd/tasks/main.yml | 11 ++++++++++- scripts/nfsd.Makefile | 4 ++-- 4 files changed, 27 insertions(+), 17 deletions(-) v2: I ended up sending an earlier draft by accident. This one actually works. 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..38718aec2bf7 100644 --- a/playbooks/roles/nfsd/defaults/main.yml +++ b/playbooks/roles/nfsd/defaults/main.yml @@ -1,6 +1,9 @@ # SPDX-License-Identifier GPL-2.0+ --- # Our sensible defaults for the nfsd role. +nfsd_lvm_pvs: [] +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..fe5f6919864d 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|string ] }}" + with_items: "{{ range(1, nfsd_export_device_count + 1) }}" + +- 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