All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Ext4 Developers List <linux-ext4@vger.kernel.org>, stable@kernel.org
Subject: Re: [PATCH 2/3] ext4: use ext4_write_inode() when fsyncing w/o a journal
Date: Wed, 23 Jan 2019 12:34:55 +0100	[thread overview]
Message-ID: <20190123113455.GA20927@quack2.suse.cz> (raw)
In-Reply-To: <20181231194836.3761-2-tytso@mit.edu>

On Mon 31-12-18 14:48:35, Theodore Ts'o wrote:
> In no-journal mode, we previously used __generic_file_fsync() in
> no-journal mode.  This triggers a lockdep warning, and in addition,
> it's not safe to depend on the inode writeback mechanism in the case
> ext4.  We can solve both problems by calling ext4_write_inode()
> directly.
> 
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
> Cc: stable@kernel.org
> ---
>  fs/ext4/fsync.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
> index 26a7fe5c4fd3..87a7ff00ef62 100644
> --- a/fs/ext4/fsync.c
> +++ b/fs/ext4/fsync.c
> @@ -116,8 +116,16 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
>  		goto out;
>  	}
>  
> +	ret = file_write_and_wait_range(file, start, end);
> +	if (ret)
> +		return ret;
> +
>  	if (!journal) {
> -		ret = __generic_file_fsync(file, start, end, datasync);
> +		struct writeback_control wbc = {
> +			.sync_mode = WB_SYNC_ALL
> +		};
> +
> +		ret = ext4_write_inode(inode, &wbc);

Going through some older email... How come this is safe Ted?
ext4_write_inode() will not write out metadata buffers associated with the
inode (unlike __generic_file_fsync() which calls sync_mapping_buffers()).
So you probably need to call sync_mapping_buffers() before calling
ext4_write_inode() here?

								Honza

> @@ -125,9 +133,6 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
>  		goto out;
>  	}
>  
> -	ret = file_write_and_wait_range(file, start, end);
> -	if (ret)
> -		return ret;
>  	/*
>  	 * data=writeback,ordered:
>  	 *  The caller's filemap_fdatawrite()/wait will sync the data.
> -- 
> 2.19.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2019-01-23 11:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-31 19:48 [PATCH 1/3] ext4: avoid kernel warning when writing the superblock to a dead device Theodore Ts'o
2018-12-31 19:48 ` [PATCH 2/3] ext4: use ext4_write_inode() when fsyncing w/o a journal Theodore Ts'o
2019-01-23 11:34   ` Jan Kara [this message]
2018-12-31 19:48 ` [PATCH 3/3] ext4: track writeback errors using the generic tracking infrastructure Theodore Ts'o
2019-01-02 14:27 ` [PATCH 1/3] ext4: avoid kernel warning when writing the superblock to a dead device Sasha Levin

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=20190123113455.GA20927@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=stable@kernel.org \
    --cc=tytso@mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.