Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 45302
b: refs/heads/master
c: d63b709
h: refs/heads/master
v: v3
  • Loading branch information
Evgeniy Dushistov authored and Linus Torvalds committed Jan 6, 2007
1 parent 4eaf22f commit ba73bf7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 37 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7ba3485947ee7bc89a17f86250fe9b692a615dff
refs/heads/master: d63b70902befe189ba2672925f28ec3f4db41352
25 changes: 25 additions & 0 deletions trunk/fs/ufs/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,25 @@ static void ufs_change_blocknr(struct inode *inode, unsigned int baseblk,
UFSD("EXIT\n");
}

static void ufs_clear_frags(struct inode *inode, sector_t beg, unsigned int n,
int sync)
{
struct buffer_head *bh;
sector_t end = beg + n;

for (; beg < end; ++beg) {
bh = sb_getblk(inode->i_sb, beg);
lock_buffer(bh);
memset(bh->b_data, 0, inode->i_sb->s_blocksize);
set_buffer_uptodate(bh);
mark_buffer_dirty(bh);
unlock_buffer(bh);
if (IS_SYNC(inode) || sync)
sync_dirty_buffer(bh);
brelse(bh);
}
}

unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
unsigned goal, unsigned count, int * err, struct page *locked_page)
{
Expand Down Expand Up @@ -350,6 +369,8 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
*p = cpu_to_fs32(sb, result);
*err = 0;
UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
locked_page != NULL);
}
unlock_super(sb);
UFSD("EXIT, result %u\n", result);
Expand All @@ -363,6 +384,8 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
if (result) {
*err = 0;
UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
locked_page != NULL);
unlock_super(sb);
UFSD("EXIT, result %u\n", result);
return result;
Expand Down Expand Up @@ -398,6 +421,8 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
*p = cpu_to_fs32(sb, result);
*err = 0;
UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
locked_page != NULL);
unlock_super(sb);
if (newcount < request)
ufs_free_fragments (inode, result + newcount, request - newcount);
Expand Down
41 changes: 5 additions & 36 deletions trunk/fs/ufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,36 +156,6 @@ static u64 ufs_frag_map(struct inode *inode, sector_t frag)
return ret;
}

static void ufs_clear_frag(struct inode *inode, struct buffer_head *bh)
{
lock_buffer(bh);
memset(bh->b_data, 0, inode->i_sb->s_blocksize);
set_buffer_uptodate(bh);
mark_buffer_dirty(bh);
unlock_buffer(bh);
if (IS_SYNC(inode))
sync_dirty_buffer(bh);
}

static struct buffer_head *
ufs_clear_frags(struct inode *inode, sector_t beg,
unsigned int n, sector_t want)
{
struct buffer_head *res = NULL, *bh;
sector_t end = beg + n;

for (; beg < end; ++beg) {
bh = sb_getblk(inode->i_sb, beg);
ufs_clear_frag(inode, bh);
if (want != beg)
brelse(bh);
else
res = bh;
}
BUG_ON(!res);
return res;
}

/**
* ufs_inode_getfrag() - allocate new fragment(s)
* @inode - pointer to inode
Expand Down Expand Up @@ -302,7 +272,7 @@ ufs_inode_getfrag(struct inode *inode, unsigned int fragment,
}

if (!phys) {
result = ufs_clear_frags(inode, tmp, required, tmp + blockoff);
result = sb_getblk(sb, tmp + blockoff);
} else {
*phys = tmp + blockoff;
result = NULL;
Expand Down Expand Up @@ -403,8 +373,7 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,


if (!phys) {
result = ufs_clear_frags(inode, tmp, uspi->s_fpb,
tmp + blockoff);
result = sb_getblk(sb, tmp + blockoff);
} else {
*phys = tmp + blockoff;
*new = 1;
Expand Down Expand Up @@ -471,13 +440,13 @@ int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buffer_head
#define GET_INODE_DATABLOCK(x) \
ufs_inode_getfrag(inode, x, fragment, 1, &err, &phys, &new, bh_result->b_page)
#define GET_INODE_PTR(x) \
ufs_inode_getfrag(inode, x, fragment, uspi->s_fpb, &err, NULL, NULL, bh_result->b_page)
ufs_inode_getfrag(inode, x, fragment, uspi->s_fpb, &err, NULL, NULL, NULL)
#define GET_INDIRECT_DATABLOCK(x) \
ufs_inode_getblock(inode, bh, x, fragment, \
&err, &phys, &new, bh_result->b_page);
&err, &phys, &new, bh_result->b_page)
#define GET_INDIRECT_PTR(x) \
ufs_inode_getblock(inode, bh, x, fragment, \
&err, NULL, NULL, bh_result->b_page);
&err, NULL, NULL, NULL)

if (ptr < UFS_NDIR_FRAGMENT) {
bh = GET_INODE_DATABLOCK(ptr);
Expand Down

0 comments on commit ba73bf7

Please sign in to comment.