Skip to contentSkip to conversation

ocfs2: Hold ip_lock when set/clear flags for indexed dir.

PATCH New Tao Ma 3 participants 3 messages Dec 15, 2010 – Dec 16, 2010 OCFS2

lore
Share & tools
lore

Tao Ma

author
#0 lore raw

PATCH 1/1 ocfs2: Hold ip_lock when set/clear flags for indexed dir.

From: Tao Ma <[email protected]>

When we set/clear the dyn_features for an inode we hold the ip_lock. So do it when we set/clear OCFS2_INDEXED_DIR_FL also.

---
 fs/ocfs2/dir.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
fs/ocfs2/dir.c +4 -0
index c49f6de..d417b3f 100644
@@ -2461,8 +2461,10 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb,
 
 	di->i_dx_root = cpu_to_le64(dr_blkno);
 
+	spin_lock(&OCFS2_I(dir)->ip_lock);
 	OCFS2_I(dir)->ip_dyn_features |= OCFS2_INDEXED_DIR_FL;
 	di->i_dyn_features = cpu_to_le16(OCFS2_I(dir)->ip_dyn_features);
+	spin_unlock(&OCFS2_I(dir)->ip_lock);
 
 	ocfs2_journal_dirty(handle, di_bh);
 
@@ -4466,8 +4468,10 @@ static int ocfs2_dx_dir_remove_index(struct inode *dir,
 		goto out_commit;
 	}
 
+	spin_lock(&OCFS2_I(dir)->ip_lock);
 	OCFS2_I(dir)->ip_dyn_features &= ~OCFS2_INDEXED_DIR_FL;
 	di->i_dyn_features = cpu_to_le16(OCFS2_I(dir)->ip_dyn_features);
+	spin_unlock(&OCFS2_I(dir)->ip_lock);
 	di->i_dx_root = cpu_to_le64(0ULL);
 
 	ocfs2_journal_dirty(handle, di_bh);
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 ocfs2: Hold ip_lock when set/clear flags for indexed dir.

Acked-by Sunil Mushran <[email protected]>

Quoted 36 lines · Tao Ma

From: Tao Ma<[email protected]>

When we set/clear the dyn_features for an inode we hold the ip_lock. So do it when we set/clear OCFS2_INDEXED_DIR_FL also.

---
  fs/ocfs2/dir.c |    4 ++++
  1 files changed, 4 insertions(+), 0 deletions(-)
fs/ocfs2/dir.c +4 -0
index c49f6de..d417b3f 100644
@@ -2461,8 +2461,10 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb,
 
  	di->i_dx_root = cpu_to_le64(dr_blkno);
 
+	spin_lock(&OCFS2_I(dir)->ip_lock);
  	OCFS2_I(dir)->ip_dyn_features |= OCFS2_INDEXED_DIR_FL;
  	di->i_dyn_features = cpu_to_le16(OCFS2_I(dir)->ip_dyn_features);
+	spin_unlock(&OCFS2_I(dir)->ip_lock);
 
  	ocfs2_journal_dirty(handle, di_bh);
 
@@ -4466,8 +4468,10 @@ static int ocfs2_dx_dir_remove_index(struct inode *dir,
  		goto out_commit;
  	}
 
+	spin_lock(&OCFS2_I(dir)->ip_lock);
  	OCFS2_I(dir)->ip_dyn_features&= ~OCFS2_INDEXED_DIR_FL;
  	di->i_dyn_features = cpu_to_le16(OCFS2_I(dir)->ip_dyn_features);
+	spin_unlock(&OCFS2_I(dir)->ip_lock);
  	di->i_dx_root = cpu_to_le64(0ULL);
 
  	ocfs2_journal_dirty(handle, di_bh);
#2 lore raw

PATCH 1/1 ocfs2: Hold ip_lock when set/clear flags for indexed dir.

In reply to Tao Ma
Quoted 6 lines · Tao Ma

From: Tao Ma <[email protected]>

When we set/clear the dyn_features for an inode we hold the ip_lock. So do it when we set/clear OCFS2_INDEXED_DIR_FL also.

This is now in the fixes branch of ocfs2.git.

Joel

Quoted 33 lines
---
 fs/ocfs2/dir.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
fs/ocfs2/dir.c +4 -0
index c49f6de..d417b3f 100644
@@ -2461,8 +2461,10 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb,
 
 	di->i_dx_root = cpu_to_le64(dr_blkno);
 
+	spin_lock(&OCFS2_I(dir)->ip_lock);
 	OCFS2_I(dir)->ip_dyn_features |= OCFS2_INDEXED_DIR_FL;
 	di->i_dyn_features = cpu_to_le16(OCFS2_I(dir)->ip_dyn_features);
+	spin_unlock(&OCFS2_I(dir)->ip_lock);
 
 	ocfs2_journal_dirty(handle, di_bh);
 
@@ -4466,8 +4468,10 @@ static int ocfs2_dx_dir_remove_index(struct inode *dir,
 		goto out_commit;
 	}
 
+	spin_lock(&OCFS2_I(dir)->ip_lock);
 	OCFS2_I(dir)->ip_dyn_features &= ~OCFS2_INDEXED_DIR_FL;
 	di->i_dyn_features = cpu_to_le16(OCFS2_I(dir)->ip_dyn_features);
+	spin_unlock(&OCFS2_I(dir)->ip_lock);
 	di->i_dx_root = cpu_to_le64(0ULL);
 
 	ocfs2_journal_dirty(handle, di_bh);
Signature · 1 line
1.7.0.4
Signature · 9 lines
"Here's something to think about:  How come you never see a headline
 like ``Psychic Wins Lottery''?"
	- Jay Leno

Joel Becker
Senior Development Manager
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127