Skip to contentSkip to conversation

nilfs2: reduce redundant mark_inode_dirty

PATCH In review Jiro SEKIBA 2 participants 11 messages Nov 27, 2009 1 message not in the archive NILFS2 filesystem

lore
Share & tools
lore
#0 lore raw

v2 cover nilfs2: reduce redundant mark_inode_dirty

Hi,

This is a revised series of patches to reduce redandunt mark_inode_dirty calls.

Many functions call mark_inode_dirty() whenever they change inode object. However, it is redundant to call mark_inode_dirty() to same inode object within a transaction.

Last patch also replaces all mark_inode_dirty() calls as nilfs_mark_inode_dirty(), to reduce deep function call tree.

Changes since v2 is:
- deleted mark_inode_dirty(dir) in nilfs_mkdir()
- moved mark_inod_dirty(dir) from nilfs_do_unlink() to nilfs_unlink()
- correct diff stat ;-)

 fs/nilfs2/dir.c   |   24 ++++++---------
 fs/nilfs2/inode.c |    7 ++--
 fs/nilfs2/namei.c |   83 +++++++++++++++++++++++++++++++++-------------------
 3 files changed, 66 insertions(+), 48 deletions(-)

A message that is not in the archive (sent off-list or not yet received): 1259318474-28342-1-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org

#2 lore raw

PATCH v2 1/9 nilfs2: delete mark_inode_dirty in nilfs_new_inode

It is redundant to call mark_inode_dirty() in nilfs_new_inode() because all caller of nilfs_new_inode() will call mark_inode_dirty() after calling nilfs_new_inode() directly or indirectly in transaction.

---
 fs/nilfs2/inode.c |    1 -
 fs/nilfs2/namei.c |    2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)
fs/nilfs2/inode.c +0 -1
index a16c179..ede0375 100644
@@ -323,7 +323,6 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode)
 				    nilfs_init_acl(), proper cancellation of
 				    above jobs should be considered */
 
-	mark_inode_dirty(inode);
 	return inode;
 
  failed_acl:
