Commit 1ed9b777 authored by Joel Becker's avatar Joel Becker Committed by Tao Ma

ocfs2: ocfs2_claim_*() don't need an ocfs2_super argument.

They all take an ocfs2_alloc_context, which has the allocation inode.
Signed-off-by: default avatarJoel Becker <joel.becker@oracle.com>
Signed-off-by: default avatarTao Ma <tao.ma@oracle.com>
parent 13e434cf
...@@ -1015,8 +1015,7 @@ static int ocfs2_create_new_meta_bhs(handle_t *handle, ...@@ -1015,8 +1015,7 @@ static int ocfs2_create_new_meta_bhs(handle_t *handle,
count = 0; count = 0;
while (count < wanted) { while (count < wanted) {
status = ocfs2_claim_metadata(osb, status = ocfs2_claim_metadata(handle,
handle,
meta_ac, meta_ac,
wanted - count, wanted - count,
&suballoc_bit_start, &suballoc_bit_start,
...@@ -4786,7 +4785,7 @@ int ocfs2_add_clusters_in_btree(handle_t *handle, ...@@ -4786,7 +4785,7 @@ int ocfs2_add_clusters_in_btree(handle_t *handle,
goto leave; goto leave;
} }
status = __ocfs2_claim_clusters(osb, handle, data_ac, 1, status = __ocfs2_claim_clusters(handle, data_ac, 1,
clusters_to_add, &bit_off, &num_bits); clusters_to_add, &bit_off, &num_bits);
if (status < 0) { if (status < 0) {
if (status != -ENOSPC) if (status != -ENOSPC)
...@@ -7201,7 +7200,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, ...@@ -7201,7 +7200,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
data_ac->ac_resv = &OCFS2_I(inode)->ip_la_data_resv; data_ac->ac_resv = &OCFS2_I(inode)->ip_la_data_resv;
ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, ret = ocfs2_claim_clusters(handle, data_ac, 1, &bit_off,
&num); &num);
if (ret) { if (ret) {
mlog_errno(ret); mlog_errno(ret);
......
...@@ -2402,7 +2402,7 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb, ...@@ -2402,7 +2402,7 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb,
struct ocfs2_dir_block_trailer *trailer = struct ocfs2_dir_block_trailer *trailer =
ocfs2_trailer_from_bh(dirdata_bh, dir->i_sb); ocfs2_trailer_from_bh(dirdata_bh, dir->i_sb);
ret = ocfs2_claim_metadata(osb, handle, meta_ac, 1, &dr_suballoc_bit, ret = ocfs2_claim_metadata(handle, meta_ac, 1, &dr_suballoc_bit,
&num_bits, &dr_blkno); &num_bits, &dr_blkno);
if (ret) { if (ret) {
mlog_errno(ret); mlog_errno(ret);
...@@ -2544,7 +2544,7 @@ static int __ocfs2_dx_dir_new_cluster(struct inode *dir, ...@@ -2544,7 +2544,7 @@ static int __ocfs2_dx_dir_new_cluster(struct inode *dir,
* chance of contiguousness as the directory grows in number * chance of contiguousness as the directory grows in number
* of entries. * of entries.
*/ */
ret = __ocfs2_claim_clusters(osb, handle, data_ac, 1, 1, &phys, &num); ret = __ocfs2_claim_clusters(handle, data_ac, 1, 1, &phys, &num);
if (ret) { if (ret) {
mlog_errno(ret); mlog_errno(ret);
goto out; goto out;
...@@ -2979,7 +2979,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh, ...@@ -2979,7 +2979,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
*/ */
if (ocfs2_dir_resv_allowed(osb)) if (ocfs2_dir_resv_allowed(osb))
data_ac->ac_resv = &oi->ip_la_data_resv; data_ac->ac_resv = &oi->ip_la_data_resv;
ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, &len); ret = ocfs2_claim_clusters(handle, data_ac, 1, &bit_off, &len);
if (ret) { if (ret) {
mlog_errno(ret); mlog_errno(ret);
goto out_commit; goto out_commit;
...@@ -3118,7 +3118,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh, ...@@ -3118,7 +3118,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
* pass. Claim the 2nd cluster as a separate extent. * pass. Claim the 2nd cluster as a separate extent.
*/ */
if (alloc > len) { if (alloc > len) {
ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, ret = ocfs2_claim_clusters(handle, data_ac, 1, &bit_off,
&len); &len);
if (ret) { if (ret) {
mlog_errno(ret); mlog_errno(ret);
......
...@@ -1161,7 +1161,7 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, ...@@ -1161,7 +1161,7 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
/* we used the generic suballoc reserve function, but we set /* we used the generic suballoc reserve function, but we set
* everything up nicely, so there's no reason why we can't use * everything up nicely, so there's no reason why we can't use
* the more specific cluster api to claim bits. */ * the more specific cluster api to claim bits. */
status = ocfs2_claim_clusters(osb, handle, ac, osb->local_alloc_bits, status = ocfs2_claim_clusters(handle, ac, osb->local_alloc_bits,
&cluster_off, &cluster_count); &cluster_off, &cluster_count);
if (status == -ENOSPC) { if (status == -ENOSPC) {
retry_enospc: retry_enospc:
...@@ -1175,7 +1175,7 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, ...@@ -1175,7 +1175,7 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
goto bail; goto bail;
ac->ac_bits_wanted = osb->local_alloc_default_bits; ac->ac_bits_wanted = osb->local_alloc_default_bits;
status = ocfs2_claim_clusters(osb, handle, ac, status = ocfs2_claim_clusters(handle, ac,
osb->local_alloc_bits, osb->local_alloc_bits,
&cluster_off, &cluster_off,
&cluster_count); &cluster_count);
......
...@@ -478,7 +478,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, ...@@ -478,7 +478,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
*new_fe_bh = NULL; *new_fe_bh = NULL;
status = ocfs2_claim_new_inode(osb, handle, dir, parent_fe_bh, status = ocfs2_claim_new_inode(handle, dir, parent_fe_bh,
inode_ac, &suballoc_bit, &fe_blkno); inode_ac, &suballoc_bit, &fe_blkno);
if (status < 0) { if (status < 0) {
mlog_errno(status); mlog_errno(status);
......
...@@ -597,7 +597,7 @@ static int ocfs2_create_refcount_tree(struct inode *inode, ...@@ -597,7 +597,7 @@ static int ocfs2_create_refcount_tree(struct inode *inode,
goto out_commit; goto out_commit;
} }
ret = ocfs2_claim_metadata(osb, handle, meta_ac, 1, ret = ocfs2_claim_metadata(handle, meta_ac, 1,
&suballoc_bit_start, &num_got, &suballoc_bit_start, &num_got,
&first_blkno); &first_blkno);
if (ret) { if (ret) {
...@@ -1297,7 +1297,7 @@ static int ocfs2_expand_inline_ref_root(handle_t *handle, ...@@ -1297,7 +1297,7 @@ static int ocfs2_expand_inline_ref_root(handle_t *handle,
goto out; goto out;
} }
ret = ocfs2_claim_metadata(OCFS2_SB(sb), handle, meta_ac, 1, ret = ocfs2_claim_metadata(handle, meta_ac, 1,
&suballoc_bit_start, &num_got, &suballoc_bit_start, &num_got,
&blkno); &blkno);
if (ret) { if (ret) {
...@@ -1547,7 +1547,7 @@ static int ocfs2_new_leaf_refcount_block(handle_t *handle, ...@@ -1547,7 +1547,7 @@ static int ocfs2_new_leaf_refcount_block(handle_t *handle,
goto out; goto out;
} }
ret = ocfs2_claim_metadata(OCFS2_SB(sb), handle, meta_ac, 1, ret = ocfs2_claim_metadata(handle, meta_ac, 1,
&suballoc_bit_start, &num_got, &suballoc_bit_start, &num_got,
&blkno); &blkno);
if (ret) { if (ret) {
...@@ -3271,7 +3271,7 @@ static int ocfs2_make_clusters_writable(struct super_block *sb, ...@@ -3271,7 +3271,7 @@ static int ocfs2_make_clusters_writable(struct super_block *sb,
} else { } else {
delete = 1; delete = 1;
ret = __ocfs2_claim_clusters(osb, handle, ret = __ocfs2_claim_clusters(handle,
context->data_ac, context->data_ac,
1, set_len, 1, set_len,
&new_bit, &new_len); &new_bit, &new_len);
......
...@@ -439,7 +439,7 @@ ocfs2_block_group_alloc_contig(struct ocfs2_super *osb, handle_t *handle, ...@@ -439,7 +439,7 @@ ocfs2_block_group_alloc_contig(struct ocfs2_super *osb, handle_t *handle,
struct buffer_head *bg_bh; struct buffer_head *bg_bh;
unsigned int alloc_rec = ocfs2_find_smallest_chain(cl); unsigned int alloc_rec = ocfs2_find_smallest_chain(cl);
status = ocfs2_claim_clusters(osb, handle, ac, status = ocfs2_claim_clusters(handle, ac,
le16_to_cpu(cl->cl_cpg), &bit_off, le16_to_cpu(cl->cl_cpg), &bit_off,
&num_bits); &num_bits);
if (status < 0) { if (status < 0) {
...@@ -481,7 +481,7 @@ static int ocfs2_block_group_claim_bits(struct ocfs2_super *osb, ...@@ -481,7 +481,7 @@ static int ocfs2_block_group_claim_bits(struct ocfs2_super *osb,
int status; int status;
while (min_bits) { while (min_bits) {
status = ocfs2_claim_clusters(osb, handle, ac, min_bits, status = ocfs2_claim_clusters(handle, ac, min_bits,
bit_off, num_bits); bit_off, num_bits);
if (status != -ENOSPC) if (status != -ENOSPC)
break; break;
...@@ -1919,8 +1919,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, ...@@ -1919,8 +1919,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
return status; return status;
} }
int ocfs2_claim_metadata(struct ocfs2_super *osb, int ocfs2_claim_metadata(handle_t *handle,
handle_t *handle,
struct ocfs2_alloc_context *ac, struct ocfs2_alloc_context *ac,
u32 bits_wanted, u32 bits_wanted,
u16 *suballoc_bit_start, u16 *suballoc_bit_start,
...@@ -1943,7 +1942,7 @@ int ocfs2_claim_metadata(struct ocfs2_super *osb, ...@@ -1943,7 +1942,7 @@ int ocfs2_claim_metadata(struct ocfs2_super *osb,
mlog_errno(status); mlog_errno(status);
goto bail; goto bail;
} }
atomic_inc(&osb->alloc_stats.bg_allocs); atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
*suballoc_bit_start = res.sr_bit_offset; *suballoc_bit_start = res.sr_bit_offset;
*blkno_start = res.sr_bg_blkno + (u64)(res.sr_bit_offset); *blkno_start = res.sr_bg_blkno + (u64)(res.sr_bit_offset);
...@@ -1986,8 +1985,7 @@ static inline void ocfs2_save_inode_ac_group(struct inode *dir, ...@@ -1986,8 +1985,7 @@ static inline void ocfs2_save_inode_ac_group(struct inode *dir,
OCFS2_I(dir)->ip_last_used_slot = ac->ac_alloc_slot; OCFS2_I(dir)->ip_last_used_slot = ac->ac_alloc_slot;
} }
int ocfs2_claim_new_inode(struct ocfs2_super *osb, int ocfs2_claim_new_inode(handle_t *handle,
handle_t *handle,
struct inode *dir, struct inode *dir,
struct buffer_head *parent_fe_bh, struct buffer_head *parent_fe_bh,
struct ocfs2_alloc_context *ac, struct ocfs2_alloc_context *ac,
...@@ -2015,7 +2013,7 @@ int ocfs2_claim_new_inode(struct ocfs2_super *osb, ...@@ -2015,7 +2013,7 @@ int ocfs2_claim_new_inode(struct ocfs2_super *osb,
mlog_errno(status); mlog_errno(status);
goto bail; goto bail;
} }
atomic_inc(&osb->alloc_stats.bg_allocs); atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
BUG_ON(res.sr_bits != 1); BUG_ON(res.sr_bits != 1);
...@@ -2090,8 +2088,7 @@ static inline void ocfs2_block_to_cluster_group(struct inode *inode, ...@@ -2090,8 +2088,7 @@ static inline void ocfs2_block_to_cluster_group(struct inode *inode,
* contig. allocation, set to '1' to indicate we can deal with extents * contig. allocation, set to '1' to indicate we can deal with extents
* of any size. * of any size.
*/ */
int __ocfs2_claim_clusters(struct ocfs2_super *osb, int __ocfs2_claim_clusters(handle_t *handle,
handle_t *handle,
struct ocfs2_alloc_context *ac, struct ocfs2_alloc_context *ac,
u32 min_clusters, u32 min_clusters,
u32 max_clusters, u32 max_clusters,
...@@ -2101,6 +2098,7 @@ int __ocfs2_claim_clusters(struct ocfs2_super *osb, ...@@ -2101,6 +2098,7 @@ int __ocfs2_claim_clusters(struct ocfs2_super *osb,
int status; int status;
unsigned int bits_wanted = max_clusters; unsigned int bits_wanted = max_clusters;
struct ocfs2_suballoc_result res; struct ocfs2_suballoc_result res;
struct ocfs2_super *osb = OCFS2_SB(ac->ac_inode->i_sb);
mlog_entry_void(); mlog_entry_void();
...@@ -2161,8 +2159,7 @@ int __ocfs2_claim_clusters(struct ocfs2_super *osb, ...@@ -2161,8 +2159,7 @@ int __ocfs2_claim_clusters(struct ocfs2_super *osb,
return status; return status;
} }
int ocfs2_claim_clusters(struct ocfs2_super *osb, int ocfs2_claim_clusters(handle_t *handle,
handle_t *handle,
struct ocfs2_alloc_context *ac, struct ocfs2_alloc_context *ac,
u32 min_clusters, u32 min_clusters,
u32 *cluster_start, u32 *cluster_start,
...@@ -2170,7 +2167,7 @@ int ocfs2_claim_clusters(struct ocfs2_super *osb, ...@@ -2170,7 +2167,7 @@ int ocfs2_claim_clusters(struct ocfs2_super *osb,
{ {
unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given; unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given;
return __ocfs2_claim_clusters(osb, handle, ac, min_clusters, return __ocfs2_claim_clusters(handle, ac, min_clusters,
bits_wanted, cluster_start, num_clusters); bits_wanted, cluster_start, num_clusters);
} }
......
...@@ -83,22 +83,19 @@ int ocfs2_reserve_clusters(struct ocfs2_super *osb, ...@@ -83,22 +83,19 @@ int ocfs2_reserve_clusters(struct ocfs2_super *osb,
u32 bits_wanted, u32 bits_wanted,
struct ocfs2_alloc_context **ac); struct ocfs2_alloc_context **ac);
int ocfs2_claim_metadata(struct ocfs2_super *osb, int ocfs2_claim_metadata(handle_t *handle,
handle_t *handle,
struct ocfs2_alloc_context *ac, struct ocfs2_alloc_context *ac,
u32 bits_wanted, u32 bits_wanted,
u16 *suballoc_bit_start, u16 *suballoc_bit_start,
u32 *num_bits, u32 *num_bits,
u64 *blkno_start); u64 *blkno_start);
int ocfs2_claim_new_inode(struct ocfs2_super *osb, int ocfs2_claim_new_inode(handle_t *handle,
handle_t *handle,
struct inode *dir, struct inode *dir,
struct buffer_head *parent_fe_bh, struct buffer_head *parent_fe_bh,
struct ocfs2_alloc_context *ac, struct ocfs2_alloc_context *ac,
u16 *suballoc_bit, u16 *suballoc_bit,
u64 *fe_blkno); u64 *fe_blkno);
int ocfs2_claim_clusters(struct ocfs2_super *osb, int ocfs2_claim_clusters(handle_t *handle,
handle_t *handle,
struct ocfs2_alloc_context *ac, struct ocfs2_alloc_context *ac,
u32 min_clusters, u32 min_clusters,
u32 *cluster_start, u32 *cluster_start,
...@@ -107,8 +104,7 @@ int ocfs2_claim_clusters(struct ocfs2_super *osb, ...@@ -107,8 +104,7 @@ int ocfs2_claim_clusters(struct ocfs2_super *osb,
* Use this variant of ocfs2_claim_clusters to specify a maxiumum * Use this variant of ocfs2_claim_clusters to specify a maxiumum
* number of clusters smaller than the allocation reserved. * number of clusters smaller than the allocation reserved.
*/ */
int __ocfs2_claim_clusters(struct ocfs2_super *osb, int __ocfs2_claim_clusters(handle_t *handle,
handle_t *handle,
struct ocfs2_alloc_context *ac, struct ocfs2_alloc_context *ac,
u32 min_clusters, u32 min_clusters,
u32 max_clusters, u32 max_clusters,
......
...@@ -2831,7 +2831,6 @@ static int ocfs2_create_xattr_block(struct inode *inode, ...@@ -2831,7 +2831,6 @@ static int ocfs2_create_xattr_block(struct inode *inode,
u32 num_got; u32 num_got;
u64 first_blkno; u64 first_blkno;
struct ocfs2_dinode *di = (struct ocfs2_dinode *)inode_bh->b_data; struct ocfs2_dinode *di = (struct ocfs2_dinode *)inode_bh->b_data;
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
struct buffer_head *new_bh = NULL; struct buffer_head *new_bh = NULL;
struct ocfs2_xattr_block *xblk; struct ocfs2_xattr_block *xblk;
...@@ -2842,7 +2841,7 @@ static int ocfs2_create_xattr_block(struct inode *inode, ...@@ -2842,7 +2841,7 @@ static int ocfs2_create_xattr_block(struct inode *inode,
goto end; goto end;
} }
ret = ocfs2_claim_metadata(osb, ctxt->handle, ctxt->meta_ac, 1, ret = ocfs2_claim_metadata(ctxt->handle, ctxt->meta_ac, 1,
&suballoc_bit_start, &num_got, &suballoc_bit_start, &num_got,
&first_blkno); &first_blkno);
if (ret < 0) { if (ret < 0) {
...@@ -2867,7 +2866,8 @@ static int ocfs2_create_xattr_block(struct inode *inode, ...@@ -2867,7 +2866,8 @@ static int ocfs2_create_xattr_block(struct inode *inode,
strcpy((void *)xblk, OCFS2_XATTR_BLOCK_SIGNATURE); strcpy((void *)xblk, OCFS2_XATTR_BLOCK_SIGNATURE);
xblk->xb_suballoc_slot = cpu_to_le16(ctxt->meta_ac->ac_alloc_slot); xblk->xb_suballoc_slot = cpu_to_le16(ctxt->meta_ac->ac_alloc_slot);
xblk->xb_suballoc_bit = cpu_to_le16(suballoc_bit_start); xblk->xb_suballoc_bit = cpu_to_le16(suballoc_bit_start);
xblk->xb_fs_generation = cpu_to_le32(osb->fs_generation); xblk->xb_fs_generation =
cpu_to_le32(OCFS2_SB(inode->i_sb)->fs_generation);
xblk->xb_blkno = cpu_to_le64(first_blkno); xblk->xb_blkno = cpu_to_le64(first_blkno);
if (indexed) { if (indexed) {
struct ocfs2_xattr_tree_root *xr = &xblk->xb_attrs.xb_root; struct ocfs2_xattr_tree_root *xr = &xblk->xb_attrs.xb_root;
...@@ -4229,7 +4229,6 @@ static int ocfs2_xattr_create_index_block(struct inode *inode, ...@@ -4229,7 +4229,6 @@ static int ocfs2_xattr_create_index_block(struct inode *inode,
u32 bit_off, len; u32 bit_off, len;
u64 blkno; u64 blkno;
handle_t *handle = ctxt->handle; handle_t *handle = ctxt->handle;
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
struct ocfs2_inode_info *oi = OCFS2_I(inode); struct ocfs2_inode_info *oi = OCFS2_I(inode);
struct buffer_head *xb_bh = xs->xattr_bh; struct buffer_head *xb_bh = xs->xattr_bh;
struct ocfs2_xattr_block *xb = struct ocfs2_xattr_block *xb =
...@@ -4257,7 +4256,7 @@ static int ocfs2_xattr_create_index_block(struct inode *inode, ...@@ -4257,7 +4256,7 @@ static int ocfs2_xattr_create_index_block(struct inode *inode,
goto out; goto out;
} }
ret = __ocfs2_claim_clusters(osb, handle, ctxt->data_ac, ret = __ocfs2_claim_clusters(handle, ctxt->data_ac,
1, 1, &bit_off, &len); 1, 1, &bit_off, &len);
if (ret) { if (ret) {
mlog_errno(ret); mlog_errno(ret);
...@@ -5078,7 +5077,7 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode, ...@@ -5078,7 +5077,7 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode,
goto leave; goto leave;
} }
ret = __ocfs2_claim_clusters(osb, handle, ctxt->data_ac, 1, ret = __ocfs2_claim_clusters(handle, ctxt->data_ac, 1,
clusters_to_add, &bit_off, &num_bits); clusters_to_add, &bit_off, &num_bits);
if (ret < 0) { if (ret < 0) {
if (ret != -ENOSPC) if (ret != -ENOSPC)
...@@ -6906,7 +6905,7 @@ static int ocfs2_reflink_xattr_rec(struct inode *inode, ...@@ -6906,7 +6905,7 @@ static int ocfs2_reflink_xattr_rec(struct inode *inode,
goto out; goto out;
} }
ret = ocfs2_claim_clusters(osb, handle, data_ac, ret = ocfs2_claim_clusters(handle, data_ac,
len, &p_cluster, &num_clusters); len, &p_cluster, &num_clusters);
if (ret) { if (ret) {
mlog_errno(ret); mlog_errno(ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment