]> git.neil.brown.name Git - LaFS.git/log
LaFS.git
15 years agolafs_incorporate: bug on not dirty.
NeilBrown [Tue, 8 Jun 2010 08:25:18 +0000 (18:25 +1000)]
lafs_incorporate: bug on not dirty.

We already had some of these, but a few more doesn't hurt :-)

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoremove_from_index: various fixes.
NeilBrown [Tue, 8 Jun 2010 08:22:39 +0000 (18:22 +1000)]
remove_from_index: various fixes.

1/ Skip offset for InoIdx
2/ when moving address down, clear the space at the end
3/ stop when we find the last address.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agolafs_walk_leaf_index
NeilBrown [Tue, 8 Jun 2010 08:18:59 +0000 (18:18 +1000)]
lafs_walk_leaf_index

remove stray handler initialisation.
Both walk_indirect and walk_extent do an initialisation
so there is no point doing another one.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agowalk_extent: don't keep walking past the end of the list of addresses
NeilBrown [Tue, 8 Jun 2010 08:15:54 +0000 (18:15 +1000)]
walk_extent:  don't keep walking past the end of the list of addresses

Once we find a len of 0, there is nothing more worth finding.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoadd_extent fixes.
NeilBrown [Tue, 8 Jun 2010 08:13:13 +0000 (18:13 +1000)]
add_extent fixes.

add_extent tries to detect consecutive extents being added
and merges them.  But it got it wrong.
So change last* to actually refer to the "next" and get it right.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agotruncate: fixes for pruning addresses.
NeilBrown [Tue, 8 Jun 2010 08:10:37 +0000 (18:10 +1000)]
truncate: fixes for pruning addresses.

1/ after pruning addresses, we need to clear the index block
2/ InoIdx blocks don't follow the rule that physaddr==0 means empty.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agotruncate: can only safely lafs_incorporate dirty blocks.
NeilBrown [Tue, 8 Jun 2010 08:07:59 +0000 (18:07 +1000)]
truncate: can only safely lafs_incorporate dirty blocks.

So if the block isn't dirty, don't try.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoSet depth to 0 when InoIdx becomes empty.
NeilBrown [Tue, 8 Jun 2010 07:49:04 +0000 (17:49 +1000)]
Set depth to 0 when InoIdx becomes empty.

The code set depth to zero always, which is clearly broken.

We don't incrementally reduce the height of an indexing tree as it
shrinks.  Rather the high remains at the max until it is completely
empty, then it suddenly becomes zero.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoClear B_OnFree when removing from freelist.
NeilBrown [Tue, 8 Jun 2010 07:32:57 +0000 (17:32 +1000)]
Clear B_OnFree when removing from freelist.

This isn't strictly necessary as if refile want to use the
LRU for something else, it will clear this bit.
However clearing it both places makes for more consistency and less
confusing data structures.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoREADME sync
NeilBrown [Mon, 7 Jun 2010 03:23:59 +0000 (13:23 +1000)]
README sync

and typo fix

15 years agoRemove stray test is inode_handle_orphan
NeilBrown [Mon, 7 Jun 2010 03:20:08 +0000 (13:20 +1000)]
Remove stray test is inode_handle_orphan

As we no longer clear B_Valid on empty index blocks,
there is no point or need to test for it.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoBUG_ON in lafs_allocated_block.
NeilBrown [Mon, 7 Jun 2010 03:18:43 +0000 (13:18 +1000)]
BUG_ON in lafs_allocated_block.

We never allocate an InoIdx block - on the data block.
So add a BUG check.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoFix a BUG_ON in lafs_erase_dblock
NeilBrown [Mon, 7 Jun 2010 03:16:45 +0000 (13:16 +1000)]
Fix a BUG_ON  in lafs_erase_dblock

As we no longer clear the Valid flag on index blocks when
they become empty, we can no longer trigger a bug if it
is still set.
However depth should definitely be 0, so test for that.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoAdd some error checking to lafs_mount
NeilBrown [Mon, 7 Jun 2010 03:13:54 +0000 (13:13 +1000)]
Add some error checking to lafs_mount

