/* The caller must either have a ref on the inode or must have set I_WILL_FREE.  */
int write_inode_now(struct inode *inode, int sync)
/* The caller must either have a ref on the inode or must have set I_WILL_FREE.  */
int write_inode_now(struct inode *inode, int sync)
{
	int ret;
	struct writeback_control wbc = {
		.nr_to_write = LONG_MAX,
		.sync_mode = sync ? WB_SYNC_ALL : WB_SYNC_NONE,
		.range_start = 0,
		.range_end = LLONG_MAX,
	};
	if (!mapping_cap_writeback_dirty(inode->i_mapping))
		wbc.nr_to_write = 0;
	might_sleep();
	spin_lock(&inode_lock);
	ret = writeback_single_inode(inode, &wbc);
	spin_unlock(&inode_lock);
	if (sync)
		inode_sync_wait(inode);
	return ret;
}