History log of /fs/gfs2/trans.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
7c9ca621137cde26be05448133fc1a554345f4f8 31-Aug-2011 Bob Peterson <rpeterso@redhat.com> GFS2: Use rbtree for resource groups and clean up bitmap buffer ref count scheme

Here is an update of Bob's original rbtree patch which, in addition, also
resolves the rather strange ref counting that was being done relating to
the bitmap blocks.

Originally we had a dual system for journaling resource groups. The metadata
blocks were journaled and also the rgrp itself was added to a list. The reason
for adding the rgrp to the list in the journal was so that the "repolish
clones" code could be run to update the free space, and potentially send any
discard requests when the log was flushed. This was done by comparing the
"cloned" bitmap with what had been written back on disk during the transaction
commit.

Due to this, there was a requirement to hang on to the rgrps' bitmap buffers
until the journal had been flushed. For that reason, there was a rather
complicated set up in the ->go_lock ->go_unlock functions for rgrps involving
both a mutex and a spinlock (the ->sd_rindex_spin) to maintain a reference
count on the buffers.

However, the journal maintains a reference count on the buffers anyway, since
they are being journaled as metadata buffers. So by moving the code which deals
with the post-journal accounting for bitmap blocks to the metadata journaling
code, we can entirely dispense with the rather strange buffer ref counting
scheme and also the requirement to journal the rgrps.

The net result of all this is that the ->sd_rindex_spin is left to do exactly
one job, and that is to look after the rbtree or rgrps.

This patch is designed to be a stepping stone towards using RCU for the rbtree
of resource groups, however the reduction in the number of uses of the
->sd_rindex_spin is likely to have benefits for multi-threaded workloads,
anyway.

The patch retains ->go_lock and ->go_unlock for rgrps, however these maybe also
be removed in future in favour of calling the functions directly where required
in the code. That will allow locking of resource groups without needing to
actually read them in - something that could be useful in speeding up statfs.

In the mean time though it is valid to dereference ->bi_bh only when the rgrp
is locked. This is basically the same rule as before, modulo the references not
being valid until the following journal flush.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Cc: Benjamin Marzinski <bmarzins@redhat.com>
/fs/gfs2/trans.c
5e687eac1bd31baed110d239ef827d3ba666f311 04-May-2010 Benjamin Marzinski <bmarzins@redhat.com> GFS2: Various gfs2_logd improvements

This patch contains various tweaks to how log flushes and active item writeback
work. gfs2_logd is now managed by a waitqueue, and gfs2_log_reseve now waits
for gfs2_logd to do the log flushing. Multiple functions were rewritten to
remove the need to call gfs2_log_lock(). Instead of using one test to see if
gfs2_logd had work to do, there are now seperate tests to check if there
are two many buffers in the incore log or if there are two many items on the
active items list.

This patch is a port of a patch Steve Whitehouse wrote about a year ago, with
some minor changes. Since gfs2_ail1_start always submits all the active items,
it no longer needs to keep track of the first ai submitted, so this has been
removed. In gfs2_log_reserve(), the order of the calls to
prepare_to_wait_exclusive() and wake_up() when firing off the logd thread has
been switched. If it called wake_up first there was a small window for a race,
where logd could run and return before gfs2_log_reserve was ready to get woken
up. If gfs2_logd ran, but did not free up enough blocks, gfs2_log_reserve()
would be left waiting for gfs2_logd to eventualy run because it timed out.
Finally, gt_logd_secs, which controls how long to wait before gfs2_logd times
out, and flushes the log, can now be set on mount with ar_commit.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
a1c0643ff9f360a30644f6e3cd643ca2a5083aea 13-May-2009 Steven Whitehouse <swhiteho@redhat.com> GFS2: Move journal live test at transaction start

There seems little point grabbing the transaction glock
only to have to release it again if the journal isn't
live. This moves the test earlier to avoid grabbing the lock
when we don't need it in the first place.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
d8348de06f704fc34d24ec068546ecb1045fc11a 05-Feb-2009 Steven Whitehouse <swhiteho@redhat.com> GFS2: Fix deadlock on journal flush

This patch fixes a deadlock when the journal is flushed and there
are dirty inodes other than the one which caused the journal flush.
Originally the journal flushing code was trying to obtain the
transaction glock while running the flush code for an inode glock.
We no longer require the transaction glock at this point in time
since we know that any attempt to get the transaction glock from
another node will result in a journal flush. So if we are flushing
the journal, we can be sure that the transaction lock is still
cached from when the transaction was started.

