[PATCH 14/67] fscache: Temporarily disable fscache_invalidate()

David Howells
2021-10-18T14:54:41Z

Temporarily disable the fscache side of fscache_invalidate() so that the
operation managing code can be removed.

Signed-off-by: David Howells <dhowells@redhat.com>
---

fs/cachefiles/interface.c | 9 ++---
fs/fscache/cookie.c | 23 +-----------
fs/fscache/object.c | 78 +----------------------------------------
include/linux/fscache-cache.h | 2 +
4 files changed, 7 insertions(+), 105 deletions(-)

diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c
index 4a813a490ffe..a84adf638737 100644
--- a/fs/cachefiles/interface.c
+++ b/fs/cachefiles/interface.c
@@ -388,7 +388,7 @@ static int cachefiles_attr_changed(struct cachefiles_object *object)
/*
* Invalidate an object
*/
-static void cachefiles_invalidate_object(struct fscache_operation *op)
+static void cachefiles_invalidate_object(struct fscache_object *_object)
{
struct cachefiles_object *object;
struct cachefiles_cache *cache;
@@ -397,14 +397,14 @@ static void cachefiles_invalidate_object(struct fscache_operation *op)
uint64_t ni_size;
int ret;

- object = container_of(op->object, struct cachefiles_object, fscache);
+ object = container_of(_object, struct cachefiles_object, fscache);
cache = container_of(object->fscache.cache,
struct cachefiles_cache, cache);

- ni_size = op->object->cookie->object_size;
+ ni_size = object->fscache.cookie->object_size;

_enter("{OBJ%x},[%llu]",
- op->object->debug_id, (unsigned long long)ni_size);
+ object->fscache.debug_id, (unsigned long long)ni_size);

if (object->backer) {
ASSERT(d_is_reg(object->backer));
@@ -425,7 +425,6 @@ static void cachefiles_invalidate_object(struct fscache_operation *op)
}
}

- fscache_op_complete(op, true);
_leave("");
}

diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index 78938ea6ad1a..1a7372a1d1aa 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -612,8 +612,6 @@ static int fscache_attach_object(struct fscache_cookie *cookie,
*/
void __fscache_invalidate(struct fscache_cookie *cookie)
{
- struct fscache_object *object;
-
_enter("{%s}", cookie->type_name);

fscache_stat(&fscache_n_invalidates);
@@ -625,26 +623,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
*/
ASSERTCMP(cookie->type, ==, FSCACHE_COOKIE_TYPE_DATAFILE);

- /* If there's an object, we tell the object state machine to handle the
- * invalidation on our behalf, otherwise there's nothing to do.
- */
- if (!hlist_empty(&cookie->backing_objects)) {
- spin_lock(&cookie->lock);
-
- if (fscache_cookie_enabled(cookie) &&
- !hlist_empty(&cookie->backing_objects) &&
- !test_and_set_bit(FSCACHE_COOKIE_INVALIDATING,
- &cookie->flags)) {
- object = hlist_entry(cookie->backing_objects.first,
- struct fscache_object,
- cookie_link);
- if (fscache_object_is_live(object))
- fscache_raise_event(
- object, FSCACHE_OBJECT_EV_INVALIDATE);
- }
-
- spin_unlock(&cookie->lock);
- }
+ /* TODO: Do invalidation */

_leave("");
}
diff --git a/fs/fscache/object.c b/fs/fscache/object.c
index 7aa1f90d978b..4941b961c079 100644
--- a/fs/fscache/object.c
+++ b/fs/fscache/object.c
@@ -899,86 +899,10 @@ static void fscache_dequeue_object(struct fscache_object *object)
_leave("");
}

-/*
- * Asynchronously invalidate an object.
- */
-static const struct fscache_state *_fscache_invalidate_object(struct fscache_object *object,
- int event)
-{
- struct fscache_operation *op;
- struct fscache_cookie *cookie = object->cookie;
-
- _enter("{OBJ%x},%d", object->debug_id, event);
-
- /* We're going to need the cookie. If the cookie is not available then
- * retire the object instead.
- */
- if (!fscache_use_cookie(object)) {
- set_bit(FSCACHE_OBJECT_RETIRED, &object->flags);
- _leave(" [no cookie]");
- return transit_to(KILL_OBJECT);
- }
-
- /* Reject any new read/write ops and abort any that are pending. */
- clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags);
- fscache_cancel_all_ops(object);
-
- /* Now we have to wait for in-progress reads and writes */
- op = kzalloc(sizeof(*op), GFP_KERNEL);
- if (!op)
- goto nomem;
-
- fscache_operation_init(cookie, op, object->cache->ops->invalidate_object,
- NULL, NULL);
- op->flags = FSCACHE_OP_ASYNC |
- (1 << FSCACHE_OP_EXCLUSIVE) |
- (1 << FSCACHE_OP_UNUSE_COOKIE);
-
- spin_lock(&cookie->lock);
- if (fscache_submit_exclusive_op(object, op) < 0)
- goto submit_op_failed;
- spin_unlock(&cookie->lock);
- fscache_put_operation(op);
-
- /* Once we've completed the invalidation, we know there will be no data
- * stored in the cache and thus we can reinstate the data-check-skip
- * optimisation.
- */
- set_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
-
- /* We can allow read and write requests to come in once again. They'll
- * queue up behind our exclusive invalidation operation.
- */
- if (test_and_clear_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags))
- wake_up_bit(&cookie->flags, FSCACHE_COOKIE_INVALIDATING);
- _leave(" [ok]");
- return transit_to(UPDATE_OBJECT);
-
-nomem:
- fscache_mark_object_dead(object);
- fscache_unuse_cookie(object);
- _leave(" [ENOMEM]");
- return transit_to(KILL_OBJECT);
-
-submit_op_failed:
- fscache_mark_object_dead(object);
- spin_unlock(&cookie->lock);
- fscache_unuse_cookie(object);
- kfree(op);
- _leave(" [EIO]");
- return transit_to(KILL_OBJECT);
-}
-
static const struct fscache_state *fscache_invalidate_object(struct fscache_object *object,
int event)
{
- const struct fscache_state *s;
-
- fscache_stat(&fscache_n_invalidates_run);
- fscache_stat(&fscache_n_cop_invalidate_object);
- s = _fscache_invalidate_object(object, event);
- fscache_stat_d(&fscache_n_cop_invalidate_object);
- return s;
+ return transit_to(UPDATE_OBJECT);
}

/*
diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
index d0c6c09bb5a1..436456d4ff64 100644
--- a/include/linux/fscache-cache.h
+++ b/include/linux/fscache-cache.h
@@ -171,7 +171,7 @@ struct fscache_cache_ops {
void (*update_object)(struct fscache_object *object);

/* Invalidate an object */
- void (*invalidate_object)(struct fscache_operation *op);
+ void (*invalidate_object)(struct fscache_object *object);

/* discard the resources pinned by an object and effect retirement if
* necessary */