Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140302
b: refs/heads/master
c: 1382115
h: refs/heads/master
v: v3
  • Loading branch information
Tao Ma authored and Mark Fasheh committed Apr 3, 2009
1 parent cc640d9 commit 720c38b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 3 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: 1d46dc08d33138c29c63d717807c08ab704fc773
refs/heads/master: 138211515c102807a16c02fdc15feef1f6ef8124
2 changes: 2 additions & 0 deletions trunk/fs/ocfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,

ocfs2_set_inode_flags(inode);

OCFS2_I(inode)->ip_last_used_slot = 0;
OCFS2_I(inode)->ip_last_used_group = 0;
mlog_exit_void();
}

Expand Down
4 changes: 4 additions & 0 deletions trunk/fs/ocfs2/inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ struct ocfs2_inode_info

struct inode vfs_inode;
struct jbd2_inode ip_jinode;

/* Only valid if the inode is the dir. */
u32 ip_last_used_slot;
u64 ip_last_used_group;
};

/*
Expand Down
4 changes: 2 additions & 2 deletions trunk/fs/ocfs2/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,

*new_fe_bh = NULL;

status = ocfs2_claim_new_inode(osb, handle, inode_ac, &suballoc_bit,
&fe_blkno);
status = ocfs2_claim_new_inode(osb, handle, dir, parent_fe_bh,
inode_ac, &suballoc_bit, &fe_blkno);
if (status < 0) {
mlog_errno(status);
goto leave;
Expand Down
36 changes: 36 additions & 0 deletions trunk/fs/ocfs2/suballoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1618,8 +1618,41 @@ int ocfs2_claim_metadata(struct ocfs2_super *osb,
return status;
}

static void ocfs2_init_inode_ac_group(struct inode *dir,
struct buffer_head *parent_fe_bh,
struct ocfs2_alloc_context *ac)
{
struct ocfs2_dinode *fe = (struct ocfs2_dinode *)parent_fe_bh->b_data;
/*
* Try to allocate inodes from some specific group.
*
* If the parent dir has recorded the last group used in allocation,
* cool, use it. Otherwise if we try to allocate new inode from the
* same slot the parent dir belongs to, use the same chunk.
*
* We are very careful here to avoid the mistake of setting
* ac_last_group to a group descriptor from a different (unlocked) slot.
*/
if (OCFS2_I(dir)->ip_last_used_group &&
OCFS2_I(dir)->ip_last_used_slot == ac->ac_alloc_slot)
ac->ac_last_group = OCFS2_I(dir)->ip_last_used_group;
else if (le16_to_cpu(fe->i_suballoc_slot) == ac->ac_alloc_slot)
ac->ac_last_group = ocfs2_which_suballoc_group(
le64_to_cpu(fe->i_blkno),
le16_to_cpu(fe->i_suballoc_bit));
}

static inline void ocfs2_save_inode_ac_group(struct inode *dir,
struct ocfs2_alloc_context *ac)
{
OCFS2_I(dir)->ip_last_used_group = ac->ac_last_group;
OCFS2_I(dir)->ip_last_used_slot = ac->ac_alloc_slot;
}

int ocfs2_claim_new_inode(struct ocfs2_super *osb,
handle_t *handle,
struct inode *dir,
struct buffer_head *parent_fe_bh,
struct ocfs2_alloc_context *ac,
u16 *suballoc_bit,
u64 *fe_blkno)
Expand All @@ -1635,6 +1668,8 @@ int ocfs2_claim_new_inode(struct ocfs2_super *osb,
BUG_ON(ac->ac_bits_wanted != 1);
BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE);

ocfs2_init_inode_ac_group(dir, parent_fe_bh, ac);

status = ocfs2_claim_suballoc_bits(osb,
ac,
handle,
Expand All @@ -1653,6 +1688,7 @@ int ocfs2_claim_new_inode(struct ocfs2_super *osb,

*fe_blkno = bg_blkno + (u64) (*suballoc_bit);
ac->ac_bits_given++;
ocfs2_save_inode_ac_group(dir, ac);
status = 0;
bail:
mlog_exit(status);
Expand Down
2 changes: 2 additions & 0 deletions trunk/fs/ocfs2/suballoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ int ocfs2_claim_metadata(struct ocfs2_super *osb,
u64 *blkno_start);
int ocfs2_claim_new_inode(struct ocfs2_super *osb,
handle_t *handle,
struct inode *dir,
struct buffer_head *parent_fe_bh,
struct ocfs2_alloc_context *ac,
u16 *suballoc_bit,
u64 *fe_blkno);
Expand Down

0 comments on commit 720c38b

Please sign in to comment.