1. 03 4月, 2009 40 次提交
    • D
      FS-Cache: Implement the cookie management part of the netfs API · ccc4fc3d
      David Howells 提交于
      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: NDavid Howells <dhowells@redhat.com>
      Acked-by: NSteve Dickson <steved@redhat.com>
      Acked-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: NDaire Byrne <Daire.Byrne@framestore.com>
      ccc4fc3d
    • D
      FS-Cache: Object management state machine · 36c95590
      David Howells 提交于
      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: NDavid Howells <dhowells@redhat.com>
      Acked-by: NSteve Dickson <steved@redhat.com>
      Acked-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: NDaire Byrne <Daire.Byrne@framestore.com>
      36c95590
    • D
      FS-Cache: Bit waiting helpers · 2868cbea
      David Howells 提交于
      Add helpers for use with wait_on_bit().
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NSteve Dickson <steved@redhat.com>
      Acked-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: NDaire Byrne <Daire.Byrne@framestore.com>
      2868cbea
    • D
      FS-Cache: Add netfs registration · 726dd7ff
      David Howells 提交于
      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: NDavid Howells <dhowells@redhat.com>
      Acked-by: NSteve Dickson <steved@redhat.com>
      Acked-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: NDaire Byrne <Daire.Byrne@framestore.com>
      726dd7ff
    • D
      FS-Cache: Provide a slab for cookie allocation · 955d0091
      David Howells 提交于
      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: NDavid Howells <dhowells@redhat.com>
      Acked-by: NSteve Dickson <steved@redhat.com>
      Acked-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: NDaire Byrne <Daire.Byrne@framestore.com>
      955d0091
    • D
      FS-Cache: Add cache management · 4c515dd4
      David Howells 提交于
      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: NDavid Howells <dhowells@redhat.com>
      Acked-by: NSteve Dickson <steved@redhat.com>
      Acked-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: NDaire Byrne <Daire.Byrne@framestore.com>
      4c515dd4
    • D
      FS-Cache: Add cache tag handling · 0e04d4ce
      David Howells 提交于
      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: NDavid Howells <dhowells@redhat.com>
      Acked-by: NSteve Dickson <steved@redhat.com>
      Acked-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: NDaire Byrne <Daire.Byrne@framestore.com>
      0e04d4ce
    • D
      FS-Cache: Root index definition · a6891645
      David Howells 提交于
      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: NDavid Howells <dhowells@redhat.com>
      Acked-by: NSteve Dickson <steved@redhat.com>
      Acked-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: NDaire Byrne <Daire.Byrne@framestore.com>
      a6891645
    • D
      FS-Cache: Add use of /proc and presentation of statistics · 7394daa8
      David Howells 提交于
      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: NDavid Howells <dhowells@redhat.com>
      Acked-by: NSteve Dickson <steved@redhat.com>
      Acked-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: NDaire Byrne <Daire.Byrne@framestore.com>
      7394daa8
    • D
      FS-Cache: Add main configuration option, module entry points and debugging · 06b3db1b
      David Howells 提交于
      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: NDavid Howells <dhowells@redhat.com>
      Acked-by: NSteve Dickson <steved@redhat.com>
      Acked-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: NDaire Byrne <Daire.Byrne@framestore.com>
      06b3db1b
    • D
      FS-Cache: Recruit a page flags for cache management · 266cf658
      David Howells 提交于
      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: NDavid Howells <dhowells@redhat.com>
      Acked-by: NSteve Dickson <steved@redhat.com>
      Acked-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: NRik van Riel <riel@redhat.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: NDaire Byrne <Daire.Byrne@framestore.com>
      266cf658
    • C
      fs/ufs: return f_fsid for statfs(2) · 41d577aa
      Coly Li 提交于
      Make ufs return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Cc: Evgeniy Dushistov <dushistov@mail.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      41d577aa
    • C
      fs/sysv: return f_fsid for statfs(2) · 1c5b4541
      Coly Li 提交于
      Make sysv file system return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Cc: Christoph Hellwig <hch@infradead.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1c5b4541
    • C
      fs/squashfs: return f_fsid for statfs(2) · 2fc7f562
      Coly Li 提交于
      Make squashfs return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Cc: Phillip Lougher <phillip@lougher.demon.co.uk>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2fc7f562
    • C
      fs/reiserfs: return f_fsid for statfs(2) · 651d0623
      Coly Li 提交于
      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: NColy Li <coly.li@suse.de>
      Cc: Randy Dunlap <randy.dunlap@oracle.com>
      Cc: Jeff Mahoney <jeffm@suse.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      651d0623
    • C
      fs/qnx4: return f_fsid for statfs(2) · 5b76dc06
      Coly Li 提交于
      Make qnx4 file system return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Acked-by: NAnders Larsen <al@alarsen.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5b76dc06
    • C
      fs/omfs: return f_fsid for statfs(2) · 197e671e
      Coly Li 提交于
      Make omfs return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Acked-by: NBob Copeland <me@bobcopeland.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      197e671e
    • C
      fs/minix: return f_fsid for statfs(2) · 054475d2
      Coly Li 提交于
      Make minix file system return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      054475d2
    • C
      fs/isofs: return f_fsid for statfs(2) · 2430c4da
      Coly Li 提交于
      Make isofs return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Cc: Jan Kara <jack@ucw.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2430c4da
    • C
      fs/hpfs: return f_fsid for statfs(2) · 604d295c
      Coly Li 提交于
      Make hpfs return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      604d295c
    • C
      fs/hfsplus: return f_fsid for statfs(2) · 25564dd8
      Coly Li 提交于
      Make hfsplus return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Cc: Roman Zippel <zippel@linux-m68k.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      25564dd8
    • C
      fs/hfs: return f_fsid for statfs(2) · 7dd2c000
      Coly Li 提交于
      Make hfs return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Cc: Roman Zippel <zippel@linux-m68k.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7dd2c000
    • C
      fs/fat: return f_fsid for statfs(2) · aac49b75
      Coly Li 提交于
      Make fat return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Acked-by: NOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      aac49b75
    • C
      fs/efs: return f_fsid for statfs(2) · 514c91a9
      Coly Li 提交于
      Make efs return f_fsid info for statfs(2), and do a little variable
      renaming in efs_statfs().
      Signed-off-by: NColy Li <coly.li@suse.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      514c91a9
    • C
      fs/cramfs: return f_fsid for statfs(2) · 94ea77ac
      Coly Li 提交于
      Make cramfs return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      94ea77ac
    • C
      fs/befs: return f_fsid for statfs(2) · 8587246a
      Coly Li 提交于
      Make befs return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Cc: Sergey S. Kostyliov <rathamahata@php4.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8587246a
    • C
      fs/affs: return f_fsid for statfs(2) · a6a2a73c
      Coly Li 提交于
      Make affs return f_fsid info for statfs(2).
      Signed-off-by: NColy Li <coly.li@suse.de>
      Cc: Roman Zippel <zippel@linux-m68k.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a6a2a73c
    • C
      fs/adfs: return f_fsid for statfs(2) · accb4012
      Coly Li 提交于
      Currently many file systems in Linux kernel do not return f_fsid in statfs
      info, the value is set as 0 in vfs layer.  Anyway, in some conditions,
      f_fsid from statfs(2) is useful, especially being used as (f_fsid, ino)
      pair to uniquely identify a file.
      
      Basic idea of the patches is generating a unique fs ID by
      huge_encode_dev(sb->s_bdev->bd_dev) during file system mounting life time
      (no endian consistent issue).  sb is a point of struct super_block of
      current mounted file system being accessed by statfs(2).
      
      This patch:
      
      Make adfs return f_fsid info for statfs(2), and do a little variable
      renaming in adfs_statfs().
      Signed-off-by: NColy Li <coly.li@suse.de>
      Cc: Roman Zippel <zippel@linux-m68k.org>
      Cc: "Sergey S. Kostyliov" <rathamahata@php4.ru>
      Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
      Cc: Dave Kleikamp <shaggy@austin.ibm.com>
      Cc: Bob Copeland <me@bobcopeland.com>
      Cc: Anders Larsen <al@alarsen.net>
      Cc: Phillip Lougher <phillip@lougher.demon.co.uk>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Evgeniy Dushistov <dushistov@mail.ru>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Andreas Dilger <adilger@sun.com>
      Cc: Jamie Lokier <jamie@shareable.org>
      Cc: Theodore Ts'o <tytso@mit.edu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      accb4012
    • G
      preadv/pwritev: switch compat readv/preadv/writev/pwritev from fget to fget_light · 10c7db27
      Gerd Hoffmann 提交于
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: <linux-api@vger.kernel.org>
      Cc: <linux-arch@vger.kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      10c7db27
    • G
      preadv/pwritev: Add preadv and pwritev system calls. · f3554f4b
      Gerd Hoffmann 提交于
      This patch adds preadv and pwritev system calls.  These syscalls are a
      pretty straightforward combination of pread and readv (same for write).
      They are quite useful for doing vectored I/O in threaded applications.
      Using lseek+readv instead opens race windows you'll have to plug with
      locking.
      
      Other systems have such system calls too, for example NetBSD, check
      here: http://www.daemon-systems.org/man/preadv.2.html
      
      The application-visible interface provided by glibc should look like
      this to be compatible to the existing implementations in the *BSD family:
      
        ssize_t preadv(int d, const struct iovec *iov, int iovcnt, off_t offset);
        ssize_t pwritev(int d, const struct iovec *iov, int iovcnt, off_t offset);
      
      This prototype has one problem though: On 32bit archs is the (64bit)
      offset argument unaligned, which the syscall ABI of several archs doesn't
      allow to do.  At least s390 needs a wrapper in glibc to handle this.  As
      we'll need a wrappers in glibc anyway I've decided to push problem to
      glibc entriely and use a syscall prototype which works without
      arch-specific wrappers inside the kernel: The offset argument is
      explicitly splitted into two 32bit values.
      
      The patch sports the actual system call implementation and the windup in
      the x86 system call tables.  Other archs follow as separate patches.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: <linux-api@vger.kernel.org>
      Cc: <linux-arch@vger.kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f3554f4b
    • G
      preadv/pwritev: create compat_writev() · 6949a631
      Gerd Hoffmann 提交于
      Factor out some code from compat_sys_writev() which can be shared with the
      upcoming compat_sys_pwritev().
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: <linux-api@vger.kernel.org>
      Cc: <linux-arch@vger.kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6949a631
    • G
      preadv/pwritev: create compat_readv() · dac12138
      Gerd Hoffmann 提交于
      This patch series:
      
      Implement the preadv() and pwritev() syscalls.  *BSD has this syscall for
      quite some time.
      
      Test code:
      
      #if 0
      set -x
      gcc -Wall -O2 -o preadv $0
      exit 0
      #endif
      /*
       * preadv demo / test
       *
       * (c) 2008 Gerd Hoffmann <kraxel@redhat.com>
       *
       * build with "sh $thisfile"
       */
      
      #include <stdio.h>
      #include <stdlib.h>
      #include <unistd.h>
      #include <errno.h>
      #include <inttypes.h>
      #include <sys/uio.h>
      
      /* ----------------------------------------------------------------- */
      /* syscall windup                                                    */
      
      #include <sys/syscall.h>
      #if 0
      /* WARNING: Be sure you know what you are doing if you enable this.
       * linux syscall code isn't upstream yet, syscall numbers are subject
       * to change */
      # ifndef __NR_preadv
      #  ifdef __i386__
      #   define __NR_preadv  333
      #   define __NR_pwritev 334
      #  endif
      #  ifdef __x86_64__
      #   define __NR_preadv  295
      #   define __NR_pwritev 296
      #  endif
      # endif
      #endif
      #ifndef __NR_preadv
      # error preadv/pwritev syscall numbers are unknown
      #endif
      
      static ssize_t preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
      {
          uint32_t pos_high = (offset >> 32) & 0xffffffff;
          uint32_t pos_low  =  offset        & 0xffffffff;
      
          return syscall(__NR_preadv, fd, iov, iovcnt, pos_high, pos_low);
      }
      
      static ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
      {
          uint32_t pos_high = (offset >> 32) & 0xffffffff;
          uint32_t pos_low  =  offset        & 0xffffffff;
      
          return syscall(__NR_pwritev, fd, iov, iovcnt, pos_high, pos_low);
      }
      
      /* ----------------------------------------------------------------- */
      /* demo/test app                                                     */
      
      static char filename[] = "/tmp/preadv-XXXXXX";
      static char outbuf[11] = "0123456789";
      static char inbuf[11]  = "----------";
      
      static struct iovec ovec[2] = {{
              .iov_base = outbuf + 5,
              .iov_len  = 5,
          },{
              .iov_base = outbuf + 0,
              .iov_len  = 5,
          }};
      
      static struct iovec ivec[3] = {{
              .iov_base = inbuf + 6,
              .iov_len  = 2,
          },{
              .iov_base = inbuf + 4,
              .iov_len  = 2,
          },{
              .iov_base = inbuf + 2,
              .iov_len  = 2,
          }};
      
      void cleanup(void)
      {
          unlink(filename);
      }
      
      int main(int argc, char **argv)
      {
          int fd, rc;
      
          fd = mkstemp(filename);
          if (-1 == fd) {
              perror("mkstemp");
              exit(1);
          }
          atexit(cleanup);
      
          /* write to file: "56789-01234" */
          rc = pwritev(fd, ovec, 2, 0);
          if (rc < 0) {
              perror("pwritev");
              exit(1);
          }
      
          /* read from file: "78-90-12" */
          rc = preadv(fd, ivec, 3, 2);
          if (rc < 0) {
              perror("preadv");
              exit(1);
          }
      
          printf("result  : %s\n", inbuf);
          printf("expected: %s\n", "--129078--");
          exit(0);
      }
      
      This patch:
      
      Factor out some code from compat_sys_readv() which can be shared with the
      upcoming compat_sys_preadv().
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: <linux-api@vger.kernel.org>
      Cc: <linux-arch@vger.kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      dac12138
    • D
      cramfs: propagate uncompression errors · 98310e58
      David VomLehn 提交于
      Decompression errors can arise due to corruption of compressed blocks on
      flash or in memory.  This patch propagates errors detected during
      decompression back to the block layer.
      Signed-off-by: NDavid VomLehn <dvomlehn@cisco.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      98310e58
    • M
      bin_elf_fdpic: check the return value of clear_user · ab4ad555
      Mike Frysinger 提交于
      Signed-off-by: NMike Frysinger <vapier.adi@gmail.com>
      Signed-off-by: NBryan Wu <cooloney@kernel.org>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Greg Ungerer <gerg@snapgear.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ab4ad555
    • R
      hppfs: hppfs_read_file() may return -ERROR · 880fe76e
      Roel Kluin 提交于
      hppfs_read_file() may return (ssize_t) -ENOMEM, or -EFAULT.  When stored
      in size_t 'count', these errors will not be noticed, a large value will be
      added to *ppos.
      Signed-off-by: NRoel Kluin <roel.kluin@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      880fe76e
    • J
      ext3: avoid false EIO errors · 695f6ae0
      Jan Kara 提交于
      Sometimes block_write_begin() can map buffers in a page but later we
      fail to copy data into those buffers (because the source page has been
      paged out in the mean time).  We then end up with !uptodate mapped
      buffers.  To add a bit more to the confusion, block_write_end() does
      not commit any data (and thus does not any mark buffers as uptodate) if
      we didn't succeed with copying all the data.
      
      Commit f4fc66a8 (ext3: convert to new
      aops) missed these cases and thus we were inserting non-uptodate
      buffers to transaction's list which confuses JBD code and it reports IO
      errors, aborts a transaction and generally makes users afraid about
      their data ;-P.
      
      This patch fixes the problem by reorganizing ext3_..._write_end() code
      to first call block_write_end() to mark buffers with valid data
      uptodate and after that we file only uptodate buffers to transaction's
      lists.
      
      We also fix a problem where we could leave blocks allocated beyond i_size
      (i_disksize in fact) because of failed write. We now add inode to orphan
      list when write fails (to be safe in case we crash) and then truncate blocks
      beyond i_size in a separate transaction.
      Signed-off-by: NJan Kara <jack@suse.cz>
      Reviewed-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Cc: Nick Piggin <nickpiggin@yahoo.com.au>
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      695f6ae0
    • B
      ext3: return -EIO not -ESTALE on directory traversal through deleted inode · de18f3b2
      Bryan Donlan 提交于
      ext3_iget() returns -ESTALE if invoked on a deleted inode, in order to
      report errors to NFS properly.  However, in ext[234]_lookup(), this
      -ESTALE can be propagated to userspace if the filesystem is corrupted such
      that a directory entry references a deleted inode.  This leads to a
      misleading error message - "Stale NFS file handle" - and confusion on the
      part of the admin.
      
      The bug can be easily reproduced by creating a new filesystem, making a
      link to an unused inode using debugfs, then mounting and attempting to ls
      -l said link.
      
      This patch thus changes ext3_lookup to return -EIO if it receives -ESTALE
      from ext3_iget(), as ext3 does for other filesystem metadata corruption;
      and also invokes the appropriate ext*_error functions when this case is
      detected.
      Signed-off-by: NBryan Donlan <bdonlan@gmail.com>
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      de18f3b2
    • W
      ext3: use unsigned instead of int for type of blocksize in fs/ext3/namei.c · 45f90217
      Wei Yongjun 提交于
      Use unsigned instead of int for the parameter which carries a blocksize.
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: NWei Yongjun <yjwei@cn.fujitsu.com>
      Cc: Theodore Ts'o <tytso@mit.edu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      45f90217
    • J
      jbd: fix oops in jbd_journal_init_inode() on corrupted fs · ecca9af0
      Jan Kara 提交于
      On 32-bit system with CONFIG_LBD getblk can fail because provided block
      number is too big. Make JBD gracefully handle that.
      Signed-off-by: NJan Kara <jack@suse.cz>
      Cc: <dmaciejak@fortinet.com>
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ecca9af0
    • C
      ext3: remove the BKL in ext3/ioctl.c · 039fd8ce
      Cyrus Massoumi 提交于
      Reformat ext3/ioctl.c to make it look more like ext4/ioctl.c and remove
      the BKL around ext3_ioctl().
      Signed-off-by: NCyrus Massoumi <cyrusm@gmx.net>
      Cc: <linux-ext4@vger.kernel.org>
      Acked-by: NJan Kara <jack@ucw.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      039fd8ce
反馈
建议
客服 返回
顶部