i.e. just return the error code if there is one.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoMake sure find_block loads data from inode.
NeilBrown [Mon, 7 Jun 2010 01:30:48 +0000 (11:30 +1000)]
Make sure find_block loads data from inode.

lafs_load_block expects not to need to read block 0
of a depth==0 inode as lafs_find_block is expected to
load that.
However there is a case where find_block (called from lafs_find_block)
skips the load.  So remove that case.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoFix compile warning / incorrect test.
NeilBrown [Mon, 7 Jun 2010 01:27:33 +0000 (11:27 +1000)]
Fix compile warning / incorrect test.

New compiler noticed this...

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoDon't clear B_Valid when index block is empty
NeilBrown [Mon, 28 Sep 2009 02:32:48 +0000 (12:32 +1000)]
Don't clear B_Valid when index block is empty

This overloading just caused problem. Invent a new flag instead.

16 years agoincorporate: handle empty block correctly.
NeilBrown [Mon, 28 Sep 2009 02:26:29 +0000 (12:26 +1000)]
incorporate: handle empty block correctly.

When a block becomes empty, we need to remove it from the
indexing tree, causing the next block to take over the address
space if possible, else maybe the previous block.

16 years agoFORMAT CHANGE - include start address explicitly in indirect blocks.
NeilBrown [Mon, 28 Sep 2009 00:16:17 +0000 (10:16 +1000)]
FORMAT CHANGE - include start address explicitly in indirect blocks.

By storing the address of the first block in an indirect block,
that block can be relocated in the index tree with no adverse effects.
This makes it easier to handle blocks that have become empty.

So an indirect block now contains:
   u16 0x01   'indirect' indicator
   u32 addr   virtual address of first indexed block
   u48 paddr  physical address of first indexblock block
   u48 paddr2 next block ... etc

16 years agoREADME notes for changes to index management.
NeilBrown [Mon, 28 Sep 2009 00:16:15 +0000 (10:16 +1000)]
README notes for changes to index management.

16 years agoHandle index blocks becoming empty better.
NeilBrown [Mon, 28 Sep 2009 00:16:13 +0000 (10:16 +1000)]
Handle index blocks becoming empty better.

MORE TEXT HERE

16 years agoDon't lose path to index blocks that haven't been incorporated
NeilBrown [Mon, 28 Sep 2009 00:16:02 +0000 (10:16 +1000)]
Don't lose path to index blocks that haven't been incorporated

Before a new index block is incorporated, we can find it only by
finding a sibling and walking the sibling list.
If that primary sibling gets released, the new block becomes
unfindable.
So hold a reference to such primaries until incorporation,
and ensure that there is always a primary in the same parent
by incorporating more promptly after a split.

16 years agoGroup B_ flags by which sort of block they apply to.
NeilBrown [Sun, 13 Sep 2009 23:47:59 +0000 (09:47 +1000)]
Group B_ flags by which sort of block they apply to.

This will allow us to overlap the 'Data' and 'Index' groups
later if that proves necessary.

16 years agodir: replace wrong constant with correct symbolic version.
NeilBrown [Thu, 3 Sep 2009 06:07:45 +0000 (16:07 +1000)]
dir: replace wrong constant with correct symbolic version.

16 years agoDrop excess 'clean2' reference.
NeilBrown [Thu, 3 Sep 2009 05:54:15 +0000 (15:54 +1000)]
Drop excess 'clean2' reference.

16 years agolafs_wait_block fixes
NeilBrown [Thu, 3 Sep 2009 05:46:38 +0000 (15:46 +1000)]
lafs_wait_block fixes

If the block is already Valid, there is no need to wait for
it to be unlocked.
This avoids extra async blocks lying around.

16 years agoAvoid flushing inodes too soon.
NeilBrown [Thu, 3 Sep 2009 05:46:24 +0000 (15:46 +1000)]
Avoid flushing inodes too soon.

I'm not 100% sure of this, but it seems write.  Inode data blocks
don't have PinPending, rather the inode block is Pinned.

