History

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull fscache fixes from Al Viro. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: fscache: Fix dead object requeue fscache: Clear outstanding writes when disabling a cookie FS-Cache: Initialise stores_lock in netfs cookie

Linus Torvalds committed 9 years ago

Commit 2883aae2 parents e387dc1 e26bfeb4 files · +37 −2Browse files

Unified · Split

4 files
  1. fs/fscache/cookie.c +5 −0
  2. fs/fscache/netfs.c +1 −0
  3. fs/fscache/object.c +30 −2
  4. include/linux/fscache-cache.h +1 −0
fs/fscache/cookie.c+5−0
@@ -542,6 +542,7 @@ void __fscache_disable_cookie(struct fscache_cookie *cookie, bool invalidate) · 541 unmodified lines
542 hlist_for_each_entry(object, &cookie->backing_objects, cookie_link) {542 hlist_for_each_entry(object, &cookie->backing_objects, cookie_link) {
543 if (invalidate)543 if (invalidate)
544 set_bit(FSCACHE_OBJECT_RETIRED, &object->flags);544 set_bit(FSCACHE_OBJECT_RETIRED, &object->flags);
545 clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags);
545 fscache_raise_event(object, FSCACHE_OBJECT_EV_KILL);546 fscache_raise_event(object, FSCACHE_OBJECT_EV_KILL);
546 }547 }
547 } else {548 } else {
@@ -560,6 +561,10 @@ void __fscache_disable_cookie(struct fscache_cookie *cookie, bool invalidate) · 12 unmodified lines
560 wait_on_atomic_t(&cookie->n_active, fscache_wait_atomic_t,561 wait_on_atomic_t(&cookie->n_active, fscache_wait_atomic_t,
561 TASK_UNINTERRUPTIBLE);562 TASK_UNINTERRUPTIBLE);
562 563
564 /* Make sure any pending writes are cancelled. */
565 if (cookie->def->type != FSCACHE_COOKIE_TYPE_INDEX)
566 fscache_invalidate_writes(cookie);
567
563 /* Reset the cookie state if it wasn't relinquished */568 /* Reset the cookie state if it wasn't relinquished */
564 if (!test_bit(FSCACHE_COOKIE_RELINQUISHED, &cookie->flags)) {569 if (!test_bit(FSCACHE_COOKIE_RELINQUISHED, &cookie->flags)) {
565 atomic_inc(&cookie->n_active);570 atomic_inc(&cookie->n_active);
fs/fscache/netfs.c+1−0
@@ -48,6 +48,7 @@ int __fscache_register_netfs(struct fscache_netfs *netfs) · 47 unmodified lines
48 cookie->flags = 1 << FSCACHE_COOKIE_ENABLED;48 cookie->flags = 1 << FSCACHE_COOKIE_ENABLED;
49 49
50 spin_lock_init(&cookie->lock);50 spin_lock_init(&cookie->lock);
51 spin_lock_init(&cookie->stores_lock);
51 INIT_HLIST_HEAD(&cookie->backing_objects);52 INIT_HLIST_HEAD(&cookie->backing_objects);
52 53
53 /* check the netfs type is not already present */54 /* check the netfs type is not already present */
fs/fscache/object.c+30−2
@@ -30,6 +30,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object · 29 unmodified lines
30static const struct fscache_state *fscache_object_available(struct fscache_object *, int);30static const struct fscache_state *fscache_object_available(struct fscache_object *, int);
31static const struct fscache_state *fscache_parent_ready(struct fscache_object *, int);31static const struct fscache_state *fscache_parent_ready(struct fscache_object *, int);
32static const struct fscache_state *fscache_update_object(struct fscache_object *, int);32static const struct fscache_state *fscache_update_object(struct fscache_object *, int);
33static const struct fscache_state *fscache_object_dead(struct fscache_object *, int);
33 34
34#define __STATE_NAME(n) fscache_osm_##n35#define __STATE_NAME(n) fscache_osm_##n
35#define STATE(n) (&__STATE_NAME(n))36#define STATE(n) (&__STATE_NAME(n))
@@ -91,7 +92,7 @@ static WORK_STATE(LOOKUP_FAILURE, "LCFL", fscache_lookup_failure); · 55 unmodified lines
91static WORK_STATE(KILL_OBJECT, "KILL", fscache_kill_object);92static WORK_STATE(KILL_OBJECT, "KILL", fscache_kill_object);
92static WORK_STATE(KILL_DEPENDENTS, "KDEP", fscache_kill_dependents);93static WORK_STATE(KILL_DEPENDENTS, "KDEP", fscache_kill_dependents);
93static WORK_STATE(DROP_OBJECT, "DROP", fscache_drop_object);94static WORK_STATE(DROP_OBJECT, "DROP", fscache_drop_object);
94static WORK_STATE(OBJECT_DEAD, "DEAD", (void*)2UL);95static WORK_STATE(OBJECT_DEAD, "DEAD", fscache_object_dead);
95 96
96static WAIT_STATE(WAIT_FOR_INIT, "?INI",97static WAIT_STATE(WAIT_FOR_INIT, "?INI",
97 TRANSIT_TO(INIT_OBJECT, 1 << FSCACHE_OBJECT_EV_NEW_CHILD));98 TRANSIT_TO(INIT_OBJECT, 1 << FSCACHE_OBJECT_EV_NEW_CHILD));
@@ -229,6 +230,10 @@ execute_work_state: · 131 unmodified lines
229 event = -1;230 event = -1;
230 if (new_state == NO_TRANSIT) {231 if (new_state == NO_TRANSIT) {
231 _debug("{OBJ%x} %s notrans", object->debug_id, state->name);232 _debug("{OBJ%x} %s notrans", object->debug_id, state->name);
233 if (unlikely(state == STATE(OBJECT_DEAD))) {
234 _leave(" [dead]");
235 return;
236 }
232 fscache_enqueue_object(object);237 fscache_enqueue_object(object);
233 event_mask = object->oob_event_mask;238 event_mask = object->oob_event_mask;
234 goto unmask_events;239 goto unmask_events;
@@ -239,7 +244,7 @@ execute_work_state: · 4 unmodified lines
239 object->state = state = new_state;244 object->state = state = new_state;
240 245
241 if (state->work) {246 if (state->work) {
242 if (unlikely(state->work == ((void *)2UL))) {247 if (unlikely(state == STATE(OBJECT_DEAD))) {
243 _leave(" [dead]");248 _leave(" [dead]");
244 return;249 return;
245 }250 }
@@ -645,6 +650,12 @@ static const struct fscache_state *fscache_kill_object(struct fscache_object *ob · 399 unmodified lines
645 fscache_mark_object_dead(object);650 fscache_mark_object_dead(object);
646 object->oob_event_mask = 0;651 object->oob_event_mask = 0;
647 652
653 if (test_bit(FSCACHE_OBJECT_RETIRED, &object->flags)) {
654 /* Reject any new read/write ops and abort any that are pending. */
655 clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags);
656 fscache_cancel_all_ops(object);
657 }
658
648 if (list_empty(&object->dependents) &&659 if (list_empty(&object->dependents) &&
649 object->n_ops == 0 &&660 object->n_ops == 0 &&
650 object->n_children == 0)661 object->n_children == 0)
@@ -1077,3 +1088,20 @@ void fscache_object_mark_killed(struct fscache_object *object, · 426 unmodified lines
1077 }1088 }
1078}1089}
1079EXPORT_SYMBOL(fscache_object_mark_killed);1090EXPORT_SYMBOL(fscache_object_mark_killed);
1091
1092/*
1093 * The object is dead. We can get here if an object gets queued by an event
1094 * that would lead to its death (such as EV_KILL) when the dispatcher is
1095 * already running (and so can be requeued) but hasn't yet cleared the event
1096 * mask.
1097 */
1098static const struct fscache_state *fscache_object_dead(struct fscache_object *object,
1099 int event)
1100{
1101 if (!test_and_set_bit(FSCACHE_OBJECT_RUN_AFTER_DEAD,
1102 &object->flags))
1103 return NO_TRANSIT;
1104
1105 WARN(true, "FS-Cache object redispatched after death");
1106 return NO_TRANSIT;
1107}
include/linux/fscache-cache.h+1−0
@@ -360,6 +360,7 @@ struct fscache_object { · 359 unmodified lines
360#define FSCACHE_OBJECT_IS_AVAILABLE 5 /* T if object has become active */360#define FSCACHE_OBJECT_IS_AVAILABLE 5 /* T if object has become active */
361#define FSCACHE_OBJECT_RETIRED 6 /* T if object was retired on relinquishment */361#define FSCACHE_OBJECT_RETIRED 6 /* T if object was retired on relinquishment */
362#define FSCACHE_OBJECT_KILLED_BY_CACHE 7 /* T if object was killed by the cache */362#define FSCACHE_OBJECT_KILLED_BY_CACHE 7 /* T if object was killed by the cache */
363#define FSCACHE_OBJECT_RUN_AFTER_DEAD 8 /* T if object has been dispatched after death */
363 364
364 struct list_head cache_link; /* link in cache->object_list */365 struct list_head cache_link; /* link in cache->object_list */
365 struct hlist_node cookie_link; /* link in cookie->backing_objects */366 struct hlist_node cookie_link; /* link in cookie->backing_objects */