aio: fix dirty_head completion

This commit is contained in:
Thomas Schoebel-Theuer 2013-07-10 09:53:59 +02:00
parent ea42d36a15
commit d70a415b9a
1 changed files with 30 additions and 8 deletions

View File

@ -287,9 +287,13 @@ static void aio_ref_put(struct aio_output *output, struct mref_object *mref)
} }
static static
void _complete(struct aio_output *output, struct mref_object *mref, int err) void _complete(struct aio_output *output, struct aio_mref_aspect *mref_a, int err)
{ {
_mref_check(mref); struct mref_object *mref;
CHECK_PTR(mref_a, fatal);
mref = mref_a->object;
CHECK_PTR(mref, fatal);
mars_trace(mref, "aio_endio"); mars_trace(mref, "aio_endio");
@ -309,6 +313,8 @@ done:
atomic_dec(&output->read_count); atomic_dec(&output->read_count);
} }
remove_dirty(output, mref_a);
aio_ref_put(output, mref); aio_ref_put(output, mref);
atomic_dec(&mars_global_io_flying); atomic_dec(&mars_global_io_flying);
return; return;
@ -316,6 +322,23 @@ done:
err_found: err_found:
MARS_FAT("giving up...\n"); MARS_FAT("giving up...\n");
goto done; goto done;
fatal:
MARS_FAT("bad pointer, giving up...\n");
}
static
void _complete_mref(struct aio_output *output, struct mref_object *mref, int err)
{
struct aio_mref_aspect *mref_a;
_mref_check(mref);
mref_a = aio_mref_get_aspect(output->brick, mref);
CHECK_PTR(mref_a, fatal);
_complete(output, mref_a, err);
return;
fatal:
MARS_FAT("bad pointer, giving up...\n");
} }
static static
@ -325,8 +348,7 @@ void _complete_all(struct list_head *tmp_list, struct aio_output *output, int er
struct list_head *tmp = tmp_list->next; struct list_head *tmp = tmp_list->next;
struct aio_mref_aspect *mref_a = container_of(tmp, struct aio_mref_aspect, io_head); struct aio_mref_aspect *mref_a = container_of(tmp, struct aio_mref_aspect, io_head);
list_del_init(tmp); list_del_init(tmp);
remove_dirty(output, mref_a); _complete(output, mref_a, err);
_complete(output, mref_a->object, err);
} }
} }
@ -365,7 +387,7 @@ static void aio_ref_io(struct aio_output *output, struct mref_object *mref)
return; return;
done: done:
_complete(output, mref, err); _complete_mref(output, mref, err);
} }
static int aio_submit(struct aio_output *output, struct aio_mref_aspect *mref_a, bool use_fdsync) static int aio_submit(struct aio_output *output, struct aio_mref_aspect *mref_a, bool use_fdsync)
@ -668,7 +690,7 @@ static int aio_event_thread(void *data)
continue; continue;
} }
_complete(output, mref, err); _complete(output, mref_a, err);
} }
} }
@ -870,7 +892,7 @@ static int aio_submit_thread(void *data)
continue; continue;
} }
MARS_DBG("ENODATA %lld\n", len); MARS_DBG("ENODATA %lld\n", len);
_complete(output, mref, -ENODATA); _complete(output, mref_a, -ENODATA);
continue; continue;
} }
} }
@ -891,7 +913,7 @@ static int aio_submit_thread(void *data)
error: error:
if (unlikely(status < 0)) { if (unlikely(status < 0)) {
MARS_IO("submit_count = %d status = %d\n", atomic_read(&output->submit_count), status); MARS_IO("submit_count = %d status = %d\n", atomic_read(&output->submit_count), status);
_complete(output, mref, status); _complete_mref(output, mref, status);
} }
} }