16 years agoMultiple improvements to inode dirtying
NeilBrown [Thu, 3 Sep 2009 05:28:22 +0000 (15:28 +1000)]
Multiple improvements to inode dirtying

- in a few places we didn't called dirty_inode when we should have
  done.
- after inode_{inc,dec}_link_count we don't need to dirty the inode
  because it has already been done.
- handle I_Dirty properly rather than unpinning the block
- allocate NCredits for inodes so that I_Dirty can succeed.

16 years agoREADME update
NeilBrown [Thu, 3 Sep 2009 05:28:21 +0000 (15:28 +1000)]
README update

16 years agoFix clearing of PinPending
NeilBrown [Thu, 3 Sep 2009 05:28:21 +0000 (15:28 +1000)]
Fix clearing of PinPending

PinPending must be cleared after marking dirty, not before.

16 years agoAdd support for unattended testing.
NeilBrown [Thu, 3 Sep 2009 05:28:21 +0000 (15:28 +1000)]
Add support for unattended testing.

Make sure the qemu exits when a test completes, and always
capture the kernel output.

16 years agounmount: push orphan handling along.
NeilBrown [Thu, 3 Sep 2009 05:28:21 +0000 (15:28 +1000)]
unmount: push orphan handling along.

Just waiting for the thread to do it doesn't seem to be
enough.

16 years agolafs_find_orphan: always release the lock.
NeilBrown [Thu, 3 Sep 2009 05:28:21 +0000 (15:28 +1000)]
lafs_find_orphan: always release the lock.

Forgot to unlock on the "not found" path.

16 years agoFixed to run_orphans.
NeilBrown [Thu, 3 Sep 2009 05:28:21 +0000 (15:28 +1000)]
Fixed to run_orphans.

We need to hold a reference to the db, as orphan_release
can drop it.
And an unclaimed inode block with no mx is always free to
be orphan_released.

16 years agoMove unmap_dblock closer to map.
NeilBrown [Thu, 3 Sep 2009 05:28:20 +0000 (15:28 +1000)]
Move unmap_dblock closer to map.

As this is an atomic region, keep it as short as possible.

16 years agoFix pruning of orphan file.
NeilBrown [Thu, 3 Sep 2009 05:28:20 +0000 (15:28 +1000)]
Fix pruning of orphan file.

The test for "now beyond EOF" was all wrong.

16 years agoDon't add Credits to Dirty blocks.
NeilBrown [Thu, 3 Sep 2009 05:28:20 +0000 (15:28 +1000)]
Don't add Credits to Dirty blocks.

If the Credit has moved to Dirty, we don't need to add
another one during prealloc.
Doing so means that prealloc can fail on a block which is
already adequately allocated.

16 years agoAdd some more "temp_credits" assignment to improve credit-watch
NeilBrown [Thu, 3 Sep 2009 05:28:20 +0000 (15:28 +1000)]
Add some more "temp_credits" assignment to improve credit-watch

16 years agoClear physaddr when growing an index tree.
NeilBrown [Thu, 3 Sep 2009 05:28:19 +0000 (15:28 +1000)]
Clear physaddr when growing an index tree.

The InoIdx block probably shouldn't have a phys address,
but we must be certainly it doesn't after a grow caused it to
not be an InoIdx block any more, else accounting will get
confused when we allocate it to another block.

16 years agoRelease the orphan status when finished deleting an inode.
NeilBrown [Thu, 3 Sep 2009 05:28:19 +0000 (15:28 +1000)]
Release the orphan status when finished deleting an inode.

and ensure that if the orphan_release fails, a subsequent attempt
has a chance of doing the right thing.

16 years agoBe sure to alway unlock new inodes.
NeilBrown [Thu, 3 Sep 2009 05:28:19 +0000 (15:28 +1000)]
Be sure to alway unlock new inodes.

All error paths must unlock the new inode.
And make sure nlink is 0 so that it will not be cached.

16 years agocorrectly handle attempt to load inode that is being deleted.
NeilBrown [Thu, 3 Sep 2009 05:28:19 +0000 (15:28 +1000)]
correctly handle attempt to load inode that is being deleted.

