num_bytes = (write_bytes + pos - start_pos +
root->sectorsize - 1) & ~((u64)root->sectorsize - 1);
- down_read(&BTRFS_I(inode)->root->snap_sem);
end_of_last_block = start_pos + num_bytes - 1;
lock_extent(em_tree, start_pos, end_of_last_block, GFP_NOFS);
mutex_unlock(&root->fs_info->fs_mutex);
unlock_extent(em_tree, start_pos, end_of_last_block, GFP_NOFS);
free_extent_map(em);
- up_read(&BTRFS_I(inode)->root->snap_sem);
return err;
}
pages = kmalloc(nrptrs * sizeof(struct page *), GFP_KERNEL);
+ down_read(&BTRFS_I(inode)->root->snap_sem);
+
mutex_lock(&inode->i_mutex);
first_index = pos >> PAGE_CACHE_SHIFT;
last_index = (pos + count) >> PAGE_CACHE_SHIFT;
}
out:
mutex_unlock(&inode->i_mutex);
+ up_read(&BTRFS_I(inode)->root->snap_sem);
+
out_nolock:
kfree(pages);
if (pinned[0])