By inlining a version of gfs2_trans_begin() (minus the bit which
gets the transaction glock) we can avoid the deadlock problems
caused if there is a demote request queued up on the transaction
glock.

In addition I've also moved the umount rwsem so that it covers
the glock workqueue, since it all demotions are done by this
workqueue now. That fixes a bug on umount which I came across
while fixing the original problem.

Reported-by: David Teigland <teigland@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
f057f6cdf64175db1151b1f5d110e29904f119a1 12-Jan-2009 Steven Whitehouse <swhiteho@redhat.com> GFS2: Merge lock_dlm module into GFS2

This is the big patch that I've been working on for some time
now. There are many reasons for wanting to make this change
such as:
o Reducing overhead by eliminating duplicated fields between structures
o Simplifcation of the code (reduces the code size by a fair bit)
o The locking interface is now the DLM interface itself as proposed
some time ago.
o Fewer lookups of glocks when processing replies from the DLM
o Fewer memory allocations/deallocations for each glock
o Scope to do further optimisations in the future (but this patch is
more than big enough for now!)

Please note that (a) this patch relates to the lock_dlm module and
not the DLM itself, that is still a separate module; and (b) that
we retain the ability to build GFS2 as a standalone single node
filesystem with out requiring the DLM.

This patch needs a lot of testing, hence my keeping it I restarted
my -git tree after the last merge window. That way, this has the maximum
exposure before its merged. This is (modulo a few minor bug fixes) the
same patch that I've been posting on and off the the last three months
and its passed a number of different tests so far.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
5731be53e3d82aedd06e02574f833a57b07a08d2 01-Feb-2008 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Update gfs2_trans_add_unrevoke to accept extents

By adding an extra argument to gfs2_trans_add_unrevoke we can now
specify an extent length of blocks to unrevoke. This means that
we only need to make one pass through the list for each extent
rather than each block. Currently the only extent length which
is used is 1, but that will change in the future.

Also gfs2_trans_add_unrevoke is removed from gfs2_alloc_meta
since its the only difference between this and gfs2_alloc_data
which is left. This will allow a future patch to merge these
two functions into one (i.e. one call to allocate both data
and metadata in a single extent in the future).

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
2bcd610d2fdea608a8fdac32788fc35a32a2327c 08-Nov-2007 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Don't add glocks to the journal

The only reason for adding glocks to the journal was to keep track
of which locks required a log flush prior to release. We add a
flag to the glock to allow this check to be made in a simpler way.

This reduces the size of a glock (by 12 bytes on i386, 24 on x86_64)
and means that we can avoid extra work during the journal flush.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
1ad38c437fa33f85ba4b6a85ea8c5478ee72d5bd 03-Sep-2007 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Clean up gfs2_trans_add_revoke()

The following alters gfs2_trans_add_revoke() to take a struct
gfs2_bufdata as an argument. This eliminates the memory allocation which
was previously required by making use of the already existing struct
gfs2_bufdata. It makes some sanity checks to ensure that the
gfs2_bufdata has been removed from all the lists before its recycled as
a revoke structure. This saves one memory allocation and one free per
revoke structure.

Also as a result, and to simplify the locking, since there is no longer
any blocking code in gfs2_trans_add_revoke() we must hold the log lock
whenever this function is called. This reduces the amount of times we
take and unlock the log lock.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
0820ab517e1b100ee3f9584ec27f93309689ebe7 02-Sep-2007 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Use slab operations for all gfs2_bufdata allocations

The old revoke structure was allocated using kalloc/kfree but
there is a slab cache for gfs2_bufdata, so we should use that
now that the structures have been converted.

This is part two of the patch series to merge the revoke
and gfs2_bufdata structures.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
82e86087bb774cd54d47db4a7c771b5b29bea9ed 02-Sep-2007 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Replace revoke structure with bufdata structure

Both the revoke structure and the bufdata structure are quite similar.
They are basically small tags which are put on lists. In addition to
which the revoke structure is always allocated when there is a bufdata
structure which is (or can be) freed. As such it should be possible to
reduce the number of frees and allocations by using the same structure
for both purposes.

This patch is the first step along that path. It replaces existing uses
of the revoke structure with the bufdata structure.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
7d308590ae60d1f038a54a94e78a385c5c163452 19-Sep-2006 Fabio Massimo Di Nitto <fabbione@ubuntu.com> [GFS2] Export lm_interface to kernel headers


