- remote_mds_nodsh && skip "remote MDS with nodsh" && return
- [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
- { skip "Need MDS version at least 2.2.0"; return; }
- USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
- echo "Registered as changelog user $USER"
- do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
- grep -q $USER || error "User $USER not found in changelog_users"
-
- # change something
- test_mkdir -p $DIR/$tdir/pics/2008/zachy
- touch $DIR/$tdir/pics/2008/zachy/timestamp
- cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
- mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
- ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
- ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
- rm $DIR/$tdir/pics/desktop.jpg
-
- $LFS changelog $MDT0 | tail -5
-
- echo "verifying changelog mask"
- changelog_chmask "MKDIR"
- changelog_chmask "CLOSE"
-
- test_mkdir -p $DIR/$tdir/pics/zach/sofia
- echo "zzzzzz" > $DIR/$tdir/pics/zach/file
-
- changelog_chmask "MKDIR"
- changelog_chmask "CLOSE"
-
- test_mkdir -p $DIR/$tdir/pics/2008/sofia
- echo "zzzzzz" > $DIR/$tdir/pics/zach/file
-
- $LFS changelog $MDT0
- MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
- CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
- [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
- [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
-
- # verify contents
- echo "verifying target fid"
- fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
- tail -1 | awk '{print $6}')
- fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
- [ "$fidc" == "t=$fidf" ] || \
- err17935 "fid in changelog $fidc != file fid $fidf"
- echo "verifying parent fid"
- fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
- tail -1 | awk '{print $7}')
- fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
- [ "$fidc" == "p=$fidf" ] || \
- err17935 "pfid in changelog $fidc != dir fid $fidf"
-
- USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
- mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
- $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
- USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
- mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
- echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
- [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
- err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
-
- MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
- awk 'min == "" || $2 < min {min = $2}; END {print min}')
- FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
- echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
- [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
- err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
-
- echo "verifying user deregister"
- do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
- do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
- grep -q $USER && error "User $USER still found in changelog_users"
-
- USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
- mdd.$MDT0.changelog_users | wc -l) - 2 ))
- if [ $USERS -eq 0 ]; then
- LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
- mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
- touch $DIR/$tdir/chloe
- LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
- mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
- echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
- [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
- else
- echo "$USERS other changelog users; can't verify off"
- fi
+ remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
+ { skip "Need MDS version at least 2.2.0"; return; }
+
+ local CL_USERS="mdd.$MDT0.changelog_users"
+ local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
+ USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
+ echo "Registered as changelog user $USER"
+ $GET_CL_USERS | grep -q $USER ||
+ error "User $USER not found in changelog_users"
+
+ # change something
+ test_mkdir -p $DIR/$tdir/pics/2008/zachy
+ touch $DIR/$tdir/pics/2008/zachy/timestamp
+ cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
+ mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
+ ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
+ ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
+ rm $DIR/$tdir/pics/desktop.jpg
+
+ $LFS changelog $MDT0 | tail -5
+
+ echo "verifying changelog mask"
+ changelog_chmask "MKDIR"
+ changelog_chmask "CLOSE"
+
+ test_mkdir -p $DIR/$tdir/pics/zach/sofia
+ echo "zzzzzz" > $DIR/$tdir/pics/zach/file
+
+ changelog_chmask "MKDIR"
+ changelog_chmask "CLOSE"
+
+ test_mkdir -p $DIR/$tdir/pics/2008/sofia
+ echo "zzzzzz" > $DIR/$tdir/pics/zach/file
+
+ $LFS changelog $MDT0
+ MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
+ CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
+ [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
+ [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
+
+ # verify contents
+ echo "verifying target fid"
+ fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
+ fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
+ [ "$fidc" == "$fidf" ] ||
+ err17935 "fid in changelog $fidc != file fid $fidf"
+ echo "verifying parent fid"
+ fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
+ fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
+ [ "$fidc" == "$fidf" ] ||
+ err17935 "pfid in changelog $fidc != dir fid $fidf"
+
+ USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
+ $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
+ USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
+ echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
+ [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
+ err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
+
+ MIN_REC=$($GET_CL_USERS |
+ awk 'min == "" || $2 < min {min = $2}; END {print min}')
+ FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
+ echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
+ [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
+ err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
+
+ # LU-3446 changelog index reset on MDT restart
+ local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
+ CUR_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
+ $LFS changelog_clear $MDT0 $USER 0
+ stop $SINGLEMDS || error "Fail to stop MDT."
+ start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
+ CUR_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
+ echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
+ [ $CUR_REC1 == $CUR_REC2 ] ||
+ err17935 "current index should be $CUR_REC1 is $CUR_REC2"
+
+ echo "verifying user deregister"
+ do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
+ $GET_CL_USERS | grep -q $USER &&
+ error "User $USER still in changelog_users"
+
+ USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
+ if [ $USERS -eq 0 ]; then
+ LAST_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
+ touch $DIR/$tdir/chloe
+ LAST_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
+ echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
+ [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
+ else
+ echo "$USERS other changelog users; can't verify off"
+ fi