From 476139c962c298b2d00a3d42b90632fc25401526 Mon Sep 17 00:00:00 2001 From: David Spisla Date: Tue, 25 Feb 2020 10:57:36 +0100 Subject: WORM-Xlator: Initial write of a file succeeds if auto-commit-period 0 If worm-file-level enabled and auto-commit-period 0 an initial write of a file (e.g. $ echo test >> file1.txt) would lead to an zero byte file because the WORM xlator immediately WORMed the file when it was created. To avoid this we move the setting of trusted.worm_file from worm_create_cbk to worm_release . This means that this xattr will set when the filehandle is closed and all initial WRITE FOPs succeed. Finally we also perform gf_worm_state_transition in worm_release to ensure that the file will be immediately WORMed after the file handle was closed. Change-Id: I5d02e18975b646ca1a27ed41d836e9d0dc333204 Fixes: bz#1808421 Signed-off-by: David Spisla --- tests/features/worm.t | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/features') diff --git a/tests/features/worm.t b/tests/features/worm.t index 8b2574c8a47..168d326571b 100755 --- a/tests/features/worm.t +++ b/tests/features/worm.t @@ -72,6 +72,14 @@ sleep 10 TEST `echo "worm 1" >> $M0/file4` TEST ! rm -f $M0/file4 +## Test for state transition if auto-commit-period is 0 +TEST $CLI volume set $V0 features.auto-commit-period 0 +TEST `echo "worm 1" > $M0/file5` +EXPECT '3/10/0' echo $(getfattr -e text --absolute-names --only-value -n "trusted.reten_state" $B0/${V0}1/file5) +EXPECT 'worm 1' cat $M0/file5 +TEST ! rm -f $M0/file5 +TEST $CLI volume set $V0 features.auto-commit-period 5 + ## Test for checking if retention-period is updated on increasing the access time of a WORM-RETAINED file. TEST $CLI volume set $V0 features.worm-files-deletable 1 TEST `echo "worm 1" >> $M0/file1` -- cgit