From 3eff6bada2bc789fe6089e792e4043ef7ec8396f Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 18 Jun 2020 10:16:52 -0500 Subject: [PATCH] LU-13693 lfs: avoid opening regular files for getstripe In get_mds_md_size() just return a large enough size for all striping attributes. This saves lfs getstripe from opening the file which was interfering with leases used for mirroring. Signed-off-by: John L. Hammond Change-Id: Ia45eb8f6aa942507a55965afccbc28375788dff2 Reviewed-on: https://review.whamcloud.com/38979 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Alex Zhuravlev --- lustre/tests/sanity.sh | 21 +++++++++++++++++++++ lustre/utils/liblustreapi.c | 25 ++++++++++++------------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index a4a189d..414d95e8 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -16491,6 +16491,27 @@ test_209() { } run_test 209 "read-only open/close requests should be freed promptly" +test_210() { + local pid + + $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc & + pid=$! + sleep 1 + + $LFS getstripe $DIR/$tfile + kill -USR1 $pid + wait $pid || error "multiop failed" + + $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc & + pid=$! + sleep 1 + + $LFS getstripe $DIR/$tfile + kill -USR1 $pid + wait $pid || error "multiop failed" +} +run_test 210 "lfs getstripe does not break leases" + test_212() { size=`date +%s` size=$((size % 8192 + 1)) diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index f46f72b..92cb3d3 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -63,6 +63,7 @@ #include #include #include /* for dirname() */ +#include #ifdef HAVE_LINUX_UNISTD_H #include #else @@ -539,23 +540,21 @@ static int get_param_lmv(const char *path, const char *param, static int get_mds_md_size(const char *path) { - char buf[PATH_MAX], inst[PATH_MAX]; int md_size = lov_user_md_size(LOV_MAX_STRIPE_COUNT, LOV_USER_MAGIC_V3); - int rc; - - rc = llapi_getname(path, inst, sizeof(inst)); - if (rc != 0) - return rc; - /* Get the max ea size from llite parameters. */ - rc = get_lustre_param_value("llite", inst, FILTER_BY_EXACT, - "max_easize", buf, sizeof(buf)); - if (rc != 0) - return rc; + /* + * Rather than open the file and do the ioctl to get the + * instance name and close the file and search for the param + * file and open the param file and read the param file and + * parse the value and close the param file, let's just return + * a large enough value. It's 2020, RAM is cheap and this is + * much faster. + */ - rc = atoi(buf); + if (md_size < XATTR_SIZE_MAX) + md_size = XATTR_SIZE_MAX; - return rc > 0 ? rc : md_size; + return md_size; } int llapi_get_agent_uuid(char *path, char *buf, size_t bufsize) -- 1.8.3.1