aboutsummaryrefslogtreecommitdiff
path: root/fs/f2fs/data.c
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2015-12-24 18:04:56 +0800
committerMister Oyster <oysterized@gmail.com>2017-04-13 12:32:41 +0200
commite7c0e6c0298a78e7639d63ea5d18d69d3cdc41a2 (patch)
treed7ccc711b20f7ac9effdd239475488ad6789ac9a /fs/f2fs/data.c
parent8e7fca22123eb9b6378fed00387ee90b4add0b86 (diff)
downloadandroid_kernel_m2note-e7c0e6c0298a78e7639d63ea5d18d69d3cdc41a2.tar.gz
f2fs: let user being aware of IO error
Sometimes we keep dumb when IO error occur in lower layer device, so user will not receive any error return value for some operation, but actually, the operation did not succeed. This sould be avoided, so this patch reports such kind of error to user. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Conflicts: fs/f2fs/data.c
Diffstat (limited to 'fs/f2fs/data.c')
-rw-r--r--fs/f2fs/data.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 03b754d1c..47471de21 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -499,7 +499,7 @@ alloc:
return 0;
}
-static void __allocate_data_blocks(struct inode *inode, loff_t offset,
+static int __allocate_data_blocks(struct inode *inode, loff_t offset,
size_t count)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
@@ -508,13 +508,15 @@ static void __allocate_data_blocks(struct inode *inode, loff_t offset,
u64 len = F2FS_BYTES_TO_BLK(count);
bool allocated;
u64 end_offset;
+ int err = 0;
while (len) {
f2fs_lock_op(sbi);
/* When reading holes, we need its node page */
set_new_dnode(&dn, inode, NULL, NULL, 0);
- if (get_dnode_of_data(&dn, start, ALLOC_NODE))
+ err = get_dnode_of_data(&dn, start, ALLOC_NODE);
+ if (err)
goto out;
allocated = false;
@@ -523,12 +525,15 @@ static void __allocate_data_blocks(struct inode *inode, loff_t offset,
while (dn.ofs_in_node < end_offset && len) {
block_t blkaddr;
- if (unlikely(f2fs_cp_error(sbi)))
+ if (unlikely(f2fs_cp_error(sbi))) {
+ err = -EIO;
goto sync_out;
+ }
blkaddr = datablock_addr(dn.node_page, dn.ofs_in_node);
if (blkaddr == NULL_ADDR || blkaddr == NEW_ADDR) {
- if (__allocate_data_block(&dn))
+ err = __allocate_data_block(&dn);
+ if (err)
goto sync_out;
allocated = true;
}
@@ -546,7 +551,7 @@ static void __allocate_data_blocks(struct inode *inode, loff_t offset,
if (dn.node_changed)
f2fs_balance_fs(sbi);
}
- return;
+ return err;
sync_out:
if (allocated)
@@ -556,7 +561,7 @@ out:
f2fs_unlock_op(sbi);
if (dn.node_changed)
f2fs_balance_fs(sbi);
- return;
+ return err;
}
/*
@@ -1681,11 +1686,9 @@ static ssize_t f2fs_direct_IO(int rw, struct kiocb *iocb,
trace_f2fs_direct_IO_enter(inode, offset, count, rw);
if (rw & WRITE) {
- __allocate_data_blocks(inode, offset, count);
- if (unlikely(f2fs_cp_error(F2FS_I_SB(inode)))) {
- err = -EIO;
+ err = __allocate_data_blocks(inode, offset, count);
+ if (err)
goto out;
- }
}
err = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,