Lines Matching refs:bucket

60 	/* The actual buffers that make up the bucket */
63 /* How many blocks make up one bucket for this filesystem */
121 struct ocfs2_xattr_bucket *bucket;
275 struct ocfs2_xattr_bucket *bucket,
297 struct ocfs2_xattr_bucket *bucket,
318 struct ocfs2_xattr_bucket *bucket;
323 bucket = kzalloc(sizeof(struct ocfs2_xattr_bucket), GFP_NOFS);
324 if (bucket) {
325 bucket->bu_inode = inode;
326 bucket->bu_blocks = blks;
329 return bucket;
332 static void ocfs2_xattr_bucket_relse(struct ocfs2_xattr_bucket *bucket)
336 for (i = 0; i < bucket->bu_blocks; i++) {
337 brelse(bucket->bu_bhs[i]);
338 bucket->bu_bhs[i] = NULL;
342 static void ocfs2_xattr_bucket_free(struct ocfs2_xattr_bucket *bucket)
344 if (bucket) {
345 ocfs2_xattr_bucket_relse(bucket);
346 bucket->bu_inode = NULL;
347 kfree(bucket);
352 * A bucket that has never been written to disk doesn't need to be
357 static int ocfs2_init_xattr_bucket(struct ocfs2_xattr_bucket *bucket,
362 for (i = 0; i < bucket->bu_blocks; i++) {
363 bucket->bu_bhs[i] = sb_getblk(bucket->bu_inode->i_sb,
365 if (!bucket->bu_bhs[i]) {
371 if (!ocfs2_buffer_uptodate(INODE_CACHE(bucket->bu_inode),
372 bucket->bu_bhs[i])) {
374 ocfs2_set_new_buffer_uptodate(INODE_CACHE(bucket->bu_inode),
375 bucket->bu_bhs[i]);
377 set_buffer_uptodate(bucket->bu_bhs[i]);
378 ocfs2_set_buffer_uptodate(INODE_CACHE(bucket->bu_inode),
379 bucket->bu_bhs[i]);
385 ocfs2_xattr_bucket_relse(bucket);
389 /* Read the xattr bucket at xb_blkno */
390 static int ocfs2_read_xattr_bucket(struct ocfs2_xattr_bucket *bucket,
395 rc = ocfs2_read_blocks(INODE_CACHE(bucket->bu_inode), xb_blkno,
396 bucket->bu_blocks, bucket->bu_bhs, 0,
399 spin_lock(&OCFS2_SB(bucket->bu_inode->i_sb)->osb_xattr_lock);
400 rc = ocfs2_validate_meta_ecc_bhs(bucket->bu_inode->i_sb,
401 bucket->bu_bhs,
402 bucket->bu_blocks,
403 &bucket_xh(bucket)->xh_check);
404 spin_unlock(&OCFS2_SB(bucket->bu_inode->i_sb)->osb_xattr_lock);
410 ocfs2_xattr_bucket_relse(bucket);
415 struct ocfs2_xattr_bucket *bucket,
420 for (i = 0; i < bucket->bu_blocks; i++) {
422 INODE_CACHE(bucket->bu_inode),
423 bucket->bu_bhs[i], type);
434 struct ocfs2_xattr_bucket *bucket)
438 spin_lock(&OCFS2_SB(bucket->bu_inode->i_sb)->osb_xattr_lock);
439 ocfs2_compute_meta_ecc_bhs(bucket->bu_inode->i_sb,
440 bucket->bu_bhs, bucket->bu_blocks,
441 &bucket_xh(bucket)->xh_check);
442 spin_unlock(&OCFS2_SB(bucket->bu_inode->i_sb)->osb_xattr_lock);
444 for (i = 0; i < bucket->bu_blocks; i++)
445 ocfs2_journal_dirty(handle, bucket->bu_bhs[i]);
652 * xattr bucket, otherwise reserve one metadata block
1219 xs->bucket = ocfs2_xattr_bucket_new(inode);
1220 if (!xs->bucket) {
1250 bucket_xh(xs->bucket),
1258 xs->base = bucket_block(xs->bucket, block_off);
1276 ocfs2_xattr_bucket_free(xs->bucket);
1710 struct ocfs2_xattr_bucket *bucket = loc->xl_storage;
1712 return ocfs2_xattr_bucket_journal_access(handle, bucket, type);
1718 struct ocfs2_xattr_bucket *bucket = loc->xl_storage;
1720 ocfs2_xattr_bucket_journal_dirty(handle, bucket);
1726 struct ocfs2_xattr_bucket *bucket = loc->xl_storage;
1729 /* The header is at the front of the bucket */
1733 return bucket_block(bucket, block) + block_offset;
1745 struct ocfs2_xattr_bucket *bucket = loc->xl_storage;
1746 return le16_to_cpu(bucket_xh(bucket)->xh_free_start);
1775 * reuse. They live as holes until the bucket fills, and then
1776 * the bucket is defragmented. However, the bucket can reclaim
1867 struct ocfs2_xattr_bucket *bucket = loc->xl_storage;
1876 /* We expect the bucket to be filled in */
1877 BUG_ON(!bucket->bu_bhs[block_offset]);
1880 vb->vb_bh = bucket->bu_bhs[block_offset];
1922 * transaction and open a new one. If this is a bucket, truncate
1924 * the caller is expecting to dirty the entire bucket. So we must
1949 * important for an empty bucket, as it keeps track of the
1950 * bucket's hash value. It doesn't hurt empty block storage.
2309 struct ocfs2_xattr_bucket *bucket,
2312 loc->xl_inode = bucket->bu_inode;
2314 loc->xl_storage = bucket;
2315 loc->xl_header = bucket_xh(bucket);
3097 bucket_xh(xbs->bucket),
3100 base = bucket_block(xbs->bucket, block_off);
3215 * This cluster will be used either for new bucket or for
3217 * If the cluster size is the same as the bucket size, one
3218 * more is needed since we may need to extend the bucket
3487 * In extreme situation, may need xattr bucket when
3489 * the credits for bucket in mknod.
3492 xbs.bucket = ocfs2_xattr_bucket_new(inode);
3493 if (!xbs.bucket) {
3518 ocfs2_xattr_bucket_free(xbs.bucket);
3567 * bucket.
3569 xbs.bucket = ocfs2_xattr_bucket_new(inode);
3570 if (!xbs.bucket) {
3678 ocfs2_xattr_bucket_free(xbs.bucket);
3748 struct ocfs2_xattr_bucket *bucket,
3752 struct ocfs2_xattr_bucket *bucket,
3760 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
3766 * We don't use binary search in the bucket because there
3794 xe_name = bucket_block(bucket, block_off) + new_offset;
3809 * The ocfs2_xattr_header.xh_num_buckets of the first bucket contains
3813 * hash is in the gap of 2 buckets, return the lower bucket.
3829 int low_bucket = 0, bucket, high_bucket;
3851 bucket = (low_bucket + high_bucket) / 2;
3852 blkno = p_blkno + bucket * blk_per_bucket;
3862 high_bucket = bucket - 1;
3868 * bucket is larger than the search one. for an empty
3869 * bucket, the last one is also the first one.
3878 low_bucket = bucket + 1;
3882 /* the searched xattr should reside in this bucket if exists. */
3894 * Record the bucket we have found.
3896 * always set it to the previous bucket.
3902 ret = ocfs2_read_xattr_bucket(xs->bucket, lower_blkno);
3908 xs->header = bucket_xh(xs->bucket);
3909 xs->base = bucket_block(xs->bucket, 0);
3916 (unsigned long long)bucket_blkno(xs->bucket),
3979 struct ocfs2_xattr_bucket *bucket;
3981 bucket = ocfs2_xattr_bucket_new(inode);
3982 if (!bucket) {
3991 for (i = 0; i < num_buckets; i++, blkno += bucket->bu_blocks) {
3992 ret = ocfs2_read_xattr_bucket(bucket, blkno);
3999 * The real bucket num in this series of blocks is stored
4000 * in the 1st bucket.
4003 num_buckets = le16_to_cpu(bucket_xh(bucket)->xh_num_buckets);
4006 le32_to_cpu(bucket_xh(bucket)->xh_entries[0].xe_name_hash));
4008 ret = func(inode, bucket, para);
4014 ocfs2_xattr_bucket_relse(bucket);
4019 ocfs2_xattr_bucket_free(bucket);
4049 struct ocfs2_xattr_bucket *bucket,
4057 for (i = 0 ; i < le16_to_cpu(bucket_xh(bucket)->xh_count); i++) {
4058 struct ocfs2_xattr_entry *entry = &bucket_xh(bucket)->xh_entries[i];
4062 bucket_xh(bucket),
4069 name = (const char *)bucket_block(bucket, block_off) +
4171 * When the ocfs2_xattr_block is filled up, new bucket will be created
4172 * and all the xattr entries will be moved to the new bucket.
4173 * The header goes at the start of the bucket, and the names+values are
4180 struct ocfs2_xattr_bucket *bucket)
4189 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
4192 char *target = bucket_block(bucket, blks - 1);
4196 (unsigned long long)bucket_blkno(bucket));
4199 memset(bucket_block(bucket, i), 0, blocksize);
4221 target = bucket_block(bucket, 0);
4243 * While if the entry is in index b-tree, "bucket" indicates the
4255 xs->header = bucket_xh(xs->bucket);
4256 xs->base = bucket_block(xs->bucket, 0);
4285 BUG_ON(!xs->bucket);
4309 * The bucket may spread in many blocks, and
4311 * in the whole bucket(one for entry and one for data).
4317 ret = ocfs2_init_xattr_bucket(xs->bucket, blkno, 1);
4323 ret = ocfs2_xattr_bucket_journal_access(handle, xs->bucket,
4330 ocfs2_cp_xattr_block_to_bucket(inode, xb_bh, xs->bucket);
4331 ocfs2_xattr_bucket_journal_dirty(handle, xs->bucket);
4374 * defrag a xattr bucket if we find that the bucket has some
4376 * We will move all the name/value pairs to the end of the bucket
4381 struct ocfs2_xattr_bucket *bucket)
4387 u64 blkno = bucket_blkno(bucket);
4405 for (i = 0; i < bucket->bu_blocks; i++, buf += blocksize)
4406 memcpy(buf, bucket_block(bucket, i), blocksize);
4408 ret = ocfs2_xattr_bucket_journal_access(handle, bucket,
4432 /* Move all name/values to the end of the bucket. */
4455 "bucket %llu\n", (unsigned long long)blkno);
4461 "bucket %llu\n", (unsigned long long)blkno);
4475 for (i = 0; i < bucket->bu_blocks; i++, buf += blocksize)
4476 memcpy(bucket_block(bucket, i), buf, blocksize);
4477 ocfs2_xattr_bucket_journal_dirty(handle, bucket);
4487 * clusters contains more than bucket, we can easily split one cluster
4488 * at a bucket boundary. So we take the last cluster of the existing
4494 * extent's bucket count. header_bh is the bucket were we were hoping
4495 * to insert our xattr. If the bucket move places the target in the new
4533 /* This is the first bucket that got moved */
4537 * If the target bucket was part of the moved buckets, we need to
4541 /* Find the block for the new target bucket */
4568 * Find the suitable pos when we divide a bucket into 2.
4570 * in the same bucket.
4610 * Move some xattrs in old bucket(blk) to new bucket(new_blk).
4611 * first_hash will record the 1st hash of the new bucket.
4615 * same bucket. If all the xattrs in this bucket have the same hash
4616 * value, the new bucket will be initialized as an empty one and the
4689 * initialized a new empty bucket here.
4691 * that of the last entry in the previous bucket.
4704 /* copy the whole bucket to the new first. */
4707 /* update the new bucket. */
4712 * the old bucket first.
4724 * Now begin the modification to the new bucket.
4726 * In the new bucket, We just move the xattr entry to the beginning
4728 * bucket, and they will be removed when ocfs2_defrag_xattr_bucket is
4744 /* Calculate xh_free_start for the new bucket. */
4762 /* store the first_hash of the new bucket. */
4767 * Now only update the 1st block of the old bucket. If we
4768 * just added a new empty bucket, there is no need to modify
4791 * Copy xattr from one bucket to another bucket.
4842 * how we get here, and the bucket isn't really new.
4890 /* The first bucket of the original extent */
4892 /* The first bucket of the new extent */
4907 * We need to update the first bucket of the old extent and all
4936 * Get the new bucket ready before we dirty anything
4970 * This function should only be called when bucket size == cluster size.
4990 /* Move half of the xattr in start_blk to the next bucket. */
5004 * to extend the insert bucket.
5008 * 1. If cluster size > bucket size, that means the previous cluster has more
5009 * than 1 bucket, so just move half nums of bucket into the new cluster and
5010 * update the first_bh and header_bh if the insert bucket has been moved
5086 * indicates the bucket we will insert the new xattrs. They will be updated
5179 * We are given an extent. 'first' is the bucket at the very front of
5180 * the extent. The extent has space for an additional bucket past
5182 * of the target bucket. We wish to shift every bucket past the target
5184 * target, we split the target between itself and the now-empty bucket
5203 /* The extent must have room for an additional bucket */
5207 /* end_blk points to the last existing bucket */
5211 * end_blk is the start of the last existing bucket.
5212 * Thus, (end_blk - target_blk) covers the target bucket and
5213 * every bucket after it up to, but not including, the last
5214 * existing bucket. Then we add the last existing bucket, the
5215 * new bucket, and the first bucket (3 * blk_per_bucket).
5239 /* Move half of the xattr in target_blkno to the next bucket. */
5251 * Add new xattr bucket in an extent record and adjust the buckets
5253 * bucket we want to insert into.
5256 * one. Half of target's xattrs will be moved to the next bucket.
5278 /* The bucket at the front of the extent */
5284 /* The first bucket of the original extent */
5308 * This can move first+target if the target bucket moves
5342 * Truncate the specified xe_off entry in xattr bucket.
5343 * bucket is indicated by header_bh and len is the new length.
5349 struct ocfs2_xattr_bucket *bucket,
5357 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
5375 vb.vb_bh = bucket->bu_bhs[value_blk];
5382 * From here on out we have to dirty the bucket. The generic
5383 * value calls only modify one of the bucket's bhs, but we need
5384 * to send the bucket at once. So if they error, they *could* have
5386 * the whole bucket. This leaves us in a consistent state.
5389 (unsigned long long)bucket_blkno(bucket), xe_off, len);
5396 ret = ocfs2_xattr_bucket_journal_access(ctxt->handle, bucket,
5405 ocfs2_xattr_bucket_journal_dirty(ctxt->handle, bucket);
5507 * check whether the xattr bucket is filled up with the same hash value.
5513 struct ocfs2_xattr_bucket *bucket,
5516 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
5524 mlog(ML_ERROR, "Too much hash collision in xattr bucket %llu, "
5526 (unsigned long long)bucket_blkno(bucket),
5535 * Try to set the entry in the current bucket. If we fail, the caller
5536 * will handle getting us another bucket.
5548 ocfs2_init_xattr_bucket_xa_loc(&loc, xs->bucket,
5560 /* Ok, we need space. Let's try defragmenting the bucket. */
5562 xs->bucket);
5598 /* Ack, need more space. Let's try to get another bucket! */
5603 * one bucket's worth, so check it here whether we need to
5604 * add a new bucket for the insert.
5607 xs->bucket,
5616 xs->bucket,
5625 * xs->bucket if it moved, but it will not have updated
5630 ocfs2_xattr_bucket_relse(xs->bucket);
5638 /* Ok, we have a new bucket, let's try again */
5648 struct ocfs2_xattr_bucket *bucket,
5652 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
5670 ret = ocfs2_get_xattr_tree_value_root(inode->i_sb, bucket,
5690 ret = ocfs2_xattr_bucket_value_truncate(inode, bucket,
5712 * Whenever we modify a xattr value root in the bucket(e.g, CoW
5714 * the metaecc for the whole bucket. So it is done here.
5724 struct ocfs2_xattr_bucket *bucket =
5727 ret = ocfs2_xattr_bucket_journal_access(handle, bucket,
5734 ocfs2_xattr_bucket_journal_dirty(handle, bucket);
5770 struct ocfs2_xattr_bucket *bucket = NULL;
5793 bucket_xh(xbs->bucket),
5800 base = bucket_block(xbs->bucket, block_off);
5801 vb.vb_bh = xbs->bucket->bu_bhs[block_off];
5806 bucket = xbs->bucket;
5807 refcount.credits = bucket->bu_blocks;
5808 refcount.para = bucket;
5995 struct ocfs2_xattr_bucket *bucket,
6001 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
6006 bucket_xh(bucket),
6015 base = bucket_block(bucket, block_off);
6021 *bh = bucket->bu_bhs[block_off];
6027 * For a given xattr bucket, refcount all the entries which
6031 struct ocfs2_xattr_bucket *bucket,
6039 (struct ocfs2_xattr_header *)bucket->bu_bhs[0]->b_data;
6045 .credits = bucket->bu_blocks,
6046 .para = bucket,
6056 (unsigned long long)bucket_blkno(bucket),
6064 ret = ocfs2_get_xattr_tree_value_root(inode->i_sb, bucket, i,
6323 * It can be used for inode, block and bucket.
6663 * We have to handle the case that both old bucket and new bucket
6677 struct ocfs2_xattr_bucket *bucket;
6680 bucket = args->old_bucket;
6682 bucket = args->new_bucket;
6684 return ocfs2_get_xattr_tree_value_root(sb, bucket, offset,
6702 struct ocfs2_xattr_bucket *bucket =
6705 return ocfs2_get_xattr_tree_value_root(sb, bucket, offset,
6710 struct ocfs2_xattr_bucket *bucket,
6716 (struct ocfs2_xattr_header *)bucket->bu_bhs[0]->b_data;
6718 /* Add the credits for this bucket first. */
6719 metas->credits += bucket->bu_blocks;
6720 return ocfs2_value_metas_in_xattr_header(inode->i_sb, bucket->bu_bhs[0],
6724 bucket);
6861 * bucket.
6886 * Re-access and dirty the bucket to calculate metaecc.
7035 * We will add bucket one by one, and refcount all the xattrs in the bucket