struct buffer_head *root_bh;
struct ocfs2_extent_list *root_el;
void *private;
+ unsigned int max_leaf_clusters;
};
static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et,
};
static struct ocfs2_extent_tree*
- ocfs2_new_extent_tree(struct buffer_head *bh,
+ ocfs2_new_extent_tree(struct inode *inode,
+ struct buffer_head *bh,
enum ocfs2_extent_tree_type et_type,
void *private)
{
(struct ocfs2_xattr_block *)bh->b_data;
et->root_el = &xb->xb_attrs.xb_root.xt_list;
et->eops = &ocfs2_xattr_tree_et_ops;
+ et->max_leaf_clusters = ocfs2_clusters_for_bytes(inode->i_sb,
+ OCFS2_MAX_XATTR_TREE_LEAF_SIZE);
}
return et;
static void ocfs2_figure_contig_type(struct inode *inode,
struct ocfs2_insert_type *insert,
struct ocfs2_extent_list *el,
- struct ocfs2_extent_rec *insert_rec)
+ struct ocfs2_extent_rec *insert_rec,
+ struct ocfs2_extent_tree *et)
{
int i;
enum ocfs2_contig_type contig_type = CONTIG_NONE;
}
}
insert->ins_contig = contig_type;
+
+ if (insert->ins_contig != CONTIG_NONE) {
+ struct ocfs2_extent_rec *rec =
+ &el->l_recs[insert->ins_contig_index];
+ unsigned int len = le16_to_cpu(rec->e_leaf_clusters) +
+ le16_to_cpu(insert_rec->e_leaf_clusters);
+
+ /*
+ * Caller might want us to limit the size of extents, don't
+ * calculate contiguousness if we might exceed that limit.
+ */
+ if (et->max_leaf_clusters && len > et->max_leaf_clusters)
+ insert->ins_contig = CONTIG_NONE;
+ }
}
/*
le16_to_cpu(el->l_next_free_rec);
if (!insert->ins_tree_depth) {
- ocfs2_figure_contig_type(inode, insert, el, insert_rec);
+ ocfs2_figure_contig_type(inode, insert, el, insert_rec, et);
ocfs2_figure_appending_type(insert, el, insert_rec);
return 0;
}
* into two types of appends: simple record append, or a
* rotate inside the tail leaf.
*/
- ocfs2_figure_contig_type(inode, insert, el, insert_rec);
+ ocfs2_figure_contig_type(inode, insert, el, insert_rec, et);
/*
* The insert code isn't quite ready to deal with all cases of
int status;
struct ocfs2_extent_tree *et = NULL;
- et = ocfs2_new_extent_tree(root_bh, OCFS2_DINODE_EXTENT, NULL);
+ et = ocfs2_new_extent_tree(inode, root_bh, OCFS2_DINODE_EXTENT, NULL);
if (!et) {
status = -ENOMEM;
mlog_errno(status);
int status;
struct ocfs2_extent_tree *et = NULL;
- et = ocfs2_new_extent_tree(root_bh, OCFS2_XATTR_VALUE_EXTENT, private);
+ et = ocfs2_new_extent_tree(inode, root_bh,
+ OCFS2_XATTR_VALUE_EXTENT, private);
if (!et) {
status = -ENOMEM;
mlog_errno(status);
int status;
struct ocfs2_extent_tree *et = NULL;
- et = ocfs2_new_extent_tree(root_bh, OCFS2_XATTR_TREE_EXTENT, NULL);
+ et = ocfs2_new_extent_tree(inode, root_bh, OCFS2_XATTR_TREE_EXTENT,
+ NULL);
if (!et) {
status = -ENOMEM;
mlog_errno(status);
goto out;
}
- et = ocfs2_new_extent_tree(root_bh, et_type, private);
+ et = ocfs2_new_extent_tree(inode, root_bh, et_type, private);
if (!et) {
ret = -ENOMEM;
mlog_errno(ret);
struct ocfs2_path *path = NULL;
struct ocfs2_extent_tree *et = NULL;
- et = ocfs2_new_extent_tree(root_bh, et_type, private);
+ et = ocfs2_new_extent_tree(inode, root_bh, et_type, private);
if (!et) {
ret = -ENOMEM;
mlog_errno(ret);