From 8ed31f48b3492909739a35ae6a0fbde111f7f028 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Wed, 6 Sep 2017 00:04:56 +0900 Subject: [PATCH] LU-9946 nodemap: have fileset on default nodemap. When a directory is defined as fileset on the default nodemap entry, all clients that fall into default will be imposed subdirectory mount on this directory. Signed-off-by: Sebastien Buisson Change-Id: I3491bce4f8c2011629e56494bf1a0de57f19829d Reviewed-on: https://review.whamcloud.com/28858 Tested-by: Jenkins Reviewed-by: John L. Hammond Reviewed-by: Emoly Liu Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/ptlrpc/nodemap_handler.c | 14 ++--- lustre/ptlrpc/nodemap_lproc.c | 4 ++ lustre/tests/sanity-sec.sh | 126 +++++++++++++++++++++++----------------- 3 files changed, 83 insertions(+), 61 deletions(-) diff --git a/lustre/ptlrpc/nodemap_handler.c b/lustre/ptlrpc/nodemap_handler.c index ba5f4a7..312980c 100644 --- a/lustre/ptlrpc/nodemap_handler.c +++ b/lustre/ptlrpc/nodemap_handler.c @@ -915,10 +915,7 @@ int nodemap_set_fileset(const char *name, const char *fileset) GOTO(out, rc = PTR_ERR(nodemap)); } - if (is_default_nodemap(nodemap)) - rc = -EINVAL; - else - rc = nodemap_set_fileset_helper(active_config, nodemap, + rc = nodemap_set_fileset_helper(active_config, nodemap, fileset); mutex_unlock(&active_config_lock); @@ -937,10 +934,10 @@ EXPORT_SYMBOL(nodemap_set_fileset); */ char *nodemap_get_fileset(const struct lu_nodemap *nodemap) { - if (!nodemap_active || is_default_nodemap(nodemap)) + if (!nodemap_active) return NULL; - else - return (char *)nodemap->nm_fileset; + + return (char *)nodemap->nm_fileset; } EXPORT_SYMBOL(nodemap_get_fileset); @@ -1029,6 +1026,7 @@ struct lu_nodemap *nodemap_create(const char *name, nodemap->nm_squash_uid = NODEMAP_NOBODY_UID; nodemap->nm_squash_gid = NODEMAP_NOBODY_GID; + nodemap->nm_fileset[0] = '\0'; if (!is_default) CWARN("adding nodemap '%s' to config without" " default nodemap\n", nodemap->nm_name); @@ -1046,7 +1044,7 @@ struct lu_nodemap *nodemap_create(const char *name, nodemap->nm_squash_uid = default_nodemap->nm_squash_uid; nodemap->nm_squash_gid = default_nodemap->nm_squash_gid; - nodemap->nm_fileset[0] = 0; + nodemap->nm_fileset[0] = '\0'; } return nodemap; diff --git a/lustre/ptlrpc/nodemap_lproc.c b/lustre/ptlrpc/nodemap_lproc.c index fc13b00..6058793 100644 --- a/lustre/ptlrpc/nodemap_lproc.c +++ b/lustre/ptlrpc/nodemap_lproc.c @@ -1241,6 +1241,10 @@ static struct lprocfs_vars lprocfs_default_nodemap_vars[] = { .fops = &nodemap_squash_gid_fops, }, { + .name = "fileset", + .fops = &nodemap_fileset_fops, + }, + { .name = "exports", .fops = &nodemap_exports_fops, }, diff --git a/lustre/tests/sanity-sec.sh b/lustre/tests/sanity-sec.sh index 64e3a08..c91b7e0 100755 --- a/lustre/tests/sanity-sec.sh +++ b/lustre/tests/sanity-sec.sh @@ -1027,15 +1027,18 @@ fops_test_setup() { # fileset test directory needs to be initialized on a privileged client fileset_test_setup() { - local admin=$(do_facet mgs $LCTL get_param -n nodemap.c0.admin_nodemap) + local nm=$1 + local admin=$(do_facet mgs $LCTL get_param -n \ + nodemap.${nm}.admin_nodemap) local trust=$(do_facet mgs $LCTL get_param -n \ - nodemap.c0.trusted_nodemap) + nodemap.${nm}.trusted_nodemap) - do_facet mgs $LCTL nodemap_modify --name c0 --property admin --value 1 - do_facet mgs $LCTL nodemap_modify --name c0 --property trusted --value 1 + do_facet mgs $LCTL nodemap_modify --name $nm --property admin --value 1 + do_facet mgs $LCTL nodemap_modify --name $nm --property trusted \ + --value 1 - wait_nm_sync c0 admin_nodemap - wait_nm_sync c0 trusted_nodemap + wait_nm_sync $nm admin_nodemap + wait_nm_sync $nm trusted_nodemap # create directory and populate it for subdir mount do_node ${clients_arr[0]} mkdir $MOUNT/$subdir || @@ -1049,46 +1052,49 @@ fileset_test_setup() { error "unable to create file \ $MOUNT/$subdir/$subsubdir/this_is_$subsubdir" - do_facet mgs $LCTL nodemap_modify --name c0 \ + do_facet mgs $LCTL nodemap_modify --name $nm \ --property admin --value $admin - do_facet mgs $LCTL nodemap_modify --name c0 \ + do_facet mgs $LCTL nodemap_modify --name $nm \ --property trusted --value $trust # flush MDT locks to make sure they are reacquired before test do_node ${clients_arr[0]} $LCTL set_param \ ldlm.namespaces.$FSNAME-MDT*.lru_size=clear - wait_nm_sync c0 admin_nodemap - wait_nm_sync c0 trusted_nodemap + wait_nm_sync $nm admin_nodemap + wait_nm_sync $nm trusted_nodemap } # fileset test directory needs to be initialized on a privileged client fileset_test_cleanup() { - local admin=$(do_facet mgs $LCTL get_param -n nodemap.c0.admin_nodemap) + local nm=$1 + local admin=$(do_facet mgs $LCTL get_param -n \ + nodemap.${nm}.admin_nodemap) local trust=$(do_facet mgs $LCTL get_param -n \ - nodemap.c0.trusted_nodemap) + nodemap.${nm}.trusted_nodemap) - do_facet mgs $LCTL nodemap_modify --name c0 --property admin --value 1 - do_facet mgs $LCTL nodemap_modify --name c0 --property trusted --value 1 + do_facet mgs $LCTL nodemap_modify --name $nm --property admin --value 1 + do_facet mgs $LCTL nodemap_modify --name $nm --property trusted \ + --value 1 - wait_nm_sync c0 admin_nodemap - wait_nm_sync c0 trusted_nodemap + wait_nm_sync $nm admin_nodemap + wait_nm_sync $nm trusted_nodemap # cleanup directory created for subdir mount do_node ${clients_arr[0]} rm -rf $MOUNT/$subdir || error "unable to remove dir $MOUNT/$subdir" - do_facet mgs $LCTL nodemap_modify --name c0 \ + do_facet mgs $LCTL nodemap_modify --name $nm \ --property admin --value $admin - do_facet mgs $LCTL nodemap_modify --name c0 \ + do_facet mgs $LCTL nodemap_modify --name $nm \ --property trusted --value $trust # flush MDT locks to make sure they are reacquired before test do_node ${clients_arr[0]} $LCTL set_param \ ldlm.namespaces.$FSNAME-MDT*.lru_size=clear - wait_nm_sync c0 admin_nodemap - wait_nm_sync c0 trusted_nodemap + wait_nm_sync $nm admin_nodemap + wait_nm_sync $nm trusted_nodemap } do_create_delete() { @@ -1494,7 +1500,8 @@ run_test 22 "test nodemap mapped_trusted_admin fileops" # acl test directory needs to be initialized on a privileged client nodemap_acl_test_setup() { - local admin=$(do_facet mgs $LCTL get_param -n nodemap.c0.admin_nodemap) + local admin=$(do_facet mgs $LCTL get_param -n \ + nodemap.c0.admin_nodemap) local trust=$(do_facet mgs $LCTL get_param -n \ nodemap.c0.trusted_nodemap) @@ -1752,26 +1759,32 @@ test_26() { } run_test 26 "test transferring very large nodemap" -test_27() { - local subdir=c0dir - local subsubdir=c0subdir +nodemap_exercise_fileset() { + local nm="$1" local fileset_on_mgs="" local loop=0 - nodemap_test_setup + # setup + if [ "$nm" == "default" ]; then + do_facet mgs $LCTL nodemap_activate 1 + wait_nm_sync active + else + nodemap_test_setup + fi if $SHARED_KEY; then export SK_UNIQUE_NM=true else # will conflict with SK's nodemaps - trap nodemap_test_cleanup EXIT + trap "fileset_test_cleanup $nm" EXIT fi + fileset_test_setup "$nm" - fileset_test_setup - - # add fileset info to nodemap - do_facet mgs $LCTL set_param -P nodemap.c0.fileset=/$subdir || - error "unable to add fileset info to nodemap c0" - wait_nm_sync c0 fileset "nodemap.c0.fileset=/$subdir" + # add fileset info to $nm nodemap + do_facet mgs $LCTL set_param nodemap.${nm}.fileset=/$subdir || + error "unable to add fileset info to $nm nodemap on MGS" + do_facet mgs $LCTL set_param -P nodemap.${nm}.fileset=/$subdir || + error "unable to add fileset info to $nm nodemap for servers" + wait_nm_sync $nm fileset "nodemap.${nm}.fileset=/$subdir" # re-mount client zconf_umount_clients ${clients_arr[0]} $MOUNT || @@ -1799,23 +1812,13 @@ test_27() { error "subdir of fileset not taken into account" # remove fileset info from nodemap - do_facet mgs $LCTL nodemap_set_fileset --name c0 --fileset \'\' || - error "unable to delete fileset info on nodemap c0" - fileset_on_mgs=$(do_facet mgs $LCTL get_param nodemap.c0.fileset) - while [ "${fileset_on_mgs}" != "nodemap.c0.fileset=" ]; do - if [ $loop -eq 10 ]; then - error "On MGS, fileset cannnot be cleared" - break; - else - loop=$((loop+1)) - echo "On MGS, fileset is still ${fileset_on_mgs}, waiting..." - sleep 20; - fi - fileset_on_mgs=$(do_facet mgs $LCTL get_param nodemap.c0.fileset) - done - do_facet mgs $LCTL set_param -P nodemap.c0.fileset=\'\' || - error "unable to reset fileset info on nodemap c0" - wait_nm_sync c0 fileset + do_facet mgs $LCTL nodemap_set_fileset --name $nm --fileset \'\' || + error "unable to delete fileset info on $nm nodemap" + wait_update_facet mgs "$LCTL get_param nodemap.${nm}.fileset" \ + "nodemap.${nm}.fileset=" + do_facet mgs $LCTL set_param -P nodemap.${nm}.fileset=\'\' || + error "unable to reset fileset info on $nm nodemap" + wait_nm_sync $nm fileset # re-mount client zconf_umount_clients ${clients_arr[0]} $MOUNT || @@ -1825,7 +1828,7 @@ test_27() { # test mount point content do_node ${clients_arr[0]} test -d $MOUNT/$subdir || - (ls $MOUNT ; error "fileset not cleared on nodemap c0") + (ls $MOUNT ; error "fileset not cleared on $nm nodemap") # back to non-nodemap setup if $SHARED_KEY; then @@ -1833,14 +1836,31 @@ test_27() { zconf_umount_clients ${clients_arr[0]} $MOUNT || error "unable to umount client ${clients_arr[0]}" fi - fileset_test_cleanup - nodemap_test_cleanup + fileset_test_cleanup "$nm" + if [ "$nm" == "default" ]; then + do_facet mgs $LCTL nodemap_activate 0 + wait_nm_sync active 0 + trap 0 + export SK_UNIQUE_NM=false + else + nodemap_test_cleanup + fi if $SHARED_KEY; then zconf_mount_clients ${clients_arr[0]} $MOUNT $MOUNT_OPTS || error "unable to remount client ${clients_arr[0]}" fi } -run_test 27 "test fileset in nodemap" + +test_27() { + for nm in "default" "c0"; do + local subdir="subdir_${nm}" + local subsubdir="subsubdir_${nm}" + + echo "Exercising fileset for nodemap $nm" + nodemap_exercise_fileset "$nm" + done +} +run_test 27 "test fileset in various nodemaps" test_28() { if ! $SHARED_KEY; then -- 1.8.3.1