diff mbox

[v2] ext3: Update ctime in ext3_splice_branch() only when needed

Message ID 4F322585.3010407@sx.jp.nec.com
State Accepted, archived
Headers show

Commit Message

Kazuya Mio Feb. 8, 2012, 7:34 a.m. UTC
Currently ext3 updates ctime in ext3_splice_branch() which is called whenever
we allocate one block. But it is wasteful because ext3 doesn't support
nanosecond timestamp. This leads to a performance loss.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
---
 fs/ext3/inode.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
--
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

Comments

Jan Kara Feb. 8, 2012, 9:33 a.m. UTC | #1
On Wed 08-02-12 16:34:29, Kazuya Mio wrote:
> Currently ext3 updates ctime in ext3_splice_branch() which is called whenever
> we allocate one block. But it is wasteful because ext3 doesn't support
> nanosecond timestamp. This leads to a performance loss.
> 
> Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
  Thanks. The patch looks good. I've added it to my tree.

								Honza

> ---
>  fs/ext3/inode.c |    9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
> index 2d0afec..3c7fd63 100644
> --- a/fs/ext3/inode.c
> +++ b/fs/ext3/inode.c
> @@ -756,6 +756,7 @@ static int ext3_splice_branch(handle_t *handle, struct inode *inode,
>  	struct ext3_block_alloc_info *block_i;
>  	ext3_fsblk_t current_block;
>  	struct ext3_inode_info *ei = EXT3_I(inode);
> +	struct timespec now;
>  
>  	block_i = ei->i_block_alloc_info;
>  	/*
> @@ -795,9 +796,11 @@ static int ext3_splice_branch(handle_t *handle, struct inode *inode,
>  	}
>  
>  	/* We are done with atomic stuff, now do the rest of housekeeping */
> -
> -	inode->i_ctime = CURRENT_TIME_SEC;
> -	ext3_mark_inode_dirty(handle, inode);
> +	now = CURRENT_TIME_SEC;
> +	if (!timespec_equal(&inode->i_ctime, &now) || !where->bh) {
> +		inode->i_ctime = now;
> +		ext3_mark_inode_dirty(handle, inode);
> +	}
>  	/* ext3_mark_inode_dirty already updated i_sync_tid */
>  	atomic_set(&ei->i_datasync_tid, handle->h_transaction->t_tid);
>
diff mbox

Patch

diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 2d0afec..3c7fd63 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -756,6 +756,7 @@  static int ext3_splice_branch(handle_t *handle, struct inode *inode,
 	struct ext3_block_alloc_info *block_i;
 	ext3_fsblk_t current_block;
 	struct ext3_inode_info *ei = EXT3_I(inode);
+	struct timespec now;
 
 	block_i = ei->i_block_alloc_info;
 	/*
@@ -795,9 +796,11 @@  static int ext3_splice_branch(handle_t *handle, struct inode *inode,
 	}
 
 	/* We are done with atomic stuff, now do the rest of housekeeping */
-
-	inode->i_ctime = CURRENT_TIME_SEC;
-	ext3_mark_inode_dirty(handle, inode);
+	now = CURRENT_TIME_SEC;
+	if (!timespec_equal(&inode->i_ctime, &now) || !where->bh) {
+		inode->i_ctime = now;
+		ext3_mark_inode_dirty(handle, inode);
+	}
 	/* ext3_mark_inode_dirty already updated i_sync_tid */
 	atomic_set(&ei->i_datasync_tid, handle->h_transaction->t_tid);