lm_interface.h has a few out of the tree clients such as GFS1
and userland tools.

Right now, these clients keeps a copy of the file in their build tree
that can go out of sync.

Move lm_interface.h to include/linux, export it to userland and
clean up fs/gfs2 to use the new location.

Signed-off-by: Fabio M. Di Nitto <fabbione@ubuntu.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
cd915493fce912f1bd838ee1250737ecf33b8fae 04-Sep-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Change all types to uX style

This makes all fixed size types have consistent names.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
e9fc2aa091ab8fa46e60d4c9d06a89305c441652 01-Sep-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Update copyright, tidy up incore.h

As per comments from Jan Engelhardt <jengelh@linux01.gwdg.de> this
updates the copyright message to say "version" in full rather than
"v.2". Also incore.h has been updated to remove forward structure
declarations which are not required.

The gfs2_quota_lvb structure has now had endianess annotations added
to it. Also quota.c has been updated so that we now store the
lvb data locally in endian independant format to avoid needing
a structure in host endianess too. As a result the endianess
conversions are done as required at various points and thus the
conversion routines in lvb.[ch] are no longer required. I've
moved the one remaining constant in lvb.h thats used into lm.h
and removed the unused lvb.[ch].

I have not changed the HIF_ constants. That is left to a later patch
which I hope will unify the gh_flags and gh_iflags fields of the
struct gfs2_holder.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
3a8a9a1034813aa99f5ae3150f652d490c5ff10d 18-May-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Update copyright date to 2006

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
bd8968010a9a08e67a0ddb3ddee9feb8882e8c2f 18-May-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Remove semaphore.h from C files

We no longer use semaphores, everything has been converted to
mutex or rwsem, so we don't need to include this header any more.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
579b78a43b366d51f9c888afaf1eab1f4ea599fa 26-Apr-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Remove GL_NEVER_RECURSE flag

There is no point in keeping this flag since recursion is not
now allowed for any glock.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
f4154ea039bbf45c52840b30c68143a2dc28d4b4 11-Apr-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Update journal accounting code.

A small update to the journaling code to change the way that
the "extra" blocks are accounted for in the journal. These are
used at a rate of one per 503 metadata blocks or one per 251
journaled data blocks (or just one if the total number of journaled
blocks in the transaction is smaller). Since we are using them at
two different rates the old method of accounting for them no longer
works and we count them up as required.

Since the "per transaction" accounting can't handle this (there is no
fixed number of header blocks per transaction) we have to account for
it in the general journal code. We now require that each transaction
reserves more blocks than it actually needs to take account of the
possible extra blocks.

Also a final fix to dir.c to ensure that all ref counts are handled
correctly.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
b09e593d799560f1a0782c20ac5900058390a26f 07-Apr-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Fix a ref count bug and other clean ups

This fixes a ref count bug that sometimes showed up a umount time
(causing it to hang) but it otherwise mostly harmless. At the same
time there are some clean ups including making the log operations
structures const, moving a memory allocation so that its not done
in the fast path of checking to see if there is an outstanding
transaction related to a particular glock.

Removes the sd_log_wrap varaible which was updated, but never actually
used anywhere. Updates the gfs2 ioctl() to run without the kernel lock
(which it never needed anyway). Removes the "invalidate inodes" loop
from GFS2's put_super routine. This is done in kill super anyway so
we don't need to do it here. The loop was also bogus in that if there
are any inodes "stuck" at this point its a bug and we need to know
about it rather than hide it by hanging forever.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
cd45697f0ddbb58f3f83c29fe164713ee7765e21 30-Mar-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Add missing {} in trans.c

A conditional had missing {} around the two following
statements. Now added.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
d0dc80dbafb5c10ad2084831a61bbf945484a139 29-Mar-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Update debugging code

Update the debugging code in trans.c and at the same time improve
the debugging code for gfs2_holders. The new code should be pretty
fast during the normal case and provide just as much information
in case of errors (or more).

One small function from glock.c has moved to glock.h as a static inline so
that its return address won't get in the way of the debugging.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
484adff8a06cb5d952832f5487ae863f54c0fb69 29-Mar-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Update locking in log.c

Replace the lock_for_trans()/lock_for_flush() functions with an rwsem.
In fact the sd_log_flush_lock becomes an rwsem (the write part of it)
and is extended slightly to cover everything that the lock_for_flush()
used to cover. The read part of the lock is instead of lock_for_trans().

This corrects the races in the original code and reduces the code size.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
b4dc72911d149d7d6b7ffb512bd68906f1cbd33a 01-Mar-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Fix some bugs

