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

16 years agoSet page dirty when a data block becomes dirty.
NeilBrown [Sun, 2 Aug 2009 09:28:52 +0000 (19:28 +1000)]
Set page dirty when a data block becomes dirty.

This is important to ensure that memory pressure or fsync writes
out directories and other internally-managed files.

16 years agolafs_get_block without page lock.
NeilBrown [Sun, 2 Aug 2009 09:28:52 +0000 (19:28 +1000)]
lafs_get_block without page lock.

We need to be able to lafs_get_block an existing block even if
the page is locked.  So handle that case using ->private_lock.

Also release the page at the end..

16 years agoMKREF(dblock) should have been MKREF(iblock)
NeilBrown [Sun, 2 Aug 2009 09:28:52 +0000 (19:28 +1000)]
MKREF(dblock) should have been MKREF(iblock)

The iblock holds a reference to the dblock, hence the
confusion...

16 years agoFix sort/splitting in add_cleanable.
NeilBrown [Sun, 2 Aug 2009 09:28:51 +0000 (19:28 +1000)]
Fix sort/splitting in add_cleanable.

When the cleanable list reaches a certain length, we sort it and
discard the half which are least ready to be cleaned.
That code was broken and is now fixed.

16 years agoEmpty the segsum cache at unmount
NeilBrown [Sun, 2 Aug 2009 09:28:51 +0000 (19:28 +1000)]
Empty the segsum cache at unmount

These all hold references to blocks which need to be released.

16 years agoClean out segment table at unmount time.
NeilBrown [Sun, 2 Aug 2009 09:28:51 +0000 (19:28 +1000)]
Clean out segment table at unmount time.

Each entry in the table holds a reference to some blocks,
so we need to clean them out to release all those references.

16 years agoClear I_Deleting when delayed-truncate finishes.
NeilBrown [Sun, 2 Aug 2009 09:28:51 +0000 (19:28 +1000)]
Clear I_Deleting when delayed-truncate finishes.

Otherwise if the delayed truncate completes before we try
to destroy, destruction never happens.

16 years agoPerform a "Final Checkpoint" during unmount.
NeilBrown [Sun, 2 Aug 2009 09:28:45 +0000 (19:28 +1000)]
Perform a "Final Checkpoint" during unmount.

This checkpoint must leave everything clean, so we don't
flush out any segusage changes that will be picked up by
roll-forward anyway.

16 years agoWait correctly for checkpoint to finish.
NeilBrown [Thu, 23 Jul 2009 04:08:13 +0000 (14:08 +1000)]
Wait correctly for checkpoint to finish.

We really need to wait for it to have started and finished,
else we might stop waiting before the real finish.

16 years agoPut all intable references.
NeilBrown [Thu, 23 Jul 2009 04:08:13 +0000 (14:08 +1000)]
Put all intable references.

When segments are referenced by the free/clean segment table,
it implies a reference to the segusage blocks.
So when we remove things from the table, drop the reference.

16 years agoUse strblk is more places.
NeilBrown [Thu, 23 Jul 2009 04:08:07 +0000 (14:08 +1000)]
Use strblk is more places.

Where we printed ino/fileaddr, just use strblk.

16 years agoPrint orphan_slot number of strblk
NeilBrown [Wed, 22 Jul 2009 06:16:24 +0000 (16:16 +1000)]
Print orphan_slot number of strblk

16 years agoUse inode_{inc,dec}_link_count
NeilBrown [Wed, 22 Jul 2009 06:14:01 +0000 (16:14 +1000)]
Use inode_{inc,dec}_link_count

as it is the approved way to change i_nlink.

16 years agoStop the cleaner at unmount
NeilBrown [Wed, 22 Jul 2009 05:40:45 +0000 (15:40 +1000)]
Stop the cleaner at unmount

16 years agoVarious fixes...
NeilBrown [Mon, 20 Jul 2009 06:25:34 +0000 (16:25 +1000)]
Various fixes...

16 years agomore segusage refcount stuff.
NeilBrown [Mon, 20 Jul 2009 02:40:45 +0000 (12:40 +1000)]
more segusage refcount stuff.

(sorry, too long ago to remember)

16 years agoSeg: add youthblk to segsum
NeilBrown [Sat, 18 Apr 2009 02:04:29 +0000 (12:04 +1000)]
Seg: add youthblk to segsum

and make sure it is cleaned up when appropriate.

16 years agoYouth: dirty block when setting youth value, and other tidy ups.
NeilBrown [Mon, 13 Apr 2009 10:50:07 +0000 (20:50 +1000)]
Youth: dirty block when setting youth value, and other tidy ups.

When setting the youth for a newly allocated segment, make sure
to mark youth block 'dirty'.

Also reduce range of 'map_dblock' to where it is really needed.

16 years agoREADME update
NeilBrown [Mon, 13 Apr 2009 09:48:05 +0000 (19:48 +1000)]
README update

16 years agotest: test for umount at the end of everything.
NeilBrown [Mon, 13 Apr 2009 09:38:30 +0000 (19:38 +1000)]
test: test for umount at the end of everything.

