Lines Matching defs:frag

117  * We use a 'frag tree' to keep track of the MDS's directory fragments
119 * need to know when a child frag is delegated to a new MDS, or when
125 * find/create a frag in the tree
132 struct ceph_inode_frag *frag;
138 frag = rb_entry(parent, struct ceph_inode_frag, node);
139 c = ceph_frag_compare(f, frag->frag);
145 return frag;
148 frag = kmalloc(sizeof(*frag), GFP_NOFS);
149 if (!frag)
152 frag->frag = f;
153 frag->split_by = 0;
154 frag->mds = -1;
155 frag->ndist = 0;
157 rb_link_node(&frag->node, parent, p);
158 rb_insert_color(&frag->node, &ci->i_fragtree);
160 dout("get_or_create_frag added %llx.%llx frag %x\n",
162 return frag;
166 * find a specific frag @f
173 struct ceph_inode_frag *frag =
175 int c = ceph_frag_compare(f, frag->frag);
181 return frag;
187 * Choose frag containing the given value @v. If @pfrag is
188 * specified, copy the frag delegation info to the caller if
195 struct ceph_inode_frag *frag;
204 frag = __ceph_find_frag(ci, t);
205 if (!frag)
207 if (frag->split_by == 0) {
209 memcpy(pfrag, frag, sizeof(*pfrag));
216 nway = 1 << frag->split_by;
218 frag->split_by, nway);
220 n = ceph_frag_make_child(t, frag->split_by, i);
252 struct ceph_inode_frag *frag;
253 u32 id = le32_to_cpu(dirinfo->frag);
271 frag = __ceph_find_frag(ci, id);
272 if (!frag)
274 if (frag->split_by == 0) {
276 dout("fill_dirfrag removed %llx.%llx frag %x"
278 rb_erase(&frag->node, &ci->i_fragtree);
279 kfree(frag);
282 dout("fill_dirfrag cleared %llx.%llx frag %x"
284 frag->mds = -1;
285 frag->ndist = 0;
291 /* find/add this frag to store mds delegation info */
292 frag = __get_or_create_frag(ci, id);
293 if (IS_ERR(frag)) {
297 ceph_vinop(inode), le32_to_cpu(dirinfo->frag));
302 frag->mds = mds;
303 frag->ndist = min_t(u32, ndist, CEPH_MAX_DIRFRAG_REP);
304 for (i = 0; i < frag->ndist; i++)
305 frag->dist[i] = le32_to_cpu(dirinfo->dist[i]);
306 dout("fill_dirfrag %llx.%llx frag %x ndist=%d\n",
307 ceph_vinop(inode), frag->frag, frag->ndist);
318 return ceph_frag_compare(le32_to_cpu(ls->frag),
319 le32_to_cpu(rs->frag));
322 static bool is_frag_child(u32 f, struct ceph_inode_frag *frag)
324 if (!frag)
326 if (ceph_frag_bits(f) != ceph_frag_bits(frag->frag) + frag->split_by)
328 return ceph_frag_contains_value(frag->frag, ceph_frag_value(f));
336 struct ceph_inode_frag *frag, *prev_frag = NULL;
348 id = le32_to_cpu(fragtree->splits[i].frag);
353 frag = rb_entry(rb_node, struct ceph_inode_frag, node);
354 if (frag->frag != ceph_frag_make(0, 0) || rb_next(rb_node))
358 id = le32_to_cpu(dirinfo->frag);
373 id = le32_to_cpu(fragtree->splits[i].frag);
377 "frag %x split by %d\n", ceph_vinop(inode),
381 frag = NULL;
383 frag = rb_entry(rb_node, struct ceph_inode_frag, node);
384 if (ceph_frag_compare(frag->frag, id) >= 0) {
385 if (frag->frag != id)
386 frag = NULL;
393 if (frag->split_by > 0 ||
394 !is_frag_child(frag->frag, prev_frag)) {
395 rb_erase(&frag->node, &ci->i_fragtree);
396 if (frag->split_by > 0)
398 kfree(frag);
400 frag = NULL;
402 if (!frag) {
403 frag = __get_or_create_frag(ci, id);
404 if (IS_ERR(frag))
407 if (frag->split_by == 0)
409 frag->split_by = split_by;
410 dout(" frag %x split by %d\n", frag->frag, frag->split_by);
411 prev_frag = frag;
414 frag = rb_entry(rb_node, struct ceph_inode_frag, node);
417 if (frag->split_by > 0 ||
418 !is_frag_child(frag->frag, prev_frag)) {
419 rb_erase(&frag->node, &ci->i_fragtree);
420 if (frag->split_by > 0)
422 kfree(frag);
547 struct ceph_inode_frag *frag;
587 frag = rb_entry(n, struct ceph_inode_frag, node);
589 kfree(frag);
1039 /* populate frag tree */
1603 u32 frag = le32_to_cpu(rhead->args.readdir.frag);
1625 le32_to_cpu(rinfo->dir_dir->frag) != frag) {
1626 dout("readdir_prepopulate got new frag %x -> %x\n",
1627 frag, le32_to_cpu(rinfo->dir_dir->frag));
1628 frag = le32_to_cpu(rinfo->dir_dir->frag);
1642 if (ceph_frag_is_leftmost(frag) &&
1679 rde->offset = ceph_make_fpos(frag, fpos_offset++, false);