From 892280742a2b6347df1464379b3ed223b2961ed4 Mon Sep 17 00:00:00 2001 From: Nathaniel Clark <nathaniel.l.clark@intel.com> Date: Wed, 28 Feb 2018 17:18:09 -0500 Subject: [PATCH] LU-9551 utils: add l_tunedisk to fix disk tunings This adds l_tunedisk utility to utilize osd_tune_lustre call for mount_utils.h. This can be called from udev. This adds a udev rule to fix disk tunings. This in some ways duplicates LU-9132, which sets this value at mount time, but if a multipath component is removed then re-added, the multipath's max_sectors_kb will not propgate to the newly added device and this now will cause an error for I/Os that would violate this. Test-Parameters: trivial Signed-off-by: Nathaniel Clark <nathaniel.l.clark@intel.com> Change-Id: I35330ebe75552d71b71212f9fae00cfdcc028ea1 Reviewed-on: https://review.whamcloud.com/31464 Tested-by: Jenkins Tested-by: Maloo <hpdd-maloo@intel.com> Reviewed-by: Andreas Dilger <andreas.dilger@intel.com> Reviewed-by: Bob Glossman <bob.glossman@intel.com> --- lustre/conf/99-lustre.rules | 4 ++ lustre/utils/.gitignore | 1 + lustre/utils/Makefile.am | 7 +++- lustre/utils/l_tunedisk.c | 81 +++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 lustre/utils/l_tunedisk.c diff --git a/lustre/conf/99-lustre.rules b/lustre/conf/99-lustre.rules index acd5150c07..61cdbdf1a9 100644 --- a/lustre/conf/99-lustre.rules +++ b/lustre/conf/99-lustre.rules @@ -1,3 +1,7 @@ KERNEL=="obd", MODE="0666" + +# Ensure block devices re-added to the system allow for large writes (LU-9551) +ACTION=="add|change", SUBSYSTEM=="block", RUN+="/usr/sbin/l_tunedisk /dev/%k" + # set sysfs values on client SUBSYSTEM=="lustre", ACTION=="change", ENV{PARAM}=="?*", RUN+="/usr/sbin/lctl set_param $env{PARAM}=$env{SETTING}" diff --git a/lustre/utils/.gitignore b/lustre/utils/.gitignore index 18103f91b4..b46005183a 100644 --- a/lustre/utils/.gitignore +++ b/lustre/utils/.gitignore @@ -24,3 +24,4 @@ /ll_decode_linkea /lhsmd_posix /lhsmtool_posix +/l_tunedisk diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am index 2f1a3014cb..aaac49d34f 100644 --- a/lustre/utils/Makefile.am +++ b/lustre/utils/Makefile.am @@ -34,7 +34,7 @@ endif # TESTS if SERVER sbin_PROGRAMS += mkfs.lustre tunefs.lustre llverdev lr_reader lshowmount \ - ll_decode_filter_fid llog_reader + ll_decode_filter_fid llog_reader l_tunedisk endif if LIBPTHREAD sbin_PROGRAMS += lhsmtool_posix @@ -188,6 +188,11 @@ tunefs_lustre_CPPFLAGS := -DTUNEFS ${MNTMODCFLAGS} tunefs_lustre_LDFLAGS := ${MNTMODLDFLAGS} tunefs_lustre_LDADD := $(mkfs_lustre_LDADD) +l_tunedisk_SOURCES = l_tunedisk.c mount_utils.c mount_utils.h $(GSSSRC) +l_tunedisk_CPPFLAGS := ${MNTMODCFLAGS} +l_tunedisk_LDFLAGS := ${MNTMODLDFLAGS} +l_tunedisk_LDADD := $(mount_lustre_LDADD) + l_getidentity_SOURCES = l_getidentity.c l_getidentity_LDADD := $(top_builddir)/libcfs/libcfs/libcfs.la l_getidentity_DEPENDENCIES := $(top_builddir)/libcfs/libcfs/libcfs.la diff --git a/lustre/utils/l_tunedisk.c b/lustre/utils/l_tunedisk.c new file mode 100644 index 0000000000..47d977b184 --- /dev/null +++ b/lustre/utils/l_tunedisk.c @@ -0,0 +1,81 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2018, Intel Corporation. + */ + + +#if HAVE_CONFIG_H +# include "config.h" +#endif /* HAVE_CONFIG_H */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include <stdlib.h> +#include <stdio.h> + +#include "mount_utils.h" +int verbose; +char *progname; + + +int main(int argc, char *const argv[]) +{ + struct mount_opts mop = { + .mo_max_sectors_kb = -1 + }; + char real_path[PATH_MAX] = {'\0'}; + unsigned int mount_type; + int ret; + + verbose = 0; + progname = strrchr(argv[0], '/'); + progname = progname ? progname + 1 : argv[0]; + + ret = osd_init(); + if (ret != 0) { + vprint("%s: osd_init() failed to initialize: %d\n", + progname, ret); + return ret; + } + + /* device is last arg */ + mop.mo_usource = argv[argc - 1]; + + mop.mo_source = realpath(mop.mo_usource, real_path); + if (mop.mo_source == NULL) { + vprint("%s: No realpath for %s\n", progname, mop.mo_usource); + goto out; + } + + /* Check whether the disk has already been formatted by mkfs.lustre */ + ret = osd_is_lustre(mop.mo_source, &mount_type); + if (ret == 0) + goto out; + + ret = osd_tune_lustre(mop.mo_source, &mop); + +out: + osd_fini(); + return ret; +} -- GitLab