)]}'
{
  "log": [
    {
      "commit": "36c9559022850f919269564a74bf17fdabf4bb30",
      "tree": "f163afcf8f8a9eb1a5d63fd6198fcb3e29564493",
      "parents": [
        "2868cbea72dc89ae0eb17693596b1dedaafff1c5"
      ],
      "author": {
        "name": "David Howells",
        "email": "dhowells@redhat.com",
        "time": "Fri Apr 03 16:42:38 2009 +0100"
      },
      "committer": {
        "name": "David Howells",
        "email": "dhowells@redhat.com",
        "time": "Fri Apr 03 16:42:38 2009 +0100"
      },
      "message": "FS-Cache: Object management state machine\n\nImplement the cache object management state machine.\n\nThe following documentation is added to illuminate the working of this state\nmachine.  It will also be added as:\n\n\tDocumentation/filesystems/caching/object.txt\n\n\t     \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\t     IN-KERNEL CACHE OBJECT REPRESENTATION AND MANAGEMENT\n\t     \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\nREPRESENTATION\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\nFS-Cache maintains an in-kernel representation of each object that a netfs is\ncurrently interested in.  Such objects are represented by the fscache_cookie\nstruct and are referred to as cookies.\n\nFS-Cache also maintains a separate in-kernel representation of the objects that\na cache backend is currently actively caching.  Such objects are represented by\nthe fscache_object struct.  The cache backends allocate these upon request, and\nare expected to embed them in their own representations.  These are referred to\nas objects.\n\nThere is a 1:N relationship between cookies and objects.  A cookie may be\nrepresented by multiple objects - an index may exist in more than one cache -\nor even by no objects (it may not be cached).\n\nFurthermore, both cookies and objects are hierarchical.  The two hierarchies\ncorrespond, but the cookies tree is a superset of the union of the object trees\nof multiple caches:\n\n\t    NETFS INDEX TREE               :      CACHE 1     :      CACHE 2\n\t                                   :                  :\n\t                                   :   +-----------+  :\n\t                          +-----------\u003e|  IObject  |  :\n\t      +-----------+       |        :   +-----------+  :\n\t      |  ICookie  |-------+        :         |        :\n\t      +-----------+       |        :         |        :   +-----------+\n\t            |             +------------------------------\u003e|  IObject  |\n\t            |                      :         |        :   +-----------+\n\t            |                      :         V        :         |\n\t            |                      :   +-----------+  :         |\n\t            V             +-----------\u003e|  IObject  |  :         |\n\t      +-----------+       |        :   +-----------+  :         |\n\t      |  ICookie  |-------+        :         |        :         V\n\t      +-----------+       |        :         |        :   +-----------+\n\t            |             +------------------------------\u003e|  IObject  |\n\t      +-----+-----+                :         |        :   +-----------+\n\t      |           |                :         |        :         |\n\t      V           |                :         V        :         |\n\t+-----------+     |                :   +-----------+  :         |\n\t|  ICookie  |-------------------------\u003e|  IObject  |  :         |\n\t+-----------+     |                :   +-----------+  :         |\n\t      |           V                :         |        :         V\n\t      |     +-----------+          :         |        :   +-----------+\n\t      |     |  ICookie  |--------------------------------\u003e|  IObject  |\n\t      |     +-----------+          :         |        :   +-----------+\n\t      V           |                :         V        :         |\n\t+-----------+     |                :   +-----------+  :         |\n\t|  DCookie  |-------------------------\u003e|  DObject  |  :         |\n\t+-----------+     |                :   +-----------+  :         |\n\t                  |                :                  :         |\n\t          +-------+-------+        :                  :         |\n\t          |               |        :                  :         |\n\t          V               V        :                  :         V\n\t    +-----------+   +-----------+  :                  :   +-----------+\n\t    |  DCookie  |   |  DCookie  |------------------------\u003e|  DObject  |\n\t    +-----------+   +-----------+  :                  :   +-----------+\n\t                                   :                  :\n\nIn the above illustration, ICookie and IObject represent indices and DCookie\nand DObject represent data storage objects.  Indices may have representation in\nmultiple caches, but currently, non-index objects may not.  Objects of any type\nmay also be entirely unrepresented.\n\nAs far as the netfs API goes, the netfs is only actually permitted to see\npointers to the cookies.  The cookies themselves and any objects attached to\nthose cookies are hidden from it.\n\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\nOBJECT MANAGEMENT STATE MACHINE\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\nWithin FS-Cache, each active object is managed by its own individual state\nmachine.  The state for an object is kept in the fscache_object struct, in\nobject-\u003estate.  A cookie may point to a set of objects that are in different\nstates.\n\nEach state has an action associated with it that is invoked when the machine\nwakes up in that state.  There are four logical sets of states:\n\n (1) Preparation: states that wait for the parent objects to become ready.  The\n     representations are hierarchical, and it is expected that an object must\n     be created or accessed with respect to its parent object.\n\n (2) Initialisation: states that perform lookups in the cache and validate\n     what\u0027s found and that create on disk any missing metadata.\n\n (3) Normal running: states that allow netfs operations on objects to proceed\n     and that update the state of objects.\n\n (4) Termination: states that detach objects from their netfs cookies, that\n     delete objects from disk, that handle disk and system errors and that free\n     up in-memory resources.\n\nIn most cases, transitioning between states is in response to signalled events.\nWhen a state has finished processing, it will usually set the mask of events in\nwhich it is interested (object-\u003eevent_mask) and relinquish the worker thread.\nThen when an event is raised (by calling fscache_raise_event()), if the event\nis not masked, the object will be queued for processing (by calling\nfscache_enqueue_object()).\n\nPROVISION OF CPU TIME\n---------------------\n\nThe work to be done by the various states is given CPU time by the threads of\nthe slow work facility (see Documentation/slow-work.txt).  This is used in\npreference to the workqueue facility because:\n\n (1) Threads may be completely occupied for very long periods of time by a\n     particular work item.  These state actions may be doing sequences of\n     synchronous, journalled disk accesses (lookup, mkdir, create, setxattr,\n     getxattr, truncate, unlink, rmdir, rename).\n\n (2) Threads may do little actual work, but may rather spend a lot of time\n     sleeping on I/O.  This means that single-threaded and 1-per-CPU-threaded\n     workqueues don\u0027t necessarily have the right numbers of threads.\n\nLOCKING SIMPLIFICATION\n----------------------\n\nBecause only one worker thread may be operating on any particular object\u0027s\nstate machine at once, this simplifies the locking, particularly with respect\nto disconnecting the netfs\u0027s representation of a cache object (fscache_cookie)\nfrom the cache backend\u0027s representation (fscache_object) - which may be\nrequested from either end.\n\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\nTHE SET OF STATES\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\nThe object state machine has a set of states that it can be in.  There are\npreparation states in which the object sets itself up and waits for its parent\nobject to transit to a state that allows access to its children:\n\n (1) State FSCACHE_OBJECT_INIT.\n\n     Initialise the object and wait for the parent object to become active.  In\n     the cache, it is expected that it will not be possible to look an object\n     up from the parent object, until that parent object itself has been looked\n     up.\n\nThere are initialisation states in which the object sets itself up and accesses\ndisk for the object metadata:\n\n (2) State FSCACHE_OBJECT_LOOKING_UP.\n\n     Look up the object on disk, using the parent as a starting point.\n     FS-Cache expects the cache backend to probe the cache to see whether this\n     object is represented there, and if it is, to see if it\u0027s valid (coherency\n     management).\n\n     The cache should call fscache_object_lookup_negative() to indicate lookup\n     failure for whatever reason, and should call fscache_obtained_object() to\n     indicate success.\n\n     At the completion of lookup, FS-Cache will let the netfs go ahead with\n     read operations, no matter whether the file is yet cached.  If not yet\n     cached, read operations will be immediately rejected with ENODATA until\n     the first known page is uncached - as to that point there can be no data\n     to be read out of the cache for that file that isn\u0027t currently also held\n     in the pagecache.\n\n (3) State FSCACHE_OBJECT_CREATING.\n\n     Create an object on disk, using the parent as a starting point.  This\n     happens if the lookup failed to find the object, or if the object\u0027s\n     coherency data indicated what\u0027s on disk is out of date.  In this state,\n     FS-Cache expects the cache to create\n\n     The cache should call fscache_obtained_object() if creation completes\n     successfully, fscache_object_lookup_negative() otherwise.\n\n     At the completion of creation, FS-Cache will start processing write\n     operations the netfs has queued for an object.  If creation failed, the\n     write ops will be transparently discarded, and nothing recorded in the\n     cache.\n\nThere are some normal running states in which the object spends its time\nservicing netfs requests:\n\n (4) State FSCACHE_OBJECT_AVAILABLE.\n\n     A transient state in which pending operations are started, child objects\n     are permitted to advance from FSCACHE_OBJECT_INIT state, and temporary\n     lookup data is freed.\n\n (5) State FSCACHE_OBJECT_ACTIVE.\n\n     The normal running state.  In this state, requests the netfs makes will be\n     passed on to the cache.\n\n (6) State FSCACHE_OBJECT_UPDATING.\n\n     The state machine comes here to update the object in the cache from the\n     netfs\u0027s records.  This involves updating the auxiliary data that is used\n     to maintain coherency.\n\nAnd there are terminal states in which an object cleans itself up, deallocates\nmemory and potentially deletes stuff from disk:\n\n (7) State FSCACHE_OBJECT_LC_DYING.\n\n     The object comes here if it is dying because of a lookup or creation\n     error.  This would be due to a disk error or system error of some sort.\n     Temporary data is cleaned up, and the parent is released.\n\n (8) State FSCACHE_OBJECT_DYING.\n\n     The object comes here if it is dying due to an error, because its parent\n     cookie has been relinquished by the netfs or because the cache is being\n     withdrawn.\n\n     Any child objects waiting on this one are given CPU time so that they too\n     can destroy themselves.  This object waits for all its children to go away\n     before advancing to the next state.\n\n (9) State FSCACHE_OBJECT_ABORT_INIT.\n\n     The object comes to this state if it was waiting on its parent in\n     FSCACHE_OBJECT_INIT, but its parent died.  The object will destroy itself\n     so that the parent may proceed from the FSCACHE_OBJECT_DYING state.\n\n(10) State FSCACHE_OBJECT_RELEASING.\n(11) State FSCACHE_OBJECT_RECYCLING.\n\n     The object comes to one of these two states when dying once it is rid of\n     all its children, if it is dying because the netfs relinquished its\n     cookie.  In the first state, the cached data is expected to persist, and\n     in the second it will be deleted.\n\n(12) State FSCACHE_OBJECT_WITHDRAWING.\n\n     The object transits to this state if the cache decides it wants to\n     withdraw the object from service, perhaps to make space, but also due to\n     error or just because the whole cache is being withdrawn.\n\n(13) State FSCACHE_OBJECT_DEAD.\n\n     The object transits to this state when the in-memory object record is\n     ready to be deleted.  The object processor shouldn\u0027t ever see an object in\n     this state.\n\nTHE SET OF EVENTS\n-----------------\n\nThere are a number of events that can be raised to an object state machine:\n\n (*) FSCACHE_OBJECT_EV_UPDATE\n\n     The netfs requested that an object be updated.  The state machine will ask\n     the cache backend to update the object, and the cache backend will ask the\n     netfs for details of the change through its cookie definition ops.\n\n (*) FSCACHE_OBJECT_EV_CLEARED\n\n     This is signalled in two circumstances:\n\n     (a) when an object\u0027s last child object is dropped and\n\n     (b) when the last operation outstanding on an object is completed.\n\n     This is used to proceed from the dying state.\n\n (*) FSCACHE_OBJECT_EV_ERROR\n\n     This is signalled when an I/O error occurs during the processing of some\n     object.\n\n (*) FSCACHE_OBJECT_EV_RELEASE\n (*) FSCACHE_OBJECT_EV_RETIRE\n\n     These are signalled when the netfs relinquishes a cookie it was using.\n     The event selected depends on whether the netfs asks for the backing\n     object to be retired (deleted) or retained.\n\n (*) FSCACHE_OBJECT_EV_WITHDRAW\n\n     This is signalled when the cache backend wants to withdraw an object.\n     This means that the object will have to be detached from the netfs\u0027s\n     cookie.\n\nBecause the withdrawing releasing/retiring events are all handled by the object\nstate machine, it doesn\u0027t matter if there\u0027s a collision with both ends trying\nto sever the connection at the same time.  The state machine can just pick\nwhich one it wants to honour, and that effects the other.\n\nSigned-off-by: David Howells \u003cdhowells@redhat.com\u003e\nAcked-by: Steve Dickson \u003csteved@redhat.com\u003e\nAcked-by: Trond Myklebust \u003cTrond.Myklebust@netapp.com\u003e\nAcked-by: Al Viro \u003cviro@zeniv.linux.org.uk\u003e\nTested-by: Daire Byrne \u003cDaire.Byrne@framestore.com\u003e\n"
    }
  ]
}
