Lines Matching defs: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.
2308 struct ocfs2_xattr_bucket *bucket,
2311 loc->xl_inode = bucket->bu_inode;
2313 loc->xl_storage = bucket;
2314 loc->xl_header = bucket_xh(bucket);
3096 bucket_xh(xbs->bucket),
3099 base = bucket_block(xbs->bucket, block_off);
3214 * This cluster will be used either for new bucket or for
3216 * If the cluster size is the same as the bucket size, one
3217 * more is needed since we may need to extend the bucket
3486 * In extreme situation, may need xattr bucket when
3488 * the credits for bucket in mknod.
3491 xbs.bucket = ocfs2_xattr_bucket_new(inode);
3492 if (!xbs.bucket) {
3517 ocfs2_xattr_bucket_free(xbs.bucket);
3566 * bucket.
3568 xbs.bucket = ocfs2_xattr_bucket_new(inode);
3569 if (!xbs.bucket) {
3677 ocfs2_xattr_bucket_free(xbs.bucket);
3747 struct ocfs2_xattr_bucket *bucket,
3751 struct ocfs2_xattr_bucket *bucket,
3759 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
3765 * We don't use binary search in the bucket because there
3793 xe_name = bucket_block(bucket, block_off) + new_offset;
3808 * The ocfs2_xattr_header.xh_num_buckets of the first bucket contains
3812 * hash is in the gap of 2 buckets, return the lower bucket.
3828 int low_bucket = 0, bucket, high_bucket;
3850 bucket = (low_bucket + high_bucket) / 2;
3851 blkno = p_blkno + bucket * blk_per_bucket;
3861 high_bucket = bucket - 1;
3867 * bucket is larger than the search one. for an empty
3868 * bucket, the last one is also the first one.
3877 low_bucket = bucket + 1;
3881 /* the searched xattr should reside in this bucket if exists. */
3893 * Record the bucket we have found.
3895 * always set it to the previous bucket.
3901 ret = ocfs2_read_xattr_bucket(xs->bucket, lower_blkno);
3907 xs->header = bucket_xh(xs->bucket);
3908 xs->base = bucket_block(xs->bucket, 0);
3915 (unsigned long long)bucket_blkno(xs->bucket),
3978 struct ocfs2_xattr_bucket *bucket;
3980 bucket = ocfs2_xattr_bucket_new(inode);
3981 if (!bucket) {
3990 for (i = 0; i < num_buckets; i++, blkno += bucket->bu_blocks) {
3991 ret = ocfs2_read_xattr_bucket(bucket, blkno);
3998 * The real bucket num in this series of blocks is stored
3999 * in the 1st bucket.
4002 num_buckets = le16_to_cpu(bucket_xh(bucket)->xh_num_buckets);
4005 le32_to_cpu(bucket_xh(bucket)->xh_entries[0].xe_name_hash));
4007 ret = func(inode, bucket, para);
4013 ocfs2_xattr_bucket_relse(bucket);
4018 ocfs2_xattr_bucket_free(bucket);
4048 struct ocfs2_xattr_bucket *bucket,
4056 for (i = 0 ; i < le16_to_cpu(bucket_xh(bucket)->xh_count); i++) {
4057 struct ocfs2_xattr_entry *entry = &bucket_xh(bucket)->xh_entries[i];
4061 bucket_xh(bucket),
4068 name = (const char *)bucket_block(bucket, block_off) +
4170 * When the ocfs2_xattr_block is filled up, new bucket will be created
4171 * and all the xattr entries will be moved to the new bucket.
4172 * The header goes at the start of the bucket, and the names+values are
4179 struct ocfs2_xattr_bucket *bucket)
4188 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
4191 char *target = bucket_block(bucket, blks - 1);
4195 (unsigned long long)bucket_blkno(bucket));
4198 memset(bucket_block(bucket, i), 0, blocksize);
4220 target = bucket_block(bucket, 0);
4242 * While if the entry is in index b-tree, "bucket" indicates the
4254 xs->header = bucket_xh(xs->bucket);
4255 xs->base = bucket_block(xs->bucket, 0);
4284 BUG_ON(!xs->bucket);
4308 * The bucket may spread in many blocks, and
4310 * in the whole bucket(one for entry and one for data).
4316 ret = ocfs2_init_xattr_bucket(xs->bucket, blkno, 1);
4322 ret = ocfs2_xattr_bucket_journal_access(handle, xs->bucket,
4329 ocfs2_cp_xattr_block_to_bucket(inode, xb_bh, xs->bucket);
4330 ocfs2_xattr_bucket_journal_dirty(handle, xs->bucket);
4373 * defrag a xattr bucket if we find that the bucket has some
4375 * We will move all the name/value pairs to the end of the bucket
4380 struct ocfs2_xattr_bucket *bucket)
4386 u64 blkno = bucket_blkno(bucket);
4404 for (i = 0; i < bucket->bu_blocks; i++, buf += blocksize)
4405 memcpy(buf, bucket_block(bucket, i), blocksize);
4407 ret = ocfs2_xattr_bucket_journal_access(handle, bucket,
4431 /* Move all name/values to the end of the bucket. */
4454 "bucket %llu\n", (unsigned long long)blkno);
4460 "bucket %llu\n", (unsigned long long)blkno);
4474 for (i = 0; i < bucket->bu_blocks; i++, buf += blocksize)
4475 memcpy(bucket_block(bucket, i), buf, blocksize);
4476 ocfs2_xattr_bucket_journal_dirty(handle, bucket);
4486 * clusters contains more than bucket, we can easily split one cluster
4487 * at a bucket boundary. So we take the last cluster of the existing
4493 * extent's bucket count. header_bh is the bucket were we were hoping
4494 * to insert our xattr. If the bucket move places the target in the new
4532 /* This is the first bucket that got moved */
4536 * If the target bucket was part of the moved buckets, we need to
4540 /* Find the block for the new target bucket */
4567 * Find the suitable pos when we divide a bucket into 2.
4569 * in the same bucket.
4609 * Move some xattrs in old bucket(blk) to new bucket(new_blk).
4610 * first_hash will record the 1st hash of the new bucket.
4614 * same bucket. If all the xattrs in this bucket have the same hash
4615 * value, the new bucket will be initialized as an empty one and the
4688 * initialized a new empty bucket here.
4690 * that of the last entry in the previous bucket.
4703 /* copy the whole bucket to the new first. */
4706 /* update the new bucket. */
4711 * the old bucket first.
4723 * Now begin the modification to the new bucket.
4725 * In the new bucket, We just move the xattr entry to the beginning
4727 * bucket, and they will be removed when ocfs2_defrag_xattr_bucket is
4743 /* Calculate xh_free_start for the new bucket. */
4761 /* store the first_hash of the new bucket. */
4766 * Now only update the 1st block of the old bucket. If we
4767 * just added a new empty bucket, there is no need to modify
4790 * Copy xattr from one bucket to another bucket.
4841 * how we get here, and the bucket isn't really new.
4889 /* The first bucket of the original extent */
4891 /* The first bucket of the new extent */
4906 * We need to update the first bucket of the old extent and all
4935 * Get the new bucket ready before we dirty anything
4969 * This function should only be called when bucket size == cluster size.
4989 /* Move half of the xattr in start_blk to the next bucket. */
5003 * to extend the insert bucket.
5007 * 1. If cluster size > bucket size, that means the previous cluster has more
5008 * than 1 bucket, so just move half nums of bucket into the new cluster and
5009 * update the first_bh and header_bh if the insert bucket has been moved
5085 * indicates the bucket we will insert the new xattrs. They will be updated
5178 * We are given an extent. 'first' is the bucket at the very front of
5179 * the extent. The extent has space for an additional bucket past
5181 * of the target bucket. We wish to shift every bucket past the target
5183 * target, we split the target between itself and the now-empty bucket
5202 /* The extent must have room for an additional bucket */
5206 /* end_blk points to the last existing bucket */
5210 * end_blk is the start of the last existing bucket.
5211 * Thus, (end_blk - target_blk) covers the target bucket and
5212 * every bucket after it up to, but not including, the last
5213 * existing bucket. Then we add the last existing bucket, the
5214 * new bucket, and the first bucket (3 * blk_per_bucket).
5238 /* Move half of the xattr in target_blkno to the next bucket. */
5250 * Add new xattr bucket in an extent record and adjust the buckets
5252 * bucket we want to insert into.
5255 * one. Half of target's xattrs will be moved to the next bucket.
5277 /* The bucket at the front of the extent */
5283 /* The first bucket of the original extent */
5307 * This can move first+target if the target bucket moves
5341 * Truncate the specified xe_off entry in xattr bucket.
5342 * bucket is indicated by header_bh and len is the new length.
5348 struct ocfs2_xattr_bucket *bucket,
5356 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
5374 vb.vb_bh = bucket->bu_bhs[value_blk];
5381 * From here on out we have to dirty the bucket. The generic
5382 * value calls only modify one of the bucket's bhs, but we need
5383 * to send the bucket at once. So if they error, they *could* have
5385 * the whole bucket. This leaves us in a consistent state.
5388 (unsigned long long)bucket_blkno(bucket), xe_off, len);
5395 ret = ocfs2_xattr_bucket_journal_access(ctxt->handle, bucket,
5404 ocfs2_xattr_bucket_journal_dirty(ctxt->handle, bucket);
5506 * check whether the xattr bucket is filled up with the same hash value.
5512 struct ocfs2_xattr_bucket *bucket,
5515 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
5523 mlog(ML_ERROR, "Too much hash collision in xattr bucket %llu, "
5525 (unsigned long long)bucket_blkno(bucket),
5534 * Try to set the entry in the current bucket. If we fail, the caller
5535 * will handle getting us another bucket.
5547 ocfs2_init_xattr_bucket_xa_loc(&loc, xs->bucket,
5559 /* Ok, we need space. Let's try defragmenting the bucket. */
5561 xs->bucket);
5597 /* Ack, need more space. Let's try to get another bucket! */
5602 * one bucket's worth, so check it here whether we need to
5603 * add a new bucket for the insert.
5606 xs->bucket,
5615 xs->bucket,
5624 * xs->bucket if it moved, but it will not have updated
5629 ocfs2_xattr_bucket_relse(xs->bucket);
5637 /* Ok, we have a new bucket, let's try again */
5647 struct ocfs2_xattr_bucket *bucket,
5651 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
5669 ret = ocfs2_get_xattr_tree_value_root(inode->i_sb, bucket,
5689 ret = ocfs2_xattr_bucket_value_truncate(inode, bucket,
5711 * Whenever we modify a xattr value root in the bucket(e.g, CoW
5713 * the metaecc for the whole bucket. So it is done here.
5723 struct ocfs2_xattr_bucket *bucket =
5726 ret = ocfs2_xattr_bucket_journal_access(handle, bucket,
5733 ocfs2_xattr_bucket_journal_dirty(handle, bucket);
5769 struct ocfs2_xattr_bucket *bucket = NULL;
5792 bucket_xh(xbs->bucket),
5799 base = bucket_block(xbs->bucket, block_off);
5800 vb.vb_bh = xbs->bucket->bu_bhs[block_off];
5805 bucket = xbs->bucket;
5806 refcount.credits = bucket->bu_blocks;
5807 refcount.para = bucket;
5994 struct ocfs2_xattr_bucket *bucket,
6000 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
6005 bucket_xh(bucket),
6014 base = bucket_block(bucket, block_off);
6020 *bh = bucket->bu_bhs[block_off];
6026 * For a given xattr bucket, refcount all the entries which
6030 struct ocfs2_xattr_bucket *bucket,
6038 (struct ocfs2_xattr_header *)bucket->bu_bhs[0]->b_data;
6044 .credits = bucket->bu_blocks,
6045 .para = bucket,
6055 (unsigned long long)bucket_blkno(bucket),
6063 ret = ocfs2_get_xattr_tree_value_root(inode->i_sb, bucket, i,
6322 * It can be used for inode, block and bucket.
6662 * We have to handle the case that both old bucket and new bucket
6676 struct ocfs2_xattr_bucket *bucket;
6679 bucket = args->old_bucket;
6681 bucket = args->new_bucket;
6683 return ocfs2_get_xattr_tree_value_root(sb, bucket, offset,
6701 struct ocfs2_xattr_bucket *bucket =
6704 return ocfs2_get_xattr_tree_value_root(sb, bucket, offset,
6709 struct ocfs2_xattr_bucket *bucket,
6715 (struct ocfs2_xattr_header *)bucket->bu_bhs[0]->b_data;
6717 /* Add the credits for this bucket first. */
6718 metas->credits += bucket->bu_blocks;
6719 return ocfs2_value_metas_in_xattr_header(inode->i_sb, bucket->bu_bhs[0],
6723 bucket);
6860 * bucket.
6885 * Re-access and dirty the bucket to calculate metaecc.
7034 * We will add bucket one by one, and refcount all the xattrs in the bucket