Whamcloud - gitweb
LU-13693 lfs: avoid opening regular files for getstripe 79/38979/3
authorJohn L. Hammond <jhammond@whamcloud.com>
Thu, 18 Jun 2020 15:16:52 +0000 (10:16 -0500)
committerOleg Drokin <green@whamcloud.com>
Tue, 23 Jun 2020 08:12:49 +0000 (08:12 +0000)
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 <jhammond@whamcloud.com>
Change-Id: Ia45eb8f6aa942507a55965afccbc28375788dff2
Reviewed-on: https://review.whamcloud.com/38979
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
lustre/tests/sanity.sh
lustre/utils/liblustreapi.c

index a4a189d..414d95e 100755 (executable)
@@ -16491,6 +16491,27 @@ test_209() {
 }
 run_test 209 "read-only open/close requests should be freed promptly"
 
 }
 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))
 test_212() {
        size=`date +%s`
        size=$((size % 8192 + 1))
index f46f72b..92cb3d3 100644 (file)
@@ -63,6 +63,7 @@
 #include <time.h>
 #include <fnmatch.h>
 #include <libgen.h> /* for dirname() */
 #include <time.h>
 #include <fnmatch.h>
 #include <libgen.h> /* for dirname() */
+#include <linux/limits.h>
 #ifdef HAVE_LINUX_UNISTD_H
 #include <linux/unistd.h>
 #else
 #ifdef HAVE_LINUX_UNISTD_H
 #include <linux/unistd.h>
 #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)
 {
 
 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 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)
 }
 
 int llapi_get_agent_uuid(char *path, char *buf, size_t bufsize)