]> git.neil.brown.name Git - LaFS.git/log
LaFS.git
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

16 years agoIOLock all accesses to index blocks.
NeilBrown [Mon, 24 Aug 2009 03:30:27 +0000 (13:30 +1000)]
IOLock all accesses to index blocks.

We really don't need them to change while being read.
This creates a possibly unpleasant conflict with writeout,
so maybe we need a IOWriteback flag for writeout...

16 years agoUse i_data rather than i_mapping
NeilBrown [Mon, 24 Aug 2009 03:30:26 +0000 (13:30 +1000)]
Use i_data rather than i_mapping

For this filesystem, i_mapping always points to i_data,
so dereferencing the pointer is a total waste of a memory
access.

16 years agoRevise dirty/valid rules for Index blocks.
NeilBrown [Mon, 24 Aug 2009 03:30:24 +0000 (13:30 +1000)]
Revise dirty/valid rules for Index blocks.

An Index block is 'Valid' if it contains any index.
So an InoIdx block for a depth=0 inode is never Valid
(as there is data rather than indexes there).

When it comes time to cluster_allocate an Index block,
if it is not Valid, we simple allocated_block it to 0.

An index block is Dirty if there are any children that need incorporation
as well was when incorporate has happened but has not yet been
written.
So an Index block can be Dirty but not Valid (unlike data blocks).

16 years agoMake sure inode dblock stayed pinned in checkpoint.
NeilBrown [Tue, 18 Aug 2009 06:12:55 +0000 (16:12 +1000)]
Make sure inode dblock stayed pinned in checkpoint.

In order for a dblock to stay pinned, we need PinPending to be set.

16 years agoMake sure orphans are cleaned up when inode creation fails.
NeilBrown [Mon, 17 Aug 2009 01:54:44 +0000 (11:54 +1000)]
Make sure orphans are cleaned up when inode creation fails.

16 years agoRelease ino when file creation fails.
NeilBrown [Mon, 17 Aug 2009 01:52:28 +0000 (11:52 +1000)]
Release ino when file creation fails.

Due to a hack elsewhere, we need to explicitly set
nlink to 0 when creation fail.  The hack needs to be
fixed but for now, just set nlink to 0.

16 years agoLAFS_BUG add new debug macro that prints block information.
NeilBrown [Sun, 16 Aug 2009 06:39:21 +0000 (16:39 +1000)]
LAFS_BUG add new debug macro that prints block information.

16 years agoCleaner: make sure we finish the job.
NeilBrown [Sun, 16 Aug 2009 05:20:30 +0000 (15:20 +1000)]
Cleaner: make sure we finish the job.

If there might be blocks in the ->cleaning list even after
we have read all of the cluster headers.  So make sure we continue
cleaning until all of those are dealt with.

16 years agomake sure blocks are always refiled after Pinned is set.
NeilBrown [Sat, 15 Aug 2009 07:09:26 +0000 (17:09 +1000)]
make sure blocks are always refiled after Pinned is set.

This is important to ensure they go on the leaf lru.
There was one place we weren't doing the right thing.

16 years agoImprove credit handling when flushing a data block into the inode.
NeilBrown [Sat, 15 Aug 2009 07:09:24 +0000 (17:09 +1000)]
Improve credit handling when flushing a data block into the inode.

Both the credit and icredit need to be moved from the data block
to the inode data block (if needed)

16 years agomake checkpointing more robust
NeilBrown [Sat, 15 Aug 2009 07:09:23 +0000 (17:09 +1000)]
make checkpointing more robust

As long as the root inode hasn't changed phase, we keep
looking for things to do.
If things got confused, this could livelock, which would be bad...

16 years agoSimplify writeout rules for inode data block.
NeilBrown [Sat, 15 Aug 2009 07:09:22 +0000 (17:09 +1000)]
Simplify writeout rules for inode data block.

Previously we did not write an inode data block until the
InoIdx was ready.
This is not good if we need to sync an inode well before checkpoint
runs.
So just write an inde data block when we find it, but ensure not to
send an inode data block during checkpoint until the InoIdx block is
ready.

Note: it is now clear why an inode has two sets of credits, one on the
data block and one on the index block.  The first set may be needed to
sync the inode metadata.  The second may be need to update the
indexing information - they are copied across to the data block for
this purpose.

16 years agoSimplify iolocking in get_flushable
NeilBrown [Sat, 15 Aug 2009 07:09:20 +0000 (17:09 +1000)]
Simplify iolocking in get_flushable

