summaryrefslogtreecommitdiffstats
path: root/tests/basic/bd.t
blob: 63622edd70964c88387b8d29ab4b020b22b8b864 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash

. $(dirname $0)/../include.rc
. $(dirname $0)/../volume.rc

function execute()
{
        cmd=$1
        shift
        ${cmd} $@ >/dev/null 2>&1
}

function bd_cleanup()
{
        execute vgremove -f ${V0}
        execute pvremove ${ld}
        execute losetup -d ${ld}
        execute rm ${BD_DISK}
        cleanup
}

function check()
{
        if [ $? -ne 0 ]; then
                echo prerequsite $@ failed
                bd_cleanup
                exit
        fi
}

SIZE=256 #in MB

bd_cleanup;

## Configure environment needed for BD backend volumes
## Create a file with configured size and
## set it as a temporary loop device to create
## physical volume & VG. These are basic things needed
## for testing BD xlator if anyone of these steps fail,
## test script exits
function configure()
{
    GLDIR=`$CLI system:: getwd`
    BD_DISK=${GLDIR}/bd_disk

    execute truncate -s${SIZE}M ${BD_DISK}
    check ${BD_DISK} creation

    execute losetup -f
    check losetup
    ld=`losetup -f`

    execute losetup ${ld} ${BD_DISK}
    check losetup ${BD_DISK}
    execute pvcreate -f ${ld}
    check pvcreate ${ld}
    execute vgcreate ${V0} ${ld}
    check vgcreate ${V0}
    execute lvcreate --thin ${V0}/pool --size 128M
}

function volinfo_field()
{
    local vol=$1;
    local field=$2;
    $CLI volume info $vol | grep "^$field: " | sed 's/.*: //';
}

function volume_type()
{
        getfattr -n volume.type $M0/. --only-values --absolute-names -e text
}

case $OSTYPE in
NetBSD)
        echo "Skip test on LVM which is not available on NetBSD" >&2
        SKIP_TESTS
        exit 0
        ;;
*)      
        ;;
esac 

TEST glusterd
TEST pidof glusterd
configure

TEST $CLI volume create $V0 ${H0}:/$B0/$V0?${V0}
EXPECT "$V0" volinfo_field $V0 'Volume Name';
EXPECT 'Created' volinfo_field $V0 'Status';

## Start volume and verify
TEST $CLI volume start $V0;
EXPECT 'Started' volinfo_field $V0 'Status'

TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
EXPECT '1' volume_type

## Create posix file
TEST touch $M0/posix

TEST touch $M0/lv
gfid=`getfattr -n glusterfs.gfid.string $M0/lv --only-values --absolute-names`
TEST setfattr -n user.glusterfs.bd -v "lv:4MB" $M0/lv
# Check if LV is created
TEST stat /dev/$V0/${gfid}

## Create filesystem
sleep 1
TEST mkfs.ext4 -qF $M0/lv
# Cloning
TEST touch $M0/lv_clone
gfid=`getfattr -n glusterfs.gfid.string $M0/lv_clone --only-values --absolute-names`
TEST setfattr -n clone -v ${gfid} $M0/lv
TEST stat /dev/$V0/${gfid}

sleep 1
## Check mounting
TEST mount -o loop $M0/lv $M1
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M1

# Snapshot
TEST touch $M0/lv_sn
gfid=`getfattr -n glusterfs.gfid.string $M0/lv_sn --only-values --absolute-names`
TEST setfattr -n snapshot -v ${gfid} $M0/lv
TEST stat /dev/$V0/${gfid}

# Merge
sleep 1
TEST setfattr -n merge -v "$M0/lv_sn" $M0/lv_sn
TEST ! stat $M0/lv_sn
TEST ! stat /dev/$V0/${gfid}


rm $M0/* -f

EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
TEST $CLI volume stop ${V0}
EXPECT 'Stopped' volinfo_field $V0 'Status';
TEST $CLI volume delete ${V0}

bd_cleanup
dict_t *dict);
+int32_t default_rchecksum_resume (call_frame_t *frame,
+ xlator_t *this,
+ fd_t *fd, off_t offset,
+ int32_t len);
int32_t default_notify (xlator_t *this,
int32_t event,
diff --git a/xlators/features/Makefile.am b/xlators/features/Makefile.am
index 6496f3ab0c9..8b23b939b0e 100644
--- a/xlators/features/Makefile.am
+++ b/xlators/features/Makefile.am
@@ -1,3 +1,3 @@
-SUBDIRS = locks trash quota read-only access-control mac-compat #path-converter # filter
+SUBDIRS = locks trash quota read-only access-control mac-compat quiesce #path-converter # filter
CLEANFILES =
diff --git a/xlators/features/quiesce/Makefile.am b/xlators/features/quiesce/Makefile.am
new file mode 100644
index 00000000000..a985f42a877
--- /dev/null
+++ b/xlators/features/quiesce/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = src
+
+CLEANFILES =
diff --git a/xlators/features/quiesce/src/Makefile.am b/xlators/features/quiesce/src/Makefile.am
new file mode 100644
index 00000000000..e8ab4cb2417
--- /dev/null
+++ b/xlators/features/quiesce/src/Makefile.am
@@ -0,0 +1,14 @@
+xlator_LTLIBRARIES = quiesce.la
+xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/features
+
+quiesce_la_LDFLAGS = -module -avoidversion
+
+quiesce_la_SOURCES = quiesce.c
+quiesce_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
+
+noinst_HEADERS = quiesce.h quiesce-mem-types.h
+
+AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Wall -D$(GF_HOST_OS) \
+ -I$(top_srcdir)/libglusterfs/src -shared -nostartfiles $(GF_CFLAGS)
+
+CLEANFILES =
diff --git a/xlators/features/quiesce/src/quiesce-mem-types.h b/xlators/features/quiesce/src/quiesce-mem-types.h
new file mode 100644
index 00000000000..07f2e97c65b
--- /dev/null
+++ b/xlators/features/quiesce/src/quiesce-mem-types.h
@@ -0,0 +1,30 @@
+/*
+ Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef __QUIESCE_MEM_TYPES_H__
+#define __QUIESCE_MEM_TYPES_H__
+
+#include "mem-types.h"
+
+enum gf_quiesce_mem_types_ {
+ gf_quiesce_mt_priv_t = gf_common_mt_end + 1,
+ gf_quiesce_mt_end
+};
+#endif
diff --git a/xlators/features/quiesce/src/quiesce.c b/xlators/features/quiesce/src/quiesce.c
new file mode 100644
index 00000000000..8d062cb5105
--- /dev/null
+++ b/xlators/features/quiesce/src/quiesce.c
@@ -0,0 +1,1569 @@
+/*
+ Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "quiesce.h"
+#include "defaults.h"
+#include "call-stub.h"
+
+/* Quiesce Specific Functions */
+call_stub_t *
+gf_quiesce_dequeue (quiesce_priv_t *priv)
+{
+ call_stub_t *stub = NULL;
+
+ if (list_empty (&priv->req))
+ return NULL;
+
+ LOCK (&priv->lock);
+ {
+ stub = list_entry (priv->req.next, call_stub_t, list);
+ list_del_init (&stub->list);
+ priv->queue_size--;
+ }