sfrench/cifs-2.6.git
15 years agoocfs2: use smaller counters in ocfs2_remove_xattr_clusters_from_cache
Mark Fasheh [Tue, 7 Oct 2008 19:50:46 +0000 (12:50 -0700)]
ocfs2: use smaller counters in ocfs2_remove_xattr_clusters_from_cache

i and b_len don't really need to be u64's. Xattr extent lengths should be
limited by the VFS, and then the size of our on-disk length field.

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Documentation update for user_xattr / nouser_xattr mount options
Mark Fasheh [Tue, 7 Oct 2008 18:09:24 +0000 (11:09 -0700)]
ocfs2: Documentation update for user_xattr / nouser_xattr mount options

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: make la_debug_mutex static
Mark Fasheh [Tue, 7 Oct 2008 18:02:04 +0000 (11:02 -0700)]
ocfs2: make la_debug_mutex static

It can also be moved into ocfs2_la_debug_read().

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Remove pointless !!
Mark Fasheh [Mon, 6 Oct 2008 23:16:08 +0000 (16:16 -0700)]
ocfs2: Remove pointless !!

ocfs2_stack_supports_plocks() doesn't need this to properly return a zero or
one value.

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Add empty bucket support in xattr.
Tao Ma [Fri, 19 Sep 2008 14:17:41 +0000 (22:17 +0800)]
ocfs2: Add empty bucket support in xattr.

As Mark mentioned, it may be time-consuming when we remove the
empty xattr bucket, so this patch try to let empty bucket exist
in xattr operation. The modification includes:
1. Remove the functin of bucket and extent record deletion during
   xattr delete.
2. In xattr set:
   1) Don't clean the last entry so that if the bucket is empty,
      the hash value of the bucket is the hash value of the entry
      which is deleted last.
   2) During insert, if we meet with an empty bucket, just use the
      1st entry.
3. In binary search of xattr bucket, use the bucket hash value(which
   stored in the 1st xattr entry) to find the right place.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2/xattr.c: Fix a bug when inserting xattr.
Tao Ma [Fri, 19 Sep 2008 14:16:34 +0000 (22:16 +0800)]
ocfs2/xattr.c: Fix a bug when inserting xattr.

During the process of xatt insertion, we use binary search
to find the right place and "low" is set to it. But when
there is one xattr which has the same name hash as the inserted
one, low is the wrong value. So set it to the right position.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Add xattr mount option in ocfs2_show_options()
Sunil Mushran [Fri, 5 Sep 2008 18:29:14 +0000 (11:29 -0700)]
ocfs2: Add xattr mount option in ocfs2_show_options()

Patch adds check for [no]user_xattr in ocfs2_show_options() that completes
the list of all mount options.

Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Switch over to JBD2.
Joel Becker [Thu, 4 Sep 2008 03:03:41 +0000 (20:03 -0700)]
ocfs2: Switch over to JBD2.

ocfs2 wants JBD2 for many reasons, not the least of which is that JBD is
limiting our maximum filesystem size.

It's a pretty trivial change.  Most functions are just renamed.  The
only functional change is moving to Jan's inode-based ordered data mode.
It's better, too.

Because JBD2 reads and writes JBD journals, this is compatible with any
existing filesystem.  It can even interact with JBD-based ocfs2 as long
as the journal is formated for JBD.

We provide a compatibility option so that paranoid people can still use
JBD for the time being.  This will go away shortly.

[ Moved call of ocfs2_begin_ordered_truncate() from ocfs2_delete_inode() to
  ocfs2_truncate_for_delete(). --Mark ]

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Add the 'inode64' mount option.
Joel Becker [Thu, 4 Sep 2008 03:03:40 +0000 (20:03 -0700)]
ocfs2: Add the 'inode64' mount option.

Now that ocfs2 limits inode numbers to 32bits, add a mount option to
disable the limit.  This parallels XFS.  64bit systems can handle the
larger inode numbers.

[ Added description of inode64 mount option in ocfs2.txt. --Mark ]

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Limit inode allocation to 32bits.
Joel Becker [Thu, 4 Sep 2008 03:03:39 +0000 (20:03 -0700)]
ocfs2: Limit inode allocation to 32bits.

ocfs2 inode numbers are block numbers.  For any filesystem with less
than 2^32 blocks, this is not a problem.  However, when ocfs2 starts
using JDB2, it will be able to support filesystems with more than 2^32
blocks.  This would result in inode numbers higher than 2^32.

The problem is that stat(2) can't handle those numbers on 32bit
machines.  The simple solution is to have ocfs2 allocate all inodes
below that boundary.

The suballoc code is changed to honor an optional block limit.  Only the
inode suballocator sets that limit - all other allocations stay unlimited.

The biggest trick is to grow the inode suballocator beneath that limit.
There's no point in allocating block groups that are above the limit,
then rejecting their elements later on.  We want to prevent the inode
allocator from ever having block groups above the limit.  This involves
a little gyration with the local alloc code.  If the local alloc window
is above the limit, it signals the caller to try the global bitmap but
does not disable the local alloc file (which can be used for other
allocations).

[ Minor cleanup - removed an ML_NOTICE comment. --Mark ]

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Resolve deadlock in ocfs2_xattr_free_block.
Tao Ma [Fri, 29 Aug 2008 01:00:19 +0000 (09:00 +0800)]
ocfs2: Resolve deadlock in ocfs2_xattr_free_block.

In ocfs2_xattr_free_block, we take a cluster lock on xb_alloc_inode while we
have a transaction open. This will deadlock the downconvert thread, so fix
it.

We can clean up how xattr blocks are removed while here - this patch also
moves the mechanism of releasing xattr block (including both value, xattr
tree and xattr block) into this function.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: bug-fix for journal extend in xattr.
Tao Ma [Mon, 1 Sep 2008 00:45:18 +0000 (08:45 +0800)]
ocfs2: bug-fix for journal extend in xattr.