The difference between data and index block is not really supportable,
and we cannot just avoid waiting for some blocks.

But we cannot always for a full iowait as block that have been
allocated to a cluster do not complete until the cluster is written
and we don't want to wait for a cluster to be written, especially as
we there thread that is supposed to do that.

So create an intermediate iowait which wait for iolock to be dropped
or the block to be placed on a list.  Once it is on a list we can be
sure not to lose it.

So we wait while incorporation or truncation happens, but not while
writeout happens.

16 years agoAvoid races when processing blocks for checkpoint.
NeilBrown [Sat, 15 Aug 2009 07:03:19 +0000 (17:03 +1000)]
Avoid races when processing blocks for checkpoint.

When doing a checkpoint we need to be sure that every
flushable block is accounted for.  So we need to be able
to wait for anything outstanding.

Currently a block can be removed from the leaflist by writepage
before it is placed on the cluster list.  During this window
the checkpoint thread cannot see it and so might progress without
waiting for and so will think it has completed prematurely.

So delay the removal from the leaflist until after we have the
writecluster lock.  This assures that every leaf block will be
either on the leaf list or on the cluster list when checkpoint is
looking for it.

When checkpoint calls cluster_done, this will release any blocks
from the cluster and, if needed, put them back on the leaf list where
they can be found again.

16 years agoRemove dirtying of InoIdx in place of inode data block.
NeilBrown [Sat, 15 Aug 2009 05:52:56 +0000 (15:52 +1000)]
Remove dirtying of InoIdx in place of inode data block.

I don't remember why this was here, but until very recently
the code was wrong so it didn't do the "right" thing anyway.
And it doesn't seem to make sense.

When we dirty a dblock, we really want it to be dirty.
We might then write it and roll-forward will be able to pick
it all up except the index information which is always
calculated from addresses that are actually found.

16 years agoDon't set Valid when setting Dirty.
NeilBrown [Sat, 15 Aug 2009 05:52:49 +0000 (15:52 +1000)]
Don't set Valid when setting Dirty.

While a block must be Valid to be Dirty, it is best to
only set Valid when actually putting data in the block,
and then check that it is Valid when marking it Dirty.
That can catch more bugs.

16 years agoinode: Fix problems at inode creation.
NeilBrown [Sat, 15 Aug 2009 05:49:46 +0000 (15:49 +1000)]
inode: Fix problems at inode creation.

- we need to pin the new inode dblock to ensure it gets written
- we don't need to dirty it in inode_map_new_commit as it is already
  dirtied in lafs_inode_init.

16 years agolafs_allocated_block: don't repeat so much for a new_parent
NeilBrown [Sat, 15 Aug 2009 05:49:42 +0000 (15:49 +1000)]
lafs_allocated_block: don't repeat so much for a new_parent

When we find that incorporation has pushed us to a new parent,
we don't need to repeat so much.... maybe not even very much at all

16 years agolafs_refile: only use ->inode pointer when we know it is valid.
NeilBrown [Sun, 9 Aug 2009 06:11:08 +0000 (16:11 +1000)]
lafs_refile: only use ->inode pointer when we know it is valid.

->inode may be invalid if block is not pinned, or at least
has a parent.  So don't try to find 'fs' from it until we know
we will need it.

16 years agoDon't insist on having UnincCredits for all Index blocks.
NeilBrown [Sun, 9 Aug 2009 05:50:54 +0000 (15:50 +1000)]
Don't insist on having UnincCredits for all Index blocks.

When an Index block has room for new addresses, it does not need to
have an UnincCredit because we know it will not split before more
credits are available.

16 years agotemp_credits accounting.
NeilBrown [Sat, 8 Aug 2009 05:25:07 +0000 (15:25 +1000)]
temp_credits accounting.

Allow - in a totally smp-unsafe way - for credits which
aren't stored anywhere to be accounted when checking totals.

16 years agoBe sure to remove all credits when releasing a block from a page.
NeilBrown [Sat, 8 Aug 2009 04:56:29 +0000 (14:56 +1000)]
Be sure to remove all credits when releasing a block from a page.

As it has just become unlinked.

16 years agoMake sure inodes don't get forgotten during cleaning.
NeilBrown [Sat, 8 Aug 2009 04:23:40 +0000 (14:23 +1000)]
Make sure inodes don't get forgotten during cleaning.

During cleaning and other times when inodes might have dirty
index blocks we don't want the inode to be pushed out due to
apparently not being in use.

However there is a difficulty in holding a reference on the inode as
that cause the truncate following a final unlink to be delayed.

