D1(printk(KERN_DEBUG"Plenty of free space, so expanding to write from offset 0x%x to 0x%x\n",
/* BUG_ON(!frag) but that'll happen anyway... */
start,end));
if(end<orig_end){
BUG_ON(frag->ofs!=start);
printk(KERN_WARNING"Eep. jffs2_garbage_collect_dnode extended node to write, but it got smaller: start 0x%x, orig_end 0x%x, end 0x%x\n",start,orig_end,end);
end=orig_end;
/* First grow down... */
while((frag=frag_prev(frag))&&frag->ofs>=min){
/* If the previous frag doesn't even reach the beginning, there's
excessive fragmentation. Just merge. */
if(frag->ofs>min){
D1(printk(KERN_DEBUG"Expanding down to cover partial frag (0x%x-0x%x)\n",
frag->ofs,frag->ofs+frag->size));
start=frag->ofs;
continue;
}
/* OK. This frag holds the first byte of the page. */
if(!frag->node||!frag->node->raw){
D1(printk(KERN_DEBUG"First frag in page is hole (0x%x-0x%x). Not expanding down.\n",
frag->ofs,frag->ofs+frag->size));
break;
}else{
/* OK, it's a frag which extends to the beginning of the page. Does it live
in a block which is still considered clean? If so, don't obsolete it.
If not, cover it anyway. */
structjffs2_raw_node_ref*raw=frag->node->raw;
structjffs2_eraseblock*jeb;
jeb=&c->blocks[raw->flash_offset/c->sector_size];
if(jeb==c->gcblock){
D1(printk(KERN_DEBUG"Expanding down to cover frag (0x%x-0x%x) in gcblock at %08x\n",
frag->ofs,frag->ofs+frag->size,ref_offset(raw)));
start=frag->ofs;
break;
}
if(!ISDIRTY(jeb->dirty_size+jeb->wasted_size)){
D1(printk(KERN_DEBUG"Not expanding down to cover frag (0x%x-0x%x) in clean block %08x\n",
frag->ofs,frag->ofs+frag->size,jeb->offset));
break;
}
D1(printk(KERN_DEBUG"Expanding down to cover frag (0x%x-0x%x) in dirty block %08x\n",
frag->ofs,frag->ofs+frag->size,jeb->offset));
start=frag->ofs;
break;
}
}
/* ... then up */
/* Find last frag which is actually part of the node we're to GC. */