In ocfs2_extend_trans, when we can't extend the current
transaction, it will commit current transaction and restart
a new one. So if the previous credits we have allocated aren't
used(the block isn't dirtied before our extend), we will not
have enough credits for any future operation(it will cause jbd
complain and bug out). So check this and re-extend it.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Change ocfs2_get_*_extent_tree() to ocfs2_init_*_extent_tree()
Joel Becker [Fri, 22 Aug 2008 19:46:09 +0000 (12:46 -0700)]
ocfs2: Change ocfs2_get_*_extent_tree() to ocfs2_init_*_extent_tree()

The original get/put_extent_tree() functions held a reference on
et_root_bh.  However, every single caller already has a safe reference,
making the get/put cycle irrelevant.

We change ocfs2_get_*_extent_tree() to ocfs2_init_*_extent_tree().  It
no longer gets a reference on et_root_bh.  ocfs2_put_extent_tree() is
removed.  Callers now have a simpler init+use pattern.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Comment struct ocfs2_extent_tree_operations.
Joel Becker [Fri, 22 Aug 2008 00:11:10 +0000 (17:11 -0700)]
ocfs2: Comment struct ocfs2_extent_tree_operations.

struct ocfs2_extent_tree_operations provides methods for the different
on-disk btrees in ocfs2.  Describing what those methods do is probably a
good idea.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Make ocfs2_extent_tree the first-class representation of a tree.
Joel Becker [Thu, 21 Aug 2008 02:36:33 +0000 (19:36 -0700)]
ocfs2: Make ocfs2_extent_tree the first-class representation of a tree.

We now have three different kinds of extent trees in ocfs2: inode data
(dinode), extended attributes (xattr_tree), and extended attribute
values (xattr_value).  There is a nice abstraction for them,
ocfs2_extent_tree, but it is hidden in alloc.c.  All the calling
functions have to pick amongst a varied API and pass in type bits and
often extraneous pointers.

A better way is to make ocfs2_extent_tree a first-class object.
Everyone converts their object to an ocfs2_extent_tree() via the
ocfs2_get_*_extent_tree() calls, then uses the ocfs2_extent_tree for all
tree calls to alloc.c.

This simplifies a lot of callers, making for readability.  It also
provides an easy way to add additional extent tree types, as they only
need to be defined in alloc.c with a ocfs2_get_<new>_extent_tree()
function.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Add an insertion check to ocfs2_extent_tree_operations.
Joel Becker [Thu, 21 Aug 2008 01:32:45 +0000 (18:32 -0700)]
ocfs2: Add an insertion check to ocfs2_extent_tree_operations.

A couple places check an extent_tree for a valid inode.  We move that
out to add an eo_insert_check() operation.  It can be called from
ocfs2_insert_extent() and elsewhere.

We also have the wrapper calls ocfs2_et_insert_check() and
ocfs2_et_sanity_check() ignore NULL ops.  That way we don't have to
provide useless operations for xattr types.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Create specific get_extent_tree functions.
Joel Becker [Thu, 21 Aug 2008 00:44:24 +0000 (17:44 -0700)]
ocfs2: Create specific get_extent_tree functions.

A caller knows what kind of extent tree they have.  There's no reason
they have to call ocfs2_get_extent_tree() with a NULL when they could
just as easily call a specific function to their type of extent tree.

Introduce ocfs2_dinode_get_extent_tree(),
ocfs2_xattr_tree_get_extent_tree(), and
ocfs2_xattr_value_get_extent_tree().  They only take the necessary
arguments, calling into the underlying __ocfs2_get_extent_tree() to do
the real work.

__ocfs2_get_extent_tree() is the old ocfs2_get_extent_tree(), but
without needing any switch-by-type logic.

ocfs2_get_extent_tree() is now a wrapper around the specific calls.  It
exists because a couple alloc.c functions can take et_type.  This will
go later.

Another benefit is that ocfs2_xattr_value_get_extent_tree() can take a
struct ocfs2_xattr_value_root* instead of void*.  This gives us
typechecking where we didn't have it before.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Determine an extent tree's max_leaf_clusters in an et_op.
Joel Becker [Thu, 21 Aug 2008 00:31:10 +0000 (17:31 -0700)]
ocfs2: Determine an extent tree's max_leaf_clusters in an et_op.

Provide an optional extent_tree_operation to specify the
max_leaf_clusters of an ocfs2_extent_tree.  If not provided, the value
is 0 (unlimited).

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Use struct ocfs2_extent_tree in ocfs2_num_free_extents().
Joel Becker [Thu, 21 Aug 2008 00:09:42 +0000 (17:09 -0700)]
ocfs2: Use struct ocfs2_extent_tree in ocfs2_num_free_extents().

ocfs2_num_free_extents() re-implements the logic of
ocfs2_get_extent_tree().  Now that ocfs2_get_extent_tree() does not
allocate, let's use it in ocfs2_num_free_extents() to simplify the code.

The inode validation code in ocfs2_num_free_extents() is not needed.
All callers are passing in pre-validated inodes.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Provide the get_root_el() method to ocfs2_extent_tree_operations.
Joel Becker [Thu, 21 Aug 2008 00:19:50 +0000 (17:19 -0700)]
ocfs2: Provide the get_root_el() method to ocfs2_extent_tree_operations.

The root_el of an ocfs2_extent_tree needs to be calculated from
et->et_object.  Make it an operation on et->et_ops.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Make 'private' into 'object' on ocfs2_extent_tree.
Joel Becker [Wed, 20 Aug 2008 23:57:27 +0000 (16:57 -0700)]
ocfs2: Make 'private' into 'object' on ocfs2_extent_tree.

The 'private' pointer was a way to store off xattr values, which don't
live at a set place in the bh.  But the concept of "the object
containing the extent tree" is much more generic.  For an inode it's the
struct ocfs2_dinode, for an xattr value its the value.  Let's save off
the 'object' at all times.  If NULL is passed to
ocfs2_get_extent_tree(), 'object' is set to bh->b_data;

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Make ocfs2_extent_tree get/put instead of alloc.
Joel Becker [Wed, 20 Aug 2008 23:48:35 +0000 (16:48 -0700)]
ocfs2: Make ocfs2_extent_tree get/put instead of alloc.

Rather than allocating a struct ocfs2_extent_tree, just put it on the
stack.  Fill it with ocfs2_get_extent_tree() and drop it with
ocfs2_put_extent_tree().  Now the callers don't have to ENOMEM, yet
still safely ref the root_bh.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Prefix the ocfs2_extent_tree structure.
Joel Becker [Wed, 20 Aug 2008 23:30:07 +0000 (16:30 -0700)]
ocfs2: Prefix the ocfs2_extent_tree structure.

The members of the ocfs2_extent_tree structure gain a prefix of 'et_'.
All users are updated.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Prefix the extent tree operations structure.
Joel Becker [Wed, 20 Aug 2008 23:25:06 +0000 (16:25 -0700)]
ocfs2: Prefix the extent tree operations structure.

The ocfs2_extent_tree_operations structure gains a field prefix on its
members.  The ->eo_sanity_check() operation gains a wrapper function for
completeness.  All of the extent tree operation wrappers gain a
consistent name (ocfs2_et_*()).

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: fix printk format warnings
Mark Fasheh [Tue, 19 Aug 2008 17:54:29 +0000 (10:54 -0700)]
ocfs2: fix printk format warnings

This patch fixes the following build warnings:

fs/ocfs2/xattr.c: In function 'ocfs2_half_xattr_bucket':
fs/ocfs2/xattr.c:3282: warning: format '%d' expects type 'int', but argument 7 has type 'long int'
fs/ocfs2/xattr.c:3282: warning: format '%d' expects type 'int', but argument 8 has type 'long int'
fs/ocfs2/xattr.c:3282: warning: format '%d' expects type 'int', but argument 7 has type 'long int'
fs/ocfs2/xattr.c:3282: warning: format '%d' expects type 'int', but argument 8 has type 'long int'
fs/ocfs2/xattr.c:3282: warning: format '%d' expects type 'int', but argument 7 has type 'long int'
fs/ocfs2/xattr.c:3282: warning: format '%d' expects type 'int', but argument 8 has type 'long int'
fs/ocfs2/xattr.c: In function 'ocfs2_xattr_set_entry_in_bucket':
fs/ocfs2/xattr.c:4092: warning: format '%d' expects type 'int', but argument 6 has type 'size_t'
fs/ocfs2/xattr.c:4092: warning: format '%d' expects type 'int', but argument 6 has type 'size_t'
fs/ocfs2/xattr.c:4092: warning: format '%d' expects type 'int', but argument 6 has type 'size_t'

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Add incompatible flag for extended attribute
Tiger Yang [Mon, 18 Aug 2008 09:11:46 +0000 (17:11 +0800)]
ocfs2: Add incompatible flag for extended attribute

This patch adds the s_incompat flag for extended attribute support. This
helps us ensure that older versions of Ocfs2 or ocfs2-tools will not be able
to mount a volume with xattr support.

Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Delete all xattr buckets during inode removal
Tao Ma [Mon, 18 Aug 2008 09:38:54 +0000 (17:38 +0800)]
ocfs2: Delete all xattr buckets during inode removal

In inode removal, we need to iterate all the buckets, remove any
externally-stored EA values and delete the xattr buckets.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Enable xattr set in index btree
Tao Ma [Mon, 18 Aug 2008 09:38:53 +0000 (17:38 +0800)]
ocfs2: Enable xattr set in index btree

Where the previous patches added the ability of list/get xattr in buckets
for ocfs2, this patch enables ocfs2 to store large numbers of EAs.

The original design doc is written by Mark Fasheh, and it can be found in
http://oss.oracle.com/osswiki/OCFS2/DesignDocs/IndexedEATrees. I only had to
make small modifications to it.

First, because the bucket size is 4K, a new field named xh_free_start is added
in ocfs2_xattr_header to indicate the next valid name/value offset in a bucket.
It is used when we store new EA name/value. With this field, we can find the
place more quickly and what's more, we don't need to sort the name/value every
time to let the last entry indicate the next unused space. This makes the
insert operation more efficient for blocksizes smaller than 4k.

Because of the new xh_free_start, another field named as xh_name_value_len is
also added in ocfs2_xattr_header. It records the total length of all the
name/values in the bucket. We need this so that we can check it and defragment
the bucket if there is not enough contiguous free space.

An xattr insertion looks like this:
1. xattr_index_block_find: find the right bucket by the name_hash, say bucketA.
2. check whether there is enough space in bucketA. If yes, insert it directly
   and modify xh_free_start and xh_name_value_len accordingly. If not, check
   xh_name_value_len to see whether we can store this by defragment the bucket.
   If yes, defragment it and go on insertion.
3. If defragement doesn't work, check whether there is new empty bucket in
   the clusters within this extent record. If yes, init the new bucket and move
   all the buckets after bucketA one by one to the next bucket. Move half of the
   entries in bucketA to the next bucket and go on insertion.
4. If there is no new bucket, grow the extent tree.

As for xattr deletion, we will delete an xattr bucket when all it's xattrs
are removed and move all the buckets after it to the previous one. When all
the xattr buckets in an extend record are freed, free this extend records
from ocfs2_xattr_tree.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Optionally limit extent size in ocfs2_insert_extent()
Tao Ma [Mon, 18 Aug 2008 09:38:52 +0000 (17:38 +0800)]
ocfs2: Optionally limit extent size in ocfs2_insert_extent()

In xattr bucket, we want to limit the maximum size of a btree leaf,
otherwise we'll lose the benefits of hashing because we'll have to search
large leaves.

So add a new field in ocfs2_extent_tree which indicates the maximum leaf cluster
size we want so that we can prevent ocfs2_insert_extent() from merging the leaf
record even if it is contiguous with an adjacent record.

Other btree types are not affected by this change.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Add xattr lookup code xattr btrees
Tao Ma [Mon, 18 Aug 2008 09:38:51 +0000 (17:38 +0800)]
ocfs2: Add xattr lookup code xattr btrees

Add code to lookup a given extended attribute in the xattr btree. Lookup
follows this general scheme:

1. Use ocfs2_xattr_get_rec to find the xattr extent record

2. Find the xattr bucket within the extent which may contain this xattr

3. Iterate the bucket to find the xattr. In ocfs2_xattr_block_get(), we need
   to recalcuate the block offset and name offset for the right position of
   name/value.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Add xattr bucket iteration for large numbers of EAs
Tao Ma [Mon, 18 Aug 2008 09:38:50 +0000 (17:38 +0800)]
ocfs2: Add xattr bucket iteration for large numbers of EAs

Ocfs2 breaks up xattr index tree leaves into 4k regions, called buckets.
Attributes are stored within a given bucket, depending on hash value.

After a discussion with Mark, we decided that the per-bucket index
(xe_entry[]) would only exist in the 1st block of a bucket. Likewise,
name/value pairs will not straddle more than one block. This allows the
majority of operations to work directly on the buffer heads in a leaf block.

This patch adds code to iterate the buckets in an EA. A new abstration of
ocfs2_xattr_bucket is added. It records the bhs in this bucket and
ocfs2_xattr_header. This keeps the code neat, improving readibility.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Add xattr index tree operations
Tao Ma [Mon, 18 Aug 2008 09:38:49 +0000 (17:38 +0800)]
ocfs2: Add xattr index tree operations

When necessary, an ocfs2_xattr_block will embed an ocfs2_extent_list to
store large numbers of EAs. This patch adds a new type in
ocfs2_extent_tree_type and adds the implementation so that we can re-use the
b-tree code to handle the storage of many EAs.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Add extended attribute support
Tiger Yang [Mon, 18 Aug 2008 09:11:00 +0000 (17:11 +0800)]
ocfs2: Add extended attribute support

This patch implements storing extended attributes both in inode or a single
external block. We only store EA's in-inode when blocksize > 512 or that
inode block has free space for it. When an EA's value is larger than 80
bytes, we will store the value via b-tree outside inode or block.

Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: reserve inline space for extended attribute
Tiger Yang [Mon, 18 Aug 2008 09:08:55 +0000 (17:08 +0800)]
ocfs2: reserve inline space for extended attribute

Add the structures and helper functions we want for handling inline extended
attributes. We also update the inline-data handlers so that they properly
function in the event that we have both inline data and inline attributes
sharing an inode block.

Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Add extent tree operation for xattr value btrees
Tao Ma [Mon, 18 Aug 2008 09:38:48 +0000 (17:38 +0800)]
ocfs2: Add extent tree operation for xattr value btrees

Add some thin wrappers around ocfs2_insert_extent() for each of the 3
different btree types, ocfs2_inode_insert_extent(),
ocfs2_xattr_value_insert_extent() and ocfs2_xattr_tree_insert_extent(). The
last is for the xattr index btree, which will be used in a followup patch.

All the old callers in file.c etc will call ocfs2_dinode_insert_extent(),
while the other two handle the xattr issue. And the init of extent tree are
handled by these functions.

When storing xattr value which is too large, we will allocate some clusters
for it and here ocfs2_extent_list and ocfs2_extent_rec will also be used. In
order to re-use the b-tree operation code, a new parameter named "private"
is added into ocfs2_extent_tree and it is used to indicate the root of
ocfs2_exent_list. The reason is that we can't deduce the root from the
buffer_head now. It may be in an inode, an ocfs2_xattr_block or even worse,
in any place in an ocfs2_xattr_bucket.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Add helper function in uptodate.c for removing xattr clusters
Tao Ma [Mon, 18 Aug 2008 09:38:47 +0000 (17:38 +0800)]
ocfs2: Add helper function in uptodate.c for removing xattr clusters

The old uptodate only handles the issue of removing one buffer_head from
ocfs2 inode's buffer cache. With xattr clusters, we may need to remove
multiple buffer_head's at a time.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Add the basic xattr disk layout in ocfs2_fs.h
Tao Ma [Mon, 18 Aug 2008 09:38:46 +0000 (17:38 +0800)]
ocfs2: Add the basic xattr disk layout in ocfs2_fs.h

Ocfs2 uses a very flexible structure for storing extended attributes on
disk. Small amount of attributes are stored directly in the inode block - up
to 256 bytes worth. If that fills up, attributes are also stored in an
external block, linked to from the inode block. That block can in turn
expand to a btree, capable of storing large numbers of attributes.

Individual attribute values are stored inline if they're small enough
(currently about 80 bytes, this can be changed though), and otherwise are
expanded to a btree. The theoretical limit to the size of an individual
attribute is about the same as an inode, though the kernel's upper bound on
the size of an attributes data is far smaller.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Make high level btree extend code generic
Tao Ma [Mon, 18 Aug 2008 09:38:45 +0000 (17:38 +0800)]
ocfs2: Make high level btree extend code generic

Factor out the non-inode specifics of ocfs2_do_extend_allocation() into a more generic
function, ocfs2_do_cluster_allocation(). ocfs2_do_extend_allocation calls
ocfs2_do_cluster_allocation() now, but the latter can be used for other
btree types as well.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Abstract ocfs2_extent_tree in b-tree operations.
Tao Ma [Mon, 18 Aug 2008 09:38:44 +0000 (17:38 +0800)]
ocfs2: Abstract ocfs2_extent_tree in b-tree operations.

In the old extent tree operation, we take the hypothesis that we
are using the ocfs2_extent_list in ocfs2_dinode as the tree root.
As xattr will also use ocfs2_extent_list to store large value
for a xattr entry, we refactor the tree operation so that xattr
can use it directly.

The refactoring includes 4 steps:
1. Abstract set/get of last_eb_blk and update_clusters since they may
   be stored in different location for dinode and xattr.
2. Add a new structure named ocfs2_extent_tree to indicate the
   extent tree the operation will work on.
3. Remove all the use of fe_bh and di, use root_bh and root_el in
   extent tree instead. So now all the fe_bh is replaced with
   et->root_bh, el with root_el accordingly.
4. Make ocfs2_lock_allocators generic. Now it is limited to be only used
   in file extend allocation. But the whole function is useful when we want
   to store large EAs.

Note: This patch doesn't touch ocfs2_commit_truncate() since it is not used
for anything other than truncate inode data btrees.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Use ocfs2_extent_list instead of ocfs2_dinode.
Tao Ma [Mon, 18 Aug 2008 09:38:43 +0000 (17:38 +0800)]
ocfs2: Use ocfs2_extent_list instead of ocfs2_dinode.

ocfs2_extend_meta_needed(), ocfs2_calc_extend_credits() and
ocfs2_reserve_new_metadata() are all useful for extent tree operations. But
they are all limited to an inode btree because they use a struct
ocfs2_dinode parameter. Change their parameter to struct ocfs2_extent_list
(the part of an ocfs2_dinode they actually use) so that the xattr btree code
can use these functions.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Modify ocfs2_num_free_extents for future xattr usage.
Tao Ma [Mon, 18 Aug 2008 09:38:42 +0000 (17:38 +0800)]
ocfs2: Modify ocfs2_num_free_extents for future xattr usage.

ocfs2_num_free_extents() is used to find the number of free extent records
in an inode btree. Hence, it takes an "ocfs2_dinode" parameter. We want to
use this for extended attribute trees in the future, so genericize the
interface the take a buffer head. A future patch will allow that buffer_head
to contain any structure rooting an ocfs2 btree.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: track local alloc state via debugfs
Mark Fasheh [Wed, 30 Jul 2008 01:29:18 +0000 (18:29 -0700)]
ocfs2: track local alloc state via debugfs

A per-mount debugfs file, "local_alloc" is created which when read will
expose live state of the nodes local alloc file. Performance impact is
minimal, only a bit of memory overhead per mount point. Still, the code is
hidden behind CONFIG_OCFS2_FS_STATS. This feature will help us debug
local alloc performance problems on a live system.

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: throttle back local alloc when low on disk space
Mark Fasheh [Tue, 29 Jul 2008 01:02:53 +0000 (18:02 -0700)]
ocfs2: throttle back local alloc when low on disk space

Ocfs2's local allocator disables itself for the duration of a mount point
when it has trouble allocating a large enough area from the primary bitmap.
That can cause performance problems, especially for disks which were only
temporarily full or fragmented. This patch allows for the allocator to
shrink it's window first, before being disabled. Later, it can also be
re-enabled so that any performance drop is minimized.

To do this, we allow the value of osb->local_alloc_bits to be shrunk when
needed. The default value is recorded in a mostly read-only variable so that
we can re-initialize when required.

Locking had to be updated so that we could protect changes to
local_alloc_bits. Mostly this involves protecting various local alloc values
with the osb spinlock. A new state is also added, OCFS2_LA_THROTTLED, which
is used when the local allocator is has shrunk, but is not disabled. If the
available space dips below 1 megabyte, the local alloc file is disabled. In
either case, local alloc is re-enabled 30 seconds after the event, or when
an appropriate amount of bits is seen in the primary bitmap.

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: Track local alloc bits internally
Mark Fasheh [Mon, 28 Jul 2008 21:55:20 +0000 (14:55 -0700)]
ocfs2: Track local alloc bits internally

Do this instead of tracking absolute local alloc size. This avoids
needless re-calculatiion of bits from bytes in localalloc.c. Additionally,
the value is now in a more natural unit for internal file system bitmap
work.

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agoocfs2: POSIX file locks support
Mark Fasheh [Mon, 21 Jul 2008 21:29:16 +0000 (14:29 -0700)]
ocfs2: POSIX file locks support

This is actually pretty easy since fs/dlm already handles the bulk of the
work. The Ocfs2 userspace cluster stack module already uses fs/dlm as the
underlying lock manager, so I only had to add the right calls.

Cluster-aware POSIX locks ("plocks") can be turned off by the same means at
UNIX locks - mount with 'noflocks', or create a local-only Ocfs2 volume.
Internally, the file system uses two sets of file_operations, depending on
whether cluster aware plocks is required. This turns out to be easier than
implementing local-only versions of ->lock.

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 years agovfs: Use const for kernel parser table
Steven Whitehouse [Mon, 13 Oct 2008 09:46:57 +0000 (10:46 +0100)]
vfs: Use const for kernel parser table

This is a much better version of a previous patch to make the parser
tables constant. Rather than changing the typedef, we put the "const" in
all the various places where its required, allowing the __initconst
exception for nfsroot which was the cause of the previous trouble.

This was posted for review some time ago and I believe its been in -mm
since then.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Cc: Alexander Viro <aviro@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agoMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney...
Linus Torvalds [Mon, 13 Oct 2008 17:08:43 +0000 (10:08 -0700)]
Merge branch 'for-linus' of git://git./linux/kernel/git/cooloney/blackfin-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/blackfin-2.6: (60 commits)
  Blackfin arch: make sure we include the fix for SPORT hysteresis when reprogramming clocks
  Blackfin arch: Fix bogus str_ident check in gpio code
  Blackfin arch: AD7879 Touchscreen driver
  Blackfin arch: introducing bfin_addr_dcachable
  Blackfin arch: fix a typo in comments
  Blackfin arch: Remove useless head file
  Blackfin arch: make sure L2 start and length are always defined (fixes building on BF542)
  Blackfin arch: use the Blackfin on-chip ROM to do software reset when possible
  Blackfin arch: update anomaly headers to match the latest sheet
  Blackfin arch: bfin_reset() is an internal reboot function ... everyone should go through machine_restart()
  Blackfin arch: print out error/warning if you are running on the incorrect CPU type
  Blackfin arch: remove non-bf54x ifdef logic since this file is only compiled on bf54x parts
  Blackfin arch: update board defconfigs
  Blackfin arch: Add optional verbose debug
  Blackfin arch: emulate a TTY over the EMUDAT/JTAG interface
  Blackfin arch: have is_user_addr_valid() check for overflows (like when address is -1)
  Blackfin arch: ptrace - fix off-by-one check on end of memory regions
  Blackfin arch: Enable framebuffer support for the BF526-EZkit TFT LCD display
  Blackfin arch: flash memory map and dm9000 resources updating
  Blackfin arch: early prink code still use uart core console functions to parse and set configure option string
  ...

15 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
Linus Torvalds [Mon, 13 Oct 2008 17:08:08 +0000 (10:08 -0700)]
Merge git://git./linux/kernel/git/davem/net-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6:
  net/mac80211/rx.c: fix build error
  acpi: Make ACPI_TOSHIBA depend on INPUT.
  net/bfin_mac.c MDIO namespace fixes
  jme: remove unused #include <version.h>
  netfilter: remove unused #include <version.h>
  net: Fix off-by-one in skb_dma_map
  smc911x: Add support for LAN921{5,7,8} chips from SMSC
  qlge: remove duplicated #include
  wireless: remove duplicated #include
  net/au1000_eth.c MDIO namespace fixes
  net/tc35815.c: fix compilation
  sky2: Fix WOL regression
  r8169: NULL pointer dereference on r8169 load

15 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
Linus Torvalds [Mon, 13 Oct 2008 17:07:53 +0000 (10:07 -0700)]
Merge git://git./linux/kernel/git/davem/sparc-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6:
  chmc: Mark %ver register inline asm with __volatile__
  sparc64: Add missing notify_cpu_starting() call.
  sparc32: fix build errors

15 years agoMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
Linus Torvalds [Mon, 13 Oct 2008 17:06:58 +0000 (10:06 -0700)]
Merge branch 'for-linus' of git://git./linux/kernel/git/tiwai/sound-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6: (33 commits)
  ALSA: ASoC codec: remove unused #include <version.h>
  ALSA: ASoC: update email address for Liam Girdwood
  ALSA: hda: corrected invalid mixer values
  ALSA: hda: add mixers for analog mixer on 92hd75xx codecs
  ALSA: ASoC: Add destination and source port for DMA on OMAP1
  ALSA: ASoC: Drop device registration from GTA01 lm4857 driver
  ALSA: ASoC: Fix build of GTA01 audio driver
  ALSA: ASoC: Add widgets before setting endpoints on GTA01
  ALSA: ASoC: Fix inverted input PGA mute bits in WM8903
  ALSA: ASoC: OMAP: Set DMA stream name at runtime in McBSP DAI driver
  ALSA: ASoC: OMAP: Add support for OMAP2430 and OMAP34xx in McBSP DAI driver
  ALSA: ASoC: OMAP: Add multilink support to McBSP DAI driver
  ALSA: ASoC: Make TLV320AIC26 user-visible
  ALSA: ASoC - clean up Kconfig for TLV320AIC2
  ALSA: ASoC: Make WM8510 microphone input a DAPM mixer
  ALSA: ASoC: Implement WM8510 bias level control
  ALSA: ASoC: Remove unused AUDIO_NAME define from codec drivers
  ALSA: ASoC: tlv320aic3x: Use uniform tlv320aic naming
  ALSA: ASoC: Add WM8510 SPI support
  ALSA: ASoC: Add WM8753 SPI support
  ...

15 years agoMerge branch 'proc' of git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc
Linus Torvalds [Mon, 13 Oct 2008 17:04:04 +0000 (10:04 -0700)]
Merge branch 'proc' of git://git./linux/kernel/git/adobriyan/proc

* 'proc' of git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc:
  proc: remove kernel.maps_protect
  proc: remove now unneeded ADDBUF macro
  [PATCH] proc: show personality via /proc/pid/personality
  [PATCH] signal, procfs: some lock_task_sighand() users do not need rcu_read_lock()
  proc: move PROC_PAGE_MONITOR to fs/proc/Kconfig
  proc: make grab_header() static
  proc: remove unused get_dma_list()
  proc: remove dummy vmcore_open()
  proc: proc_sys_root tweak
  proc: fix return value of proc_reg_open() in "too late" case

Fixed up trivial conflict in removed file arch/sparc/include/asm/dma_32.h

15 years agoMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
Linus Torvalds [Mon, 13 Oct 2008 17:00:44 +0000 (10:00 -0700)]
Merge branch 'for-linus' of git://git./linux/kernel/git/jmorris/security-testing-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6: (24 commits)
  integrity: special fs magic
  As pointed out by Jonathan Corbet, the timer must be deleted before
  ERROR: code indent should use tabs where possible
  The tpm_dev_release function is only called for platform devices, not pnp
  Protect tpm_chip_list when transversing it.
  Renames num_open to is_open, as only one process can open the file at a time.
  Remove the BKL calls from the TPM driver, which were added in the overall
  netlabel: Add configuration support for local labeling
  cipso: Add support for native local labeling and fixup mapping names
  netlabel: Changes to the NetLabel security attributes to allow LSMs to pass full contexts
  selinux: Cache NetLabel secattrs in the socket's security struct
  selinux: Set socket NetLabel based on connection endpoint
  netlabel: Add functionality to set the security attributes of a packet
  netlabel: Add network address selectors to the NetLabel/LSM domain mapping
  netlabel: Add a generic way to create ordered linked lists of network addrs
  netlabel: Replace protocol/NetLabel linking with refrerence counts
  smack: Fix missing calls to netlbl_skbuff_err()
  selinux: Fix missing calls to netlbl_skbuff_err()
  selinux: Fix a problem in security_netlbl_sid_to_secattr()
  selinux: Better local/forward check in selinux_ip_postroute()
  ...

15 years agoMerge git://git.infradead.org/users/dwmw2/random-2.6
Linus Torvalds [Mon, 13 Oct 2008 16:59:14 +0000 (09:59 -0700)]
Merge git://git.infradead.org/users/dwmw2/random-2.6

* git://git.infradead.org/users/dwmw2/random-2.6:
  Fix autoloading of MacBook Pro backlight driver.
  Automatic MODULE_ALIAS() for DMI match tables.
  Remove asm/a.out.h files for all architectures without a.out support.
  Introduce HAVE_AOUT symbol to remove hard-coded arch list for BINFMT_AOUT
  Remove redundant CONFIG_ARCH_SUPPORTS_AOUT
  S390: Update comments about why we don't use <asm-generic/statfs.h>
  SPARC: Use <asm-generic/statfs.h>
  PowerPC: Use <asm-generic/statfs.h>
  PARISC: Use <asm-generic/statfs.h>
  x86_64: Use <asm-generic/statfs.h>
  IA64: Use <asm-generic/statfs.h>
  ARM: Use <asm-generic/statfs.h>
  Make <asm-generic/statfs.h> suitable for 64-bit platforms.
  Define and use PCI_DEVICE_ID_MARVELL_88ALP01_CCIC for CAFÉ camera driver
  [MTD] [NAND] Define and use PCI_DEVICE_ID_MARVELL_88ALP01_NAND for CAFÉ
  Use PCI_DEVICE_ID_88ALP01 for CAFÉ chip, rather than PCI_DEVICE_ID_CAFE.
  EFS: Don't set f_fsid in statfs().

15 years agoMerge phase #5 (misc) of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux...
Linus Torvalds [Mon, 13 Oct 2008 16:54:35 +0000 (09:54 -0700)]
Merge phase #5 (misc) of git://git./linux/kernel/git/tip/linux-2.6-tip

Merges oprofile, timers/hpet, x86/traps, x86/time, and x86/core misc items.

* 'x86-core-v4-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (132 commits)
  x86: change early_ioremap to use slots instead of nesting
  x86: adjust dependencies for CONFIG_X86_CMOV
  dumpstack: x86: various small unification steps, fix
  x86: remove additional_cpus
  x86: remove additional_cpus configurability
  x86: improve UP kernel when CPU-hotplug and SMP is enabled
  dumpstack: x86: various small unification steps
  dumpstack: i386: make kstack= an early boot-param and add oops=panic
  dumpstack: x86: use log_lvl and unify trace formatting
  dumptrace: x86: consistently include loglevel, print stack switch
  dumpstack: x86: add "end" parameter to valid_stack_ptr and print_context_stack
  dumpstack: x86: make printk_address equal
  dumpstack: x86: move die_nmi to dumpstack_32.c
  traps: x86: finalize unification of traps.c
  traps: x86: make traps_32.c and traps_64.c equal
  traps: x86: various noop-changes preparing for unification of traps_xx.c
  traps: x86_64: use task_pid_nr(tsk) instead of tsk->pid in do_general_protection
  traps: i386: expand clear_mem_error and remove from mach_traps.h
  traps: x86_64: make io_check_error equal to the one on i386
  traps: i386: use preempt_conditional_sti/cli in do_int3
  ...

15 years agotty: rename the remaining oddly named n_tty functions
Alan Cox [Mon, 13 Oct 2008 09:46:24 +0000 (10:46 +0100)]
tty: rename the remaining oddly named n_tty functions

Original idea for this from a patch by Rodolfo Giometti which merges various
bits of PPS support

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agofs3270: Correct error returns
Alan Cox [Mon, 13 Oct 2008 09:46:09 +0000 (10:46 +0100)]
fs3270: Correct error returns

Drop the kernel lock further and also correct cases where we set rc to an
error code, and then return 0

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agofs3270: remove extra locks
Alan Cox [Mon, 13 Oct 2008 09:45:52 +0000 (10:45 +0100)]
fs3270: remove extra locks

get_current_tty now does internal locking and returns a referenced object,
thus our use of tty_mutex here can go away.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: tty_io.c shadows sparse fix
Jason Wessel [Mon, 13 Oct 2008 09:45:36 +0000 (10:45 +0100)]
tty: tty_io.c shadows sparse fix

drivers/char/tty_io.c:1413:17: warning: symbol 'buf' shadows an earlier one
drivers/char/tty_io.c:1379:20: originally declared here

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agoserial: fix device name reporting when minor space is shared between drivers
David S. Miller [Mon, 13 Oct 2008 09:45:26 +0000 (10:45 +0100)]
serial: fix device name reporting when minor space is shared between drivers

The multiple drivers share the minor space occupied by a particular major
number, the actual index within the device name's space is indicated by
the tty_driver->name_base + uart_port->line

Another usable formula is (uart_driver->minor - MINOR_BASE) + port->line

Use those to print the device names properly in such situations in
serial_core.c and 8250.c

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agoapplicom: Fix an unchecked user ioctl range and an error return
Alan Cox [Mon, 13 Oct 2008 09:45:17 +0000 (10:45 +0100)]
applicom: Fix an unchecked user ioctl range and an error return

Closes bug #11408 by checking the card index range for command 0
Fixes the ioctl to return ENOTTY which is correct for unknown ioctls

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Minor tidyups and document fixes for n_tty
Alan Cox [Mon, 13 Oct 2008 09:45:06 +0000 (10:45 +0100)]
tty: Minor tidyups and document fixes for n_tty

Remove/fix some bogus NULL checks, comment some locking etc

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Remove lots of NULL checks
Alan Cox [Mon, 13 Oct 2008 09:44:57 +0000 (10:44 +0100)]
tty: Remove lots of NULL checks

Many tty drivers contain 'can't happen' checks against NULL pointers passed
in by the tty layer. These have never been possible to occur. Even more
importantly if they ever do occur we want to know as it would be a serious
bug.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: fix up gigaset a bit
Alan Cox [Mon, 13 Oct 2008 09:44:43 +0000 (10:44 +0100)]
tty: fix up gigaset a bit

Stephen's fixes reminded me that gigaset is still rather broken so fix it up
a bit

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Fallout from tty-move-canon-specials
Stephen Rothwell [Mon, 13 Oct 2008 09:44:33 +0000 (10:44 +0100)]
tty: Fallout from tty-move-canon-specials

Today's linux-next build (x86_64 allmodconfig) failed like this:

/drivers/char/tty_ioctl.c: In function 'change_termios':
drivers/isdn/capi/capi.c:1234: error: implicit declaration of function 'n_tty_ioctl'
drivers/isdn/gigaset/ser-gigaset.c: In function 'gigaset_tty_ioctl':
drivers/isdn/gigaset/ser-gigaset.c:648: error: implicit declaration of function 'n_tty_ioctl'

Introduced by commit 686b5e4aea05a80e370dc931b7f4a8d03c80da54
("tty-move-canon-specials").  I added the following patch (which may not
be correct).

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: some ICANON magic is in the wrong places
Alan Cox [Mon, 13 Oct 2008 09:44:17 +0000 (10:44 +0100)]
tty: some ICANON magic is in the wrong places

Move the set up on ldisc change into the ldisc
Move the INQ/OUTQ cases into the driver not in shared ioctl code where it
gives bogus answers for other ldisc values

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: simplify ktermios allocation
Alan Cox [Mon, 13 Oct 2008 09:44:08 +0000 (10:44 +0100)]
tty: simplify ktermios allocation

Copy the simplification from the pty unix98 special case to the generic one.
This allows us to kill off driver->termios_locked entirely which is nice. We
have to whack bits of the cris driver as it meddles in places it shouldn't
providing its own arrays that were never used anyway.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agopty: simplify unix98 allocation
Alan Cox [Mon, 13 Oct 2008 09:43:58 +0000 (10:43 +0100)]
pty: simplify unix98 allocation

We need both termios and termios_locked so allocate them as one

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agopty: Fix allocation failure double free
Alan Cox [Mon, 13 Oct 2008 09:43:48 +0000 (10:43 +0100)]
pty: Fix allocation failure double free

The updating and moving around of the pty code added a bug where both the
helper and caller free the main tty struct (the pty driver must free the
o_tty pair itself however).

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agopty: Coding style and polish
Alan Cox [Mon, 13 Oct 2008 09:43:38 +0000 (10:43 +0100)]
pty: Coding style and polish

We've done the heavy lifting now its time to mop up a bit

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agoSimplify devpts_pty_kill
Sukadev Bhattiprolu [Mon, 13 Oct 2008 09:43:27 +0000 (10:43 +0100)]
Simplify devpts_pty_kill

When creating a new pty, save the pty's inode in the tty->driver_data.
Use this inode in pty_kill() to identify the devpts instance. Since
we now have the inode for the pty, we can skip get_node() lookup and
remove the unused get_node().

TODO:
- check if the mutex_lock is needed in pty_kill().

Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agoSimplify devpts_pty_new()
Sukadev Bhattiprolu [Mon, 13 Oct 2008 09:43:18 +0000 (10:43 +0100)]
Simplify devpts_pty_new()

devpts_pty_new() is called when setting up a new pty and would not
will not have an existing dentry or inode for the pty. So don't bother
looking for an existing dentry - just create a new one.

Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agoSimplify devpts_get_tty()
Sukadev Bhattiprolu [Mon, 13 Oct 2008 09:43:08 +0000 (10:43 +0100)]
Simplify devpts_get_tty()

As pointed out by H. Peter Anvin, since the inode for the pty is known,
we don't need to look it up.

Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agoAdd an instance parameter devpts interfaces
Sukadev Bhattiprolu [Mon, 13 Oct 2008 09:42:59 +0000 (10:42 +0100)]
Add an instance parameter devpts interfaces

Pass-in 'inode' or 'tty' parameter to devpts interfaces.  With multiple
devpts instances, these parameters will be used in subsequent patches
to identify the instance of devpts mounted. The parameters also help
simplify devpts implementation.

Changelog[v3]:
- minor changes due to merge with ttydev updates
- rename parameters to emphasize they are ptmx or pts inodes
- pass-in tty_struct * to devpts_pty_kill() (this will help
  cleanup the get_node() call in a subsequent patch)

Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agoMove tty lookup/reopen to caller
Sukadev Bhattiprolu [Mon, 13 Oct 2008 09:42:49 +0000 (10:42 +0100)]
Move tty lookup/reopen to caller

Move tty_driver_lookup_tty() and tty_reopen() from tty_init_dev()
into tty_open() (one of the two callers of tty_init_dev()).  These
calls are not really required in ptmx_open(), the other caller,
since ptmx_open() would be setting up a new tty.

Changelog[v2]:
- remove the lookup and reopen calls from ptmx_open
- merge with recent changes to ttydev tree

Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: extract the pty init time special cases
Alan Cox [Mon, 13 Oct 2008 09:42:39 +0000 (10:42 +0100)]
tty: extract the pty init time special cases

The majority of the remaining init_dev code is pty special cases. We
refactor this code into the driver->install method.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Finish fixing up the init_dev interface to use ERR_PTR
Alan Cox [Mon, 13 Oct 2008 09:42:29 +0000 (10:42 +0100)]
tty: Finish fixing up the init_dev interface to use ERR_PTR

Original suggestion and proposal from Sukadev Bhattiprolu.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: More driver operations
Alan Cox [Mon, 13 Oct 2008 09:42:19 +0000 (10:42 +0100)]
tty: More driver operations

We have the lookup operation abstracted which is nice for pty cleanup but
we really want to abstract the add/remove entries as well so that we can
pull the pty code out of the tty core and create a clear defined interface
for the tty driver table.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: kref the tty driver object
Alan Cox [Mon, 13 Oct 2008 09:42:09 +0000 (10:42 +0100)]
tty: kref the tty driver object

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Clean up the tty_init_dev changes further
Alan Cox [Mon, 13 Oct 2008 09:42:00 +0000 (10:42 +0100)]
tty: Clean up the tty_init_dev changes further

Fix up the naming, style and extract some bits of code into the driver
specific code

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Move parts of tty_init_dev into new functions
Sukadev Bhattiprolu [Mon, 13 Oct 2008 09:41:51 +0000 (10:41 +0100)]
tty: Move parts of tty_init_dev into new functions

Move the 'find-tty' and 'fast-track-open' parts of init_dev() to
separate functions.

Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Remove more special casing and out of place code
Alan Cox [Mon, 13 Oct 2008 09:41:42 +0000 (10:41 +0100)]
tty: Remove more special casing and out of place code

Carry on pushing code out of tty_io when it belongs to other drivers. I'm
not 100% happy with some of this and it will be worth revisiting some of the
exports later when the restructuring work is done.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: shutdown method
Alan Cox [Mon, 13 Oct 2008 09:41:30 +0000 (10:41 +0100)]
tty: shutdown method

Right now there are various drivers that try to use tty->count to know when
they get the final close. Aristeau Rozanski showed while debugging the vt
sysfs race that this isn't entirely safe.

Instead of driver side tricks to work around this introduce a shutdown which
is called when the tty is being destructed. This also means that the shutdown
method is tied into the refcounting.

Use this to rework the console close/sysfs logic.

Remove lots of special case code from the tty core code. The pty code can now
have a shutdown() method that replaces the special case hackery in the tree
free up paths.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agovt: remove bogus lock dropping
Alan Cox [Mon, 13 Oct 2008 09:41:16 +0000 (10:41 +0100)]
vt: remove bogus lock dropping

For hysterical raisins the vt layer drops and retakes locks in the write
method. This is a left over from the days when user/kernel data was passed
directly to the tty not pre-buffered.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agopty: If the administrator creates a device for a ptmx slave we should not error
Alan Cox [Mon, 13 Oct 2008 09:41:03 +0000 (10:41 +0100)]
pty: If the administrator creates a device for a ptmx slave we should not error

The open path for ptmx slaves is via the ptmx device. Opening them any
other way is not allowed. Vegard Nossum found that previously this was not
the case and mknod foo c 128 42; cat foo would produce nasty diagnostics

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Fix abusers of current->sighand->tty
Alan Cox [Mon, 13 Oct 2008 09:40:53 +0000 (10:40 +0100)]
tty: Fix abusers of current->sighand->tty

Various people outside the tty layer still stick their noses in behind the
scenes. We need to make sure they also obey the locking and referencing rules.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Redo current tty locking
Alan Cox [Mon, 13 Oct 2008 09:40:43 +0000 (10:40 +0100)]
tty: Redo current tty locking

Currently it is sometimes locked by the tty mutex and sometimes by the
sighand lock. The latter is in fact correct and now we can hand back referenced
objects we can fix this up without problems around sleeping functions.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: the vhangup syscall is racy
Alan Cox [Mon, 13 Oct 2008 09:40:30 +0000 (10:40 +0100)]
tty: the vhangup syscall is racy

We now have the infrastructure to sort this out but rather than teaching
the syscall tty lock rules we move the hard work into a tty helper

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agomxser: Switch to kref tty
Alan Cox [Mon, 13 Oct 2008 09:40:19 +0000 (10:40 +0100)]
mxser: Switch to kref tty

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agostallion: Use krefs
Alan Cox [Mon, 13 Oct 2008 09:40:07 +0000 (10:40 +0100)]
stallion: Use krefs

Use tty_port_init and krefs in the stallion drivers to protect us from devices
going away underneath us. As with the other drives some rearranging is done to
pass the tty structure down properly on the user side.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: kref usage for isicom and moxa
Alan Cox [Mon, 13 Oct 2008 09:39:58 +0000 (10:39 +0100)]
tty: kref usage for isicom and moxa

Rather than blindly keep taking krefs we reorder the code in a few places
to pass the tty down to the right place (which is important as from the user
side it is not the case that tty == port->tty in all situations). For the irq
and related paths use the krefs to stop the tty being freed under us.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: usb-serial krefs
Alan Cox [Mon, 13 Oct 2008 09:39:46 +0000 (10:39 +0100)]
tty: usb-serial krefs

Use kref in the USB serial drivers so that we don't free tty structures
from under the URB receive handlers as has historically been the case if
you were unlucky. This also gives us a framework for general tty drivers to
use tty_port objects and refcount.

Contains two err->dev_err changes merged together to fix clashes in the
-next tree.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Move tty_write_message out of kernel/printk
Alan Cox [Mon, 13 Oct 2008 09:39:23 +0000 (10:39 +0100)]
tty: Move tty_write_message out of kernel/printk

This is pure tty code so put it in the tty layer where it can be with the
locking relevant material it uses

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Make get_current_tty use a kref
Alan Cox [Mon, 13 Oct 2008 09:39:13 +0000 (10:39 +0100)]
tty: Make get_current_tty use a kref

We now return a kref covered tty reference. That ensures the tty structure
doesn't go away when you have a return from get_current_tty. This is not
enough to protect you from most of the resources being freed behind your
back - yet.

[Updated to include fixes for SELinux problems found by Andrew Morton and
 an s390 leak found while debugging the former]

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: compare the tty winsize
Alan Cox [Mon, 13 Oct 2008 09:39:01 +0000 (10:39 +0100)]
tty: compare the tty winsize

We always use the real tty one for stuff so the pty one should not be
compared. As we propagate window changes to both it doesn't currently
matter but will when we tidy up the pty termios logic a bit more

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Termios locking - sort out real_tty confusions and lock reads
Alan Cox [Mon, 13 Oct 2008 09:38:46 +0000 (10:38 +0100)]
tty: Termios locking - sort out real_tty confusions and lock reads

This moves us towards sanity and should mean our termios locking is now
complete and comprehensive.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Add termiox
Alan Cox [Mon, 13 Oct 2008 09:38:18 +0000 (10:38 +0100)]
tty: Add termiox

We need a way to describe the various additional modes and flow control
features that random weird hardware shows up and software such as wine
wants to emulate as Windows supports them.

TCGETX/TCSETX and the termiox ioctl are a SYS5 extension that we might as
well adopt. This patches adds the structures and the basic ioctl interfaces
when the TCGETX etc defines are added for an architecture. Drivers wishing
to use this stuff need to add new methods.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: ipw need reworking
Alan Cox [Mon, 13 Oct 2008 09:38:07 +0000 (10:38 +0100)]
tty: ipw need reworking

This came in via another tree and unfortunately is rather broken on
the tty side. Comment the apparent locking problems for someone who knows
the driver to look at.

Fix the termios and other ioctl handling. The driver was calling the wrong
methods for what it wanted to do but the right ones existed so its a simple
fix up.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Cris has a nice RS485 ioctl so we should steal it
Alan Cox [Mon, 13 Oct 2008 09:37:48 +0000 (10:37 +0100)]
tty: Cris has a nice RS485 ioctl so we should steal it

JP Tosoni observed:

"About a RS485 ioctl: could you consider the attached files which are
 already in the Linux kernel (in include/asm-cris).  They define a
 TIOCSERSETRS485 (ioctl.h), and the data structure (rs485.h)
 with allows to specify timings. Sounds just like what we want ?"

and he's right: sort of. Rework the structure to use flag bits and make the
time delay a fixed sized field so we don't get 32/64bit problems. Add the ioctls
to x86 so that people know what to add to their platform of choice.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: use krefs to protect driver module counts
Alan Cox [Mon, 13 Oct 2008 09:37:36 +0000 (10:37 +0100)]
tty: use krefs to protect driver module counts

The tty layer keeps driver module counts that are used so the driver knows
when it can be unloaded. For obvious reasons we want to tie that to the
refcounting properly.

At this point the driver side itself isn't refcounted nicely but we can do
that later and kref the drivers.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotty: Add a kref count
Alan Cox [Mon, 13 Oct 2008 09:37:26 +0000 (10:37 +0100)]
tty: Add a kref count

Introduce a kref to the tty structure and use it to protect the tty->signal
tty references. For now we don't introduce it for anything else.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>