So to compromise, whenever the InoIdx block for an inode is pinned,
hold a reference to the inode as long as the link count is non-zero.

Once the link count becomes zero, we drop the extra ref and if this
leads to the inode being deleted, the current delaying of this
deletion (while the dblock is references) will keep the inode around
just long enough.

16 years agocleaner: hold ref on inode while preparing to clean blocks.
NeilBrown [Wed, 5 Aug 2009 06:38:08 +0000 (16:38 +1000)]
cleaner: hold ref on inode while preparing to clean blocks.

b->inode does not own a reference to the inode so we need to have some
other way to make sure it never goes invalid.
Normal filesystem references are safe as the VFS will truncate pages
before freeing the inode.   But cleaner accesses don't benefit from
that.

Once a block is Pinned (e.g. when B_Realloc) it owns a reference up to
the InoIdx and so the dblock is also referenced.   This ensures that
the inode won't go away even on destroy_inode.
However we hold a block for a short period before it is Pinned, so we
must hold a reference on the inode for that period as well.

16 years agocleaner: avoid blocks that are beyond the end of file.
NeilBrown [Wed, 5 Aug 2009 05:23:24 +0000 (15:23 +1000)]
cleaner: avoid blocks that are beyond the end of file.

This is a fairly half-hearted attempt which is more to
leave a reminder to get it right later.

16 years agoMake sure cleaner doesn't start up after the FinalCheckpoint
NeilBrown [Wed, 5 Aug 2009 05:13:24 +0000 (15:13 +1000)]
Make sure cleaner doesn't start up after the FinalCheckpoint

We need to leave the cleaner thread running for checkpoint processing,
but don't want an really cleaning happening after the FinalCheckpoint.
So check and don't start anything new.

16 years agoDon't use B_Credit to set B_Realloc
NeilBrown [Mon, 3 Aug 2009 01:28:37 +0000 (11:28 +1000)]
Don't use B_Credit to set B_Realloc

We need to keep B_Credit to possibly set B_Dirty (if a B_Realloc
block gets dirtied while being written to the 'clean' cluster we
still need to write it to a normal cluster).
So Find B_Realloc from elsewhere, use lafs_space_alloc if needed,
or as a last result setting B_Dirty.

16 years agoDon't clear B_Realloc when setting B_Dirty
NeilBrown [Mon, 3 Aug 2009 00:36:59 +0000 (10:36 +1000)]
Don't clear B_Realloc when setting B_Dirty

If the block has not yet been allocated to a cluster, then
B_Realloc will be cleared just before cluster allocation, and the
allocate won't happen.
If the block has already been allocated to a cluster for cleaning,
then we need the credit implied by B_Realloc so we shouldn't clear it.
The block will later be written to a normal cluster on the basis of
B_Dirty, so try to forget this cleaning, and in particular don't call
lafs_allocated_block as that will be a waste.....
Instead call lafs_pin_block to ensure that the block gets written out
in this phase, which is as good as cleaning.

16 years agoREADME update and minor cosmetic changes.
NeilBrown [Sun, 2 Aug 2009 11:09:49 +0000 (21:09 +1000)]
README update and minor cosmetic changes.

16 years agoMake sure segusage blocks are uptodate in seg_apply.
NeilBrown [Sun, 2 Aug 2009 11:09:47 +0000 (21:09 +1000)]
Make sure segusage blocks are uptodate in seg_apply.

During roll-forward they can be not-read-yet.

16 years agoRelax requirement for UnincCredit in lafs_allocated_block
NeilBrown [Sun, 2 Aug 2009 10:11:32 +0000 (20:11 +1000)]
Relax requirement for UnincCredit in lafs_allocated_block

A block that is being deleted and so has a new phys address of
0 does not need an UnincCredit.

16 years agoclean: don't allow C or F to go negative.
NeilBrown [Sun, 2 Aug 2009 10:08:47 +0000 (20:08 +1000)]
clean: don't allow C or F to go negative.

As these are unsigned values, negatives are bad and confusing.

16 years agoFix use-wrong-variable bug in cluster_insert
NeilBrown [Sun, 2 Aug 2009 09:52:20 +0000 (19:52 +1000)]
Fix use-wrong-variable bug in cluster_insert

I deleted the wrong thing from a list.

16 years agorelease iolock in lafs_phase_flip
NeilBrown [Sun, 2 Aug 2009 09:50:55 +0000 (19:50 +1000)]
release iolock in lafs_phase_flip

The tail end of lafs_phase_flip needs the iolock to have been
dropped, so always drop it somewhere in lafs_phase_flip.

16 years agoAdd tracing to help find iolock deadlocks
NeilBrown [Sun, 2 Aug 2009 09:47:40 +0000 (19:47 +1000)]
Add tracing to help find iolock deadlocks

i.e. record the place where the iolock was last claimed
on each block.

16 years agocluster_flush credit handling.
NeilBrown [Sun, 2 Aug 2009 09:29:52 +0000 (19:29 +1000)]
cluster_flush credit handling.

Combine calls to space_use and space_return as they do the same thing.
And move them up to immediately after the credits have been calculated
to avoid possibility of the credit-counter finding an incorrect count
that is only transient.

16 years agoClear uninc_credit when removing a data block from the tree.
NeilBrown [Sun, 2 Aug 2009 09:29:52 +0000 (19:29 +1000)]
Clear uninc_credit when removing a data block from the tree.

We must drop this credit to keep the counts correct..

16 years agoImprove prepare_checkpoint locking.
NeilBrown [Sun, 2 Aug 2009 09:29:52 +0000 (19:29 +1000)]
Improve prepare_checkpoint locking.

prepare_checkpoint currently takes wc[0].lock.
This is presumably to avoid races with ->checkpointing updates.
However it causes a deadlock if any code that holds the checkpoint
lock needs to flush a cluster or make other updates to a cluster,
which can happen.
So use fs->lock to protect ->checkpointing instead.

16 years agoflush_data_to_inode fixes.
NeilBrown [Sun, 2 Aug 2009 09:29:52 +0000 (19:29 +1000)]
flush_data_to_inode fixes.

When flushing data to the inode, mark the dblock dirty
rather than the iblock.  We aren't allow to mark the iblock
dirty unless it is pinned, which it might not be....
It must be preallocated as the data is dirty, but the iblock doesn't
get pinned until the data is actually written.
As the inode data block is not pinned, it might not be written in
a particular phase, but that isn't a problem as long as it gets
written some time.

Add a BUG_ON if we ever try to dirty a non-Pinned index block again.
They are a problem because non-pinned InoIdx can lose their dblock
and then they fall out of the tree.

Also fix the space_return - we have already returned for the Dirty
flag.

16 years agofix max height for segment skiplist.
NeilBrown [Sun, 2 Aug 2009 09:29:52 +0000 (19:29 +1000)]
fix max height for segment skiplist.

The max is defined as 8, but we use 9 !!!
Fix this and make sure it doesn't happen again.

16 years agocount credits for debugging
NeilBrown [Sun, 2 Aug 2009 09:29:51 +0000 (19:29 +1000)]
count credits for debugging

Add code to count the number of credits in the tree
and make sure it matches the allocated_blocks number.
Call this at some useful places.

16 years agolafs_put_super - don't putref dblock
NeilBrown [Sun, 2 Aug 2009 09:29:51 +0000 (19:29 +1000)]
lafs_put_super - don't putref dblock

There is no need for this putref here - normal inode handling
gets it right.

16 years agolafs_shrinker fixes.
NeilBrown [Sun, 2 Aug 2009 09:29:51 +0000 (19:29 +1000)]
lafs_shrinker fixes.

1/ only clear inode->iblock if the block we are about to
   free is the InoIdx block (i.e. is inode->iblock).
2/ Assume that unreffed iblocks are not pinned, they should
   never be.

16 years agolafs_release_index: free all index blocks when freeing an inode.
NeilBrown [Sun, 2 Aug 2009 09:29:49 +0000 (19:29 +1000)]
lafs_release_index: free all index blocks when freeing an inode.

That than leaving the index blocks on the free list in an
to-be-freed state, actively free them when the inode is freed.

16 years agoFix freeing of inodes and ->dblock
NeilBrown [Sun, 2 Aug 2009 09:29:49 +0000 (19:29 +1000)]
Fix freeing of inodes and ->dblock

The inode and the dblock each have a reference to the other.  Neither
are counted because:
   We don't want the inode to refcnt the dblock as that wastes space.
   We don't want the dblock to refcnt the inode as that stops it from
     being freed.

So when either is freed, it must remove the reference from the other.
To ease locking,  when the inode is freed it converts the reference,
if present, to a counted reference (using the same rule as
lafs_inode_dblock), then flags the inode for destruction and drops
the reference.

When the last reference to a dblock is dropped, it removes
both references and the calls destroy_inode again.

