summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 9f5cc1e8e126..098bb8f690c9 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1762,17 +1762,17 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
1762 loff_t pos; 1762 loff_t pos;
1763 size_t count; 1763 size_t count;
1764 1764
1765 mutex_lock(&inode->i_mutex); 1765 inode_lock(inode);
1766 err = generic_write_checks(iocb, from); 1766 err = generic_write_checks(iocb, from);
1767 if (err <= 0) { 1767 if (err <= 0) {
1768 mutex_unlock(&inode->i_mutex); 1768 inode_unlock(inode);
1769 return err; 1769 return err;
1770 } 1770 }
1771 1771
1772 current->backing_dev_info = inode_to_bdi(inode); 1772 current->backing_dev_info = inode_to_bdi(inode);
1773 err = file_remove_privs(file); 1773 err = file_remove_privs(file);
1774 if (err) { 1774 if (err) {
1775 mutex_unlock(&inode->i_mutex); 1775 inode_unlock(inode);
1776 goto out; 1776 goto out;
1777 } 1777 }
1778 1778
@@ -1783,7 +1783,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
1783 * to stop this write operation to ensure FS consistency. 1783 * to stop this write operation to ensure FS consistency.
1784 */ 1784 */
1785 if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) { 1785 if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) {
1786 mutex_unlock(&inode->i_mutex); 1786 inode_unlock(inode);
1787 err = -EROFS; 1787 err = -EROFS;
1788 goto out; 1788 goto out;
1789 } 1789 }
@@ -1804,7 +1804,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
1804 end_pos = round_up(pos + count, root->sectorsize); 1804 end_pos = round_up(pos + count, root->sectorsize);
1805 err = btrfs_cont_expand(inode, i_size_read(inode), end_pos); 1805 err = btrfs_cont_expand(inode, i_size_read(inode), end_pos);
1806 if (err) { 1806 if (err) {
1807 mutex_unlock(&inode->i_mutex); 1807 inode_unlock(inode);
1808 goto out; 1808 goto out;
1809 } 1809 }
1810 } 1810 }
@@ -1820,7 +1820,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
1820 iocb->ki_pos = pos + num_written; 1820 iocb->ki_pos = pos + num_written;
1821 } 1821 }
1822 1822
1823 mutex_unlock(&inode->i_mutex); 1823 inode_unlock(inode);
1824 1824
1825 /* 1825 /*
1826 * We also have to set last_sub_trans to the current log transid, 1826 * We also have to set last_sub_trans to the current log transid,
@@ -1909,7 +1909,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
1909 if (ret) 1909 if (ret)
1910 return ret; 1910 return ret;
1911 1911
1912 mutex_lock(&inode->i_mutex); 1912 inode_lock(inode);
1913 atomic_inc(&root->log_batch); 1913 atomic_inc(&root->log_batch);
1914 full_sync = test_bit(BTRFS_INODE_NEEDS_FULL_SYNC, 1914 full_sync = test_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
1915 &BTRFS_I(inode)->runtime_flags); 1915 &BTRFS_I(inode)->runtime_flags);
@@ -1961,7 +1961,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
1961 ret = start_ordered_ops(inode, start, end); 1961 ret = start_ordered_ops(inode, start, end);
1962 } 1962 }
1963 if (ret) { 1963 if (ret) {
1964 mutex_unlock(&inode->i_mutex); 1964 inode_unlock(inode);
1965 goto out; 1965 goto out;
1966 } 1966 }
1967 atomic_inc(&root->log_batch); 1967 atomic_inc(&root->log_batch);
@@ -2007,7 +2007,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
2007 */ 2007 */
2008 clear_bit(BTRFS_INODE_NEEDS_FULL_SYNC, 2008 clear_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
2009 &BTRFS_I(inode)->runtime_flags); 2009 &BTRFS_I(inode)->runtime_flags);
2010 mutex_unlock(&inode->i_mutex); 2010 inode_unlock(inode);
2011 goto out; 2011 goto out;
2012 } 2012 }
2013 2013
@@ -2031,7 +2031,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
2031 trans = btrfs_start_transaction(root, 0); 2031 trans = btrfs_start_transaction(root, 0);
2032 if (IS_ERR(trans)) { 2032 if (IS_ERR(trans)) {
2033 ret = PTR_ERR(trans); 2033 ret = PTR_ERR(trans);
2034 mutex_unlock(&inode->i_mutex); 2034 inode_unlock(inode);
2035 goto out; 2035 goto out;
2036 } 2036 }
2037 trans->sync = true; 2037 trans->sync = true;
@@ -2054,7 +2054,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
2054 * file again, but that will end up using the synchronization 2054 * file again, but that will end up using the synchronization
2055 * inside btrfs_sync_log to keep things safe. 2055 * inside btrfs_sync_log to keep things safe.
2056 */ 2056 */
2057 mutex_unlock(&inode->i_mutex); 2057 inode_unlock(inode);
2058 2058
2059 /* 2059 /*
2060 * If any of the ordered extents had an error, just return it to user 2060 * If any of the ordered extents had an error, just return it to user
@@ -2303,7 +2303,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
2303 if (ret) 2303 if (ret)
2304 return ret; 2304 return ret;
2305 2305
2306 mutex_lock(&inode->i_mutex); 2306 inode_lock(inode);
2307 ino_size = round_up(inode->i_size, PAGE_CACHE_SIZE); 2307 ino_size = round_up(inode->i_size, PAGE_CACHE_SIZE);
2308 ret = find_first_non_hole(inode, &offset, &len); 2308 ret = find_first_non_hole(inode, &offset, &len);
2309 if (ret < 0) 2309 if (ret < 0)
@@ -2343,7 +2343,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
2343 truncated_page = true; 2343 truncated_page = true;
2344 ret = btrfs_truncate_page(inode, offset, 0, 0); 2344 ret = btrfs_truncate_page(inode, offset, 0, 0);
2345 if (ret) { 2345 if (ret) {
2346 mutex_unlock(&inode->i_mutex); 2346 inode_unlock(inode);
2347 return ret; 2347 return ret;
2348 } 2348 }
2349 } 2349 }
@@ -2419,7 +2419,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
2419 ret = btrfs_wait_ordered_range(inode, lockstart, 2419 ret = btrfs_wait_ordered_range(inode, lockstart,
2420 lockend - lockstart + 1); 2420 lockend - lockstart + 1);
2421 if (ret) { 2421 if (ret) {
2422 mutex_unlock(&inode->i_mutex); 2422 inode_unlock(inode);
2423 return ret; 2423 return ret;
2424 } 2424 }
2425 } 2425 }
@@ -2574,7 +2574,7 @@ out_only_mutex:
2574 ret = btrfs_end_transaction(trans, root); 2574 ret = btrfs_end_transaction(trans, root);
2575 } 2575 }
2576 } 2576 }
2577 mutex_unlock(&inode->i_mutex); 2577 inode_unlock(inode);
2578 if (ret && !err) 2578 if (ret && !err)
2579 err = ret; 2579 err = ret;
2580 return err; 2580 return err;
@@ -2658,7 +2658,7 @@ static long btrfs_fallocate(struct file *file, int mode,
2658 if (ret < 0) 2658 if (ret < 0)
2659 return ret; 2659 return ret;
2660 2660
2661 mutex_lock(&inode->i_mutex); 2661 inode_lock(inode);
2662 ret = inode_newsize_ok(inode, alloc_end); 2662 ret = inode_newsize_ok(inode, alloc_end);
2663 if (ret) 2663 if (ret)
2664 goto out; 2664 goto out;
@@ -2816,7 +2816,7 @@ out:
2816 * So this is completely used as cleanup. 2816 * So this is completely used as cleanup.
2817 */ 2817 */
2818 btrfs_qgroup_free_data(inode, alloc_start, alloc_end - alloc_start); 2818 btrfs_qgroup_free_data(inode, alloc_start, alloc_end - alloc_start);
2819 mutex_unlock(&inode->i_mutex); 2819 inode_unlock(inode);
2820 /* Let go of our reservation. */ 2820 /* Let go of our reservation. */
2821 btrfs_free_reserved_data_space(inode, alloc_start, 2821 btrfs_free_reserved_data_space(inode, alloc_start,
2822 alloc_end - alloc_start); 2822 alloc_end - alloc_start);
@@ -2892,7 +2892,7 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence)
2892 struct inode *inode = file->f_mapping->host; 2892 struct inode *inode = file->f_mapping->host;
2893 int ret; 2893 int ret;
2894 2894
2895 mutex_lock(&inode->i_mutex); 2895 inode_lock(inode);
2896 switch (whence) { 2896 switch (whence) {
2897 case SEEK_END: 2897 case SEEK_END:
2898 case SEEK_CUR: 2898 case SEEK_CUR:
@@ -2901,20 +2901,20 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence)
2901 case SEEK_DATA: 2901 case SEEK_DATA:
2902 case SEEK_HOLE: 2902 case SEEK_HOLE:
2903 if (offset >= i_size_read(inode)) { 2903 if (offset >= i_size_read(inode)) {
2904 mutex_unlock(&inode->i_mutex); 2904 inode_unlock(inode);
2905 return -ENXIO; 2905 return -ENXIO;
2906 } 2906 }
2907 2907
2908 ret = find_desired_extent(inode, &offset, whence); 2908 ret = find_desired_extent(inode, &offset, whence);
2909 if (ret) { 2909 if (ret) {
2910 mutex_unlock(&inode->i_mutex); 2910 inode_unlock(inode);
2911 return ret; 2911 return ret;
2912 } 2912 }
2913 } 2913 }
2914 2914
2915 offset = vfs_setpos(file, offset, inode->i_sb->s_maxbytes); 2915 offset = vfs_setpos(file, offset, inode->i_sb->s_maxbytes);
2916out: 2916out:
2917 mutex_unlock(&inode->i_mutex); 2917 inode_unlock(inode);
2918 return offset; 2918 return offset;
2919} 2919}
2920 2920