Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 347830
b: refs/heads/master
c: 8d76349
h: refs/heads/master
v: v3
  • Loading branch information
David Howells committed Dec 20, 2012
1 parent be01844 commit 0b1f3a8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 75bc411388f4aeb9fb0381bd56eb5d67193ed9a1
refs/heads/master: 8d76349d359064859217dc292dc8733e209705af
1 change: 1 addition & 0 deletions trunk/fs/fscache/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ extern const struct file_operations fscache_stats_fops;
static inline void fscache_raise_event(struct fscache_object *object,
unsigned event)
{
BUG_ON(event >= NR_FSCACHE_OBJECT_EVENTS);
if (!test_and_set_bit(event, &object->events) &&
test_bit(event, &object->event_mask))
fscache_enqueue_object(object);
Expand Down
23 changes: 17 additions & 6 deletions trunk/fs/fscache/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
{
enum fscache_object_state new_state;
struct fscache_cookie *cookie;
int event;

ASSERT(object != NULL);

Expand Down Expand Up @@ -275,7 +276,8 @@ static void fscache_object_state_machine(struct fscache_object *object)

/* determine the transition from a lookup state */
lookup_transit:
switch (fls(object->events & object->event_mask) - 1) {
event = fls(object->events & object->event_mask) - 1;
switch (event) {
case FSCACHE_OBJECT_EV_WITHDRAW:
case FSCACHE_OBJECT_EV_RETIRE:
case FSCACHE_OBJECT_EV_RELEASE:
Expand All @@ -292,7 +294,8 @@ static void fscache_object_state_machine(struct fscache_object *object)

/* determine the transition from an active state */
active_transit:
switch (fls(object->events & object->event_mask) - 1) {
event = fls(object->events & object->event_mask) - 1;
switch (event) {
case FSCACHE_OBJECT_EV_WITHDRAW:
case FSCACHE_OBJECT_EV_RETIRE:
case FSCACHE_OBJECT_EV_RELEASE:
Expand All @@ -314,7 +317,8 @@ static void fscache_object_state_machine(struct fscache_object *object)

/* determine the transition from a terminal state */
terminal_transit:
switch (fls(object->events & object->event_mask) - 1) {
event = fls(object->events & object->event_mask) - 1;
switch (event) {
case FSCACHE_OBJECT_EV_WITHDRAW:
new_state = FSCACHE_OBJECT_WITHDRAWING;
goto change_state;
Expand Down Expand Up @@ -347,8 +351,8 @@ static void fscache_object_state_machine(struct fscache_object *object)

unsupported_event:
printk(KERN_ERR "FS-Cache:"
" Unsupported event %lx [mask %lx] in state %s\n",
object->events, object->event_mask,
" Unsupported event %d [%lx/%lx] in state %s\n",
event, object->events, object->event_mask,
fscache_object_states[object->state]);
BUG();
}
Expand Down Expand Up @@ -945,7 +949,7 @@ static void fscache_invalidate_object(struct fscache_object *object)

spin_lock(&cookie->lock);
if (fscache_submit_exclusive_op(object, op) < 0)
BUG();
goto submit_op_failed;
spin_unlock(&cookie->lock);
fscache_put_operation(op);

Expand All @@ -960,4 +964,11 @@ static void fscache_invalidate_object(struct fscache_object *object)
*/
fscache_invalidation_complete(cookie);
_leave("");
return;

submit_op_failed:
spin_unlock(&cookie->lock);
kfree(op);
fscache_raise_event(object, FSCACHE_OBJECT_EV_ERROR);
_leave(" [EIO]");
}
13 changes: 10 additions & 3 deletions trunk/fs/fscache/operation.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ static void fscache_run_op(struct fscache_object *object,
int fscache_submit_exclusive_op(struct fscache_object *object,
struct fscache_operation *op)
{
int ret;

_enter("{OBJ%x OP%x},", object->debug_id, op->debug_id);

ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED);
Expand Down Expand Up @@ -116,20 +118,25 @@ int fscache_submit_exclusive_op(struct fscache_object *object,

/* need to issue a new write op after this */
clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags);
ret = 0;
} else if (object->state == FSCACHE_OBJECT_CREATING) {
op->object = object;
object->n_ops++;
object->n_exclusive++; /* reads and writes must wait */
atomic_inc(&op->usage);
list_add_tail(&op->pend_link, &object->pending_ops);
fscache_stat(&fscache_n_op_pend);
ret = 0;
} else {
/* not allowed to submit ops in any other state */
BUG();
/* If we're in any other state, there must have been an I/O
* error of some nature.
*/
ASSERT(test_bit(FSCACHE_IOERROR, &object->cache->flags));
ret = -EIO;
}

spin_unlock(&object->lock);
return 0;
return ret;
}

/*
Expand Down

0 comments on commit 0b1f3a8

Please sign in to comment.