fs/nilfs2/namei.c +1 -1
index ed02e88..01adda8 100644
@@ -188,7 +188,7 @@ static int nilfs_symlink(struct inode *dir, struct dentry *dentry,
 		goto out_fail;
 
 	/* mark_inode_dirty(inode); */
-	/* nilfs_new_inode() and page_symlink() do this */
+	/* page_symlink() do this */
 
 	err = nilfs_add_nondir(dentry, inode);
 out:
Signature · 1 line
1.5.6.5
#3 lore raw

PATCH v2 2/9 nilfs2: delete mark_inode_dirty from nilfs_set_link

In reply to a message not in the archive

Delete mark_inode_dirty() from nilfs_set_link() to reduce redundant mark_inode_dirty() calls in caller of nilfs_set_link().

---
 fs/nilfs2/dir.c   |    1 -
 fs/nilfs2/namei.c |    4 +++-
 2 files changed, 3 insertions(+), 2 deletions(-)
fs/nilfs2/dir.c +0 -1
index e097099..4f3fa00 100644
@@ -459,7 +459,6 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,
 	nilfs_put_page(page);
 	dir->i_mtime = dir->i_ctime = CURRENT_TIME;
 /*	NILFS_I(dir)->i_flags &= ~NILFS_BTREE_FL; */
-	mark_inode_dirty(dir);
 }
 
 /*
fs/nilfs2/namei.c +3 -1
index 01adda8..4616f96 100644
@@ -397,6 +397,7 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 			goto out_dir;
 		inode_inc_link_count(old_inode);
 		nilfs_set_link(new_dir, new_de, new_page, old_inode);
+		mark_inode_dirty(new_dir);
 		new_inode->i_ctime = CURRENT_TIME;
 		if (dir_de)
 			drop_nlink(new_inode);
@@ -425,12 +426,13 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	old_inode->i_ctime = CURRENT_TIME;
 
 	nilfs_delete_entry(old_de, old_page);
-	inode_dec_link_count(old_inode);
+	drop_nlink(old_inode);
 
 	if (dir_de) {
 		nilfs_set_link(old_inode, dir_de, dir_page, new_dir);
 		inode_dec_link_count(old_dir);
 	}
+	mark_inode_dirty(old_inode);
 
 	err = nilfs_transaction_commit(old_dir->i_sb);
 	return err;
Signature · 1 line
1.5.6.5
#4 lore raw

PATCH v2 3/9 nilfs2: expand inode_inc_link_count and inode_dec_link_count

In reply to a message not in the archive

This is an intermidiate patch to reduce redandunt mark_inode_dirty() calls by calling inode_inc_link_count() and inode_dec_link_count() functions.

---
 fs/nilfs2/namei.c |   49 ++++++++++++++++++++++++++++++++-----------------
 1 files changed, 32 insertions(+), 17 deletions(-)
fs/nilfs2/namei.c +32 -17
index 4616f96..f952439 100644
@@ -200,7 +200,8 @@ out:
 	return err;
 
 out_fail:
-	inode_dec_link_count(inode);
+	drop_nlink(inode);
+	mark_inode_dirty(inode);
 	iput(inode);
 	goto out;
 }
@@ -245,7 +246,8 @@ static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 	if (err)
 		return err;
 
-	inode_inc_link_count(dir);
+	inc_nlink(dir);
+	mark_inode_dirty(dir);
 
 	inode = nilfs_new_inode(dir, S_IFDIR | mode);
 	err = PTR_ERR(inode);
@@ -256,7 +258,8 @@ static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 	inode->i_fop = &nilfs_dir_operations;
 	inode->i_mapping->a_ops = &nilfs_aops;
 
-	inode_inc_link_count(inode);
+	inc_nlink(inode);
+	mark_inode_dirty(inode);
 
 	err = nilfs_make_empty(inode, dir);
 	if (err)
@@ -276,11 +279,14 @@ out:
 	return err;
 
 out_fail:
-	inode_dec_link_count(inode);
-	inode_dec_link_count(inode);
+	drop_nlink(inode);
+	mark_inode_dirty(inode);
+	drop_nlink(inode);
+	mark_inode_dirty(inode);
 	iput(inode);
 out_dir:
-	inode_dec_link_count(dir);
+	drop_nlink(dir);
+	mark_inode_dirty(dir);
 	goto out;
 }
 
@@ -317,7 +323,8 @@ static int nilfs_unlink(struct inode *dir, struct dentry *dentry)
 		goto out;
 
 	inode->i_ctime = dir->i_ctime;
-	inode_dec_link_count(inode);
+	drop_nlink(inode);
+	mark_inode_dirty(inode);
 	err = 0;
 out:
 	if (!err)
@@ -343,8 +350,10 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry)
 		err = nilfs_unlink(dir, dentry);
 		if (!err) {
 			inode->i_size = 0;
-			inode_dec_link_count(inode);
-			inode_dec_link_count(dir);
+			drop_nlink(inode);
+			mark_inode_dirty(inode);
+			drop_nlink(dir);
+			mark_inode_dirty(dir);
 		}
 	}
 	if (!err)
@@ -395,33 +404,38 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 		new_de = nilfs_find_entry(new_dir, new_dentry, &new_page);
 		if (!new_de)
 			goto out_dir;
-		inode_inc_link_count(old_inode);
+		inc_nlink(old_inode);
+		mark_inode_dirty(old_inode);
 		nilfs_set_link(new_dir, new_de, new_page, old_inode);
 		mark_inode_dirty(new_dir);
 		new_inode->i_ctime = CURRENT_TIME;
 		if (dir_de)
 			drop_nlink(new_inode);
-		inode_dec_link_count(new_inode);
+		drop_nlink(new_inode);
+		mark_inode_dirty(new_inode);
 	} else {
 		if (dir_de) {
 			err = -EMLINK;
 			if (new_dir->i_nlink >= NILFS_LINK_MAX)
 				goto out_dir;
 		}
-		inode_inc_link_count(old_inode);
+		inc_nlink(old_inode);
+		mark_inode_dirty(old_inode);
 		err = nilfs_add_link(new_dentry, old_inode);
 		if (err) {
-			inode_dec_link_count(old_inode);
+			drop_nlink(old_inode);
+			mark_inode_dirty(old_inode);
 			goto out_dir;
 		}
-		if (dir_de)
-			inode_inc_link_count(new_dir);
+		if (dir_de) {
+			inc_nlink(new_dir);
+			mark_inode_dirty(new_dir);
+		}
 	}
 
 	/*
 	 * Like most other Unix systems, set the ctime for inodes on a
 	 * rename.
-	 * inode_dec_link_count() will mark the inode dirty.
 	 */
 	old_inode->i_ctime = CURRENT_TIME;
 
