From 84097792f56c38265b6eb0417a47c557f81f9461 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Sat, 5 Oct 2019 02:06:24 -0600 Subject: [PATCH] LU-12784 llite: limit max xattr size by kernel value Limit the maximum xattr size returned to userspace from the MDS to what the currently-running kernel supports (XATTR_SIZE_MAX=65536 bytes typically). While it is possible a Lustre backing filesystem may store larger xattrs than this, it wouldn't be possible for users to access a larger xattr via kernel xattr interfaces. This fixes interop problems when newer clients and tests are running against older servers: sanity.sh: line 8946: /usr/bin/setfattr: Argument list too long Skip subtests for new features in 2.13 so 2.12 interop testing passes. Fix test-framework.sh::large_xattr_enabled() to return true for ZFS. Fix test-framework.sh::max_xattr_size() to return the actual value returned from the MDS rather than computing it locally. Fixes: 3ec712bd183 ("LU-11868 osd: Set max ea size to XATTR_SIZE_MAX") Test-Parameters: trivial serverversion=2.12 testlist=sanity Test-Parameters: serverversion=2.12 testlist=conf-sanity envdefinitions=ONLY=81 Test-Parameters: testlist=sanity-pfl,replay-single Test-Parameters: testlist=conf-sanity envdefinitions=ONLY=48,61,81 Signed-off-by: Andreas Dilger Change-Id: I14232809b13886efa8f11a50ecc35e78f316810d Reviewed-on: https://review.whamcloud.com/36240 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Wang Shilong Reviewed-by: James Simmons --- lustre/llite/lproc_llite.c | 8 ++++++-- lustre/tests/conf-sanity.sh | 32 +++++++++++--------------------- lustre/tests/sanity-flr.sh | 6 +++--- lustre/tests/sanity.sh | 10 ++++++++-- lustre/tests/test-framework.sh | 21 ++++----------------- 5 files changed, 32 insertions(+), 45 deletions(-) diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index c676ed6..6f26f49 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -918,7 +918,9 @@ static ssize_t max_easize_show(struct kobject *kobj, if (rc) return rc; - return sprintf(buf, "%u\n", ealen); + /* Limit xattr size returned to userspace based on kernel maximum */ + return snprintf(buf, PAGE_SIZE, "%u\n", + ealen > XATTR_SIZE_MAX ? XATTR_SIZE_MAX : ealen); } LUSTRE_RO_ATTR(max_easize); @@ -946,7 +948,9 @@ static ssize_t default_easize_show(struct kobject *kobj, if (rc) return rc; - return sprintf(buf, "%u\n", ealen); + /* Limit xattr size returned to userspace based on kernel maximum */ + return snprintf(buf, PAGE_SIZE, "%u\n", + ealen > XATTR_SIZE_MAX ? XATTR_SIZE_MAX : ealen); } /** diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index b06db01..23d434a0 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -3506,16 +3506,13 @@ test_48() { # bz-17636 LU-7473 # LOV EA, and so on. These EA will use some EA space that is shared by # ACL entries. So here we only check some reasonable ACL entries count, # instead of the max number that is calculated from the max_ea_size. - if [ "$MDS1_VERSION" -lt $(version_code 2.8.57) ]; - then + if [ "$MDS1_VERSION" -lt $(version_code 2.8.57) ]; then count=28 # hard coded of RPC protocol - elif [ "$mds1_FSTYPE" != ldiskfs ]; then - count=4000 # max_num 4091 max_ea_size = ~65536 - elif ! large_xattr_enabled; then - count=450 # max_num 497 max_ea_size = 4012 - else + elif large_xattr_enabled; then count=4500 # max_num 8187 max_ea_size = 65452 - # not create too much (>5000) to save test time + # not create too many (4500) to save test time + else + count=450 # max_num 497 max_ea_size = 4012 fi echo "It is expected to hold at least $count ACL entries" @@ -5859,22 +5856,15 @@ test_81() { # LU-4665 # Check max_easize. local max_easize=$($LCTL get_param -n llite.*.max_easize) - if [ $MDS1_VERSION -lt $(version_code 2.12.51) ] - then - [[ $max_easize -eq 128 ]] || - error "max_easize is $max_easize, should be 128 bytes" + # 65452 is XATTR_SIZE_MAX less ldiskfs ea overhead + if large_xattr_enabled; then + [[ $max_easize -ge 65452 ]] || + error "max_easize is $max_easize, should be at least 65452 bytes" else # LU-11868 - # 4012 is 4096 - ldiskfs ea overhead + # 4012 is 4096 less ldiskfs ea overhead [[ $max_easize -ge 4012 ]] || - error "max_easize is $max_easize, should be at least 4012 bytes" - - # 65452 is XATTR_SIZE_MAX - ldiskfs ea overhead - if large_xattr_enabled; - then - [[ $max_easize -ge 65452 ]] || - error "max_easize is $max_easize, should be at least 65452 bytes" - fi + error "max_easize is $max_easize, should be at least 4012 bytes" fi restore_ostindex diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index 3df762b..a8b4127 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -2628,7 +2628,7 @@ run_test 204c "FLR write/stale/resync test with component removal" test_204d() { [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] && - skip "skipped for lustre < $SEL_VERSION" + skip "skipped for lustre < $SEL_VER" local comp_file=$DIR/$tdir/$tfile local found="" @@ -2697,7 +2697,7 @@ run_test 204d "FLR write/stale/resync sel test with repeated comp" test_204e() { [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] && - skip "skipped for lustre < $SEL_VERSION" + skip "skipped for lustre < $SEL_VER" local comp_file=$DIR/$tdir/$tfile local found="" @@ -2778,7 +2778,7 @@ run_test 204e "FLR write/stale/resync sel test with repeated comp" test_204f() { [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] && - skip "skipped for lustre < $SEL_VERSION" + skip "skipped for lustre < $SEL_VER" local comp_file=$DIR/$tdir/$tfile local found="" diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 3f784ff..1e7d1e1 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -2468,11 +2468,11 @@ test_27D() { [ $MDS1_VERSION -lt $(version_code 2.9.55) ] || [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] && skip27D+=" -s 30,31" - [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] && - skip27D+="-s 32" [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping || $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] && skip27D+=" -s 32,33" + [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] && + skip27D+=" -s 34" llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D || error "llapi_layout_test failed" @@ -2612,6 +2612,8 @@ run_test 27H "Set specific OSTs stripe" test_27I() { [ $PARALLEL == "yes" ] && skip "skip parallel run" [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" + [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] || + skip "Need MDS version newer than 2.12.52" local pool=$TESTNAME local ostrange="1 1 1" @@ -5857,6 +5859,8 @@ test_56r() { run_test 56r "check lfs find -size works" test_56ra() { + [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] || + skip "MDS < 2.12.58 doesn't return LSOM data" local dir=$DIR/$tdir [[ $OSC == "mdc" ]] && skip "DoM files" && return @@ -22144,6 +22148,8 @@ run_test 809 "Verify no SOM xattr store for DoM-only files" test_810() { [ $PARALLEL == "yes" ] && skip "skip parallel run" $GSS && skip_env "could not run with gss" + [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] || + skip "OST < 2.12.58 doesn't align checksum" set_checksums 1 stack_trap "set_checksums $ORIG_CSUM" EXIT diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 896a983..537a041 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -8475,7 +8475,7 @@ get_block_size() { # ldiskfs xattrs over one block in size. Allow both the historical # Lustre feature name (large_xattr) and the upstream name (ea_inode). large_xattr_enabled() { - [[ $(facet_fstype $SINGLEMDS) == zfs ]] && return 0 + [[ $(facet_fstype $SINGLEMDS) == zfs ]] && return 1 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/}) @@ -8486,20 +8486,7 @@ large_xattr_enabled() { # Get the maximum xattr size supported by the filesystem. max_xattr_size() { - local size - - if large_xattr_enabled; then - size=$($LCTL get_param -n llite.*.max_easize) - else - local mds_dev=$(mdsdevname ${SINGLEMDS//mds/}) - local block_size=$(get_block_size $SINGLEMDS $mds_dev) - - # maximum xattr size = size of block - size of header - - # size of 1 entry - 4 null bytes - size=$((block_size - 32 - 32 - 4)) - fi - - echo $size + $LCTL get_param -n llite.*.max_easize } # Dump the value of the named xattr from a file. @@ -10262,8 +10249,8 @@ verify_comp_at_zero() { error "No component starting at zero(!)" } -#TODO: This version is a placeholder, to be replaced before final commit -SEL_VER="2.12.52" +# version after which Self-Extending Layouts are available +SEL_VER="2.12.55" sel_layout_sanity() { local file=$1 -- 1.8.3.1