Re: ext4: call blkdev_issue_flush on fsync

From: Fernando Luis Vázquez Cao
Date: Mon Feb 16 2009 - 02:09:55 EST


On Sun, 2009-02-15 at 17:46 -0500, Theodore Tso wrote:
> 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.

Yes, you are right. I just wanted to follow the current style of the
code, but I got carried away and took things a bit too far.

I'll be replying to this email with a new iteration of the patch-set
that leaves out the potentially conflictive bits and should be more
readable.

Regards,

Fernando

--
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/