@@ -430,7 +444,8 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 
 	if (dir_de) {
 		nilfs_set_link(old_inode, dir_de, dir_page, new_dir);
-		inode_dec_link_count(old_dir);
+		drop_nlink(old_dir);
+		mark_inode_dirty(old_dir);
 	}
 	mark_inode_dirty(old_inode);
 
Signature · 1 line
1.5.6.5
#5 lore raw

PATCH v2 4/9 nilfs2: delete redundant mark_inode_dirty

In reply to a message not in the archive

delete redundant mark_inode_dirty() calls

---
 fs/nilfs2/namei.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
fs/nilfs2/namei.c +0 -4
index f952439..35f59da 100644
@@ -247,7 +247,6 @@ static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 		return err;
 
 	inc_nlink(dir);
-	mark_inode_dirty(dir);
 
 	inode = nilfs_new_inode(dir, S_IFDIR | mode);
 	err = PTR_ERR(inode);
@@ -280,7 +279,6 @@ out:
 
 out_fail:
 	drop_nlink(inode);
-	mark_inode_dirty(inode);
 	drop_nlink(inode);
 	mark_inode_dirty(inode);
 	iput(inode);
@@ -405,7 +403,6 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 		if (!new_de)
 			goto out_dir;
 		inc_nlink(old_inode);
-		mark_inode_dirty(old_inode);
 		nilfs_set_link(new_dir, new_de, new_page, old_inode);
 		mark_inode_dirty(new_dir);
 		new_inode->i_ctime = CURRENT_TIME;
@@ -420,7 +417,6 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 				goto out_dir;
 		}
 		inc_nlink(old_inode);
-		mark_inode_dirty(old_inode);
 		err = nilfs_add_link(new_dentry, old_inode);
 		if (err) {
 			drop_nlink(old_inode);
Signature · 1 line
1.5.6.5
#6 lore raw

PATCH v2 5/9 nilfs2: split nilfs_unlink as nilfs_do_unlink and nilfs_unlink

In reply to a message not in the archive

Split nilfs_unlink() to reduce nested transaction and duplicate mark_inode_dirty() calls when calling nilfs_unlink() from nilfs_rmdir().

nilfs_do_unlink() is an actual unlink functionality which is not in transaction and does not call mark_inode_dirty() for dentry argument.

nilfs_unlink() is a wrapper function for do_nilfs_unlink() with transaction and mark_inode_dirty() for dentry argument.

---
 fs/nilfs2/namei.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)
fs/nilfs2/namei.c +19 -10
index 35f59da..d92e839 100644
@@ -288,18 +288,13 @@ out_dir:
 	goto out;
 }
 
