linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Chengguang Xu <cgxu519@mykernel.net>
Cc: jack@suse.com, linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext2: discard block reservation on last writable file release
Date: Mon, 4 Jan 2021 15:01:51 +0100	[thread overview]
Message-ID: <20210104140151.GD4018@quack2.suse.cz> (raw)
In-Reply-To: <20210102101805.355106-1-cgxu519@mykernel.net>

On Sat 02-01-21 18:18:05, Chengguang Xu wrote:
> Currently reserved blocks are discarded on every writable
> file release, it's not efficient for multiple writer case.
> 
> Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>

Thanks for the patch. I agree that in principle something like this is
desirable but there's a small catch. i_writecount is also elevated from
vfs_truncate() which does not have inode open. So it can happen that
->release() gets called, sees inode->i_writecount > 1, but never gets
called again (and thus reservation is not properly released). So I prefer
to leave ext2 as is until this gets resolved - especially since ext2 fs
driver isn't really used on any performance sensitive multi-writer
workloads AFAIK (ext4 driver is usually used in such cases).

								Honza

> ---
>  fs/ext2/file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ext2/file.c b/fs/ext2/file.c
> index 96044f5dbc0e..9a19d8fe7ffd 100644
> --- a/fs/ext2/file.c
> +++ b/fs/ext2/file.c
> @@ -141,7 +141,7 @@ static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma)
>   */
>  static int ext2_release_file (struct inode * inode, struct file * filp)
>  {
> -	if (filp->f_mode & FMODE_WRITE) {
> +	if (filp->f_mode & FMODE_WRITE && (atomic_read(&inode->i_writecount) == 1)) {
>  		mutex_lock(&EXT2_I(inode)->truncate_mutex);
>  		ext2_discard_reservation(inode);
>  		mutex_unlock(&EXT2_I(inode)->truncate_mutex);
> -- 
> 2.18.4
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

      reply	other threads:[~2021-01-04 14:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-02 10:18 [PATCH] ext2: discard block reservation on last writable file release Chengguang Xu
2021-01-04 14:01 ` Jan Kara [this message]

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=20210104140151.GD4018@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=cgxu519@mykernel.net \
    --cc=jack@suse.com \
    --cc=linux-ext4@vger.kernel.org \
    /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).