X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fsysv%2Fitree.c;h=f2bcccd1d6fcf42fb9ac5db739eaf33d2ad43fc4;hb=refs%2Fheads%2Fvserver;hp=60b40506748dab7bd266928a3a820273bbd9598f;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c index 60b405067..f2bcccd1d 100644 --- a/fs/sysv/itree.c +++ b/fs/sysv/itree.c @@ -50,20 +50,20 @@ static int block_to_path(struct inode *inode, long block, int offsets[DEPTH]) return n; } -static inline int block_to_cpu(struct sysv_sb_info *sbi, u32 nr) +static inline int block_to_cpu(struct sysv_sb_info *sbi, sysv_zone_t nr) { return sbi->s_block_base + fs32_to_cpu(sbi, nr); } typedef struct { - u32 *p; - u32 key; + sysv_zone_t *p; + sysv_zone_t key; struct buffer_head *bh; } Indirect; -static rwlock_t pointers_lock = RW_LOCK_UNLOCKED; +static DEFINE_RWLOCK(pointers_lock); -static inline void add_chain(Indirect *p, struct buffer_head *bh, u32 *v) +static inline void add_chain(Indirect *p, struct buffer_head *bh, sysv_zone_t *v) { p->key = *(p->p = v); p->bh = bh; @@ -76,11 +76,14 @@ static inline int verify_chain(Indirect *from, Indirect *to) return (from > to); } -static inline u32 *block_end(struct buffer_head *bh) +static inline sysv_zone_t *block_end(struct buffer_head *bh) { - return (u32*)((char*)bh->b_data + bh->b_size); + return (sysv_zone_t*)((char*)bh->b_data + bh->b_size); } +/* + * Requires read_lock(&pointers_lock) or write_lock(&pointers_lock) + */ static Indirect *get_branch(struct inode *inode, int depth, int offsets[], @@ -100,18 +103,15 @@ static Indirect *get_branch(struct inode *inode, bh = sb_bread(sb, block); if (!bh) goto failure; - read_lock(&pointers_lock); if (!verify_chain(chain, p)) goto changed; - add_chain(++p, bh, (u32*)bh->b_data + *++offsets); - read_unlock(&pointers_lock); + add_chain(++p, bh, (sysv_zone_t*)bh->b_data + *++offsets); if (!p->key) goto no_block; } return NULL; changed: - read_unlock(&pointers_lock); brelse(bh); *err = -EAGAIN; goto no_block; @@ -147,7 +147,7 @@ static int alloc_branch(struct inode *inode, lock_buffer(bh); memset(bh->b_data, 0, blocksize); branch[n].bh = bh; - branch[n].p = (u32*) bh->b_data + offsets[n]; + branch[n].p = (sysv_zone_t*) bh->b_data + offsets[n]; *branch[n].p = branch[n].key; set_buffer_uptodate(bh); unlock_buffer(bh); @@ -178,7 +178,7 @@ static inline int splice_branch(struct inode *inode, *where->p = where->key; write_unlock(&pointers_lock); - inode->i_ctime = CURRENT_TIME; + inode->i_ctime = CURRENT_TIME_SEC; /* had we spliced it onto indirect block? */ if (where->bh) @@ -213,7 +213,9 @@ static int get_block(struct inode *inode, sector_t iblock, struct buffer_head *b goto out; reread: + read_lock(&pointers_lock); partial = get_branch(inode, depth, offsets, chain, &err); + read_unlock(&pointers_lock); /* Simplest case - block found, no allocation needed */ if (!partial) { @@ -263,7 +265,7 @@ changed: goto reread; } -static inline int all_zeroes(u32 *p, u32 *q) +static inline int all_zeroes(sysv_zone_t *p, sysv_zone_t *q) { while (p < q) if (*p++) @@ -275,7 +277,7 @@ static Indirect *find_shared(struct inode *inode, int depth, int offsets[], Indirect chain[], - u32 *top) + sysv_zone_t *top) { Indirect *partial, *p; int k, err; @@ -296,7 +298,7 @@ static Indirect *find_shared(struct inode *inode, write_unlock(&pointers_lock); goto no_top; } - for (p=partial; p>chain && all_zeroes((u32*)p->bh->b_data,p->p); p--) + for (p=partial; p>chain && all_zeroes((sysv_zone_t*)p->bh->b_data,p->p); p--) ; /* * OK, we've found the last block that must survive. The rest of our @@ -320,10 +322,10 @@ no_top: return partial; } -static inline void free_data(struct inode *inode, u32 *p, u32 *q) +static inline void free_data(struct inode *inode, sysv_zone_t *p, sysv_zone_t *q) { for ( ; p < q ; p++) { - u32 nr = *p; + sysv_zone_t nr = *p; if (nr) { *p = 0; sysv_free_block(inode->i_sb, nr); @@ -332,7 +334,7 @@ static inline void free_data(struct inode *inode, u32 *p, u32 *q) } } -static void free_branches(struct inode *inode, u32 *p, u32 *q, int depth) +static void free_branches(struct inode *inode, sysv_zone_t *p, sysv_zone_t *q, int depth) { struct buffer_head * bh; struct super_block *sb = inode->i_sb; @@ -340,7 +342,7 @@ static void free_branches(struct inode *inode, u32 *p, u32 *q, int depth) if (depth--) { for ( ; p < q ; p++) { int block; - u32 nr = *p; + sysv_zone_t nr = *p; if (!nr) continue; *p = 0; @@ -348,7 +350,7 @@ static void free_branches(struct inode *inode, u32 *p, u32 *q, int depth) bh = sb_bread(sb, block); if (!bh) continue; - free_branches(inode, (u32*)bh->b_data, + free_branches(inode, (sysv_zone_t*)bh->b_data, block_end(bh), depth); bforget(bh); sysv_free_block(sb, nr); @@ -360,11 +362,11 @@ static void free_branches(struct inode *inode, u32 *p, u32 *q, int depth) void sysv_truncate (struct inode * inode) { - u32 *i_data = SYSV_I(inode)->i_data; + sysv_zone_t *i_data = SYSV_I(inode)->i_data; int offsets[DEPTH]; Indirect chain[DEPTH]; Indirect *partial; - int nr = 0; + sysv_zone_t nr = 0; int n; long iblock; unsigned blocksize; @@ -416,7 +418,7 @@ do_indirects: } n++; } - inode->i_mtime = inode->i_ctime = CURRENT_TIME; + inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; if (IS_SYNC(inode)) sysv_sync_inode (inode); else @@ -463,7 +465,7 @@ static sector_t sysv_bmap(struct address_space *mapping, sector_t block) { return generic_block_bmap(mapping,block,get_block); } -struct address_space_operations sysv_aops = { +const struct address_space_operations sysv_aops = { .readpage = sysv_readpage, .writepage = sysv_writepage, .sync_page = block_sync_page,