16 years agoroll-forward: handle segusage blocks better.
NeilBrown [Mon, 13 Apr 2009 09:36:33 +0000 (19:36 +1000)]
roll-forward:  handle segusage blocks better.

During roll-forward we mustn't load segusage blocks until we have
processed the checkpoint.  During that time segusage updates must be
delayed.
So make sure phase and qphase have suitable setting, and delay the
load where appropriate.
This allows us to remove 'in_checkpoint' as it can be determined from
qphase.

16 years agowalk_leaf_index - use kmap, not kmap_atomic
NeilBrown [Mon, 13 Apr 2009 01:50:31 +0000 (11:50 +1000)]
walk_leaf_index - use kmap, not kmap_atomic

When truncating a file, we need to update the segusage counts
for all relevant segments.  This can require reading segusage blocks
while walking a leaf index.  So we cannot use kmap_atomic in
lafs_walk_leaf_index.  So use kmap instead.

16 years agoiget - use symbolic error code, not number.
NeilBrown [Mon, 13 Apr 2009 01:46:45 +0000 (11:46 +1000)]
iget - use symbolic error code, not number.

16 years agoFix dirty_block for inode data blocks.
NeilBrown [Mon, 13 Apr 2009 01:43:07 +0000 (11:43 +1000)]
Fix dirty_block for inode data blocks.

When an inode block is to be marked dirty, make the
InoIdx block dirty instead.  When it gets written, the dirtiness
then gets moved to the data block and it gets written.

Also, don't unpin the InoIdx block while the data blocks
is dirty.  This probably shouldn't happen, but adding the test
is safest.

16 years agolafs_seg_deref - actually use it.
NeilBrown [Mon, 13 Apr 2009 01:27:16 +0000 (11:27 +1000)]
lafs_seg_deref - actually use it.

We never clear B_SegRef and drop the associated reference.
Also never drop the reference on the current writeout segment.
Fix that.

16 years agolafs_seg_ref - take all required references.
NeilBrown [Mon, 13 Apr 2009 01:18:31 +0000 (11:18 +1000)]
lafs_seg_ref - take all required references.

Every dirty or pinned block needs a reference to the segment usage
count for the segment holding that block.
This must be a writable reference so that when the block is written
the segusage can be decremented.

A writable reference requires a pinned block so the segusage block
must hold segref as well.  This can recurse a couple of levels.

So introduce lafs_seg_ref_block which walks through the recursion
and gets some seg references at the bottom of the recursion.
Then have lafs_reserve_block call seg_ref_block repeatedly until
everything required has a SegRef.

16 years agolafs_invalidate_page: don't erase blocks in special files.
NeilBrown [Mon, 13 Apr 2009 00:19:39 +0000 (10:19 +1000)]
lafs_invalidate_page: don't erase blocks in special files.

