btrfs: use filemap_check_errors()
authorMiklos Szeredi <mszeredi@redhat.com>
Fri, 16 Sep 2016 10:44:21 +0000 (12:44 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Fri, 16 Sep 2016 10:44:21 +0000 (12:44 +0200)
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Cc: Chris Mason <clm@fb.com>
fs/btrfs/ctree.h
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/tree-log.c

index 33fe035..e62fd50 100644 (file)
@@ -3161,7 +3161,6 @@ int btrfs_prealloc_file_range_trans(struct inode *inode,
                                    struct btrfs_trans_handle *trans, int mode,
                                    u64 start, u64 num_bytes, u64 min_size,
                                    loff_t actual_len, u64 *alloc_hint);
-int btrfs_inode_check_errors(struct inode *inode);
 extern const struct dentry_operations btrfs_dentry_operations;
 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
 void btrfs_test_inode_set_ops(struct inode *inode);
index fea31a4..4843cb9 100644 (file)
@@ -2040,7 +2040,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
                 * flags for any errors that might have happened while doing
                 * writeback of file data.
                 */
-               ret = btrfs_inode_check_errors(inode);
+               ret = filemap_check_errors(inode->i_mapping);
                inode_unlock(inode);
                goto out;
        }
index e6811c4..0207622 100644 (file)
@@ -10543,21 +10543,6 @@ out_inode:
 
 }
 
-/* Inspired by filemap_check_errors() */
-int btrfs_inode_check_errors(struct inode *inode)
-{
-       int ret = 0;
-
-       if (test_bit(AS_ENOSPC, &inode->i_mapping->flags) &&
-           test_and_clear_bit(AS_ENOSPC, &inode->i_mapping->flags))
-               ret = -ENOSPC;
-       if (test_bit(AS_EIO, &inode->i_mapping->flags) &&
-           test_and_clear_bit(AS_EIO, &inode->i_mapping->flags))
-               ret = -EIO;
-
-       return ret;
-}
-
 static const struct inode_operations btrfs_dir_inode_operations = {
        .getattr        = btrfs_getattr,
        .lookup         = btrfs_lookup,
index ef9c55b..8a84ebd 100644 (file)
@@ -3961,7 +3961,7 @@ static int wait_ordered_extents(struct btrfs_trans_handle *trans,
                         * i_mapping flags, so that the next fsync won't get
                         * an outdated io error too.
                         */
-                       btrfs_inode_check_errors(inode);
+                       filemap_check_errors(inode->i_mapping);
                        *ordered_io_error = true;
                        break;
                }
@@ -4198,7 +4198,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
         * without writing to the log tree and the fsync must report the
         * file data write error and not commit the current transaction.
         */
-       ret = btrfs_inode_check_errors(inode);
+       ret = filemap_check_errors(inode->i_mapping);
        if (ret)
                ctx->io_err = ret;
 process: