Commit graph

203 commits

Author SHA1 Message Date
Steven Whitehouse b6397893a5 [GFS2] Use hlist for glock hash chains
This results in smaller list heads, so that we can have more chains
in the same amount of memory (twice as many). I've multiplied the
size of the table by four though - this is because we are saving
memory by not having one lock per chain any more. So we land up
using about the same amount of memory for the hash table as we
did before I started these changes, the difference being that we
now have four times as many hash chains.

The reason that I say "about the same amount of memory" is that the
actual amount now depends upon the NR_CPUS and some of the config
variables, so that its not exact and in some cases we do use more
memory. Eventually we might want to scale the hash table size
according to the size of physical ram as measured on module load.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-12 10:10:01 -04:00
Steven Whitehouse 2426443460 [GFS2] Rewrite of examine_bucket()
The existing implementation of this function in glock.c was not
very efficient as it relied upon keeping a cursor element upon the
hash chain in question and moving it along. This new version improves
upon this by using the current element as a cursor. This is possible
since we only look at the "next" element in the list after we've
taken the read_lock() subsequent to calling the examiner function.
Obviously we have to eventually drop the ref count that we are then
left with and we cannot do that while holding the read_lock, so we
do that next time we drop the lock. That means either just before
we examine another glock, or when the loop has terminated.

The new implementation has several advantages: it uses only a
read_lock() rather than a write_lock(), so it can run simnultaneously
with other code, it doesn't need a "plug" element, so that it removes
a test not only from this list iterator, but from all the other glock
list iterators too. So it makes things faster and smaller.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-11 21:40:30 -04:00
Steven Whitehouse 94610610f1 [GFS2] Remove unused function from glock.c
The callback for iopen locks is unused, so this removes
it.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-09 18:59:27 -04:00
Steven Whitehouse a5e08a9ef5 [GFS2] Add consts to glock sorting function
Add back the consts which were casted away in the glock sorting
function. Also add early exit code.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-09 17:07:05 -04:00
Steven Whitehouse 087efdd391 [GFS2] Make glock hash locks proportional to NR_CPUS
Make the number of locks used for hash chains in glock.c
proportional to NR_CPUS. Also move constants for the number
of hash chains into glock.c from incore.h since they are
not used outside of glock.c.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-09 16:59:11 -04:00
Steven Whitehouse ff6af411ae [GFS2] vfree should be kfree (II)
The superblock is now created with kmalloc, not vmalloc.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-09 16:56:34 -04:00
Steven Whitehouse 37b2fa6a24 [GFS2] Move rwlocks in glock.c into their own array
This splits the rwlocks guarding the hash chains of the glock hash
table into their own array. This will reduce memory usage in some
cases due to better alignment, although the real reason for doing it
is to allow the two tables to be different sizes in future (i.e.
the locks will be sized proportionally with the max number of CPUs
and the hash chains sized proportinally with the size of physical memory)

In order to allow this, the gl_bucket member of struct gfs2_glock has
now become gl_hash, so we record the hash rather than a pointer to the
bucket itself.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-08 13:35:56 -04:00
Steven Whitehouse 9b47c11d1c [GFS2] Use void * instead of typedef for locking module interface
As requested by Jan Engelhardt, this removes the typedefs in the
locking module interface and replaces them with void *. Also
since we are changing the interface, I've added a few consts
as well.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: David Teigland <teigland@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-08 10:17:58 -04:00
Steven Whitehouse a2c4580797 [GFS2] vfree should be kfree
This was missed in an earlier patch when changing over from vmalloc
to kmalloc for the superblock.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-08 10:13:03 -04:00
Steven Whitehouse 5ce311ebdb [GFS2] Remove unused sync_lvb code from lock modules
This code is no longer used for anything and can be removed
from the locking modules. The sync_lvb function is not required
as this happens automatically with the current locking system.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-07 17:35:48 -04:00
Steven Whitehouse 1c089c325d [GFS2] Remove one typedef
This removes one of the typedefs from the locking interface. It
is replaced by a forward declaration of the gfs2 superblock. The
other two are not so easy to solve since in their case, they
can refer to one of two possible structures.

Cc: David Teigland <teigland@redhat.com>
Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-07 15:50:20 -04:00
Steven Whitehouse b9201ce9a8 [GFS2] Forgot to remove unused include vmalloc.h
Excatly as the subject line says.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-07 14:46:39 -04:00
Steven Whitehouse 85d1da67f7 [GFS2] Move glock hash table out of superblock
There are several reasons why we want to do this:
 - Firstly its large and thus we'll scale better with multiple
   GFS2 fs mounted at the same time
 - Secondly its easier to scale its size as required (thats a plan
   for later patches)
 - Thirdly, we can use kzalloc rather than vmalloc when allocating
   the superblock (its now only 4888 bytes)
 - Fourth its all part of my plan to eventually be able to use RCU
   with the glock hash.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-07 14:40:21 -04:00
Steven Whitehouse b8547856f9 [GFS2] Add gfs2 superblock to glock hash function
This is another patch preparing for sharing of the glock hash
table between different gfs2 mounts.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-07 13:12:27 -04:00
Steven Whitehouse 62f140c173 [GFS2] Add brackets in locking/dlm/sysfs.c
As per Jan Engelhardt's request.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-07 09:54:55 -04:00
David Teigland 3204a6c055 [GFS2] use snprintf for sysfs show
Use snprintf(buf, PAGE_SIZE, ...) instead of sprintf for sysfs show
methods.  Per instructions in Documentation/filesystems/sysfs.txt

Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-07 09:43:34 -04:00
Jan Engelhardt c53921248c [GFS2] More style changes
Remove redundant brackets

Signed-off-by: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-07 09:42:56 -04:00
Steven Whitehouse 7b62536141 [GFS2] Add a comment in ops_export.c
Ass a comment explaining the slightly odd construct used to
pass error values back.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-05 15:56:17 -04:00
Steven Whitehouse 2c1e52aa90 [GFS2] More style fixes
As per Jan Engelhardt's follow up emails, here are a few small
fixes which were missed earlier.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-05 15:41:57 -04:00
Steven Whitehouse 48fac17909 [GFS2] Remove unused code from quota
As per Jan Engelhardt's request, some unused code is removed and
some consts added in the quota code.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-05 15:17:12 -04:00
Steven Whitehouse a67cdbd457 [GFS2] Style changes in logging code
As per Jan Engelhardt's comments, removed some unused code and
removed some brackets which were not required.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-05 14:41:30 -04:00
Steven Whitehouse cca195c5c0 [GFS2] Extended attribute code style changes
As per Jan Engelhardt's request and also a few of my own. It has
been possible to add a few most const to the code as a result of
the change in gfs2_ea_name2type.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-05 13:15:18 -04:00
Steven Whitehouse 16910427e1 [GFS2] Style changes in rgrp.c
Change one constant plus remove a redundant !!.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-05 11:15:45 -04:00
Steven Whitehouse ea67eedb21 [GFS2] Fix end of multi-line structures
As per Jan Engelhardt's request, I've added a ',' to the end of
each of the multi-line structures which didn't already have
one (most already did).

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-05 10:53:09 -04:00
Steven Whitehouse f2f7ba5237 [GFS2] Make headers compile on their own
As per Jan Engelhardt's comments, this should make all the headers
compile on their own by including and/or declaring structures
early.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-05 10:39:21 -04:00
Steven Whitehouse 2bdbc5d739 [GFS2] Directory code style changes
As per comments from Jan Engelhardt, remove redundant casts, redundant
endian conversions, add a smattering of const and rewrite the
dirent_next function in order to avoid as many casts as possible.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-05 09:34:20 -04:00
Steven Whitehouse 5acd396734 [GFS2] Some further style changes
Introduce a couple of new constants which make the NFS filehandle
sizes that GFS2 uses a bit clearer. Also fix one or two minor
issues as per Jan Engelhardt's sixth email.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-04 16:16:45 -04:00
Steven Whitehouse 26c1a57412 [GFS2] More code style updates
As per Jan Engelhardt's fifth email. This has most of the changes
recommended, which is the removal of casts which are not required,
some indenting fixes and similar.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-04 15:32:10 -04:00
Steven Whitehouse 0bd5996a00 [GFS2] Style changes in ops_address.c
As per the remainder of Jan Engelhardt's fourth email comments,
remove an cast thats not required. Also tidy up the "limit" code
in stuck_releasepage().

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-04 14:59:35 -04:00
Steven Whitehouse dd538c832a [GFS2] Spelling sentinal -> sentinel
A spelling mistake (one of mine).

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-04 14:53:30 -04:00
Steven Whitehouse 38c60ef228 [GFS2] Use const in endian conversion routines
Use const in endian conversion and printing of on-disk structures.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-04 14:48:37 -04:00
Steven Whitehouse 82ffa51637 [GFS2] More style changes
As per Jan Engelhardt's fourth email, this is the first part of the
change set with a few minor style points.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-04 14:47:06 -04:00
Steven Whitehouse c26687113a [GFS2] Remove a cast, tidy gfs2_inode_attr_in
The remains of the changes for Jan Engelhardt's third email. Remove
a cast and tidy up gfs2_inode_attr_in.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-04 13:55:48 -04:00
Steven Whitehouse cd915493fc [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>
2006-09-04 12:49:07 -04:00
Steven Whitehouse a91ea69ffd [GFS2] Align all labels against LH side
This makes everything consistent.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-04 12:04:26 -04:00
Steven Whitehouse 75d3b817a0 [GFS2] Tidy up bmap/inode code
As per Jan Engelhardt's third set of comments, this make various
code style changes and moves the structures from format.h into
super.c, which was the only place that format.h was actually used.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-04 11:41:31 -04:00
Steven Whitehouse 5029996547 [GFS2] Tidy up locking code
As per Jan Engelhardt's second email, this removes some unused code,
and fixes up indenting in various places.

Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-09-04 09:49:55 -04:00
Steven Whitehouse e9fc2aa091 [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>
2006-09-01 11:05:15 -04:00
Steven Whitehouse 623d93555c [GFS2] Fix releasepage bug (fixes direct i/o writes)
This patch fixes three main bugs. Firstly the direct i/o get_block
was returning the wrong return code in certain cases. Secondly, the
GFS2's releasepage function was not dealing with cases when clean,
ordered buffers were found still queued on a transaction (which can
happen depending on the ordering of journal flushes). Thirdly, the
journaling code itself needed altering to take account of the
after effects of removing the clean ordered buffers from the transactions
before a journal flush.

The releasepage bug did also show up under "normal" buffered i/o
as well, so its not just a fix for direct i/o. In fact its not
normally used in the direct i/o path at all, except when flushing
existing buffers after performing a direct i/o write, but that was
the code path that led us to spot this.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-08-31 12:14:44 -04:00
Steven Whitehouse 899be4d3b7 [GFS2] Add superblock into key for glock lookups
This adds the superblock as a key for glock lookups. Since the glocks
are already stored in a per-superblock table, this has no effect at
the moment. Later on this will change though.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-08-30 12:50:28 -04:00
Steven Whitehouse d6a5372768 [GFS2] Use const on glock lookup key
Use const for the glock name which is being used as a lookup key
in the glock hash table.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-08-30 11:16:23 -04:00
Steven Whitehouse ec45d9f583 [GFS2] Use slab properly with glocks
We can take advantage of the slab allocator to ensure that all the list
heads and the spinlock (plus one or two other fields) are initialised
by slab to speed up allocation of glocks.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-08-30 10:36:52 -04:00
Steven Whitehouse 5e2b0613ed [GFS2] Remove unused code from glock layer
Remove the unused sync feature from glocks. This is currently done by
calling the required functions to sync pages/blocks directly so this
code isn't needed.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-08-30 09:38:30 -04:00
Steven Whitehouse 8fb4b536e7 [GFS2] Make glock operations const
For all the usual reasons of enforcing correctness and potentially
reducing code size, this patch makes the glock operations const.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-08-30 09:30:00 -04:00
Abhijith Das 8638460540 [GFS2] Allow mounting of gfs2 and gfs2meta at the same time
This patch allows the simultaneous mounting of gfs2meta and gfs2
filesystems. A restriction however is that a gfs2meta fs may only be
mounted if its corresponding gfs2 filesystem is also mounted. Also, a
gfs2 filesystem cannot be unmounted before its gfs2meta filesystem.

Signed-off-by: Abhijith Das <adas@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-08-25 17:19:55 -04:00
Benjamin Marzinski 5dc39fe621 [GFS2] Fix journal off-by-one error
log_refund() incorrectly assumed that if a transaction had been touched, it
always committed buffers to the incore log. Thus, when you got around to
flushing the log, you would need one more block than you committed, to account
for the header. So it automatically set reserved to 1, which had the effect of
making sdp->sd_log_blks_reserved one greater when you got to gfs2_log_flush().
However, if you don't actually commit anything to the incore log between
flushes, you don't need the header, because you aren't writing anything out.
With this patch, log_refund() only increments reservered to account for the
header if something has been committed since the last flush.

Signed-off-by: Benjamin E. Marzinski <bmarzins@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-08-25 09:57:41 -04:00
Steven Whitehouse a2242db090 [GFS2] Speed up scanning of glocks
I noticed the gfs2_scand seemed to be taking a lot of CPU,
so in order to cut that down a bit, here is a patch. Firstly
the type of a glock is a constant during its lifetime, so that
its possible to check this without needing locking. I've moved
the (common) case of testing for an inode glock outside of
the glmutex lock.

Also there was a mutex left over from when the glock cache was
master of the inode cache. That isn't required any more so I've
removed that too.

There is probably scope for further speed ups in the future
in this area.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-08-24 17:03:05 -04:00
Steven Whitehouse 166afccd71 [GFS2] Tidy up error handling in gfs2_releasepage()
This should clarify the logic in gfs2_releasepage() relating to
error handling as well as making the response to errors a bit
more graceful.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-08-24 15:59:40 -04:00
Steven Whitehouse b8e1aabf21 [GFS2] Another list_del bug
Another case where list_del should be list_del_init.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2006-08-22 16:25:50 -04:00
Steven Whitehouse 08867605e1 [GFS2] Fix to list_del in lops.c
A list_del should have been a list_del_init in lops.c which was
resulting in incorrect status returns from list_empty().

Signed-off-by: Steven Whitheouse <swhiteho@redhat.com>
2006-08-22 11:03:57 -04:00