Notes that the dblock only exists while the inode exists - as soon
as the inode is destroyed, any dblock that might be around will
quickly get destroyed too, and the inode destruction is delayed until
this point.

16 years agoSet I_Deleting on root inode during unmount
NeilBrown [Sun, 2 Aug 2009 09:29:49 +0000 (19:29 +1000)]
Set I_Deleting on root inode during unmount

I don't remember exactly why I need this unfortunately....

16 years agogetref_locked fixes.
NeilBrown [Sun, 2 Aug 2009 09:29:49 +0000 (19:29 +1000)]
getref_locked fixes.

When lafs_dirty_inode chooses to dirty the dblock, because there
is no iblock, we need to getref_locked that dblock because there
will be no implied reference.

And when doing that, don't dereference ->my_inode unless we are sure
it is valid - i.e. that this is a block in an inode file.

16 years agoUse write_super to start checkpoint and sync_fs to wait for it.
NeilBrown [Sun, 2 Aug 2009 09:29:48 +0000 (19:29 +1000)]
Use write_super to start checkpoint and sync_fs to wait for it.

There are always called in the right order and at the right place,
and this gives us a bit more control.

I don't remember why the cluster_flush was there, so I don't know
where to put it..

16 years agoroll: use add_block_address rather than allocated block.
NeilBrown [Sun, 2 Aug 2009 09:29:48 +0000 (19:29 +1000)]
roll: use add_block_address rather than allocated block.

This avoids messing around with setting 'dirty' flags.

16 years agoallocated_block: split out part of code for use in phase_flip.
NeilBrown [Sun, 2 Aug 2009 09:29:48 +0000 (19:29 +1000)]
allocated_block: split out part of code for use in phase_flip.

When we flip phase, delayed incorporation needs to include addresses
in to the block.  But some of the lafs_allocated_block work has
already been done.  So split out the rest into a smaller function
for phase_flip to call.

16 years agoput_super: release orphan and segsum files.
NeilBrown [Sun, 2 Aug 2009 09:29:48 +0000 (19:29 +1000)]
put_super: release orphan and segsum files.

These files need to be released at unmount...

16 years agoumount fixups - flush in the right place.
NeilBrown [Sun, 2 Aug 2009 09:29:27 +0000 (19:29 +1000)]
umount fixups - flush in the right place.

We really need to sync the filesystem before the
final checkpoint and other cleanups in lafs_release.
So move them to lafs_put_super so they get done after
the sync in generic_shutdown_super, but before the superblock
is completely destroyed.

16 years agorefile: when clearing Pinned, remove from lru too
NeilBrown [Sun, 2 Aug 2009 09:28:53 +0000 (19:28 +1000)]
refile: when clearing Pinned, remove from lru too

As only pinned blocks should be on leafs lru.

16 years agorefile: blocks with B_IOLock are not on lru
NeilBrown [Sun, 2 Aug 2009 09:28:53 +0000 (19:28 +1000)]
refile: blocks with B_IOLock are not on lru

so don't assume they are when checking refcounts.

16 years agocluster_allocate: remove from leafs list if needed.
NeilBrown [Sun, 2 Aug 2009 09:28:53 +0000 (19:28 +1000)]
cluster_allocate: remove from leafs list if needed.

When lafs_writepage called cluster_allocate, the block could
be on a leafs list.  In that case we need to cleanly remove it
from the list as lru is about to be used for a different purpose,
and it doesn't need to be on the list for a while.

16 years agodir orphans: always put orphans on the dirorphan list.
NeilBrown [Sun, 2 Aug 2009 09:28:52 +0000 (19:28 +1000)]
dir orphans: always put orphans on the dirorphan list.

Once we call orphan_pin, we must put the block on the
dirorphans lists so that it can be checked and possibly
unorphaned.  Otherwise the B_Orphan flag which was set will
never be cleared.

16 years agocluster_allocate: handle credits better.
NeilBrown [Sun, 2 Aug 2009 09:28:52 +0000 (19:28 +1000)]
cluster_allocate: handle credits better.

When moving credits from InoIdx to Inode data, allow for
the InoIdx not to have any if the Inode data already has enough.

16 years agoCheckpoint: allocate InoIdx block if data block is dirty.
NeilBrown [Sun, 2 Aug 2009 09:28:52 +0000 (19:28 +1000)]
Checkpoint: allocate InoIdx block if data block is dirty.

Sometimes the Inode data block can be dirty without the InoIdx
block being dirty.  We still need to write it out, so we move the
'pinning' across from the index to data blocks be calling
allocate here.