[Ocfs2-commits] smushran commits r3028 - branches/ocfs2-1.2/fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Jun 11 14:25:36 PDT 2007


Author: smushran
Date: 2007-06-11 14:25:34 -0700 (Mon, 11 Jun 2007)
New Revision: 3028

Modified:
   branches/ocfs2-1.2/fs/ocfs2/dir.c
   branches/ocfs2-1.2/fs/ocfs2/inode.c
Log:
ocfs2: Wrap access of directory allocations with ip_alloc_sem.

OCFS2_I(inode)->ip_alloc_sem is a read-write semaphore protecting
local concurrent access of ocfs2 inodes.  However, ocfs2 directories were
not taking the semaphore while they accessed or modified the allocation
tree.

ocfs2_extend_dir() needs to take the semaphore in a write mode when it
adds to the allocation.  All other directory users get there via
ocfs2_bread(), which takes the semaphore in read mode.

Authored-by: Joel Becker <joel.becker at oracle.com>
Signed-off-by: mfasheh

Modified: branches/ocfs2-1.2/fs/ocfs2/dir.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/dir.c	2007-05-25 18:25:21 UTC (rev 3027)
+++ branches/ocfs2-1.2/fs/ocfs2/dir.c	2007-06-11 21:25:34 UTC (rev 3028)
@@ -393,7 +393,7 @@
 			    struct buffer_head **new_de_bh)
 {
 	int status = 0;
-	int credits, num_free_extents;
+	int credits, num_free_extents, drop_alloc_sem = 0;
 	loff_t dir_i_size;
 	struct ocfs2_dinode *fe = (struct ocfs2_dinode *) parent_fe_bh->b_data;
 	struct ocfs2_alloc_context *data_ac = NULL;
@@ -450,6 +450,9 @@
 		credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS;
 	}
 
+	down_write(&OCFS2_I(dir)->ip_alloc_sem);
+	drop_alloc_sem = 1;
+
 	handle = ocfs2_start_trans(osb, handle, credits);
 	if (IS_ERR(handle)) {
 		status = PTR_ERR(handle);
@@ -495,6 +498,8 @@
 	*new_de_bh = new_bh;
 	get_bh(*new_de_bh);
 bail:
+	if (drop_alloc_sem)
+		up_write(&OCFS2_I(dir)->ip_alloc_sem);
 	if (handle)
 		ocfs2_commit_trans(handle);
 

Modified: branches/ocfs2-1.2/fs/ocfs2/inode.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/inode.c	2007-05-25 18:25:21 UTC (rev 3027)
+++ branches/ocfs2-1.2/fs/ocfs2/inode.c	2007-06-11 21:25:34 UTC (rev 3028)
@@ -1027,8 +1027,10 @@
 		return NULL;
 	}
 
+	down_read(&OCFS2_I(inode)->ip_alloc_sem);
 	tmperr = ocfs2_extent_map_get_blocks(inode, block, 1,
 					     &p_blkno, NULL);
+	up_read(&OCFS2_I(inode)->ip_alloc_sem);
 	if (tmperr < 0) {
 		mlog_errno(tmperr);
 		goto fail;




More information about the Ocfs2-commits mailing list