X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;ds=inline;f=lustre%2Fobdclass%2Fcl_io.c;h=bcb0ad34be6b49d3b2eb7fb0d428604e655b982b;hb=58c997babb608f5ab26f326772574bfd34e8cdc3;hp=f3d18faed39fc5c8216053ea1777b0706c6dc025;hpb=08aa217ce49aba1ded52e0f7adb8a607035123fd;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/cl_io.c b/lustre/obdclass/cl_io.c index f3d18fa..bcb0ad3 100644 --- a/lustre/obdclass/cl_io.c +++ b/lustre/obdclass/cl_io.c @@ -44,9 +44,6 @@ #include #include #include -/* lu_time_global_{init,fini}() */ -#include - #include #include "cl_internal.h" @@ -133,6 +130,7 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) switch(io->ci_type) { case CIT_READ: case CIT_WRITE: + break; case CIT_FAULT: case CIT_FSYNC: LASSERT(!io->ci_need_restart); @@ -392,12 +390,7 @@ static int cl_lockset_lock_one(const struct lu_env *env, ENTRY; - if (io->ci_lockreq == CILR_PEEK) { - lock = cl_lock_peek(env, io, &link->cill_descr, "io", io); - if (lock == NULL) - lock = ERR_PTR(-ENODATA); - } else - lock = cl_lock_request(env, io, &link->cill_descr, "io", io); + lock = cl_lock_request(env, io, &link->cill_descr, "io", io); if (!IS_ERR(lock)) { link->cill_lock = lock; @@ -1686,11 +1679,12 @@ EXPORT_SYMBOL(cl_req_attr_set); */ void cl_sync_io_init(struct cl_sync_io *anchor, int nrpages) { - ENTRY; - cfs_waitq_init(&anchor->csi_waitq); - cfs_atomic_set(&anchor->csi_sync_nr, nrpages); - anchor->csi_sync_rc = 0; - EXIT; + ENTRY; + cfs_waitq_init(&anchor->csi_waitq); + cfs_atomic_set(&anchor->csi_sync_nr, nrpages); + cfs_atomic_set(&anchor->csi_barrier, nrpages > 0); + anchor->csi_sync_rc = 0; + EXIT; } EXPORT_SYMBOL(cl_sync_io_init); @@ -1728,8 +1722,16 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_io *io, } LASSERT(cfs_atomic_read(&anchor->csi_sync_nr) == 0); cl_page_list_assume(env, io, queue); - POISON(anchor, 0x5a, sizeof *anchor); - RETURN(rc); + + /* wait until cl_sync_io_note() has done wakeup */ + while (unlikely(cfs_atomic_read(&anchor->csi_barrier) != 0)) { +#ifdef __KERNEL__ + cpu_relax(); +#endif + } + + POISON(anchor, 0x5a, sizeof *anchor); + RETURN(rc); } EXPORT_SYMBOL(cl_sync_io_wait); @@ -1747,8 +1749,11 @@ void cl_sync_io_note(struct cl_sync_io *anchor, int ioret) * IO. */ LASSERT(cfs_atomic_read(&anchor->csi_sync_nr) > 0); - if (cfs_atomic_dec_and_test(&anchor->csi_sync_nr)) - cfs_waitq_broadcast(&anchor->csi_waitq); - EXIT; + if (cfs_atomic_dec_and_test(&anchor->csi_sync_nr)) { + cfs_waitq_broadcast(&anchor->csi_waitq); + /* it's safe to nuke or reuse anchor now */ + cfs_atomic_set(&anchor->csi_barrier, 0); + } + EXIT; } EXPORT_SYMBOL(cl_sync_io_note);