From: Jan Kara <jack@suse.cz>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Ext4 Developers List <linux-ext4@vger.kernel.org>,
viro@ZenIV.linux.org.uk
Subject: Re: [PATCH 4/5] ext4: factor out common code in ext4_file_write()
Date: Tue, 15 Apr 2014 19:07:10 +0200 [thread overview]
Message-ID: <20140415170710.GG10144@quack.suse.cz> (raw)
In-Reply-To: <1397322161-32148-5-git-send-email-tytso@mit.edu>
On Sat 12-04-14 13:02:40, Ted Tso wrote:
> This shouldn't change any logic flow; just delete duplicated code.
>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Looks good. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/file.c | 37 +++++++++++++------------------------
> 1 file changed, 13 insertions(+), 24 deletions(-)
>
> diff --git a/fs/ext4/file.c b/fs/ext4/file.c
> index 5e428d58..7c8f483 100644
> --- a/fs/ext4/file.c
> +++ b/fs/ext4/file.c
> @@ -98,6 +98,7 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
> struct file *file = iocb->ki_filp;
> struct inode *inode = file_inode(iocb->ki_filp);
> struct blk_plug plug;
> + int o_direct = file->f_flags & O_DIRECT;
> int overwrite = 0;
> size_t length = iov_length(iov, nr_segs);
> ssize_t ret;
> @@ -122,7 +123,7 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
> }
> }
>
> - if (unlikely(iocb->ki_filp->f_flags & O_DIRECT)) {
> + if (o_direct) {
> struct mutex *aio_mutex = NULL;
>
> /* Unaligned direct AIO must be serialized; see comment above */
> @@ -169,33 +170,21 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
> if (err == len && (map.m_flags & EXT4_MAP_MAPPED))
> overwrite = 1;
> }
> -
> - ret = __generic_file_aio_write(iocb, iov, nr_segs,
> - &iocb->ki_pos);
> - mutex_unlock(&inode->i_mutex);
> -
> - if (ret > 0) {
> - ssize_t err;
> -
> - err = generic_write_sync(file, iocb->ki_pos - ret, ret);
> - if (err < 0)
> - ret = err;
> - }
> - blk_finish_plug(&plug);
> - } else {
> + } else
> mutex_lock(&inode->i_mutex);
> - ret = __generic_file_aio_write(iocb, iov, nr_segs,
> - &iocb->ki_pos);
> - mutex_unlock(&inode->i_mutex);
>
> - if (ret > 0) {
> - ssize_t err;
> + ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos);
> + mutex_unlock(&inode->i_mutex);
>
> - err = generic_write_sync(file, iocb->ki_pos - ret, ret);
> - if (err < 0)
> - ret = err;
> - }
> + if (ret > 0) {
> + ssize_t err;
> +
> + err = generic_write_sync(file, iocb->ki_pos - ret, ret);
> + if (err < 0)
> + ret = err;
> }
> + if (o_direct)
> + blk_finish_plug(&plug);
>
> return ret;
> }
> --
> 1.9.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2014-04-15 17:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-12 17:02 [RFC PATCH 0/5] Clean up ext4_file_write() Theodore Ts'o
2014-04-12 17:02 ` [PATCH 1/5] ext4: inline generic_file_aio_write() into ext4_file_write() Theodore Ts'o
2014-04-15 17:06 ` Jan Kara
2014-04-12 17:02 ` [PATCH 2/5] ext4: move ext4_file_dio_write() " Theodore Ts'o
2014-04-15 17:06 ` Jan Kara
2014-04-12 17:02 ` [PATCH 3/5] ext4: drop aio_mutex after grabbing i_mutex in ext4_file_write() Theodore Ts'o
2014-04-15 17:06 ` Jan Kara
2014-04-12 17:02 ` [PATCH 4/5] ext4: factor out common code " Theodore Ts'o
2014-04-15 17:07 ` Jan Kara [this message]
2014-04-12 17:02 ` [PATCH 5/5] ext4: add locking for O_APPEND writes Theodore Ts'o
2014-04-15 17:05 ` Jan Kara
2014-04-15 19:36 ` Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140415170710.GG10144@quack.suse.cz \
--to=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).