Make sure to return ENOENT in this case.

16 years agoInitialise empty index block during allocation.
NeilBrown [Thu, 3 Sep 2009 05:28:18 +0000 (15:28 +1000)]
Initialise empty index block during allocation.

I'm still not sure about this handling of empty index blocks,
but leaving it invalid certainly isn't correct.  I have to
initialise it and make it valid.

16 years agoAvoid inadvertently flush blocks that are in middle of a transaction.
NeilBrown [Thu, 3 Sep 2009 05:28:15 +0000 (15:28 +1000)]
Avoid inadvertently flush blocks that are in middle of a transaction.

If a directory block has PinPending, then a transaction is in progress
and flushing the block (e.g. pdflush) would be a bad idea, as we could
lose the credit before the final update.

16 years agoComplete proper pinning dir_handle_orphans.
NeilBrown [Wed, 2 Sep 2009 00:55:20 +0000 (10:55 +1000)]
Complete proper pinning dir_handle_orphans.

If the orphan handler is going to dirty a block, it must
first pin it (and check for errors), and must afterwards remove
the PinPending.
One of the places which caused change did this.  The other didn't.

16 years agoFix orphan flushing in rmdir
NeilBrown [Wed, 2 Sep 2009 00:55:20 +0000 (10:55 +1000)]
Fix orphan flushing in rmdir

lafs_dir_handle_orphan no longer requires drop_orphan,
and can drop the reference to the orphan block.
So we need to hold our own so we can test if it is still
and orphan after handling (in which case we must wait).

16 years agoFix beyond-eof check when cleaning
NeilBrown [Wed, 2 Sep 2009 00:55:20 +0000 (10:55 +1000)]
Fix beyond-eof check when cleaning

special files don't maintain i_size, so we must not compare against
that when cleaning them.

16 years agoRemove incorrect BUG_ON in checkpoint.
NeilBrown [Wed, 2 Sep 2009 00:55:20 +0000 (10:55 +1000)]
Remove incorrect BUG_ON in checkpoint.

It seems that this list can be empty fairly often without
any problems caused - I was afraid of infinite loops as it appears
there is nothing to do.
Maybe it is just the waiting that is needed.

16 years agoRemove incorrect assumption from erase_dblock
NeilBrown [Wed, 2 Sep 2009 00:55:07 +0000 (10:55 +1000)]
Remove incorrect assumption from erase_dblock

When erasing a pinned dblock, it might not be on the leaf list.
The fact that we have it locked can mean that it wasn't put there
yet.
So check leaf list membership explicitly.

Note that it cannot be in write-back, as we should have
waited for any writeback to finish, and won't have started any.

16 years agoAdd alloc_type to lafs_pin_dblock
NeilBrown [Wed, 2 Sep 2009 00:10:04 +0000 (10:10 +1000)]
Add alloc_type to lafs_pin_dblock

This is particularly needed for make_orphan which needs
to allocate new blocks sometimes just to delete files.

16 years agoImprove inode orphan handling.
NeilBrown [Wed, 2 Sep 2009 00:10:03 +0000 (10:10 +1000)]
Improve inode orphan handling.

And inode can be an orphan for an extended period of time and
should not be on the pending_orphans list all that time.
So we need to remove it if nothing needs doing for now, and
add it back on when it requires attention.

16 years agoImprove lafs_run_orphans list handling.
NeilBrown [Wed, 2 Sep 2009 00:10:03 +0000 (10:10 +1000)]
Improve lafs_run_orphans list handling.

Requiring the 'handle' routines to leave the orphan on the list and
then removing it if B_Orphan isn't set is not appropriate as we will
want to remove block while they still have B_Orphan set.
So do the list management differently to still ensure a single pass
through without needing the current block to hold our place.

16 years agoRemove special handling for i_nlink when reading inodes.
NeilBrown [Wed, 2 Sep 2009 00:09:52 +0000 (10:09 +1000)]
Remove special handling for i_nlink when reading inodes.