-static int nilfs_unlink(struct inode *dir, struct dentry *dentry)
+static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry)
 {
 	struct inode *inode;
 	struct nilfs_dir_entry *de;
 	struct page *page;
-	struct nilfs_transaction_info ti;
 	int err;
 
-	err = nilfs_transaction_begin(dir->i_sb, &ti, 0);
-	if (err)
-		return err;
-
 	err = -ENOENT;
 	de = nilfs_find_entry(dir, dentry, &page);
 	if (!de)
@@ -322,12 +317,26 @@ static int nilfs_unlink(struct inode *dir, struct dentry *dentry)
 
 	inode->i_ctime = dir->i_ctime;
 	drop_nlink(inode);
-	mark_inode_dirty(inode);
 	err = 0;
 out:
-	if (!err)
+	return err;
+}
+
+static int nilfs_unlink(struct inode *dir, struct dentry *dentry)
+{
+	struct nilfs_transaction_info ti;
+	int err;
+
+	err = nilfs_transaction_begin(dir->i_sb, &ti, 0);
+	if (err)
+		return err;
+
+	err = nilfs_do_unlink(dir, dentry);
+
+	if (!err) {
+		mark_inode_dirty(dentry->d_inode);
 		err = nilfs_transaction_commit(dir->i_sb);
-	else
+	} else
 		nilfs_transaction_abort(dir->i_sb);
 
 	return err;
@@ -345,7 +354,7 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry)
 
 	err = -ENOTEMPTY;
 	if (nilfs_empty_dir(inode)) {
-		err = nilfs_unlink(dir, dentry);
+		err = nilfs_do_unlink(dir, dentry);
 		if (!err) {
 			inode->i_size = 0;
 			drop_nlink(inode);
Signature · 1 line
1.5.6.5
#7 lore raw

PATCH v2 6/9 nilfs2: change return type of nilfs_commit_chunk

In reply to a message not in the archive

change return type of nilfs_commit_chunk() as void from int, for nilfs_set_file_dirty() usually does not return error.

This is an intermediate patch to reduce mark_inode_dirty() in nilfs_commit_chunk().

---
 fs/nilfs2/dir.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
fs/nilfs2/dir.c +8 -8
index 4f3fa00..173530d 100644
@@ -99,9 +99,9 @@ static int nilfs_prepare_chunk(struct page *page,
 				 NULL, nilfs_get_block);
 }
 
-static int nilfs_commit_chunk(struct page *page,
-			      struct address_space *mapping,
-			      unsigned from, unsigned to)
+static void nilfs_commit_chunk(struct page *page,
+			       struct address_space *mapping,
+			       unsigned from, unsigned to)
 {
 	struct inode *dir = mapping->host;
 	struct nilfs_sb_info *sbi = NILFS_SB(dir->i_sb);
@@ -119,8 +119,8 @@ static int nilfs_commit_chunk(struct page *page,
 	if (IS_DIRSYNC(dir))
 		nilfs_set_transaction_flag(NILFS_TI_SYNC);
 	err = nilfs_set_file_dirty(sbi, dir, nr_dirty);
+	WARN_ON(err); /* do not happen */
 	unlock_page(page);
-	return err;
 }
 
 static void nilfs_check_page(struct page *page)
@@ -455,7 +455,7 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,
 	BUG_ON(err);
 	de->inode = cpu_to_le64(inode->i_ino);
 	nilfs_set_de_type(de, inode);
-	err = nilfs_commit_chunk(page, mapping, from, to);
+	nilfs_commit_chunk(page, mapping, from, to);
 	nilfs_put_page(page);
 	dir->i_mtime = dir->i_ctime = CURRENT_TIME;
 /*	NILFS_I(dir)->i_flags &= ~NILFS_BTREE_FL; */
@@ -547,7 +547,7 @@ got_it:
 	memcpy(de->name, name, namelen);
 	de->inode = cpu_to_le64(inode->i_ino);
 	nilfs_set_de_type(de, inode);
-	err = nilfs_commit_chunk(page, page->mapping, from, to);
+	nilfs_commit_chunk(page, page->mapping, from, to);
 	dir->i_mtime = dir->i_ctime = CURRENT_TIME;
 /*	NILFS_I(dir)->i_flags &= ~NILFS_BTREE_FL; */
 	mark_inode_dirty(dir);
@@ -594,7 +594,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
 	if (pde)
 		pde->rec_len = cpu_to_le16(to - from);
 	dir->inode = 0;
-	err = nilfs_commit_chunk(page, mapping, from, to);
+	nilfs_commit_chunk(page, mapping, from, to);
 	inode->i_ctime = inode->i_mtime = CURRENT_TIME;
 /*	NILFS_I(inode)->i_flags &= ~NILFS_BTREE_FL; */
 	mark_inode_dirty(inode);
@@ -639,7 +639,7 @@ int nilfs_make_empty(struct inode *inode, struct inode *parent)
 	memcpy(de->name, "..\0", 4);
 	nilfs_set_de_type(de, inode);
 	kunmap_atomic(kaddr, KM_USER0);
-	err = nilfs_commit_chunk(page, mapping, 0, chunk_size);
+	nilfs_commit_chunk(page, mapping, 0, chunk_size);
 fail:
 	page_cache_release(page);
 	return err;
Signature · 1 line
1.5.6.5
#8 lore raw

PATCH v2 7/9 nilfs2: delete mark_inode_dirty in nilfs_commit_chunk

In reply to a message not in the archive

Delete mark_inode_dirty() in nilfs_commit_chunk(), for callers of nilfs_commit_chunk() will call equivalent mark_inode_dirty() after calling nilfs_commit_chunk().

---
 fs/nilfs2/dir.c   |    4 +---
 fs/nilfs2/namei.c |    2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)
fs/nilfs2/dir.c +1 -3
index 173530d..693539b 100644
@@ -112,10 +112,8 @@ static void nilfs_commit_chunk(struct page *page,
 
 	nr_dirty = nilfs_page_count_clean_buffers(page, from, to);
 	copied = block_write_end(NULL, mapping, pos, len, len, page, NULL);
-	if (pos + copied > dir->i_size) {
+	if (pos + copied > dir->i_size)
 		i_size_write(dir, pos + copied);
-		mark_inode_dirty(dir);
-	}
 	if (IS_DIRSYNC(dir))
 		nilfs_set_transaction_flag(NILFS_TI_SYNC);
 	err = nilfs_set_file_dirty(sbi, dir, nr_dirty);
fs/nilfs2/namei.c +1 -1
index d92e839..d6aa8f4 100644
@@ -258,7 +258,6 @@ static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 	inode->i_mapping->a_ops = &nilfs_aops;
 
 	inc_nlink(inode);
-	mark_inode_dirty(inode);
 
 	err = nilfs_make_empty(inode, dir);
 	if (err)
@@ -268,6 +267,7 @@ static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 	if (err)
 		goto out_fail;
 
+	mark_inode_dirty(inode);
 	d_instantiate(dentry, inode);
 out:
 	if (!err)
Signature · 1 line
1.5.6.5
#9 lore raw

PATCH v2 8/9 nilfs2: delete mark_inode_dirty in nilfs_delete_entry

In reply to a message not in the archive

Delete mark_inode_dirty() in nilfs_delete_entry() to reduce duplicate mark_inode_dirty() calls both in nilfs_rename() and nilfs_delete_entry().

---
 fs/nilfs2/dir.c   |    1 -
 fs/nilfs2/namei.c |    3 ++-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/nilfs2/dir.c +0 -1
index 693539b..1d9a4e4 100644
@@ -595,7 +595,6 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
 	nilfs_commit_chunk(page, mapping, from, to);
 	inode->i_ctime = inode->i_mtime = CURRENT_TIME;
 /*	NILFS_I(inode)->i_flags &= ~NILFS_BTREE_FL; */
-	mark_inode_dirty(inode);
 out:
 	nilfs_put_page(page);
 	return err;
fs/nilfs2/namei.c +2 -1
index d6aa8f4..4237722 100644
@@ -334,6 +334,7 @@ static int nilfs_unlink(struct inode *dir, struct dentry *dentry)
 	err = nilfs_do_unlink(dir, dentry);
 
 	if (!err) {
+		mark_inode_dirty(dir);
 		mark_inode_dirty(dentry->d_inode);
 		err = nilfs_transaction_commit(dir->i_sb);
 	} else
@@ -450,8 +451,8 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (dir_de) {
 		nilfs_set_link(old_inode, dir_de, dir_page, new_dir);
 		drop_nlink(old_dir);
-		mark_inode_dirty(old_dir);
 	}
+	mark_inode_dirty(old_dir);
 	mark_inode_dirty(old_inode);
 
 	err = nilfs_transaction_commit(old_dir->i_sb);
Signature · 1 line
1.5.6.5
#10 lore raw

PATCH v2 9/9 nilfs2: replace mark_inode_dirty as nilfs_mark_inode_dirty

In reply to a message not in the archive

Replace mark_inode_dirty() as nilfs_mark_inode_dirty() to reduce deep function calls.

---
 fs/nilfs2/dir.c   |    2 +-
 fs/nilfs2/inode.c |    6 +++---
 fs/nilfs2/namei.c |   32 ++++++++++++++++----------------
 3 files changed, 20 insertions(+), 20 deletions(-)
fs/nilfs2/dir.c +1 -1
index 1d9a4e4..76d803e 100644
@@ -548,7 +548,7 @@ got_it:
 	nilfs_commit_chunk(page, page->mapping, from, to);
 	dir->i_mtime = dir->i_ctime = CURRENT_TIME;
 /*	NILFS_I(dir)->i_flags &= ~NILFS_BTREE_FL; */
-	mark_inode_dirty(dir);
+	nilfs_mark_inode_dirty(dir);
 	/* OFFSET_CACHE */
 out_put:
 	nilfs_put_page(page);
fs/nilfs2/inode.c +3 -3
index ede0375..7868cc1 100644
@@ -97,7 +97,7 @@ int nilfs_get_block(struct inode *inode, sector_t blkoff,
 			nilfs_transaction_abort(inode->i_sb);
 			goto out;
 		}
-		mark_inode_dirty(inode);
+		nilfs_mark_inode_dirty(inode);
 		nilfs_transaction_commit(inode->i_sb); /* never fails */
 		/* Error handling should be detailed */
 		set_buffer_new(bh_result);
@@ -598,7 +598,7 @@ void nilfs_truncate(struct inode *inode)
 	if (IS_SYNC(inode))
 		nilfs_set_transaction_flag(NILFS_TI_SYNC);
 
-	mark_inode_dirty(inode);
+	nilfs_mark_inode_dirty(inode);
 	nilfs_set_file_dirty(NILFS_SB(sb), inode, 0);
 	nilfs_transaction_commit(sb);
 	/* May construct a logical segment and may fail in sync mode.
@@ -623,7 +623,7 @@ void nilfs_delete_inode(struct inode *inode)
 		truncate_inode_pages(&inode->i_data, 0);
 
 	nilfs_truncate_bmap(ii, 0);
-	mark_inode_dirty(inode);
+	nilfs_mark_inode_dirty(inode);
 	nilfs_free_inode(inode);
 	/* nilfs_free_inode() marks inode buffer dirty */
 	if (IS_SYNC(inode))
fs/nilfs2/namei.c +16 -16
index 4237722..07ba838 100644
@@ -120,7 +120,7 @@ static int nilfs_create(struct inode *dir, struct dentry *dentry, int mode,
 		inode->i_op = &nilfs_file_inode_operations;
 		inode->i_fop = &nilfs_file_operations;
 		inode->i_mapping->a_ops = &nilfs_aops;
-		mark_inode_dirty(inode);
+		nilfs_mark_inode_dirty(inode);
 		err = nilfs_add_nondir(dentry, inode);
 	}
 	if (!err)
@@ -148,7 +148,7 @@ nilfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
 	err = PTR_ERR(inode);
 	if (!IS_ERR(inode)) {
 		init_special_inode(inode, inode->i_mode, rdev);
-		mark_inode_dirty(inode);
+		nilfs_mark_inode_dirty(inode);
 		err = nilfs_add_nondir(dentry, inode);
 	}
 	if (!err)
@@ -201,7 +201,7 @@ out:
 
 out_fail:
 	drop_nlink(inode);
-	mark_inode_dirty(inode);
+	nilfs_mark_inode_dirty(inode);
 	iput(inode);
 	goto out;
 }
@@ -267,7 +267,7 @@ static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 	if (err)
 		goto out_fail;
 
-	mark_inode_dirty(inode);
+	nilfs_mark_inode_dirty(inode);
 	d_instantiate(dentry, inode);
 out:
 	if (!err)
@@ -280,11 +280,11 @@ out:
 out_fail:
 	drop_nlink(inode);
 	drop_nlink(inode);
-	mark_inode_dirty(inode);
+	nilfs_mark_inode_dirty(inode);
 	iput(inode);
 out_dir:
 	drop_nlink(dir);
-	mark_inode_dirty(dir);
+	nilfs_mark_inode_dirty(dir);
 	goto out;
 }
 
