diff --git a/src/cephadm/cephadmlib/daemons/nvmeof.py b/src/cephadm/cephadmlib/daemons/nvmeof.py index 9bce32201bb6..ab0af3f1b4c2 100644 --- a/src/cephadm/cephadmlib/daemons/nvmeof.py +++ b/src/cephadm/cephadmlib/daemons/nvmeof.py @@ -73,13 +73,18 @@ def _get_container_mounts( os.path.join(data_dir, 'ceph-nvmeof.conf') ] = '/src/ceph-nvmeof.conf:z' mounts[os.path.join(data_dir, 'configfs')] = '/sys/kernel/config' - mounts['/dev/hugepages'] = '/dev/hugepages' - mounts['/dev/vfio/vfio'] = '/dev/vfio/vfio' mounts[log_dir] = '/var/log/ceph:z' if mtls_dir: mounts[mtls_dir] = '/src/mtls:z' return mounts + def _get_huge_pages_mounts(self, files: Dict[str, str]) -> Dict[str, str]: + mounts = dict() + if 'spdk_mem_size' not in files: + mounts['/dev/hugepages'] = '/dev/hugepages' + mounts['/dev/vfio/vfio'] = '/dev/vfio/vfio' + return mounts + def _get_tls_cert_key_mounts( self, data_dir: str, files: Dict[str, str] ) -> Dict[str, str]: @@ -111,6 +116,7 @@ def customize_container_mounts( ) else: mounts.update(self._get_container_mounts(data_dir, log_dir)) + mounts.update(self._get_huge_pages_mounts(self.files)) mounts.update(self._get_tls_cert_key_mounts(data_dir, self.files)) def customize_container_binds( @@ -198,11 +204,13 @@ def configfs_mount_umount(data_dir, mount=True): ) return cmd.split() - @staticmethod - def get_sysctl_settings() -> List[str]: - return [ - 'vm.nr_hugepages = 4096', - ] + def get_sysctl_settings(self) -> List[str]: + if 'spdk_mem_size' not in self.files: + return [ + 'vm.nr_hugepages = 4096', + ] + else: + return [] def container(self, ctx: CephadmContext) -> CephContainer: ctr = daemon_to_container(ctx, self) @@ -222,4 +230,6 @@ def customize_container_args( args.append(ctx.container_engine.unlimited_pids_option) args.extend(['--ulimit', 'memlock=-1:-1']) args.extend(['--ulimit', 'nofile=10240']) - args.extend(['--cap-add=SYS_ADMIN', '--cap-add=CAP_SYS_NICE']) + args.extend(['--cap-add=CAP_SYS_NICE']) + if 'spdk_mem_size' not in self.files: + args.extend(['--cap-add=SYS_ADMIN']) diff --git a/src/pybind/mgr/cephadm/services/nvmeof.py b/src/pybind/mgr/cephadm/services/nvmeof.py index b91427dcace0..d2f3831f4cfa 100644 --- a/src/pybind/mgr/cephadm/services/nvmeof.py +++ b/src/pybind/mgr/cephadm/services/nvmeof.py @@ -63,6 +63,10 @@ def prepare_create(self, daemon_spec: CephadmDaemonDeploySpec) -> CephadmDaemonD daemon_spec.keyring = keyring daemon_spec.extra_files = {'ceph-nvmeof.conf': gw_conf} + # Indicate to the daemon whether to utilize huge pages + if spec.spdk_mem_size: + daemon_spec.extra_files['spdk_mem_size'] = str(spec.spdk_mem_size) + if spec.enable_auth: if ( not spec.client_cert diff --git a/src/pybind/mgr/cephadm/templates/services/nvmeof/ceph-nvmeof.conf.j2 b/src/pybind/mgr/cephadm/templates/services/nvmeof/ceph-nvmeof.conf.j2 index 644ca586ba93..e37bee88a576 100644 --- a/src/pybind/mgr/cephadm/templates/services/nvmeof/ceph-nvmeof.conf.j2 +++ b/src/pybind/mgr/cephadm/templates/services/nvmeof/ceph-nvmeof.conf.j2 @@ -55,6 +55,9 @@ timeout = {{ spec.spdk_timeout }} bdevs_per_cluster = {{ spec.bdevs_per_cluster }} log_level = {{ spec.spdk_log_level }} conn_retries = {{ spec.conn_retries }} +{% if spec.spdk_mem_size %} +mem_size = {{ spec.spdk_mem_size }} +{% endif %} transports = {{ spec.transports }} {% if transport_tcp_options %} transport_tcp_options = {{ transport_tcp_options }} diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index e69ab8bae6aa..dd68e104757b 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -1332,7 +1332,9 @@ def __init__(self, client_key: Optional[str] = None, client_cert: Optional[str] = None, root_ca_cert: Optional[str] = None, + # unused and duplicate of tgt_path below, consider removing spdk_path: Optional[str] = None, + spdk_mem_size: Optional[int] = None, tgt_path: Optional[str] = None, spdk_timeout: Optional[float] = 60.0, spdk_log_level: Optional[str] = 'WARNING', @@ -1418,8 +1420,10 @@ def __init__(self, self.client_cert = client_cert #: ``root_ca_cert`` CA cert for server/client certs self.root_ca_cert = root_ca_cert - #: ``spdk_path`` path to SPDK + #: ``spdk_path`` path is unused and duplicate of tgt_path below, consider removing self.spdk_path = spdk_path or '/usr/local/bin/nvmf_tgt' + #: ``spdk_mem_size`` memory size in MB for DPDK + self.spdk_mem_size = spdk_mem_size #: ``tgt_path`` nvmeof target path self.tgt_path = tgt_path or '/usr/local/bin/nvmf_tgt' #: ``spdk_timeout`` SPDK connectivity timeout