]> git.hungrycats.org Git - linux/commit
Btrfs: fill ->last_trans for delayed inode in btrfs_fill_inode.
authorYang Dongsheng <yangds.fnst@cn.fujitsu.com>
Thu, 9 Apr 2015 04:08:43 +0000 (12:08 +0800)
committerChris Mason <clm@fb.com>
Tue, 21 Apr 2015 01:44:15 +0000 (18:44 -0700)
commitc7dd5f4d39048dc075796b53aede1c5d7711c561
tree2c64068ff29119a4b04c264603d43f40dae49966
parentf5b5132ae00b3d62c31532064c0995ad02d92787
Btrfs: fill ->last_trans for delayed inode in btrfs_fill_inode.

We need to fill inode when we found a node for it in delayed_nodes_tree.
But we did not fill the ->last_trans currently, it will cause the test
of xfstest/generic/311 fail. Scenario of the 311 is shown as below:

Problem:
(1). test_fd = open(fname, O_RDWR|O_DIRECT)
(2). pwrite(test_fd, buf, 4096, 0)
(3). close(test_fd)
(4). drop_all_caches() <-------- "echo 3 > /proc/sys/vm/drop_caches"
(5). test_fd = open(fname, O_RDWR|O_DIRECT)
(6). fsync(test_fd);
<-------- we did not get the correct log entry for the file
Reason:
When we re-open this file in (5), we would find a node
in delayed_nodes_tree and fill the inode we are lookup with the
information. But the ->last_trans is not filled, then the fsync()
will check the ->last_trans and found it's 0 then say this inode
is already in our tree which is commited, not recording the extents
for it.

Fix:
This patch fill the ->last_trans properly and set the
runtime_flags if needed in this situation. Then we can get the
log entries we expected after (6) and generic/311 passed.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Reviewed-by: Miao Xie <miaoxie@huawei.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/delayed-inode.c
fs/btrfs/inode.c