Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87021526 authored by David Howells's avatar David Howells
Browse files

FS-Cache: fscache_object_is_dead() has wrong logic, kill it



fscache_object_is_dead() returns true only if the object is marked dead and
the cache got an I/O error.  This should be a logical OR instead.  Since two
of the callers got split up into handling for separate subcases, expand the
other callers and kill the function.  This is probably the right thing to do
anyway since one of the subcases isn't about the object at all, but rather
about the cache.

Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Reviewed-by: default avatarSteve Dickson <steved@redhat.com>
Acked-by: default avatarJeff Layton <jeff.layton@primarydata.com>
parent f09b443d
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -327,7 +327,8 @@ static int fscache_alloc_object(struct fscache_cache *cache,


object_already_extant:
object_already_extant:
	ret = -ENOBUFS;
	ret = -ENOBUFS;
	if (fscache_object_is_dead(object)) {
	if (fscache_object_is_dying(object) ||
	    fscache_cache_is_broken(object)) {
		spin_unlock(&cookie->lock);
		spin_unlock(&cookie->lock);
		goto error;
		goto error;
	}
	}
+4 −2
Original line number Original line Diff line number Diff line
@@ -377,11 +377,13 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
		_leave(" = -ENOBUFS [cancelled]");
		_leave(" = -ENOBUFS [cancelled]");
		return -ENOBUFS;
		return -ENOBUFS;
	}
	}
	if (unlikely(fscache_object_is_dead(object))) {
	if (unlikely(fscache_object_is_dying(object) ||
		pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->state);
		     fscache_cache_is_broken(object))) {
		enum fscache_operation_state state = op->state;
		fscache_cancel_op(op, do_cancel);
		fscache_cancel_op(op, do_cancel);
		if (stat_object_dead)
		if (stat_object_dead)
			fscache_stat(stat_object_dead);
			fscache_stat(stat_object_dead);
		_leave(" = -ENOBUFS [obj dead %d]", state);
		return -ENOBUFS;
		return -ENOBUFS;
	}
	}
	return 0;
	return 0;
+0 −6
Original line number Original line Diff line number Diff line
@@ -423,12 +423,6 @@ static inline bool fscache_object_is_active(struct fscache_object *object)
		!fscache_cache_is_broken(object);
		!fscache_cache_is_broken(object);
}
}


static inline bool fscache_object_is_dead(struct fscache_object *object)
{
	return fscache_object_is_dying(object) &&
		fscache_cache_is_broken(object);
}

/**
/**
 * fscache_object_destroyed - Note destruction of an object in a cache
 * fscache_object_destroyed - Note destruction of an object in a cache
 * @cache: The cache from which the object came
 * @cache: The cache from which the object came