Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ee19a77956cb65c5da54d85a5efefe50b39fa6e5
Commit:     ee19a77956cb65c5da54d85a5efefe50b39fa6e5
Parent:     6cb129f5675c39944e5fe18fd2530a2eb771b754
Author:     Joel Becker <[EMAIL PROTECTED]>
AuthorDate: Wed Mar 28 18:27:07 2007 -0700
Committer:  Mark Fasheh <[EMAIL PROTECTED]>
CommitDate: Wed May 2 15:07:42 2007 -0700

    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.
    
    Signed-off-by: Joel Becker <[EMAIL PROTECTED]>
    Signed-off-by: Mark Fasheh <[EMAIL PROTECTED]>
---
 fs/ocfs2/dir.c   |    7 ++++++-
 fs/ocfs2/inode.c |    2 ++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 67e6866..c441ef1 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -403,7 +403,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
                            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;
@@ -452,6 +452,9 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
                credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS;
        }
 
+       down_write(&OCFS2_I(dir)->ip_alloc_sem);
+       drop_alloc_sem = 1;
+
        handle = ocfs2_start_trans(osb, credits);
        if (IS_ERR(handle)) {
                status = PTR_ERR(handle);
@@ -497,6 +500,8 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
        *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(osb, handle);
 
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 21a6050..58ec54b 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -1106,8 +1106,10 @@ struct buffer_head *ocfs2_bread(struct inode *inode,
                return NULL;
        }
 
+       down_read(&OCFS2_I(inode)->ip_alloc_sem);
        tmperr = ocfs2_extent_map_get_blocks(inode, block, &p_blkno, NULL,
                                             NULL);
+       up_read(&OCFS2_I(inode)->ip_alloc_sem);
        if (tmperr < 0) {
                mlog_errno(tmperr);
                goto fail;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to