mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
fscache: Pass object size in rather than calling back for it
Pass the object size in to fscache_acquire_cookie() and fscache_write_page() rather than the netfs providing a callback by which it can be received. This makes it easier to update the size of the object when a new page is written that extends the object. The current object size is also passed by fscache to the check_aux function, obviating the need to store it in the aux data. Signed-off-by: David Howells <[email protected]> Acked-by: Anna Schumaker <[email protected]> Tested-by: Steve Dickson <[email protected]>
This commit is contained in:
parent
402cb8dda9
commit
ee1235a9a0
21 changed files with 127 additions and 166 deletions
|
|
@ -21,7 +21,8 @@ struct kmem_cache *fscache_cookie_jar;
|
|||
|
||||
static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
|
||||
|
||||
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);
|
||||
static int fscache_alloc_object(struct fscache_cache *cache,
|
||||
struct fscache_cookie *cookie);
|
||||
static int fscache_attach_object(struct fscache_cookie *cookie,
|
||||
|
|
@ -61,6 +62,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
|
|||
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,
|
||||
bool enable)
|
||||
{
|
||||
struct fscache_cookie *cookie;
|
||||
|
|
@ -160,7 +162,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
|
|||
* - we create indices on disk when we need them as an index
|
||||
* may exist in multiple caches */
|
||||
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);
|
||||
} else {
|
||||
atomic_dec(&parent->n_children);
|
||||
|
|
@ -194,6 +196,7 @@ EXPORT_SYMBOL(__fscache_acquire_cookie);
|
|||
*/
|
||||
void __fscache_enable_cookie(struct fscache_cookie *cookie,
|
||||
const void *aux_data,
|
||||
loff_t object_size,
|
||||
bool (*can_enable)(void *data),
|
||||
void *data)
|
||||
{
|
||||
|
|
@ -215,7 +218,7 @@ void __fscache_enable_cookie(struct fscache_cookie *cookie,
|
|||
/* Wait for outstanding disablement to complete */
|
||||
__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);
|
||||
} else {
|
||||
set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags);
|
||||
|
|
@ -232,11 +235,11 @@ EXPORT_SYMBOL(__fscache_enable_cookie);
|
|||
* - this must make sure the index chain is instantiated and instantiate the
|
||||
* 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_cache *cache;
|
||||
uint64_t i_size;
|
||||
int ret;
|
||||
|
||||
_enter("");
|
||||
|
|
@ -275,9 +278,6 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
|
|||
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);
|
||||
if (hlist_empty(&cookie->backing_objects)) {
|
||||
spin_unlock(&cookie->lock);
|
||||
|
|
@ -287,7 +287,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
|
|||
object = hlist_entry(cookie->backing_objects.first,
|
||||
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
|
||||
* (done by fscache_initialise_object()) */
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@
|
|||
static
|
||||
enum fscache_checkaux fscache_fsdef_netfs_check_aux(void *cookie_netfs_data,
|
||||
const void *data,
|
||||
uint16_t datalen);
|
||||
uint16_t datalen,
|
||||
loff_t object_size);
|
||||
|
||||
/*
|
||||
* The root index is owned by FS-Cache itself.
|
||||
|
|
@ -76,7 +77,8 @@ struct fscache_cookie_def fscache_fsdef_netfs_def = {
|
|||
static enum fscache_checkaux fscache_fsdef_netfs_check_aux(
|
||||
void *cookie_netfs_data,
|
||||
const void *data,
|
||||
uint16_t datalen)
|
||||
uint16_t datalen,
|
||||
loff_t object_size)
|
||||
{
|
||||
struct fscache_netfs *netfs = cookie_netfs_data;
|
||||
uint32_t version;
|
||||
|
|
|
|||
|
|
@ -922,7 +922,8 @@ static void fscache_dequeue_object(struct fscache_object *object)
|
|||
* and creation).
|
||||
*/
|
||||
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;
|
||||
|
||||
|
|
@ -932,7 +933,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
|
|||
}
|
||||
|
||||
result = object->cookie->def->check_aux(object->cookie->netfs_data,
|
||||
data, datalen);
|
||||
data, datalen, object_size);
|
||||
switch (result) {
|
||||
/* entry okay as is */
|
||||
case FSCACHE_CHECKAUX_OKAY:
|
||||
|
|
|
|||
|
|
@ -963,6 +963,7 @@ void fscache_invalidate_writes(struct fscache_cookie *cookie)
|
|||
*/
|
||||
int __fscache_write_page(struct fscache_cookie *cookie,
|
||||
struct page *page,
|
||||
loff_t object_size,
|
||||
gfp_t gfp)
|
||||
{
|
||||
struct fscache_storage *op;
|
||||
|
|
@ -1014,6 +1015,10 @@ int __fscache_write_page(struct fscache_cookie *cookie,
|
|||
/* add the page to the pending-storage radix tree on the backing
|
||||
* object */
|
||||
spin_lock(&object->lock);
|
||||
|
||||
if (object->store_limit_l != object_size)
|
||||
fscache_set_store_limit(object, object_size);
|
||||
|
||||
spin_lock(&cookie->stores_lock);
|
||||
|
||||
_debug("store limit %llx", (unsigned long long) object->store_limit);
|
||||
|
|
|
|||
Loading…
Reference in a new issue