]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | import os | |
3 | import time | |
4 | from textwrap import dedent | |
7c673cae FG |
5 | from tasks.cephfs.cephfs_test_case import CephFSTestCase, for_teuthology |
6 | ||
7 | class TestCapFlush(CephFSTestCase): | |
8 | @for_teuthology | |
9 | def test_replay_create(self): | |
10 | """ | |
11 | MDS starts to handle client caps when it enters clientreplay stage. | |
12 | When handling a client cap in clientreplay stage, it's possible that | |
13 | corresponding inode does not exist because the client request which | |
14 | creates inode hasn't been replayed. | |
15 | """ | |
16 | ||
7c673cae FG |
17 | dir_path = os.path.join(self.mount_a.mountpoint, "testdir") |
18 | py_script = dedent(""" | |
19 | import os | |
20 | os.mkdir("{0}") | |
21 | fd = os.open("{0}", os.O_RDONLY) | |
9f95a23c | 22 | os.fchmod(fd, 0o777) |
7c673cae FG |
23 | os.fsync(fd) |
24 | """).format(dir_path) | |
25 | self.mount_a.run_python(py_script) | |
26 | ||
27 | self.fs.mds_asok(["flush", "journal"]) | |
28 | ||
29 | # client will only get unsafe replay | |
30 | self.fs.mds_asok(["config", "set", "mds_log_pause", "1"]) | |
31 | ||
32 | file_name = "testfile" | |
33 | file_path = dir_path + "/" + file_name | |
34 | ||
35 | # Create a file and modify its mode. ceph-fuse will mark Ax cap dirty | |
36 | py_script = dedent(""" | |
37 | import os | |
38 | os.chdir("{0}") | |
39 | os.setgid(65534) | |
40 | os.setuid(65534) | |
9f95a23c TL |
41 | fd = os.open("{1}", os.O_CREAT | os.O_RDWR, 0o644) |
42 | os.fchmod(fd, 0o640) | |
7c673cae | 43 | """).format(dir_path, file_name) |
522d829b | 44 | self.mount_a.run_python(py_script, sudo=True) |
7c673cae FG |
45 | |
46 | # Modify file mode by different user. ceph-fuse will send a setattr request | |
1e59de90 | 47 | self.mount_a.run_shell(["sudo", "chmod", "600", file_path], wait=False, omit_sudo=False) |
7c673cae FG |
48 | |
49 | time.sleep(10) | |
50 | ||
51 | # Restart mds. Client will re-send the unsafe request and cap flush | |
f67539c2 | 52 | self.fs.rank_fail() |
7c673cae FG |
53 | self.fs.wait_for_daemons() |
54 | ||
55 | mode = self.mount_a.run_shell(['stat', '-c' '%a', file_path]).stdout.getvalue().strip() | |
56 | # If the cap flush get dropped, mode should be 0644. | |
57 | # (Ax cap stays in dirty state, which prevents setattr reply from updating file mode) | |
58 | self.assertEqual(mode, "600") |