Special internal files - particularly the inode file - does not
keep i_size up-to-date (it really isn't needed) so erasing
blocks beyond i_size is inappropriate.
All internal files do their own block erasure as needed without
depending in the setting of i_size, so simply ignore the
size on these files.

16 years agoClear CheckpointNeeded
NeilBrown [Mon, 13 Apr 2009 00:15:48 +0000 (10:15 +1000)]
Clear CheckpointNeeded

This bit was previously set but never cleared.

16 years agoUpdate segrefs when changing phys address.
NeilBrown [Mon, 13 Apr 2009 00:13:41 +0000 (10:13 +1000)]
Update segrefs when changing phys address.

When changing the ->physaddr of a block which holds a SegRef,
we must move the reference to the new segment.

So track whether a segref needs to be moved, and make the appropriate
refcount changes.

16 years agoreadpage: add missing putdref
NeilBrown [Sun, 12 Apr 2009 23:54:45 +0000 (09:54 +1000)]
readpage: add missing putdref

17 years agosegments.c: refcount fixes
NeilBrown [Sun, 29 Mar 2009 21:12:28 +0000 (08:12 +1100)]
segments.c: refcount fixes

17 years agoorphan.c: lots of refcount fixes.
NeilBrown [Sun, 29 Mar 2009 21:11:20 +0000 (08:11 +1100)]
orphan.c:  lots of refcount fixes.

Choose better ref names, and make sure were put them
appropriately.

17 years agoinode.c refcount fixes.
NeilBrown [Sun, 29 Mar 2009 21:06:57 +0000 (08:06 +1100)]
inode.c refcount fixes.

I had forgotten serveral 'iput's and similar.

17 years agoCosmetic cleanups.
NeilBrown [Fri, 20 Mar 2009 11:24:04 +0000 (22:24 +1100)]
Cosmetic cleanups.

Mostly checkpatch.pl warnings, but also remove some old, uninteresting
printks and things like that.

17 years agoMake sure all global functions have distinctive names.
NeilBrown [Thu, 19 Mar 2009 23:01:36 +0000 (10:01 +1100)]
Make sure all global functions have distinctive names.

All non-static functions should have names starting lafs_ or
_lafs_.  A few had slipped in that didn't so resolve them either
making them static or changing their name.

17 years agoCleanup timestamp handling.
NeilBrown [Thu, 19 Mar 2009 21:53:56 +0000 (08:53 +1100)]
Cleanup timestamp handling.

 - register correct s_time_gran
 - remove useless lafs_timestamp
 - fix encode_time

17 years agoTruncate from arbitrary offset in file.
NeilBrown [Thu, 19 Mar 2009 10:46:35 +0000 (21:46 +1100)]
Truncate from arbitrary offset in file.

When truncating a file, allow that we might not be truncating
from the beginning.

17 years agoAnother README update
NeilBrown [Thu, 19 Mar 2009 06:21:28 +0000 (17:21 +1100)]
Another README update

17 years agoAnnotate getref depending on whether '0' is safe.
NeilBrown [Thu, 19 Mar 2009 06:16:42 +0000 (17:16 +1100)]
Annotate getref depending on whether '0' is safe.

Any place where we might be getting the first reference on
a block, use get?ref_locked, and put appropriate checks in
getref and getref_locked to make sure they are used that way.

This required rearranging lafs_refile so that we didn't drop
the last ref if we were about to add a ref on _leafs.

17 years agoUse 'enum' for B_* flags
NeilBrown [Thu, 19 Mar 2009 04:17:14 +0000 (15:17 +1100)]
Use 'enum' for B_* flags

Rather than listing the numbers.

17 years agoRemove list_del from ihash_lookup
NeilBrown [Thu, 19 Mar 2009 04:12:37 +0000 (15:12 +1100)]
Remove list_del from ihash_lookup

We don't want these list_dels.
 One removes from the global free list, which happens else where based
    on B_OnFree
 The other removes from the per-inode free list that happens else
 where base on ->parent.

17 years agomake strblk safer
NeilBrown [Thu, 19 Mar 2009 04:11:21 +0000 (15:11 +1100)]
make strblk safer

Check if ->inode is non-NULL before de-referencing it.

17 years agoMinor fixes to lafs_leaf_find
NeilBrown [Thu, 19 Mar 2009 01:48:38 +0000 (12:48 +1100)]
Minor fixes to lafs_leaf_find

It cannot be used during truncation, so make a note of that...

17 years agoDon't erase inode dblock during incorporation.
NeilBrown [Thu, 19 Mar 2009 01:48:31 +0000 (12:48 +1100)]
Don't erase inode dblock during incorporation.

When incorporation notices that the indexes are all gone
and the inode is ready to die, it should *not* erase the
dblock.  That gets things out of order.  The dblock gets
erased by the orphan handler which will still be overseeing
the operation.

17 years agoFix incorporate_index
NeilBrown [Thu, 19 Mar 2009 01:48:23 +0000 (12:48 +1100)]
Fix incorporate_index

While uninc->physaddr is unlikely to be zero, it is
possible and we must allow for it.

17 years agoFurther Truncate fixes.
NeilBrown [Thu, 19 Mar 2009 01:48:20 +0000 (12:48 +1100)]
Further Truncate fixes.

In particular, don't use lafs_find_next to find the next place to
truncate.  This can instantiate data blocks past EOF which is confusing.
Just use lafs_leaf_find and only ever instantiate index blocks.

17 years agoRemove need to hold i_mutex when flushing data into inode
NeilBrown [Thu, 19 Mar 2009 01:47:37 +0000 (12:47 +1100)]
Remove need to hold i_mutex when flushing data into inode

Holding i_mutex while flush data into the inode is a problem because
it can triggered deadlocks if something hold i_mutex and waits for
checkpoint to finish - checkpoint might do the flush.

So check the i_size after clearing B_Dirty.  If it changes after this,
we will just do another write-out and fix things up.

17 years agoclean up lafs_erase_dblock
NeilBrown [Thu, 19 Mar 2009 01:47:07 +0000 (12:47 +1100)]
clean up lafs_erase_dblock

- remove some dead code
- make it work for blocks that don't have a parent
- simplify the call from lafs_invalidate_page
- general clean up

17 years agoVarious incorporation and truncation fixes.
NeilBrown [Thu, 19 Mar 2009 01:46:24 +0000 (12:46 +1100)]
Various incorporation and truncation fixes.

17 years agoVarious fixes for truncation (inode orphan handling).
NeilBrown [Thu, 19 Mar 2009 01:46:18 +0000 (12:46 +1100)]
Various fixes for truncation (inode orphan handling).

- Don't update ->trunc_next until we do the truncation
   (it is possible to retry if reserve_block fails)
- Search down the index tree properly (ib2, not ib!)
- set 'adopt' for lafs_leaf_find - very important.
- general code tidy up.

17 years agoFixes for lafs_leaf_find
NeilBrown [Thu, 19 Mar 2009 01:46:11 +0000 (12:46 +1100)]
Fixes for lafs_leaf_find

In particular, make sure 'next' gets the right value when we
find blocks on the siblings list.
Also add a useful comment.