|
@@ -524,6 +524,9 @@ 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)))
|
|
|
+ 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))
|
|
@@ -566,6 +569,7 @@ static int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
|
|
|
{
|
|
|
unsigned int maxblocks = map->m_len;
|
|
|
struct dnode_of_data dn;
|
|
|
+ struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
|
|
int mode = create ? ALLOC_NODE : LOOKUP_NODE_RA;
|
|
|
pgoff_t pgofs, end_offset;
|
|
|
int err = 0, ofs = 1;
|
|
@@ -599,6 +603,10 @@ static int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
|
|
|
|
|
|
if (dn.data_blkaddr == NEW_ADDR || dn.data_blkaddr == NULL_ADDR) {
|
|
|
if (create) {
|
|
|
+ if (unlikely(f2fs_cp_error(sbi))) {
|
|
|
+ err = -EIO;
|
|
|
+ goto put_out;
|
|
|
+ }
|
|
|
err = __allocate_data_block(&dn);
|
|
|
if (err)
|
|
|
goto put_out;
|
|
@@ -652,6 +660,10 @@ get_next:
|
|
|
|
|
|
if (blkaddr == NEW_ADDR || blkaddr == NULL_ADDR) {
|
|
|
if (create) {
|
|
|
+ if (unlikely(f2fs_cp_error(sbi))) {
|
|
|
+ err = -EIO;
|
|
|
+ goto sync_out;
|
|
|
+ }
|
|
|
err = __allocate_data_block(&dn);
|
|
|
if (err)
|
|
|
goto sync_out;
|
|
@@ -1556,10 +1568,16 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
|
|
|
|
|
|
trace_f2fs_direct_IO_enter(inode, offset, count, iov_iter_rw(iter));
|
|
|
|
|
|
- if (iov_iter_rw(iter) == WRITE)
|
|
|
+ if (iov_iter_rw(iter) == WRITE) {
|
|
|
__allocate_data_blocks(inode, offset, count);
|
|
|
+ if (unlikely(f2fs_cp_error(F2FS_I_SB(inode)))) {
|
|
|
+ err = -EIO;
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
err = blockdev_direct_IO(iocb, inode, iter, offset, get_data_block_dio);
|
|
|
+out:
|
|
|
if (err < 0 && iov_iter_rw(iter) == WRITE)
|
|
|
f2fs_write_failed(mapping, offset + count);
|
|
|
|