@@ -334,8 +334,8 @@ static int nilfs_unlink(struct inode *dir, struct dentry *dentry)
 	err = nilfs_do_unlink(dir, dentry);
 
 	if (!err) {
-		mark_inode_dirty(dir);
-		mark_inode_dirty(dentry->d_inode);
+		nilfs_mark_inode_dirty(dir);
+		nilfs_mark_inode_dirty(dentry->d_inode);
 		err = nilfs_transaction_commit(dir->i_sb);
 	} else
 		nilfs_transaction_abort(dir->i_sb);
@@ -359,9 +359,9 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry)
 		if (!err) {
 			inode->i_size = 0;
 			drop_nlink(inode);
-			mark_inode_dirty(inode);
+			nilfs_mark_inode_dirty(inode);
 			drop_nlink(dir);
-			mark_inode_dirty(dir);
+			nilfs_mark_inode_dirty(dir);
 		}
 	}
 	if (!err)
@@ -414,12 +414,12 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 			goto out_dir;
 		inc_nlink(old_inode);
 		nilfs_set_link(new_dir, new_de, new_page, old_inode);
-		mark_inode_dirty(new_dir);
+		nilfs_mark_inode_dirty(new_dir);
 		new_inode->i_ctime = CURRENT_TIME;
 		if (dir_de)
 			drop_nlink(new_inode);
 		drop_nlink(new_inode);
