Patchwork [2/7] ext4: fold ext4_generic_write_end() into ext4_write_end()

login
register
mail settings
Submitter Theodore Ts'o
Date March 25, 2013, 12:06 a.m.
Message ID <1364170014-10295-3-git-send-email-tytso@mit.edu>
Download mbox | patch
Permalink /patch/230535/
State Accepted
Headers show

Comments

Theodore Ts'o - March 25, 2013, 12:06 a.m.
From: Zheng Liu <wenqing.lz@taobao.com>

After collpasing the handling of data ordered and data writeback
codepath, ext4_generic_write_end() has only one caller,
ext4_write_end().  So we fold it into ext4_write_end().

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 fs/ext4/inode.c | 67 +++++++++++++++++++++++----------------------------------
 1 file changed, 27 insertions(+), 40 deletions(-)
Lukas Czerner - March 27, 2013, 12:58 p.m.
On Sun, 24 Mar 2013, Theodore Ts'o wrote:

> Date: Sun, 24 Mar 2013 20:06:49 -0400
> From: Theodore Ts'o <tytso@mit.edu>
> To: Ext4 Developers List <linux-ext4@vger.kernel.org>
> Cc: Zheng Liu <wenqing.lz@taobao.com>, Theodore Ts'o <tytso@mit.edu>
> Subject: [PATCH 2/7] ext4: fold ext4_generic_write_end() into ext4_write_end()
> 
> From: Zheng Liu <wenqing.lz@taobao.com>
> 
> After collpasing the handling of data ordered and data writeback
> codepath, ext4_generic_write_end() has only one caller,
> ext4_write_end().  So we fold it into ext4_write_end().

Looks good.

Reviewed-by: Lukas Czerner <lczerner@redhat.com>

Thanks!
-Lukas

