1. 03 Apr, 2009 40 commits
    • David Howells's avatar
      FS-Cache: Add and document asynchronous operation handling · 952efe7b
      David Howells authored
      Add and document asynchronous operation handling for use by FS-Cache's data
      storage and retrieval routines.
      
      The following documentation is added to:
      
      	Documentation/filesystems/caching/operations.txt
      
      		       ================================
      		       ASYNCHRONOUS OPERATIONS HANDLING
      		       ================================
      
      ========
      OVERVIEW
      ========
      
      FS-Cache has an asynchronous operations handling facility that it uses for its
      data storage and retrieval routines.  Its operations are represented by
      fscache_operation structs, though these are usually embedded into some other
      structure.
      
      This facility is available to and expected to be be used by the cache backends,
      and FS-Cache will create operations and pass them off to the appropriate cache
      backend for completion.
      
      To make use of this facility, <linux/fscache-cache.h> should be #included.
      
      ===============================
      OPERATION RECORD INITIALISATION
      ===============================
      
      An operation is recorded in an fscache_operation struct:
      
      	struct fscache_operation {
      		union {
      			struct work_struct fast_work;
      			struct slow_work slow_work;
      		};
      		unsigned long		flags;
      		fscache_operation_processor_t processor;
      		...
      	};
      
      Someone wanting to issue an operation should allocate something with this
      struct embedded in it.  They should initialise it by calling:
      
      	void fscache_operation_init(struct fscache_operation *op,
      				    fscache_operation_release_t release);
      
      with the operation to be initialised and the release function to use.
      
      The op->flags parameter should be set to indicate the CPU time provision and
      the exclusivity (see the Parameters section).
      
      The op->fast_work, op->slow_work and op->processor flags should be set as
      appropriate for the CPU time provision (see the Parameters section).
      
      FSCACHE_OP_WAITING may be set in op->flags prior to each submission of the
      operation and waited for afterwards.
      
      ==========
      PARAMETERS
      ==========
      
      There are a number of parameters that can be set in the operation record's flag
      parameter.  There are three options for the provision of CPU time in these
      operations:
      
       (1) The operation may be done synchronously (FSCACHE_OP_MYTHREAD).  A thread
           may decide it wants to handle an operation itself without deferring it to
           another thread.
      
           This is, for example, used in read operations for calling readpages() on
           the backing filesystem in CacheFiles.  Although readpages() does an
           asynchronous data fetch, the determination of whether pages exist is done
           synchronously - and the netfs does not proceed until this has been
           determined.
      
           If this option is to be used, FSCACHE_OP_WAITING must be set in op->flags
           before submitting the operation, and the operating thread must wait for it
           to be cleared before proceeding:
      
      		wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
      			    fscache_wait_bit, TASK_UNINTERRUPTIBLE);
      
       (2) The operation may be fast asynchronous (FSCACHE_OP_FAST), in which case it
           will be given to keventd to process.  Such an operation is not permitted
           to sleep on I/O.
      
           This is, for example, used by CacheFiles to copy data from a backing fs
           page to a netfs page after the backing fs has read the page in.
      
           If this option is used, op->fast_work and op->processor must be
           initialised before submitting the operation:
      
      		INIT_WORK(&op->fast_work, do_some_work);
      
       (3) The operation may be slow asynchronous (FSCACHE_OP_SLOW), in which case it
           will be given to the slow work facility to process.  Such an operation is
           permitted to sleep on I/O.
      
           This is, for example, used by FS-Cache to handle background writes of
           pages that have just been fetched from a remote server.
      
           If this option is used, op->slow_work and op->processor must be
           initialised before submitting the operation:
      
      		fscache_operation_init_slow(op, processor)
      
      Furthermore, operations may be one of two types:
      
       (1) Exclusive (FSCACHE_OP_EXCLUSIVE).  Operations of this type may not run in
           conjunction with any other operation on the object being operated upon.
      
           An example of this is the attribute change operation, in which the file
           being written to may need truncation.
      
       (2) Shareable.  Operations of this type may be running simultaneously.  It's
           up to the operation implementation to prevent interference between other
           operations running at the same time.
      
      =========
      PROCEDURE
      =========
      
      Operations are used through the following procedure:
      
       (1) The submitting thread must allocate the operation and initialise it
           itself.  Normally this would be part of a more specific structure with the
           generic op embedded within.
      
       (2) The submitting thread must then submit the operation for processing using
           one of the following two functions:
      
      	int fscache_submit_op(struct fscache_object *object,
      			      struct fscache_operation *op);
      
      	int fscache_submit_exclusive_op(struct fscache_object *object,
      					struct fscache_operation *op);
      
           The first function should be used to submit non-exclusive ops and the
           second to submit exclusive ones.  The caller must still set the
           FSCACHE_OP_EXCLUSIVE flag.
      
           If successful, both functions will assign the operation to the specified
           object and return 0.  -ENOBUFS will be returned if the object specified is
           permanently unavailable.
      
           The operation manager will defer operations on an object that is still
           undergoing lookup or creation.  The operation will also be deferred if an
           operation of conflicting exclusivity is in progress on the object.
      
           If the operation is asynchronous, the manager will retain a reference to
           it, so the caller should put their reference to it by passing it to:
      
      	void fscache_put_operation(struct fscache_operation *op);
      
       (3) If the submitting thread wants to do the work itself, and has marked the
           operation with FSCACHE_OP_MYTHREAD, then it should monitor
           FSCACHE_OP_WAITING as described above and check the state of the object if
           necessary (the object might have died whilst the thread was waiting).
      
           When it has finished doing its processing, it should call
           fscache_put_operation() on it.
      
       (4) The operation holds an effective lock upon the object, preventing other
           exclusive ops conflicting until it is released.  The operation can be
           enqueued for further immediate asynchronous processing by adjusting the
           CPU time provisioning option if necessary, eg:
      
      	op->flags &= ~FSCACHE_OP_TYPE;
      	op->flags |= ~FSCACHE_OP_FAST;
      
           and calling:
      
      	void fscache_enqueue_operation(struct fscache_operation *op)
      
           This can be used to allow other things to have use of the worker thread
           pools.
      
      =====================
      ASYNCHRONOUS CALLBACK
      =====================
      
      When used in asynchronous mode, the worker thread pool will invoke the
      processor method with a pointer to the operation.  This should then get at the
      container struct by using container_of():
      
      	static void fscache_write_op(struct fscache_operation *_op)
      	{
      		struct fscache_storage *op =
      			container_of(_op, struct fscache_storage, op);
      	...
      	}
      
      The caller holds a reference on the operation, and will invoke
      fscache_put_operation() when the processor function returns.  The processor
      function is at liberty to call fscache_enqueue_operation() or to take extra
      references.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      952efe7b
    • David Howells's avatar
      FS-Cache: Implement the cookie management part of the netfs API · ccc4fc3d
      David Howells authored
      Implement the cookie management part of the FS-Cache netfs client API.  The
      documentation and API header file were added in a previous patch.
      
      This patch implements the following three functions:
      
       (1) fscache_acquire_cookie().
      
           Acquire a cookie to represent an object to the netfs.  If the object in
           question is a non-index object, then that object and its parent indices
           will be created on disk at this point if they don't already exist.  Index
           creation is deferred because an index may reside in multiple caches.
      
       (2) fscache_relinquish_cookie().
      
           Retire or release a cookie previously acquired.  At this point, the
           object on disk may be destroyed.
      
       (3) fscache_update_cookie().
      
           Update the in-cache representation of a cookie.  This is used to update
           the auxiliary data for coherency management purposes.
      
      With this patch it is possible to have a netfs instruct a cache backend to
      look up, validate and create metadata on disk and to destroy it again.
      The ability to actually store and retrieve data in the objects so created is
      added in later patches.
      
      Note that these functions will never return an error.  _All_ errors are
      handled internally to FS-Cache.
      
      The worst that can happen is that fscache_acquire_cookie() may return a NULL
      pointer - which is considered a negative cookie pointer and can be passed back
      to any function that takes a cookie without harm.  A negative cookie pointer
      merely suppresses caching at that level.
      
      The stub in linux/fscache.h will detect inline the negative cookie pointer and
      abort the operation as fast as possible.  This means that the compiler doesn't
      have to set up for a call in that case.
      
      See the documentation in Documentation/filesystems/caching/netfs-api.txt for
      more information.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      ccc4fc3d
    • David Howells's avatar
      FS-Cache: Object management state machine · 36c95590
      David Howells authored
      Implement the cache object management state machine.
      
      The following documentation is added to illuminate the working of this state
      machine.  It will also be added as:
      
      	Documentation/filesystems/caching/object.txt
      
      	     ====================================================
      	     IN-KERNEL CACHE OBJECT REPRESENTATION AND MANAGEMENT
      	     ====================================================
      
      ==============
      REPRESENTATION
      ==============
      
      FS-Cache maintains an in-kernel representation of each object that a netfs is
      currently interested in.  Such objects are represented by the fscache_cookie
      struct and are referred to as cookies.
      
      FS-Cache also maintains a separate in-kernel representation of the objects that
      a cache backend is currently actively caching.  Such objects are represented by
      the fscache_object struct.  The cache backends allocate these upon request, and
      are expected to embed them in their own representations.  These are referred to
      as objects.
      
      There is a 1:N relationship between cookies and objects.  A cookie may be
      represented by multiple objects - an index may exist in more than one cache -
      or even by no objects (it may not be cached).
      
      Furthermore, both cookies and objects are hierarchical.  The two hierarchies
      correspond, but the cookies tree is a superset of the union of the object trees
      of multiple caches:
      
      	    NETFS INDEX TREE               :      CACHE 1     :      CACHE 2
      	                                   :                  :
      	                                   :   +-----------+  :
      	                          +----------->|  IObject  |  :
      	      +-----------+       |        :   +-----------+  :
      	      |  ICookie  |-------+        :         |        :
      	      +-----------+       |        :         |        :   +-----------+
      	            |             +------------------------------>|  IObject  |
      	            |                      :         |        :   +-----------+
      	            |                      :         V        :         |
      	            |                      :   +-----------+  :         |
      	            V             +----------->|  IObject  |  :         |
      	      +-----------+       |        :   +-----------+  :         |
      	      |  ICookie  |-------+        :         |        :         V
      	      +-----------+       |        :         |        :   +-----------+
      	            |             +------------------------------>|  IObject  |
      	      +-----+-----+                :         |        :   +-----------+
      	      |           |                :         |        :         |
      	      V           |                :         V        :         |
      	+-----------+     |                :   +-----------+  :         |
      	|  ICookie  |------------------------->|  IObject  |  :         |
      	+-----------+     |                :   +-----------+  :         |
      	      |           V                :         |        :         V
      	      |     +-----------+          :         |        :   +-----------+
      	      |     |  ICookie  |-------------------------------->|  IObject  |
      	      |     +-----------+          :         |        :   +-----------+
      	      V           |                :         V        :         |
      	+-----------+     |                :   +-----------+  :         |
      	|  DCookie  |------------------------->|  DObject  |  :         |
      	+-----------+     |                :   +-----------+  :         |
      	                  |                :                  :         |
      	          +-------+-------+        :                  :         |
      	          |               |        :                  :         |
      	          V               V        :                  :         V
      	    +-----------+   +-----------+  :                  :   +-----------+
      	    |  DCookie  |   |  DCookie  |------------------------>|  DObject  |
      	    +-----------+   +-----------+  :                  :   +-----------+
      	                                   :                  :
      
      In the above illustration, ICookie and IObject represent indices and DCookie
      and DObject represent data storage objects.  Indices may have representation in
      multiple caches, but currently, non-index objects may not.  Objects of any type
      may also be entirely unrepresented.
      
      As far as the netfs API goes, the netfs is only actually permitted to see
      pointers to the cookies.  The cookies themselves and any objects attached to
      those cookies are hidden from it.
      
      ===============================
      OBJECT MANAGEMENT STATE MACHINE
      ===============================
      
      Within FS-Cache, each active object is managed by its own individual state
      machine.  The state for an object is kept in the fscache_object struct, in
      object->state.  A cookie may point to a set of objects that are in different
      states.
      
      Each state has an action associated with it that is invoked when the machine
      wakes up in that state.  There are four logical sets of states:
      
       (1) Preparation: states that wait for the parent objects to become ready.  The
           representations are hierarchical, and it is expected that an object must
           be created or accessed with respect to its parent object.
      
       (2) Initialisation: states that perform lookups in the cache and validate
           what's found and that create on disk any missing metadata.
      
       (3) Normal running: states that allow netfs operations on objects to proceed
           and that update the state of objects.
      
       (4) Termination: states that detach objects from their netfs cookies, that
           delete objects from disk, that handle disk and system errors and that free
           up in-memory resources.
      
      In most cases, transitioning between states is in response to signalled events.
      When a state has finished processing, it will usually set the mask of events in
      which it is interested (object->event_mask) and relinquish the worker thread.
      Then when an event is raised (by calling fscache_raise_event()), if the event
      is not masked, the object will be queued for processing (by calling
      fscache_enqueue_object()).
      
      PROVISION OF CPU TIME
      ---------------------
      
      The work to be done by the various states is given CPU time by the threads of
      the slow work facility (see Documentation/slow-work.txt).  This is used in
      preference to the workqueue facility because:
      
       (1) Threads may be completely occupied for very long periods of time by a
           particular work item.  These state actions may be doing sequences of
           synchronous, journalled disk accesses (lookup, mkdir, create, setxattr,
           getxattr, truncate, unlink, rmdir, rename).
      
       (2) Threads may do little actual work, but may rather spend a lot of time
           sleeping on I/O.  This means that single-threaded and 1-per-CPU-threaded
           workqueues don't necessarily have the right numbers of threads.
      
      LOCKING SIMPLIFICATION
      ----------------------
      
      Because only one worker thread may be operating on any particular object's
      state machine at once, this simplifies the locking, particularly with respect
      to disconnecting the netfs's representation of a cache object (fscache_cookie)
      from the cache backend's representation (fscache_object) - which may be
      requested from either end.
      
      =================
      THE SET OF STATES
      =================
      
      The object state machine has a set of states that it can be in.  There are
      preparation states in which the object sets itself up and waits for its parent
      object to transit to a state that allows access to its children:
      
       (1) State FSCACHE_OBJECT_INIT.
      
           Initialise the object and wait for the parent object to become active.  In
           the cache, it is expected that it will not be possible to look an object
           up from the parent object, until that parent object itself has been looked
           up.
      
      There are initialisation states in which the object sets itself up and accesses
      disk for the object metadata:
      
       (2) State FSCACHE_OBJECT_LOOKING_UP.
      
           Look up the object on disk, using the parent as a starting point.
           FS-Cache expects the cache backend to probe the cache to see whether this
           object is represented there, and if it is, to see if it's valid (coherency
           management).
      
           The cache should call fscache_object_lookup_negative() to indicate lookup
           failure for whatever reason, and should call fscache_obtained_object() to
           indicate success.
      
           At the completion of lookup, FS-Cache will let the netfs go ahead with
           read operations, no matter whether the file is yet cached.  If not yet
           cached, read operations will be immediately rejected with ENODATA until
           the first known page is uncached - as to that point there can be no data
           to be read out of the cache for that file that isn't currently also held
           in the pagecache.
      
       (3) State FSCACHE_OBJECT_CREATING.
      
           Create an object on disk, using the parent as a starting point.  This
           happens if the lookup failed to find the object, or if the object's
           coherency data indicated what's on disk is out of date.  In this state,
           FS-Cache expects the cache to create
      
           The cache should call fscache_obtained_object() if creation completes
           successfully, fscache_object_lookup_negative() otherwise.
      
           At the completion of creation, FS-Cache will start processing write
           operations the netfs has queued for an object.  If creation failed, the
           write ops will be transparently discarded, and nothing recorded in the
           cache.
      
      There are some normal running states in which the object spends its time
      servicing netfs requests:
      
       (4) State FSCACHE_OBJECT_AVAILABLE.
      
           A transient state in which pending operations are started, child objects
           are permitted to advance from FSCACHE_OBJECT_INIT state, and temporary
           lookup data is freed.
      
       (5) State FSCACHE_OBJECT_ACTIVE.
      
           The normal running state.  In this state, requests the netfs makes will be
           passed on to the cache.
      
       (6) State FSCACHE_OBJECT_UPDATING.
      
           The state machine comes here to update the object in the cache from the
           netfs's records.  This involves updating the auxiliary data that is used
           to maintain coherency.
      
      And there are terminal states in which an object cleans itself up, deallocates
      memory and potentially deletes stuff from disk:
      
       (7) State FSCACHE_OBJECT_LC_DYING.
      
           The object comes here if it is dying because of a lookup or creation
           error.  This would be due to a disk error or system error of some sort.
           Temporary data is cleaned up, and the parent is released.
      
       (8) State FSCACHE_OBJECT_DYING.
      
           The object comes here if it is dying due to an error, because its parent
           cookie has been relinquished by the netfs or because the cache is being
           withdrawn.
      
           Any child objects waiting on this one are given CPU time so that they too
           can destroy themselves.  This object waits for all its children to go away
           before advancing to the next state.
      
       (9) State FSCACHE_OBJECT_ABORT_INIT.
      
           The object comes to this state if it was waiting on its parent in
           FSCACHE_OBJECT_INIT, but its parent died.  The object will destroy itself
           so that the parent may proceed from the FSCACHE_OBJECT_DYING state.
      
      (10) State FSCACHE_OBJECT_RELEASING.
      (11) State FSCACHE_OBJECT_RECYCLING.
      
           The object comes to one of these two states when dying once it is rid of
           all its children, if it is dying because the netfs relinquished its
           cookie.  In the first state, the cached data is expected to persist, and
           in the second it will be deleted.
      
      (12) State FSCACHE_OBJECT_WITHDRAWING.
      
           The object transits to this state if the cache decides it wants to
           withdraw the object from service, perhaps to make space, but also due to
           error or just because the whole cache is being withdrawn.
      
      (13) State FSCACHE_OBJECT_DEAD.
      
           The object transits to this state when the in-memory object record is
           ready to be deleted.  The object processor shouldn't ever see an object in
           this state.
      
      THE SET OF EVENTS
      -----------------
      
      There are a number of events that can be raised to an object state machine:
      
       (*) FSCACHE_OBJECT_EV_UPDATE
      
           The netfs requested that an object be updated.  The state machine will ask
           the cache backend to update the object, and the cache backend will ask the
           netfs for details of the change through its cookie definition ops.
      
       (*) FSCACHE_OBJECT_EV_CLEARED
      
           This is signalled in two circumstances:
      
           (a) when an object's last child object is dropped and
      
           (b) when the last operation outstanding on an object is completed.
      
           This is used to proceed from the dying state.
      
       (*) FSCACHE_OBJECT_EV_ERROR
      
           This is signalled when an I/O error occurs during the processing of some
           object.
      
       (*) FSCACHE_OBJECT_EV_RELEASE
       (*) FSCACHE_OBJECT_EV_RETIRE
      
           These are signalled when the netfs relinquishes a cookie it was using.
           The event selected depends on whether the netfs asks for the backing
           object to be retired (deleted) or retained.
      
       (*) FSCACHE_OBJECT_EV_WITHDRAW
      
           This is signalled when the cache backend wants to withdraw an object.
           This means that the object will have to be detached from the netfs's
           cookie.
      
      Because the withdrawing releasing/retiring events are all handled by the object
      state machine, it doesn't matter if there's a collision with both ends trying
      to sever the connection at the same time.  The state machine can just pick
      which one it wants to honour, and that effects the other.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      36c95590
    • David Howells's avatar
      FS-Cache: Bit waiting helpers · 2868cbea
      David Howells authored
      Add helpers for use with wait_on_bit().
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      2868cbea
    • David Howells's avatar
      FS-Cache: Add netfs registration · 726dd7ff
      David Howells authored
      Add functions to register and unregister a network filesystem or other client
      of the FS-Cache service.  This allocates and releases the cookie representing
      the top-level index for a netfs, and makes it available to the netfs.
      
      If the FS-Cache facility is disabled, then the calls are optimised away at
      compile time.
      
      Note that whilst this patch may appear to work with FS-Cache enabled and a
      netfs attempting to use it, it will leak the cookie it allocates for the netfs
      as fscache_relinquish_cookie() is implemented in a later patch.  This will
      cause the slab code to emit a warning when the module is removed.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      726dd7ff
    • David Howells's avatar
      FS-Cache: Provide a slab for cookie allocation · 955d0091
      David Howells authored
      Provide a slab from which can be allocated the FS-Cache cookies that will be
      presented to the netfs.
      
      Also provide a slab constructor and a function to recursively discard a cookie
      and its ancestor chain.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      955d0091
    • David Howells's avatar
      FS-Cache: Add cache management · 4c515dd4
      David Howells authored
      Implement the entry points by which a cache backend may initialise, add,
      declare an error upon and withdraw a cache.
      
      Further, an object is created in sysfs under which each cache added will get
      an object created:
      
      	/sys/fs/fscache/<cachetag>/
      
      All of this is described in Documentation/filesystems/caching/backend-api.txt
      added by a previous patch.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      4c515dd4
    • David Howells's avatar
      FS-Cache: Add cache tag handling · 0e04d4ce
      David Howells authored
      Implement two features of FS-Cache:
      
       (1) The ability to request and release cache tags - names by which a cache may
           be known to a netfs, and thus selected for use.
      
       (2) An internal function by which a cache is selected by consulting the netfs,
           if the netfs wishes to be consulted.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      0e04d4ce
    • David Howells's avatar
      FS-Cache: Root index definition · a6891645
      David Howells authored
      Add a description of the root index of the cache for later patches to make use
      of.
      
      The root index is owned by FS-Cache itself.  When a netfs requests caching
      facilities, FS-Cache will, if one doesn't already exist, create an entry in
      the root index with the key being the name of the netfs ("AFS" for example),
      and the auxiliary data holding the index structure version supplied by the
      netfs:
      
      				     FSDEF
      				       |
      				 +-----------+
      				 |           |
      				NFS         AFS
      			       [v=1]       [v=1]
      
      If an entry with the appropriate name does already exist, the version is
      compared.  If the version is different, the entire subtree from that entry
      will be discarded and a new entry created.
      
      The new entry will be an index, and a cookie referring to it will be passed to
      the netfs.  This is then the root handle by which the netfs accesses the
      cache.  It can create whatever objects it likes in that index, including
      further indices.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      a6891645
    • David Howells's avatar
      FS-Cache: Add use of /proc and presentation of statistics · 7394daa8
      David Howells authored
      Make FS-Cache create its /proc interface and present various statistical
      information through it.  Also provide the functions for updating this
      information.
      
      These features are enabled by:
      
      	CONFIG_FSCACHE_PROC
      	CONFIG_FSCACHE_STATS
      	CONFIG_FSCACHE_HISTOGRAM
      
      The /proc directory for FS-Cache is also exported so that caching modules can
      add their own statistics there too.
      
      The FS-Cache module is loadable at this point, and the statistics files can be
      examined by userspace:
      
      	cat /proc/fs/fscache/stats
      	cat /proc/fs/fscache/histogram
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      7394daa8
    • David Howells's avatar
      FS-Cache: Add main configuration option, module entry points and debugging · 06b3db1b
      David Howells authored
      Add the main configuration option, allowing FS-Cache to be selected; the
      module entry and exit functions and the debugging stuff used by these patches.
      
      The two configuration options added are:
      
      	CONFIG_FSCACHE
      	CONFIG_FSCACHE_DEBUG
      
      The first enables the facility, and the second makes the debugging statements
      enableable through the "debug" module parameter.  The value of this parameter
      is a bitmask as described in:
      
      	Documentation/filesystems/caching/fscache.txt
      
      The module can be loaded at this point, but all it will do at this point in
      the patch series is to start up the slow work facility and shut it down again.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      06b3db1b
    • David Howells's avatar
      FS-Cache: Add the FS-Cache cache backend API and documentation · 0dfc41d1
      David Howells authored
      Add the API for a generic facility (FS-Cache) by which caches may declare them
      selves open for business, and may obtain work to be done from network
      filesystems.  The header file is included by:
      
      	#include <linux/fscache-cache.h>
      
      Documentation for the API is also added to:
      
      	Documentation/filesystems/caching/backend-api.txt
      
      This API is not usable without the implementation of the utility functions
      which will be added in further patches.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      0dfc41d1
    • David Howells's avatar
      FS-Cache: Add the FS-Cache netfs API and documentation · 2d6fff63
      David Howells authored
      Add the API for a generic facility (FS-Cache) by which filesystems (such as AFS
      or NFS) may call on local caching capabilities without having to know anything
      about how the cache works, or even if there is a cache:
      
      	+---------+
      	|         |                        +--------------+
      	|   NFS   |--+                     |              |
      	|         |  |                 +-->|   CacheFS    |
      	+---------+  |   +----------+  |   |  /dev/hda5   |
      	             |   |          |  |   +--------------+
      	+---------+  +-->|          |  |
      	|         |      |          |--+
      	|   AFS   |----->| FS-Cache |
      	|         |      |          |--+
      	+---------+  +-->|          |  |
      	             |   |          |  |   +--------------+
      	+---------+  |   +----------+  |   |              |
      	|         |  |                 +-->|  CacheFiles  |
      	|  ISOFS  |--+                     |  /var/cache  |
      	|         |                        +--------------+
      	+---------+
      
      General documentation and documentation of the netfs specific API are provided
      in addition to the header files.
      
      As this patch stands, it is possible to build a filesystem against the facility
      and attempt to use it.  All that will happen is that all requests will be
      immediately denied as if no cache is present.
      
      Further patches will implement the core of the facility.  The facility will
      transfer requests from networking filesystems to appropriate caches if
      possible, or else gracefully deny them.
      
      If this facility is disabled in the kernel configuration, then all its
      operations will trivially reduce to nothing during compilation.
      
      WHY NOT I_MAPPING?
      ==================
      
      I have added my own API to implement caching rather than using i_mapping to do
      this for a number of reasons.  These have been discussed a lot on the LKML and
      CacheFS mailing lists, but to summarise the basics:
      
       (1) Most filesystems don't do hole reportage.  Holes in files are treated as
           blocks of zeros and can't be distinguished otherwise, making it difficult
           to distinguish blocks that have been read from the network and cached from
           those that haven't.
      
       (2) The backing inode must be fully populated before being exposed to
           userspace through the main inode because the VM/VFS goes directly to the
           backing inode and does not interrogate the front inode's VM ops.
      
           Therefore:
      
           (a) The backing inode must fit entirely within the cache.
      
           (b) All backed files currently open must fit entirely within the cache at
           	 the same time.
      
           (c) A working set of files in total larger than the cache may not be
           	 cached.
      
           (d) A file may not grow larger than the available space in the cache.
      
           (e) A file that's open and cached, and remotely grows larger than the
           	 cache is potentially stuffed.
      
       (3) Writes go to the backing filesystem, and can only be transferred to the
           network when the file is closed.
      
       (4) There's no record of what changes have been made, so the whole file must
           be written back.
      
       (5) The pages belong to the backing filesystem, and all metadata associated
           with that page are relevant only to the backing filesystem, and not
           anything stacked atop it.
      
      OVERVIEW
      ========
      
      FS-Cache provides (or will provide) the following facilities:
      
       (1) Caches can be added / removed at any time, even whilst in use.
      
       (2) Adds a facility by which tags can be used to refer to caches, even if
           they're not available yet.
      
       (3) More than one cache can be used at once.  Caches can be selected
           explicitly by use of tags.
      
       (4) The netfs is provided with an interface that allows either party to
           withdraw caching facilities from a file (required for (1)).
      
       (5) A netfs may annotate cache objects that belongs to it.  This permits the
           storage of coherency maintenance data.
      
       (6) Cache objects will be pinnable and space reservations will be possible.
      
       (7) The interface to the netfs returns as few errors as possible, preferring
           rather to let the netfs remain oblivious.
      
       (8) Cookies are used to represent indices, files and other objects to the
           netfs.  The simplest cookie is just a NULL pointer - indicating nothing
           cached there.
      
       (9) The netfs is allowed to propose - dynamically - any index hierarchy it
           desires, though it must be aware that the index search function is
           recursive, stack space is limited, and indices can only be children of
           indices.
      
      (10) Indices can be used to group files together to reduce key size and to make
           group invalidation easier.  The use of indices may make lookup quicker,
           but that's cache dependent.
      
      (11) Data I/O is effectively done directly to and from the netfs's pages.  The
           netfs indicates that page A is at index B of the data-file represented by
           cookie C, and that it should be read or written.  The cache backend may or
           may not start I/O on that page, but if it does, a netfs callback will be
           invoked to indicate completion.  The I/O may be either synchronous or
           asynchronous.
      
      (12) Cookies can be "retired" upon release.  At this point FS-Cache will mark
           them as obsolete and the index hierarchy rooted at that point will get
           recycled.
      
      (13) The netfs provides a "match" function for index searches.  In addition to
           saying whether a match was made or not, this can also specify that an
           entry should be updated or deleted.
      
      FS-Cache maintains a virtual index tree in which all indices, files, objects
      and pages are kept.  Bits of this tree may actually reside in one or more
      caches.
      
                                                 FSDEF
                                                   |
                              +------------------------------------+
                              |                                    |
                             NFS                                  AFS
                              |                                    |
                 +--------------------------+                +-----------+
                 |                          |                |           |
              homedir                     mirror          afs.org   redhat.com
                 |                          |                            |
           +------------+           +---------------+              +----------+
           |            |           |               |              |          |
         00001        00002       00007           00125        vol00001   vol00002
           |            |           |               |                         |
       +---+---+     +-----+      +---+      +------+------+            +-----+----+
       |   |   |     |     |      |   |      |      |      |            |     |    |
      PG0 PG1 PG2   PG0  XATTR   PG0 PG1   DIRENT DIRENT DIRENT        R/W   R/O  Bak
                           |                                            |
                          PG0                                       +-------+
                                                                    |       |
                                                                  00001   00003
                                                                    |
                                                                +---+---+
                                                                |   |   |
                                                               PG0 PG1 PG2
      
      In the example above, two netfs's can be seen to be backed: NFS and AFS.  These
      have different index hierarchies:
      
       (*) The NFS primary index will probably contain per-server indices.  Each
           server index is indexed by NFS file handles to get data file objects.
           Each data file objects can have an array of pages, but may also have
           further child objects, such as extended attributes and directory entries.
           Extended attribute objects themselves have page-array contents.
      
       (*) The AFS primary index contains per-cell indices.  Each cell index contains
           per-logical-volume indices.  Each of volume index contains up to three
           indices for the read-write, read-only and backup mirrors of those volumes.
           Each of these contains vnode data file objects, each of which contains an
           array of pages.
      
      The very top index is the FS-Cache master index in which individual netfs's
      have entries.
      
      Any index object may reside in more than one cache, provided it only has index
      children.  Any index with non-index object children will be assumed to only
      reside in one cache.
      
      The FS-Cache overview can be found in:
      
      	Documentation/filesystems/caching/fscache.txt
      
      The netfs API to FS-Cache can be found in:
      
      	Documentation/filesystems/caching/netfs-api.txt
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      2d6fff63
    • David Howells's avatar
      FS-Cache: Recruit a page flags for cache management · 266cf658
      David Howells authored
      Recruit a page flag to aid in cache management.  The following extra flag is
      defined:
      
       (1) PG_fscache (PG_private_2)
      
           The marked page is backed by a local cache and is pinning resources in the
           cache driver.
      
      If PG_fscache is set, then things that checked for PG_private will now also
      check for that.  This includes things like truncation and page invalidation.
      The function page_has_private() had been added to make the checks for both
      PG_private and PG_private_2 at the same time.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarRik van Riel <riel@redhat.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      266cf658
    • David Howells's avatar
      FS-Cache: Release page->private after failed readahead · 03fb3d2a
      David Howells authored
      The attached patch causes read_cache_pages() to release page-private data on a
      page for which add_to_page_cache() fails.  If the filler function fails, then
      the problematic page is left attached to the pagecache (with appropriate flags
      set, one presumes) and the remaining to-be-attached pages are invalidated and
      discarded.  This permits pages with caching references associated with them to
      be cleaned up.
      
      The invalidatepage() address space op is called (indirectly) to do the honours.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarRik van Riel <riel@redhat.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      03fb3d2a
    • David Howells's avatar
      Document the slow work thread pool · 8f0aa2f2
      David Howells authored
      Document the slow work thread pool.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      8f0aa2f2
    • David Howells's avatar
      Make the slow work pool configurable · 12e22c5e
      David Howells authored
      Make the slow work pool configurable through /proc/sys/kernel/slow-work.
      
       (*) /proc/sys/kernel/slow-work/min-threads
      
           The minimum number of threads that should be in the pool as long as it is
           in use.  This may be anywhere between 2 and max-threads.
      
       (*) /proc/sys/kernel/slow-work/max-threads
      
           The maximum number of threads that should in the pool.  This may be
           anywhere between min-threads and 255 or NR_CPUS * 2, whichever is greater.
      
       (*) /proc/sys/kernel/slow-work/vslow-percentage
      
           The percentage of active threads in the pool that may be used to execute
           very slow work items.  This may be between 1 and 99.  The resultant number
           is bounded to between 1 and one fewer than the number of active threads.
           This ensures there is always at least one thread that can process very
           slow work items, and always at least one thread that won't.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSerge Hallyn <serue@us.ibm.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      12e22c5e
    • David Howells's avatar
      Make slow-work thread pool actually dynamic · 109d9272
      David Howells authored
      Make the slow-work thread pool actually dynamic in the number of threads it
      contains.  With this patch, it will both create additional threads when it has
      extra work to do, and cull excess threads that aren't doing anything.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSerge Hallyn <serue@us.ibm.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      109d9272
    • David Howells's avatar
      Create a dynamically sized pool of threads for doing very slow work items · 07fe7cb7
      David Howells authored
      Create a dynamically sized pool of threads for doing very slow work items, such
      as invoking mkdir() or rmdir() - things that may take a long time and may
      sleep, holding mutexes/semaphores and hogging a thread, and are thus unsuitable
      for workqueues.
      
      The number of threads is always at least a settable minimum, but more are
      started when there's more work to do, up to a limit.  Because of the nature of
      the load, it's not suitable for a 1-thread-per-CPU type pool.  A system with
      one CPU may well want several threads.
      
      This is used by FS-Cache to do slow caching operations in the background, such
      as looking up, creating or deleting cache objects.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarSerge Hallyn <serue@us.ibm.com>
      Acked-by: default avatarSteve Dickson <steved@redhat.com>
      Acked-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarDaire Byrne <Daire.Byrne@framestore.com>
      07fe7cb7
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6 · 8fe74cf0
      Linus Torvalds authored
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
        Remove two unneeded exports and make two symbols static in fs/mpage.c
        Cleanup after commit 585d3bc0
        Trim includes of fdtable.h
        Don't crap into descriptor table in binfmt_som
        Trim includes in binfmt_elf
        Don't mess with descriptor table in load_elf_binary()
        Get rid of indirect include of fs_struct.h
        New helper - current_umask()
        check_unsafe_exec() doesn't care about signal handlers sharing
        New locking/refcounting for fs_struct
        Take fs_struct handling to new file (fs/fs_struct.c)
        Get rid of bumping fs_struct refcount in pivot_root(2)
        Kill unsharing fs_struct in __set_personality()
      8fe74cf0
    • Linus Torvalds's avatar
      Merge branch 'drm-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6 · c2eb2fa6
      Linus Torvalds authored
      * 'drm-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6: (21 commits)
        drm/radeon: load the right microcode on rs780
        drm: remove unused "can_grow" parameter from drm_crtc_helper_initial_config
        drm: fix EDID backward compat check
        drm: sync the mode validation for INTERLACE/DBLSCAN
        drm: fix typo in edid vendor parsing.
        DRM: drm_crtc_helper.h doesn't actually need i2c.h
        drm: fix missing inline function on 32-bit powerpc.
        drm: Use pgprot_writecombine in GEM GTT mapping to get the right bits for !PAT.
        drm/i915: Add a spinlock to protect the active_list
        drm/i915: Fix SDVO TV support
        drm/i915: Fix SDVO CREATE_PREFERRED_INPUT_TIMING command
        drm/i915: Fix error in SDVO DTD and modeline convert
        drm/i915: Fix SDVO command debug function
        drm/i915: fix TV mode setting in property change
        drm/i915: only set TV mode when any property changed
        drm/i915: clean up udelay usage
        drm/i915: add VGA hotplug support for 945+
        drm/i915: correctly set IGD device's gtt size for KMS.
        drm/i915: avoid hanging on to a stale pointer to raw_edid.
        drm/i915: check for -EINVAL from vm_insert_pfn
        ...
      c2eb2fa6
    • Linus Torvalds's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 · ef8a97bb
      Linus Torvalds authored
      * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (54 commits)
        glge: remove unused #include <version.h>
        dnet: remove unused #include <version.h>
        tcp: miscounts due to tcp_fragment pcount reset
        tcp: add helper for counter tweaking due mid-wq change
        hso: fix for the 'invalid frame length' messages
        hso: fix for crash when unplugging the device
        fsl_pq_mdio: Fix compile failure
        fsl_pq_mdio: Revive UCC MDIO support
        ucc_geth: Pass proper device to DMA routines, otherwise oops happens
        i.MX31: Fixing cs89x0 network building to i.MX31ADS
        tc35815: Fix build error if NAPI enabled
        hso: add Vendor/Product ID's for new devices
        ucc_geth: Remove unused header
        gianfar: Remove unused header
        kaweth: Fix locking to be SMP-safe
        net: allow multiple dev per napi with GRO
        r8169: reset IntrStatus after chip reset
        ixgbe: Fix potential memory leak/driver panic issue while setting up Tx & Rx ring parameters
        ixgbe: fix ethtool -A|a behavior
        ixgbe: Patch to fix driver panic while freeing up tx & rx resources
        ...
      ef8a97bb
    • Jack Steiner's avatar
      cpumask: fix slab corruption caused by alloc_cpumask_var_node() · 4f032ac4
      Jack Steiner authored
      Fix slab corruption caused by alloc_cpumask_var_node() overwriting the
      tail end of an off-stack cpumask.
      
      The function zeros out cpumask bits beyond the last possible cpu.  The
      starting point for zeroing should be the beginning of the mask offset by a
      byte count derived from the number of possible cpus.  The offset was
      calculated in bits instead of bytes.  This resulted in overwriting the end
      of the cpumask.
      Signed-off-by: default avatarJack Steiner <steiner@sgi.com>
      Acked-by: Mike Travis <travis.sgi.com>
      Acked-by: default avatarIngo Molnar <mingo@elte.hu>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: <stable@kernel.org>		[2.6.29.x]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4f032ac4
    • Robin Holt's avatar
      ia64: implement interrupt-enabling rwlocks · 2d09cde9
      Robin Holt authored
      Implement __raw_read_lock_flags and __raw_write_lock_flags for the ia64
      architecture.
      
      [kosaki.motohiro@jp.fujitsu.com: typo fix]
      Signed-off-by: default avatarPetr Tesarik <ptesarik@suse.cz>
      Signed-off-by: default avatarRobin Holt <holt@sgi.com>
      Cc: <linux-arch@vger.kernel.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Acked-by: default avatarTony Luck <tony.luck@intel.com>
      Signed-off-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2d09cde9
    • Robin Holt's avatar
      Allow rwlocks to re-enable interrupts · f5f7eac4
      Robin Holt authored
      Pass the original flags to rwlock arch-code, so that it can re-enable
      interrupts if implemented for that architecture.
      
      Initially, make __raw_read_lock_flags and __raw_write_lock_flags stubs
      which just do the same thing as non-flags variants.
      Signed-off-by: default avatarPetr Tesarik <ptesarik@suse.cz>
      Signed-off-by: default avatarRobin Holt <holt@sgi.com>
      Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: <linux-arch@vger.kernel.org>
      Acked-by: default avatarIngo Molnar <mingo@elte.hu>
      Cc: "Luck, Tony" <tony.luck@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f5f7eac4
    • Robin Holt's avatar
      Factor out #ifdefs from kernel/spinlock.c to LOCK_CONTENDED_FLAGS · e8c158bb
      Robin Holt authored
      SGI has observed that on large systems, interrupts are not serviced for a
      long period of time when waiting for a rwlock.  The following patch series
      re-enables irqs while waiting for the lock, resembling the code which is
      already there for spinlocks.
      
      I only made the ia64 version, because the patch adds some overhead to the
      fast path.  I assume there is currently no demand to have this for other
      architectures, because the systems are not so large.  Of course, the
      possibility to implement raw_{read|write}_lock_flags for any architecture
      is still there.
      
      This patch:
      
      The new macro LOCK_CONTENDED_FLAGS expands to the correct implementation
      depending on the config options, so that IRQ's are re-enabled when
      possible, but they remain disabled if CONFIG_LOCKDEP is set.
      Signed-off-by: default avatarPetr Tesarik <ptesarik@suse.cz>
      Signed-off-by: default avatarRobin Holt <holt@sgi.com>
      Cc: <linux-arch@vger.kernel.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: "Luck, Tony" <tony.luck@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e8c158bb
    • Coly Li's avatar
      fs/ufs: return f_fsid for statfs(2) · 41d577aa
      Coly Li authored
      Make ufs return f_fsid info for statfs(2).
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Cc: Evgeniy Dushistov <dushistov@mail.ru>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      41d577aa
    • Coly Li's avatar
      fs/sysv: return f_fsid for statfs(2) · 1c5b4541
      Coly Li authored
      Make sysv file system return f_fsid info for statfs(2).
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Cc: Christoph Hellwig <hch@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1c5b4541
    • Coly Li's avatar
      fs/squashfs: return f_fsid for statfs(2) · 2fc7f562
      Coly Li authored
      Make squashfs return f_fsid info for statfs(2).
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Cc: Phillip Lougher <phillip@lougher.demon.co.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2fc7f562
    • Coly Li's avatar
      fs/reiserfs: return f_fsid for statfs(2) · 651d0623
      Coly Li authored
      Make reiserfs3 return f_fsid info for statfs(2).  By Andreas' suggestion,
      this patch populates a persistent f_fsid between boots/mounts with help of
      on-disk uuid record.
      
      Randy Dunlap reported a compiling error from v2 patch like:
          fs/built-in.o: In function `reiserfs_statfs':
          super.c:(.text+0x7332b): undefined reference to `crc32_le'
          super.c:(.text+0x7333f): undefined reference to `crc32_le'
      Also he provided helpful solution to fix this error. The modification of v3
      patch is based on Randy's suggestion, add 'select CRC32' in fs/reiserfs/Kconfig.
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Cc: Randy Dunlap <randy.dunlap@oracle.com>
      Cc: Jeff Mahoney <jeffm@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      651d0623
    • Coly Li's avatar
      fs/qnx4: return f_fsid for statfs(2) · 5b76dc06
      Coly Li authored
      Make qnx4 file system return f_fsid info for statfs(2).
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Acked-by: default avatarAnders Larsen <al@alarsen.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5b76dc06
    • Coly Li's avatar
      fs/omfs: return f_fsid for statfs(2) · 197e671e
      Coly Li authored
      Make omfs return f_fsid info for statfs(2).
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Acked-by: default avatarBob Copeland <me@bobcopeland.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      197e671e
    • Coly Li's avatar
      fs/minix: return f_fsid for statfs(2) · 054475d2
      Coly Li authored
      Make minix file system return f_fsid info for statfs(2).
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      054475d2
    • Coly Li's avatar
      fs/isofs: return f_fsid for statfs(2) · 2430c4da
      Coly Li authored
      Make isofs return f_fsid info for statfs(2).
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Cc: Jan Kara <jack@ucw.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2430c4da
    • Coly Li's avatar
      fs/hpfs: return f_fsid for statfs(2) · 604d295c
      Coly Li authored
      Make hpfs return f_fsid info for statfs(2).
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      604d295c
    • Coly Li's avatar
      fs/hfsplus: return f_fsid for statfs(2) · 25564dd8
      Coly Li authored
      Make hfsplus return f_fsid info for statfs(2).
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Cc: Roman Zippel <zippel@linux-m68k.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      25564dd8
    • Coly Li's avatar
      fs/hfs: return f_fsid for statfs(2) · 7dd2c000
      Coly Li authored
      Make hfs return f_fsid info for statfs(2).
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Cc: Roman Zippel <zippel@linux-m68k.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7dd2c000
    • Coly Li's avatar
      fs/fat: return f_fsid for statfs(2) · aac49b75
      Coly Li authored
      Make fat return f_fsid info for statfs(2).
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Acked-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      aac49b75
    • Coly Li's avatar
      fs/efs: return f_fsid for statfs(2) · 514c91a9
      Coly Li authored
      Make efs return f_fsid info for statfs(2), and do a little variable
      renaming in efs_statfs().
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      514c91a9
    • Coly Li's avatar
      fs/cramfs: return f_fsid for statfs(2) · 94ea77ac
      Coly Li authored
      Make cramfs return f_fsid info for statfs(2).
      Signed-off-by: default avatarColy Li <coly.li@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      94ea77ac