Skip to content

Commit

Permalink
udf: use get_bh()
Browse files Browse the repository at this point in the history
Make UDF use get_bh() instead of directly accessing b_count and use
brelse() instead of udf_release_data() which does just brelse()...

Signed-off-by: Jan Kara <jack@suse.cz>
Acked-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
jankara authored and Linus Torvalds committed May 8, 2007
1 parent ff116fc commit 3bf25cb
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 177 deletions.
35 changes: 19 additions & 16 deletions fs/udf/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ static void udf_table_free_blocks(struct super_block * sb,
{
i = -1;
oepos.block = epos.block;
udf_release_data(oepos.bh);
atomic_inc(&epos.bh->b_count);
brelse(oepos.bh);
get_bh(epos.bh);
oepos.bh = epos.bh;
oepos.offset = 0;
}
Expand Down Expand Up @@ -546,8 +546,8 @@ static void udf_table_free_blocks(struct super_block * sb,
adsize = sizeof(long_ad);
else
{
udf_release_data(oepos.bh);
udf_release_data(epos.bh);
brelse(oepos.bh);
brelse(epos.bh);
goto error_return;
}

Expand All @@ -556,7 +556,7 @@ static void udf_table_free_blocks(struct super_block * sb,
char *sptr, *dptr;
int loffset;

udf_release_data(oepos.bh);
brelse(oepos.bh);
oepos = epos;

/* Steal a block from the extent being free'd */
Expand All @@ -567,7 +567,7 @@ static void udf_table_free_blocks(struct super_block * sb,
if (!(epos.bh = udf_tread(sb,
udf_get_lb_pblock(sb, epos.block, 0))))
{
udf_release_data(oepos.bh);
brelse(oepos.bh);
goto error_return;
}
aed = (struct allocExtDesc *)(epos.bh->b_data);
Expand Down Expand Up @@ -658,8 +658,8 @@ static void udf_table_free_blocks(struct super_block * sb,
}
}

udf_release_data(epos.bh);
udf_release_data(oepos.bh);
brelse(epos.bh);
brelse(oepos.bh);

error_return:
sb->s_dirt = 1;
Expand Down Expand Up @@ -723,7 +723,7 @@ static int udf_table_prealloc_blocks(struct super_block * sb,
else
alloc_count = 0;

udf_release_data(epos.bh);
brelse(epos.bh);

if (alloc_count && UDF_SB_LVIDBH(sb))
{
Expand Down Expand Up @@ -789,9 +789,9 @@ static int udf_table_new_block(struct super_block * sb,
spread = nspread;
if (goal_epos.bh != epos.bh)
{
udf_release_data(goal_epos.bh);
brelse(goal_epos.bh);
goal_epos.bh = epos.bh;
atomic_inc(&goal_epos.bh->b_count);
get_bh(goal_epos.bh);
}
goal_epos.block = epos.block;
goal_epos.offset = epos.offset - adsize;
Expand All @@ -800,11 +800,11 @@ static int udf_table_new_block(struct super_block * sb,
}
}

udf_release_data(epos.bh);
brelse(epos.bh);

if (spread == 0xFFFFFFFF)
{
udf_release_data(goal_epos.bh);
brelse(goal_epos.bh);
mutex_unlock(&sbi->s_alloc_mutex);
return 0;
}
Expand All @@ -820,7 +820,7 @@ static int udf_table_new_block(struct super_block * sb,

if (inode && DQUOT_ALLOC_BLOCK(inode, 1))
{
udf_release_data(goal_epos.bh);
brelse(goal_epos.bh);
mutex_unlock(&sbi->s_alloc_mutex);
*err = -EDQUOT;
return 0;
Expand All @@ -830,7 +830,7 @@ static int udf_table_new_block(struct super_block * sb,
udf_write_aext(table, &goal_epos, goal_eloc, goal_elen, 1);
else
udf_delete_aext(table, goal_epos, goal_eloc, goal_elen);
udf_release_data(goal_epos.bh);
brelse(goal_epos.bh);

if (UDF_SB_LVIDBH(sb))
{
Expand Down Expand Up @@ -915,11 +915,14 @@ inline int udf_new_block(struct super_block * sb,
struct inode * inode,
uint16_t partition, uint32_t goal, int *err)
{
int ret;

if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP)
{
return udf_bitmap_new_block(sb, inode,
ret = udf_bitmap_new_block(sb, inode,
UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap,
partition, goal, err);
return ret;
}
else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE)
{
Expand Down
22 changes: 11 additions & 11 deletions fs/udf/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d

if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block)))
{
udf_release_data(epos.bh);
brelse(epos.bh);
return -EIO;
}

Expand Down Expand Up @@ -172,7 +172,7 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
}
else
{
udf_release_data(epos.bh);
brelse(epos.bh);
return -ENOENT;
}

Expand All @@ -185,9 +185,9 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
if (!fi)
{
if (fibh.sbh != fibh.ebh)
udf_release_data(fibh.ebh);
udf_release_data(fibh.sbh);
udf_release_data(epos.bh);
brelse(fibh.ebh);
brelse(fibh.sbh);
brelse(epos.bh);
return 0;
}

Expand Down Expand Up @@ -245,9 +245,9 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
if (filldir(dirent, fname, flen, filp->f_pos, iblock, dt_type) < 0)
{
if (fibh.sbh != fibh.ebh)
udf_release_data(fibh.ebh);
udf_release_data(fibh.sbh);
udf_release_data(epos.bh);
brelse(fibh.ebh);
brelse(fibh.sbh);
brelse(epos.bh);
return 0;
}
}
Expand All @@ -256,9 +256,9 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
filp->f_pos = nf_pos + 1;

if (fibh.sbh != fibh.ebh)
udf_release_data(fibh.ebh);
udf_release_data(fibh.sbh);
udf_release_data(epos.bh);
brelse(fibh.ebh);
brelse(fibh.sbh);
brelse(epos.bh);

return 0;
}
10 changes: 5 additions & 5 deletions fs/udf/directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ udf_filead_read(struct inode *dir, uint8_t *tmpad, uint8_t ad_size,

if (!ad)
{
udf_release_data(*bh);
brelse(*bh);
*error = 1;
return NULL;
}

if (*offset == dir->i_sb->s_blocksize)
{
udf_release_data(*bh);
brelse(*bh);
block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
if (!block)
return NULL;
Expand All @@ -57,7 +57,7 @@ udf_filead_read(struct inode *dir, uint8_t *tmpad, uint8_t ad_size,
remainder = dir->i_sb->s_blocksize - loffset;
memcpy((uint8_t *)ad, (*bh)->b_data + loffset, remainder);

udf_release_data(*bh);
brelse(*bh);
block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
if (!block)
return NULL;
Expand Down Expand Up @@ -120,7 +120,7 @@ udf_fileident_read(struct inode *dir, loff_t *nf_pos,
else
epos->offset = lextoffset;

udf_release_data(fibh->sbh);
brelse(fibh->sbh);
if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block)))
return NULL;
fibh->soffset = fibh->eoffset = 0;
Expand Down Expand Up @@ -149,7 +149,7 @@ udf_fileident_read(struct inode *dir, loff_t *nf_pos,
}
else if (fibh->sbh != fibh->ebh)
{
udf_release_data(fibh->sbh);
brelse(fibh->sbh);
fibh->sbh = fibh->ebh;
}

Expand Down
Loading

0 comments on commit 3bf25cb

Please sign in to comment.