Fix a bug I introduced earlier with a kfree() and usage of
a structure in the wrong order. Also try and get the counts
of the journaled data buffers "more correct". Still some work
to do in this area though.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
e317ffcb7cc26c5e80cab97160a5e2761a4436ec 01-Mar-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Remove uneeded memory allocation

For every filesystem operation where we need a transaction, we
now make one less memory allocation.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
5c676f6d359b0404d53f542f02e1359583cb2895 27-Feb-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Macros removal in gfs2.h

As suggested by Pekka Enberg <penberg@cs.helsinki.fi>.

The DIV_RU macro is renamed DIV_ROUND_UP and and moved to kernel.h
The other macros are gone from gfs2.h as (although not requested
by Pekka Enberg) are a number of included header file which are now
included individually. The inode number comparison function is
now an inline function.

The DT2IF and IF2DT may be addressed in a future patch.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
f55ab26a8f92a23988c3e6da28dae4741933a4e2 21-Feb-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Use mutices rather than semaphores

As well as a number of minor bug fixes, this patch changes GFS
to use mutices rather than semaphores. This results in better
information in case there are any locking problems.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
18ec7d5c3f434aed9661ed10a9e1f48cdeb4981d 08-Feb-2006 Steven Whitehouse <swhiteho@redhat.com> [GFS2] Make journaled data files identical to normal files on disk

This is a very large patch, with a few still to be resolved issues
so you might want to check out the previous head of the tree since
this is known to be unstable. Fixes for the various bugs will be
forthcoming shortly.

This patch removes the special data format which has been used
up till now for journaled data files. Directories still retain the
old format so that they will remain on disk compatible with earlier
releases. As a result you can now do the following with journaled
data files:

1) mmap them
2) export them over NFS
3) convert to/from normal files whenever you want to (the zero length
restriction is gone)

In addition the level at which GFS' locking is done has changed for all
files (since they all now use the page cache) such that the locking is
done at the page cache level rather than the level of the fs operations.
This should mean that things like loopback mounts and other things which
touch the page cache directly should now work.

Current known issues:

1. There is a lock mode inversion problem related to the resource
group hold function which needs to be resolved.
2. Any significant amount of I/O causes an oops with an offset of hex 320
(NULL pointer dereference) which appears to be related to a journaled data
buffer appearing on a list where it shouldn't be.
3. Direct I/O writes are disabled for the time being (will reappear later)
4. There is probably a deadlock between the page lock and GFS' locks under
certain combinations of mmap and fs operation I/O.
5. Issue relating to ref counting on internally used inodes causes a hang
on umount (discovered before this patch, and not fixed by it)
6. One part of the directory metadata is different from GFS1 and will need
to be resolved before next release.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
64fb4eb7d4cc9de89f4d9b9061adde46ed3b5641 18-Jan-2006 Steven Whitehouse <steve@chygwyn.com> [GFS2] Remove gfs2_databuf in favour of gfs2_bufdata structure

Removing the gfs2_databuf structure and using gfs2_bufdata instead
is a step towards allowing journaling of data without requiring the
metadata header on each journaled block. The idea is to merge the
code paths for ordered data with that of journaled data, with the
log operations in lops.c tacking account of the different types of
buffers as they are presented to it. Largely the code path for
metadata will be similar too, but obviously through a different set
of log operations.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
586dfdaaf328d79bb356d760db963b03a75a4131 18-Jan-2006 Steven Whitehouse <steve@chygwyn.com> [GFS2] Make the new argument to gfs2_trans_add_bh() actually do something

Passes the flag through to ensure that the correct log operations are
invoked when the flag is set.

Signed-off-by: Steven Whitehouse: <swhiteho@redhat.com>
/fs/gfs2/trans.c
d4e9c4c3bf861ef2ac96e0de659c75a00da92b28 18-Jan-2006 Steven Whitehouse <steve@chygwyn.com> [GFS2] Add an additional argument to gfs2_trans_add_bh()

This adds an extra argument to gfs2_trans_add_bh() to indicate whether the
bh being added to the transaction is metadata or data. Its currently unused
since all existing callers set it to 1 (metadata) but following patches will
make use of it.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c
b3b94faa5fe5968827ba0640ee9fba4b3e7f736e 16-Jan-2006 David Teigland <teigland@redhat.com> [GFS2] The core of GFS2

This patch contains all the core files for GFS2.

Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
/fs/gfs2/trans.c