From 195548f55b09bf71db92929b7b734407b863093c Mon Sep 17 00:00:00 2001 From: Ashish Pandey Date: Thu, 26 Nov 2015 14:35:49 +0530 Subject: storage/posix: Implement .unlink directory Problem: For EC volume, If a file descriptor is open and file has been unlinked, any further write on that fd will fail. When a write request comes, EC internally reads some blocks using anonymous fd. This read will fail as the file has already been unlinked. Solution: To solve this issue, we are using .unlink directory to keep track of unlinked file. If a file is to be unlinked while its fd is open, move this to .unlink directory and unlink it from .glusterfs and real path. Once all the fd will be closed, remove this entry form .unlink directory. master - http://review.gluster.org/#/c/12816/ Change-Id: I8344edb0d340bdb883dc46458c16edbc336916b9 BUG: 1291557 Signed-off-by: Ashish Pandey Reviewed-on: http://review.gluster.org/12968 Reviewed-by: Pranith Kumar Karampuri Tested-by: Pranith Kumar Karampuri Smoke: Gluster Build System CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System --- tests/basic/ec/ec-anonymous-fd.t | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/basic/ec/ec-anonymous-fd.t (limited to 'tests/basic') diff --git a/tests/basic/ec/ec-anonymous-fd.t b/tests/basic/ec/ec-anonymous-fd.t new file mode 100644 index 00000000000..a61628182ef --- /dev/null +++ b/tests/basic/ec/ec-anonymous-fd.t @@ -0,0 +1,42 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../fileio.rc + +cleanup +function num_entries { + ls -l $1 | wc -l +} + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 disperse 6 redundancy 2 $H0:$B0/${V0}{0..5} +TEST $CLI volume start $V0 +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0 + +fd1=`fd_available` +TEST fd_open $fd1 'w' $M0/file1 +TEST fd_write $fd1 testing +TEST cat $M0/file1 +TEST rm -rf $M0/file1 +TEST fd_write $fd1 testing +TEST fd_write $fd1 testing +TEST fd_write $fd1 testing + +EXPECT "^2$" num_entries $B0/${V0}0/.glusterfs/unlink/ +EXPECT "^2$" num_entries $B0/${V0}1/.glusterfs/unlink/ +EXPECT "^2$" num_entries $B0/${V0}2/.glusterfs/unlink/ +EXPECT "^2$" num_entries $B0/${V0}3/.glusterfs/unlink/ +EXPECT "^2$" num_entries $B0/${V0}4/.glusterfs/unlink/ +EXPECT "^2$" num_entries $B0/${V0}5/.glusterfs/unlink/ +TEST fd_close $fd1; +EXPECT_WITHIN $UNLINK_TIMEOUT "^1$" num_entries $B0/${V0}0/.glusterfs/unlink/ +EXPECT_WITHIN $UNLINK_TIMEOUT "^1$" num_entries $B0/${V0}1/.glusterfs/unlink/ +EXPECT_WITHIN $UNLINK_TIMEOUT "^1$" num_entries $B0/${V0}2/.glusterfs/unlink/ +EXPECT_WITHIN $UNLINK_TIMEOUT "^1$" num_entries $B0/${V0}3/.glusterfs/unlink/ +EXPECT_WITHIN $UNLINK_TIMEOUT "^1$" num_entries $B0/${V0}4/.glusterfs/unlink/ +EXPECT_WITHIN $UNLINK_TIMEOUT "^1$" num_entries $B0/${V0}5/.glusterfs/unlink/ + +cleanup; -- cgit