Patchwork [26/29] ext4: Remove i_mutex from ext4_file_sync()

login
register
mail settings
Submitter Jan Kara
Date April 8, 2013, 9:32 p.m.
Message ID <1365456754-29373-27-git-send-email-jack@suse.cz>
Download mbox | patch
Permalink /patch/234908/
State Superseded
Headers show

Comments

Jan Kara - April 8, 2013, 9:32 p.m.
After removal of ext4_flush_unwritten_io() call, ext4_file_sync()
doesn't need i_mutex anymore. Forcing of transaction commits doesn't
need i_mutex as there's nothing inode specific in that code apart from
grabbing transaction ids from the inode. So remove the lock.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/fsync.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
Zheng Liu - May 8, 2013, 7:41 a.m.
On Mon, Apr 08, 2013 at 11:32:31PM +0200, Jan Kara wrote:
> After removal of ext4_flush_unwritten_io() call, ext4_file_sync()
> doesn't need i_mutex anymore. Forcing of transaction commits doesn't
> need i_mutex as there's nothing inode specific in that code apart from
> grabbing transaction ids from the inode. So remove the lock.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>

Due to the comment in patch 25/29, here we need to change that statement
back again.

                ret = generic_file_fsync(file, start, end, datasync);
                if (!ret && !hlist_empty(&inode->i_dentry))
                        ret = ext4_sync_parent(inode);
-               goto out_trace;
+               goto out;
        }
 
        ret = filemap_write_and_wait_range(inode->i_mapping, start, end);

Otherwise the patch looks good to me.
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>

Regards,
                                                - Zheng

> ---
>  fs/ext4/fsync.c |    6 +-----
>  1 files changed, 1 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
> index 1c08780..9040faa 100644
> --- a/fs/ext4/fsync.c
> +++ b/fs/ext4/fsync.c
> @@ -99,7 +99,7 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
>  	trace_ext4_sync_file_enter(file, datasync);
>  
>  	if (inode->i_sb->s_flags & MS_RDONLY)
> -		goto out_trace;
> +		goto out;
>  
>  	if (!journal) {
>  		ret = generic_file_fsync(file, start, end, datasync);
> @@ -111,8 +111,6 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
>  	ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
>  	if (ret)
>  		return ret;
> -	mutex_lock(&inode->i_mutex);
> -
>  	/*
>  	 * data=writeback,ordered:
>  	 *  The caller's filemap_fdatawrite()/wait will sync the data.
> @@ -144,8 +142,6 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
>  			ret = err;
>  	}
>  out:
> -	mutex_unlock(&inode->i_mutex);
> -out_trace:
>  	trace_ext4_sync_file_exit(inode, ret);
>  	return ret;
>  }
> -- 
> 1.7.1
> 
> --
> 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
--
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

Patch

diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
index 1c08780..9040faa 100644
--- a/fs/ext4/fsync.c
+++ b/fs/ext4/fsync.c
@@ -99,7 +99,7 @@  int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	trace_ext4_sync_file_enter(file, datasync);
 
 	if (inode->i_sb->s_flags & MS_RDONLY)
-		goto out_trace;
+		goto out;
 
 	if (!journal) {
 		ret = generic_file_fsync(file, start, end, datasync);
@@ -111,8 +111,6 @@  int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
 	if (ret)
 		return ret;
-	mutex_lock(&inode->i_mutex);
-
 	/*
 	 * data=writeback,ordered:
 	 *  The caller's filemap_fdatawrite()/wait will sync the data.
@@ -144,8 +142,6 @@  int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 			ret = err;
 	}
 out:
-	mutex_unlock(&inode->i_mutex);
-out_trace:
 	trace_ext4_sync_file_exit(inode, ret);
 	return ret;
 }