* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2016, Intel Corporation.
+ * Copyright (c) 2011, 2017, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
* Lustre is a trademark of Sun Microsystems, Inc.
*
- * glimpse code shared between vvp and liblustre (and other Lustre clients in
- * the future).
+ * glimpse code used by vvp (and other Lustre clients in the future).
*
* Author: Nikita Danilov <nikita.danilov@sun.com>
* Author: Oleg Drokin <oleg.drokin@sun.com>
*/
struct lu_env *env = NULL;
struct cl_io *io = NULL;
- __u16 refcheck;
- int result;
-
- ENTRY;
-
- result = cl_io_get(inode, &env, &io, &refcheck);
- if (result > 0) {
- again:
- io->ci_verify_layout = 1;
- result = cl_io_init(env, io, CIT_MISC, io->ci_obj);
- if (result > 0)
- /*
- * nothing to do for this io. This currently happens
- * when stripe sub-object's are not yet created.
- */
- result = io->ci_result;
- else if (result == 0)
- result = cl_glimpse_lock(env, io, inode, io->ci_obj,
- agl);
+ __u16 refcheck;
+ int retried = 0;
+ int result;
+
+ ENTRY;
+
+ result = cl_io_get(inode, &env, &io, &refcheck);
+ if (result <= 0)
+ RETURN(result);
+
+ do {
+ io->ci_ndelay_tried = retried++;
+ io->ci_ndelay = io->ci_verify_layout = 1;
+ result = cl_io_init(env, io, CIT_GLIMPSE, io->ci_obj);
+ if (result > 0) {
+ /*
+ * nothing to do for this io. This currently happens
+ * when stripe sub-object's are not yet created.
+ */
+ result = io->ci_result;
+ } else if (result == 0) {
+ result = cl_glimpse_lock(env, io, inode, io->ci_obj,
+ agl);
+ if (!agl && result == -EWOULDBLOCK)
+ io->ci_need_restart = 1;
+ }
OBD_FAIL_TIMEOUT(OBD_FAIL_GLIMPSE_DELAY, 2);
- cl_io_fini(env, io);
- if (unlikely(io->ci_need_restart))
- goto again;
- cl_env_put(env, &refcheck);
- }
+ cl_io_fini(env, io);
+ } while (unlikely(io->ci_need_restart));
+
+ cl_env_put(env, &refcheck);
RETURN(result);
}