fscache development
-----BEGIN PGP SIGNATURE----- iQIVAwUAWsdxrvu3V2unywtrAQJVmQ/9Fv8d/Ecdwv5nxVBmN7uA8lOYcHEbZWmd FhFQE8qYLjKMo9Fy4tPkBbu1l6CVnetaTRE5qwixACJAftrdjABKJAazGR3Uxief 0jMSWScrV1XCeRErPcczHcx52Hefl8f1DQdA3zpoF0ewz7CjyxMxkl67bsYJbNKE T4ebCu5IJk+5PPwwMM3REKjQbunSXXnzgCLUI2cc0Yf76CTVpx6p+NpxV+2wq0p7 vym83F68qACAEzNH+oozN7IwqjkWyYOnTtCLiMsh4iq30jP6ohtLom6RcRp7QUxM Z9hxgG3NptypuVBO1jKxaQ6XZGgAasYmppOmJ/SoALv2PKsAbxi372lTR4ikceKq H4oNTbs5tVmyvu3qFwtLN+vX+GdfaoSUnUG8vTvnCB3tHHtYj7q5QeFE0HaX4QSq oLANkCOZU8TJsT30pxsCNYiqc5HK9kaLjUQId9K+xq7mM/IuhtNtBQ+ZpqAh5IxB 4bXKYLdeJ1myZrkYTa6gcTqeFax3djCBJ3UvjTnuqRZAaQg079WkG84Kdq1ZjDRp IQpKQnPX9JGhjW1zqLK1Ay8h+HFPgWR5BBVOaLwImr1mH+ccG0iNIeDjrOc8h6J5 e60XM/x2dIYxpXyFYAkldbAI24aRg1FNzfniG4rSAPecf3SwWrxg/qK7uujLbJHM fKNA80yifHo= =ukqs -----END PGP SIGNATURE----- Merge tag 'fscache-next-20180406' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs Pull fscache updates from David Howells: "Three patches that fix some of AFS's usage of fscache: (1) Need to invalidate the cache if a foreign data change is detected on the server. (2) Move the vnode ID uniquifier (equivalent to i_generation) from the auxiliary data to the index key to prevent a race between file delete and a subsequent file create seeing the same index key. (3) Need to retire cookies that correspond to files that we think got deleted on the server. Four patches to fix some things in fscache and cachefiles: (4) Fix a couple of checker warnings. (5) Correctly indicate to the end-of-operation callback whether an operation completed or was cancelled. (6) Add a check for multiple cookie relinquishment. (7) Fix a path through the asynchronous write that doesn't wake up a waiter for a page if the cache decides not to write that page, but discards it instead. A couple of patches to add tracepoints to fscache and cachefiles: (8) Add tracepoints for cookie operators, object state machine execution, cachefiles object management and cachefiles VFS operations. (9) Add tracepoints for fscache operation management and page wrangling. And then three development patches: (10) Attach the index key and auxiliary data to the cookie, pass this information through various fscache-netfs API functions and get rid of the callbacks to the netfs to get it. This means that the cache can get at this information, even if the netfs goes away. It also means that the cache can be lazy in updating the coherency data. (11) Pass the object data size through various fscache-netfs API rather than calling back to the netfs for it, and store the value in the object. This makes it easier to correctly resize the object, as the size is updated on writes to the cache, rather than calling back out to the netfs. (12) Maintain a catalogue of allocated cookies. This makes it possible to catch cookie collision up front rather than down in the bowels of the cache being run from a service thread from the object state machine. This will also make it possible in the future to reconnect to a cookie that's not gone dead yet because it's waiting for finalisation of the storage and also make it possible to bring cookies online if the cache is added after the cookie has been obtained" * tag 'fscache-next-20180406' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: fscache: Maintain a catalogue of allocated cookies fscache: Pass object size in rather than calling back for it fscache: Attach the index key and aux data to the cookie fscache: Add more tracepoints fscache: Add tracepoints fscache: Fix hanging wait on page discarded by writeback fscache: Detect multiple relinquishment of a cookie fscache: Pass the correct cancelled indications to fscache_op_complete() fscache, cachefiles: Fix checker warnings afs: Be more aggressive in retiring cached vnodes afs: Use the vnode ID uniquifier in the cache key not the aux data afs: Invalidate cache on server data change
This commit is contained in:
commit
62f8e6c5dc
|
@ -129,20 +129,10 @@ To define an object, a structure of the following type should be filled out:
|
||||||
const void *parent_netfs_data,
|
const void *parent_netfs_data,
|
||||||
const void *cookie_netfs_data);
|
const void *cookie_netfs_data);
|
||||||
|
|
||||||
uint16_t (*get_key)(const void *cookie_netfs_data,
|
|
||||||
void *buffer,
|
|
||||||
uint16_t bufmax);
|
|
||||||
|
|
||||||
void (*get_attr)(const void *cookie_netfs_data,
|
|
||||||
uint64_t *size);
|
|
||||||
|
|
||||||
uint16_t (*get_aux)(const void *cookie_netfs_data,
|
|
||||||
void *buffer,
|
|
||||||
uint16_t bufmax);
|
|
||||||
|
|
||||||
enum fscache_checkaux (*check_aux)(void *cookie_netfs_data,
|
enum fscache_checkaux (*check_aux)(void *cookie_netfs_data,
|
||||||
const void *data,
|
const void *data,
|
||||||
uint16_t datalen);
|
uint16_t datalen,
|
||||||
|
loff_t object_size);
|
||||||
|
|
||||||
void (*get_context)(void *cookie_netfs_data, void *context);
|
void (*get_context)(void *cookie_netfs_data, void *context);
|
||||||
|
|
||||||
|
@ -187,36 +177,7 @@ This has the following fields:
|
||||||
cache in the parent's list will be chosen, or failing that, the first
|
cache in the parent's list will be chosen, or failing that, the first
|
||||||
cache in the master list.
|
cache in the master list.
|
||||||
|
|
||||||
(4) A function to retrieve an object's key from the netfs [mandatory].
|
(4) A function to check the auxiliary data [optional].
|
||||||
|
|
||||||
This function will be called with the netfs data that was passed to the
|
|
||||||
cookie acquisition function and the maximum length of key data that it may
|
|
||||||
provide. It should write the required key data into the given buffer and
|
|
||||||
return the quantity it wrote.
|
|
||||||
|
|
||||||
(5) A function to retrieve attribute data from the netfs [optional].
|
|
||||||
|
|
||||||
This function will be called with the netfs data that was passed to the
|
|
||||||
cookie acquisition function. It should return the size of the file if
|
|
||||||
this is a data file. The size may be used to govern how much cache must
|
|
||||||
be reserved for this file in the cache.
|
|
||||||
|
|
||||||
If the function is absent, a file size of 0 is assumed.
|
|
||||||
|
|
||||||
(6) A function to retrieve auxiliary data from the netfs [optional].
|
|
||||||
|
|
||||||
This function will be called with the netfs data that was passed to the
|
|
||||||
cookie acquisition function and the maximum length of auxiliary data that
|
|
||||||
it may provide. It should write the auxiliary data into the given buffer
|
|
||||||
and return the quantity it wrote.
|
|
||||||
|
|
||||||
If this function is absent, the auxiliary data length will be set to 0.
|
|
||||||
|
|
||||||
The length of the auxiliary data buffer may be dependent on the key
|
|
||||||
length. A netfs mustn't rely on being able to provide more than 400 bytes
|
|
||||||
for both.
|
|
||||||
|
|
||||||
(7) A function to check the auxiliary data [optional].
|
|
||||||
|
|
||||||
This function will be called to check that a match found in the cache for
|
This function will be called to check that a match found in the cache for
|
||||||
this object is valid. For instance with AFS it could check the auxiliary
|
this object is valid. For instance with AFS it could check the auxiliary
|
||||||
|
@ -226,6 +187,9 @@ This has the following fields:
|
||||||
If this function is absent, it will be assumed that matching objects in a
|
If this function is absent, it will be assumed that matching objects in a
|
||||||
cache are always valid.
|
cache are always valid.
|
||||||
|
|
||||||
|
The function is also passed the cache's idea of the object size and may
|
||||||
|
use this to manage coherency also.
|
||||||
|
|
||||||
If present, the function should return one of the following values:
|
If present, the function should return one of the following values:
|
||||||
|
|
||||||
(*) FSCACHE_CHECKAUX_OKAY - the entry is okay as is
|
(*) FSCACHE_CHECKAUX_OKAY - the entry is okay as is
|
||||||
|
@ -235,7 +199,7 @@ This has the following fields:
|
||||||
This function can also be used to extract data from the auxiliary data in
|
This function can also be used to extract data from the auxiliary data in
|
||||||
the cache and copy it into the netfs's structures.
|
the cache and copy it into the netfs's structures.
|
||||||
|
|
||||||
(8) A pair of functions to manage contexts for the completion callback
|
(5) A pair of functions to manage contexts for the completion callback
|
||||||
[optional].
|
[optional].
|
||||||
|
|
||||||
The cache read/write functions are passed a context which is then passed
|
The cache read/write functions are passed a context which is then passed
|
||||||
|
@ -249,7 +213,7 @@ This has the following fields:
|
||||||
required for indices as indices may not contain data. These functions may
|
required for indices as indices may not contain data. These functions may
|
||||||
be called in interrupt context and so may not sleep.
|
be called in interrupt context and so may not sleep.
|
||||||
|
|
||||||
(9) A function to mark a page as retaining cache metadata [optional].
|
(6) A function to mark a page as retaining cache metadata [optional].
|
||||||
|
|
||||||
This is called by the cache to indicate that it is retaining in-memory
|
This is called by the cache to indicate that it is retaining in-memory
|
||||||
information for this page and that the netfs should uncache the page when
|
information for this page and that the netfs should uncache the page when
|
||||||
|
@ -261,7 +225,7 @@ This has the following fields:
|
||||||
|
|
||||||
This function is not required for indices as they're not permitted data.
|
This function is not required for indices as they're not permitted data.
|
||||||
|
|
||||||
(10) A function to unmark all the pages retaining cache metadata [mandatory].
|
(7) A function to unmark all the pages retaining cache metadata [mandatory].
|
||||||
|
|
||||||
This is called by FS-Cache to indicate that a backing store is being
|
This is called by FS-Cache to indicate that a backing store is being
|
||||||
unbound from a cookie and that all the marks on the pages should be
|
unbound from a cookie and that all the marks on the pages should be
|
||||||
|
@ -333,12 +297,32 @@ the path to the file:
|
||||||
struct fscache_cookie *
|
struct fscache_cookie *
|
||||||
fscache_acquire_cookie(struct fscache_cookie *parent,
|
fscache_acquire_cookie(struct fscache_cookie *parent,
|
||||||
const struct fscache_object_def *def,
|
const struct fscache_object_def *def,
|
||||||
|
const void *index_key,
|
||||||
|
size_t index_key_len,
|
||||||
|
const void *aux_data,
|
||||||
|
size_t aux_data_len,
|
||||||
void *netfs_data,
|
void *netfs_data,
|
||||||
|
loff_t object_size,
|
||||||
bool enable);
|
bool enable);
|
||||||
|
|
||||||
This function creates an index entry in the index represented by parent,
|
This function creates an index entry in the index represented by parent,
|
||||||
filling in the index entry by calling the operations pointed to by def.
|
filling in the index entry by calling the operations pointed to by def.
|
||||||
|
|
||||||
|
A unique key that represents the object within the parent must be pointed to by
|
||||||
|
index_key and is of length index_key_len.
|
||||||
|
|
||||||
|
An optional blob of auxiliary data that is to be stored within the cache can be
|
||||||
|
pointed to with aux_data and should be of length aux_data_len. This would
|
||||||
|
typically be used for storing coherency data.
|
||||||
|
|
||||||
|
The netfs may pass an arbitrary value in netfs_data and this will be presented
|
||||||
|
to it in the event of any calling back. This may also be used in tracing or
|
||||||
|
logging of messages.
|
||||||
|
|
||||||
|
The cache tracks the size of the data attached to an object and this set to be
|
||||||
|
object_size. For indices, this should be 0. This value will be passed to the
|
||||||
|
->check_aux() callback.
|
||||||
|
|
||||||
Note that this function never returns an error - all errors are handled
|
Note that this function never returns an error - all errors are handled
|
||||||
internally. It may, however, return NULL to indicate no cookie. It is quite
|
internally. It may, however, return NULL to indicate no cookie. It is quite
|
||||||
acceptable to pass this token back to this function as the parent to another
|
acceptable to pass this token back to this function as the parent to another
|
||||||
|
@ -355,30 +339,24 @@ must be enabled to do anything with it. A disabled cookie can be enabled by
|
||||||
calling fscache_enable_cookie() (see below).
|
calling fscache_enable_cookie() (see below).
|
||||||
|
|
||||||
For example, with AFS, a cell would be added to the primary index. This index
|
For example, with AFS, a cell would be added to the primary index. This index
|
||||||
entry would have a dependent inode containing a volume location index for the
|
entry would have a dependent inode containing volume mappings within this cell:
|
||||||
volume mappings within this cell:
|
|
||||||
|
|
||||||
cell->cache =
|
cell->cache =
|
||||||
fscache_acquire_cookie(afs_cache_netfs.primary_index,
|
fscache_acquire_cookie(afs_cache_netfs.primary_index,
|
||||||
&afs_cell_cache_index_def,
|
&afs_cell_cache_index_def,
|
||||||
cell, true);
|
cell->name, strlen(cell->name),
|
||||||
|
NULL, 0,
|
||||||
|
cell, 0, true);
|
||||||
|
|
||||||
Then when a volume location was accessed, it would be entered into the cell's
|
And then a particular volume could be added to that index by ID, creating
|
||||||
index and an inode would be allocated that acts as a volume type and hash chain
|
another index for vnodes (AFS inode equivalents):
|
||||||
combination:
|
|
||||||
|
|
||||||
vlocation->cache =
|
|
||||||
fscache_acquire_cookie(cell->cache,
|
|
||||||
&afs_vlocation_cache_index_def,
|
|
||||||
vlocation, true);
|
|
||||||
|
|
||||||
And then a particular flavour of volume (R/O for example) could be added to
|
|
||||||
that index, creating another index for vnodes (AFS inode equivalents):
|
|
||||||
|
|
||||||
volume->cache =
|
volume->cache =
|
||||||
fscache_acquire_cookie(vlocation->cache,
|
fscache_acquire_cookie(volume->cell->cache,
|
||||||
&afs_volume_cache_index_def,
|
&afs_volume_cache_index_def,
|
||||||
volume, true);
|
&volume->vid, sizeof(volume->vid),
|
||||||
|
NULL, 0,
|
||||||
|
volume, 0, true);
|
||||||
|
|
||||||
|
|
||||||
======================
|
======================
|
||||||
|
@ -392,7 +370,9 @@ the object definition should be something other than index type.
|
||||||
vnode->cache =
|
vnode->cache =
|
||||||
fscache_acquire_cookie(volume->cache,
|
fscache_acquire_cookie(volume->cache,
|
||||||
&afs_vnode_cache_object_def,
|
&afs_vnode_cache_object_def,
|
||||||
vnode, true);
|
&key, sizeof(key),
|
||||||
|
&aux, sizeof(aux),
|
||||||
|
vnode, vnode->status.size, true);
|
||||||
|
|
||||||
|
|
||||||
=================================
|
=================================
|
||||||
|
@ -408,7 +388,9 @@ it would be some other type of object such as a data file.
|
||||||
xattr->cache =
|
xattr->cache =
|
||||||
fscache_acquire_cookie(vnode->cache,
|
fscache_acquire_cookie(vnode->cache,
|
||||||
&afs_xattr_cache_object_def,
|
&afs_xattr_cache_object_def,
|
||||||
xattr, true);
|
&xattr->name, strlen(xattr->name),
|
||||||
|
NULL, 0,
|
||||||
|
xattr, strlen(xattr->val), true);
|
||||||
|
|
||||||
Miscellaneous objects might be used to store extended attributes or directory
|
Miscellaneous objects might be used to store extended attributes or directory
|
||||||
entries for example.
|
entries for example.
|
||||||
|
@ -425,8 +407,7 @@ cache to adjust its metadata for data tracking appropriately:
|
||||||
int fscache_attr_changed(struct fscache_cookie *cookie);
|
int fscache_attr_changed(struct fscache_cookie *cookie);
|
||||||
|
|
||||||
The cache will return -ENOBUFS if there is no backing cache or if there is no
|
The cache will return -ENOBUFS if there is no backing cache or if there is no
|
||||||
space to allocate any extra metadata required in the cache. The attributes
|
space to allocate any extra metadata required in the cache.
|
||||||
will be accessed with the get_attr() cookie definition operation.
|
|
||||||
|
|
||||||
Note that attempts to read or write data pages in the cache over this size may
|
Note that attempts to read or write data pages in the cache over this size may
|
||||||
be rebuffed with -ENOBUFS.
|
be rebuffed with -ENOBUFS.
|
||||||
|
@ -551,12 +532,13 @@ written back to the cache:
|
||||||
|
|
||||||
int fscache_write_page(struct fscache_cookie *cookie,
|
int fscache_write_page(struct fscache_cookie *cookie,
|
||||||
struct page *page,
|
struct page *page,
|
||||||
|
loff_t object_size,
|
||||||
gfp_t gfp);
|
gfp_t gfp);
|
||||||
|
|
||||||
The cookie argument must specify a data file cookie, the page specified should
|
The cookie argument must specify a data file cookie, the page specified should
|
||||||
contain the data to be written (and is also used to specify the page number),
|
contain the data to be written (and is also used to specify the page number),
|
||||||
and the gfp argument is used to control how any memory allocations made are
|
object_size is the revised size of the object and the gfp argument is used to
|
||||||
satisfied.
|
control how any memory allocations made are satisfied.
|
||||||
|
|
||||||
The page must have first been read or allocated successfully and must not have
|
The page must have first been read or allocated successfully and must not have
|
||||||
been uncached before writing is performed.
|
been uncached before writing is performed.
|
||||||
|
@ -717,21 +699,23 @@ INDEX AND DATA FILE CONSISTENCY
|
||||||
To find out whether auxiliary data for an object is up to data within the
|
To find out whether auxiliary data for an object is up to data within the
|
||||||
cache, the following function can be called:
|
cache, the following function can be called:
|
||||||
|
|
||||||
int fscache_check_consistency(struct fscache_cookie *cookie)
|
int fscache_check_consistency(struct fscache_cookie *cookie,
|
||||||
|
const void *aux_data);
|
||||||
|
|
||||||
This will call back to the netfs to check whether the auxiliary data associated
|
This will call back to the netfs to check whether the auxiliary data associated
|
||||||
with a cookie is correct. It returns 0 if it is and -ESTALE if it isn't; it
|
with a cookie is correct; if aux_data is non-NULL, it will update the auxiliary
|
||||||
may also return -ENOMEM and -ERESTARTSYS.
|
data buffer first. It returns 0 if it is and -ESTALE if it isn't; it may also
|
||||||
|
return -ENOMEM and -ERESTARTSYS.
|
||||||
|
|
||||||
To request an update of the index data for an index or other object, the
|
To request an update of the index data for an index or other object, the
|
||||||
following function should be called:
|
following function should be called:
|
||||||
|
|
||||||
void fscache_update_cookie(struct fscache_cookie *cookie);
|
void fscache_update_cookie(struct fscache_cookie *cookie,
|
||||||
|
const void *aux_data);
|
||||||
|
|
||||||
This function will refer back to the netfs_data pointer stored in the cookie by
|
This function will update the cookie's auxiliary data buffer from aux_data if
|
||||||
the acquisition function to obtain the data to write into each revised index
|
that is non-NULL and then schedule this to be stored on disk. The update
|
||||||
entry. The update method in the parent index definition will be called to
|
method in the parent index definition will be called to transfer the data.
|
||||||
transfer the data.
|
|
||||||
|
|
||||||
Note that partial updates may happen automatically at other times, such as when
|
Note that partial updates may happen automatically at other times, such as when
|
||||||
data blocks are added to a data file object.
|
data blocks are added to a data file object.
|
||||||
|
@ -748,10 +732,11 @@ still possible to uncache pages and relinquish the cookie.
|
||||||
|
|
||||||
The initial enablement state is set by fscache_acquire_cookie(), but the cookie
|
The initial enablement state is set by fscache_acquire_cookie(), but the cookie
|
||||||
can be enabled or disabled later. To disable a cookie, call:
|
can be enabled or disabled later. To disable a cookie, call:
|
||||||
|
|
||||||
void fscache_disable_cookie(struct fscache_cookie *cookie,
|
void fscache_disable_cookie(struct fscache_cookie *cookie,
|
||||||
|
const void *aux_data,
|
||||||
bool invalidate);
|
bool invalidate);
|
||||||
|
|
||||||
If the cookie is not already disabled, this locks the cookie against other
|
If the cookie is not already disabled, this locks the cookie against other
|
||||||
enable and disable ops, marks the cookie as being disabled, discards or
|
enable and disable ops, marks the cookie as being disabled, discards or
|
||||||
invalidates any backing objects and waits for cessation of activity on any
|
invalidates any backing objects and waits for cessation of activity on any
|
||||||
|
@ -760,13 +745,15 @@ associated object before unlocking the cookie.
|
||||||
All possible failures are handled internally. The caller should consider
|
All possible failures are handled internally. The caller should consider
|
||||||
calling fscache_uncache_all_inode_pages() afterwards to make sure all page
|
calling fscache_uncache_all_inode_pages() afterwards to make sure all page
|
||||||
markings are cleared up.
|
markings are cleared up.
|
||||||
|
|
||||||
Cookies can be enabled or reenabled with:
|
Cookies can be enabled or reenabled with:
|
||||||
|
|
||||||
void fscache_enable_cookie(struct fscache_cookie *cookie,
|
void fscache_enable_cookie(struct fscache_cookie *cookie,
|
||||||
|
const void *aux_data,
|
||||||
|
loff_t object_size,
|
||||||
bool (*can_enable)(void *data),
|
bool (*can_enable)(void *data),
|
||||||
void *data)
|
void *data)
|
||||||
|
|
||||||
If the cookie is not already enabled, this locks the cookie against other
|
If the cookie is not already enabled, this locks the cookie against other
|
||||||
enable and disable ops, invokes can_enable() and, if the cookie is not an index
|
enable and disable ops, invokes can_enable() and, if the cookie is not an index
|
||||||
cookie, will begin the procedure of acquiring backing objects.
|
cookie, will begin the procedure of acquiring backing objects.
|
||||||
|
@ -777,6 +764,12 @@ ruling as to whether or not enablement should actually be permitted to begin.
|
||||||
All possible failures are handled internally. The cookie will only be marked
|
All possible failures are handled internally. The cookie will only be marked
|
||||||
as enabled if provisional backing objects are allocated.
|
as enabled if provisional backing objects are allocated.
|
||||||
|
|
||||||
|
The object's data size is updated from object_size and is passed to the
|
||||||
|
->check_aux() function.
|
||||||
|
|
||||||
|
In both cases, the cookie's auxiliary data buffer is updated from aux_data if
|
||||||
|
that is non-NULL inside the enablement lock before proceeding.
|
||||||
|
|
||||||
|
|
||||||
===============================
|
===============================
|
||||||
MISCELLANEOUS COOKIE OPERATIONS
|
MISCELLANEOUS COOKIE OPERATIONS
|
||||||
|
@ -823,6 +816,7 @@ COOKIE UNREGISTRATION
|
||||||
To get rid of a cookie, this function should be called.
|
To get rid of a cookie, this function should be called.
|
||||||
|
|
||||||
void fscache_relinquish_cookie(struct fscache_cookie *cookie,
|
void fscache_relinquish_cookie(struct fscache_cookie *cookie,
|
||||||
|
const void *aux_data,
|
||||||
bool retire);
|
bool retire);
|
||||||
|
|
||||||
If retire is non-zero, then the object will be marked for recycling, and all
|
If retire is non-zero, then the object will be marked for recycling, and all
|
||||||
|
@ -833,6 +827,9 @@ If retire is zero, then the object may be available again when next the
|
||||||
acquisition function is called. Retirement here will overrule the pinning on a
|
acquisition function is called. Retirement here will overrule the pinning on a
|
||||||
cookie.
|
cookie.
|
||||||
|
|
||||||
|
The cookie's auxiliary data will be updated from aux_data if that is non-NULL
|
||||||
|
so that the cache can lazily update it on disk.
|
||||||
|
|
||||||
One very important note - relinquish must NOT be called for a cookie unless all
|
One very important note - relinquish must NOT be called for a cookie unless all
|
||||||
the cookies for "child" indices, objects and pages have been relinquished
|
the cookies for "child" indices, objects and pages have been relinquished
|
||||||
first.
|
first.
|
||||||
|
|
100
fs/9p/cache.c
100
fs/9p/cache.c
|
@ -55,42 +55,27 @@ int v9fs_random_cachetag(struct v9fs_session_info *v9ses)
|
||||||
return scnprintf(v9ses->cachetag, CACHETAG_LEN, "%lu", jiffies);
|
return scnprintf(v9ses->cachetag, CACHETAG_LEN, "%lu", jiffies);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t v9fs_cache_session_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax)
|
|
||||||
{
|
|
||||||
struct v9fs_session_info *v9ses;
|
|
||||||
uint16_t klen = 0;
|
|
||||||
|
|
||||||
v9ses = (struct v9fs_session_info *)cookie_netfs_data;
|
|
||||||
p9_debug(P9_DEBUG_FSC, "session %p buf %p size %u\n",
|
|
||||||
v9ses, buffer, bufmax);
|
|
||||||
|
|
||||||
if (v9ses->cachetag)
|
|
||||||
klen = strlen(v9ses->cachetag);
|
|
||||||
|
|
||||||
if (klen > bufmax)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(buffer, v9ses->cachetag, klen);
|
|
||||||
p9_debug(P9_DEBUG_FSC, "cache session tag %s\n", v9ses->cachetag);
|
|
||||||
return klen;
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct fscache_cookie_def v9fs_cache_session_index_def = {
|
const struct fscache_cookie_def v9fs_cache_session_index_def = {
|
||||||
.name = "9P.session",
|
.name = "9P.session",
|
||||||
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
||||||
.get_key = v9fs_cache_session_get_key,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses)
|
void v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses)
|
||||||
{
|
{
|
||||||
/* If no cache session tag was specified, we generate a random one. */
|
/* If no cache session tag was specified, we generate a random one. */
|
||||||
if (!v9ses->cachetag)
|
if (!v9ses->cachetag) {
|
||||||
v9fs_random_cachetag(v9ses);
|
if (v9fs_random_cachetag(v9ses) < 0) {
|
||||||
|
v9ses->fscache = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
v9ses->fscache = fscache_acquire_cookie(v9fs_cache_netfs.primary_index,
|
v9ses->fscache = fscache_acquire_cookie(v9fs_cache_netfs.primary_index,
|
||||||
&v9fs_cache_session_index_def,
|
&v9fs_cache_session_index_def,
|
||||||
v9ses, true);
|
v9ses->cachetag,
|
||||||
|
strlen(v9ses->cachetag),
|
||||||
|
NULL, 0,
|
||||||
|
v9ses, 0, true);
|
||||||
p9_debug(P9_DEBUG_FSC, "session %p get cookie %p\n",
|
p9_debug(P9_DEBUG_FSC, "session %p get cookie %p\n",
|
||||||
v9ses, v9ses->fscache);
|
v9ses, v9ses->fscache);
|
||||||
}
|
}
|
||||||
|
@ -99,45 +84,15 @@ void v9fs_cache_session_put_cookie(struct v9fs_session_info *v9ses)
|
||||||
{
|
{
|
||||||
p9_debug(P9_DEBUG_FSC, "session %p put cookie %p\n",
|
p9_debug(P9_DEBUG_FSC, "session %p put cookie %p\n",
|
||||||
v9ses, v9ses->fscache);
|
v9ses, v9ses->fscache);
|
||||||
fscache_relinquish_cookie(v9ses->fscache, 0);
|
fscache_relinquish_cookie(v9ses->fscache, NULL, false);
|
||||||
v9ses->fscache = NULL;
|
v9ses->fscache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uint16_t v9fs_cache_inode_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax)
|
|
||||||
{
|
|
||||||
const struct v9fs_inode *v9inode = cookie_netfs_data;
|
|
||||||
memcpy(buffer, &v9inode->qid.path, sizeof(v9inode->qid.path));
|
|
||||||
p9_debug(P9_DEBUG_FSC, "inode %p get key %llu\n",
|
|
||||||
&v9inode->vfs_inode, v9inode->qid.path);
|
|
||||||
return sizeof(v9inode->qid.path);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void v9fs_cache_inode_get_attr(const void *cookie_netfs_data,
|
|
||||||
uint64_t *size)
|
|
||||||
{
|
|
||||||
const struct v9fs_inode *v9inode = cookie_netfs_data;
|
|
||||||
*size = i_size_read(&v9inode->vfs_inode);
|
|
||||||
|
|
||||||
p9_debug(P9_DEBUG_FSC, "inode %p get attr %llu\n",
|
|
||||||
&v9inode->vfs_inode, *size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint16_t v9fs_cache_inode_get_aux(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t buflen)
|
|
||||||
{
|
|
||||||
const struct v9fs_inode *v9inode = cookie_netfs_data;
|
|
||||||
memcpy(buffer, &v9inode->qid.version, sizeof(v9inode->qid.version));
|
|
||||||
p9_debug(P9_DEBUG_FSC, "inode %p get aux %u\n",
|
|
||||||
&v9inode->vfs_inode, v9inode->qid.version);
|
|
||||||
return sizeof(v9inode->qid.version);
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum
|
static enum
|
||||||
fscache_checkaux v9fs_cache_inode_check_aux(void *cookie_netfs_data,
|
fscache_checkaux v9fs_cache_inode_check_aux(void *cookie_netfs_data,
|
||||||
const void *buffer,
|
const void *buffer,
|
||||||
uint16_t buflen)
|
uint16_t buflen,
|
||||||
|
loff_t object_size)
|
||||||
{
|
{
|
||||||
const struct v9fs_inode *v9inode = cookie_netfs_data;
|
const struct v9fs_inode *v9inode = cookie_netfs_data;
|
||||||
|
|
||||||
|
@ -154,9 +109,6 @@ fscache_checkaux v9fs_cache_inode_check_aux(void *cookie_netfs_data,
|
||||||
const struct fscache_cookie_def v9fs_cache_inode_index_def = {
|
const struct fscache_cookie_def v9fs_cache_inode_index_def = {
|
||||||
.name = "9p.inode",
|
.name = "9p.inode",
|
||||||
.type = FSCACHE_COOKIE_TYPE_DATAFILE,
|
.type = FSCACHE_COOKIE_TYPE_DATAFILE,
|
||||||
.get_key = v9fs_cache_inode_get_key,
|
|
||||||
.get_attr = v9fs_cache_inode_get_attr,
|
|
||||||
.get_aux = v9fs_cache_inode_get_aux,
|
|
||||||
.check_aux = v9fs_cache_inode_check_aux,
|
.check_aux = v9fs_cache_inode_check_aux,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -175,7 +127,13 @@ void v9fs_cache_inode_get_cookie(struct inode *inode)
|
||||||
v9ses = v9fs_inode2v9ses(inode);
|
v9ses = v9fs_inode2v9ses(inode);
|
||||||
v9inode->fscache = fscache_acquire_cookie(v9ses->fscache,
|
v9inode->fscache = fscache_acquire_cookie(v9ses->fscache,
|
||||||
&v9fs_cache_inode_index_def,
|
&v9fs_cache_inode_index_def,
|
||||||
v9inode, true);
|
&v9inode->qid.path,
|
||||||
|
sizeof(v9inode->qid.path),
|
||||||
|
&v9inode->qid.version,
|
||||||
|
sizeof(v9inode->qid.version),
|
||||||
|
v9inode,
|
||||||
|
i_size_read(&v9inode->vfs_inode),
|
||||||
|
true);
|
||||||
|
|
||||||
p9_debug(P9_DEBUG_FSC, "inode %p get cookie %p\n",
|
p9_debug(P9_DEBUG_FSC, "inode %p get cookie %p\n",
|
||||||
inode, v9inode->fscache);
|
inode, v9inode->fscache);
|
||||||
|
@ -190,7 +148,8 @@ void v9fs_cache_inode_put_cookie(struct inode *inode)
|
||||||
p9_debug(P9_DEBUG_FSC, "inode %p put cookie %p\n",
|
p9_debug(P9_DEBUG_FSC, "inode %p put cookie %p\n",
|
||||||
inode, v9inode->fscache);
|
inode, v9inode->fscache);
|
||||||
|
|
||||||
fscache_relinquish_cookie(v9inode->fscache, 0);
|
fscache_relinquish_cookie(v9inode->fscache, &v9inode->qid.version,
|
||||||
|
false);
|
||||||
v9inode->fscache = NULL;
|
v9inode->fscache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +162,7 @@ void v9fs_cache_inode_flush_cookie(struct inode *inode)
|
||||||
p9_debug(P9_DEBUG_FSC, "inode %p flush cookie %p\n",
|
p9_debug(P9_DEBUG_FSC, "inode %p flush cookie %p\n",
|
||||||
inode, v9inode->fscache);
|
inode, v9inode->fscache);
|
||||||
|
|
||||||
fscache_relinquish_cookie(v9inode->fscache, 1);
|
fscache_relinquish_cookie(v9inode->fscache, NULL, true);
|
||||||
v9inode->fscache = NULL;
|
v9inode->fscache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,12 +195,18 @@ void v9fs_cache_inode_reset_cookie(struct inode *inode)
|
||||||
old = v9inode->fscache;
|
old = v9inode->fscache;
|
||||||
|
|
||||||
mutex_lock(&v9inode->fscache_lock);
|
mutex_lock(&v9inode->fscache_lock);
|
||||||
fscache_relinquish_cookie(v9inode->fscache, 1);
|
fscache_relinquish_cookie(v9inode->fscache, NULL, true);
|
||||||
|
|
||||||
v9ses = v9fs_inode2v9ses(inode);
|
v9ses = v9fs_inode2v9ses(inode);
|
||||||
v9inode->fscache = fscache_acquire_cookie(v9ses->fscache,
|
v9inode->fscache = fscache_acquire_cookie(v9ses->fscache,
|
||||||
&v9fs_cache_inode_index_def,
|
&v9fs_cache_inode_index_def,
|
||||||
v9inode, true);
|
&v9inode->qid.path,
|
||||||
|
sizeof(v9inode->qid.path),
|
||||||
|
&v9inode->qid.version,
|
||||||
|
sizeof(v9inode->qid.version),
|
||||||
|
v9inode,
|
||||||
|
i_size_read(&v9inode->vfs_inode),
|
||||||
|
true);
|
||||||
p9_debug(P9_DEBUG_FSC, "inode %p revalidating cookie old %p new %p\n",
|
p9_debug(P9_DEBUG_FSC, "inode %p revalidating cookie old %p new %p\n",
|
||||||
inode, old, v9inode->fscache);
|
inode, old, v9inode->fscache);
|
||||||
|
|
||||||
|
@ -367,7 +332,8 @@ void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page)
|
||||||
const struct v9fs_inode *v9inode = V9FS_I(inode);
|
const struct v9fs_inode *v9inode = V9FS_I(inode);
|
||||||
|
|
||||||
p9_debug(P9_DEBUG_FSC, "inode %p page %p\n", inode, page);
|
p9_debug(P9_DEBUG_FSC, "inode %p page %p\n", inode, page);
|
||||||
ret = fscache_write_page(v9inode->fscache, page, GFP_KERNEL);
|
ret = fscache_write_page(v9inode->fscache, page,
|
||||||
|
i_size_read(&v9inode->vfs_inode), GFP_KERNEL);
|
||||||
p9_debug(P9_DEBUG_FSC, "ret = %d\n", ret);
|
p9_debug(P9_DEBUG_FSC, "ret = %d\n", ret);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
v9fs_uncache_page(inode, page);
|
v9fs_uncache_page(inode, page);
|
||||||
|
|
150
fs/afs/cache.c
150
fs/afs/cache.c
|
@ -12,167 +12,39 @@
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
static uint16_t afs_cell_cache_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t buflen);
|
|
||||||
static uint16_t afs_volume_cache_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t buflen);
|
|
||||||
|
|
||||||
static uint16_t afs_vnode_cache_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t buflen);
|
|
||||||
static void afs_vnode_cache_get_attr(const void *cookie_netfs_data,
|
|
||||||
uint64_t *size);
|
|
||||||
static uint16_t afs_vnode_cache_get_aux(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t buflen);
|
|
||||||
static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data,
|
static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data,
|
||||||
const void *buffer,
|
const void *buffer,
|
||||||
uint16_t buflen);
|
uint16_t buflen,
|
||||||
|
loff_t object_size);
|
||||||
|
|
||||||
struct fscache_netfs afs_cache_netfs = {
|
struct fscache_netfs afs_cache_netfs = {
|
||||||
.name = "afs",
|
.name = "afs",
|
||||||
.version = 1,
|
.version = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fscache_cookie_def afs_cell_cache_index_def = {
|
struct fscache_cookie_def afs_cell_cache_index_def = {
|
||||||
.name = "AFS.cell",
|
.name = "AFS.cell",
|
||||||
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
||||||
.get_key = afs_cell_cache_get_key,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fscache_cookie_def afs_volume_cache_index_def = {
|
struct fscache_cookie_def afs_volume_cache_index_def = {
|
||||||
.name = "AFS.volume",
|
.name = "AFS.volume",
|
||||||
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
||||||
.get_key = afs_volume_cache_get_key,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fscache_cookie_def afs_vnode_cache_index_def = {
|
struct fscache_cookie_def afs_vnode_cache_index_def = {
|
||||||
.name = "AFS.vnode",
|
.name = "AFS.vnode",
|
||||||
.type = FSCACHE_COOKIE_TYPE_DATAFILE,
|
.type = FSCACHE_COOKIE_TYPE_DATAFILE,
|
||||||
.get_key = afs_vnode_cache_get_key,
|
.check_aux = afs_vnode_cache_check_aux,
|
||||||
.get_attr = afs_vnode_cache_get_attr,
|
|
||||||
.get_aux = afs_vnode_cache_get_aux,
|
|
||||||
.check_aux = afs_vnode_cache_check_aux,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* set the key for the index entry
|
|
||||||
*/
|
|
||||||
static uint16_t afs_cell_cache_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax)
|
|
||||||
{
|
|
||||||
const struct afs_cell *cell = cookie_netfs_data;
|
|
||||||
uint16_t klen;
|
|
||||||
|
|
||||||
_enter("%p,%p,%u", cell, buffer, bufmax);
|
|
||||||
|
|
||||||
klen = strlen(cell->name);
|
|
||||||
if (klen > bufmax)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(buffer, cell->name, klen);
|
|
||||||
return klen;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*
|
|
||||||
* set the key for the volume index entry
|
|
||||||
*/
|
|
||||||
static uint16_t afs_volume_cache_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax)
|
|
||||||
{
|
|
||||||
const struct afs_volume *volume = cookie_netfs_data;
|
|
||||||
struct {
|
|
||||||
u64 volid;
|
|
||||||
} __packed key;
|
|
||||||
|
|
||||||
_enter("{%u},%p,%u", volume->type, buffer, bufmax);
|
|
||||||
|
|
||||||
if (bufmax < sizeof(key))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
key.volid = volume->vid;
|
|
||||||
memcpy(buffer, &key, sizeof(key));
|
|
||||||
return sizeof(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*
|
|
||||||
* set the key for the index entry
|
|
||||||
*/
|
|
||||||
static uint16_t afs_vnode_cache_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax)
|
|
||||||
{
|
|
||||||
const struct afs_vnode *vnode = cookie_netfs_data;
|
|
||||||
struct {
|
|
||||||
u32 vnode_id[3];
|
|
||||||
} __packed key;
|
|
||||||
|
|
||||||
_enter("{%x,%x,%llx},%p,%u",
|
|
||||||
vnode->fid.vnode, vnode->fid.unique, vnode->status.data_version,
|
|
||||||
buffer, bufmax);
|
|
||||||
|
|
||||||
/* Allow for a 96-bit key */
|
|
||||||
memset(&key, 0, sizeof(key));
|
|
||||||
key.vnode_id[0] = vnode->fid.vnode;
|
|
||||||
key.vnode_id[1] = 0;
|
|
||||||
key.vnode_id[2] = 0;
|
|
||||||
|
|
||||||
if (sizeof(key) > bufmax)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(buffer, &key, sizeof(key));
|
|
||||||
return sizeof(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* provide updated file attributes
|
|
||||||
*/
|
|
||||||
static void afs_vnode_cache_get_attr(const void *cookie_netfs_data,
|
|
||||||
uint64_t *size)
|
|
||||||
{
|
|
||||||
const struct afs_vnode *vnode = cookie_netfs_data;
|
|
||||||
|
|
||||||
_enter("{%x,%x,%llx},",
|
|
||||||
vnode->fid.vnode, vnode->fid.unique,
|
|
||||||
vnode->status.data_version);
|
|
||||||
|
|
||||||
*size = vnode->status.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct afs_vnode_cache_aux {
|
|
||||||
u64 data_version;
|
|
||||||
u32 fid_unique;
|
|
||||||
} __packed;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* provide new auxiliary cache data
|
|
||||||
*/
|
|
||||||
static uint16_t afs_vnode_cache_get_aux(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax)
|
|
||||||
{
|
|
||||||
const struct afs_vnode *vnode = cookie_netfs_data;
|
|
||||||
struct afs_vnode_cache_aux aux;
|
|
||||||
|
|
||||||
_enter("{%x,%x,%Lx},%p,%u",
|
|
||||||
vnode->fid.vnode, vnode->fid.unique, vnode->status.data_version,
|
|
||||||
buffer, bufmax);
|
|
||||||
|
|
||||||
memset(&aux, 0, sizeof(aux));
|
|
||||||
aux.data_version = vnode->status.data_version;
|
|
||||||
aux.fid_unique = vnode->fid.unique;
|
|
||||||
|
|
||||||
if (bufmax < sizeof(aux))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(buffer, &aux, sizeof(aux));
|
|
||||||
return sizeof(aux);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check that the auxiliary data indicates that the entry is still valid
|
* check that the auxiliary data indicates that the entry is still valid
|
||||||
*/
|
*/
|
||||||
static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data,
|
static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data,
|
||||||
const void *buffer,
|
const void *buffer,
|
||||||
uint16_t buflen)
|
uint16_t buflen,
|
||||||
|
loff_t object_size)
|
||||||
{
|
{
|
||||||
struct afs_vnode *vnode = cookie_netfs_data;
|
struct afs_vnode *vnode = cookie_netfs_data;
|
||||||
struct afs_vnode_cache_aux aux;
|
struct afs_vnode_cache_aux aux;
|
||||||
|
@ -189,12 +61,6 @@ static enum fscache_checkaux afs_vnode_cache_check_aux(void *cookie_netfs_data,
|
||||||
return FSCACHE_CHECKAUX_OBSOLETE;
|
return FSCACHE_CHECKAUX_OBSOLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vnode->fid.unique != aux.fid_unique) {
|
|
||||||
_leave(" = OBSOLETE [uniq %x != %x]",
|
|
||||||
aux.fid_unique, vnode->fid.unique);
|
|
||||||
return FSCACHE_CHECKAUX_OBSOLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vnode->status.data_version != aux.data_version) {
|
if (vnode->status.data_version != aux.data_version) {
|
||||||
_leave(" = OBSOLETE [vers %llx != %llx]",
|
_leave(" = OBSOLETE [vers %llx != %llx]",
|
||||||
aux.data_version, vnode->status.data_version);
|
aux.data_version, vnode->status.data_version);
|
||||||
|
|
|
@ -522,7 +522,9 @@ static int afs_activate_cell(struct afs_net *net, struct afs_cell *cell)
|
||||||
#ifdef CONFIG_AFS_FSCACHE
|
#ifdef CONFIG_AFS_FSCACHE
|
||||||
cell->cache = fscache_acquire_cookie(afs_cache_netfs.primary_index,
|
cell->cache = fscache_acquire_cookie(afs_cache_netfs.primary_index,
|
||||||
&afs_cell_cache_index_def,
|
&afs_cell_cache_index_def,
|
||||||
cell, true);
|
cell->name, strlen(cell->name),
|
||||||
|
NULL, 0,
|
||||||
|
cell, 0, true);
|
||||||
#endif
|
#endif
|
||||||
ret = afs_proc_cell_setup(net, cell);
|
ret = afs_proc_cell_setup(net, cell);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -547,7 +549,7 @@ static void afs_deactivate_cell(struct afs_net *net, struct afs_cell *cell)
|
||||||
spin_unlock(&net->proc_cells_lock);
|
spin_unlock(&net->proc_cells_lock);
|
||||||
|
|
||||||
#ifdef CONFIG_AFS_FSCACHE
|
#ifdef CONFIG_AFS_FSCACHE
|
||||||
fscache_relinquish_cookie(cell->cache, 0);
|
fscache_relinquish_cookie(cell->cache, NULL, false);
|
||||||
cell->cache = NULL;
|
cell->cache = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,8 @@ int afs_page_filler(void *data, struct page *page)
|
||||||
/* send the page to the cache */
|
/* send the page to the cache */
|
||||||
#ifdef CONFIG_AFS_FSCACHE
|
#ifdef CONFIG_AFS_FSCACHE
|
||||||
if (PageFsCache(page) &&
|
if (PageFsCache(page) &&
|
||||||
fscache_write_page(vnode->cache, page, GFP_KERNEL) != 0) {
|
fscache_write_page(vnode->cache, page, vnode->status.size,
|
||||||
|
GFP_KERNEL) != 0) {
|
||||||
fscache_uncache_page(vnode->cache, page);
|
fscache_uncache_page(vnode->cache, page);
|
||||||
BUG_ON(PageFsCache(page));
|
BUG_ON(PageFsCache(page));
|
||||||
}
|
}
|
||||||
|
@ -403,7 +404,8 @@ static void afs_readpages_page_done(struct afs_call *call, struct afs_read *req)
|
||||||
/* send the page to the cache */
|
/* send the page to the cache */
|
||||||
#ifdef CONFIG_AFS_FSCACHE
|
#ifdef CONFIG_AFS_FSCACHE
|
||||||
if (PageFsCache(page) &&
|
if (PageFsCache(page) &&
|
||||||
fscache_write_page(vnode->cache, page, GFP_KERNEL) != 0) {
|
fscache_write_page(vnode->cache, page, vnode->status.size,
|
||||||
|
GFP_KERNEL) != 0) {
|
||||||
fscache_uncache_page(vnode->cache, page);
|
fscache_uncache_page(vnode->cache, page);
|
||||||
BUG_ON(PageFsCache(page));
|
BUG_ON(PageFsCache(page));
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,6 +242,33 @@ struct inode *afs_iget_pseudo_dir(struct super_block *sb, bool root)
|
||||||
return inode;
|
return inode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get a cache cookie for an inode.
|
||||||
|
*/
|
||||||
|
static void afs_get_inode_cache(struct afs_vnode *vnode)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_AFS_FSCACHE
|
||||||
|
struct {
|
||||||
|
u32 vnode_id;
|
||||||
|
u32 unique;
|
||||||
|
u32 vnode_id_ext[2]; /* Allow for a 96-bit key */
|
||||||
|
} __packed key;
|
||||||
|
struct afs_vnode_cache_aux aux;
|
||||||
|
|
||||||
|
key.vnode_id = vnode->fid.vnode;
|
||||||
|
key.unique = vnode->fid.unique;
|
||||||
|
key.vnode_id_ext[0] = 0;
|
||||||
|
key.vnode_id_ext[1] = 0;
|
||||||
|
aux.data_version = vnode->status.data_version;
|
||||||
|
|
||||||
|
vnode->cache = fscache_acquire_cookie(vnode->volume->cache,
|
||||||
|
&afs_vnode_cache_index_def,
|
||||||
|
&key, sizeof(key),
|
||||||
|
&aux, sizeof(aux),
|
||||||
|
vnode, vnode->status.size, true);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* inode retrieval
|
* inode retrieval
|
||||||
*/
|
*/
|
||||||
|
@ -307,11 +334,7 @@ struct inode *afs_iget(struct super_block *sb, struct key *key,
|
||||||
/* set up caching before mapping the status, as map-status reads the
|
/* set up caching before mapping the status, as map-status reads the
|
||||||
* first page of symlinks to see if they're really mountpoints */
|
* first page of symlinks to see if they're really mountpoints */
|
||||||
inode->i_size = vnode->status.size;
|
inode->i_size = vnode->status.size;
|
||||||
#ifdef CONFIG_AFS_FSCACHE
|
afs_get_inode_cache(vnode);
|
||||||
vnode->cache = fscache_acquire_cookie(vnode->volume->cache,
|
|
||||||
&afs_vnode_cache_index_def,
|
|
||||||
vnode, true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = afs_inode_map_status(vnode, key);
|
ret = afs_inode_map_status(vnode, key);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -327,7 +350,7 @@ struct inode *afs_iget(struct super_block *sb, struct key *key,
|
||||||
/* failure */
|
/* failure */
|
||||||
bad_inode:
|
bad_inode:
|
||||||
#ifdef CONFIG_AFS_FSCACHE
|
#ifdef CONFIG_AFS_FSCACHE
|
||||||
fscache_relinquish_cookie(vnode->cache, 0);
|
fscache_relinquish_cookie(vnode->cache, NULL, ret == -ENOENT);
|
||||||
vnode->cache = NULL;
|
vnode->cache = NULL;
|
||||||
#endif
|
#endif
|
||||||
iget_failed(inode);
|
iget_failed(inode);
|
||||||
|
@ -343,6 +366,10 @@ void afs_zap_data(struct afs_vnode *vnode)
|
||||||
{
|
{
|
||||||
_enter("{%x:%u}", vnode->fid.vid, vnode->fid.vnode);
|
_enter("{%x:%u}", vnode->fid.vid, vnode->fid.vnode);
|
||||||
|
|
||||||
|
#ifdef CONFIG_AFS_FSCACHE
|
||||||
|
fscache_invalidate(vnode->cache);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* nuke all the non-dirty pages that aren't locked, mapped or being
|
/* nuke all the non-dirty pages that aren't locked, mapped or being
|
||||||
* written back in a regular file and completely discard the pages in a
|
* written back in a regular file and completely discard the pages in a
|
||||||
* directory or symlink */
|
* directory or symlink */
|
||||||
|
@ -507,8 +534,14 @@ void afs_evict_inode(struct inode *inode)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_AFS_FSCACHE
|
#ifdef CONFIG_AFS_FSCACHE
|
||||||
fscache_relinquish_cookie(vnode->cache, 0);
|
{
|
||||||
vnode->cache = NULL;
|
struct afs_vnode_cache_aux aux;
|
||||||
|
|
||||||
|
aux.data_version = vnode->status.data_version;
|
||||||
|
fscache_relinquish_cookie(vnode->cache, &aux,
|
||||||
|
test_bit(AFS_VNODE_DELETED, &vnode->flags));
|
||||||
|
vnode->cache = NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
afs_put_permits(vnode->permit_cache);
|
afs_put_permits(vnode->permit_cache);
|
||||||
|
|
|
@ -559,6 +559,13 @@ struct afs_fs_cursor {
|
||||||
#define AFS_FS_CURSOR_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */
|
#define AFS_FS_CURSOR_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cache auxiliary data.
|
||||||
|
*/
|
||||||
|
struct afs_vnode_cache_aux {
|
||||||
|
u64 data_version;
|
||||||
|
} __packed;
|
||||||
|
|
||||||
#include <trace/events/afs.h>
|
#include <trace/events/afs.h>
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -225,7 +225,9 @@ void afs_activate_volume(struct afs_volume *volume)
|
||||||
#ifdef CONFIG_AFS_FSCACHE
|
#ifdef CONFIG_AFS_FSCACHE
|
||||||
volume->cache = fscache_acquire_cookie(volume->cell->cache,
|
volume->cache = fscache_acquire_cookie(volume->cell->cache,
|
||||||
&afs_volume_cache_index_def,
|
&afs_volume_cache_index_def,
|
||||||
volume, true);
|
&volume->vid, sizeof(volume->vid),
|
||||||
|
NULL, 0,
|
||||||
|
volume, 0, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
write_lock(&volume->cell->proc_lock);
|
write_lock(&volume->cell->proc_lock);
|
||||||
|
@ -245,7 +247,7 @@ void afs_deactivate_volume(struct afs_volume *volume)
|
||||||
write_unlock(&volume->cell->proc_lock);
|
write_unlock(&volume->cell->proc_lock);
|
||||||
|
|
||||||
#ifdef CONFIG_AFS_FSCACHE
|
#ifdef CONFIG_AFS_FSCACHE
|
||||||
fscache_relinquish_cookie(volume->cache,
|
fscache_relinquish_cookie(volume->cache, NULL,
|
||||||
test_bit(AFS_VOLUME_DELETED, &volume->flags));
|
test_bit(AFS_VOLUME_DELETED, &volume->flags));
|
||||||
volume->cache = NULL;
|
volume->cache = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,7 +32,7 @@ static struct fscache_object *cachefiles_alloc_object(
|
||||||
struct cachefiles_cache *cache;
|
struct cachefiles_cache *cache;
|
||||||
struct cachefiles_xattr *auxdata;
|
struct cachefiles_xattr *auxdata;
|
||||||
unsigned keylen, auxlen;
|
unsigned keylen, auxlen;
|
||||||
void *buffer;
|
void *buffer, *p;
|
||||||
char *key;
|
char *key;
|
||||||
|
|
||||||
cache = container_of(_cache, struct cachefiles_cache, cache);
|
cache = container_of(_cache, struct cachefiles_cache, cache);
|
||||||
|
@ -65,8 +65,12 @@ static struct fscache_object *cachefiles_alloc_object(
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
goto nomem_buffer;
|
goto nomem_buffer;
|
||||||
|
|
||||||
keylen = cookie->def->get_key(cookie->netfs_data, buffer + 2, 512);
|
keylen = cookie->key_len;
|
||||||
ASSERTCMP(keylen, <, 512);
|
if (keylen <= sizeof(cookie->inline_key))
|
||||||
|
p = cookie->inline_key;
|
||||||
|
else
|
||||||
|
p = cookie->key;
|
||||||
|
memcpy(buffer + 2, p, keylen);
|
||||||
|
|
||||||
*(uint16_t *)buffer = keylen;
|
*(uint16_t *)buffer = keylen;
|
||||||
((char *)buffer)[keylen + 2] = 0;
|
((char *)buffer)[keylen + 2] = 0;
|
||||||
|
@ -80,15 +84,17 @@ static struct fscache_object *cachefiles_alloc_object(
|
||||||
|
|
||||||
/* get hold of the auxiliary data and prepend the object type */
|
/* get hold of the auxiliary data and prepend the object type */
|
||||||
auxdata = buffer;
|
auxdata = buffer;
|
||||||
auxlen = 0;
|
auxlen = cookie->aux_len;
|
||||||
if (cookie->def->get_aux) {
|
if (auxlen) {
|
||||||
auxlen = cookie->def->get_aux(cookie->netfs_data,
|
if (auxlen <= sizeof(cookie->inline_aux))
|
||||||
auxdata->data, 511);
|
p = cookie->inline_aux;
|
||||||
ASSERTCMP(auxlen, <, 511);
|
else
|
||||||
|
p = cookie->aux;
|
||||||
|
memcpy(auxdata->data, p, auxlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
auxdata->len = auxlen + 1;
|
auxdata->len = auxlen + 1;
|
||||||
auxdata->type = cookie->def->type;
|
auxdata->type = cookie->type;
|
||||||
|
|
||||||
lookup_data->auxdata = auxdata;
|
lookup_data->auxdata = auxdata;
|
||||||
lookup_data->key = key;
|
lookup_data->key = key;
|
||||||
|
@ -177,10 +183,12 @@ static void cachefiles_lookup_complete(struct fscache_object *_object)
|
||||||
* increment the usage count on an inode object (may fail if unmounting)
|
* increment the usage count on an inode object (may fail if unmounting)
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
struct fscache_object *cachefiles_grab_object(struct fscache_object *_object)
|
struct fscache_object *cachefiles_grab_object(struct fscache_object *_object,
|
||||||
|
enum fscache_obj_ref_trace why)
|
||||||
{
|
{
|
||||||
struct cachefiles_object *object =
|
struct cachefiles_object *object =
|
||||||
container_of(_object, struct cachefiles_object, fscache);
|
container_of(_object, struct cachefiles_object, fscache);
|
||||||
|
int u;
|
||||||
|
|
||||||
_enter("{OBJ%x,%d}", _object->debug_id, atomic_read(&object->usage));
|
_enter("{OBJ%x,%d}", _object->debug_id, atomic_read(&object->usage));
|
||||||
|
|
||||||
|
@ -188,7 +196,9 @@ struct fscache_object *cachefiles_grab_object(struct fscache_object *_object)
|
||||||
ASSERT((atomic_read(&object->usage) & 0xffff0000) != 0x6b6b0000);
|
ASSERT((atomic_read(&object->usage) & 0xffff0000) != 0x6b6b0000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
atomic_inc(&object->usage);
|
u = atomic_inc_return(&object->usage);
|
||||||
|
trace_cachefiles_ref(object, _object->cookie,
|
||||||
|
(enum cachefiles_obj_ref_trace)why, u);
|
||||||
return &object->fscache;
|
return &object->fscache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,6 +212,7 @@ static void cachefiles_update_object(struct fscache_object *_object)
|
||||||
struct cachefiles_cache *cache;
|
struct cachefiles_cache *cache;
|
||||||
struct fscache_cookie *cookie;
|
struct fscache_cookie *cookie;
|
||||||
const struct cred *saved_cred;
|
const struct cred *saved_cred;
|
||||||
|
const void *aux;
|
||||||
unsigned auxlen;
|
unsigned auxlen;
|
||||||
|
|
||||||
_enter("{OBJ%x}", _object->debug_id);
|
_enter("{OBJ%x}", _object->debug_id);
|
||||||
|
@ -216,26 +227,29 @@ static void cachefiles_update_object(struct fscache_object *_object)
|
||||||
}
|
}
|
||||||
|
|
||||||
cookie = object->fscache.cookie;
|
cookie = object->fscache.cookie;
|
||||||
|
auxlen = cookie->aux_len;
|
||||||
|
|
||||||
if (!cookie->def->get_aux) {
|
if (!auxlen) {
|
||||||
fscache_unuse_cookie(_object);
|
fscache_unuse_cookie(_object);
|
||||||
_leave(" [no aux]");
|
_leave(" [no aux]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auxdata = kmalloc(2 + 512 + 3, cachefiles_gfp);
|
auxdata = kmalloc(2 + auxlen + 3, cachefiles_gfp);
|
||||||
if (!auxdata) {
|
if (!auxdata) {
|
||||||
fscache_unuse_cookie(_object);
|
fscache_unuse_cookie(_object);
|
||||||
_leave(" [nomem]");
|
_leave(" [nomem]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auxlen = cookie->def->get_aux(cookie->netfs_data, auxdata->data, 511);
|
aux = (auxlen <= sizeof(cookie->inline_aux)) ?
|
||||||
|
cookie->inline_aux : cookie->aux;
|
||||||
|
|
||||||
|
memcpy(auxdata->data, aux, auxlen);
|
||||||
fscache_unuse_cookie(_object);
|
fscache_unuse_cookie(_object);
|
||||||
ASSERTCMP(auxlen, <, 511);
|
|
||||||
|
|
||||||
auxdata->len = auxlen + 1;
|
auxdata->len = auxlen + 1;
|
||||||
auxdata->type = cookie->def->type;
|
auxdata->type = cookie->type;
|
||||||
|
|
||||||
cachefiles_begin_secure(cache, &saved_cred);
|
cachefiles_begin_secure(cache, &saved_cred);
|
||||||
cachefiles_update_object_xattr(object, auxdata);
|
cachefiles_update_object_xattr(object, auxdata);
|
||||||
|
@ -309,10 +323,12 @@ static void cachefiles_drop_object(struct fscache_object *_object)
|
||||||
/*
|
/*
|
||||||
* dispose of a reference to an object
|
* dispose of a reference to an object
|
||||||
*/
|
*/
|
||||||
static void cachefiles_put_object(struct fscache_object *_object)
|
static void cachefiles_put_object(struct fscache_object *_object,
|
||||||
|
enum fscache_obj_ref_trace why)
|
||||||
{
|
{
|
||||||
struct cachefiles_object *object;
|
struct cachefiles_object *object;
|
||||||
struct fscache_cache *cache;
|
struct fscache_cache *cache;
|
||||||
|
int u;
|
||||||
|
|
||||||
ASSERT(_object);
|
ASSERT(_object);
|
||||||
|
|
||||||
|
@ -328,7 +344,11 @@ static void cachefiles_put_object(struct fscache_object *_object)
|
||||||
ASSERTIFCMP(object->fscache.parent,
|
ASSERTIFCMP(object->fscache.parent,
|
||||||
object->fscache.parent->n_children, >, 0);
|
object->fscache.parent->n_children, >, 0);
|
||||||
|
|
||||||
if (atomic_dec_and_test(&object->usage)) {
|
u = atomic_dec_return(&object->usage);
|
||||||
|
trace_cachefiles_ref(object, _object->cookie,
|
||||||
|
(enum cachefiles_obj_ref_trace)why, u);
|
||||||
|
ASSERTCMP(u, !=, -1);
|
||||||
|
if (u == 0) {
|
||||||
_debug("- kill object OBJ%x", object->fscache.debug_id);
|
_debug("- kill object OBJ%x", object->fscache.debug_id);
|
||||||
|
|
||||||
ASSERT(!test_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags));
|
ASSERT(!test_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags));
|
||||||
|
@ -421,7 +441,7 @@ static int cachefiles_attr_changed(struct fscache_object *_object)
|
||||||
loff_t oi_size;
|
loff_t oi_size;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
_object->cookie->def->get_attr(_object->cookie->netfs_data, &ni_size);
|
ni_size = _object->store_limit_l;
|
||||||
|
|
||||||
_enter("{OBJ%x},[%llu]",
|
_enter("{OBJ%x},[%llu]",
|
||||||
_object->debug_id, (unsigned long long) ni_size);
|
_object->debug_id, (unsigned long long) ni_size);
|
||||||
|
@ -493,8 +513,7 @@ static void cachefiles_invalidate_object(struct fscache_operation *op)
|
||||||
cache = container_of(object->fscache.cache,
|
cache = container_of(object->fscache.cache,
|
||||||
struct cachefiles_cache, cache);
|
struct cachefiles_cache, cache);
|
||||||
|
|
||||||
op->object->cookie->def->get_attr(op->object->cookie->netfs_data,
|
ni_size = op->object->store_limit_l;
|
||||||
&ni_size);
|
|
||||||
|
|
||||||
_enter("{OBJ%x},[%llu]",
|
_enter("{OBJ%x},[%llu]",
|
||||||
op->object->debug_id, (unsigned long long)ni_size);
|
op->object->debug_id, (unsigned long long)ni_size);
|
||||||
|
|
|
@ -124,6 +124,8 @@ struct cachefiles_xattr {
|
||||||
uint8_t data[];
|
uint8_t data[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include <trace/events/cachefiles.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* note change of state for daemon
|
* note change of state for daemon
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <linux/statfs.h>
|
#include <linux/statfs.h>
|
||||||
#include <linux/sysctl.h>
|
#include <linux/sysctl.h>
|
||||||
#include <linux/miscdevice.h>
|
#include <linux/miscdevice.h>
|
||||||
|
#define CREATE_TRACE_POINTS
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
unsigned cachefiles_debug;
|
unsigned cachefiles_debug;
|
||||||
|
|
|
@ -30,11 +30,11 @@
|
||||||
*/
|
*/
|
||||||
static noinline
|
static noinline
|
||||||
void __cachefiles_printk_object(struct cachefiles_object *object,
|
void __cachefiles_printk_object(struct cachefiles_object *object,
|
||||||
const char *prefix,
|
const char *prefix)
|
||||||
u8 *keybuf)
|
|
||||||
{
|
{
|
||||||
struct fscache_cookie *cookie;
|
struct fscache_cookie *cookie;
|
||||||
unsigned keylen, loop;
|
const u8 *k;
|
||||||
|
unsigned loop;
|
||||||
|
|
||||||
pr_err("%sobject: OBJ%x\n", prefix, object->fscache.debug_id);
|
pr_err("%sobject: OBJ%x\n", prefix, object->fscache.debug_id);
|
||||||
pr_err("%sobjstate=%s fl=%lx wbusy=%x ev=%lx[%lx]\n",
|
pr_err("%sobjstate=%s fl=%lx wbusy=%x ev=%lx[%lx]\n",
|
||||||
|
@ -56,23 +56,16 @@ void __cachefiles_printk_object(struct cachefiles_object *object,
|
||||||
object->fscache.cookie->parent,
|
object->fscache.cookie->parent,
|
||||||
object->fscache.cookie->netfs_data,
|
object->fscache.cookie->netfs_data,
|
||||||
object->fscache.cookie->flags);
|
object->fscache.cookie->flags);
|
||||||
if (keybuf && cookie->def)
|
pr_err("%skey=[%u] '", prefix, cookie->key_len);
|
||||||
keylen = cookie->def->get_key(cookie->netfs_data, keybuf,
|
k = (cookie->key_len <= sizeof(cookie->inline_key)) ?
|
||||||
CACHEFILES_KEYBUF_SIZE);
|
cookie->inline_key : cookie->key;
|
||||||
else
|
for (loop = 0; loop < cookie->key_len; loop++)
|
||||||
keylen = 0;
|
pr_cont("%02x", k[loop]);
|
||||||
|
pr_cont("'\n");
|
||||||
} else {
|
} else {
|
||||||
pr_err("%scookie=NULL\n", prefix);
|
pr_err("%scookie=NULL\n", prefix);
|
||||||
keylen = 0;
|
|
||||||
}
|
}
|
||||||
spin_unlock(&object->fscache.lock);
|
spin_unlock(&object->fscache.lock);
|
||||||
|
|
||||||
if (keylen) {
|
|
||||||
pr_err("%skey=[%u] '", prefix, keylen);
|
|
||||||
for (loop = 0; loop < keylen; loop++)
|
|
||||||
pr_cont("%02x", keybuf[loop]);
|
|
||||||
pr_cont("'\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -81,14 +74,10 @@ void __cachefiles_printk_object(struct cachefiles_object *object,
|
||||||
static noinline void cachefiles_printk_object(struct cachefiles_object *object,
|
static noinline void cachefiles_printk_object(struct cachefiles_object *object,
|
||||||
struct cachefiles_object *xobject)
|
struct cachefiles_object *xobject)
|
||||||
{
|
{
|
||||||
u8 *keybuf;
|
|
||||||
|
|
||||||
keybuf = kmalloc(CACHEFILES_KEYBUF_SIZE, GFP_NOIO);
|
|
||||||
if (object)
|
if (object)
|
||||||
__cachefiles_printk_object(object, "", keybuf);
|
__cachefiles_printk_object(object, "");
|
||||||
if (xobject)
|
if (xobject)
|
||||||
__cachefiles_printk_object(xobject, "x", keybuf);
|
__cachefiles_printk_object(xobject, "x");
|
||||||
kfree(keybuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -120,6 +109,7 @@ static void cachefiles_mark_object_buried(struct cachefiles_cache *cache,
|
||||||
}
|
}
|
||||||
|
|
||||||
write_unlock(&cache->active_lock);
|
write_unlock(&cache->active_lock);
|
||||||
|
trace_cachefiles_mark_buried(NULL, dentry, why);
|
||||||
_leave(" [no owner]");
|
_leave(" [no owner]");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -130,6 +120,8 @@ found_dentry:
|
||||||
object->fscache.state->name,
|
object->fscache.state->name,
|
||||||
dentry);
|
dentry);
|
||||||
|
|
||||||
|
trace_cachefiles_mark_buried(object, dentry, why);
|
||||||
|
|
||||||
if (fscache_object_is_live(&object->fscache)) {
|
if (fscache_object_is_live(&object->fscache)) {
|
||||||
pr_err("\n");
|
pr_err("\n");
|
||||||
pr_err("Error: Can't preemptively bury live object\n");
|
pr_err("Error: Can't preemptively bury live object\n");
|
||||||
|
@ -158,13 +150,15 @@ static int cachefiles_mark_object_active(struct cachefiles_cache *cache,
|
||||||
try_again:
|
try_again:
|
||||||
write_lock(&cache->active_lock);
|
write_lock(&cache->active_lock);
|
||||||
|
|
||||||
|
dentry = object->dentry;
|
||||||
|
trace_cachefiles_mark_active(object, dentry);
|
||||||
|
|
||||||
if (test_and_set_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags)) {
|
if (test_and_set_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags)) {
|
||||||
pr_err("Error: Object already active\n");
|
pr_err("Error: Object already active\n");
|
||||||
cachefiles_printk_object(object, NULL);
|
cachefiles_printk_object(object, NULL);
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
dentry = object->dentry;
|
|
||||||
_p = &cache->active_nodes.rb_node;
|
_p = &cache->active_nodes.rb_node;
|
||||||
while (*_p) {
|
while (*_p) {
|
||||||
_parent = *_p;
|
_parent = *_p;
|
||||||
|
@ -191,6 +185,8 @@ try_again:
|
||||||
/* an old object from a previous incarnation is hogging the slot - we
|
/* an old object from a previous incarnation is hogging the slot - we
|
||||||
* need to wait for it to be destroyed */
|
* need to wait for it to be destroyed */
|
||||||
wait_for_old_object:
|
wait_for_old_object:
|
||||||
|
trace_cachefiles_wait_active(object, dentry, xobject);
|
||||||
|
|
||||||
if (fscache_object_is_live(&xobject->fscache)) {
|
if (fscache_object_is_live(&xobject->fscache)) {
|
||||||
pr_err("\n");
|
pr_err("\n");
|
||||||
pr_err("Error: Unexpected object collision\n");
|
pr_err("Error: Unexpected object collision\n");
|
||||||
|
@ -248,12 +244,12 @@ wait_for_old_object:
|
||||||
|
|
||||||
ASSERT(!test_bit(CACHEFILES_OBJECT_ACTIVE, &xobject->flags));
|
ASSERT(!test_bit(CACHEFILES_OBJECT_ACTIVE, &xobject->flags));
|
||||||
|
|
||||||
cache->cache.ops->put_object(&xobject->fscache);
|
cache->cache.ops->put_object(&xobject->fscache, cachefiles_obj_put_wait_retry);
|
||||||
goto try_again;
|
goto try_again;
|
||||||
|
|
||||||
requeue:
|
requeue:
|
||||||
clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags);
|
clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags);
|
||||||
cache->cache.ops->put_object(&xobject->fscache);
|
cache->cache.ops->put_object(&xobject->fscache, cachefiles_obj_put_wait_timeo);
|
||||||
_leave(" = -ETIMEDOUT");
|
_leave(" = -ETIMEDOUT");
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
@ -265,6 +261,11 @@ void cachefiles_mark_object_inactive(struct cachefiles_cache *cache,
|
||||||
struct cachefiles_object *object,
|
struct cachefiles_object *object,
|
||||||
blkcnt_t i_blocks)
|
blkcnt_t i_blocks)
|
||||||
{
|
{
|
||||||
|
struct dentry *dentry = object->dentry;
|
||||||
|
struct inode *inode = d_backing_inode(dentry);
|
||||||
|
|
||||||
|
trace_cachefiles_mark_inactive(object, dentry, inode);
|
||||||
|
|
||||||
write_lock(&cache->active_lock);
|
write_lock(&cache->active_lock);
|
||||||
rb_erase(&object->active_node, &cache->active_nodes);
|
rb_erase(&object->active_node, &cache->active_nodes);
|
||||||
clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags);
|
clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags);
|
||||||
|
@ -288,6 +289,7 @@ void cachefiles_mark_object_inactive(struct cachefiles_cache *cache,
|
||||||
* - unlocks the directory mutex
|
* - unlocks the directory mutex
|
||||||
*/
|
*/
|
||||||
static int cachefiles_bury_object(struct cachefiles_cache *cache,
|
static int cachefiles_bury_object(struct cachefiles_cache *cache,
|
||||||
|
struct cachefiles_object *object,
|
||||||
struct dentry *dir,
|
struct dentry *dir,
|
||||||
struct dentry *rep,
|
struct dentry *rep,
|
||||||
bool preemptive,
|
bool preemptive,
|
||||||
|
@ -312,6 +314,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache,
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
cachefiles_io_error(cache, "Unlink security error");
|
cachefiles_io_error(cache, "Unlink security error");
|
||||||
} else {
|
} else {
|
||||||
|
trace_cachefiles_unlink(object, rep, why);
|
||||||
ret = vfs_unlink(d_inode(dir), rep, NULL);
|
ret = vfs_unlink(d_inode(dir), rep, NULL);
|
||||||
|
|
||||||
if (preemptive)
|
if (preemptive)
|
||||||
|
@ -413,6 +416,7 @@ try_again:
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
cachefiles_io_error(cache, "Rename security error %d", ret);
|
cachefiles_io_error(cache, "Rename security error %d", ret);
|
||||||
} else {
|
} else {
|
||||||
|
trace_cachefiles_rename(object, rep, grave, why);
|
||||||
ret = vfs_rename(d_inode(dir), rep,
|
ret = vfs_rename(d_inode(dir), rep,
|
||||||
d_inode(cache->graveyard), grave, NULL, 0);
|
d_inode(cache->graveyard), grave, NULL, 0);
|
||||||
if (ret != 0 && ret != -ENOMEM)
|
if (ret != 0 && ret != -ENOMEM)
|
||||||
|
@ -458,7 +462,7 @@ int cachefiles_delete_object(struct cachefiles_cache *cache,
|
||||||
/* we need to check that our parent is _still_ our parent - it
|
/* we need to check that our parent is _still_ our parent - it
|
||||||
* may have been renamed */
|
* may have been renamed */
|
||||||
if (dir == object->dentry->d_parent) {
|
if (dir == object->dentry->d_parent) {
|
||||||
ret = cachefiles_bury_object(cache, dir,
|
ret = cachefiles_bury_object(cache, object, dir,
|
||||||
object->dentry, false,
|
object->dentry, false,
|
||||||
FSCACHE_OBJECT_WAS_RETIRED);
|
FSCACHE_OBJECT_WAS_RETIRED);
|
||||||
} else {
|
} else {
|
||||||
|
@ -486,6 +490,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent,
|
||||||
{
|
{
|
||||||
struct cachefiles_cache *cache;
|
struct cachefiles_cache *cache;
|
||||||
struct dentry *dir, *next = NULL;
|
struct dentry *dir, *next = NULL;
|
||||||
|
struct inode *inode;
|
||||||
struct path path;
|
struct path path;
|
||||||
unsigned long start;
|
unsigned long start;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -529,13 +534,17 @@ lookup_again:
|
||||||
start = jiffies;
|
start = jiffies;
|
||||||
next = lookup_one_len(name, dir, nlen);
|
next = lookup_one_len(name, dir, nlen);
|
||||||
cachefiles_hist(cachefiles_lookup_histogram, start);
|
cachefiles_hist(cachefiles_lookup_histogram, start);
|
||||||
if (IS_ERR(next))
|
if (IS_ERR(next)) {
|
||||||
|
trace_cachefiles_lookup(object, next, NULL);
|
||||||
goto lookup_error;
|
goto lookup_error;
|
||||||
|
}
|
||||||
|
|
||||||
_debug("next -> %p %s", next, d_backing_inode(next) ? "positive" : "negative");
|
inode = d_backing_inode(next);
|
||||||
|
trace_cachefiles_lookup(object, next, inode);
|
||||||
|
_debug("next -> %p %s", next, inode ? "positive" : "negative");
|
||||||
|
|
||||||
if (!key)
|
if (!key)
|
||||||
object->new = !d_backing_inode(next);
|
object->new = !inode;
|
||||||
|
|
||||||
/* if this element of the path doesn't exist, then the lookup phase
|
/* if this element of the path doesn't exist, then the lookup phase
|
||||||
* failed, and we can release any readers in the certain knowledge that
|
* failed, and we can release any readers in the certain knowledge that
|
||||||
|
@ -558,6 +567,8 @@ lookup_again:
|
||||||
start = jiffies;
|
start = jiffies;
|
||||||
ret = vfs_mkdir(d_inode(dir), next, 0);
|
ret = vfs_mkdir(d_inode(dir), next, 0);
|
||||||
cachefiles_hist(cachefiles_mkdir_histogram, start);
|
cachefiles_hist(cachefiles_mkdir_histogram, start);
|
||||||
|
if (!key)
|
||||||
|
trace_cachefiles_mkdir(object, next, ret);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto create_error;
|
goto create_error;
|
||||||
|
|
||||||
|
@ -587,6 +598,7 @@ lookup_again:
|
||||||
start = jiffies;
|
start = jiffies;
|
||||||
ret = vfs_create(d_inode(dir), next, S_IFREG, true);
|
ret = vfs_create(d_inode(dir), next, S_IFREG, true);
|
||||||
cachefiles_hist(cachefiles_create_histogram, start);
|
cachefiles_hist(cachefiles_create_histogram, start);
|
||||||
|
trace_cachefiles_create(object, next, ret);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto create_error;
|
goto create_error;
|
||||||
|
|
||||||
|
@ -629,7 +641,8 @@ lookup_again:
|
||||||
* mutex) */
|
* mutex) */
|
||||||
object->dentry = NULL;
|
object->dentry = NULL;
|
||||||
|
|
||||||
ret = cachefiles_bury_object(cache, dir, next, true,
|
ret = cachefiles_bury_object(cache, object, dir, next,
|
||||||
|
true,
|
||||||
FSCACHE_OBJECT_IS_STALE);
|
FSCACHE_OBJECT_IS_STALE);
|
||||||
dput(next);
|
dput(next);
|
||||||
next = NULL;
|
next = NULL;
|
||||||
|
@ -955,7 +968,7 @@ int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir,
|
||||||
/* actually remove the victim (drops the dir mutex) */
|
/* actually remove the victim (drops the dir mutex) */
|
||||||
_debug("bury");
|
_debug("bury");
|
||||||
|
|
||||||
ret = cachefiles_bury_object(cache, dir, victim, false,
|
ret = cachefiles_bury_object(cache, NULL, dir, victim, false,
|
||||||
FSCACHE_OBJECT_WAS_CULLED);
|
FSCACHE_OBJECT_WAS_CULLED);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
|
@ -952,6 +952,7 @@ error:
|
||||||
* - cache withdrawal is prevented by the caller
|
* - cache withdrawal is prevented by the caller
|
||||||
*/
|
*/
|
||||||
void cachefiles_uncache_page(struct fscache_object *_object, struct page *page)
|
void cachefiles_uncache_page(struct fscache_object *_object, struct page *page)
|
||||||
|
__releases(&object->fscache.cookie->lock)
|
||||||
{
|
{
|
||||||
struct cachefiles_object *object;
|
struct cachefiles_object *object;
|
||||||
struct cachefiles_cache *cache;
|
struct cachefiles_cache *cache;
|
||||||
|
|
|
@ -113,6 +113,7 @@ int cachefiles_set_object_xattr(struct cachefiles_object *object,
|
||||||
/* attempt to install the cache metadata directly */
|
/* attempt to install the cache metadata directly */
|
||||||
_debug("SET #%u", auxdata->len);
|
_debug("SET #%u", auxdata->len);
|
||||||
|
|
||||||
|
clear_bit(FSCACHE_COOKIE_AUX_UPDATED, &object->fscache.cookie->flags);
|
||||||
ret = vfs_setxattr(dentry, cachefiles_xattr_cache,
|
ret = vfs_setxattr(dentry, cachefiles_xattr_cache,
|
||||||
&auxdata->type, auxdata->len,
|
&auxdata->type, auxdata->len,
|
||||||
XATTR_CREATE);
|
XATTR_CREATE);
|
||||||
|
@ -141,6 +142,7 @@ int cachefiles_update_object_xattr(struct cachefiles_object *object,
|
||||||
/* attempt to install the cache metadata directly */
|
/* attempt to install the cache metadata directly */
|
||||||
_debug("SET #%u", auxdata->len);
|
_debug("SET #%u", auxdata->len);
|
||||||
|
|
||||||
|
clear_bit(FSCACHE_COOKIE_AUX_UPDATED, &object->fscache.cookie->flags);
|
||||||
ret = vfs_setxattr(dentry, cachefiles_xattr_cache,
|
ret = vfs_setxattr(dentry, cachefiles_xattr_cache,
|
||||||
&auxdata->type, auxdata->len,
|
&auxdata->type, auxdata->len,
|
||||||
XATTR_REPLACE);
|
XATTR_REPLACE);
|
||||||
|
@ -180,7 +182,8 @@ int cachefiles_check_auxdata(struct cachefiles_object *object)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
xlen--;
|
xlen--;
|
||||||
validity = fscache_check_aux(&object->fscache, &auxbuf->data, xlen);
|
validity = fscache_check_aux(&object->fscache, &auxbuf->data, xlen,
|
||||||
|
i_size_read(d_backing_inode(dentry)));
|
||||||
if (validity != FSCACHE_CHECKAUX_OKAY)
|
if (validity != FSCACHE_CHECKAUX_OKAY)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -249,7 +252,8 @@ int cachefiles_check_object_xattr(struct cachefiles_object *object,
|
||||||
object->fscache.cookie->def->name, dlen);
|
object->fscache.cookie->def->name, dlen);
|
||||||
|
|
||||||
result = fscache_check_aux(&object->fscache,
|
result = fscache_check_aux(&object->fscache,
|
||||||
&auxbuf->data, dlen);
|
&auxbuf->data, dlen,
|
||||||
|
i_size_read(d_backing_inode(dentry)));
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
/* entry okay as is */
|
/* entry okay as is */
|
||||||
|
|
113
fs/ceph/cache.c
113
fs/ceph/cache.c
|
@ -27,7 +27,6 @@
|
||||||
struct ceph_aux_inode {
|
struct ceph_aux_inode {
|
||||||
u64 version;
|
u64 version;
|
||||||
struct timespec mtime;
|
struct timespec mtime;
|
||||||
loff_t size;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fscache_netfs ceph_cache_netfs = {
|
struct fscache_netfs ceph_cache_netfs = {
|
||||||
|
@ -41,34 +40,15 @@ static LIST_HEAD(ceph_fscache_list);
|
||||||
struct ceph_fscache_entry {
|
struct ceph_fscache_entry {
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
struct fscache_cookie *fscache;
|
struct fscache_cookie *fscache;
|
||||||
struct ceph_fsid fsid;
|
|
||||||
size_t uniq_len;
|
size_t uniq_len;
|
||||||
|
/* The following members must be last */
|
||||||
|
struct ceph_fsid fsid;
|
||||||
char uniquifier[0];
|
char uniquifier[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint16_t ceph_fscache_session_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t maxbuf)
|
|
||||||
{
|
|
||||||
const struct ceph_fs_client* fsc = cookie_netfs_data;
|
|
||||||
const char *fscache_uniq = fsc->mount_options->fscache_uniq;
|
|
||||||
uint16_t fsid_len, uniq_len;
|
|
||||||
|
|
||||||
fsid_len = sizeof(fsc->client->fsid);
|
|
||||||
uniq_len = fscache_uniq ? strlen(fscache_uniq) : 0;
|
|
||||||
if (fsid_len + uniq_len > maxbuf)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(buffer, &fsc->client->fsid, fsid_len);
|
|
||||||
if (uniq_len)
|
|
||||||
memcpy(buffer + fsid_len, fscache_uniq, uniq_len);
|
|
||||||
|
|
||||||
return fsid_len + uniq_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct fscache_cookie_def ceph_fscache_fsid_object_def = {
|
static const struct fscache_cookie_def ceph_fscache_fsid_object_def = {
|
||||||
.name = "CEPH.fsid",
|
.name = "CEPH.fsid",
|
||||||
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
||||||
.get_key = ceph_fscache_session_get_key,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int ceph_fscache_register(void)
|
int ceph_fscache_register(void)
|
||||||
|
@ -110,16 +90,19 @@ int ceph_fscache_register_fs(struct ceph_fs_client* fsc)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memcpy(&ent->fsid, fsid, sizeof(*fsid));
|
||||||
|
if (uniq_len > 0) {
|
||||||
|
memcpy(&ent->uniquifier, fscache_uniq, uniq_len);
|
||||||
|
ent->uniq_len = uniq_len;
|
||||||
|
}
|
||||||
|
|
||||||
fsc->fscache = fscache_acquire_cookie(ceph_cache_netfs.primary_index,
|
fsc->fscache = fscache_acquire_cookie(ceph_cache_netfs.primary_index,
|
||||||
&ceph_fscache_fsid_object_def,
|
&ceph_fscache_fsid_object_def,
|
||||||
fsc, true);
|
&ent->fsid, sizeof(ent->fsid) + uniq_len,
|
||||||
|
NULL, 0,
|
||||||
|
fsc, 0, true);
|
||||||
|
|
||||||
if (fsc->fscache) {
|
if (fsc->fscache) {
|
||||||
memcpy(&ent->fsid, fsid, sizeof(*fsid));
|
|
||||||
if (uniq_len > 0) {
|
|
||||||
memcpy(&ent->uniquifier, fscache_uniq, uniq_len);
|
|
||||||
ent->uniq_len = uniq_len;
|
|
||||||
}
|
|
||||||
ent->fscache = fsc->fscache;
|
ent->fscache = fsc->fscache;
|
||||||
list_add_tail(&ent->list, &ceph_fscache_list);
|
list_add_tail(&ent->list, &ceph_fscache_list);
|
||||||
} else {
|
} else {
|
||||||
|
@ -133,59 +116,21 @@ out_unlock:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t ceph_fscache_inode_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t maxbuf)
|
|
||||||
{
|
|
||||||
const struct ceph_inode_info* ci = cookie_netfs_data;
|
|
||||||
uint16_t klen;
|
|
||||||
|
|
||||||
/* use ceph virtual inode (id + snapshot) */
|
|
||||||
klen = sizeof(ci->i_vino);
|
|
||||||
if (klen > maxbuf)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(buffer, &ci->i_vino, klen);
|
|
||||||
return klen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint16_t ceph_fscache_inode_get_aux(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax)
|
|
||||||
{
|
|
||||||
struct ceph_aux_inode aux;
|
|
||||||
const struct ceph_inode_info* ci = cookie_netfs_data;
|
|
||||||
const struct inode* inode = &ci->vfs_inode;
|
|
||||||
|
|
||||||
memset(&aux, 0, sizeof(aux));
|
|
||||||
aux.version = ci->i_version;
|
|
||||||
aux.mtime = inode->i_mtime;
|
|
||||||
aux.size = i_size_read(inode);
|
|
||||||
|
|
||||||
memcpy(buffer, &aux, sizeof(aux));
|
|
||||||
|
|
||||||
return sizeof(aux);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ceph_fscache_inode_get_attr(const void *cookie_netfs_data,
|
|
||||||
uint64_t *size)
|
|
||||||
{
|
|
||||||
const struct ceph_inode_info* ci = cookie_netfs_data;
|
|
||||||
*size = i_size_read(&ci->vfs_inode);
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum fscache_checkaux ceph_fscache_inode_check_aux(
|
static enum fscache_checkaux ceph_fscache_inode_check_aux(
|
||||||
void *cookie_netfs_data, const void *data, uint16_t dlen)
|
void *cookie_netfs_data, const void *data, uint16_t dlen,
|
||||||
|
loff_t object_size)
|
||||||
{
|
{
|
||||||
struct ceph_aux_inode aux;
|
struct ceph_aux_inode aux;
|
||||||
struct ceph_inode_info* ci = cookie_netfs_data;
|
struct ceph_inode_info* ci = cookie_netfs_data;
|
||||||
struct inode* inode = &ci->vfs_inode;
|
struct inode* inode = &ci->vfs_inode;
|
||||||
|
|
||||||
if (dlen != sizeof(aux))
|
if (dlen != sizeof(aux) ||
|
||||||
|
i_size_read(inode) != object_size)
|
||||||
return FSCACHE_CHECKAUX_OBSOLETE;
|
return FSCACHE_CHECKAUX_OBSOLETE;
|
||||||
|
|
||||||
memset(&aux, 0, sizeof(aux));
|
memset(&aux, 0, sizeof(aux));
|
||||||
aux.version = ci->i_version;
|
aux.version = ci->i_version;
|
||||||
aux.mtime = inode->i_mtime;
|
aux.mtime = inode->i_mtime;
|
||||||
aux.size = i_size_read(inode);
|
|
||||||
|
|
||||||
if (memcmp(data, &aux, sizeof(aux)) != 0)
|
if (memcmp(data, &aux, sizeof(aux)) != 0)
|
||||||
return FSCACHE_CHECKAUX_OBSOLETE;
|
return FSCACHE_CHECKAUX_OBSOLETE;
|
||||||
|
@ -197,9 +142,6 @@ static enum fscache_checkaux ceph_fscache_inode_check_aux(
|
||||||
static const struct fscache_cookie_def ceph_fscache_inode_object_def = {
|
static const struct fscache_cookie_def ceph_fscache_inode_object_def = {
|
||||||
.name = "CEPH.inode",
|
.name = "CEPH.inode",
|
||||||
.type = FSCACHE_COOKIE_TYPE_DATAFILE,
|
.type = FSCACHE_COOKIE_TYPE_DATAFILE,
|
||||||
.get_key = ceph_fscache_inode_get_key,
|
|
||||||
.get_attr = ceph_fscache_inode_get_attr,
|
|
||||||
.get_aux = ceph_fscache_inode_get_aux,
|
|
||||||
.check_aux = ceph_fscache_inode_check_aux,
|
.check_aux = ceph_fscache_inode_check_aux,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -207,6 +149,7 @@ void ceph_fscache_register_inode_cookie(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct ceph_inode_info *ci = ceph_inode(inode);
|
struct ceph_inode_info *ci = ceph_inode(inode);
|
||||||
struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
|
struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
|
||||||
|
struct ceph_aux_inode aux;
|
||||||
|
|
||||||
/* No caching for filesystem */
|
/* No caching for filesystem */
|
||||||
if (!fsc->fscache)
|
if (!fsc->fscache)
|
||||||
|
@ -218,9 +161,14 @@ void ceph_fscache_register_inode_cookie(struct inode *inode)
|
||||||
|
|
||||||
inode_lock_nested(inode, I_MUTEX_CHILD);
|
inode_lock_nested(inode, I_MUTEX_CHILD);
|
||||||
if (!ci->fscache) {
|
if (!ci->fscache) {
|
||||||
|
memset(&aux, 0, sizeof(aux));
|
||||||
|
aux.version = ci->i_version;
|
||||||
|
aux.mtime = inode->i_mtime;
|
||||||
ci->fscache = fscache_acquire_cookie(fsc->fscache,
|
ci->fscache = fscache_acquire_cookie(fsc->fscache,
|
||||||
&ceph_fscache_inode_object_def,
|
&ceph_fscache_inode_object_def,
|
||||||
ci, false);
|
&ci->i_vino, sizeof(ci->i_vino),
|
||||||
|
&aux, sizeof(aux),
|
||||||
|
ci, i_size_read(inode), false);
|
||||||
}
|
}
|
||||||
inode_unlock(inode);
|
inode_unlock(inode);
|
||||||
}
|
}
|
||||||
|
@ -235,7 +183,7 @@ void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci)
|
||||||
ci->fscache = NULL;
|
ci->fscache = NULL;
|
||||||
|
|
||||||
fscache_uncache_all_inode_pages(cookie, &ci->vfs_inode);
|
fscache_uncache_all_inode_pages(cookie, &ci->vfs_inode);
|
||||||
fscache_relinquish_cookie(cookie, 0);
|
fscache_relinquish_cookie(cookie, &ci->i_vino, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ceph_fscache_can_enable(void *data)
|
static bool ceph_fscache_can_enable(void *data)
|
||||||
|
@ -254,11 +202,11 @@ void ceph_fscache_file_set_cookie(struct inode *inode, struct file *filp)
|
||||||
if (inode_is_open_for_write(inode)) {
|
if (inode_is_open_for_write(inode)) {
|
||||||
dout("fscache_file_set_cookie %p %p disabling cache\n",
|
dout("fscache_file_set_cookie %p %p disabling cache\n",
|
||||||
inode, filp);
|
inode, filp);
|
||||||
fscache_disable_cookie(ci->fscache, false);
|
fscache_disable_cookie(ci->fscache, &ci->i_vino, false);
|
||||||
fscache_uncache_all_inode_pages(ci->fscache, inode);
|
fscache_uncache_all_inode_pages(ci->fscache, inode);
|
||||||
} else {
|
} else {
|
||||||
fscache_enable_cookie(ci->fscache, ceph_fscache_can_enable,
|
fscache_enable_cookie(ci->fscache, &ci->i_vino, i_size_read(inode),
|
||||||
inode);
|
ceph_fscache_can_enable, inode);
|
||||||
if (fscache_cookie_enabled(ci->fscache)) {
|
if (fscache_cookie_enabled(ci->fscache)) {
|
||||||
dout("fscache_file_set_cookie %p %p enabling cache\n",
|
dout("fscache_file_set_cookie %p %p enabling cache\n",
|
||||||
inode, filp);
|
inode, filp);
|
||||||
|
@ -351,7 +299,8 @@ void ceph_readpage_to_fscache(struct inode *inode, struct page *page)
|
||||||
if (!cache_valid(ci))
|
if (!cache_valid(ci))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ret = fscache_write_page(ci->fscache, page, GFP_KERNEL);
|
ret = fscache_write_page(ci->fscache, page, i_size_read(inode),
|
||||||
|
GFP_KERNEL);
|
||||||
if (ret)
|
if (ret)
|
||||||
fscache_uncache_page(ci->fscache, page);
|
fscache_uncache_page(ci->fscache, page);
|
||||||
}
|
}
|
||||||
|
@ -385,7 +334,7 @@ void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc)
|
||||||
WARN_ON_ONCE(!found);
|
WARN_ON_ONCE(!found);
|
||||||
mutex_unlock(&ceph_fscache_lock);
|
mutex_unlock(&ceph_fscache_lock);
|
||||||
|
|
||||||
__fscache_relinquish_cookie(fsc->fscache, 0);
|
__fscache_relinquish_cookie(fsc->fscache, NULL, false);
|
||||||
}
|
}
|
||||||
fsc->fscache = NULL;
|
fsc->fscache = NULL;
|
||||||
}
|
}
|
||||||
|
@ -402,7 +351,7 @@ void ceph_fscache_revalidate_cookie(struct ceph_inode_info *ci)
|
||||||
* truncate while the caller holds CEPH_CAP_FILE_RD */
|
* truncate while the caller holds CEPH_CAP_FILE_RD */
|
||||||
mutex_lock(&ci->i_truncate_mutex);
|
mutex_lock(&ci->i_truncate_mutex);
|
||||||
if (!cache_valid(ci)) {
|
if (!cache_valid(ci)) {
|
||||||
if (fscache_check_consistency(ci->fscache))
|
if (fscache_check_consistency(ci->fscache, &ci->i_vino))
|
||||||
fscache_invalidate(ci->fscache);
|
fscache_invalidate(ci->fscache);
|
||||||
spin_lock(&ci->i_ceph_lock);
|
spin_lock(&ci->i_ceph_lock);
|
||||||
ci->i_fscache_gen = ci->i_rdcache_gen;
|
ci->i_fscache_gen = ci->i_rdcache_gen;
|
||||||
|
|
168
fs/cifs/cache.c
168
fs/cifs/cache.c
|
@ -45,68 +45,12 @@ void cifs_fscache_unregister(void)
|
||||||
fscache_unregister_netfs(&cifs_fscache_netfs);
|
fscache_unregister_netfs(&cifs_fscache_netfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Key layout of CIFS server cache index object
|
|
||||||
*/
|
|
||||||
struct cifs_server_key {
|
|
||||||
uint16_t family; /* address family */
|
|
||||||
__be16 port; /* IP port */
|
|
||||||
union {
|
|
||||||
struct in_addr ipv4_addr;
|
|
||||||
struct in6_addr ipv6_addr;
|
|
||||||
} addr[0];
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Server object keyed by {IPaddress,port,family} tuple
|
|
||||||
*/
|
|
||||||
static uint16_t cifs_server_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t maxbuf)
|
|
||||||
{
|
|
||||||
const struct TCP_Server_Info *server = cookie_netfs_data;
|
|
||||||
const struct sockaddr *sa = (struct sockaddr *) &server->dstaddr;
|
|
||||||
const struct sockaddr_in *addr = (struct sockaddr_in *) sa;
|
|
||||||
const struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) sa;
|
|
||||||
struct cifs_server_key *key = buffer;
|
|
||||||
uint16_t key_len = sizeof(struct cifs_server_key);
|
|
||||||
|
|
||||||
memset(key, 0, key_len);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Should not be a problem as sin_family/sin6_family overlays
|
|
||||||
* sa_family field
|
|
||||||
*/
|
|
||||||
switch (sa->sa_family) {
|
|
||||||
case AF_INET:
|
|
||||||
key->family = sa->sa_family;
|
|
||||||
key->port = addr->sin_port;
|
|
||||||
key->addr[0].ipv4_addr = addr->sin_addr;
|
|
||||||
key_len += sizeof(key->addr[0].ipv4_addr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AF_INET6:
|
|
||||||
key->family = sa->sa_family;
|
|
||||||
key->port = addr6->sin6_port;
|
|
||||||
key->addr[0].ipv6_addr = addr6->sin6_addr;
|
|
||||||
key_len += sizeof(key->addr[0].ipv6_addr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
cifs_dbg(VFS, "Unknown network family '%d'\n", sa->sa_family);
|
|
||||||
key_len = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return key_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Server object for FS-Cache
|
* Server object for FS-Cache
|
||||||
*/
|
*/
|
||||||
const struct fscache_cookie_def cifs_fscache_server_index_def = {
|
const struct fscache_cookie_def cifs_fscache_server_index_def = {
|
||||||
.name = "CIFS.server",
|
.name = "CIFS.server",
|
||||||
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
||||||
.get_key = cifs_server_get_key,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -116,7 +60,7 @@ struct cifs_fscache_super_auxdata {
|
||||||
u64 resource_id; /* unique server resource id */
|
u64 resource_id; /* unique server resource id */
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *extract_sharename(const char *treename)
|
char *extract_sharename(const char *treename)
|
||||||
{
|
{
|
||||||
const char *src;
|
const char *src;
|
||||||
char *delim, *dst;
|
char *delim, *dst;
|
||||||
|
@ -140,56 +84,11 @@ static char *extract_sharename(const char *treename)
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Superblock object currently keyed by share name
|
|
||||||
*/
|
|
||||||
static uint16_t cifs_super_get_key(const void *cookie_netfs_data, void *buffer,
|
|
||||||
uint16_t maxbuf)
|
|
||||||
{
|
|
||||||
const struct cifs_tcon *tcon = cookie_netfs_data;
|
|
||||||
char *sharename;
|
|
||||||
uint16_t len;
|
|
||||||
|
|
||||||
sharename = extract_sharename(tcon->treeName);
|
|
||||||
if (IS_ERR(sharename)) {
|
|
||||||
cifs_dbg(FYI, "%s: couldn't extract sharename\n", __func__);
|
|
||||||
sharename = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
len = strlen(sharename);
|
|
||||||
if (len > maxbuf)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(buffer, sharename, len);
|
|
||||||
|
|
||||||
kfree(sharename);
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint16_t
|
|
||||||
cifs_fscache_super_get_aux(const void *cookie_netfs_data, void *buffer,
|
|
||||||
uint16_t maxbuf)
|
|
||||||
{
|
|
||||||
struct cifs_fscache_super_auxdata auxdata;
|
|
||||||
const struct cifs_tcon *tcon = cookie_netfs_data;
|
|
||||||
|
|
||||||
memset(&auxdata, 0, sizeof(auxdata));
|
|
||||||
auxdata.resource_id = tcon->resource_id;
|
|
||||||
|
|
||||||
if (maxbuf > sizeof(auxdata))
|
|
||||||
maxbuf = sizeof(auxdata);
|
|
||||||
|
|
||||||
memcpy(buffer, &auxdata, maxbuf);
|
|
||||||
|
|
||||||
return maxbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum
|
static enum
|
||||||
fscache_checkaux cifs_fscache_super_check_aux(void *cookie_netfs_data,
|
fscache_checkaux cifs_fscache_super_check_aux(void *cookie_netfs_data,
|
||||||
const void *data,
|
const void *data,
|
||||||
uint16_t datalen)
|
uint16_t datalen,
|
||||||
|
loff_t object_size)
|
||||||
{
|
{
|
||||||
struct cifs_fscache_super_auxdata auxdata;
|
struct cifs_fscache_super_auxdata auxdata;
|
||||||
const struct cifs_tcon *tcon = cookie_netfs_data;
|
const struct cifs_tcon *tcon = cookie_netfs_data;
|
||||||
|
@ -212,68 +111,14 @@ fscache_checkaux cifs_fscache_super_check_aux(void *cookie_netfs_data,
|
||||||
const struct fscache_cookie_def cifs_fscache_super_index_def = {
|
const struct fscache_cookie_def cifs_fscache_super_index_def = {
|
||||||
.name = "CIFS.super",
|
.name = "CIFS.super",
|
||||||
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
||||||
.get_key = cifs_super_get_key,
|
|
||||||
.get_aux = cifs_fscache_super_get_aux,
|
|
||||||
.check_aux = cifs_fscache_super_check_aux,
|
.check_aux = cifs_fscache_super_check_aux,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Auxiliary data attached to CIFS inode within the cache
|
|
||||||
*/
|
|
||||||
struct cifs_fscache_inode_auxdata {
|
|
||||||
struct timespec last_write_time;
|
|
||||||
struct timespec last_change_time;
|
|
||||||
u64 eof;
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint16_t cifs_fscache_inode_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t maxbuf)
|
|
||||||
{
|
|
||||||
const struct cifsInodeInfo *cifsi = cookie_netfs_data;
|
|
||||||
uint16_t keylen;
|
|
||||||
|
|
||||||
/* use the UniqueId as the key */
|
|
||||||
keylen = sizeof(cifsi->uniqueid);
|
|
||||||
if (keylen > maxbuf)
|
|
||||||
keylen = 0;
|
|
||||||
else
|
|
||||||
memcpy(buffer, &cifsi->uniqueid, keylen);
|
|
||||||
|
|
||||||
return keylen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cifs_fscache_inode_get_attr(const void *cookie_netfs_data, uint64_t *size)
|
|
||||||
{
|
|
||||||
const struct cifsInodeInfo *cifsi = cookie_netfs_data;
|
|
||||||
|
|
||||||
*size = cifsi->vfs_inode.i_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint16_t
|
|
||||||
cifs_fscache_inode_get_aux(const void *cookie_netfs_data, void *buffer,
|
|
||||||
uint16_t maxbuf)
|
|
||||||
{
|
|
||||||
struct cifs_fscache_inode_auxdata auxdata;
|
|
||||||
const struct cifsInodeInfo *cifsi = cookie_netfs_data;
|
|
||||||
|
|
||||||
memset(&auxdata, 0, sizeof(auxdata));
|
|
||||||
auxdata.eof = cifsi->server_eof;
|
|
||||||
auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
|
|
||||||
auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
|
|
||||||
|
|
||||||
if (maxbuf > sizeof(auxdata))
|
|
||||||
maxbuf = sizeof(auxdata);
|
|
||||||
|
|
||||||
memcpy(buffer, &auxdata, maxbuf);
|
|
||||||
|
|
||||||
return maxbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum
|
static enum
|
||||||
fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
|
fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
|
||||||
const void *data,
|
const void *data,
|
||||||
uint16_t datalen)
|
uint16_t datalen,
|
||||||
|
loff_t object_size)
|
||||||
{
|
{
|
||||||
struct cifs_fscache_inode_auxdata auxdata;
|
struct cifs_fscache_inode_auxdata auxdata;
|
||||||
struct cifsInodeInfo *cifsi = cookie_netfs_data;
|
struct cifsInodeInfo *cifsi = cookie_netfs_data;
|
||||||
|
@ -295,8 +140,5 @@ fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
|
||||||
const struct fscache_cookie_def cifs_fscache_inode_object_def = {
|
const struct fscache_cookie_def cifs_fscache_inode_object_def = {
|
||||||
.name = "CIFS.uniqueid",
|
.name = "CIFS.uniqueid",
|
||||||
.type = FSCACHE_COOKIE_TYPE_DATAFILE,
|
.type = FSCACHE_COOKIE_TYPE_DATAFILE,
|
||||||
.get_key = cifs_fscache_inode_get_key,
|
|
||||||
.get_attr = cifs_fscache_inode_get_attr,
|
|
||||||
.get_aux = cifs_fscache_inode_get_aux,
|
|
||||||
.check_aux = cifs_fscache_inode_check_aux,
|
.check_aux = cifs_fscache_inode_check_aux,
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,11 +23,63 @@
|
||||||
#include "cifs_debug.h"
|
#include "cifs_debug.h"
|
||||||
#include "cifs_fs_sb.h"
|
#include "cifs_fs_sb.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Key layout of CIFS server cache index object
|
||||||
|
*/
|
||||||
|
struct cifs_server_key {
|
||||||
|
struct {
|
||||||
|
uint16_t family; /* address family */
|
||||||
|
__be16 port; /* IP port */
|
||||||
|
} hdr;
|
||||||
|
union {
|
||||||
|
struct in_addr ipv4_addr;
|
||||||
|
struct in6_addr ipv6_addr;
|
||||||
|
};
|
||||||
|
} __packed;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get a cookie for a server object keyed by {IPaddress,port,family} tuple
|
||||||
|
*/
|
||||||
void cifs_fscache_get_client_cookie(struct TCP_Server_Info *server)
|
void cifs_fscache_get_client_cookie(struct TCP_Server_Info *server)
|
||||||
{
|
{
|
||||||
|
const struct sockaddr *sa = (struct sockaddr *) &server->dstaddr;
|
||||||
|
const struct sockaddr_in *addr = (struct sockaddr_in *) sa;
|
||||||
|
const struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) sa;
|
||||||
|
struct cifs_server_key key;
|
||||||
|
uint16_t key_len = sizeof(key.hdr);
|
||||||
|
|
||||||
|
memset(&key, 0, sizeof(key));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Should not be a problem as sin_family/sin6_family overlays
|
||||||
|
* sa_family field
|
||||||
|
*/
|
||||||
|
key.hdr.family = sa->sa_family;
|
||||||
|
switch (sa->sa_family) {
|
||||||
|
case AF_INET:
|
||||||
|
key.hdr.port = addr->sin_port;
|
||||||
|
key.ipv4_addr = addr->sin_addr;
|
||||||
|
key_len += sizeof(key.ipv4_addr);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AF_INET6:
|
||||||
|
key.hdr.port = addr6->sin6_port;
|
||||||
|
key.ipv6_addr = addr6->sin6_addr;
|
||||||
|
key_len += sizeof(key.ipv6_addr);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
cifs_dbg(VFS, "Unknown network family '%d'\n", sa->sa_family);
|
||||||
|
server->fscache = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
server->fscache =
|
server->fscache =
|
||||||
fscache_acquire_cookie(cifs_fscache_netfs.primary_index,
|
fscache_acquire_cookie(cifs_fscache_netfs.primary_index,
|
||||||
&cifs_fscache_server_index_def, server, true);
|
&cifs_fscache_server_index_def,
|
||||||
|
&key, key_len,
|
||||||
|
NULL, 0,
|
||||||
|
server, 0, true);
|
||||||
cifs_dbg(FYI, "%s: (0x%p/0x%p)\n",
|
cifs_dbg(FYI, "%s: (0x%p/0x%p)\n",
|
||||||
__func__, server, server->fscache);
|
__func__, server, server->fscache);
|
||||||
}
|
}
|
||||||
|
@ -36,17 +88,29 @@ void cifs_fscache_release_client_cookie(struct TCP_Server_Info *server)
|
||||||
{
|
{
|
||||||
cifs_dbg(FYI, "%s: (0x%p/0x%p)\n",
|
cifs_dbg(FYI, "%s: (0x%p/0x%p)\n",
|
||||||
__func__, server, server->fscache);
|
__func__, server, server->fscache);
|
||||||
fscache_relinquish_cookie(server->fscache, 0);
|
fscache_relinquish_cookie(server->fscache, NULL, false);
|
||||||
server->fscache = NULL;
|
server->fscache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
|
void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
|
||||||
{
|
{
|
||||||
struct TCP_Server_Info *server = tcon->ses->server;
|
struct TCP_Server_Info *server = tcon->ses->server;
|
||||||
|
char *sharename;
|
||||||
|
|
||||||
|
sharename = extract_sharename(tcon->treeName);
|
||||||
|
if (IS_ERR(sharename)) {
|
||||||
|
cifs_dbg(FYI, "%s: couldn't extract sharename\n", __func__);
|
||||||
|
tcon->fscache = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tcon->fscache =
|
tcon->fscache =
|
||||||
fscache_acquire_cookie(server->fscache,
|
fscache_acquire_cookie(server->fscache,
|
||||||
&cifs_fscache_super_index_def, tcon, true);
|
&cifs_fscache_super_index_def,
|
||||||
|
sharename, strlen(sharename),
|
||||||
|
&tcon->resource_id, sizeof(tcon->resource_id),
|
||||||
|
tcon, 0, true);
|
||||||
|
kfree(sharename);
|
||||||
cifs_dbg(FYI, "%s: (0x%p/0x%p)\n",
|
cifs_dbg(FYI, "%s: (0x%p/0x%p)\n",
|
||||||
__func__, server->fscache, tcon->fscache);
|
__func__, server->fscache, tcon->fscache);
|
||||||
}
|
}
|
||||||
|
@ -54,10 +118,28 @@ void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
|
||||||
void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon)
|
void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon)
|
||||||
{
|
{
|
||||||
cifs_dbg(FYI, "%s: (0x%p)\n", __func__, tcon->fscache);
|
cifs_dbg(FYI, "%s: (0x%p)\n", __func__, tcon->fscache);
|
||||||
fscache_relinquish_cookie(tcon->fscache, 0);
|
fscache_relinquish_cookie(tcon->fscache, &tcon->resource_id, false);
|
||||||
tcon->fscache = NULL;
|
tcon->fscache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cifs_fscache_acquire_inode_cookie(struct cifsInodeInfo *cifsi,
|
||||||
|
struct cifs_tcon *tcon)
|
||||||
|
{
|
||||||
|
struct cifs_fscache_inode_auxdata auxdata;
|
||||||
|
|
||||||
|
memset(&auxdata, 0, sizeof(auxdata));
|
||||||
|
auxdata.eof = cifsi->server_eof;
|
||||||
|
auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
|
||||||
|
auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
|
||||||
|
|
||||||
|
cifsi->fscache =
|
||||||
|
fscache_acquire_cookie(tcon->fscache,
|
||||||
|
&cifs_fscache_inode_object_def,
|
||||||
|
&cifsi->uniqueid, sizeof(cifsi->uniqueid),
|
||||||
|
&auxdata, sizeof(auxdata),
|
||||||
|
cifsi, cifsi->vfs_inode.i_size, true);
|
||||||
|
}
|
||||||
|
|
||||||
static void cifs_fscache_enable_inode_cookie(struct inode *inode)
|
static void cifs_fscache_enable_inode_cookie(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct cifsInodeInfo *cifsi = CIFS_I(inode);
|
struct cifsInodeInfo *cifsi = CIFS_I(inode);
|
||||||
|
@ -67,21 +149,28 @@ static void cifs_fscache_enable_inode_cookie(struct inode *inode)
|
||||||
if (cifsi->fscache)
|
if (cifsi->fscache)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE) {
|
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE))
|
||||||
cifsi->fscache = fscache_acquire_cookie(tcon->fscache,
|
return;
|
||||||
&cifs_fscache_inode_object_def, cifsi, true);
|
|
||||||
cifs_dbg(FYI, "%s: got FH cookie (0x%p/0x%p)\n",
|
cifs_fscache_acquire_inode_cookie(cifsi, tcon);
|
||||||
__func__, tcon->fscache, cifsi->fscache);
|
|
||||||
}
|
cifs_dbg(FYI, "%s: got FH cookie (0x%p/0x%p)\n",
|
||||||
|
__func__, tcon->fscache, cifsi->fscache);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cifs_fscache_release_inode_cookie(struct inode *inode)
|
void cifs_fscache_release_inode_cookie(struct inode *inode)
|
||||||
{
|
{
|
||||||
|
struct cifs_fscache_inode_auxdata auxdata;
|
||||||
struct cifsInodeInfo *cifsi = CIFS_I(inode);
|
struct cifsInodeInfo *cifsi = CIFS_I(inode);
|
||||||
|
|
||||||
if (cifsi->fscache) {
|
if (cifsi->fscache) {
|
||||||
|
memset(&auxdata, 0, sizeof(auxdata));
|
||||||
|
auxdata.eof = cifsi->server_eof;
|
||||||
|
auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
|
||||||
|
auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
|
||||||
|
|
||||||
cifs_dbg(FYI, "%s: (0x%p)\n", __func__, cifsi->fscache);
|
cifs_dbg(FYI, "%s: (0x%p)\n", __func__, cifsi->fscache);
|
||||||
fscache_relinquish_cookie(cifsi->fscache, 0);
|
fscache_relinquish_cookie(cifsi->fscache, &auxdata, false);
|
||||||
cifsi->fscache = NULL;
|
cifsi->fscache = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +182,7 @@ static void cifs_fscache_disable_inode_cookie(struct inode *inode)
|
||||||
if (cifsi->fscache) {
|
if (cifsi->fscache) {
|
||||||
cifs_dbg(FYI, "%s: (0x%p)\n", __func__, cifsi->fscache);
|
cifs_dbg(FYI, "%s: (0x%p)\n", __func__, cifsi->fscache);
|
||||||
fscache_uncache_all_inode_pages(cifsi->fscache, inode);
|
fscache_uncache_all_inode_pages(cifsi->fscache, inode);
|
||||||
fscache_relinquish_cookie(cifsi->fscache, 1);
|
fscache_relinquish_cookie(cifsi->fscache, NULL, true);
|
||||||
cifsi->fscache = NULL;
|
cifsi->fscache = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,16 +199,14 @@ void cifs_fscache_reset_inode_cookie(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct cifsInodeInfo *cifsi = CIFS_I(inode);
|
struct cifsInodeInfo *cifsi = CIFS_I(inode);
|
||||||
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
|
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
|
||||||
|
struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
|
||||||
struct fscache_cookie *old = cifsi->fscache;
|
struct fscache_cookie *old = cifsi->fscache;
|
||||||
|
|
||||||
if (cifsi->fscache) {
|
if (cifsi->fscache) {
|
||||||
/* retire the current fscache cache and get a new one */
|
/* retire the current fscache cache and get a new one */
|
||||||
fscache_relinquish_cookie(cifsi->fscache, 1);
|
fscache_relinquish_cookie(cifsi->fscache, NULL, true);
|
||||||
|
|
||||||
cifsi->fscache = fscache_acquire_cookie(
|
cifs_fscache_acquire_inode_cookie(cifsi, tcon);
|
||||||
cifs_sb_master_tcon(cifs_sb)->fscache,
|
|
||||||
&cifs_fscache_inode_object_def,
|
|
||||||
cifsi, true);
|
|
||||||
cifs_dbg(FYI, "%s: new cookie 0x%p oldcookie 0x%p\n",
|
cifs_dbg(FYI, "%s: new cookie 0x%p oldcookie 0x%p\n",
|
||||||
__func__, cifsi->fscache, old);
|
__func__, cifsi->fscache, old);
|
||||||
}
|
}
|
||||||
|
@ -214,13 +301,15 @@ int __cifs_readpages_from_fscache(struct inode *inode,
|
||||||
|
|
||||||
void __cifs_readpage_to_fscache(struct inode *inode, struct page *page)
|
void __cifs_readpage_to_fscache(struct inode *inode, struct page *page)
|
||||||
{
|
{
|
||||||
|
struct cifsInodeInfo *cifsi = CIFS_I(inode);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
cifs_dbg(FYI, "%s: (fsc: %p, p: %p, i: %p)\n",
|
cifs_dbg(FYI, "%s: (fsc: %p, p: %p, i: %p)\n",
|
||||||
__func__, CIFS_I(inode)->fscache, page, inode);
|
__func__, cifsi->fscache, page, inode);
|
||||||
ret = fscache_write_page(CIFS_I(inode)->fscache, page, GFP_KERNEL);
|
ret = fscache_write_page(cifsi->fscache, page,
|
||||||
|
cifsi->vfs_inode.i_size, GFP_KERNEL);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
fscache_uncache_page(CIFS_I(inode)->fscache, page);
|
fscache_uncache_page(cifsi->fscache, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __cifs_fscache_readpages_cancel(struct inode *inode, struct list_head *pages)
|
void __cifs_fscache_readpages_cancel(struct inode *inode, struct list_head *pages)
|
||||||
|
@ -239,4 +328,3 @@ void __cifs_fscache_invalidate_page(struct page *page, struct inode *inode)
|
||||||
fscache_wait_on_page_write(cookie, page);
|
fscache_wait_on_page_write(cookie, page);
|
||||||
fscache_uncache_page(cookie, page);
|
fscache_uncache_page(cookie, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,18 @@
|
||||||
|
|
||||||
#ifdef CONFIG_CIFS_FSCACHE
|
#ifdef CONFIG_CIFS_FSCACHE
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Auxiliary data attached to CIFS inode within the cache
|
||||||
|
*/
|
||||||
|
struct cifs_fscache_inode_auxdata {
|
||||||
|
struct timespec last_write_time;
|
||||||
|
struct timespec last_change_time;
|
||||||
|
u64 eof;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* cache.c
|
||||||
|
*/
|
||||||
extern struct fscache_netfs cifs_fscache_netfs;
|
extern struct fscache_netfs cifs_fscache_netfs;
|
||||||
extern const struct fscache_cookie_def cifs_fscache_server_index_def;
|
extern const struct fscache_cookie_def cifs_fscache_server_index_def;
|
||||||
extern const struct fscache_cookie_def cifs_fscache_super_index_def;
|
extern const struct fscache_cookie_def cifs_fscache_super_index_def;
|
||||||
|
@ -34,6 +46,7 @@ extern const struct fscache_cookie_def cifs_fscache_inode_object_def;
|
||||||
|
|
||||||
extern int cifs_fscache_register(void);
|
extern int cifs_fscache_register(void);
|
||||||
extern void cifs_fscache_unregister(void);
|
extern void cifs_fscache_unregister(void);
|
||||||
|
extern char *extract_sharename(const char *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fscache.c
|
* fscache.c
|
||||||
|
|
|
@ -125,7 +125,7 @@ struct fscache_cache *fscache_select_cache_for_object(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the parent is unbacked */
|
/* the parent is unbacked */
|
||||||
if (cookie->def->type != FSCACHE_COOKIE_TYPE_INDEX) {
|
if (cookie->type != FSCACHE_COOKIE_TYPE_INDEX) {
|
||||||
/* cookie not an index and is unbacked */
|
/* cookie not an index and is unbacked */
|
||||||
spin_unlock(&cookie->lock);
|
spin_unlock(&cookie->lock);
|
||||||
_leave(" = NULL [cookie ub,ni]");
|
_leave(" = NULL [cookie ub,ni]");
|
||||||
|
|
|
@ -21,12 +21,54 @@ struct kmem_cache *fscache_cookie_jar;
|
||||||
|
|
||||||
static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
|
static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
|
||||||
|
|
||||||
static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
|
#define fscache_cookie_hash_shift 15
|
||||||
|
static struct hlist_bl_head fscache_cookie_hash[1 << fscache_cookie_hash_shift];
|
||||||
|
|
||||||
|
static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie,
|
||||||
|
loff_t object_size);
|
||||||
static int fscache_alloc_object(struct fscache_cache *cache,
|
static int fscache_alloc_object(struct fscache_cache *cache,
|
||||||
struct fscache_cookie *cookie);
|
struct fscache_cookie *cookie);
|
||||||
static int fscache_attach_object(struct fscache_cookie *cookie,
|
static int fscache_attach_object(struct fscache_cookie *cookie,
|
||||||
struct fscache_object *object);
|
struct fscache_object *object);
|
||||||
|
|
||||||
|
static void fscache_print_cookie(struct fscache_cookie *cookie, char prefix)
|
||||||
|
{
|
||||||
|
struct hlist_node *object;
|
||||||
|
const u8 *k;
|
||||||
|
unsigned loop;
|
||||||
|
|
||||||
|
pr_err("%c-cookie c=%p [p=%p fl=%lx nc=%u na=%u]\n",
|
||||||
|
prefix, cookie, cookie->parent, cookie->flags,
|
||||||
|
atomic_read(&cookie->n_children),
|
||||||
|
atomic_read(&cookie->n_active));
|
||||||
|
pr_err("%c-cookie d=%p n=%p\n",
|
||||||
|
prefix, cookie->def, cookie->netfs_data);
|
||||||
|
|
||||||
|
object = READ_ONCE(cookie->backing_objects.first);
|
||||||
|
if (object)
|
||||||
|
pr_err("%c-cookie o=%p\n",
|
||||||
|
prefix, hlist_entry(object, struct fscache_object, cookie_link));
|
||||||
|
|
||||||
|
pr_err("%c-key=[%u] '", prefix, cookie->key_len);
|
||||||
|
k = (cookie->key_len <= sizeof(cookie->inline_key)) ?
|
||||||
|
cookie->inline_key : cookie->key;
|
||||||
|
for (loop = 0; loop < cookie->key_len; loop++)
|
||||||
|
pr_cont("%02x", k[loop]);
|
||||||
|
pr_cont("'\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void fscache_free_cookie(struct fscache_cookie *cookie)
|
||||||
|
{
|
||||||
|
if (cookie) {
|
||||||
|
BUG_ON(!hlist_empty(&cookie->backing_objects));
|
||||||
|
if (cookie->aux_len > sizeof(cookie->inline_aux))
|
||||||
|
kfree(cookie->aux);
|
||||||
|
if (cookie->key_len > sizeof(cookie->inline_key))
|
||||||
|
kfree(cookie->key);
|
||||||
|
kmem_cache_free(fscache_cookie_jar, cookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialise an cookie jar slab element prior to any use
|
* initialise an cookie jar slab element prior to any use
|
||||||
*/
|
*/
|
||||||
|
@ -40,6 +82,170 @@ void fscache_cookie_init_once(void *_cookie)
|
||||||
INIT_HLIST_HEAD(&cookie->backing_objects);
|
INIT_HLIST_HEAD(&cookie->backing_objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the index key in a cookie. The cookie struct has space for a 12-byte
|
||||||
|
* key plus length and hash, but if that's not big enough, it's instead a
|
||||||
|
* pointer to a buffer containing 3 bytes of hash, 1 byte of length and then
|
||||||
|
* the key data.
|
||||||
|
*/
|
||||||
|
static int fscache_set_key(struct fscache_cookie *cookie,
|
||||||
|
const void *index_key, size_t index_key_len)
|
||||||
|
{
|
||||||
|
unsigned long long h;
|
||||||
|
u32 *buf;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
cookie->key_len = index_key_len;
|
||||||
|
|
||||||
|
if (index_key_len > sizeof(cookie->inline_key)) {
|
||||||
|
buf = kzalloc(index_key_len, GFP_KERNEL);
|
||||||
|
if (!buf)
|
||||||
|
return -ENOMEM;
|
||||||
|
cookie->key = buf;
|
||||||
|
} else {
|
||||||
|
buf = (u32 *)cookie->inline_key;
|
||||||
|
buf[0] = 0;
|
||||||
|
buf[1] = 0;
|
||||||
|
buf[2] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(buf, index_key, index_key_len);
|
||||||
|
|
||||||
|
/* Calculate a hash and combine this with the length in the first word
|
||||||
|
* or first half word
|
||||||
|
*/
|
||||||
|
h = (unsigned long)cookie->parent;
|
||||||
|
h += index_key_len + cookie->type;
|
||||||
|
for (i = 0; i < (index_key_len + sizeof(u32) - 1) / sizeof(u32); i++)
|
||||||
|
h += buf[i];
|
||||||
|
|
||||||
|
cookie->key_hash = h ^ (h >> 32);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static long fscache_compare_cookie(const struct fscache_cookie *a,
|
||||||
|
const struct fscache_cookie *b)
|
||||||
|
{
|
||||||
|
const void *ka, *kb;
|
||||||
|
|
||||||
|
if (a->key_hash != b->key_hash)
|
||||||
|
return (long)a->key_hash - (long)b->key_hash;
|
||||||
|
if (a->parent != b->parent)
|
||||||
|
return (long)a->parent - (long)b->parent;
|
||||||
|
if (a->key_len != b->key_len)
|
||||||
|
return (long)a->key_len - (long)b->key_len;
|
||||||
|
if (a->type != b->type)
|
||||||
|
return (long)a->type - (long)b->type;
|
||||||
|
|
||||||
|
if (a->key_len <= sizeof(a->inline_key)) {
|
||||||
|
ka = &a->inline_key;
|
||||||
|
kb = &b->inline_key;
|
||||||
|
} else {
|
||||||
|
ka = a->key;
|
||||||
|
kb = b->key;
|
||||||
|
}
|
||||||
|
return memcmp(ka, kb, a->key_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate a cookie.
|
||||||
|
*/
|
||||||
|
struct fscache_cookie *fscache_alloc_cookie(
|
||||||
|
struct fscache_cookie *parent,
|
||||||
|
const struct fscache_cookie_def *def,
|
||||||
|
const void *index_key, size_t index_key_len,
|
||||||
|
const void *aux_data, size_t aux_data_len,
|
||||||
|
void *netfs_data,
|
||||||
|
loff_t object_size)
|
||||||
|
{
|
||||||
|
struct fscache_cookie *cookie;
|
||||||
|
|
||||||
|
/* allocate and initialise a cookie */
|
||||||
|
cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
|
||||||
|
if (!cookie)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
cookie->key_len = index_key_len;
|
||||||
|
cookie->aux_len = aux_data_len;
|
||||||
|
|
||||||
|
if (fscache_set_key(cookie, index_key, index_key_len) < 0)
|
||||||
|
goto nomem;
|
||||||
|
|
||||||
|
if (cookie->aux_len <= sizeof(cookie->inline_aux)) {
|
||||||
|
memcpy(cookie->inline_aux, aux_data, cookie->aux_len);
|
||||||
|
} else {
|
||||||
|
cookie->aux = kmemdup(aux_data, cookie->aux_len, GFP_KERNEL);
|
||||||
|
if (!cookie->aux)
|
||||||
|
goto nomem;
|
||||||
|
}
|
||||||
|
|
||||||
|
atomic_set(&cookie->usage, 1);
|
||||||
|
atomic_set(&cookie->n_children, 0);
|
||||||
|
|
||||||
|
/* We keep the active count elevated until relinquishment to prevent an
|
||||||
|
* attempt to wake up every time the object operations queue quiesces.
|
||||||
|
*/
|
||||||
|
atomic_set(&cookie->n_active, 1);
|
||||||
|
|
||||||
|
cookie->def = def;
|
||||||
|
cookie->parent = parent;
|
||||||
|
cookie->netfs_data = netfs_data;
|
||||||
|
cookie->flags = (1 << FSCACHE_COOKIE_NO_DATA_YET);
|
||||||
|
cookie->type = def->type;
|
||||||
|
|
||||||
|
/* radix tree insertion won't use the preallocation pool unless it's
|
||||||
|
* told it may not wait */
|
||||||
|
INIT_RADIX_TREE(&cookie->stores, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
|
||||||
|
return cookie;
|
||||||
|
|
||||||
|
nomem:
|
||||||
|
fscache_free_cookie(cookie);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Attempt to insert the new cookie into the hash. If there's a collision, we
|
||||||
|
* return the old cookie if it's not in use and an error otherwise.
|
||||||
|
*/
|
||||||
|
struct fscache_cookie *fscache_hash_cookie(struct fscache_cookie *candidate)
|
||||||
|
{
|
||||||
|
struct fscache_cookie *cursor;
|
||||||
|
struct hlist_bl_head *h;
|
||||||
|
struct hlist_bl_node *p;
|
||||||
|
unsigned int bucket;
|
||||||
|
|
||||||
|
bucket = candidate->key_hash & (ARRAY_SIZE(fscache_cookie_hash) - 1);
|
||||||
|
h = &fscache_cookie_hash[bucket];
|
||||||
|
|
||||||
|
hlist_bl_lock(h);
|
||||||
|
hlist_bl_for_each_entry(cursor, p, h, hash_link) {
|
||||||
|
if (fscache_compare_cookie(candidate, cursor) == 0)
|
||||||
|
goto collision;
|
||||||
|
}
|
||||||
|
|
||||||
|
__set_bit(FSCACHE_COOKIE_ACQUIRED, &candidate->flags);
|
||||||
|
fscache_cookie_get(candidate->parent, fscache_cookie_get_acquire_parent);
|
||||||
|
atomic_inc(&candidate->parent->n_children);
|
||||||
|
hlist_bl_add_head(&candidate->hash_link, h);
|
||||||
|
hlist_bl_unlock(h);
|
||||||
|
return candidate;
|
||||||
|
|
||||||
|
collision:
|
||||||
|
if (test_and_set_bit(FSCACHE_COOKIE_ACQUIRED, &cursor->flags)) {
|
||||||
|
trace_fscache_cookie(cursor, fscache_cookie_collision,
|
||||||
|
atomic_read(&cursor->usage));
|
||||||
|
pr_err("Duplicate cookie detected\n");
|
||||||
|
fscache_print_cookie(cursor, 'O');
|
||||||
|
fscache_print_cookie(candidate, 'N');
|
||||||
|
hlist_bl_unlock(h);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fscache_cookie_get(cursor, fscache_cookie_get_reacquire);
|
||||||
|
hlist_bl_unlock(h);
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* request a cookie to represent an object (index, datafile, xattr, etc)
|
* request a cookie to represent an object (index, datafile, xattr, etc)
|
||||||
* - parent specifies the parent object
|
* - parent specifies the parent object
|
||||||
|
@ -58,10 +264,13 @@ void fscache_cookie_init_once(void *_cookie)
|
||||||
struct fscache_cookie *__fscache_acquire_cookie(
|
struct fscache_cookie *__fscache_acquire_cookie(
|
||||||
struct fscache_cookie *parent,
|
struct fscache_cookie *parent,
|
||||||
const struct fscache_cookie_def *def,
|
const struct fscache_cookie_def *def,
|
||||||
|
const void *index_key, size_t index_key_len,
|
||||||
|
const void *aux_data, size_t aux_data_len,
|
||||||
void *netfs_data,
|
void *netfs_data,
|
||||||
|
loff_t object_size,
|
||||||
bool enable)
|
bool enable)
|
||||||
{
|
{
|
||||||
struct fscache_cookie *cookie;
|
struct fscache_cookie *candidate, *cookie;
|
||||||
|
|
||||||
BUG_ON(!def);
|
BUG_ON(!def);
|
||||||
|
|
||||||
|
@ -69,6 +278,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
|
||||||
parent ? (char *) parent->def->name : "<no-parent>",
|
parent ? (char *) parent->def->name : "<no-parent>",
|
||||||
def->name, netfs_data, enable);
|
def->name, netfs_data, enable);
|
||||||
|
|
||||||
|
if (!index_key || !index_key_len || index_key_len > 255 || aux_data_len > 255)
|
||||||
|
return NULL;
|
||||||
|
if (!aux_data || !aux_data_len) {
|
||||||
|
aux_data = NULL;
|
||||||
|
aux_data_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
fscache_stat(&fscache_n_acquires);
|
fscache_stat(&fscache_n_acquires);
|
||||||
|
|
||||||
/* if there's no parent cookie, then we don't create one here either */
|
/* if there's no parent cookie, then we don't create one here either */
|
||||||
|
@ -79,41 +295,31 @@ struct fscache_cookie *__fscache_acquire_cookie(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* validate the definition */
|
/* validate the definition */
|
||||||
BUG_ON(!def->get_key);
|
|
||||||
BUG_ON(!def->name[0]);
|
BUG_ON(!def->name[0]);
|
||||||
|
|
||||||
BUG_ON(def->type == FSCACHE_COOKIE_TYPE_INDEX &&
|
BUG_ON(def->type == FSCACHE_COOKIE_TYPE_INDEX &&
|
||||||
parent->def->type != FSCACHE_COOKIE_TYPE_INDEX);
|
parent->type != FSCACHE_COOKIE_TYPE_INDEX);
|
||||||
|
|
||||||
/* allocate and initialise a cookie */
|
candidate = fscache_alloc_cookie(parent, def,
|
||||||
cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
|
index_key, index_key_len,
|
||||||
if (!cookie) {
|
aux_data, aux_data_len,
|
||||||
|
netfs_data, object_size);
|
||||||
|
if (!candidate) {
|
||||||
fscache_stat(&fscache_n_acquires_oom);
|
fscache_stat(&fscache_n_acquires_oom);
|
||||||
_leave(" [ENOMEM]");
|
_leave(" [ENOMEM]");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_set(&cookie->usage, 1);
|
cookie = fscache_hash_cookie(candidate);
|
||||||
atomic_set(&cookie->n_children, 0);
|
if (!cookie) {
|
||||||
|
trace_fscache_cookie(candidate, fscache_cookie_discard, 1);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* We keep the active count elevated until relinquishment to prevent an
|
if (cookie == candidate)
|
||||||
* attempt to wake up every time the object operations queue quiesces.
|
candidate = NULL;
|
||||||
*/
|
|
||||||
atomic_set(&cookie->n_active, 1);
|
|
||||||
|
|
||||||
atomic_inc(&parent->usage);
|
switch (cookie->type) {
|
||||||
atomic_inc(&parent->n_children);
|
|
||||||
|
|
||||||
cookie->def = def;
|
|
||||||
cookie->parent = parent;
|
|
||||||
cookie->netfs_data = netfs_data;
|
|
||||||
cookie->flags = (1 << FSCACHE_COOKIE_NO_DATA_YET);
|
|
||||||
|
|
||||||
/* radix tree insertion won't use the preallocation pool unless it's
|
|
||||||
* told it may not wait */
|
|
||||||
INIT_RADIX_TREE(&cookie->stores, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
|
|
||||||
|
|
||||||
switch (cookie->def->type) {
|
|
||||||
case FSCACHE_COOKIE_TYPE_INDEX:
|
case FSCACHE_COOKIE_TYPE_INDEX:
|
||||||
fscache_stat(&fscache_n_cookie_index);
|
fscache_stat(&fscache_n_cookie_index);
|
||||||
break;
|
break;
|
||||||
|
@ -125,16 +331,19 @@ struct fscache_cookie *__fscache_acquire_cookie(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trace_fscache_acquire(cookie);
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
/* if the object is an index then we need do nothing more here
|
/* if the object is an index then we need do nothing more here
|
||||||
* - we create indices on disk when we need them as an index
|
* - we create indices on disk when we need them as an index
|
||||||
* may exist in multiple caches */
|
* may exist in multiple caches */
|
||||||
if (cookie->def->type != FSCACHE_COOKIE_TYPE_INDEX) {
|
if (cookie->type != FSCACHE_COOKIE_TYPE_INDEX) {
|
||||||
if (fscache_acquire_non_index_cookie(cookie) == 0) {
|
if (fscache_acquire_non_index_cookie(cookie, object_size) == 0) {
|
||||||
set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
|
set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
|
||||||
} else {
|
} else {
|
||||||
atomic_dec(&parent->n_children);
|
atomic_dec(&parent->n_children);
|
||||||
__fscache_cookie_put(cookie);
|
fscache_cookie_put(cookie,
|
||||||
|
fscache_cookie_put_acquire_nobufs);
|
||||||
fscache_stat(&fscache_n_acquires_nobufs);
|
fscache_stat(&fscache_n_acquires_nobufs);
|
||||||
_leave(" = NULL");
|
_leave(" = NULL");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -145,7 +354,9 @@ struct fscache_cookie *__fscache_acquire_cookie(
|
||||||
}
|
}
|
||||||
|
|
||||||
fscache_stat(&fscache_n_acquires_ok);
|
fscache_stat(&fscache_n_acquires_ok);
|
||||||
_leave(" = %p", cookie);
|
|
||||||
|
out:
|
||||||
|
fscache_free_cookie(candidate);
|
||||||
return cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__fscache_acquire_cookie);
|
EXPORT_SYMBOL(__fscache_acquire_cookie);
|
||||||
|
@ -154,24 +365,30 @@ EXPORT_SYMBOL(__fscache_acquire_cookie);
|
||||||
* Enable a cookie to permit it to accept new operations.
|
* Enable a cookie to permit it to accept new operations.
|
||||||
*/
|
*/
|
||||||
void __fscache_enable_cookie(struct fscache_cookie *cookie,
|
void __fscache_enable_cookie(struct fscache_cookie *cookie,
|
||||||
|
const void *aux_data,
|
||||||
|
loff_t object_size,
|
||||||
bool (*can_enable)(void *data),
|
bool (*can_enable)(void *data),
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
_enter("%p", cookie);
|
_enter("%p", cookie);
|
||||||
|
|
||||||
|
trace_fscache_enable(cookie);
|
||||||
|
|
||||||
wait_on_bit_lock(&cookie->flags, FSCACHE_COOKIE_ENABLEMENT_LOCK,
|
wait_on_bit_lock(&cookie->flags, FSCACHE_COOKIE_ENABLEMENT_LOCK,
|
||||||
TASK_UNINTERRUPTIBLE);
|
TASK_UNINTERRUPTIBLE);
|
||||||
|
|
||||||
|
fscache_update_aux(cookie, aux_data);
|
||||||
|
|
||||||
if (test_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags))
|
if (test_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags))
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
|
||||||
if (can_enable && !can_enable(data)) {
|
if (can_enable && !can_enable(data)) {
|
||||||
/* The netfs decided it didn't want to enable after all */
|
/* The netfs decided it didn't want to enable after all */
|
||||||
} else if (cookie->def->type != FSCACHE_COOKIE_TYPE_INDEX) {
|
} else if (cookie->type != FSCACHE_COOKIE_TYPE_INDEX) {
|
||||||
/* Wait for outstanding disablement to complete */
|
/* Wait for outstanding disablement to complete */
|
||||||
__fscache_wait_on_invalidate(cookie);
|
__fscache_wait_on_invalidate(cookie);
|
||||||
|
|
||||||
if (fscache_acquire_non_index_cookie(cookie) == 0)
|
if (fscache_acquire_non_index_cookie(cookie, object_size) == 0)
|
||||||
set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
|
set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
|
||||||
} else {
|
} else {
|
||||||
set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
|
set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
|
||||||
|
@ -188,11 +405,11 @@ EXPORT_SYMBOL(__fscache_enable_cookie);
|
||||||
* - this must make sure the index chain is instantiated and instantiate the
|
* - this must make sure the index chain is instantiated and instantiate the
|
||||||
* object representation too
|
* object representation too
|
||||||
*/
|
*/
|
||||||
static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
|
static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie,
|
||||||
|
loff_t object_size)
|
||||||
{
|
{
|
||||||
struct fscache_object *object;
|
struct fscache_object *object;
|
||||||
struct fscache_cache *cache;
|
struct fscache_cache *cache;
|
||||||
uint64_t i_size;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
_enter("");
|
_enter("");
|
||||||
|
@ -231,9 +448,6 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pass on how big the object we're caching is supposed to be */
|
|
||||||
cookie->def->get_attr(cookie->netfs_data, &i_size);
|
|
||||||
|
|
||||||
spin_lock(&cookie->lock);
|
spin_lock(&cookie->lock);
|
||||||
if (hlist_empty(&cookie->backing_objects)) {
|
if (hlist_empty(&cookie->backing_objects)) {
|
||||||
spin_unlock(&cookie->lock);
|
spin_unlock(&cookie->lock);
|
||||||
|
@ -243,7 +457,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
|
||||||
object = hlist_entry(cookie->backing_objects.first,
|
object = hlist_entry(cookie->backing_objects.first,
|
||||||
struct fscache_object, cookie_link);
|
struct fscache_object, cookie_link);
|
||||||
|
|
||||||
fscache_set_store_limit(object, i_size);
|
fscache_set_store_limit(object, object_size);
|
||||||
|
|
||||||
/* initiate the process of looking up all the objects in the chain
|
/* initiate the process of looking up all the objects in the chain
|
||||||
* (done by fscache_initialise_object()) */
|
* (done by fscache_initialise_object()) */
|
||||||
|
@ -318,7 +532,7 @@ static int fscache_alloc_object(struct fscache_cache *cache,
|
||||||
* attached to the cookie */
|
* attached to the cookie */
|
||||||
if (fscache_attach_object(cookie, object) < 0) {
|
if (fscache_attach_object(cookie, object) < 0) {
|
||||||
fscache_stat(&fscache_n_cop_put_object);
|
fscache_stat(&fscache_n_cop_put_object);
|
||||||
cache->ops->put_object(object);
|
cache->ops->put_object(object, fscache_obj_put_attach_fail);
|
||||||
fscache_stat_d(&fscache_n_cop_put_object);
|
fscache_stat_d(&fscache_n_cop_put_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +552,7 @@ object_already_extant:
|
||||||
|
|
||||||
error_put:
|
error_put:
|
||||||
fscache_stat(&fscache_n_cop_put_object);
|
fscache_stat(&fscache_n_cop_put_object);
|
||||||
cache->ops->put_object(object);
|
cache->ops->put_object(object, fscache_obj_put_alloc_fail);
|
||||||
fscache_stat_d(&fscache_n_cop_put_object);
|
fscache_stat_d(&fscache_n_cop_put_object);
|
||||||
error:
|
error:
|
||||||
_leave(" = %d", ret);
|
_leave(" = %d", ret);
|
||||||
|
@ -398,7 +612,7 @@ static int fscache_attach_object(struct fscache_cookie *cookie,
|
||||||
|
|
||||||
/* attach to the cookie */
|
/* attach to the cookie */
|
||||||
object->cookie = cookie;
|
object->cookie = cookie;
|
||||||
atomic_inc(&cookie->usage);
|
fscache_cookie_get(cookie, fscache_cookie_get_attach_object);
|
||||||
hlist_add_head(&object->cookie_link, &cookie->backing_objects);
|
hlist_add_head(&object->cookie_link, &cookie->backing_objects);
|
||||||
|
|
||||||
fscache_objlist_add(object);
|
fscache_objlist_add(object);
|
||||||
|
@ -426,10 +640,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
|
||||||
* there, and if it's doing that, it may as well just retire the
|
* there, and if it's doing that, it may as well just retire the
|
||||||
* cookie.
|
* cookie.
|
||||||
*/
|
*/
|
||||||
ASSERTCMP(cookie->def->type, ==, FSCACHE_COOKIE_TYPE_DATAFILE);
|
ASSERTCMP(cookie->type, ==, FSCACHE_COOKIE_TYPE_DATAFILE);
|
||||||
|
|
||||||
/* We will be updating the cookie too. */
|
|
||||||
BUG_ON(!cookie->def->get_aux);
|
|
||||||
|
|
||||||
/* If there's an object, we tell the object state machine to handle the
|
/* If there's an object, we tell the object state machine to handle the
|
||||||
* invalidation on our behalf, otherwise there's nothing to do.
|
* invalidation on our behalf, otherwise there's nothing to do.
|
||||||
|
@ -473,7 +684,7 @@ EXPORT_SYMBOL(__fscache_wait_on_invalidate);
|
||||||
/*
|
/*
|
||||||
* update the index entries backing a cookie
|
* update the index entries backing a cookie
|
||||||
*/
|
*/
|
||||||
void __fscache_update_cookie(struct fscache_cookie *cookie)
|
void __fscache_update_cookie(struct fscache_cookie *cookie, const void *aux_data)
|
||||||
{
|
{
|
||||||
struct fscache_object *object;
|
struct fscache_object *object;
|
||||||
|
|
||||||
|
@ -487,10 +698,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
|
||||||
|
|
||||||
_enter("{%s}", cookie->def->name);
|
_enter("{%s}", cookie->def->name);
|
||||||
|
|
||||||
BUG_ON(!cookie->def->get_aux);
|
|
||||||
|
|
||||||
spin_lock(&cookie->lock);
|
spin_lock(&cookie->lock);
|
||||||
|
|
||||||
|
fscache_update_aux(cookie, aux_data);
|
||||||
|
|
||||||
if (fscache_cookie_enabled(cookie)) {
|
if (fscache_cookie_enabled(cookie)) {
|
||||||
/* update the index entry on disk in each cache backing this
|
/* update the index entry on disk in each cache backing this
|
||||||
* cookie.
|
* cookie.
|
||||||
|
@ -509,13 +720,17 @@ EXPORT_SYMBOL(__fscache_update_cookie);
|
||||||
/*
|
/*
|
||||||
* Disable a cookie to stop it from accepting new requests from the netfs.
|
* Disable a cookie to stop it from accepting new requests from the netfs.
|
||||||
*/
|
*/
|
||||||
void __fscache_disable_cookie(struct fscache_cookie *cookie, bool invalidate)
|
void __fscache_disable_cookie(struct fscache_cookie *cookie,
|
||||||
|
const void *aux_data,
|
||||||
|
bool invalidate)
|
||||||
{
|
{
|
||||||
struct fscache_object *object;
|
struct fscache_object *object;
|
||||||
bool awaken = false;
|
bool awaken = false;
|
||||||
|
|
||||||
_enter("%p,%u", cookie, invalidate);
|
_enter("%p,%u", cookie, invalidate);
|
||||||
|
|
||||||
|
trace_fscache_disable(cookie);
|
||||||
|
|
||||||
ASSERTCMP(atomic_read(&cookie->n_active), >, 0);
|
ASSERTCMP(atomic_read(&cookie->n_active), >, 0);
|
||||||
|
|
||||||
if (atomic_read(&cookie->n_children) != 0) {
|
if (atomic_read(&cookie->n_children) != 0) {
|
||||||
|
@ -526,6 +741,9 @@ void __fscache_disable_cookie(struct fscache_cookie *cookie, bool invalidate)
|
||||||
|
|
||||||
wait_on_bit_lock(&cookie->flags, FSCACHE_COOKIE_ENABLEMENT_LOCK,
|
wait_on_bit_lock(&cookie->flags, FSCACHE_COOKIE_ENABLEMENT_LOCK,
|
||||||
TASK_UNINTERRUPTIBLE);
|
TASK_UNINTERRUPTIBLE);
|
||||||
|
|
||||||
|
fscache_update_aux(cookie, aux_data);
|
||||||
|
|
||||||
if (!test_and_clear_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags))
|
if (!test_and_clear_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags))
|
||||||
goto out_unlock_enable;
|
goto out_unlock_enable;
|
||||||
|
|
||||||
|
@ -563,7 +781,7 @@ void __fscache_disable_cookie(struct fscache_cookie *cookie, bool invalidate)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure any pending writes are cancelled. */
|
/* Make sure any pending writes are cancelled. */
|
||||||
if (cookie->def->type != FSCACHE_COOKIE_TYPE_INDEX)
|
if (cookie->type != FSCACHE_COOKIE_TYPE_INDEX)
|
||||||
fscache_invalidate_writes(cookie);
|
fscache_invalidate_writes(cookie);
|
||||||
|
|
||||||
/* Reset the cookie state if it wasn't relinquished */
|
/* Reset the cookie state if it wasn't relinquished */
|
||||||
|
@ -585,7 +803,9 @@ EXPORT_SYMBOL(__fscache_disable_cookie);
|
||||||
* - all dependents of this cookie must have already been unregistered
|
* - all dependents of this cookie must have already been unregistered
|
||||||
* (indices/files/pages)
|
* (indices/files/pages)
|
||||||
*/
|
*/
|
||||||
void __fscache_relinquish_cookie(struct fscache_cookie *cookie, bool retire)
|
void __fscache_relinquish_cookie(struct fscache_cookie *cookie,
|
||||||
|
const void *aux_data,
|
||||||
|
bool retire)
|
||||||
{
|
{
|
||||||
fscache_stat(&fscache_n_relinquishes);
|
fscache_stat(&fscache_n_relinquishes);
|
||||||
if (retire)
|
if (retire)
|
||||||
|
@ -601,10 +821,13 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, bool retire)
|
||||||
cookie, cookie->def->name, cookie->netfs_data,
|
cookie, cookie->def->name, cookie->netfs_data,
|
||||||
atomic_read(&cookie->n_active), retire);
|
atomic_read(&cookie->n_active), retire);
|
||||||
|
|
||||||
/* No further netfs-accessing operations on this cookie permitted */
|
trace_fscache_relinquish(cookie, retire);
|
||||||
set_bit(FSCACHE_COOKIE_RELINQUISHED, &cookie->flags);
|
|
||||||
|
|
||||||
__fscache_disable_cookie(cookie, retire);
|
/* No further netfs-accessing operations on this cookie permitted */
|
||||||
|
if (test_and_set_bit(FSCACHE_COOKIE_RELINQUISHED, &cookie->flags))
|
||||||
|
BUG();
|
||||||
|
|
||||||
|
__fscache_disable_cookie(cookie, aux_data, retire);
|
||||||
|
|
||||||
/* Clear pointers back to the netfs */
|
/* Clear pointers back to the netfs */
|
||||||
cookie->netfs_data = NULL;
|
cookie->netfs_data = NULL;
|
||||||
|
@ -619,35 +842,54 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, bool retire)
|
||||||
|
|
||||||
/* Dispose of the netfs's link to the cookie */
|
/* Dispose of the netfs's link to the cookie */
|
||||||
ASSERTCMP(atomic_read(&cookie->usage), >, 0);
|
ASSERTCMP(atomic_read(&cookie->usage), >, 0);
|
||||||
fscache_cookie_put(cookie);
|
fscache_cookie_put(cookie, fscache_cookie_put_relinquish);
|
||||||
|
|
||||||
_leave("");
|
_leave("");
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__fscache_relinquish_cookie);
|
EXPORT_SYMBOL(__fscache_relinquish_cookie);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* destroy a cookie
|
* Remove a cookie from the hash table.
|
||||||
*/
|
*/
|
||||||
void __fscache_cookie_put(struct fscache_cookie *cookie)
|
static void fscache_unhash_cookie(struct fscache_cookie *cookie)
|
||||||
|
{
|
||||||
|
struct hlist_bl_head *h;
|
||||||
|
unsigned int bucket;
|
||||||
|
|
||||||
|
bucket = cookie->key_hash & (ARRAY_SIZE(fscache_cookie_hash) - 1);
|
||||||
|
h = &fscache_cookie_hash[bucket];
|
||||||
|
|
||||||
|
hlist_bl_lock(h);
|
||||||
|
hlist_bl_del(&cookie->hash_link);
|
||||||
|
hlist_bl_unlock(h);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Drop a reference to a cookie.
|
||||||
|
*/
|
||||||
|
void fscache_cookie_put(struct fscache_cookie *cookie,
|
||||||
|
enum fscache_cookie_trace where)
|
||||||
{
|
{
|
||||||
struct fscache_cookie *parent;
|
struct fscache_cookie *parent;
|
||||||
|
int usage;
|
||||||
|
|
||||||
_enter("%p", cookie);
|
_enter("%p", cookie);
|
||||||
|
|
||||||
for (;;) {
|
do {
|
||||||
_debug("FREE COOKIE %p", cookie);
|
usage = atomic_dec_return(&cookie->usage);
|
||||||
parent = cookie->parent;
|
trace_fscache_cookie(cookie, where, usage);
|
||||||
BUG_ON(!hlist_empty(&cookie->backing_objects));
|
|
||||||
kmem_cache_free(fscache_cookie_jar, cookie);
|
|
||||||
|
|
||||||
if (!parent)
|
if (usage > 0)
|
||||||
break;
|
return;
|
||||||
|
BUG_ON(usage < 0);
|
||||||
|
|
||||||
|
parent = cookie->parent;
|
||||||
|
fscache_unhash_cookie(cookie);
|
||||||
|
fscache_free_cookie(cookie);
|
||||||
|
|
||||||
cookie = parent;
|
cookie = parent;
|
||||||
BUG_ON(atomic_read(&cookie->usage) <= 0);
|
where = fscache_cookie_put_parent;
|
||||||
if (!atomic_dec_and_test(&cookie->usage))
|
} while (cookie);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_leave("");
|
_leave("");
|
||||||
}
|
}
|
||||||
|
@ -657,7 +899,8 @@ void __fscache_cookie_put(struct fscache_cookie *cookie)
|
||||||
*
|
*
|
||||||
* NOTE: it only serves no-index type
|
* NOTE: it only serves no-index type
|
||||||
*/
|
*/
|
||||||
int __fscache_check_consistency(struct fscache_cookie *cookie)
|
int __fscache_check_consistency(struct fscache_cookie *cookie,
|
||||||
|
const void *aux_data)
|
||||||
{
|
{
|
||||||
struct fscache_operation *op;
|
struct fscache_operation *op;
|
||||||
struct fscache_object *object;
|
struct fscache_object *object;
|
||||||
|
@ -666,7 +909,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
|
||||||
|
|
||||||
_enter("%p,", cookie);
|
_enter("%p,", cookie);
|
||||||
|
|
||||||
ASSERTCMP(cookie->def->type, ==, FSCACHE_COOKIE_TYPE_DATAFILE);
|
ASSERTCMP(cookie->type, ==, FSCACHE_COOKIE_TYPE_DATAFILE);
|
||||||
|
|
||||||
if (fscache_wait_for_deferred_lookup(cookie) < 0)
|
if (fscache_wait_for_deferred_lookup(cookie) < 0)
|
||||||
return -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
|
@ -678,13 +921,16 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
|
||||||
if (!op)
|
if (!op)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
fscache_operation_init(op, NULL, NULL, NULL);
|
fscache_operation_init(cookie, op, NULL, NULL, NULL);
|
||||||
op->flags = FSCACHE_OP_MYTHREAD |
|
op->flags = FSCACHE_OP_MYTHREAD |
|
||||||
(1 << FSCACHE_OP_WAITING) |
|
(1 << FSCACHE_OP_WAITING) |
|
||||||
(1 << FSCACHE_OP_UNUSE_COOKIE);
|
(1 << FSCACHE_OP_UNUSE_COOKIE);
|
||||||
|
trace_fscache_page_op(cookie, NULL, op, fscache_page_op_check_consistency);
|
||||||
|
|
||||||
spin_lock(&cookie->lock);
|
spin_lock(&cookie->lock);
|
||||||
|
|
||||||
|
fscache_update_aux(cookie, aux_data);
|
||||||
|
|
||||||
if (!fscache_cookie_enabled(cookie) ||
|
if (!fscache_cookie_enabled(cookie) ||
|
||||||
hlist_empty(&cookie->backing_objects))
|
hlist_empty(&cookie->backing_objects))
|
||||||
goto inconsistent;
|
goto inconsistent;
|
||||||
|
|
|
@ -13,16 +13,11 @@
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
static uint16_t fscache_fsdef_netfs_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax);
|
|
||||||
|
|
||||||
static uint16_t fscache_fsdef_netfs_get_aux(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax);
|
|
||||||
|
|
||||||
static
|
static
|
||||||
enum fscache_checkaux fscache_fsdef_netfs_check_aux(void *cookie_netfs_data,
|
enum fscache_checkaux fscache_fsdef_netfs_check_aux(void *cookie_netfs_data,
|
||||||
const void *data,
|
const void *data,
|
||||||
uint16_t datalen);
|
uint16_t datalen,
|
||||||
|
loff_t object_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The root index is owned by FS-Cache itself.
|
* The root index is owned by FS-Cache itself.
|
||||||
|
@ -60,6 +55,7 @@ struct fscache_cookie fscache_fsdef_index = {
|
||||||
.backing_objects = HLIST_HEAD_INIT,
|
.backing_objects = HLIST_HEAD_INIT,
|
||||||
.def = &fscache_fsdef_index_def,
|
.def = &fscache_fsdef_index_def,
|
||||||
.flags = 1 << FSCACHE_COOKIE_ENABLED,
|
.flags = 1 << FSCACHE_COOKIE_ENABLED,
|
||||||
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
||||||
};
|
};
|
||||||
EXPORT_SYMBOL(fscache_fsdef_index);
|
EXPORT_SYMBOL(fscache_fsdef_index);
|
||||||
|
|
||||||
|
@ -71,51 +67,9 @@ EXPORT_SYMBOL(fscache_fsdef_index);
|
||||||
struct fscache_cookie_def fscache_fsdef_netfs_def = {
|
struct fscache_cookie_def fscache_fsdef_netfs_def = {
|
||||||
.name = "FSDEF.netfs",
|
.name = "FSDEF.netfs",
|
||||||
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
||||||
.get_key = fscache_fsdef_netfs_get_key,
|
|
||||||
.get_aux = fscache_fsdef_netfs_get_aux,
|
|
||||||
.check_aux = fscache_fsdef_netfs_check_aux,
|
.check_aux = fscache_fsdef_netfs_check_aux,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* get the key data for an FSDEF index record - this is the name of the netfs
|
|
||||||
* for which this entry is created
|
|
||||||
*/
|
|
||||||
static uint16_t fscache_fsdef_netfs_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax)
|
|
||||||
{
|
|
||||||
const struct fscache_netfs *netfs = cookie_netfs_data;
|
|
||||||
unsigned klen;
|
|
||||||
|
|
||||||
_enter("{%s.%u},", netfs->name, netfs->version);
|
|
||||||
|
|
||||||
klen = strlen(netfs->name);
|
|
||||||
if (klen > bufmax)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(buffer, netfs->name, klen);
|
|
||||||
return klen;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* get the auxiliary data for an FSDEF index record - this is the index
|
|
||||||
* structure version number of the netfs for which this version is created
|
|
||||||
*/
|
|
||||||
static uint16_t fscache_fsdef_netfs_get_aux(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax)
|
|
||||||
{
|
|
||||||
const struct fscache_netfs *netfs = cookie_netfs_data;
|
|
||||||
unsigned dlen;
|
|
||||||
|
|
||||||
_enter("{%s.%u},", netfs->name, netfs->version);
|
|
||||||
|
|
||||||
dlen = sizeof(uint32_t);
|
|
||||||
if (dlen > bufmax)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(buffer, &netfs->version, dlen);
|
|
||||||
return dlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check that the index structure version number stored in the auxiliary data
|
* check that the index structure version number stored in the auxiliary data
|
||||||
* matches the one the netfs gave us
|
* matches the one the netfs gave us
|
||||||
|
@ -123,7 +77,8 @@ static uint16_t fscache_fsdef_netfs_get_aux(const void *cookie_netfs_data,
|
||||||
static enum fscache_checkaux fscache_fsdef_netfs_check_aux(
|
static enum fscache_checkaux fscache_fsdef_netfs_check_aux(
|
||||||
void *cookie_netfs_data,
|
void *cookie_netfs_data,
|
||||||
const void *data,
|
const void *data,
|
||||||
uint16_t datalen)
|
uint16_t datalen,
|
||||||
|
loff_t object_size)
|
||||||
{
|
{
|
||||||
struct fscache_netfs *netfs = cookie_netfs_data;
|
struct fscache_netfs *netfs = cookie_netfs_data;
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#define pr_fmt(fmt) "FS-Cache: " fmt
|
#define pr_fmt(fmt) "FS-Cache: " fmt
|
||||||
|
|
||||||
#include <linux/fscache-cache.h>
|
#include <linux/fscache-cache.h>
|
||||||
|
#include <trace/events/fscache.h>
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
|
|
||||||
#define FSCACHE_MIN_THREADS 4
|
#define FSCACHE_MIN_THREADS 4
|
||||||
|
@ -48,8 +49,16 @@ extern struct fscache_cache *fscache_select_cache_for_object(
|
||||||
*/
|
*/
|
||||||
extern struct kmem_cache *fscache_cookie_jar;
|
extern struct kmem_cache *fscache_cookie_jar;
|
||||||
|
|
||||||
|
extern void fscache_free_cookie(struct fscache_cookie *);
|
||||||
extern void fscache_cookie_init_once(void *);
|
extern void fscache_cookie_init_once(void *);
|
||||||
extern void __fscache_cookie_put(struct fscache_cookie *);
|
extern struct fscache_cookie *fscache_alloc_cookie(struct fscache_cookie *,
|
||||||
|
const struct fscache_cookie_def *,
|
||||||
|
const void *, size_t,
|
||||||
|
const void *, size_t,
|
||||||
|
void *, loff_t);
|
||||||
|
extern struct fscache_cookie *fscache_hash_cookie(struct fscache_cookie *);
|
||||||
|
extern void fscache_cookie_put(struct fscache_cookie *,
|
||||||
|
enum fscache_cookie_trace);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fsdef.c
|
* fsdef.c
|
||||||
|
@ -311,14 +320,12 @@ static inline void fscache_raise_event(struct fscache_object *object,
|
||||||
fscache_enqueue_object(object);
|
fscache_enqueue_object(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static inline void fscache_cookie_get(struct fscache_cookie *cookie,
|
||||||
* drop a reference to a cookie
|
enum fscache_cookie_trace where)
|
||||||
*/
|
|
||||||
static inline void fscache_cookie_put(struct fscache_cookie *cookie)
|
|
||||||
{
|
{
|
||||||
BUG_ON(atomic_read(&cookie->usage) <= 0);
|
int usage = atomic_inc_return(&cookie->usage);
|
||||||
if (atomic_dec_and_test(&cookie->usage))
|
|
||||||
__fscache_cookie_put(cookie);
|
trace_fscache_cookie(cookie, where, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -342,6 +349,27 @@ void fscache_put_context(struct fscache_cookie *cookie, void *context)
|
||||||
cookie->def->put_context(cookie->netfs_data, context);
|
cookie->def->put_context(cookie->netfs_data, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update the auxiliary data on a cookie.
|
||||||
|
*/
|
||||||
|
static inline
|
||||||
|
void fscache_update_aux(struct fscache_cookie *cookie, const void *aux_data)
|
||||||
|
{
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
if (!aux_data)
|
||||||
|
return;
|
||||||
|
if (cookie->aux_len <= sizeof(cookie->inline_aux))
|
||||||
|
p = cookie->inline_aux;
|
||||||
|
else
|
||||||
|
p = cookie->aux;
|
||||||
|
|
||||||
|
if (memcmp(p, aux_data, cookie->aux_len) != 0) {
|
||||||
|
memcpy(p, aux_data, cookie->aux_len);
|
||||||
|
set_bit(FSCACHE_COOKIE_AUX_UPDATED, &cookie->flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*
|
/*
|
||||||
* debug tracing
|
* debug tracing
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <linux/completion.h>
|
#include <linux/completion.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/seq_file.h>
|
#include <linux/seq_file.h>
|
||||||
|
#define CREATE_TRACE_POINTS
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
MODULE_DESCRIPTION("FS Cache Manager");
|
MODULE_DESCRIPTION("FS Cache Manager");
|
||||||
|
|
|
@ -14,69 +14,51 @@
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
static LIST_HEAD(fscache_netfs_list);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* register a network filesystem for caching
|
* register a network filesystem for caching
|
||||||
*/
|
*/
|
||||||
int __fscache_register_netfs(struct fscache_netfs *netfs)
|
int __fscache_register_netfs(struct fscache_netfs *netfs)
|
||||||
{
|
{
|
||||||
struct fscache_netfs *ptr;
|
struct fscache_cookie *candidate, *cookie;
|
||||||
struct fscache_cookie *cookie;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
_enter("{%s}", netfs->name);
|
_enter("{%s}", netfs->name);
|
||||||
|
|
||||||
INIT_LIST_HEAD(&netfs->link);
|
|
||||||
|
|
||||||
/* allocate a cookie for the primary index */
|
/* allocate a cookie for the primary index */
|
||||||
cookie = kmem_cache_zalloc(fscache_cookie_jar, GFP_KERNEL);
|
candidate = fscache_alloc_cookie(&fscache_fsdef_index,
|
||||||
|
&fscache_fsdef_netfs_def,
|
||||||
if (!cookie) {
|
netfs->name, strlen(netfs->name),
|
||||||
|
&netfs->version, sizeof(netfs->version),
|
||||||
|
netfs, 0);
|
||||||
|
if (!candidate) {
|
||||||
_leave(" = -ENOMEM");
|
_leave(" = -ENOMEM");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialise the primary index cookie */
|
candidate->flags = 1 << FSCACHE_COOKIE_ENABLED;
|
||||||
atomic_set(&cookie->usage, 1);
|
|
||||||
atomic_set(&cookie->n_children, 0);
|
|
||||||
atomic_set(&cookie->n_active, 1);
|
|
||||||
|
|
||||||
cookie->def = &fscache_fsdef_netfs_def;
|
|
||||||
cookie->parent = &fscache_fsdef_index;
|
|
||||||
cookie->netfs_data = netfs;
|
|
||||||
cookie->flags = 1 << FSCACHE_COOKIE_ENABLED;
|
|
||||||
|
|
||||||
spin_lock_init(&cookie->lock);
|
|
||||||
spin_lock_init(&cookie->stores_lock);
|
|
||||||
INIT_HLIST_HEAD(&cookie->backing_objects);
|
|
||||||
|
|
||||||
/* check the netfs type is not already present */
|
/* check the netfs type is not already present */
|
||||||
down_write(&fscache_addremove_sem);
|
cookie = fscache_hash_cookie(candidate);
|
||||||
|
if (!cookie)
|
||||||
ret = -EEXIST;
|
goto already_registered;
|
||||||
list_for_each_entry(ptr, &fscache_netfs_list, link) {
|
if (cookie != candidate) {
|
||||||
if (strcmp(ptr->name, netfs->name) == 0)
|
trace_fscache_cookie(candidate, fscache_cookie_discard, 1);
|
||||||
goto already_registered;
|
fscache_free_cookie(candidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_inc(&cookie->parent->usage);
|
fscache_cookie_get(cookie->parent, fscache_cookie_get_register_netfs);
|
||||||
atomic_inc(&cookie->parent->n_children);
|
atomic_inc(&cookie->parent->n_children);
|
||||||
|
|
||||||
netfs->primary_index = cookie;
|
netfs->primary_index = cookie;
|
||||||
list_add(&netfs->link, &fscache_netfs_list);
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
pr_notice("Netfs '%s' registered for caching\n", netfs->name);
|
pr_notice("Netfs '%s' registered for caching\n", netfs->name);
|
||||||
|
trace_fscache_netfs(netfs);
|
||||||
|
_leave(" = 0");
|
||||||
|
return 0;
|
||||||
|
|
||||||
already_registered:
|
already_registered:
|
||||||
up_write(&fscache_addremove_sem);
|
fscache_cookie_put(candidate, fscache_cookie_put_dup_netfs);
|
||||||
|
_leave(" = -EEXIST");
|
||||||
if (ret < 0)
|
return -EEXIST;
|
||||||
kmem_cache_free(fscache_cookie_jar, cookie);
|
|
||||||
|
|
||||||
_leave(" = %d", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__fscache_register_netfs);
|
EXPORT_SYMBOL(__fscache_register_netfs);
|
||||||
|
|
||||||
|
@ -88,15 +70,8 @@ void __fscache_unregister_netfs(struct fscache_netfs *netfs)
|
||||||
{
|
{
|
||||||
_enter("{%s.%u}", netfs->name, netfs->version);
|
_enter("{%s.%u}", netfs->name, netfs->version);
|
||||||
|
|
||||||
down_write(&fscache_addremove_sem);
|
fscache_relinquish_cookie(netfs->primary_index, NULL, false);
|
||||||
|
pr_notice("Netfs '%s' unregistered from caching\n", netfs->name);
|
||||||
list_del(&netfs->link);
|
|
||||||
fscache_relinquish_cookie(netfs->primary_index, 0);
|
|
||||||
|
|
||||||
up_write(&fscache_addremove_sem);
|
|
||||||
|
|
||||||
pr_notice("Netfs '%s' unregistered from caching\n",
|
|
||||||
netfs->name);
|
|
||||||
|
|
||||||
_leave("");
|
_leave("");
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,6 @@ struct fscache_objlist_data {
|
||||||
#define FSCACHE_OBJLIST_CONFIG_NOEVENTS 0x00000800 /* show objects without no events */
|
#define FSCACHE_OBJLIST_CONFIG_NOEVENTS 0x00000800 /* show objects without no events */
|
||||||
#define FSCACHE_OBJLIST_CONFIG_WORK 0x00001000 /* show objects with work */
|
#define FSCACHE_OBJLIST_CONFIG_WORK 0x00001000 /* show objects with work */
|
||||||
#define FSCACHE_OBJLIST_CONFIG_NOWORK 0x00002000 /* show objects without work */
|
#define FSCACHE_OBJLIST_CONFIG_NOWORK 0x00002000 /* show objects without work */
|
||||||
|
|
||||||
u8 buf[512]; /* key and aux data buffer */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -170,7 +168,7 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
|
||||||
struct fscache_cookie *cookie;
|
struct fscache_cookie *cookie;
|
||||||
unsigned long config = data->config;
|
unsigned long config = data->config;
|
||||||
char _type[3], *type;
|
char _type[3], *type;
|
||||||
u8 *buf = data->buf, *p;
|
u8 *p;
|
||||||
|
|
||||||
if ((unsigned long) v == 1) {
|
if ((unsigned long) v == 1) {
|
||||||
seq_puts(m, "OBJECT PARENT STAT CHLDN OPS OOP IPR EX READS"
|
seq_puts(m, "OBJECT PARENT STAT CHLDN OPS OOP IPR EX READS"
|
||||||
|
@ -254,7 +252,7 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
|
||||||
if (fscache_use_cookie(obj)) {
|
if (fscache_use_cookie(obj)) {
|
||||||
uint16_t keylen = 0, auxlen = 0;
|
uint16_t keylen = 0, auxlen = 0;
|
||||||
|
|
||||||
switch (cookie->def->type) {
|
switch (cookie->type) {
|
||||||
case 0:
|
case 0:
|
||||||
type = "IX";
|
type = "IX";
|
||||||
break;
|
break;
|
||||||
|
@ -263,7 +261,7 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
snprintf(_type, sizeof(_type), "%02u",
|
snprintf(_type, sizeof(_type), "%02u",
|
||||||
cookie->def->type);
|
cookie->type);
|
||||||
type = _type;
|
type = _type;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -274,30 +272,30 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
|
||||||
cookie->flags,
|
cookie->flags,
|
||||||
cookie->netfs_data);
|
cookie->netfs_data);
|
||||||
|
|
||||||
if (cookie->def->get_key &&
|
if (config & FSCACHE_OBJLIST_CONFIG_KEY)
|
||||||
config & FSCACHE_OBJLIST_CONFIG_KEY)
|
keylen = cookie->key_len;
|
||||||
keylen = cookie->def->get_key(cookie->netfs_data,
|
|
||||||
buf, 400);
|
|
||||||
|
|
||||||
if (cookie->def->get_aux &&
|
if (config & FSCACHE_OBJLIST_CONFIG_AUX)
|
||||||
config & FSCACHE_OBJLIST_CONFIG_AUX)
|
auxlen = cookie->aux_len;
|
||||||
auxlen = cookie->def->get_aux(cookie->netfs_data,
|
|
||||||
buf + keylen, 512 - keylen);
|
|
||||||
fscache_unuse_cookie(obj);
|
|
||||||
|
|
||||||
if (keylen > 0 || auxlen > 0) {
|
if (keylen > 0 || auxlen > 0) {
|
||||||
seq_puts(m, " ");
|
seq_puts(m, " ");
|
||||||
for (p = buf; keylen > 0; keylen--)
|
p = keylen <= sizeof(cookie->inline_key) ?
|
||||||
|
cookie->inline_key : cookie->key;
|
||||||
|
for (; keylen > 0; keylen--)
|
||||||
seq_printf(m, "%02x", *p++);
|
seq_printf(m, "%02x", *p++);
|
||||||
if (auxlen > 0) {
|
if (auxlen > 0) {
|
||||||
if (config & FSCACHE_OBJLIST_CONFIG_KEY)
|
if (config & FSCACHE_OBJLIST_CONFIG_KEY)
|
||||||
seq_puts(m, ", ");
|
seq_puts(m, ", ");
|
||||||
|
p = auxlen <= sizeof(cookie->inline_aux) ?
|
||||||
|
cookie->inline_aux : cookie->aux;
|
||||||
for (; auxlen > 0; auxlen--)
|
for (; auxlen > 0; auxlen--)
|
||||||
seq_printf(m, "%02x", *p++);
|
seq_printf(m, "%02x", *p++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
seq_puts(m, "\n");
|
seq_puts(m, "\n");
|
||||||
|
fscache_unuse_cookie(obj);
|
||||||
} else {
|
} else {
|
||||||
seq_puts(m, "<no_netfs>\n");
|
seq_puts(m, "<no_netfs>\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,10 +138,13 @@ static const struct fscache_transition fscache_osm_run_oob[] = {
|
||||||
{ 0, NULL }
|
{ 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static int fscache_get_object(struct fscache_object *);
|
static int fscache_get_object(struct fscache_object *,
|
||||||
static void fscache_put_object(struct fscache_object *);
|
enum fscache_obj_ref_trace);
|
||||||
|
static void fscache_put_object(struct fscache_object *,
|
||||||
|
enum fscache_obj_ref_trace);
|
||||||
static bool fscache_enqueue_dependents(struct fscache_object *, int);
|
static bool fscache_enqueue_dependents(struct fscache_object *, int);
|
||||||
static void fscache_dequeue_object(struct fscache_object *);
|
static void fscache_dequeue_object(struct fscache_object *);
|
||||||
|
static void fscache_update_aux_data(struct fscache_object *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we need to notify the parent when an op completes that we had outstanding
|
* we need to notify the parent when an op completes that we had outstanding
|
||||||
|
@ -170,6 +173,7 @@ static void fscache_object_sm_dispatcher(struct fscache_object *object)
|
||||||
const struct fscache_transition *t;
|
const struct fscache_transition *t;
|
||||||
const struct fscache_state *state, *new_state;
|
const struct fscache_state *state, *new_state;
|
||||||
unsigned long events, event_mask;
|
unsigned long events, event_mask;
|
||||||
|
bool oob;
|
||||||
int event = -1;
|
int event = -1;
|
||||||
|
|
||||||
ASSERT(object != NULL);
|
ASSERT(object != NULL);
|
||||||
|
@ -188,6 +192,7 @@ restart_masked:
|
||||||
if (events & object->oob_event_mask) {
|
if (events & object->oob_event_mask) {
|
||||||
_debug("{OBJ%x} oob %lx",
|
_debug("{OBJ%x} oob %lx",
|
||||||
object->debug_id, events & object->oob_event_mask);
|
object->debug_id, events & object->oob_event_mask);
|
||||||
|
oob = true;
|
||||||
for (t = object->oob_table; t->events; t++) {
|
for (t = object->oob_table; t->events; t++) {
|
||||||
if (events & t->events) {
|
if (events & t->events) {
|
||||||
state = t->transit_to;
|
state = t->transit_to;
|
||||||
|
@ -199,6 +204,7 @@ restart_masked:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
oob = false;
|
||||||
|
|
||||||
/* Wait states are just transition tables */
|
/* Wait states are just transition tables */
|
||||||
if (!state->work) {
|
if (!state->work) {
|
||||||
|
@ -207,6 +213,8 @@ restart_masked:
|
||||||
if (events & t->events) {
|
if (events & t->events) {
|
||||||
new_state = t->transit_to;
|
new_state = t->transit_to;
|
||||||
event = fls(events & t->events) - 1;
|
event = fls(events & t->events) - 1;
|
||||||
|
trace_fscache_osm(object, state,
|
||||||
|
true, false, event);
|
||||||
clear_bit(event, &object->events);
|
clear_bit(event, &object->events);
|
||||||
_debug("{OBJ%x} ev %d: %s -> %s",
|
_debug("{OBJ%x} ev %d: %s -> %s",
|
||||||
object->debug_id, event,
|
object->debug_id, event,
|
||||||
|
@ -226,6 +234,7 @@ restart_masked:
|
||||||
execute_work_state:
|
execute_work_state:
|
||||||
_debug("{OBJ%x} exec %s", object->debug_id, state->name);
|
_debug("{OBJ%x} exec %s", object->debug_id, state->name);
|
||||||
|
|
||||||
|
trace_fscache_osm(object, state, false, oob, event);
|
||||||
new_state = state->work(object, event);
|
new_state = state->work(object, event);
|
||||||
event = -1;
|
event = -1;
|
||||||
if (new_state == NO_TRANSIT) {
|
if (new_state == NO_TRANSIT) {
|
||||||
|
@ -279,7 +288,7 @@ static void fscache_object_work_func(struct work_struct *work)
|
||||||
start = jiffies;
|
start = jiffies;
|
||||||
fscache_object_sm_dispatcher(object);
|
fscache_object_sm_dispatcher(object);
|
||||||
fscache_hist(fscache_objs_histogram, start);
|
fscache_hist(fscache_objs_histogram, start);
|
||||||
fscache_put_object(object);
|
fscache_put_object(object, fscache_obj_put_work);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -397,7 +406,7 @@ static const struct fscache_state *fscache_initialise_object(struct fscache_obje
|
||||||
fscache_stat(&fscache_n_cop_grab_object);
|
fscache_stat(&fscache_n_cop_grab_object);
|
||||||
success = false;
|
success = false;
|
||||||
if (fscache_object_is_live(parent) &&
|
if (fscache_object_is_live(parent) &&
|
||||||
object->cache->ops->grab_object(object)) {
|
object->cache->ops->grab_object(object, fscache_obj_get_add_to_deps)) {
|
||||||
list_add(&object->dep_link, &parent->dependents);
|
list_add(&object->dep_link, &parent->dependents);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
@ -703,6 +712,11 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
|
||||||
ASSERT(cookie != NULL);
|
ASSERT(cookie != NULL);
|
||||||
ASSERT(!hlist_unhashed(&object->cookie_link));
|
ASSERT(!hlist_unhashed(&object->cookie_link));
|
||||||
|
|
||||||
|
if (test_bit(FSCACHE_COOKIE_AUX_UPDATED, &cookie->flags)) {
|
||||||
|
_debug("final update");
|
||||||
|
fscache_update_aux_data(object);
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure the cookie no longer points here and that the netfs isn't
|
/* Make sure the cookie no longer points here and that the netfs isn't
|
||||||
* waiting for us.
|
* waiting for us.
|
||||||
*/
|
*/
|
||||||
|
@ -745,7 +759,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this just shifts the object release to the work processor */
|
/* this just shifts the object release to the work processor */
|
||||||
fscache_put_object(object);
|
fscache_put_object(object, fscache_obj_put_drop_obj);
|
||||||
fscache_stat(&fscache_n_object_dead);
|
fscache_stat(&fscache_n_object_dead);
|
||||||
|
|
||||||
_leave("");
|
_leave("");
|
||||||
|
@ -755,12 +769,13 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
|
||||||
/*
|
/*
|
||||||
* get a ref on an object
|
* get a ref on an object
|
||||||
*/
|
*/
|
||||||
static int fscache_get_object(struct fscache_object *object)
|
static int fscache_get_object(struct fscache_object *object,
|
||||||
|
enum fscache_obj_ref_trace why)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
fscache_stat(&fscache_n_cop_grab_object);
|
fscache_stat(&fscache_n_cop_grab_object);
|
||||||
ret = object->cache->ops->grab_object(object) ? 0 : -EAGAIN;
|
ret = object->cache->ops->grab_object(object, why) ? 0 : -EAGAIN;
|
||||||
fscache_stat_d(&fscache_n_cop_grab_object);
|
fscache_stat_d(&fscache_n_cop_grab_object);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -768,10 +783,11 @@ static int fscache_get_object(struct fscache_object *object)
|
||||||
/*
|
/*
|
||||||
* Discard a ref on an object
|
* Discard a ref on an object
|
||||||
*/
|
*/
|
||||||
static void fscache_put_object(struct fscache_object *object)
|
static void fscache_put_object(struct fscache_object *object,
|
||||||
|
enum fscache_obj_ref_trace why)
|
||||||
{
|
{
|
||||||
fscache_stat(&fscache_n_cop_put_object);
|
fscache_stat(&fscache_n_cop_put_object);
|
||||||
object->cache->ops->put_object(object);
|
object->cache->ops->put_object(object, why);
|
||||||
fscache_stat_d(&fscache_n_cop_put_object);
|
fscache_stat_d(&fscache_n_cop_put_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,7 +802,7 @@ void fscache_object_destroy(struct fscache_object *object)
|
||||||
fscache_objlist_remove(object);
|
fscache_objlist_remove(object);
|
||||||
|
|
||||||
/* We can get rid of the cookie now */
|
/* We can get rid of the cookie now */
|
||||||
fscache_cookie_put(object->cookie);
|
fscache_cookie_put(object->cookie, fscache_cookie_put_object);
|
||||||
object->cookie = NULL;
|
object->cookie = NULL;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(fscache_object_destroy);
|
EXPORT_SYMBOL(fscache_object_destroy);
|
||||||
|
@ -798,7 +814,7 @@ void fscache_enqueue_object(struct fscache_object *object)
|
||||||
{
|
{
|
||||||
_enter("{OBJ%x}", object->debug_id);
|
_enter("{OBJ%x}", object->debug_id);
|
||||||
|
|
||||||
if (fscache_get_object(object) >= 0) {
|
if (fscache_get_object(object, fscache_obj_get_queue) >= 0) {
|
||||||
wait_queue_head_t *cong_wq =
|
wait_queue_head_t *cong_wq =
|
||||||
&get_cpu_var(fscache_object_cong_wait);
|
&get_cpu_var(fscache_object_cong_wait);
|
||||||
|
|
||||||
|
@ -806,7 +822,7 @@ void fscache_enqueue_object(struct fscache_object *object)
|
||||||
if (fscache_object_congested())
|
if (fscache_object_congested())
|
||||||
wake_up(cong_wq);
|
wake_up(cong_wq);
|
||||||
} else
|
} else
|
||||||
fscache_put_object(object);
|
fscache_put_object(object, fscache_obj_put_queue);
|
||||||
|
|
||||||
put_cpu_var(fscache_object_cong_wait);
|
put_cpu_var(fscache_object_cong_wait);
|
||||||
}
|
}
|
||||||
|
@ -866,7 +882,7 @@ static bool fscache_enqueue_dependents(struct fscache_object *object, int event)
|
||||||
list_del_init(&dep->dep_link);
|
list_del_init(&dep->dep_link);
|
||||||
|
|
||||||
fscache_raise_event(dep, event);
|
fscache_raise_event(dep, event);
|
||||||
fscache_put_object(dep);
|
fscache_put_object(dep, fscache_obj_put_enq_dep);
|
||||||
|
|
||||||
if (!list_empty(&object->dependents) && need_resched()) {
|
if (!list_empty(&object->dependents) && need_resched()) {
|
||||||
ret = false;
|
ret = false;
|
||||||
|
@ -906,7 +922,8 @@ static void fscache_dequeue_object(struct fscache_object *object)
|
||||||
* and creation).
|
* and creation).
|
||||||
*/
|
*/
|
||||||
enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
|
enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
|
||||||
const void *data, uint16_t datalen)
|
const void *data, uint16_t datalen,
|
||||||
|
loff_t object_size)
|
||||||
{
|
{
|
||||||
enum fscache_checkaux result;
|
enum fscache_checkaux result;
|
||||||
|
|
||||||
|
@ -916,7 +933,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
|
||||||
}
|
}
|
||||||
|
|
||||||
result = object->cookie->def->check_aux(object->cookie->netfs_data,
|
result = object->cookie->def->check_aux(object->cookie->netfs_data,
|
||||||
data, datalen);
|
data, datalen, object_size);
|
||||||
switch (result) {
|
switch (result) {
|
||||||
/* entry okay as is */
|
/* entry okay as is */
|
||||||
case FSCACHE_CHECKAUX_OKAY:
|
case FSCACHE_CHECKAUX_OKAY:
|
||||||
|
@ -972,11 +989,12 @@ static const struct fscache_state *_fscache_invalidate_object(struct fscache_obj
|
||||||
if (!op)
|
if (!op)
|
||||||
goto nomem;
|
goto nomem;
|
||||||
|
|
||||||
fscache_operation_init(op, object->cache->ops->invalidate_object,
|
fscache_operation_init(cookie, op, object->cache->ops->invalidate_object,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
op->flags = FSCACHE_OP_ASYNC |
|
op->flags = FSCACHE_OP_ASYNC |
|
||||||
(1 << FSCACHE_OP_EXCLUSIVE) |
|
(1 << FSCACHE_OP_EXCLUSIVE) |
|
||||||
(1 << FSCACHE_OP_UNUSE_COOKIE);
|
(1 << FSCACHE_OP_UNUSE_COOKIE);
|
||||||
|
trace_fscache_page_op(cookie, NULL, op, fscache_page_op_invalidate);
|
||||||
|
|
||||||
spin_lock(&cookie->lock);
|
spin_lock(&cookie->lock);
|
||||||
if (fscache_submit_exclusive_op(object, op) < 0)
|
if (fscache_submit_exclusive_op(object, op) < 0)
|
||||||
|
@ -1025,6 +1043,17 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update auxiliary data.
|
||||||
|
*/
|
||||||
|
static void fscache_update_aux_data(struct fscache_object *object)
|
||||||
|
{
|
||||||
|
fscache_stat(&fscache_n_updates_run);
|
||||||
|
fscache_stat(&fscache_n_cop_update_object);
|
||||||
|
object->cache->ops->update_object(object);
|
||||||
|
fscache_stat_d(&fscache_n_cop_update_object);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Asynchronously update an object.
|
* Asynchronously update an object.
|
||||||
*/
|
*/
|
||||||
|
@ -1033,10 +1062,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
|
||||||
{
|
{
|
||||||
_enter("{OBJ%x},%d", object->debug_id, event);
|
_enter("{OBJ%x},%d", object->debug_id, event);
|
||||||
|
|
||||||
fscache_stat(&fscache_n_updates_run);
|
fscache_update_aux_data(object);
|
||||||
fscache_stat(&fscache_n_cop_update_object);
|
|
||||||
object->cache->ops->update_object(object);
|
|
||||||
fscache_stat_d(&fscache_n_cop_update_object);
|
|
||||||
|
|
||||||
_leave("");
|
_leave("");
|
||||||
return transit_to(WAIT_FOR_CMD);
|
return transit_to(WAIT_FOR_CMD);
|
||||||
|
|
|
@ -32,7 +32,8 @@ static void fscache_operation_dummy_cancel(struct fscache_operation *op)
|
||||||
* Do basic initialisation of an operation. The caller must still set flags,
|
* Do basic initialisation of an operation. The caller must still set flags,
|
||||||
* object and processor if needed.
|
* object and processor if needed.
|
||||||
*/
|
*/
|
||||||
void fscache_operation_init(struct fscache_operation *op,
|
void fscache_operation_init(struct fscache_cookie *cookie,
|
||||||
|
struct fscache_operation *op,
|
||||||
fscache_operation_processor_t processor,
|
fscache_operation_processor_t processor,
|
||||||
fscache_operation_cancel_t cancel,
|
fscache_operation_cancel_t cancel,
|
||||||
fscache_operation_release_t release)
|
fscache_operation_release_t release)
|
||||||
|
@ -46,6 +47,7 @@ void fscache_operation_init(struct fscache_operation *op,
|
||||||
op->release = release;
|
op->release = release;
|
||||||
INIT_LIST_HEAD(&op->pend_link);
|
INIT_LIST_HEAD(&op->pend_link);
|
||||||
fscache_stat(&fscache_n_op_initialised);
|
fscache_stat(&fscache_n_op_initialised);
|
||||||
|
trace_fscache_op(cookie, op, fscache_op_init);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(fscache_operation_init);
|
EXPORT_SYMBOL(fscache_operation_init);
|
||||||
|
|
||||||
|
@ -59,6 +61,8 @@ EXPORT_SYMBOL(fscache_operation_init);
|
||||||
*/
|
*/
|
||||||
void fscache_enqueue_operation(struct fscache_operation *op)
|
void fscache_enqueue_operation(struct fscache_operation *op)
|
||||||
{
|
{
|
||||||
|
struct fscache_cookie *cookie = op->object->cookie;
|
||||||
|
|
||||||
_enter("{OBJ%x OP%x,%u}",
|
_enter("{OBJ%x OP%x,%u}",
|
||||||
op->object->debug_id, op->debug_id, atomic_read(&op->usage));
|
op->object->debug_id, op->debug_id, atomic_read(&op->usage));
|
||||||
|
|
||||||
|
@ -71,12 +75,14 @@ void fscache_enqueue_operation(struct fscache_operation *op)
|
||||||
fscache_stat(&fscache_n_op_enqueue);
|
fscache_stat(&fscache_n_op_enqueue);
|
||||||
switch (op->flags & FSCACHE_OP_TYPE) {
|
switch (op->flags & FSCACHE_OP_TYPE) {
|
||||||
case FSCACHE_OP_ASYNC:
|
case FSCACHE_OP_ASYNC:
|
||||||
|
trace_fscache_op(cookie, op, fscache_op_enqueue_async);
|
||||||
_debug("queue async");
|
_debug("queue async");
|
||||||
atomic_inc(&op->usage);
|
atomic_inc(&op->usage);
|
||||||
if (!queue_work(fscache_op_wq, &op->work))
|
if (!queue_work(fscache_op_wq, &op->work))
|
||||||
fscache_put_operation(op);
|
fscache_put_operation(op);
|
||||||
break;
|
break;
|
||||||
case FSCACHE_OP_MYTHREAD:
|
case FSCACHE_OP_MYTHREAD:
|
||||||
|
trace_fscache_op(cookie, op, fscache_op_enqueue_mythread);
|
||||||
_debug("queue for caller's attention");
|
_debug("queue for caller's attention");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -101,6 +107,8 @@ static void fscache_run_op(struct fscache_object *object,
|
||||||
wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
|
wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
|
||||||
if (op->processor)
|
if (op->processor)
|
||||||
fscache_enqueue_operation(op);
|
fscache_enqueue_operation(op);
|
||||||
|
else
|
||||||
|
trace_fscache_op(object->cookie, op, fscache_op_run);
|
||||||
fscache_stat(&fscache_n_op_run);
|
fscache_stat(&fscache_n_op_run);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +163,8 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
|
||||||
|
|
||||||
_enter("{OBJ%x OP%x},", object->debug_id, op->debug_id);
|
_enter("{OBJ%x OP%x},", object->debug_id, op->debug_id);
|
||||||
|
|
||||||
|
trace_fscache_op(object->cookie, op, fscache_op_submit_ex);
|
||||||
|
|
||||||
ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED);
|
ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED);
|
||||||
ASSERTCMP(atomic_read(&op->usage), >, 0);
|
ASSERTCMP(atomic_read(&op->usage), >, 0);
|
||||||
|
|
||||||
|
@ -240,6 +250,8 @@ int fscache_submit_op(struct fscache_object *object,
|
||||||
_enter("{OBJ%x OP%x},{%u}",
|
_enter("{OBJ%x OP%x},{%u}",
|
||||||
object->debug_id, op->debug_id, atomic_read(&op->usage));
|
object->debug_id, op->debug_id, atomic_read(&op->usage));
|
||||||
|
|
||||||
|
trace_fscache_op(object->cookie, op, fscache_op_submit);
|
||||||
|
|
||||||
ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED);
|
ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED);
|
||||||
ASSERTCMP(atomic_read(&op->usage), >, 0);
|
ASSERTCMP(atomic_read(&op->usage), >, 0);
|
||||||
|
|
||||||
|
@ -357,6 +369,8 @@ int fscache_cancel_op(struct fscache_operation *op,
|
||||||
|
|
||||||
_enter("OBJ%x OP%x}", op->object->debug_id, op->debug_id);
|
_enter("OBJ%x OP%x}", op->object->debug_id, op->debug_id);
|
||||||
|
|
||||||
|
trace_fscache_op(object->cookie, op, fscache_op_cancel);
|
||||||
|
|
||||||
ASSERTCMP(op->state, >=, FSCACHE_OP_ST_PENDING);
|
ASSERTCMP(op->state, >=, FSCACHE_OP_ST_PENDING);
|
||||||
ASSERTCMP(op->state, !=, FSCACHE_OP_ST_CANCELLED);
|
ASSERTCMP(op->state, !=, FSCACHE_OP_ST_CANCELLED);
|
||||||
ASSERTCMP(atomic_read(&op->usage), >, 0);
|
ASSERTCMP(atomic_read(&op->usage), >, 0);
|
||||||
|
@ -419,6 +433,8 @@ void fscache_cancel_all_ops(struct fscache_object *object)
|
||||||
fscache_stat(&fscache_n_op_cancelled);
|
fscache_stat(&fscache_n_op_cancelled);
|
||||||
list_del_init(&op->pend_link);
|
list_del_init(&op->pend_link);
|
||||||
|
|
||||||
|
trace_fscache_op(object->cookie, op, fscache_op_cancel_all);
|
||||||
|
|
||||||
ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
|
ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
|
||||||
op->cancel(op);
|
op->cancel(op);
|
||||||
op->state = FSCACHE_OP_ST_CANCELLED;
|
op->state = FSCACHE_OP_ST_CANCELLED;
|
||||||
|
@ -454,9 +470,11 @@ void fscache_op_complete(struct fscache_operation *op, bool cancelled)
|
||||||
spin_lock(&object->lock);
|
spin_lock(&object->lock);
|
||||||
|
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
|
trace_fscache_op(object->cookie, op, fscache_op_completed);
|
||||||
op->state = FSCACHE_OP_ST_COMPLETE;
|
op->state = FSCACHE_OP_ST_COMPLETE;
|
||||||
} else {
|
} else {
|
||||||
op->cancel(op);
|
op->cancel(op);
|
||||||
|
trace_fscache_op(object->cookie, op, fscache_op_cancelled);
|
||||||
op->state = FSCACHE_OP_ST_CANCELLED;
|
op->state = FSCACHE_OP_ST_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,6 +506,8 @@ void fscache_put_operation(struct fscache_operation *op)
|
||||||
if (!atomic_dec_and_test(&op->usage))
|
if (!atomic_dec_and_test(&op->usage))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
trace_fscache_op(op->object ? op->object->cookie : NULL, op, fscache_op_put);
|
||||||
|
|
||||||
_debug("PUT OP");
|
_debug("PUT OP");
|
||||||
ASSERTIFCMP(op->state != FSCACHE_OP_ST_INITIALISED &&
|
ASSERTIFCMP(op->state != FSCACHE_OP_ST_INITIALISED &&
|
||||||
op->state != FSCACHE_OP_ST_COMPLETE,
|
op->state != FSCACHE_OP_ST_COMPLETE,
|
||||||
|
@ -563,6 +583,8 @@ void fscache_operation_gc(struct work_struct *work)
|
||||||
spin_unlock(&cache->op_gc_list_lock);
|
spin_unlock(&cache->op_gc_list_lock);
|
||||||
|
|
||||||
object = op->object;
|
object = op->object;
|
||||||
|
trace_fscache_op(object->cookie, op, fscache_op_gc);
|
||||||
|
|
||||||
spin_lock(&object->lock);
|
spin_lock(&object->lock);
|
||||||
|
|
||||||
_debug("GC DEFERRED REL OBJ%x OP%x",
|
_debug("GC DEFERRED REL OBJ%x OP%x",
|
||||||
|
@ -601,6 +623,8 @@ void fscache_op_work_func(struct work_struct *work)
|
||||||
_enter("{OBJ%x OP%x,%d}",
|
_enter("{OBJ%x OP%x,%d}",
|
||||||
op->object->debug_id, op->debug_id, atomic_read(&op->usage));
|
op->object->debug_id, op->debug_id, atomic_read(&op->usage));
|
||||||
|
|
||||||
|
trace_fscache_op(op->object->cookie, op, fscache_op_work);
|
||||||
|
|
||||||
ASSERT(op->processor != NULL);
|
ASSERT(op->processor != NULL);
|
||||||
start = jiffies;
|
start = jiffies;
|
||||||
op->processor(op);
|
op->processor(op);
|
||||||
|
|
|
@ -27,6 +27,7 @@ bool __fscache_check_page_write(struct fscache_cookie *cookie, struct page *page
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
val = radix_tree_lookup(&cookie->stores, page->index);
|
val = radix_tree_lookup(&cookie->stores, page->index);
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
trace_fscache_check_page(cookie, page, val, 0);
|
||||||
|
|
||||||
return val != NULL;
|
return val != NULL;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +40,8 @@ void __fscache_wait_on_page_write(struct fscache_cookie *cookie, struct page *pa
|
||||||
{
|
{
|
||||||
wait_queue_head_t *wq = bit_waitqueue(&cookie->flags, 0);
|
wait_queue_head_t *wq = bit_waitqueue(&cookie->flags, 0);
|
||||||
|
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_write_wait);
|
||||||
|
|
||||||
wait_event(*wq, !__fscache_check_page_write(cookie, page));
|
wait_event(*wq, !__fscache_check_page_write(cookie, page));
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__fscache_wait_on_page_write);
|
EXPORT_SYMBOL(__fscache_wait_on_page_write);
|
||||||
|
@ -69,6 +72,8 @@ bool __fscache_maybe_release_page(struct fscache_cookie *cookie,
|
||||||
|
|
||||||
_enter("%p,%p,%x", cookie, page, gfp);
|
_enter("%p,%p,%x", cookie, page, gfp);
|
||||||
|
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_maybe_release);
|
||||||
|
|
||||||
try_again:
|
try_again:
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
val = radix_tree_lookup(&cookie->stores, page->index);
|
val = radix_tree_lookup(&cookie->stores, page->index);
|
||||||
|
@ -101,6 +106,7 @@ try_again:
|
||||||
}
|
}
|
||||||
|
|
||||||
xpage = radix_tree_delete(&cookie->stores, page->index);
|
xpage = radix_tree_delete(&cookie->stores, page->index);
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_radix_delete);
|
||||||
spin_unlock(&cookie->stores_lock);
|
spin_unlock(&cookie->stores_lock);
|
||||||
|
|
||||||
if (xpage) {
|
if (xpage) {
|
||||||
|
@ -112,6 +118,7 @@ try_again:
|
||||||
}
|
}
|
||||||
|
|
||||||
wake_up_bit(&cookie->flags, 0);
|
wake_up_bit(&cookie->flags, 0);
|
||||||
|
trace_fscache_wake_cookie(cookie);
|
||||||
if (xpage)
|
if (xpage)
|
||||||
put_page(xpage);
|
put_page(xpage);
|
||||||
__fscache_uncache_page(cookie, page);
|
__fscache_uncache_page(cookie, page);
|
||||||
|
@ -144,7 +151,7 @@ static void fscache_end_page_write(struct fscache_object *object,
|
||||||
struct page *page)
|
struct page *page)
|
||||||
{
|
{
|
||||||
struct fscache_cookie *cookie;
|
struct fscache_cookie *cookie;
|
||||||
struct page *xpage = NULL;
|
struct page *xpage = NULL, *val;
|
||||||
|
|
||||||
spin_lock(&object->lock);
|
spin_lock(&object->lock);
|
||||||
cookie = object->cookie;
|
cookie = object->cookie;
|
||||||
|
@ -154,13 +161,24 @@ static void fscache_end_page_write(struct fscache_object *object,
|
||||||
spin_lock(&cookie->stores_lock);
|
spin_lock(&cookie->stores_lock);
|
||||||
radix_tree_tag_clear(&cookie->stores, page->index,
|
radix_tree_tag_clear(&cookie->stores, page->index,
|
||||||
FSCACHE_COOKIE_STORING_TAG);
|
FSCACHE_COOKIE_STORING_TAG);
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_radix_clear_store);
|
||||||
if (!radix_tree_tag_get(&cookie->stores, page->index,
|
if (!radix_tree_tag_get(&cookie->stores, page->index,
|
||||||
FSCACHE_COOKIE_PENDING_TAG)) {
|
FSCACHE_COOKIE_PENDING_TAG)) {
|
||||||
fscache_stat(&fscache_n_store_radix_deletes);
|
fscache_stat(&fscache_n_store_radix_deletes);
|
||||||
xpage = radix_tree_delete(&cookie->stores, page->index);
|
xpage = radix_tree_delete(&cookie->stores, page->index);
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_radix_delete);
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_write_end);
|
||||||
|
|
||||||
|
val = radix_tree_lookup(&cookie->stores, page->index);
|
||||||
|
trace_fscache_check_page(cookie, page, val, 1);
|
||||||
|
} else {
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_write_end_pend);
|
||||||
}
|
}
|
||||||
spin_unlock(&cookie->stores_lock);
|
spin_unlock(&cookie->stores_lock);
|
||||||
wake_up_bit(&cookie->flags, 0);
|
wake_up_bit(&cookie->flags, 0);
|
||||||
|
trace_fscache_wake_cookie(cookie);
|
||||||
|
} else {
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_write_end_noc);
|
||||||
}
|
}
|
||||||
spin_unlock(&object->lock);
|
spin_unlock(&object->lock);
|
||||||
if (xpage)
|
if (xpage)
|
||||||
|
@ -185,9 +203,11 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
|
||||||
fscache_stat_d(&fscache_n_cop_attr_changed);
|
fscache_stat_d(&fscache_n_cop_attr_changed);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
fscache_abort_object(object);
|
fscache_abort_object(object);
|
||||||
|
fscache_op_complete(op, ret < 0);
|
||||||
|
} else {
|
||||||
|
fscache_op_complete(op, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
fscache_op_complete(op, true);
|
|
||||||
_leave("");
|
_leave("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +233,8 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
fscache_operation_init(op, fscache_attr_changed_op, NULL, NULL);
|
fscache_operation_init(cookie, op, fscache_attr_changed_op, NULL, NULL);
|
||||||
|
trace_fscache_page_op(cookie, NULL, op, fscache_page_op_attr_changed);
|
||||||
op->flags = FSCACHE_OP_ASYNC |
|
op->flags = FSCACHE_OP_ASYNC |
|
||||||
(1 << FSCACHE_OP_EXCLUSIVE) |
|
(1 << FSCACHE_OP_EXCLUSIVE) |
|
||||||
(1 << FSCACHE_OP_UNUSE_COOKIE);
|
(1 << FSCACHE_OP_UNUSE_COOKIE);
|
||||||
|
@ -297,7 +318,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fscache_operation_init(&op->op, NULL,
|
fscache_operation_init(cookie, &op->op, NULL,
|
||||||
fscache_do_cancel_retrieval,
|
fscache_do_cancel_retrieval,
|
||||||
fscache_release_retrieval_op);
|
fscache_release_retrieval_op);
|
||||||
op->op.flags = FSCACHE_OP_MYTHREAD |
|
op->op.flags = FSCACHE_OP_MYTHREAD |
|
||||||
|
@ -368,6 +389,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
|
||||||
fscache_stat(stat_op_waits);
|
fscache_stat(stat_op_waits);
|
||||||
if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
|
if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
|
||||||
TASK_INTERRUPTIBLE) != 0) {
|
TASK_INTERRUPTIBLE) != 0) {
|
||||||
|
trace_fscache_op(object->cookie, op, fscache_op_signal);
|
||||||
ret = fscache_cancel_op(op, false);
|
ret = fscache_cancel_op(op, false);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
return -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
|
@ -389,6 +411,7 @@ check_if_dead:
|
||||||
if (unlikely(fscache_object_is_dying(object) ||
|
if (unlikely(fscache_object_is_dying(object) ||
|
||||||
fscache_cache_is_broken(object))) {
|
fscache_cache_is_broken(object))) {
|
||||||
enum fscache_operation_state state = op->state;
|
enum fscache_operation_state state = op->state;
|
||||||
|
trace_fscache_op(object->cookie, op, fscache_op_signal);
|
||||||
fscache_cancel_op(op, true);
|
fscache_cancel_op(op, true);
|
||||||
if (stat_object_dead)
|
if (stat_object_dead)
|
||||||
fscache_stat(stat_object_dead);
|
fscache_stat(stat_object_dead);
|
||||||
|
@ -443,6 +466,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
atomic_set(&op->n_pages, 1);
|
atomic_set(&op->n_pages, 1);
|
||||||
|
trace_fscache_page_op(cookie, page, &op->op, fscache_page_op_retr_one);
|
||||||
|
|
||||||
spin_lock(&cookie->lock);
|
spin_lock(&cookie->lock);
|
||||||
|
|
||||||
|
@ -571,6 +595,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
|
||||||
if (!op)
|
if (!op)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
atomic_set(&op->n_pages, *nr_pages);
|
atomic_set(&op->n_pages, *nr_pages);
|
||||||
|
trace_fscache_page_op(cookie, NULL, &op->op, fscache_page_op_retr_multi);
|
||||||
|
|
||||||
spin_lock(&cookie->lock);
|
spin_lock(&cookie->lock);
|
||||||
|
|
||||||
|
@ -682,6 +707,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
|
||||||
if (!op)
|
if (!op)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
atomic_set(&op->n_pages, 1);
|
atomic_set(&op->n_pages, 1);
|
||||||
|
trace_fscache_page_op(cookie, page, &op->op, fscache_page_op_alloc_one);
|
||||||
|
|
||||||
spin_lock(&cookie->lock);
|
spin_lock(&cookie->lock);
|
||||||
|
|
||||||
|
@ -776,15 +802,17 @@ static void fscache_write_op(struct fscache_operation *_op)
|
||||||
|
|
||||||
_enter("{OP%x,%d}", op->op.debug_id, atomic_read(&op->op.usage));
|
_enter("{OP%x,%d}", op->op.debug_id, atomic_read(&op->op.usage));
|
||||||
|
|
||||||
|
again:
|
||||||
spin_lock(&object->lock);
|
spin_lock(&object->lock);
|
||||||
cookie = object->cookie;
|
cookie = object->cookie;
|
||||||
|
|
||||||
if (!fscache_object_is_active(object)) {
|
if (!fscache_object_is_active(object)) {
|
||||||
/* If we get here, then the on-disk cache object likely longer
|
/* If we get here, then the on-disk cache object likely no
|
||||||
* exists, so we should just cancel this write operation.
|
* longer exists, so we should just cancel this write
|
||||||
|
* operation.
|
||||||
*/
|
*/
|
||||||
spin_unlock(&object->lock);
|
spin_unlock(&object->lock);
|
||||||
fscache_op_complete(&op->op, false);
|
fscache_op_complete(&op->op, true);
|
||||||
_leave(" [inactive]");
|
_leave(" [inactive]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -797,7 +825,7 @@ static void fscache_write_op(struct fscache_operation *_op)
|
||||||
* cancel this write operation.
|
* cancel this write operation.
|
||||||
*/
|
*/
|
||||||
spin_unlock(&object->lock);
|
spin_unlock(&object->lock);
|
||||||
fscache_op_complete(&op->op, false);
|
fscache_op_complete(&op->op, true);
|
||||||
_leave(" [cancel] op{f=%lx s=%u} obj{s=%s f=%lx}",
|
_leave(" [cancel] op{f=%lx s=%u} obj{s=%s f=%lx}",
|
||||||
_op->flags, _op->state, object->state->short_name,
|
_op->flags, _op->state, object->state->short_name,
|
||||||
object->flags);
|
object->flags);
|
||||||
|
@ -809,30 +837,33 @@ static void fscache_write_op(struct fscache_operation *_op)
|
||||||
fscache_stat(&fscache_n_store_calls);
|
fscache_stat(&fscache_n_store_calls);
|
||||||
|
|
||||||
/* find a page to store */
|
/* find a page to store */
|
||||||
|
results[0] = NULL;
|
||||||
page = NULL;
|
page = NULL;
|
||||||
n = radix_tree_gang_lookup_tag(&cookie->stores, results, 0, 1,
|
n = radix_tree_gang_lookup_tag(&cookie->stores, results, 0, 1,
|
||||||
FSCACHE_COOKIE_PENDING_TAG);
|
FSCACHE_COOKIE_PENDING_TAG);
|
||||||
|
trace_fscache_gang_lookup(cookie, &op->op, results, n, op->store_limit);
|
||||||
if (n != 1)
|
if (n != 1)
|
||||||
goto superseded;
|
goto superseded;
|
||||||
page = results[0];
|
page = results[0];
|
||||||
_debug("gang %d [%lx]", n, page->index);
|
_debug("gang %d [%lx]", n, page->index);
|
||||||
if (page->index >= op->store_limit) {
|
|
||||||
fscache_stat(&fscache_n_store_pages_over_limit);
|
|
||||||
goto superseded;
|
|
||||||
}
|
|
||||||
|
|
||||||
radix_tree_tag_set(&cookie->stores, page->index,
|
radix_tree_tag_set(&cookie->stores, page->index,
|
||||||
FSCACHE_COOKIE_STORING_TAG);
|
FSCACHE_COOKIE_STORING_TAG);
|
||||||
radix_tree_tag_clear(&cookie->stores, page->index,
|
radix_tree_tag_clear(&cookie->stores, page->index,
|
||||||
FSCACHE_COOKIE_PENDING_TAG);
|
FSCACHE_COOKIE_PENDING_TAG);
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_radix_pend2store);
|
||||||
|
|
||||||
spin_unlock(&cookie->stores_lock);
|
spin_unlock(&cookie->stores_lock);
|
||||||
spin_unlock(&object->lock);
|
spin_unlock(&object->lock);
|
||||||
|
|
||||||
|
if (page->index >= op->store_limit)
|
||||||
|
goto discard_page;
|
||||||
|
|
||||||
fscache_stat(&fscache_n_store_pages);
|
fscache_stat(&fscache_n_store_pages);
|
||||||
fscache_stat(&fscache_n_cop_write_page);
|
fscache_stat(&fscache_n_cop_write_page);
|
||||||
ret = object->cache->ops->write_page(op, page);
|
ret = object->cache->ops->write_page(op, page);
|
||||||
fscache_stat_d(&fscache_n_cop_write_page);
|
fscache_stat_d(&fscache_n_cop_write_page);
|
||||||
|
trace_fscache_wrote_page(cookie, page, &op->op, ret);
|
||||||
fscache_end_page_write(object, page);
|
fscache_end_page_write(object, page);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fscache_abort_object(object);
|
fscache_abort_object(object);
|
||||||
|
@ -844,6 +875,12 @@ static void fscache_write_op(struct fscache_operation *_op)
|
||||||
_leave("");
|
_leave("");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
discard_page:
|
||||||
|
fscache_stat(&fscache_n_store_pages_over_limit);
|
||||||
|
trace_fscache_wrote_page(cookie, page, &op->op, -ENOBUFS);
|
||||||
|
fscache_end_page_write(object, page);
|
||||||
|
goto again;
|
||||||
|
|
||||||
superseded:
|
superseded:
|
||||||
/* this writer is going away and there aren't any more things to
|
/* this writer is going away and there aren't any more things to
|
||||||
* write */
|
* write */
|
||||||
|
@ -851,7 +888,7 @@ superseded:
|
||||||
spin_unlock(&cookie->stores_lock);
|
spin_unlock(&cookie->stores_lock);
|
||||||
clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags);
|
clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags);
|
||||||
spin_unlock(&object->lock);
|
spin_unlock(&object->lock);
|
||||||
fscache_op_complete(&op->op, true);
|
fscache_op_complete(&op->op, false);
|
||||||
_leave("");
|
_leave("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -879,6 +916,8 @@ void fscache_invalidate_writes(struct fscache_cookie *cookie)
|
||||||
for (i = n - 1; i >= 0; i--) {
|
for (i = n - 1; i >= 0; i--) {
|
||||||
page = results[i];
|
page = results[i];
|
||||||
radix_tree_delete(&cookie->stores, page->index);
|
radix_tree_delete(&cookie->stores, page->index);
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_radix_delete);
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_inval);
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock(&cookie->stores_lock);
|
spin_unlock(&cookie->stores_lock);
|
||||||
|
@ -888,6 +927,7 @@ void fscache_invalidate_writes(struct fscache_cookie *cookie)
|
||||||
}
|
}
|
||||||
|
|
||||||
wake_up_bit(&cookie->flags, 0);
|
wake_up_bit(&cookie->flags, 0);
|
||||||
|
trace_fscache_wake_cookie(cookie);
|
||||||
|
|
||||||
_leave("");
|
_leave("");
|
||||||
}
|
}
|
||||||
|
@ -923,6 +963,7 @@ void fscache_invalidate_writes(struct fscache_cookie *cookie)
|
||||||
*/
|
*/
|
||||||
int __fscache_write_page(struct fscache_cookie *cookie,
|
int __fscache_write_page(struct fscache_cookie *cookie,
|
||||||
struct page *page,
|
struct page *page,
|
||||||
|
loff_t object_size,
|
||||||
gfp_t gfp)
|
gfp_t gfp)
|
||||||
{
|
{
|
||||||
struct fscache_storage *op;
|
struct fscache_storage *op;
|
||||||
|
@ -946,7 +987,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
|
||||||
if (!op)
|
if (!op)
|
||||||
goto nomem;
|
goto nomem;
|
||||||
|
|
||||||
fscache_operation_init(&op->op, fscache_write_op, NULL,
|
fscache_operation_init(cookie, &op->op, fscache_write_op, NULL,
|
||||||
fscache_release_write_op);
|
fscache_release_write_op);
|
||||||
op->op.flags = FSCACHE_OP_ASYNC |
|
op->op.flags = FSCACHE_OP_ASYNC |
|
||||||
(1 << FSCACHE_OP_WAITING) |
|
(1 << FSCACHE_OP_WAITING) |
|
||||||
|
@ -956,6 +997,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto nomem_free;
|
goto nomem_free;
|
||||||
|
|
||||||
|
trace_fscache_page_op(cookie, page, &op->op, fscache_page_op_write_one);
|
||||||
|
|
||||||
ret = -ENOBUFS;
|
ret = -ENOBUFS;
|
||||||
spin_lock(&cookie->lock);
|
spin_lock(&cookie->lock);
|
||||||
|
|
||||||
|
@ -967,9 +1010,15 @@ int __fscache_write_page(struct fscache_cookie *cookie,
|
||||||
if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
|
if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
|
||||||
goto nobufs;
|
goto nobufs;
|
||||||
|
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_write);
|
||||||
|
|
||||||
/* add the page to the pending-storage radix tree on the backing
|
/* add the page to the pending-storage radix tree on the backing
|
||||||
* object */
|
* object */
|
||||||
spin_lock(&object->lock);
|
spin_lock(&object->lock);
|
||||||
|
|
||||||
|
if (object->store_limit_l != object_size)
|
||||||
|
fscache_set_store_limit(object, object_size);
|
||||||
|
|
||||||
spin_lock(&cookie->stores_lock);
|
spin_lock(&cookie->stores_lock);
|
||||||
|
|
||||||
_debug("store limit %llx", (unsigned long long) object->store_limit);
|
_debug("store limit %llx", (unsigned long long) object->store_limit);
|
||||||
|
@ -982,8 +1031,10 @@ int __fscache_write_page(struct fscache_cookie *cookie,
|
||||||
goto nobufs_unlock_obj;
|
goto nobufs_unlock_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_radix_insert);
|
||||||
radix_tree_tag_set(&cookie->stores, page->index,
|
radix_tree_tag_set(&cookie->stores, page->index,
|
||||||
FSCACHE_COOKIE_PENDING_TAG);
|
FSCACHE_COOKIE_PENDING_TAG);
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_radix_set_pend);
|
||||||
get_page(page);
|
get_page(page);
|
||||||
|
|
||||||
/* we only want one writer at a time, but we do need to queue new
|
/* we only want one writer at a time, but we do need to queue new
|
||||||
|
@ -1026,6 +1077,7 @@ already_pending:
|
||||||
submit_failed:
|
submit_failed:
|
||||||
spin_lock(&cookie->stores_lock);
|
spin_lock(&cookie->stores_lock);
|
||||||
radix_tree_delete(&cookie->stores, page->index);
|
radix_tree_delete(&cookie->stores, page->index);
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_radix_delete);
|
||||||
spin_unlock(&cookie->stores_lock);
|
spin_unlock(&cookie->stores_lock);
|
||||||
wake_cookie = __fscache_unuse_cookie(cookie);
|
wake_cookie = __fscache_unuse_cookie(cookie);
|
||||||
put_page(page);
|
put_page(page);
|
||||||
|
@ -1072,6 +1124,8 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
|
||||||
if (!PageFsCache(page))
|
if (!PageFsCache(page))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_uncache);
|
||||||
|
|
||||||
/* get the object */
|
/* get the object */
|
||||||
spin_lock(&cookie->lock);
|
spin_lock(&cookie->lock);
|
||||||
|
|
||||||
|
@ -1120,6 +1174,8 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
|
||||||
atomic_inc(&fscache_n_marks);
|
atomic_inc(&fscache_n_marks);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
trace_fscache_page(cookie, page, fscache_page_cached);
|
||||||
|
|
||||||
_debug("- mark %p{%lx}", page, page->index);
|
_debug("- mark %p{%lx}", page, page->index);
|
||||||
if (TestSetPageFsCache(page)) {
|
if (TestSetPageFsCache(page)) {
|
||||||
static bool once_only;
|
static bool once_only;
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
atomic_t fscache_n_op_pend;
|
atomic_t fscache_n_op_pend;
|
||||||
atomic_t fscache_n_op_run;
|
atomic_t fscache_n_op_run;
|
||||||
atomic_t fscache_n_op_enqueue;
|
atomic_t fscache_n_op_enqueue;
|
||||||
atomic_t fscache_n_op_requeue;
|
|
||||||
atomic_t fscache_n_op_deferred_release;
|
atomic_t fscache_n_op_deferred_release;
|
||||||
atomic_t fscache_n_op_initialised;
|
atomic_t fscache_n_op_initialised;
|
||||||
atomic_t fscache_n_op_release;
|
atomic_t fscache_n_op_release;
|
||||||
|
|
|
@ -49,59 +49,6 @@ void nfs_fscache_unregister(void)
|
||||||
fscache_unregister_netfs(&nfs_fscache_netfs);
|
fscache_unregister_netfs(&nfs_fscache_netfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Layout of the key for an NFS server cache object.
|
|
||||||
*/
|
|
||||||
struct nfs_server_key {
|
|
||||||
uint16_t nfsversion; /* NFS protocol version */
|
|
||||||
uint16_t family; /* address family */
|
|
||||||
uint16_t port; /* IP port */
|
|
||||||
union {
|
|
||||||
struct in_addr ipv4_addr; /* IPv4 address */
|
|
||||||
struct in6_addr ipv6_addr; /* IPv6 address */
|
|
||||||
} addr[0];
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Generate a key to describe a server in the main NFS index
|
|
||||||
* - We return the length of the key, or 0 if we can't generate one
|
|
||||||
*/
|
|
||||||
static uint16_t nfs_server_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax)
|
|
||||||
{
|
|
||||||
const struct nfs_client *clp = cookie_netfs_data;
|
|
||||||
const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) &clp->cl_addr;
|
|
||||||
const struct sockaddr_in *sin = (struct sockaddr_in *) &clp->cl_addr;
|
|
||||||
struct nfs_server_key *key = buffer;
|
|
||||||
uint16_t len = sizeof(struct nfs_server_key);
|
|
||||||
|
|
||||||
memset(key, 0, len);
|
|
||||||
key->nfsversion = clp->rpc_ops->version;
|
|
||||||
key->family = clp->cl_addr.ss_family;
|
|
||||||
|
|
||||||
switch (clp->cl_addr.ss_family) {
|
|
||||||
case AF_INET:
|
|
||||||
key->port = sin->sin_port;
|
|
||||||
key->addr[0].ipv4_addr = sin->sin_addr;
|
|
||||||
len += sizeof(key->addr[0].ipv4_addr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AF_INET6:
|
|
||||||
key->port = sin6->sin6_port;
|
|
||||||
key->addr[0].ipv6_addr = sin6->sin6_addr;
|
|
||||||
len += sizeof(key->addr[0].ipv6_addr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
printk(KERN_WARNING "NFS: Unknown network family '%d'\n",
|
|
||||||
clp->cl_addr.ss_family);
|
|
||||||
len = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define the server object for FS-Cache. This is used to describe a server
|
* Define the server object for FS-Cache. This is used to describe a server
|
||||||
* object to fscache_acquire_cookie(). It is keyed by the NFS protocol and
|
* object to fscache_acquire_cookie(). It is keyed by the NFS protocol and
|
||||||
|
@ -110,32 +57,8 @@ static uint16_t nfs_server_get_key(const void *cookie_netfs_data,
|
||||||
const struct fscache_cookie_def nfs_fscache_server_index_def = {
|
const struct fscache_cookie_def nfs_fscache_server_index_def = {
|
||||||
.name = "NFS.server",
|
.name = "NFS.server",
|
||||||
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
||||||
.get_key = nfs_server_get_key,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Generate a key to describe a superblock key in the main NFS index
|
|
||||||
*/
|
|
||||||
static uint16_t nfs_super_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax)
|
|
||||||
{
|
|
||||||
const struct nfs_fscache_key *key;
|
|
||||||
const struct nfs_server *nfss = cookie_netfs_data;
|
|
||||||
uint16_t len;
|
|
||||||
|
|
||||||
key = nfss->fscache_key;
|
|
||||||
len = sizeof(key->key) + key->key.uniq_len;
|
|
||||||
if (len > bufmax) {
|
|
||||||
len = 0;
|
|
||||||
} else {
|
|
||||||
memcpy(buffer, &key->key, sizeof(key->key));
|
|
||||||
memcpy(buffer + sizeof(key->key),
|
|
||||||
key->key.uniquifier, key->key.uniq_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define the superblock object for FS-Cache. This is used to describe a
|
* Define the superblock object for FS-Cache. This is used to describe a
|
||||||
* superblock object to fscache_acquire_cookie(). It is keyed by all the NFS
|
* superblock object to fscache_acquire_cookie(). It is keyed by all the NFS
|
||||||
|
@ -144,83 +67,8 @@ static uint16_t nfs_super_get_key(const void *cookie_netfs_data,
|
||||||
const struct fscache_cookie_def nfs_fscache_super_index_def = {
|
const struct fscache_cookie_def nfs_fscache_super_index_def = {
|
||||||
.name = "NFS.super",
|
.name = "NFS.super",
|
||||||
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
.type = FSCACHE_COOKIE_TYPE_INDEX,
|
||||||
.get_key = nfs_super_get_key,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Definition of the auxiliary data attached to NFS inode storage objects
|
|
||||||
* within the cache.
|
|
||||||
*
|
|
||||||
* The contents of this struct are recorded in the on-disk local cache in the
|
|
||||||
* auxiliary data attached to the data storage object backing an inode. This
|
|
||||||
* permits coherency to be managed when a new inode binds to an already extant
|
|
||||||
* cache object.
|
|
||||||
*/
|
|
||||||
struct nfs_fscache_inode_auxdata {
|
|
||||||
struct timespec mtime;
|
|
||||||
struct timespec ctime;
|
|
||||||
loff_t size;
|
|
||||||
u64 change_attr;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Generate a key to describe an NFS inode in an NFS server's index
|
|
||||||
*/
|
|
||||||
static uint16_t nfs_fscache_inode_get_key(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax)
|
|
||||||
{
|
|
||||||
const struct nfs_inode *nfsi = cookie_netfs_data;
|
|
||||||
uint16_t nsize;
|
|
||||||
|
|
||||||
/* use the inode's NFS filehandle as the key */
|
|
||||||
nsize = nfsi->fh.size;
|
|
||||||
memcpy(buffer, nfsi->fh.data, nsize);
|
|
||||||
return nsize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get certain file attributes from the netfs data
|
|
||||||
* - This function can be absent for an index
|
|
||||||
* - Not permitted to return an error
|
|
||||||
* - The netfs data from the cookie being used as the source is presented
|
|
||||||
*/
|
|
||||||
static void nfs_fscache_inode_get_attr(const void *cookie_netfs_data,
|
|
||||||
uint64_t *size)
|
|
||||||
{
|
|
||||||
const struct nfs_inode *nfsi = cookie_netfs_data;
|
|
||||||
|
|
||||||
*size = nfsi->vfs_inode.i_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the auxiliary data from netfs data
|
|
||||||
* - This function can be absent if the index carries no state data
|
|
||||||
* - Should store the auxiliary data in the buffer
|
|
||||||
* - Should return the amount of amount stored
|
|
||||||
* - Not permitted to return an error
|
|
||||||
* - The netfs data from the cookie being used as the source is presented
|
|
||||||
*/
|
|
||||||
static uint16_t nfs_fscache_inode_get_aux(const void *cookie_netfs_data,
|
|
||||||
void *buffer, uint16_t bufmax)
|
|
||||||
{
|
|
||||||
struct nfs_fscache_inode_auxdata auxdata;
|
|
||||||
const struct nfs_inode *nfsi = cookie_netfs_data;
|
|
||||||
|
|
||||||
memset(&auxdata, 0, sizeof(auxdata));
|
|
||||||
auxdata.size = nfsi->vfs_inode.i_size;
|
|
||||||
auxdata.mtime = nfsi->vfs_inode.i_mtime;
|
|
||||||
auxdata.ctime = nfsi->vfs_inode.i_ctime;
|
|
||||||
|
|
||||||
if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
|
|
||||||
auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
|
|
||||||
|
|
||||||
if (bufmax > sizeof(auxdata))
|
|
||||||
bufmax = sizeof(auxdata);
|
|
||||||
|
|
||||||
memcpy(buffer, &auxdata, bufmax);
|
|
||||||
return bufmax;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Consult the netfs about the state of an object
|
* Consult the netfs about the state of an object
|
||||||
* - This function can be absent if the index carries no state data
|
* - This function can be absent if the index carries no state data
|
||||||
|
@ -230,7 +78,8 @@ static uint16_t nfs_fscache_inode_get_aux(const void *cookie_netfs_data,
|
||||||
static
|
static
|
||||||
enum fscache_checkaux nfs_fscache_inode_check_aux(void *cookie_netfs_data,
|
enum fscache_checkaux nfs_fscache_inode_check_aux(void *cookie_netfs_data,
|
||||||
const void *data,
|
const void *data,
|
||||||
uint16_t datalen)
|
uint16_t datalen,
|
||||||
|
loff_t object_size)
|
||||||
{
|
{
|
||||||
struct nfs_fscache_inode_auxdata auxdata;
|
struct nfs_fscache_inode_auxdata auxdata;
|
||||||
struct nfs_inode *nfsi = cookie_netfs_data;
|
struct nfs_inode *nfsi = cookie_netfs_data;
|
||||||
|
@ -239,7 +88,6 @@ enum fscache_checkaux nfs_fscache_inode_check_aux(void *cookie_netfs_data,
|
||||||
return FSCACHE_CHECKAUX_OBSOLETE;
|
return FSCACHE_CHECKAUX_OBSOLETE;
|
||||||
|
|
||||||
memset(&auxdata, 0, sizeof(auxdata));
|
memset(&auxdata, 0, sizeof(auxdata));
|
||||||
auxdata.size = nfsi->vfs_inode.i_size;
|
|
||||||
auxdata.mtime = nfsi->vfs_inode.i_mtime;
|
auxdata.mtime = nfsi->vfs_inode.i_mtime;
|
||||||
auxdata.ctime = nfsi->vfs_inode.i_ctime;
|
auxdata.ctime = nfsi->vfs_inode.i_ctime;
|
||||||
|
|
||||||
|
@ -288,9 +136,6 @@ static void nfs_fh_put_context(void *cookie_netfs_data, void *context)
|
||||||
const struct fscache_cookie_def nfs_fscache_inode_object_def = {
|
const struct fscache_cookie_def nfs_fscache_inode_object_def = {
|
||||||
.name = "NFS.fh",
|
.name = "NFS.fh",
|
||||||
.type = FSCACHE_COOKIE_TYPE_DATAFILE,
|
.type = FSCACHE_COOKIE_TYPE_DATAFILE,
|
||||||
.get_key = nfs_fscache_inode_get_key,
|
|
||||||
.get_attr = nfs_fscache_inode_get_attr,
|
|
||||||
.get_aux = nfs_fscache_inode_get_aux,
|
|
||||||
.check_aux = nfs_fscache_inode_check_aux,
|
.check_aux = nfs_fscache_inode_check_aux,
|
||||||
.get_context = nfs_fh_get_context,
|
.get_context = nfs_fh_get_context,
|
||||||
.put_context = nfs_fh_put_context,
|
.put_context = nfs_fh_put_context,
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <linux/in6.h>
|
#include <linux/in6.h>
|
||||||
#include <linux/seq_file.h>
|
#include <linux/seq_file.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/iversion.h>
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "iostat.h"
|
#include "iostat.h"
|
||||||
|
@ -28,6 +29,21 @@
|
||||||
static struct rb_root nfs_fscache_keys = RB_ROOT;
|
static struct rb_root nfs_fscache_keys = RB_ROOT;
|
||||||
static DEFINE_SPINLOCK(nfs_fscache_keys_lock);
|
static DEFINE_SPINLOCK(nfs_fscache_keys_lock);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Layout of the key for an NFS server cache object.
|
||||||
|
*/
|
||||||
|
struct nfs_server_key {
|
||||||
|
struct {
|
||||||
|
uint16_t nfsversion; /* NFS protocol version */
|
||||||
|
uint16_t family; /* address family */
|
||||||
|
__be16 port; /* IP port */
|
||||||
|
} hdr;
|
||||||
|
union {
|
||||||
|
struct in_addr ipv4_addr; /* IPv4 address */
|
||||||
|
struct in6_addr ipv6_addr; /* IPv6 address */
|
||||||
|
};
|
||||||
|
} __packed;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the per-client index cookie for an NFS client if the appropriate mount
|
* Get the per-client index cookie for an NFS client if the appropriate mount
|
||||||
* flag was set
|
* flag was set
|
||||||
|
@ -36,10 +52,41 @@ static DEFINE_SPINLOCK(nfs_fscache_keys_lock);
|
||||||
*/
|
*/
|
||||||
void nfs_fscache_get_client_cookie(struct nfs_client *clp)
|
void nfs_fscache_get_client_cookie(struct nfs_client *clp)
|
||||||
{
|
{
|
||||||
|
const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) &clp->cl_addr;
|
||||||
|
const struct sockaddr_in *sin = (struct sockaddr_in *) &clp->cl_addr;
|
||||||
|
struct nfs_server_key key;
|
||||||
|
uint16_t len = sizeof(key.hdr);
|
||||||
|
|
||||||
|
memset(&key, 0, sizeof(key));
|
||||||
|
key.hdr.nfsversion = clp->rpc_ops->version;
|
||||||
|
key.hdr.family = clp->cl_addr.ss_family;
|
||||||
|
|
||||||
|
switch (clp->cl_addr.ss_family) {
|
||||||
|
case AF_INET:
|
||||||
|
key.hdr.port = sin->sin_port;
|
||||||
|
key.ipv4_addr = sin->sin_addr;
|
||||||
|
len += sizeof(key.ipv4_addr);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AF_INET6:
|
||||||
|
key.hdr.port = sin6->sin6_port;
|
||||||
|
key.ipv6_addr = sin6->sin6_addr;
|
||||||
|
len += sizeof(key.ipv6_addr);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printk(KERN_WARNING "NFS: Unknown network family '%d'\n",
|
||||||
|
clp->cl_addr.ss_family);
|
||||||
|
clp->fscache = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* create a cache index for looking up filehandles */
|
/* create a cache index for looking up filehandles */
|
||||||
clp->fscache = fscache_acquire_cookie(nfs_fscache_netfs.primary_index,
|
clp->fscache = fscache_acquire_cookie(nfs_fscache_netfs.primary_index,
|
||||||
&nfs_fscache_server_index_def,
|
&nfs_fscache_server_index_def,
|
||||||
clp, true);
|
&key, len,
|
||||||
|
NULL, 0,
|
||||||
|
clp, 0, true);
|
||||||
dfprintk(FSCACHE, "NFS: get client cookie (0x%p/0x%p)\n",
|
dfprintk(FSCACHE, "NFS: get client cookie (0x%p/0x%p)\n",
|
||||||
clp, clp->fscache);
|
clp, clp->fscache);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +99,7 @@ void nfs_fscache_release_client_cookie(struct nfs_client *clp)
|
||||||
dfprintk(FSCACHE, "NFS: releasing client cookie (0x%p/0x%p)\n",
|
dfprintk(FSCACHE, "NFS: releasing client cookie (0x%p/0x%p)\n",
|
||||||
clp, clp->fscache);
|
clp, clp->fscache);
|
||||||
|
|
||||||
fscache_relinquish_cookie(clp->fscache, 0);
|
fscache_relinquish_cookie(clp->fscache, NULL, false);
|
||||||
clp->fscache = NULL;
|
clp->fscache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +186,9 @@ void nfs_fscache_get_super_cookie(struct super_block *sb, const char *uniq, int
|
||||||
/* create a cache index for looking up filehandles */
|
/* create a cache index for looking up filehandles */
|
||||||
nfss->fscache = fscache_acquire_cookie(nfss->nfs_client->fscache,
|
nfss->fscache = fscache_acquire_cookie(nfss->nfs_client->fscache,
|
||||||
&nfs_fscache_super_index_def,
|
&nfs_fscache_super_index_def,
|
||||||
nfss, true);
|
key, sizeof(*key) + ulen,
|
||||||
|
NULL, 0,
|
||||||
|
nfss, 0, true);
|
||||||
dfprintk(FSCACHE, "NFS: get superblock cookie (0x%p/0x%p)\n",
|
dfprintk(FSCACHE, "NFS: get superblock cookie (0x%p/0x%p)\n",
|
||||||
nfss, nfss->fscache);
|
nfss, nfss->fscache);
|
||||||
return;
|
return;
|
||||||
|
@ -163,7 +212,7 @@ void nfs_fscache_release_super_cookie(struct super_block *sb)
|
||||||
dfprintk(FSCACHE, "NFS: releasing superblock cookie (0x%p/0x%p)\n",
|
dfprintk(FSCACHE, "NFS: releasing superblock cookie (0x%p/0x%p)\n",
|
||||||
nfss, nfss->fscache);
|
nfss, nfss->fscache);
|
||||||
|
|
||||||
fscache_relinquish_cookie(nfss->fscache, 0);
|
fscache_relinquish_cookie(nfss->fscache, NULL, false);
|
||||||
nfss->fscache = NULL;
|
nfss->fscache = NULL;
|
||||||
|
|
||||||
if (nfss->fscache_key) {
|
if (nfss->fscache_key) {
|
||||||
|
@ -180,14 +229,25 @@ void nfs_fscache_release_super_cookie(struct super_block *sb)
|
||||||
*/
|
*/
|
||||||
void nfs_fscache_init_inode(struct inode *inode)
|
void nfs_fscache_init_inode(struct inode *inode)
|
||||||
{
|
{
|
||||||
|
struct nfs_fscache_inode_auxdata auxdata;
|
||||||
struct nfs_inode *nfsi = NFS_I(inode);
|
struct nfs_inode *nfsi = NFS_I(inode);
|
||||||
|
|
||||||
nfsi->fscache = NULL;
|
nfsi->fscache = NULL;
|
||||||
if (!S_ISREG(inode->i_mode))
|
if (!S_ISREG(inode->i_mode))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
memset(&auxdata, 0, sizeof(auxdata));
|
||||||
|
auxdata.mtime = nfsi->vfs_inode.i_mtime;
|
||||||
|
auxdata.ctime = nfsi->vfs_inode.i_ctime;
|
||||||
|
|
||||||
|
if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
|
||||||
|
auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
|
||||||
|
|
||||||
nfsi->fscache = fscache_acquire_cookie(NFS_SB(inode->i_sb)->fscache,
|
nfsi->fscache = fscache_acquire_cookie(NFS_SB(inode->i_sb)->fscache,
|
||||||
&nfs_fscache_inode_object_def,
|
&nfs_fscache_inode_object_def,
|
||||||
nfsi, false);
|
nfsi->fh.data, nfsi->fh.size,
|
||||||
|
&auxdata, sizeof(auxdata),
|
||||||
|
nfsi, nfsi->vfs_inode.i_size, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -195,12 +255,16 @@ void nfs_fscache_init_inode(struct inode *inode)
|
||||||
*/
|
*/
|
||||||
void nfs_fscache_clear_inode(struct inode *inode)
|
void nfs_fscache_clear_inode(struct inode *inode)
|
||||||
{
|
{
|
||||||
|
struct nfs_fscache_inode_auxdata auxdata;
|
||||||
struct nfs_inode *nfsi = NFS_I(inode);
|
struct nfs_inode *nfsi = NFS_I(inode);
|
||||||
struct fscache_cookie *cookie = nfs_i_fscache(inode);
|
struct fscache_cookie *cookie = nfs_i_fscache(inode);
|
||||||
|
|
||||||
dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie);
|
dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie);
|
||||||
|
|
||||||
fscache_relinquish_cookie(cookie, false);
|
memset(&auxdata, 0, sizeof(auxdata));
|
||||||
|
auxdata.mtime = nfsi->vfs_inode.i_mtime;
|
||||||
|
auxdata.ctime = nfsi->vfs_inode.i_ctime;
|
||||||
|
fscache_relinquish_cookie(cookie, &auxdata, false);
|
||||||
nfsi->fscache = NULL;
|
nfsi->fscache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,20 +296,26 @@ static bool nfs_fscache_can_enable(void *data)
|
||||||
*/
|
*/
|
||||||
void nfs_fscache_open_file(struct inode *inode, struct file *filp)
|
void nfs_fscache_open_file(struct inode *inode, struct file *filp)
|
||||||
{
|
{
|
||||||
|
struct nfs_fscache_inode_auxdata auxdata;
|
||||||
struct nfs_inode *nfsi = NFS_I(inode);
|
struct nfs_inode *nfsi = NFS_I(inode);
|
||||||
struct fscache_cookie *cookie = nfs_i_fscache(inode);
|
struct fscache_cookie *cookie = nfs_i_fscache(inode);
|
||||||
|
|
||||||
if (!fscache_cookie_valid(cookie))
|
if (!fscache_cookie_valid(cookie))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
memset(&auxdata, 0, sizeof(auxdata));
|
||||||
|
auxdata.mtime = nfsi->vfs_inode.i_mtime;
|
||||||
|
auxdata.ctime = nfsi->vfs_inode.i_ctime;
|
||||||
|
|
||||||
if (inode_is_open_for_write(inode)) {
|
if (inode_is_open_for_write(inode)) {
|
||||||
dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi);
|
dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi);
|
||||||
clear_bit(NFS_INO_FSCACHE, &nfsi->flags);
|
clear_bit(NFS_INO_FSCACHE, &nfsi->flags);
|
||||||
fscache_disable_cookie(cookie, true);
|
fscache_disable_cookie(cookie, &auxdata, true);
|
||||||
fscache_uncache_all_inode_pages(cookie, inode);
|
fscache_uncache_all_inode_pages(cookie, inode);
|
||||||
} else {
|
} else {
|
||||||
dfprintk(FSCACHE, "NFS: nfsi 0x%p enabling cache\n", nfsi);
|
dfprintk(FSCACHE, "NFS: nfsi 0x%p enabling cache\n", nfsi);
|
||||||
fscache_enable_cookie(cookie, nfs_fscache_can_enable, inode);
|
fscache_enable_cookie(cookie, &auxdata, nfsi->vfs_inode.i_size,
|
||||||
|
nfs_fscache_can_enable, inode);
|
||||||
if (fscache_cookie_enabled(cookie))
|
if (fscache_cookie_enabled(cookie))
|
||||||
set_bit(NFS_INO_FSCACHE, &NFS_I(inode)->flags);
|
set_bit(NFS_INO_FSCACHE, &NFS_I(inode)->flags);
|
||||||
}
|
}
|
||||||
|
@ -422,7 +492,8 @@ void __nfs_readpage_to_fscache(struct inode *inode, struct page *page, int sync)
|
||||||
"NFS: readpage_to_fscache(fsc:%p/p:%p(i:%lx f:%lx)/%d)\n",
|
"NFS: readpage_to_fscache(fsc:%p/p:%p(i:%lx f:%lx)/%d)\n",
|
||||||
nfs_i_fscache(inode), page, page->index, page->flags, sync);
|
nfs_i_fscache(inode), page, page->index, page->flags, sync);
|
||||||
|
|
||||||
ret = fscache_write_page(nfs_i_fscache(inode), page, GFP_KERNEL);
|
ret = fscache_write_page(nfs_i_fscache(inode), page,
|
||||||
|
inode->i_size, GFP_KERNEL);
|
||||||
dfprintk(FSCACHE,
|
dfprintk(FSCACHE,
|
||||||
"NFS: readpage_to_fscache: p:%p(i:%lu f:%lx) ret %d\n",
|
"NFS: readpage_to_fscache: p:%p(i:%lu f:%lx) ret %d\n",
|
||||||
page, page->index, page->flags, ret);
|
page, page->index, page->flags, ret);
|
||||||
|
|
|
@ -56,6 +56,21 @@ struct nfs_fscache_key {
|
||||||
} key;
|
} key;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Definition of the auxiliary data attached to NFS inode storage objects
|
||||||
|
* within the cache.
|
||||||
|
*
|
||||||
|
* The contents of this struct are recorded in the on-disk local cache in the
|
||||||
|
* auxiliary data attached to the data storage object backing an inode. This
|
||||||
|
* permits coherency to be managed when a new inode binds to an already extant
|
||||||
|
* cache object.
|
||||||
|
*/
|
||||||
|
struct nfs_fscache_inode_auxdata {
|
||||||
|
struct timespec mtime;
|
||||||
|
struct timespec ctime;
|
||||||
|
u64 change_attr;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fscache-index.c
|
* fscache-index.c
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,6 +29,18 @@ struct fscache_cache_ops;
|
||||||
struct fscache_object;
|
struct fscache_object;
|
||||||
struct fscache_operation;
|
struct fscache_operation;
|
||||||
|
|
||||||
|
enum fscache_obj_ref_trace {
|
||||||
|
fscache_obj_get_add_to_deps,
|
||||||
|
fscache_obj_get_queue,
|
||||||
|
fscache_obj_put_alloc_fail,
|
||||||
|
fscache_obj_put_attach_fail,
|
||||||
|
fscache_obj_put_drop_obj,
|
||||||
|
fscache_obj_put_enq_dep,
|
||||||
|
fscache_obj_put_queue,
|
||||||
|
fscache_obj_put_work,
|
||||||
|
fscache_obj_ref__nr_traces
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cache tag definition
|
* cache tag definition
|
||||||
*/
|
*/
|
||||||
|
@ -123,7 +135,8 @@ extern void fscache_op_work_func(struct work_struct *work);
|
||||||
extern void fscache_enqueue_operation(struct fscache_operation *);
|
extern void fscache_enqueue_operation(struct fscache_operation *);
|
||||||
extern void fscache_op_complete(struct fscache_operation *, bool);
|
extern void fscache_op_complete(struct fscache_operation *, bool);
|
||||||
extern void fscache_put_operation(struct fscache_operation *);
|
extern void fscache_put_operation(struct fscache_operation *);
|
||||||
extern void fscache_operation_init(struct fscache_operation *,
|
extern void fscache_operation_init(struct fscache_cookie *,
|
||||||
|
struct fscache_operation *,
|
||||||
fscache_operation_processor_t,
|
fscache_operation_processor_t,
|
||||||
fscache_operation_cancel_t,
|
fscache_operation_cancel_t,
|
||||||
fscache_operation_release_t);
|
fscache_operation_release_t);
|
||||||
|
@ -185,7 +198,7 @@ static inline void fscache_retrieval_complete(struct fscache_retrieval *op,
|
||||||
{
|
{
|
||||||
atomic_sub(n_pages, &op->n_pages);
|
atomic_sub(n_pages, &op->n_pages);
|
||||||
if (atomic_read(&op->n_pages) <= 0)
|
if (atomic_read(&op->n_pages) <= 0)
|
||||||
fscache_op_complete(&op->op, true);
|
fscache_op_complete(&op->op, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -231,7 +244,8 @@ struct fscache_cache_ops {
|
||||||
void (*lookup_complete)(struct fscache_object *object);
|
void (*lookup_complete)(struct fscache_object *object);
|
||||||
|
|
||||||
/* increment the usage count on this object (may fail if unmounting) */
|
/* increment the usage count on this object (may fail if unmounting) */
|
||||||
struct fscache_object *(*grab_object)(struct fscache_object *object);
|
struct fscache_object *(*grab_object)(struct fscache_object *object,
|
||||||
|
enum fscache_obj_ref_trace why);
|
||||||
|
|
||||||
/* pin an object in the cache */
|
/* pin an object in the cache */
|
||||||
int (*pin_object)(struct fscache_object *object);
|
int (*pin_object)(struct fscache_object *object);
|
||||||
|
@ -254,7 +268,8 @@ struct fscache_cache_ops {
|
||||||
void (*drop_object)(struct fscache_object *object);
|
void (*drop_object)(struct fscache_object *object);
|
||||||
|
|
||||||
/* dispose of a reference to an object */
|
/* dispose of a reference to an object */
|
||||||
void (*put_object)(struct fscache_object *object);
|
void (*put_object)(struct fscache_object *object,
|
||||||
|
enum fscache_obj_ref_trace why);
|
||||||
|
|
||||||
/* sync a cache */
|
/* sync a cache */
|
||||||
void (*sync_cache)(struct fscache_cache *cache);
|
void (*sync_cache)(struct fscache_cache *cache);
|
||||||
|
@ -538,7 +553,8 @@ extern bool fscache_object_sleep_till_congested(signed long *timeoutp);
|
||||||
|
|
||||||
extern enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
|
extern enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
|
||||||
const void *data,
|
const void *data,
|
||||||
uint16_t datalen);
|
uint16_t datalen,
|
||||||
|
loff_t object_size);
|
||||||
|
|
||||||
extern void fscache_object_retrying_stale(struct fscache_object *object);
|
extern void fscache_object_retrying_stale(struct fscache_object *object);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
#include <linux/pagemap.h>
|
#include <linux/pagemap.h>
|
||||||
#include <linux/pagevec.h>
|
#include <linux/pagevec.h>
|
||||||
|
#include <linux/list_bl.h>
|
||||||
|
|
||||||
#if defined(CONFIG_FSCACHE) || defined(CONFIG_FSCACHE_MODULE)
|
#if defined(CONFIG_FSCACHE) || defined(CONFIG_FSCACHE_MODULE)
|
||||||
#define fscache_available() (1)
|
#define fscache_available() (1)
|
||||||
|
@ -83,45 +84,15 @@ struct fscache_cookie_def {
|
||||||
const void *parent_netfs_data,
|
const void *parent_netfs_data,
|
||||||
const void *cookie_netfs_data);
|
const void *cookie_netfs_data);
|
||||||
|
|
||||||
/* get an index key
|
|
||||||
* - should store the key data in the buffer
|
|
||||||
* - should return the amount of data stored
|
|
||||||
* - not permitted to return an error
|
|
||||||
* - the netfs data from the cookie being used as the source is
|
|
||||||
* presented
|
|
||||||
*/
|
|
||||||
uint16_t (*get_key)(const void *cookie_netfs_data,
|
|
||||||
void *buffer,
|
|
||||||
uint16_t bufmax);
|
|
||||||
|
|
||||||
/* get certain file attributes from the netfs data
|
|
||||||
* - this function can be absent for an index
|
|
||||||
* - not permitted to return an error
|
|
||||||
* - the netfs data from the cookie being used as the source is
|
|
||||||
* presented
|
|
||||||
*/
|
|
||||||
void (*get_attr)(const void *cookie_netfs_data, uint64_t *size);
|
|
||||||
|
|
||||||
/* get the auxiliary data from netfs data
|
|
||||||
* - this function can be absent if the index carries no state data
|
|
||||||
* - should store the auxiliary data in the buffer
|
|
||||||
* - should return the amount of amount stored
|
|
||||||
* - not permitted to return an error
|
|
||||||
* - the netfs data from the cookie being used as the source is
|
|
||||||
* presented
|
|
||||||
*/
|
|
||||||
uint16_t (*get_aux)(const void *cookie_netfs_data,
|
|
||||||
void *buffer,
|
|
||||||
uint16_t bufmax);
|
|
||||||
|
|
||||||
/* consult the netfs about the state of an object
|
/* consult the netfs about the state of an object
|
||||||
* - this function can be absent if the index carries no state data
|
* - this function can be absent if the index carries no state data
|
||||||
* - the netfs data from the cookie being used as the target is
|
* - the netfs data from the cookie being used as the target is
|
||||||
* presented, as is the auxiliary data
|
* presented, as is the auxiliary data and the object size
|
||||||
*/
|
*/
|
||||||
enum fscache_checkaux (*check_aux)(void *cookie_netfs_data,
|
enum fscache_checkaux (*check_aux)(void *cookie_netfs_data,
|
||||||
const void *data,
|
const void *data,
|
||||||
uint16_t datalen);
|
uint16_t datalen,
|
||||||
|
loff_t object_size);
|
||||||
|
|
||||||
/* get an extra reference on a read context
|
/* get an extra reference on a read context
|
||||||
* - this function can be absent if the completion function doesn't
|
* - this function can be absent if the completion function doesn't
|
||||||
|
@ -154,7 +125,6 @@ struct fscache_netfs {
|
||||||
uint32_t version; /* indexing version */
|
uint32_t version; /* indexing version */
|
||||||
const char *name; /* filesystem name */
|
const char *name; /* filesystem name */
|
||||||
struct fscache_cookie *primary_index;
|
struct fscache_cookie *primary_index;
|
||||||
struct list_head link; /* internal link */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -173,6 +143,7 @@ struct fscache_cookie {
|
||||||
struct hlist_head backing_objects; /* object(s) backing this file/index */
|
struct hlist_head backing_objects; /* object(s) backing this file/index */
|
||||||
const struct fscache_cookie_def *def; /* definition */
|
const struct fscache_cookie_def *def; /* definition */
|
||||||
struct fscache_cookie *parent; /* parent of this entry */
|
struct fscache_cookie *parent; /* parent of this entry */
|
||||||
|
struct hlist_bl_node hash_link; /* Link in hash table */
|
||||||
void *netfs_data; /* back pointer to netfs */
|
void *netfs_data; /* back pointer to netfs */
|
||||||
struct radix_tree_root stores; /* pages to be stored on this cookie */
|
struct radix_tree_root stores; /* pages to be stored on this cookie */
|
||||||
#define FSCACHE_COOKIE_PENDING_TAG 0 /* pages tag: pending write to cache */
|
#define FSCACHE_COOKIE_PENDING_TAG 0 /* pages tag: pending write to cache */
|
||||||
|
@ -186,6 +157,22 @@ struct fscache_cookie {
|
||||||
#define FSCACHE_COOKIE_RELINQUISHED 4 /* T if cookie has been relinquished */
|
#define FSCACHE_COOKIE_RELINQUISHED 4 /* T if cookie has been relinquished */
|
||||||
#define FSCACHE_COOKIE_ENABLED 5 /* T if cookie is enabled */
|
#define FSCACHE_COOKIE_ENABLED 5 /* T if cookie is enabled */
|
||||||
#define FSCACHE_COOKIE_ENABLEMENT_LOCK 6 /* T if cookie is being en/disabled */
|
#define FSCACHE_COOKIE_ENABLEMENT_LOCK 6 /* T if cookie is being en/disabled */
|
||||||
|
#define FSCACHE_COOKIE_AUX_UPDATED 8 /* T if the auxiliary data was updated */
|
||||||
|
#define FSCACHE_COOKIE_ACQUIRED 9 /* T if cookie is in use */
|
||||||
|
#define FSCACHE_COOKIE_RELINQUISHING 10 /* T if cookie is being relinquished */
|
||||||
|
|
||||||
|
u8 type; /* Type of object */
|
||||||
|
u8 key_len; /* Length of index key */
|
||||||
|
u8 aux_len; /* Length of auxiliary data */
|
||||||
|
u32 key_hash; /* Hash of parent, type, key, len */
|
||||||
|
union {
|
||||||
|
void *key; /* Index key */
|
||||||
|
u8 inline_key[16]; /* - If the key is short enough */
|
||||||
|
};
|
||||||
|
union {
|
||||||
|
void *aux; /* Auxiliary data */
|
||||||
|
u8 inline_aux[8]; /* - If the aux data is short enough */
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline bool fscache_cookie_enabled(struct fscache_cookie *cookie)
|
static inline bool fscache_cookie_enabled(struct fscache_cookie *cookie)
|
||||||
|
@ -208,10 +195,12 @@ extern void __fscache_release_cache_tag(struct fscache_cache_tag *);
|
||||||
extern struct fscache_cookie *__fscache_acquire_cookie(
|
extern struct fscache_cookie *__fscache_acquire_cookie(
|
||||||
struct fscache_cookie *,
|
struct fscache_cookie *,
|
||||||
const struct fscache_cookie_def *,
|
const struct fscache_cookie_def *,
|
||||||
void *, bool);
|
const void *, size_t,
|
||||||
extern void __fscache_relinquish_cookie(struct fscache_cookie *, bool);
|
const void *, size_t,
|
||||||
extern int __fscache_check_consistency(struct fscache_cookie *);
|
void *, loff_t, bool);
|
||||||
extern void __fscache_update_cookie(struct fscache_cookie *);
|
extern void __fscache_relinquish_cookie(struct fscache_cookie *, const void *, bool);
|
||||||
|
extern int __fscache_check_consistency(struct fscache_cookie *, const void *);
|
||||||
|
extern void __fscache_update_cookie(struct fscache_cookie *, const void *);
|
||||||
extern int __fscache_attr_changed(struct fscache_cookie *);
|
extern int __fscache_attr_changed(struct fscache_cookie *);
|
||||||
extern void __fscache_invalidate(struct fscache_cookie *);
|
extern void __fscache_invalidate(struct fscache_cookie *);
|
||||||
extern void __fscache_wait_on_invalidate(struct fscache_cookie *);
|
extern void __fscache_wait_on_invalidate(struct fscache_cookie *);
|
||||||
|
@ -228,7 +217,7 @@ extern int __fscache_read_or_alloc_pages(struct fscache_cookie *,
|
||||||
void *,
|
void *,
|
||||||
gfp_t);
|
gfp_t);
|
||||||
extern int __fscache_alloc_page(struct fscache_cookie *, struct page *, gfp_t);
|
extern int __fscache_alloc_page(struct fscache_cookie *, struct page *, gfp_t);
|
||||||
extern int __fscache_write_page(struct fscache_cookie *, struct page *, gfp_t);
|
extern int __fscache_write_page(struct fscache_cookie *, struct page *, loff_t, gfp_t);
|
||||||
extern void __fscache_uncache_page(struct fscache_cookie *, struct page *);
|
extern void __fscache_uncache_page(struct fscache_cookie *, struct page *);
|
||||||
extern bool __fscache_check_page_write(struct fscache_cookie *, struct page *);
|
extern bool __fscache_check_page_write(struct fscache_cookie *, struct page *);
|
||||||
extern void __fscache_wait_on_page_write(struct fscache_cookie *, struct page *);
|
extern void __fscache_wait_on_page_write(struct fscache_cookie *, struct page *);
|
||||||
|
@ -238,8 +227,8 @@ extern void __fscache_uncache_all_inode_pages(struct fscache_cookie *,
|
||||||
struct inode *);
|
struct inode *);
|
||||||
extern void __fscache_readpages_cancel(struct fscache_cookie *cookie,
|
extern void __fscache_readpages_cancel(struct fscache_cookie *cookie,
|
||||||
struct list_head *pages);
|
struct list_head *pages);
|
||||||
extern void __fscache_disable_cookie(struct fscache_cookie *, bool);
|
extern void __fscache_disable_cookie(struct fscache_cookie *, const void *, bool);
|
||||||
extern void __fscache_enable_cookie(struct fscache_cookie *,
|
extern void __fscache_enable_cookie(struct fscache_cookie *, const void *, loff_t,
|
||||||
bool (*)(void *), void *);
|
bool (*)(void *), void *);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -317,8 +306,13 @@ void fscache_release_cache_tag(struct fscache_cache_tag *tag)
|
||||||
* fscache_acquire_cookie - Acquire a cookie to represent a cache object
|
* fscache_acquire_cookie - Acquire a cookie to represent a cache object
|
||||||
* @parent: The cookie that's to be the parent of this one
|
* @parent: The cookie that's to be the parent of this one
|
||||||
* @def: A description of the cache object, including callback operations
|
* @def: A description of the cache object, including callback operations
|
||||||
|
* @index_key: The index key for this cookie
|
||||||
|
* @index_key_len: Size of the index key
|
||||||
|
* @aux_data: The auxiliary data for the cookie (may be NULL)
|
||||||
|
* @aux_data_len: Size of the auxiliary data buffer
|
||||||
* @netfs_data: An arbitrary piece of data to be kept in the cookie to
|
* @netfs_data: An arbitrary piece of data to be kept in the cookie to
|
||||||
* represent the cache object to the netfs
|
* represent the cache object to the netfs
|
||||||
|
* @object_size: The initial size of object
|
||||||
* @enable: Whether or not to enable a data cookie immediately
|
* @enable: Whether or not to enable a data cookie immediately
|
||||||
*
|
*
|
||||||
* This function is used to inform FS-Cache about part of an index hierarchy
|
* This function is used to inform FS-Cache about part of an index hierarchy
|
||||||
|
@ -332,12 +326,19 @@ static inline
|
||||||
struct fscache_cookie *fscache_acquire_cookie(
|
struct fscache_cookie *fscache_acquire_cookie(
|
||||||
struct fscache_cookie *parent,
|
struct fscache_cookie *parent,
|
||||||
const struct fscache_cookie_def *def,
|
const struct fscache_cookie_def *def,
|
||||||
|
const void *index_key,
|
||||||
|
size_t index_key_len,
|
||||||
|
const void *aux_data,
|
||||||
|
size_t aux_data_len,
|
||||||
void *netfs_data,
|
void *netfs_data,
|
||||||
|
loff_t object_size,
|
||||||
bool enable)
|
bool enable)
|
||||||
{
|
{
|
||||||
if (fscache_cookie_valid(parent) && fscache_cookie_enabled(parent))
|
if (fscache_cookie_valid(parent) && fscache_cookie_enabled(parent))
|
||||||
return __fscache_acquire_cookie(parent, def, netfs_data,
|
return __fscache_acquire_cookie(parent, def,
|
||||||
enable);
|
index_key, index_key_len,
|
||||||
|
aux_data, aux_data_len,
|
||||||
|
netfs_data, object_size, enable);
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -346,36 +347,44 @@ struct fscache_cookie *fscache_acquire_cookie(
|
||||||
* fscache_relinquish_cookie - Return the cookie to the cache, maybe discarding
|
* fscache_relinquish_cookie - Return the cookie to the cache, maybe discarding
|
||||||
* it
|
* it
|
||||||
* @cookie: The cookie being returned
|
* @cookie: The cookie being returned
|
||||||
|
* @aux_data: The updated auxiliary data for the cookie (may be NULL)
|
||||||
* @retire: True if the cache object the cookie represents is to be discarded
|
* @retire: True if the cache object the cookie represents is to be discarded
|
||||||
*
|
*
|
||||||
* This function returns a cookie to the cache, forcibly discarding the
|
* This function returns a cookie to the cache, forcibly discarding the
|
||||||
* associated cache object if retire is set to true.
|
* associated cache object if retire is set to true. The opportunity is
|
||||||
|
* provided to update the auxiliary data in the cache before the object is
|
||||||
|
* disconnected.
|
||||||
*
|
*
|
||||||
* See Documentation/filesystems/caching/netfs-api.txt for a complete
|
* See Documentation/filesystems/caching/netfs-api.txt for a complete
|
||||||
* description.
|
* description.
|
||||||
*/
|
*/
|
||||||
static inline
|
static inline
|
||||||
void fscache_relinquish_cookie(struct fscache_cookie *cookie, bool retire)
|
void fscache_relinquish_cookie(struct fscache_cookie *cookie,
|
||||||
|
const void *aux_data,
|
||||||
|
bool retire)
|
||||||
{
|
{
|
||||||
if (fscache_cookie_valid(cookie))
|
if (fscache_cookie_valid(cookie))
|
||||||
__fscache_relinquish_cookie(cookie, retire);
|
__fscache_relinquish_cookie(cookie, aux_data, retire);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fscache_check_consistency - Request that if the cache is updated
|
* fscache_check_consistency - Request validation of a cache's auxiliary data
|
||||||
* @cookie: The cookie representing the cache object
|
* @cookie: The cookie representing the cache object
|
||||||
|
* @aux_data: The updated auxiliary data for the cookie (may be NULL)
|
||||||
*
|
*
|
||||||
* Request an consistency check from fscache, which passes the request
|
* Request an consistency check from fscache, which passes the request to the
|
||||||
* to the backing cache.
|
* backing cache. The auxiliary data on the cookie will be updated first if
|
||||||
|
* @aux_data is set.
|
||||||
*
|
*
|
||||||
* Returns 0 if consistent and -ESTALE if inconsistent. May also
|
* Returns 0 if consistent and -ESTALE if inconsistent. May also
|
||||||
* return -ENOMEM and -ERESTARTSYS.
|
* return -ENOMEM and -ERESTARTSYS.
|
||||||
*/
|
*/
|
||||||
static inline
|
static inline
|
||||||
int fscache_check_consistency(struct fscache_cookie *cookie)
|
int fscache_check_consistency(struct fscache_cookie *cookie,
|
||||||
|
const void *aux_data)
|
||||||
{
|
{
|
||||||
if (fscache_cookie_valid(cookie) && fscache_cookie_enabled(cookie))
|
if (fscache_cookie_valid(cookie) && fscache_cookie_enabled(cookie))
|
||||||
return __fscache_check_consistency(cookie);
|
return __fscache_check_consistency(cookie, aux_data);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -383,18 +392,20 @@ int fscache_check_consistency(struct fscache_cookie *cookie)
|
||||||
/**
|
/**
|
||||||
* fscache_update_cookie - Request that a cache object be updated
|
* fscache_update_cookie - Request that a cache object be updated
|
||||||
* @cookie: The cookie representing the cache object
|
* @cookie: The cookie representing the cache object
|
||||||
|
* @aux_data: The updated auxiliary data for the cookie (may be NULL)
|
||||||
*
|
*
|
||||||
* Request an update of the index data for the cache object associated with the
|
* Request an update of the index data for the cache object associated with the
|
||||||
* cookie.
|
* cookie. The auxiliary data on the cookie will be updated first if @aux_data
|
||||||
|
* is set.
|
||||||
*
|
*
|
||||||
* See Documentation/filesystems/caching/netfs-api.txt for a complete
|
* See Documentation/filesystems/caching/netfs-api.txt for a complete
|
||||||
* description.
|
* description.
|
||||||
*/
|
*/
|
||||||
static inline
|
static inline
|
||||||
void fscache_update_cookie(struct fscache_cookie *cookie)
|
void fscache_update_cookie(struct fscache_cookie *cookie, const void *aux_data)
|
||||||
{
|
{
|
||||||
if (fscache_cookie_valid(cookie) && fscache_cookie_enabled(cookie))
|
if (fscache_cookie_valid(cookie) && fscache_cookie_enabled(cookie))
|
||||||
__fscache_update_cookie(cookie);
|
__fscache_update_cookie(cookie, aux_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -648,6 +659,7 @@ void fscache_readpages_cancel(struct fscache_cookie *cookie,
|
||||||
* fscache_write_page - Request storage of a page in the cache
|
* fscache_write_page - Request storage of a page in the cache
|
||||||
* @cookie: The cookie representing the cache object
|
* @cookie: The cookie representing the cache object
|
||||||
* @page: The netfs page to store
|
* @page: The netfs page to store
|
||||||
|
* @object_size: Updated size of object
|
||||||
* @gfp: The conditions under which memory allocation should be made
|
* @gfp: The conditions under which memory allocation should be made
|
||||||
*
|
*
|
||||||
* Request the contents of the netfs page be written into the cache. This
|
* Request the contents of the netfs page be written into the cache. This
|
||||||
|
@ -665,10 +677,11 @@ void fscache_readpages_cancel(struct fscache_cookie *cookie,
|
||||||
static inline
|
static inline
|
||||||
int fscache_write_page(struct fscache_cookie *cookie,
|
int fscache_write_page(struct fscache_cookie *cookie,
|
||||||
struct page *page,
|
struct page *page,
|
||||||
|
loff_t object_size,
|
||||||
gfp_t gfp)
|
gfp_t gfp)
|
||||||
{
|
{
|
||||||
if (fscache_cookie_valid(cookie) && fscache_cookie_enabled(cookie))
|
if (fscache_cookie_valid(cookie) && fscache_cookie_enabled(cookie))
|
||||||
return __fscache_write_page(cookie, page, gfp);
|
return __fscache_write_page(cookie, page, object_size, gfp);
|
||||||
else
|
else
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
}
|
}
|
||||||
|
@ -780,6 +793,7 @@ void fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
|
||||||
/**
|
/**
|
||||||
* fscache_disable_cookie - Disable a cookie
|
* fscache_disable_cookie - Disable a cookie
|
||||||
* @cookie: The cookie representing the cache object
|
* @cookie: The cookie representing the cache object
|
||||||
|
* @aux_data: The updated auxiliary data for the cookie (may be NULL)
|
||||||
* @invalidate: Invalidate the backing object
|
* @invalidate: Invalidate the backing object
|
||||||
*
|
*
|
||||||
* Disable a cookie from accepting further alloc, read, write, invalidate,
|
* Disable a cookie from accepting further alloc, read, write, invalidate,
|
||||||
|
@ -790,34 +804,44 @@ void fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
|
||||||
*
|
*
|
||||||
* If @invalidate is set, then the backing object will be invalidated and
|
* If @invalidate is set, then the backing object will be invalidated and
|
||||||
* detached, otherwise it will just be detached.
|
* detached, otherwise it will just be detached.
|
||||||
|
*
|
||||||
|
* If @aux_data is set, then auxiliary data will be updated from that.
|
||||||
*/
|
*/
|
||||||
static inline
|
static inline
|
||||||
void fscache_disable_cookie(struct fscache_cookie *cookie, bool invalidate)
|
void fscache_disable_cookie(struct fscache_cookie *cookie,
|
||||||
|
const void *aux_data,
|
||||||
|
bool invalidate)
|
||||||
{
|
{
|
||||||
if (fscache_cookie_valid(cookie) && fscache_cookie_enabled(cookie))
|
if (fscache_cookie_valid(cookie) && fscache_cookie_enabled(cookie))
|
||||||
__fscache_disable_cookie(cookie, invalidate);
|
__fscache_disable_cookie(cookie, aux_data, invalidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fscache_enable_cookie - Reenable a cookie
|
* fscache_enable_cookie - Reenable a cookie
|
||||||
* @cookie: The cookie representing the cache object
|
* @cookie: The cookie representing the cache object
|
||||||
|
* @aux_data: The updated auxiliary data for the cookie (may be NULL)
|
||||||
|
* @object_size: Current size of object
|
||||||
* @can_enable: A function to permit enablement once lock is held
|
* @can_enable: A function to permit enablement once lock is held
|
||||||
* @data: Data for can_enable()
|
* @data: Data for can_enable()
|
||||||
*
|
*
|
||||||
* Reenable a previously disabled cookie, allowing it to accept further alloc,
|
* Reenable a previously disabled cookie, allowing it to accept further alloc,
|
||||||
* read, write, invalidate, update or acquire operations. An attempt will be
|
* read, write, invalidate, update or acquire operations. An attempt will be
|
||||||
* made to immediately reattach the cookie to a backing object.
|
* made to immediately reattach the cookie to a backing object. If @aux_data
|
||||||
|
* is set, the auxiliary data attached to the cookie will be updated.
|
||||||
*
|
*
|
||||||
* The can_enable() function is called (if not NULL) once the enablement lock
|
* The can_enable() function is called (if not NULL) once the enablement lock
|
||||||
* is held to rule on whether enablement is still permitted to go ahead.
|
* is held to rule on whether enablement is still permitted to go ahead.
|
||||||
*/
|
*/
|
||||||
static inline
|
static inline
|
||||||
void fscache_enable_cookie(struct fscache_cookie *cookie,
|
void fscache_enable_cookie(struct fscache_cookie *cookie,
|
||||||
|
const void *aux_data,
|
||||||
|
loff_t object_size,
|
||||||
bool (*can_enable)(void *data),
|
bool (*can_enable)(void *data),
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
if (fscache_cookie_valid(cookie) && !fscache_cookie_enabled(cookie))
|
if (fscache_cookie_valid(cookie) && !fscache_cookie_enabled(cookie))
|
||||||
__fscache_enable_cookie(cookie, can_enable, data);
|
__fscache_enable_cookie(cookie, aux_data, object_size,
|
||||||
|
can_enable, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _LINUX_FSCACHE_H */
|
#endif /* _LINUX_FSCACHE_H */
|
||||||
|
|
|
@ -0,0 +1,325 @@
|
||||||
|
/* CacheFiles tracepoints
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
|
||||||
|
* Written by David Howells (dhowells@redhat.com)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public Licence
|
||||||
|
* as published by the Free Software Foundation; either version
|
||||||
|
* 2 of the Licence, or (at your option) any later version.
|
||||||
|
*/
|
||||||
|
#undef TRACE_SYSTEM
|
||||||
|
#define TRACE_SYSTEM cachefiles
|
||||||
|
|
||||||
|
#if !defined(_TRACE_CACHEFILES_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||||
|
#define _TRACE_CACHEFILES_H
|
||||||
|
|
||||||
|
#include <linux/tracepoint.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define enums for tracing information.
|
||||||
|
*/
|
||||||
|
#ifndef __CACHEFILES_DECLARE_TRACE_ENUMS_ONCE_ONLY
|
||||||
|
#define __CACHEFILES_DECLARE_TRACE_ENUMS_ONCE_ONLY
|
||||||
|
|
||||||
|
enum cachefiles_obj_ref_trace {
|
||||||
|
cachefiles_obj_put_wait_retry = fscache_obj_ref__nr_traces,
|
||||||
|
cachefiles_obj_put_wait_timeo,
|
||||||
|
cachefiles_obj_ref__nr_traces
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define enum -> string mappings for display.
|
||||||
|
*/
|
||||||
|
#define cachefiles_obj_kill_traces \
|
||||||
|
EM(FSCACHE_OBJECT_IS_STALE, "stale") \
|
||||||
|
EM(FSCACHE_OBJECT_NO_SPACE, "no_space") \
|
||||||
|
EM(FSCACHE_OBJECT_WAS_RETIRED, "was_retired") \
|
||||||
|
E_(FSCACHE_OBJECT_WAS_CULLED, "was_culled")
|
||||||
|
|
||||||
|
#define cachefiles_obj_ref_traces \
|
||||||
|
EM(fscache_obj_get_add_to_deps, "GET add_to_deps") \
|
||||||
|
EM(fscache_obj_get_queue, "GET queue") \
|
||||||
|
EM(fscache_obj_put_alloc_fail, "PUT alloc_fail") \
|
||||||
|
EM(fscache_obj_put_attach_fail, "PUT attach_fail") \
|
||||||
|
EM(fscache_obj_put_drop_obj, "PUT drop_obj") \
|
||||||
|
EM(fscache_obj_put_enq_dep, "PUT enq_dep") \
|
||||||
|
EM(fscache_obj_put_queue, "PUT queue") \
|
||||||
|
EM(fscache_obj_put_work, "PUT work") \
|
||||||
|
EM(cachefiles_obj_put_wait_retry, "PUT wait_retry") \
|
||||||
|
E_(cachefiles_obj_put_wait_timeo, "PUT wait_timeo")
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Export enum symbols via userspace.
|
||||||
|
*/
|
||||||
|
#undef EM
|
||||||
|
#undef E_
|
||||||
|
#define EM(a, b) TRACE_DEFINE_ENUM(a);
|
||||||
|
#define E_(a, b) TRACE_DEFINE_ENUM(a);
|
||||||
|
|
||||||
|
cachefiles_obj_kill_traces;
|
||||||
|
cachefiles_obj_ref_traces;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now redefine the EM() and E_() macros to map the enums to the strings that
|
||||||
|
* will be printed in the output.
|
||||||
|
*/
|
||||||
|
#undef EM
|
||||||
|
#undef E_
|
||||||
|
#define EM(a, b) { a, b },
|
||||||
|
#define E_(a, b) { a, b }
|
||||||
|
|
||||||
|
|
||||||
|
TRACE_EVENT(cachefiles_ref,
|
||||||
|
TP_PROTO(struct cachefiles_object *obj,
|
||||||
|
struct fscache_cookie *cookie,
|
||||||
|
enum cachefiles_obj_ref_trace why,
|
||||||
|
int usage),
|
||||||
|
|
||||||
|
TP_ARGS(obj, cookie, why, usage),
|
||||||
|
|
||||||
|
/* Note that obj may be NULL */
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct cachefiles_object *, obj )
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__field(enum cachefiles_obj_ref_trace, why )
|
||||||
|
__field(int, usage )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->obj = obj;
|
||||||
|
__entry->cookie = cookie;
|
||||||
|
__entry->usage = usage;
|
||||||
|
__entry->why = why;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p o=%p u=%d %s",
|
||||||
|
__entry->cookie, __entry->obj, __entry->usage,
|
||||||
|
__print_symbolic(__entry->why, cachefiles_obj_ref_traces))
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(cachefiles_lookup,
|
||||||
|
TP_PROTO(struct cachefiles_object *obj,
|
||||||
|
struct dentry *de,
|
||||||
|
struct inode *inode),
|
||||||
|
|
||||||
|
TP_ARGS(obj, de, inode),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct cachefiles_object *, obj )
|
||||||
|
__field(struct dentry *, de )
|
||||||
|
__field(struct inode *, inode )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->obj = obj;
|
||||||
|
__entry->de = de;
|
||||||
|
__entry->inode = inode;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("o=%p d=%p i=%p",
|
||||||
|
__entry->obj, __entry->de, __entry->inode)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(cachefiles_mkdir,
|
||||||
|
TP_PROTO(struct cachefiles_object *obj,
|
||||||
|
struct dentry *de, int ret),
|
||||||
|
|
||||||
|
TP_ARGS(obj, de, ret),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct cachefiles_object *, obj )
|
||||||
|
__field(struct dentry *, de )
|
||||||
|
__field(int, ret )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->obj = obj;
|
||||||
|
__entry->de = de;
|
||||||
|
__entry->ret = ret;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("o=%p d=%p r=%u",
|
||||||
|
__entry->obj, __entry->de, __entry->ret)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(cachefiles_create,
|
||||||
|
TP_PROTO(struct cachefiles_object *obj,
|
||||||
|
struct dentry *de, int ret),
|
||||||
|
|
||||||
|
TP_ARGS(obj, de, ret),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct cachefiles_object *, obj )
|
||||||
|
__field(struct dentry *, de )
|
||||||
|
__field(int, ret )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->obj = obj;
|
||||||
|
__entry->de = de;
|
||||||
|
__entry->ret = ret;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("o=%p d=%p r=%u",
|
||||||
|
__entry->obj, __entry->de, __entry->ret)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(cachefiles_unlink,
|
||||||
|
TP_PROTO(struct cachefiles_object *obj,
|
||||||
|
struct dentry *de,
|
||||||
|
enum fscache_why_object_killed why),
|
||||||
|
|
||||||
|
TP_ARGS(obj, de, why),
|
||||||
|
|
||||||
|
/* Note that obj may be NULL */
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct cachefiles_object *, obj )
|
||||||
|
__field(struct dentry *, de )
|
||||||
|
__field(enum fscache_why_object_killed, why )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->obj = obj;
|
||||||
|
__entry->de = de;
|
||||||
|
__entry->why = why;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("o=%p d=%p w=%s",
|
||||||
|
__entry->obj, __entry->de,
|
||||||
|
__print_symbolic(__entry->why, cachefiles_obj_kill_traces))
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(cachefiles_rename,
|
||||||
|
TP_PROTO(struct cachefiles_object *obj,
|
||||||
|
struct dentry *de,
|
||||||
|
struct dentry *to,
|
||||||
|
enum fscache_why_object_killed why),
|
||||||
|
|
||||||
|
TP_ARGS(obj, de, to, why),
|
||||||
|
|
||||||
|
/* Note that obj may be NULL */
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct cachefiles_object *, obj )
|
||||||
|
__field(struct dentry *, de )
|
||||||
|
__field(struct dentry *, to )
|
||||||
|
__field(enum fscache_why_object_killed, why )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->obj = obj;
|
||||||
|
__entry->de = de;
|
||||||
|
__entry->to = to;
|
||||||
|
__entry->why = why;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("o=%p d=%p t=%p w=%s",
|
||||||
|
__entry->obj, __entry->de, __entry->to,
|
||||||
|
__print_symbolic(__entry->why, cachefiles_obj_kill_traces))
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(cachefiles_mark_active,
|
||||||
|
TP_PROTO(struct cachefiles_object *obj,
|
||||||
|
struct dentry *de),
|
||||||
|
|
||||||
|
TP_ARGS(obj, de),
|
||||||
|
|
||||||
|
/* Note that obj may be NULL */
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct cachefiles_object *, obj )
|
||||||
|
__field(struct dentry *, de )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->obj = obj;
|
||||||
|
__entry->de = de;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("o=%p d=%p",
|
||||||
|
__entry->obj, __entry->de)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(cachefiles_wait_active,
|
||||||
|
TP_PROTO(struct cachefiles_object *obj,
|
||||||
|
struct dentry *de,
|
||||||
|
struct cachefiles_object *xobj),
|
||||||
|
|
||||||
|
TP_ARGS(obj, de, xobj),
|
||||||
|
|
||||||
|
/* Note that obj may be NULL */
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct cachefiles_object *, obj )
|
||||||
|
__field(struct dentry *, de )
|
||||||
|
__field(struct cachefiles_object *, xobj )
|
||||||
|
__field(u16, flags )
|
||||||
|
__field(u16, fsc_flags )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->obj = obj;
|
||||||
|
__entry->de = de;
|
||||||
|
__entry->xobj = xobj;
|
||||||
|
__entry->flags = xobj->flags;
|
||||||
|
__entry->fsc_flags = xobj->fscache.flags;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("o=%p d=%p wo=%p wf=%x wff=%x",
|
||||||
|
__entry->obj, __entry->de, __entry->xobj,
|
||||||
|
__entry->flags, __entry->fsc_flags)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(cachefiles_mark_inactive,
|
||||||
|
TP_PROTO(struct cachefiles_object *obj,
|
||||||
|
struct dentry *de,
|
||||||
|
struct inode *inode),
|
||||||
|
|
||||||
|
TP_ARGS(obj, de, inode),
|
||||||
|
|
||||||
|
/* Note that obj may be NULL */
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct cachefiles_object *, obj )
|
||||||
|
__field(struct dentry *, de )
|
||||||
|
__field(struct inode *, inode )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->obj = obj;
|
||||||
|
__entry->de = de;
|
||||||
|
__entry->inode = inode;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("o=%p d=%p i=%p",
|
||||||
|
__entry->obj, __entry->de, __entry->inode)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(cachefiles_mark_buried,
|
||||||
|
TP_PROTO(struct cachefiles_object *obj,
|
||||||
|
struct dentry *de,
|
||||||
|
enum fscache_why_object_killed why),
|
||||||
|
|
||||||
|
TP_ARGS(obj, de, why),
|
||||||
|
|
||||||
|
/* Note that obj may be NULL */
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct cachefiles_object *, obj )
|
||||||
|
__field(struct dentry *, de )
|
||||||
|
__field(enum fscache_why_object_killed, why )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->obj = obj;
|
||||||
|
__entry->de = de;
|
||||||
|
__entry->why = why;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("o=%p d=%p w=%s",
|
||||||
|
__entry->obj, __entry->de,
|
||||||
|
__print_symbolic(__entry->why, cachefiles_obj_kill_traces))
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif /* _TRACE_CACHEFILES_H */
|
||||||
|
|
||||||
|
/* This part must be outside protection */
|
||||||
|
#include <trace/define_trace.h>
|
|
@ -0,0 +1,537 @@
|
||||||
|
/* FS-Cache tracepoints
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
|
||||||
|
* Written by David Howells (dhowells@redhat.com)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public Licence
|
||||||
|
* as published by the Free Software Foundation; either version
|
||||||
|
* 2 of the Licence, or (at your option) any later version.
|
||||||
|
*/
|
||||||
|
#undef TRACE_SYSTEM
|
||||||
|
#define TRACE_SYSTEM fscache
|
||||||
|
|
||||||
|
#if !defined(_TRACE_FSCACHE_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||||
|
#define _TRACE_FSCACHE_H
|
||||||
|
|
||||||
|
#include <linux/fscache.h>
|
||||||
|
#include <linux/tracepoint.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define enums for tracing information.
|
||||||
|
*/
|
||||||
|
#ifndef __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY
|
||||||
|
#define __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY
|
||||||
|
|
||||||
|
enum fscache_cookie_trace {
|
||||||
|
fscache_cookie_collision,
|
||||||
|
fscache_cookie_discard,
|
||||||
|
fscache_cookie_get_acquire_parent,
|
||||||
|
fscache_cookie_get_attach_object,
|
||||||
|
fscache_cookie_get_reacquire,
|
||||||
|
fscache_cookie_get_register_netfs,
|
||||||
|
fscache_cookie_put_acquire_nobufs,
|
||||||
|
fscache_cookie_put_dup_netfs,
|
||||||
|
fscache_cookie_put_relinquish,
|
||||||
|
fscache_cookie_put_object,
|
||||||
|
fscache_cookie_put_parent,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum fscache_page_trace {
|
||||||
|
fscache_page_cached,
|
||||||
|
fscache_page_inval,
|
||||||
|
fscache_page_maybe_release,
|
||||||
|
fscache_page_radix_clear_store,
|
||||||
|
fscache_page_radix_delete,
|
||||||
|
fscache_page_radix_insert,
|
||||||
|
fscache_page_radix_pend2store,
|
||||||
|
fscache_page_radix_set_pend,
|
||||||
|
fscache_page_uncache,
|
||||||
|
fscache_page_write,
|
||||||
|
fscache_page_write_end,
|
||||||
|
fscache_page_write_end_pend,
|
||||||
|
fscache_page_write_end_noc,
|
||||||
|
fscache_page_write_wait,
|
||||||
|
fscache_page_trace__nr
|
||||||
|
};
|
||||||
|
|
||||||
|
enum fscache_op_trace {
|
||||||
|
fscache_op_cancel,
|
||||||
|
fscache_op_cancel_all,
|
||||||
|
fscache_op_cancelled,
|
||||||
|
fscache_op_completed,
|
||||||
|
fscache_op_enqueue_async,
|
||||||
|
fscache_op_enqueue_mythread,
|
||||||
|
fscache_op_gc,
|
||||||
|
fscache_op_init,
|
||||||
|
fscache_op_put,
|
||||||
|
fscache_op_run,
|
||||||
|
fscache_op_signal,
|
||||||
|
fscache_op_submit,
|
||||||
|
fscache_op_submit_ex,
|
||||||
|
fscache_op_work,
|
||||||
|
fscache_op_trace__nr
|
||||||
|
};
|
||||||
|
|
||||||
|
enum fscache_page_op_trace {
|
||||||
|
fscache_page_op_alloc_one,
|
||||||
|
fscache_page_op_attr_changed,
|
||||||
|
fscache_page_op_check_consistency,
|
||||||
|
fscache_page_op_invalidate,
|
||||||
|
fscache_page_op_retr_multi,
|
||||||
|
fscache_page_op_retr_one,
|
||||||
|
fscache_page_op_write_one,
|
||||||
|
fscache_page_op_trace__nr
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Declare tracing information enums and their string mappings for display.
|
||||||
|
*/
|
||||||
|
#define fscache_cookie_traces \
|
||||||
|
EM(fscache_cookie_collision, "*COLLISION*") \
|
||||||
|
EM(fscache_cookie_discard, "DISCARD") \
|
||||||
|
EM(fscache_cookie_get_acquire_parent, "GET prn") \
|
||||||
|
EM(fscache_cookie_get_attach_object, "GET obj") \
|
||||||
|
EM(fscache_cookie_get_reacquire, "GET raq") \
|
||||||
|
EM(fscache_cookie_get_register_netfs, "GET net") \
|
||||||
|
EM(fscache_cookie_put_acquire_nobufs, "PUT nbf") \
|
||||||
|
EM(fscache_cookie_put_dup_netfs, "PUT dnt") \
|
||||||
|
EM(fscache_cookie_put_relinquish, "PUT rlq") \
|
||||||
|
EM(fscache_cookie_put_object, "PUT obj") \
|
||||||
|
E_(fscache_cookie_put_parent, "PUT prn")
|
||||||
|
|
||||||
|
#define fscache_page_traces \
|
||||||
|
EM(fscache_page_cached, "Cached ") \
|
||||||
|
EM(fscache_page_inval, "InvalPg") \
|
||||||
|
EM(fscache_page_maybe_release, "MayRels") \
|
||||||
|
EM(fscache_page_uncache, "Uncache") \
|
||||||
|
EM(fscache_page_radix_clear_store, "RxCStr ") \
|
||||||
|
EM(fscache_page_radix_delete, "RxDel ") \
|
||||||
|
EM(fscache_page_radix_insert, "RxIns ") \
|
||||||
|
EM(fscache_page_radix_pend2store, "RxP2S ") \
|
||||||
|
EM(fscache_page_radix_set_pend, "RxSPend ") \
|
||||||
|
EM(fscache_page_write, "WritePg") \
|
||||||
|
EM(fscache_page_write_end, "EndPgWr") \
|
||||||
|
EM(fscache_page_write_end_pend, "EndPgWP") \
|
||||||
|
EM(fscache_page_write_end_noc, "EndPgNC") \
|
||||||
|
E_(fscache_page_write_wait, "WtOnWrt")
|
||||||
|
|
||||||
|
#define fscache_op_traces \
|
||||||
|
EM(fscache_op_cancel, "Cancel1") \
|
||||||
|
EM(fscache_op_cancel_all, "CancelA") \
|
||||||
|
EM(fscache_op_cancelled, "Canclld") \
|
||||||
|
EM(fscache_op_completed, "Complet") \
|
||||||
|
EM(fscache_op_enqueue_async, "EnqAsyn") \
|
||||||
|
EM(fscache_op_enqueue_mythread, "EnqMyTh") \
|
||||||
|
EM(fscache_op_gc, "GC ") \
|
||||||
|
EM(fscache_op_init, "Init ") \
|
||||||
|
EM(fscache_op_put, "Put ") \
|
||||||
|
EM(fscache_op_run, "Run ") \
|
||||||
|
EM(fscache_op_signal, "Signal ") \
|
||||||
|
EM(fscache_op_submit, "Submit ") \
|
||||||
|
EM(fscache_op_submit_ex, "SubmitX") \
|
||||||
|
E_(fscache_op_work, "Work ")
|
||||||
|
|
||||||
|
#define fscache_page_op_traces \
|
||||||
|
EM(fscache_page_op_alloc_one, "Alloc1 ") \
|
||||||
|
EM(fscache_page_op_attr_changed, "AttrChg") \
|
||||||
|
EM(fscache_page_op_check_consistency, "CheckCn") \
|
||||||
|
EM(fscache_page_op_invalidate, "Inval ") \
|
||||||
|
EM(fscache_page_op_retr_multi, "RetrMul") \
|
||||||
|
EM(fscache_page_op_retr_one, "Retr1 ") \
|
||||||
|
E_(fscache_page_op_write_one, "Write1 ")
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Export enum symbols via userspace.
|
||||||
|
*/
|
||||||
|
#undef EM
|
||||||
|
#undef E_
|
||||||
|
#define EM(a, b) TRACE_DEFINE_ENUM(a);
|
||||||
|
#define E_(a, b) TRACE_DEFINE_ENUM(a);
|
||||||
|
|
||||||
|
fscache_cookie_traces;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now redefine the EM() and E_() macros to map the enums to the strings that
|
||||||
|
* will be printed in the output.
|
||||||
|
*/
|
||||||
|
#undef EM
|
||||||
|
#undef E_
|
||||||
|
#define EM(a, b) { a, b },
|
||||||
|
#define E_(a, b) { a, b }
|
||||||
|
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_cookie,
|
||||||
|
TP_PROTO(struct fscache_cookie *cookie,
|
||||||
|
enum fscache_cookie_trace where,
|
||||||
|
int usage),
|
||||||
|
|
||||||
|
TP_ARGS(cookie, where, usage),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__field(struct fscache_cookie *, parent )
|
||||||
|
__field(enum fscache_cookie_trace, where )
|
||||||
|
__field(int, usage )
|
||||||
|
__field(int, n_children )
|
||||||
|
__field(int, n_active )
|
||||||
|
__field(u8, flags )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = cookie;
|
||||||
|
__entry->parent = cookie->parent;
|
||||||
|
__entry->where = where;
|
||||||
|
__entry->usage = usage;
|
||||||
|
__entry->n_children = atomic_read(&cookie->n_children);
|
||||||
|
__entry->n_active = atomic_read(&cookie->n_active);
|
||||||
|
__entry->flags = cookie->flags;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("%s c=%p u=%d p=%p Nc=%d Na=%d f=%02x",
|
||||||
|
__print_symbolic(__entry->where, fscache_cookie_traces),
|
||||||
|
__entry->cookie, __entry->usage,
|
||||||
|
__entry->parent, __entry->n_children, __entry->n_active,
|
||||||
|
__entry->flags)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_netfs,
|
||||||
|
TP_PROTO(struct fscache_netfs *netfs),
|
||||||
|
|
||||||
|
TP_ARGS(netfs),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__array(char, name, 8 )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = netfs->primary_index;
|
||||||
|
strncpy(__entry->name, netfs->name, 8);
|
||||||
|
__entry->name[7] = 0;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p n=%s",
|
||||||
|
__entry->cookie, __entry->name)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_acquire,
|
||||||
|
TP_PROTO(struct fscache_cookie *cookie),
|
||||||
|
|
||||||
|
TP_ARGS(cookie),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__field(struct fscache_cookie *, parent )
|
||||||
|
__array(char, name, 8 )
|
||||||
|
__field(int, p_usage )
|
||||||
|
__field(int, p_n_children )
|
||||||
|
__field(u8, p_flags )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = cookie;
|
||||||
|
__entry->parent = cookie->parent;
|
||||||
|
__entry->p_usage = atomic_read(&cookie->parent->usage);
|
||||||
|
__entry->p_n_children = atomic_read(&cookie->parent->n_children);
|
||||||
|
__entry->p_flags = cookie->parent->flags;
|
||||||
|
memcpy(__entry->name, cookie->def->name, 8);
|
||||||
|
__entry->name[7] = 0;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p p=%p pu=%d pc=%d pf=%02x n=%s",
|
||||||
|
__entry->cookie, __entry->parent, __entry->p_usage,
|
||||||
|
__entry->p_n_children, __entry->p_flags, __entry->name)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_relinquish,
|
||||||
|
TP_PROTO(struct fscache_cookie *cookie, bool retire),
|
||||||
|
|
||||||
|
TP_ARGS(cookie, retire),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__field(struct fscache_cookie *, parent )
|
||||||
|
__field(int, usage )
|
||||||
|
__field(int, n_children )
|
||||||
|
__field(int, n_active )
|
||||||
|
__field(u8, flags )
|
||||||
|
__field(bool, retire )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = cookie;
|
||||||
|
__entry->parent = cookie->parent;
|
||||||
|
__entry->usage = atomic_read(&cookie->usage);
|
||||||
|
__entry->n_children = atomic_read(&cookie->n_children);
|
||||||
|
__entry->n_active = atomic_read(&cookie->n_active);
|
||||||
|
__entry->flags = cookie->flags;
|
||||||
|
__entry->retire = retire;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p u=%d p=%p Nc=%d Na=%d f=%02x r=%u",
|
||||||
|
__entry->cookie, __entry->usage,
|
||||||
|
__entry->parent, __entry->n_children, __entry->n_active,
|
||||||
|
__entry->flags, __entry->retire)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_enable,
|
||||||
|
TP_PROTO(struct fscache_cookie *cookie),
|
||||||
|
|
||||||
|
TP_ARGS(cookie),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__field(int, usage )
|
||||||
|
__field(int, n_children )
|
||||||
|
__field(int, n_active )
|
||||||
|
__field(u8, flags )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = cookie;
|
||||||
|
__entry->usage = atomic_read(&cookie->usage);
|
||||||
|
__entry->n_children = atomic_read(&cookie->n_children);
|
||||||
|
__entry->n_active = atomic_read(&cookie->n_active);
|
||||||
|
__entry->flags = cookie->flags;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p u=%d Nc=%d Na=%d f=%02x",
|
||||||
|
__entry->cookie, __entry->usage,
|
||||||
|
__entry->n_children, __entry->n_active, __entry->flags)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_disable,
|
||||||
|
TP_PROTO(struct fscache_cookie *cookie),
|
||||||
|
|
||||||
|
TP_ARGS(cookie),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__field(int, usage )
|
||||||
|
__field(int, n_children )
|
||||||
|
__field(int, n_active )
|
||||||
|
__field(u8, flags )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = cookie;
|
||||||
|
__entry->usage = atomic_read(&cookie->usage);
|
||||||
|
__entry->n_children = atomic_read(&cookie->n_children);
|
||||||
|
__entry->n_active = atomic_read(&cookie->n_active);
|
||||||
|
__entry->flags = cookie->flags;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p u=%d Nc=%d Na=%d f=%02x",
|
||||||
|
__entry->cookie, __entry->usage,
|
||||||
|
__entry->n_children, __entry->n_active, __entry->flags)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_osm,
|
||||||
|
TP_PROTO(struct fscache_object *object,
|
||||||
|
const struct fscache_state *state,
|
||||||
|
bool wait, bool oob, s8 event_num),
|
||||||
|
|
||||||
|
TP_ARGS(object, state, wait, oob, event_num),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__field(struct fscache_object *, object )
|
||||||
|
__array(char, state, 8 )
|
||||||
|
__field(bool, wait )
|
||||||
|
__field(bool, oob )
|
||||||
|
__field(s8, event_num )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = object->cookie;
|
||||||
|
__entry->object = object;
|
||||||
|
__entry->wait = wait;
|
||||||
|
__entry->oob = oob;
|
||||||
|
__entry->event_num = event_num;
|
||||||
|
memcpy(__entry->state, state->short_name, 8);
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p o=%p %s %s%sev=%d",
|
||||||
|
__entry->cookie,
|
||||||
|
__entry->object,
|
||||||
|
__entry->state,
|
||||||
|
__print_symbolic(__entry->wait,
|
||||||
|
{ true, "WAIT" },
|
||||||
|
{ false, "WORK" }),
|
||||||
|
__print_symbolic(__entry->oob,
|
||||||
|
{ true, " OOB " },
|
||||||
|
{ false, " " }),
|
||||||
|
__entry->event_num)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_page,
|
||||||
|
TP_PROTO(struct fscache_cookie *cookie, struct page *page,
|
||||||
|
enum fscache_page_trace why),
|
||||||
|
|
||||||
|
TP_ARGS(cookie, page, why),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__field(pgoff_t, page )
|
||||||
|
__field(enum fscache_page_trace, why )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = cookie;
|
||||||
|
__entry->page = page->index;
|
||||||
|
__entry->why = why;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p %s pg=%lx",
|
||||||
|
__entry->cookie,
|
||||||
|
__print_symbolic(__entry->why, fscache_page_traces),
|
||||||
|
__entry->page)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_check_page,
|
||||||
|
TP_PROTO(struct fscache_cookie *cookie, struct page *page,
|
||||||
|
void *val, int n),
|
||||||
|
|
||||||
|
TP_ARGS(cookie, page, val, n),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__field(void *, page )
|
||||||
|
__field(void *, val )
|
||||||
|
__field(int, n )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = cookie;
|
||||||
|
__entry->page = page;
|
||||||
|
__entry->val = val;
|
||||||
|
__entry->n = n;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p pg=%p val=%p n=%d",
|
||||||
|
__entry->cookie, __entry->page, __entry->val, __entry->n)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_wake_cookie,
|
||||||
|
TP_PROTO(struct fscache_cookie *cookie),
|
||||||
|
|
||||||
|
TP_ARGS(cookie),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = cookie;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p", __entry->cookie)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_op,
|
||||||
|
TP_PROTO(struct fscache_cookie *cookie, struct fscache_operation *op,
|
||||||
|
enum fscache_op_trace why),
|
||||||
|
|
||||||
|
TP_ARGS(cookie, op, why),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__field(struct fscache_operation *, op )
|
||||||
|
__field(enum fscache_op_trace, why )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = cookie;
|
||||||
|
__entry->op = op;
|
||||||
|
__entry->why = why;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p op=%p %s",
|
||||||
|
__entry->cookie, __entry->op,
|
||||||
|
__print_symbolic(__entry->why, fscache_op_traces))
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_page_op,
|
||||||
|
TP_PROTO(struct fscache_cookie *cookie, struct page *page,
|
||||||
|
struct fscache_operation *op, enum fscache_page_op_trace what),
|
||||||
|
|
||||||
|
TP_ARGS(cookie, page, op, what),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__field(pgoff_t, page )
|
||||||
|
__field(struct fscache_operation *, op )
|
||||||
|
__field(enum fscache_page_op_trace, what )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = cookie;
|
||||||
|
__entry->page = page ? page->index : 0;
|
||||||
|
__entry->op = op;
|
||||||
|
__entry->what = what;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p %s pg=%lx op=%p",
|
||||||
|
__entry->cookie,
|
||||||
|
__print_symbolic(__entry->what, fscache_page_op_traces),
|
||||||
|
__entry->page, __entry->op)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_wrote_page,
|
||||||
|
TP_PROTO(struct fscache_cookie *cookie, struct page *page,
|
||||||
|
struct fscache_operation *op, int ret),
|
||||||
|
|
||||||
|
TP_ARGS(cookie, page, op, ret),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__field(pgoff_t, page )
|
||||||
|
__field(struct fscache_operation *, op )
|
||||||
|
__field(int, ret )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = cookie;
|
||||||
|
__entry->page = page->index;
|
||||||
|
__entry->op = op;
|
||||||
|
__entry->ret = ret;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p pg=%lx op=%p ret=%d",
|
||||||
|
__entry->cookie, __entry->page, __entry->op, __entry->ret)
|
||||||
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(fscache_gang_lookup,
|
||||||
|
TP_PROTO(struct fscache_cookie *cookie, struct fscache_operation *op,
|
||||||
|
void **results, int n, pgoff_t store_limit),
|
||||||
|
|
||||||
|
TP_ARGS(cookie, op, results, n, store_limit),
|
||||||
|
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(struct fscache_cookie *, cookie )
|
||||||
|
__field(struct fscache_operation *, op )
|
||||||
|
__field(pgoff_t, results0 )
|
||||||
|
__field(int, n )
|
||||||
|
__field(pgoff_t, store_limit )
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->cookie = cookie;
|
||||||
|
__entry->op = op;
|
||||||
|
__entry->results0 = results[0] ? ((struct page *)results[0])->index : (pgoff_t)-1;
|
||||||
|
__entry->n = n;
|
||||||
|
__entry->store_limit = store_limit;
|
||||||
|
),
|
||||||
|
|
||||||
|
TP_printk("c=%p op=%p r0=%lx n=%d sl=%lx",
|
||||||
|
__entry->cookie, __entry->op, __entry->results0, __entry->n,
|
||||||
|
__entry->store_limit)
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif /* _TRACE_FSCACHE_H */
|
||||||
|
|
||||||
|
/* This part must be outside protection */
|
||||||
|
#include <trace/define_trace.h>
|
Loading…
Reference in New Issue