diff options
author | Dave Kleikamp <shaggy@austin.ibm.com> | 2004-07-07 05:34:11 -0500 |
---|---|---|
committer | Dave Kleikamp <shaggy@austin.ibm.com> | 2004-07-07 05:34:11 -0500 |
commit | e83a5d51a5b727e9e594b73194baf986539b1585 (patch) | |
tree | 5df242efe2161467915874089fb62c25acd29ba9 /fs | |
parent | 5f32f3d431b10fae5adcf83730838e1315e7d039 (diff) | |
download | history-e83a5d51a5b727e9e594b73194baf986539b1585.tar.gz |
JFS: Protect active_ag with a spinlock
Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/jfs/file.c | 4 | ||||
-rw-r--r-- | fs/jfs/jfs_extent.c | 2 | ||||
-rw-r--r-- | fs/jfs/jfs_incore.h | 1 | ||||
-rw-r--r-- | fs/jfs/super.c | 4 |
4 files changed, 11 insertions, 0 deletions
diff --git a/fs/jfs/file.c b/fs/jfs/file.c index 67e4ba8ce0956c..a87b06fa8ff899 100644 --- a/fs/jfs/file.c +++ b/fs/jfs/file.c @@ -65,11 +65,13 @@ static int jfs_open(struct inode *inode, struct file *file) if (S_ISREG(inode->i_mode) && file->f_mode & FMODE_WRITE && (inode->i_size == 0)) { struct jfs_inode_info *ji = JFS_IP(inode); + spin_lock_irq(&ji->ag_lock); if (ji->active_ag == -1) { ji->active_ag = ji->agno; atomic_inc( &JFS_SBI(inode->i_sb)->bmap->db_active[ji->agno]); } + spin_unlock_irq(&ji->ag_lock); } return 0; @@ -78,11 +80,13 @@ static int jfs_release(struct inode *inode, struct file *file) { struct jfs_inode_info *ji = JFS_IP(inode); + spin_lock_irq(&ji->ag_lock); if (ji->active_ag != -1) { struct bmap *bmap = JFS_SBI(inode->i_sb)->bmap; atomic_dec(&bmap->db_active[ji->active_ag]); ji->active_ag = -1; } + spin_unlock_irq(&ji->ag_lock); return 0; } diff --git a/fs/jfs/jfs_extent.c b/fs/jfs/jfs_extent.c index 2068c4746e029d..2b411bc32eb833 100644 --- a/fs/jfs/jfs_extent.c +++ b/fs/jfs/jfs_extent.c @@ -553,6 +553,7 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno) if (S_ISREG(ip->i_mode) && (ji->fileset == FILESYSTEM_I)) { ag = BLKTOAG(daddr, sbi); + spin_lock_irq(&ji->ag_lock); if (ji->active_ag == -1) { atomic_inc(&bmp->db_active[ag]); ji->active_ag = ag; @@ -561,6 +562,7 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno) atomic_inc(&bmp->db_active[ag]); ji->active_ag = ag; } + spin_unlock_irq(&ji->ag_lock); } return (0); diff --git a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h index ac608c9ff5307a..5496bfb149cf20 100644 --- a/fs/jfs/jfs_incore.h +++ b/fs/jfs/jfs_incore.h @@ -53,6 +53,7 @@ struct jfs_inode_info { lid_t blid; /* lid of pseudo buffer? */ lid_t atlhead; /* anonymous tlock list head */ lid_t atltail; /* anonymous tlock list tail */ + spinlock_t ag_lock; /* protects active_ag */ struct list_head anon_inode_list; /* inodes having anonymous txns */ /* * rdwrlock serializes xtree between reads & writes and synchronizes diff --git a/fs/jfs/super.c b/fs/jfs/super.c index d359c26195cfbf..96c1ee382a6827 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c @@ -141,10 +141,13 @@ static void jfs_destroy_inode(struct inode *inode) { struct jfs_inode_info *ji = JFS_IP(inode); + spin_lock_irq(&ji->ag_lock); if (ji->active_ag != -1) { struct bmap *bmap = JFS_SBI(inode->i_sb)->bmap; atomic_dec(&bmap->db_active[ji->active_ag]); + ji->active_ag = -1; } + spin_unlock_irq(&ji->ag_lock); #ifdef CONFIG_JFS_POSIX_ACL if (ji->i_acl != JFS_ACL_NOT_CACHED) { @@ -559,6 +562,7 @@ static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags) init_rwsem(&jfs_ip->rdwrlock); init_MUTEX(&jfs_ip->commit_sem); init_rwsem(&jfs_ip->xattr_sem); + spin_lock_init(&jfs_ip->ag_lock); jfs_ip->active_ag = -1; #ifdef CONFIG_JFS_POSIX_ACL jfs_ip->i_acl = JFS_ACL_NOT_CACHED; |