This was never "right" and is confusing orphan handling.
We should not lose those blocks anymore but if we do we need a better
fix.

16 years agoFlush orphans before failing rmdir due to not being empty.
NeilBrown [Wed, 2 Sep 2009 00:09:51 +0000 (10:09 +1000)]
Flush orphans before failing rmdir due to not being empty.

Before we can be sure if a directory is empty, we need to
flush and orphans that might be holding space in the directory
in use.  Only then can a check on the file size be meaningful.

16 years agoRun orphans from the cleaner thread, not immediately.
NeilBrown [Wed, 2 Sep 2009 00:09:49 +0000 (10:09 +1000)]
Run orphans from the cleaner thread, not immediately.

This involves:

 making dir_handle_orphans and inode_handle_orphans non-blocking.
 removing lots of explicit calls to handle_orphans.

16 years agomake lafs_leaf_find properly async
NeilBrown [Wed, 2 Sep 2009 00:09:07 +0000 (10:09 +1000)]
make lafs_leaf_find properly async

The new iolock_block calls weren't honouring 'async'.
So fix that.

16 years agolafs_make_orphan_nb - non-blocking version.
NeilBrown [Thu, 27 Aug 2009 01:51:03 +0000 (11:51 +1000)]
lafs_make_orphan_nb - non-blocking version.

We will need to in the 'dir' orphan handler which itself
needs to be non-blocking.

16 years agoFurther tidy up for make_orphan
NeilBrown [Thu, 27 Aug 2009 01:46:02 +0000 (11:46 +1000)]
Further tidy up for make_orphan

Move the calls to orphan_abort and orphan_commit into make_orphan
to follow the pattern used elsewhere.
This requires moving the i_mutex lock out into make_orphan,
but otherwise seems to be a good improvement.

16 years agoSplit orphan_commit out from orphan_pin
NeilBrown [Thu, 27 Aug 2009 01:46:01 +0000 (11:46 +1000)]
Split orphan_commit out from orphan_pin

It seems to work better as a separate function.

16 years agoUse orphan_abort in lafs_orphan_release
NeilBrown [Thu, 27 Aug 2009 01:46:00 +0000 (11:46 +1000)]
Use orphan_abort in lafs_orphan_release

lafs_orphan_release currently open-codes all of orphan_abort,
except the i_mutex locking is a bit different.  So change locking
rules for orphan_abort, then use that directly in lafs_orphan_release.

16 years agoGet rid of orphan_info structure.
NeilBrown [Thu, 27 Aug 2009 01:45:59 +0000 (11:45 +1000)]
Get rid of orphan_info structure.

It no longer contains anything really useful...

16 years agoTidy up release_orphan
NeilBrown [Thu, 27 Aug 2009 01:45:58 +0000 (11:45 +1000)]
Tidy up release_orphan

In particular it need to pin the dblocks, be async and get all the
references right.

16 years agoOrphan: simplify orphan creation.
NeilBrown [Thu, 27 Aug 2009 01:45:56 +0000 (11:45 +1000)]
Orphan:  simplify orphan creation.

We don't need to synchronise orphan creation with other parts of
direct ops etc.  We just make the block into an orphan if we
think that might be needed.  If this gets committed in a previous
checkpoint, there is no problem.

This simplifies things a lot and lets us get rid of some races.

16 years agoDiscard lafs_inode_prepare
NeilBrown [Wed, 26 Aug 2009 10:06:14 +0000 (20:06 +1000)]
Discard lafs_inode_prepare

This function has minimal content, and there is no matching
lafs_inode_pin, lafs_inode_commit etc.  So just remove it and
open-code instead.

16 years agoRemove some outdated comments.
NeilBrown [Wed, 26 Aug 2009 06:46:31 +0000 (16:46 +1000)]
Remove some outdated comments.

and some code that is pointless (dmap_dblock is identical to
map_dblock).

16 years agodir: fix use-after-put ordering error.
NeilBrown [Wed, 26 Aug 2009 06:26:12 +0000 (16:26 +1000)]
dir: fix use-after-put ordering error.

