aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/file.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index c9ebd4fe8f7e..e862292bdfc6 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -251,7 +251,6 @@ static int noinline dirty_and_release_pages(struct btrfs_trans_handle *trans,
251 num_bytes = (write_bytes + pos - start_pos + 251 num_bytes = (write_bytes + pos - start_pos +
252 root->sectorsize - 1) & ~((u64)root->sectorsize - 1); 252 root->sectorsize - 1) & ~((u64)root->sectorsize - 1);
253 253
254 down_read(&BTRFS_I(inode)->root->snap_sem);
255 end_of_last_block = start_pos + num_bytes - 1; 254 end_of_last_block = start_pos + num_bytes - 1;
256 255
257 lock_extent(em_tree, start_pos, end_of_last_block, GFP_NOFS); 256 lock_extent(em_tree, start_pos, end_of_last_block, GFP_NOFS);
@@ -356,7 +355,6 @@ out_unlock:
356 mutex_unlock(&root->fs_info->fs_mutex); 355 mutex_unlock(&root->fs_info->fs_mutex);
357 unlock_extent(em_tree, start_pos, end_of_last_block, GFP_NOFS); 356 unlock_extent(em_tree, start_pos, end_of_last_block, GFP_NOFS);
358 free_extent_map(em); 357 free_extent_map(em);
359 up_read(&BTRFS_I(inode)->root->snap_sem);
360 return err; 358 return err;
361} 359}
362 360
@@ -726,6 +724,8 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf,
726 724
727 pages = kmalloc(nrptrs * sizeof(struct page *), GFP_KERNEL); 725 pages = kmalloc(nrptrs * sizeof(struct page *), GFP_KERNEL);
728 726
727 down_read(&BTRFS_I(inode)->root->snap_sem);
728
729 mutex_lock(&inode->i_mutex); 729 mutex_lock(&inode->i_mutex);
730 first_index = pos >> PAGE_CACHE_SHIFT; 730 first_index = pos >> PAGE_CACHE_SHIFT;
731 last_index = (pos + count) >> PAGE_CACHE_SHIFT; 731 last_index = (pos + count) >> PAGE_CACHE_SHIFT;
@@ -804,6 +804,8 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf,
804 } 804 }
805out: 805out:
806 mutex_unlock(&inode->i_mutex); 806 mutex_unlock(&inode->i_mutex);
807 up_read(&BTRFS_I(inode)->root->snap_sem);
808
807out_nolock: 809out_nolock:
808 kfree(pages); 810 kfree(pages);
809 if (pinned[0]) 811 if (pinned[0])