34 #define NFSDBG_FACILITY NFSDBG_PNFS_LD
37 #define EXTENT_INITIALIZED 0
38 #define EXTENT_WRITTEN 1
39 #define EXTENT_IN_COMMIT 2
40 #define INTERNAL_EXISTS MY_MAX_TAGS
41 #define INTERNAL_MASK ((1 << INTERNAL_EXISTS) - 1)
47 return s -
do_div(tmp, base);
52 return normalize(s + base - 1, base);
62 dprintk(
"%s(%llu) enter\n", __func__, s);
79 dprintk(
"%s(%llu, %i) enter\n", __func__, s, tag);
81 tags = _find_entry(tree, s);
82 if ((tags < 0) || !(tags & (1 << tag)))
98 dprintk(
"%s(%llu, %i, %p) enter\n", __func__, s, tag, storage);
115 new->it_tags = (1 <<
tag);
116 list_add(&new->it_link, &pos->
it_link);
127 dprintk(
"%s(%i, %llu, %llu) enter\n", __func__, tag, s, length);
130 if (_add_entry(tree, i, tag,
NULL))
144 dprintk(
"%s(%llu, %llu) enter\n", __func__, offset, length);
150 storage = kcalloc(count,
sizeof(*storage),
GFP_NOFS);
153 for (i = 0; i <
count; i++) {
163 spin_unlock_bh(&marks->
im_lock);
168 for (i = used; i <
count; i++) {
184 spin_unlock_bh(&marks->
im_lock);
195 dprintk(
"%s(%llu, %llu, %i) enter\n", __func__, start, end, tag);
226 spin_unlock_bh(&marks->
im_lock);
239 dprintk(
"%s(offset=%llu,len=%llu) enter\n",
240 __func__, (
u64)offset, (
u64)length);
244 if (_preload_range(marks, start, end - start))
250 spin_unlock_bh(&marks->
im_lock);
255 spin_unlock_bh(&marks->
im_lock);
268 dprintk(
"%s(offset=%llu,len=%llu) enter\n", __func__,
269 (
u64)offset, (
u64)length);
272 spin_unlock_bh(&marks->
im_lock);
278 dprintk(
"PRINT SHORT EXTENT extent %p\n", be);
285 static void print_clist(
struct list_head *
list,
unsigned int count)
295 print_short_extent(be);
314 dprintk(
"%s enter\n", __func__);
315 print_short_extent(
new);
329 }
else if (new->bse_f_offset <=
332 if (new->bse_mdev == old->
bse_mdev) {
334 new->bse_length +=
new->bse_f_offset -
355 if (new->bse_mdev == old->
bse_mdev) {
356 if (end < old->bse_f_offset + old->
bse_length) {
359 new->bse_length = end -
new->bse_f_offset;
366 dprintk(
"%s: after merging\n", __func__);
384 mark_written_sectors(be->
be_inval, offset, length);
389 new->bse_f_offset =
offset;
392 if (is_range_written(be->
be_inval, offset, new->bse_f_offset))
393 new->bse_f_offset =
offset;
399 if (is_range_written(be->
be_inval, end, new_end))
404 if (end <= new->bse_f_offset) {
408 new->bse_length = end -
new->bse_f_offset;
413 add_to_commitlist(bl,
new);
420 dprintk(
"PRINT EXTENT extent %p\n", be);
435 dprintk(
"%s be=%p\n", __func__, be);
443 dprintk(
"%s enter %p (%i)\n", __func__, be,
445 kref_put(&be->
be_refcnt, destroy_extent);
462 static void print_elist(
struct list_head *list)
466 dprintk(
"Extent list looks like:\n");
477 return (new->be_state == old->
be_state) &&
481 new->be_mdev == old->
be_mdev));
499 sector_t end =
new->be_f_offset +
new->be_length;
502 dprintk(
"%s enter with be=%p\n", __func__,
new);
503 print_bl_extent(
new);
504 list = &bl->
bl_extents[bl_choose_list(new->be_state)];
514 if (end <= be->be_f_offset + be->
be_length) {
516 if (extents_consistent(be,
new)) {
517 dprintk(
"%s: new is subset, ignoring\n",
527 if (extents_consistent(be,
new)) {
529 new->be_length +=
new->be_f_offset -
533 dprintk(
"%s: removing %p\n", __func__, be);
542 if (extents_consistent(be,
new)) {
544 dprintk(
"%s: removing %p\n", __func__, be);
553 if (extents_consistent(
new, be)) {
556 new->be_f_offset -
new->be_length;
557 dprintk(
"%s: removing %p\n", __func__, be);
568 list_add(&new->be_node, &be->
be_node);
569 dprintk(
"%s: inserting new\n", __func__);
596 dprintk(
"%s enter with isect %llu\n", __func__, (
u64)isect);
605 dprintk(
"%s Get %p (%i)\n", __func__, be,
624 print_bl_extent(ret);
635 dprintk(
"%s enter with isect %llu\n", __func__, (
u64)isect);
644 dprintk(
"%s Get %p (%i)\n", __func__, be,
652 print_bl_extent(ret);
658 struct xdr_stream *xdr,
662 unsigned int count = 0;
665 dprintk(
"%s enter\n", __func__);
684 p = xdr_encode_hyper(p, 0
LL);
690 xdr_start[0] =
cpu_to_be32((xdr->p - xdr_start - 1) * 4);
694 dprintk(
"%s found %i ranges\n", __func__, count);
704 kref_init(&new->be_refcnt);
708 new->be_f_offset =
offset;
711 new->be_state =
state;
730 !extents_consistent(prev, be))
754 dprintk(
"%s(%llu, %llu)\n", __func__, offset, length);
760 if (!e1 || !e2 || !e3)
764 be = bl_find_get_extent_locked(bl, offset);
779 _prep_new_extent(e2, be, offset,
801 list_replace(&be->
be_node, &new->be_node);
804 for (
j = 1;
j <
i;
j++) {
807 list_add(&new->be_node, &old->
be_node);
821 dprintk(
"%s returns %llu after split\n", __func__, rv);
828 dprintk(
"%s returns %llu without splitting\n", __func__, rv);
839 dprintk(
"%s status %d\n", __func__, status);
846 offset = set_to_rw(bl, offset, end - offset);
847 }
while (offset < end);
854 add_to_commitlist(bl, lce);
870 spin_unlock_bh(&marks->
im_lock);
886 spin_unlock_bh(&marks->
im_lock);
895 if (num_to_free <= 0)
902 if (--num_to_free == 0)