16 years agoumount: wait for last cluster to be written.
NeilBrown [Tue, 25 Aug 2009 07:21:30 +0000 (17:21 +1000)]
umount: wait for last cluster to be written.

checkpoint_unlock_wait only wait for the last cluster
to start.  We need to wait for all writes to be complete so
that no inodes remained pinned.

16 years agoAccount for some more temporary credits.
NeilBrown [Tue, 25 Aug 2009 07:09:55 +0000 (17:09 +1000)]
Account for some more temporary credits.

This might save us from a few check_credits warnings.

16 years agoDocumentation updates and some BUG_ON and tracing.
NeilBrown [Tue, 25 Aug 2009 07:09:55 +0000 (17:09 +1000)]
Documentation updates and some BUG_ON and tracing.

16 years agoSlight improvement in tracing in orphan_pin
NeilBrown [Tue, 25 Aug 2009 07:09:55 +0000 (17:09 +1000)]
Slight improvement in tracing in orphan_pin

16 years agoRename share_uninic to share_uninc
NeilBrown [Tue, 25 Aug 2009 07:09:55 +0000 (17:09 +1000)]
Rename  share_uninic to share_uninc

As the former is a typo.

16 years agoAvoid confusion with ref name "orphans"
NeilBrown [Tue, 25 Aug 2009 07:09:55 +0000 (17:09 +1000)]
Avoid confusion with ref name "orphans"

Two different places use the reference name "orphans", so change one
to avoid confusion.

16 years agoDemote check_credits from BUG to WARNING.
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
Demote check_credits from BUG to WARNING.

Races and other things can cause inbalances.

16 years agoAdd tracing for seg_move
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
Add tracing for seg_move

This turns out to be very useful for tracking segment usage.

16 years agosimplify seg_apply
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
simplify seg_apply

Just call seg_inc rather than open coding most of that
functionality.

16 years agolafs_print_tree: export and use in super.
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
lafs_print_tree: export and use in super.

This is for tracking an unmount bug, but print_tree seems
generally useful, so export it.

16 years agolafs_incorporate - don't clear a block with children.
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
lafs_incorporate - don't clear a block with children.

If an index block has children, then erasing it is pointless
and confusing.  So don't.

16 years agoImprove tracing for lafs_incorporate.
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
Improve tracing for lafs_incorporate.

Show the uninc list as well, and do it before trying to
incorporate.

16 years agosilly typo in do_incorporate_leaf.
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
silly typo in do_incorporate_leaf.

The 'type' header is 2 bytes.

16 years agoAccelerate walk_indirect.
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
Accelerate walk_indirect.

If an indirect block is being asked to incorporate an address that
is very must after the address of the block, it has to count all
the way up to that number, which is a waste of time.
So if there is an opportunity to jump forward, take it.

16 years agoincorporate: always call sort_blocks on the uninc list.
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
incorporate: always call sort_blocks on the uninc list.

Were were not calling it when trying the 'simple' incorporation.

16 years agoFix add_extent
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
Fix add_extent

We weren't updating the lastaddr/lastphys at all!!

16 years agocorrect some comments in lafs.h
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
correct some comments in lafs.h

I was spelling the idtag wrongly.

16 years agoIO: support loading of an index block from addr 0.
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
IO: support loading of an index block from addr 0.

This can happen when adding blocks to a prevously truncated
file, or even when continuing with a slow truncate.

phys==0 just means the index block is empty, so honour that.

16 years agotruncate: make sure index block is pinned and dirty when we prune it.
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
truncate: make sure index block is pinned and dirty when we prune it.

16 years agotruncate: make sure index changes get incorporated.
NeilBrown [Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)]
truncate: make sure index changes get incorporated.

When we have used lafs_incorporate to clear and unpin
an index block we need to incorporate the parent so that
the unpinned block gets fully released.

16 years agoFix prune_some.
NeilBrown [Tue, 25 Aug 2009 07:09:52 +0000 (17:09 +1000)]
Fix prune_some.

We need to put phys==0 into the uninc_table, not the current phys.
This might end up not being very efficient... might need to rethink
it.

