Re: ext4: call blkdev_issue_flush on fsync

From: Theodore Tso
Date: Sun Feb 15 2009 - 21:57:13 EST


On Thu, Feb 12, 2009 at 07:40:45PM +0900, Fernando Luis Vázquez Cao wrote:
> @@ -76,25 +77,34 @@ int ext4_sync_file(struct file *file, st
> */
> if (ext4_should_journal_data(inode)) {
> ret = ext4_force_commit(inode->i_sb);
> + if (!(journal->j_flags & JBD2_BARRIER))
> + goto no_journal_barrier;
> goto out;
> }

All of these goto statements makes it one gigantic pile of spaghetti.
The code will be much more understable if you do:

if (!(journal->j_flags & JBD2_BARRIER))
block_flush_device(inode->i_sb);
return ret;

>
> - if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
> - goto out;
> + if (datasync && !(i_state & I_DIRTY_DATASYNC))
> + goto flush_blkdev;
>

Maybe instead:
if (datasync && !(i_state & I_DIRTY_DATASYNC)) {
if (i_state & I_DIRTY_PAGES)
block_flush_device(inode->i_sb);
return ret;
}


> - if (journal && (journal->j_flags & JBD2_BARRIER))
> - blkdev_issue_flush(inode->i_sb->s_bdev, NULL);
> + if (journal && !(journal->j_flags & JBD2_BARRIER))
> + goto no_journal_barrier;
> + goto out;

Maybe instead:
if (journal && !(journal->j_flags & JBD2_BARRIER))
block_flush_device(inode->i_sb);
return ret;
}

I'm not a fanatic about eliminating all goto's, but "goto out" which
could be replaced by "return ret;" is just silly.

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/