diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-09-10 19:58:36 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-09-10 19:58:36 -0400 |
commit | 011410bd859a481a335d7db1fb559542c5663fd5 (patch) | |
tree | 39b7d65352f49abe4eeb9cabd3b19d1b50faf9a2 /fs/btrfs/file.c | |
parent | 86479a04eef8f304a13aeb8b64bcc8e506a68268 (diff) |
Btrfs: Add more synchronization before creating a snapshot
File data checksums are only done during writepage, so we have to make sure
all pages are written when the snapshot is taken. This also adds some
locking so that new writes don't race in and add new dirty pages.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r-- | fs/btrfs/file.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index acef8cb7fb79..77f1950b0aa0 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -160,6 +160,7 @@ static int dirty_and_release_pages(struct btrfs_trans_handle *trans, | |||
160 | num_blocks = (write_bytes + pos - start_pos + root->blocksize - 1) >> | 160 | num_blocks = (write_bytes + pos - start_pos + root->blocksize - 1) >> |
161 | inode->i_blkbits; | 161 | inode->i_blkbits; |
162 | 162 | ||
163 | down_read(&BTRFS_I(inode)->root->snap_sem); | ||
163 | end_of_last_block = start_pos + (num_blocks << inode->i_blkbits) - 1; | 164 | end_of_last_block = start_pos + (num_blocks << inode->i_blkbits) - 1; |
164 | lock_extent(em_tree, start_pos, end_of_last_block, GFP_NOFS); | 165 | lock_extent(em_tree, start_pos, end_of_last_block, GFP_NOFS); |
165 | mutex_lock(&root->fs_info->fs_mutex); | 166 | mutex_lock(&root->fs_info->fs_mutex); |
@@ -250,6 +251,7 @@ out_unlock: | |||
250 | mutex_unlock(&root->fs_info->fs_mutex); | 251 | mutex_unlock(&root->fs_info->fs_mutex); |
251 | unlock_extent(em_tree, start_pos, end_of_last_block, GFP_NOFS); | 252 | unlock_extent(em_tree, start_pos, end_of_last_block, GFP_NOFS); |
252 | free_extent_map(em); | 253 | free_extent_map(em); |
254 | up_read(&BTRFS_I(inode)->root->snap_sem); | ||
253 | return err; | 255 | return err; |
254 | } | 256 | } |
255 | 257 | ||