summaryrefslogtreecommitdiff
path: root/tests/bcachefs/quota.ktest
blob: 54d42aad84906d04a1933f7f2d4fe98609af0357 (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash

. $(dirname $(readlink -e ${BASH_SOURCE[0]}))/bcachefs-test-libs.sh

require-kernel-config QUOTA
require-kernel-config BCACHEFS_QUOTA

config-scratch-devs 4G
config-scratch-devs 4G

require-git http://evilpiepirate.org/git/linuxquota.git
require-make linuxquota

test_usrquota_twodevices()
{
    bcachefs format				\
	--errors=panic		\
	/dev/sd[bc] >/dev/null

    mount -t bcachefs -o usrquota,grpquota,prjquota /dev/sdc:/dev/sdb /mnt

    repquota -s /mnt

    echo foo:10	    >> /etc/projid
    echo 10:/mnt    >> /etc/projects

    setquota -u root 256M 512M 64 128 /mnt
    #setquota -t 60 60 /mnt

    echo "testing direct writes"
    ! dd if=/dev/zero of=/mnt/foo bs=1M oflag=direct
    repquota -s /mnt

    rm /mnt/foo

    echo "testing buffered writes"
    ! dd if=/dev/zero of=/mnt/foo bs=1M
    repquota -s /mnt
    rm /mnt/foo

    umount /mnt
}

test_usrquota()
{
    if false; then
	mkfs.xfs /dev/sdb
    else
	bcachefs format				\
	    --errors=panic		\
	    /dev/sdb >/dev/null
    fi

    mount -t bcachefs -o usrquota,grpquota,prjquota /dev/sdb /mnt

    repquota -s /mnt

    echo foo:10	    >> /etc/projid
    echo 10:/mnt    >> /etc/projects

    setquota -u root 256M 512M 64 128 /mnt
    #setquota -t 60 60 /mnt

    echo "testing direct writes"
    ! dd if=/dev/zero of=/mnt/foo bs=1M oflag=direct
    repquota -s /mnt

    rm /mnt/foo

    echo "testing buffered writes"
    ! dd if=/dev/zero of=/mnt/foo bs=1M
    repquota -s /mnt
    rm /mnt/foo

    umount /mnt
}

test_grpquota()
{
    if false; then
	mkfs.xfs /dev/sdb
    else
	bcachefs format				\
	    --errors=panic		\
	    /dev/sdb /dev/sdc >/dev/null
    fi

    mount -t bcachefs -o usrquota,grpquota,prjquota /dev/sdb:/dev/sdc /mnt

    setquota -g root 256M 512M 64 128 /mnt
    #setquota -t 60 60 /mnt

    repquota -g -s /mnt

    echo "testing direct writes"
    ! dd if=/dev/zero of=/mnt/foo bs=1M oflag=direct
    repquota -g -s /mnt

    umount /mnt
}

test_prjquota()
{
    bcachefs format		\
	--errors=panic		\
	/dev/sdb >/dev/null

    mount -t bcachefs -o usrquota,grpquota,prjquota /dev/sdb /mnt

    repquota -vP  /mnt
    mkdir /mnt/q1
    mkdir /mnt/q2
    touch /mnt/q1/foo
    touch /mnt/q1/foo

    setproject -c -P q1 /mnt/q1
    setproject -c -P q2_averylongprojectquotanamefooooooooooooooooooooooooooooooooooooooooobar /mnt/q2

    getfattr -R -d -m - /mnt/

    #setquota -t 60 60 /mnt
    setquota -P q1 256M 512M 64 128 /mnt

    echo "testing direct writes"
    ! dd if=/dev/zero of=/mnt/q1/foo bs=1M oflag=direct
    repquota -P -s /mnt

    chattr -p 0 /mnt/q1/foo

    #mv /mnt/q1/foo /mnt/q2
    repquota -P -s /mnt

    umount /mnt
}

test_prjquota_multidevices()
{
    bcachefs format			\
	--errors=panic		\
	/dev/sd[bc] >/dev/null

    mount -t bcachefs -o usrquota,grpquota,prjquota /dev/sdb:/dev/sdc /mnt

    repquota -vP  /mnt
    mkdir /mnt/q1
    mkdir /mnt/q2
    touch /mnt/q1/foo
    touch /mnt/q1/foo

    setproject -c -P q1 /mnt/q1
    setproject -c -P q2 /mnt/q2

    getfattr -R -d -m - /mnt/

    #setquota -t 60 60 /mnt
    setquota -P q1 256M 512M 64 128 /mnt

    echo "testing direct writes"
    ! dd if=/dev/zero of=/mnt/q1/foo bs=1M oflag=direct
    repquota -P -s /mnt

    mv /mnt/q1/foo /mnt/q2
    repquota -P -s /mnt

    umount /mnt
}

main "$@"