> 
> Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> ---
>  fs/ext4/inode.c | 67 +++++++++++++++++++++++----------------------------------
>  1 file changed, 27 insertions(+), 40 deletions(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 4ee6927..a4ffb47 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -1087,14 +1087,32 @@ static int write_end_fn(handle_t *handle, struct buffer_head *bh)
>  	return ext4_handle_dirty_metadata(handle, NULL, bh);
>  }
>  
> -static int ext4_generic_write_end(struct file *file,
> -				  struct address_space *mapping,
> -				  loff_t pos, unsigned len, unsigned copied,
> -				  struct page *page, void *fsdata)
> +/*
> + * We need to pick up the new inode size which generic_commit_write gave us
> + * `file' can be NULL - eg, when called from page_symlink().
> + *
> + * ext4 never places buffers on inode->i_mapping->private_list.  metadata
> + * buffers are managed internally.
> + */
> +static int ext4_write_end(struct file *file,
> +			  struct address_space *mapping,
> +			  loff_t pos, unsigned len, unsigned copied,
> +			  struct page *page, void *fsdata)
>  {
> -	int i_size_changed = 0;
> -	struct inode *inode = mapping->host;
>  	handle_t *handle = ext4_journal_current_handle();
> +	struct inode *inode = mapping->host;
> +	int ret = 0, ret2;
> +	int i_size_changed = 0;
> +
> +	trace_ext4_write_end(inode, pos, len, copied);
> +	if (ext4_test_inode_state(inode, EXT4_STATE_ORDERED_MODE)) {
> +		ret = ext4_jbd2_file_inode(handle, inode);
> +		if (ret) {
> +			unlock_page(page);
> +			page_cache_release(page);
> +			goto errout;
> +		}
> +	}
>  
>  	if (ext4_has_inline_data(inode))
>  		copied = ext4_write_inline_data_end(inode, pos, len,
> @@ -1105,7 +1123,7 @@ static int ext4_generic_write_end(struct file *file,
>  
>  	/*
>  	 * No need to use i_size_read() here, the i_size
> -	 * cannot change under us because we hold i_mutex.
> +	 * cannot change under us because we hole i_mutex.
>  	 *
>  	 * But it's important to update i_size while still holding page lock:
>  	 * page writeout could otherwise come in and zero beyond i_size.
> @@ -1115,10 +1133,10 @@ static int ext4_generic_write_end(struct file *file,
>  		i_size_changed = 1;
>  	}
>  
> -	if (pos + copied >  EXT4_I(inode)->i_disksize) {
> +	if (pos + copied > EXT4_I(inode)->i_disksize) {
>  		/* We need to mark inode dirty even if
>  		 * new_i_size is less that inode->i_size
> -		 * bu greater than i_disksize.(hint delalloc)
> +		 * but greater than i_disksize. (hint delalloc)
>  		 */
>  		ext4_update_i_disksize(inode, (pos + copied));
>  		i_size_changed = 1;
> @@ -1135,37 +1153,6 @@ static int ext4_generic_write_end(struct file *file,
>  	if (i_size_changed)
>  		ext4_mark_inode_dirty(handle, inode);
>  
> -	return copied;
> -}
> -
> -/*
> - * We need to pick up the new inode size which generic_commit_write gave us
> - * `file' can be NULL - eg, when called from page_symlink().
> - *
> - * ext4 never places buffers on inode->i_mapping->private_list.  metadata
> - * buffers are managed internally.
> - */
> -static int ext4_write_end(struct file *file,
> -			  struct address_space *mapping,
> -			  loff_t pos, unsigned len, unsigned copied,
> -			  struct page *page, void *fsdata)
> -{
> -	handle_t *handle = ext4_journal_current_handle();
> -	struct inode *inode = mapping->host;
> -	int ret = 0, ret2;
> -
> -	trace_ext4_write_end(inode, pos, len, copied);
> -	if (ext4_test_inode_state(inode, EXT4_STATE_ORDERED_MODE)) {
> -		ret = ext4_jbd2_file_inode(handle, inode);
> -		if (ret) {
> -			unlock_page(page);
> -			page_cache_release(page);
> -			goto errout;
> -		}
> -	}
> -
> -	copied = ext4_generic_write_end(file, mapping, pos, len, copied,
> -					page, fsdata);
>  	if (copied < 0)
>  		ret = copied;
>  	if (pos + len > inode->i_size && ext4_can_truncate(inode))
> 
--
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 - March 27, 2013, 3:35 p.m.
On Sun 24-03-13 20:06:49, Ted Tso wrote:
> From: Zheng Liu <wenqing.lz@taobao.com>
> 
> After collpasing the handling of data ordered and data writeback
> codepath, ext4_generic_write_end() has only one caller,
> ext4_write_end().  So we fold it into ext4_write_end().
> 
> Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> ---
>  fs/ext4/inode.c | 67 +++++++++++++++++++++++----------------------------------
>  1 file changed, 27 insertions(+), 40 deletions(-)
> 
...
> @@ -1105,7 +1123,7 @@ static int ext4_generic_write_end(struct file *file,
>  
>  	/*
>  	 * No need to use i_size_read() here, the i_size
> -	 * cannot change under us because we hold i_mutex.
> +	 * cannot change under us because we hole i_mutex.
  Typo added here. Otherwise the patch is fine. You can add
Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

Patch

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 4ee6927..a4ffb47 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1087,14 +1087,32 @@  static int write_end_fn(handle_t *handle, struct buffer_head *bh)
 	return ext4_handle_dirty_metadata(handle, NULL, bh);
 }
 
-static int ext4_generic_write_end(struct file *file,
-				  struct address_space *mapping,
-				  loff_t pos, unsigned len, unsigned copied,
-				  struct page *page, void *fsdata)
+/*
+ * We need to pick up the new inode size which generic_commit_write gave us
+ * `file' can be NULL - eg, when called from page_symlink().
+ *
+ * ext4 never places buffers on inode->i_mapping->private_list.  metadata
+ * buffers are managed internally.
+ */
+static int ext4_write_end(struct file *file,
+			  struct address_space *mapping,
+			  loff_t pos, unsigned len, unsigned copied,
+			  struct page *page, void *fsdata)
 {
-	int i_size_changed = 0;
-	struct inode *inode = mapping->host;
 	handle_t *handle = ext4_journal_current_handle();
+	struct inode *inode = mapping->host;
+	int ret = 0, ret2;
+	int i_size_changed = 0;
+
+	trace_ext4_write_end(inode, pos, len, copied);
+	if (ext4_test_inode_state(inode, EXT4_STATE_ORDERED_MODE)) {
+		ret = ext4_jbd2_file_inode(handle, inode);
+		if (ret) {
+			unlock_page(page);
+			page_cache_release(page);
+			goto errout;
+		}
+	}
 
 	if (ext4_has_inline_data(inode))
 		copied = ext4_write_inline_data_end(inode, pos, len,
@@ -1105,7 +1123,7 @@  static int ext4_generic_write_end(struct file *file,
 
 	/*
 	 * No need to use i_size_read() here, the i_size
-	 * cannot change under us because we hold i_mutex.
+	 * cannot change under us because we hole i_mutex.
 	 *
 	 * But it's important to update i_size while still holding page lock:
 	 * page writeout could otherwise come in and zero beyond i_size.
@@ -1115,10 +1133,10 @@  static int ext4_generic_write_end(struct file *file,
 		i_size_changed = 1;
 	}
 
-	if (pos + copied >  EXT4_I(inode)->i_disksize) {
+	if (pos + copied > EXT4_I(inode)->i_disksize) {
 		/* We need to mark inode dirty even if
 		 * new_i_size is less that inode->i_size
-		 * bu greater than i_disksize.(hint delalloc)
+		 * but greater than i_disksize. (hint delalloc)
 		 */
 		ext4_update_i_disksize(inode, (pos + copied));
 		i_size_changed = 1;
@@ -1135,37 +1153,6 @@  static int ext4_generic_write_end(struct file *file,
 	if (i_size_changed)
 		ext4_mark_inode_dirty(handle, inode);
 
-	return copied;
-}
-
-/*
- * We need to pick up the new inode size which generic_commit_write gave us
- * `file' can be NULL - eg, when called from page_symlink().
- *
- * ext4 never places buffers on inode->i_mapping->private_list.  metadata
- * buffers are managed internally.
- */
-static int ext4_write_end(struct file *file,
-			  struct address_space *mapping,
-			  loff_t pos, unsigned len, unsigned copied,
-			  struct page *page, void *fsdata)
-{
-	handle_t *handle = ext4_journal_current_handle();
-	struct inode *inode = mapping->host;
-	int ret = 0, ret2;
-
-	trace_ext4_write_end(inode, pos, len, copied);
-	if (ext4_test_inode_state(inode, EXT4_STATE_ORDERED_MODE)) {
-		ret = ext4_jbd2_file_inode(handle, inode);
-		if (ret) {
-			unlock_page(page);
-			page_cache_release(page);
-			goto errout;
-		}
-	}
-
-	copied = ext4_generic_write_end(file, mapping, pos, len, copied,
-					page, fsdata);
 	if (copied < 0)
 		ret = copied;
 	if (pos + len > inode->i_size && ext4_can_truncate(inode))