u64 end_offset;
while (len) {
- f2fs_balance_fs(sbi);
f2fs_lock_op(sbi);
/* When reading holes, we need its node page */
f2fs_put_dnode(&dn);
f2fs_unlock_op(sbi);
+
+ if (dn.node_changed)
+ f2fs_balance_fs(sbi);
}
return;
f2fs_put_dnode(&dn);
out:
f2fs_unlock_op(sbi);
+ if (dn.node_changed)
+ f2fs_balance_fs(sbi);
return;
}
if (create) {
f2fs_unlock_op(sbi);
+ if (dn.node_changed)
+ f2fs_balance_fs(sbi);
f2fs_lock_op(sbi);
}
put_out:
f2fs_put_dnode(&dn);
unlock_out:
- if (create)
+ if (create) {
f2fs_unlock_op(sbi);
+ if (dn.node_changed)
+ f2fs_balance_fs(sbi);
+ }
out:
trace_f2fs_map_blocks(inode, map, err);
return err;
trace_f2fs_write_begin(inode, pos, len, flags);
- f2fs_balance_fs(sbi);
-
/*
* We should check this at this moment to avoid deadlock on inode page
* and #0 page. The locking rule for inline_data conversion should be:
f2fs_put_dnode(&dn);
f2fs_unlock_op(sbi);
+ if (dn.node_changed && has_not_enough_free_secs(sbi, 0)) {
+ unlock_page(page);
+ f2fs_balance_fs(sbi);
+ lock_page(page);
+ if (page->mapping != mapping) {
+ /* The page got truncated from under us */
+ f2fs_put_page(page, 1);
+ goto repeat;
+ }
+ }
+
f2fs_wait_on_page_writeback(page, DATA);
/* wait for GCed encrypted page writeback */
struct dnode_of_data dn;
int err;
- f2fs_balance_fs(sbi);
-
sb_start_pagefault(inode->i_sb);
f2fs_bug_on(sbi, f2fs_has_inline_data(inode));
f2fs_put_dnode(&dn);
f2fs_unlock_op(sbi);
+ if (dn.node_changed)
+ f2fs_balance_fs(sbi);
+
file_update_time(vma->vm_file);
lock_page(page);
if (unlikely(page->mapping != inode->i_mapping ||
goto out;
}
go_write:
- /* guarantee free sections for fsync */
- f2fs_balance_fs(sbi);
-
/*
* Both of fdatasync() and fsync() are able to be recovered from
* sudden-power-off.
if (need_inode_block_update(sbi, ino)) {
mark_inode_dirty_sync(inode);
f2fs_write_inode(inode, NULL);
+
+ f2fs_balance_fs(sbi);
goto sync_nodes;
}
if (offset & (F2FS_BLKSIZE - 1) || len & (F2FS_BLKSIZE - 1))
return -EINVAL;
- f2fs_balance_fs(F2FS_I_SB(inode));
-
ret = f2fs_convert_inline_inode(inode);
if (ret)
return ret;
if (ret)
return ret;
- f2fs_balance_fs(sbi);
-
ret = f2fs_convert_inline_inode(inode);
if (ret)
return ret;
if (offset & (F2FS_BLKSIZE - 1) || len & (F2FS_BLKSIZE - 1))
return -EINVAL;
- f2fs_balance_fs(sbi);
-
ret = f2fs_convert_inline_inode(inode);
if (ret)
return ret;
+ f2fs_balance_fs(sbi);
+
ret = truncate_blocks(inode, i_size_read(inode), true);
if (ret)
return ret;
loff_t off_start, off_end;
int ret = 0;
- f2fs_balance_fs(sbi);
-
ret = inode_newsize_ok(inode, (len + offset));
if (ret)
return ret;
if (ret)
return ret;
+ f2fs_balance_fs(sbi);
+
pg_start = ((unsigned long long) offset) >> PAGE_CACHE_SHIFT;
pg_end = ((unsigned long long) offset + len) >> PAGE_CACHE_SHIFT;
if (!inode_owner_or_capable(inode))
return -EACCES;
- f2fs_balance_fs(F2FS_I_SB(inode));
-
if (f2fs_is_atomic_file(inode))
return 0;
if (ret)
return ret;
- f2fs_balance_fs(F2FS_I_SB(inode));
-
clear_inode_flag(F2FS_I(inode), FI_ATOMIC_FILE);
clear_inode_flag(F2FS_I(inode), FI_VOLATILE_FILE);
commit_inmem_pages(inode, true);