-		mark_inode_dirty(new_inode);
+		nilfs_mark_inode_dirty(new_inode);
 	} else {
 		if (dir_de) {
 			err = -EMLINK;
@@ -430,12 +430,12 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 		err = nilfs_add_link(new_dentry, old_inode);
 		if (err) {
 			drop_nlink(old_inode);
-			mark_inode_dirty(old_inode);
+			nilfs_mark_inode_dirty(old_inode);
 			goto out_dir;
 		}
 		if (dir_de) {
 			inc_nlink(new_dir);
-			mark_inode_dirty(new_dir);
+			nilfs_mark_inode_dirty(new_dir);
 		}
 	}
 
@@ -452,8 +452,8 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 		nilfs_set_link(old_inode, dir_de, dir_page, new_dir);
 		drop_nlink(old_dir);
 	}
-	mark_inode_dirty(old_dir);
-	mark_inode_dirty(old_inode);
+	nilfs_mark_inode_dirty(old_dir);
+	nilfs_mark_inode_dirty(old_inode);
 
 	err = nilfs_transaction_commit(old_dir->i_sb);
 	return err;
Signature · 1 line
1.5.6.5
#11 lore raw
In reply to a message not in the archive
Quoted 16 lines · Jiro SEKIBA

Hi,

This is a revised series of patches to reduce redandunt mark_inode_dirty calls.

Many functions call mark_inode_dirty() whenever they change inode object. However, it is redundant to call mark_inode_dirty() to same inode object within a transaction.

Last patch also replaces all mark_inode_dirty() calls as nilfs_mark_inode_dirty(), to reduce deep function call tree.

Changes since v2 is:
- deleted mark_inode_dirty(dir) in nilfs_mkdir()
- moved mark_inod_dirty(dir) from nilfs_do_unlink() to nilfs_unlink()
- correct diff stat ;-)

Quoted 4 lines
 fs/nilfs2/dir.c   |   24 ++++++---------
 fs/nilfs2/inode.c |    7 ++--
 fs/nilfs2/namei.c |   83 +++++++++++++++++++++++++++++++++-------------------
 3 files changed, 66 insertions(+), 48 deletions(-)

Looks good to me. Applied on top of the for-next branch.

Thank you,
Ryusuke Konishi