16 years agoMove a dprintk in delete_inode
NeilBrown [Tue, 25 Aug 2009 07:09:52 +0000 (17:09 +1000)]
Move a dprintk in delete_inode

We very often enter delete_inode (when cleaning) on an inode that
doesn't really exist.  So only print a message if this is a real
inode needing to be deleted.

16 years agoRemove useless test in lafs_add_block_address
NeilBrown [Tue, 25 Aug 2009 07:09:52 +0000 (17:09 +1000)]
Remove useless test in lafs_add_block_address

If it is an Index block, we never get to this test, so there is
no point testing it again.

16 years agoleaf_find: make sure returned block is IOLocked.
NeilBrown [Tue, 25 Aug 2009 07:09:52 +0000 (17:09 +1000)]
leaf_find: make sure returned block is IOLocked.

If we had to return a sibling of the found block, we weren't
getting an IOLock on it, which is bad.

16 years agoDon't accept failure from lafs_add_block_address
NeilBrown [Tue, 25 Aug 2009 07:09:52 +0000 (17:09 +1000)]
Don't accept failure from lafs_add_block_address

If this returns 0, it didn't add the address, so we need to
call it repeatedly.

16 years agoincorporate_index - minor cleanups.
NeilBrown [Tue, 25 Aug 2009 07:09:51 +0000 (17:09 +1000)]
incorporate_index - minor cleanups.

Improve robustness and remove a LAFS_BUG that only ever for
a NULL block.

16 years agoInitialise inode->update_cluster
NeilBrown [Tue, 25 Aug 2009 07:09:51 +0000 (17:09 +1000)]
Initialise inode->update_cluster

16 years agoIntroduce lafs_index_empty.
NeilBrown [Tue, 25 Aug 2009 07:09:51 +0000 (17:09 +1000)]
Introduce lafs_index_empty.

We currently use lafs_leaf_next to test if an index block is empty,
but that doesn't work on internal nodes of course.
So create lafs_index_empty for that purpose.

16 years agoUpdates summaries when flushing a block into the inode.
NeilBrown [Tue, 25 Aug 2009 07:09:51 +0000 (17:09 +1000)]
Updates summaries when flushing a block into the inode.

If the block previously had a real address, we need to
release that address for reuse.

16 years agocleaner: recognise end of segment properly.
NeilBrown [Tue, 25 Aug 2009 07:09:51 +0000 (17:09 +1000)]
cleaner: recognise end of segment properly.

If we find an incorrect cluster header, then abort cleaning
for that segment.  This should not normally happen as we
shouldn't clean a segment until it has been completely written.
But we need to protect against it anyway.

16 years agosegments: don't lose delayed updates.
NeilBrown [Tue, 25 Aug 2009 07:09:51 +0000 (17:09 +1000)]
segments: don't lose delayed updates.

We need to keep ss if it has negative updates as well as
positive.

16 years agoSplit B_Writeback out from B_IOLock
NeilBrown [Tue, 25 Aug 2009 07:09:49 +0000 (17:09 +1000)]
Split B_Writeback out from B_IOLock

It is best to have Writeback separate from Lock, just like pages
do.  Then readonly accesses don't have to wait for writeback to
finish.

16 years agoFix iolock semantics.
NeilBrown [Mon, 24 Aug 2009 03:30:30 +0000 (13:30 +1000)]
Fix iolock semantics.

There are some races with IOlock and page unlock due to bad
assumption.
So make things more explicit with a flag to say if we own
the lock, or the 'Writeback' flag.

This allows us to remove the extra flag to iounlock_block
which is really nice because it always confused me.

A significant but subtle part of the locking involved the
fact that one a page has been read, it will not be read
again, so when readpage calls lafs_iocheck_block it is not
possible that it will unlock incorrectly.
It could conceivably unwriteback incorrectly, but next patch
should fix that.

16 years agoCorrectly handle Dirty index blocks during truncate
NeilBrown [Mon, 24 Aug 2009 03:30:28 +0000 (13:30 +1000)]
Correctly handle Dirty index blocks during truncate