From a7f48e6c15e28617793d89958c79e9ed8cb73e65 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Tue, 20 Oct 2020 09:20:35 -0500 Subject: [PATCH] LU-14047 lustre: change EWOULDBLOCK to EAGAIN On linux, EWOULDBLOCK has always been defined as an alias for EAGAIN. In the interest of readability we should not use two names for the same thing. So change the remaining uses of EWOULDBLOCK to EAGAIN and add EWOULDBLOCK||EAGAIN to spelling.txt. Signed-off-by: John L. Hammond Change-Id: Ib48b8a1e58bfa961d2a4ba411c038c476bfc300d Reviewed-on: https://review.whamcloud.com/40307 Tested-by: jenkins Reviewed-by: Neil Brown Tested-by: Maloo Reviewed-by: Yingjin Qian Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- contrib/scripts/spelling.txt | 1 + lustre/doc/llapi_hsm_copytool_register.3 | 4 ++-- lustre/fld/fld_request.c | 2 +- lustre/include/cl_object.h | 10 +++++----- lustre/ldlm/ldlm_extent.c | 16 ++++++++-------- lustre/llite/glimpse.c | 2 +- lustre/llite/vvp_page.c | 2 +- lustre/obdclass/cl_io.c | 2 +- lustre/osc/osc_io.c | 2 +- lustre/osc/osc_lock.c | 2 +- lustre/osc/osc_request.c | 2 +- lustre/osp/osp_precreate.c | 8 ++++---- lustre/ptlrpc/client.c | 2 +- lustre/ptlrpc/errno.c | 4 ++-- lustre/ptlrpc/sec.c | 2 +- lustre/tests/llapi_hsm_test.c | 4 ++-- lustre/tests/mpi/parallel_grouplock.c | 12 ++++++------ 17 files changed, 39 insertions(+), 38 deletions(-) diff --git a/contrib/scripts/spelling.txt b/contrib/scripts/spelling.txt index 55eeb44..d04f21b 100644 --- a/contrib/scripts/spelling.txt +++ b/contrib/scripts/spelling.txt @@ -100,6 +100,7 @@ cfs_time_current_sec||ktime_get_real_seconds CLASSERT||BUILD_BUG_ON() msecs_to_jiffies||cfs_time_seconds DEFINE_TIMER||CFS_DEFINE_TIMER +EWOULDBLOCK||EAGAIN container_of0||container_of_safe DN_MAX_BONUSLEN||DN_BONUS_SIZE(dnodesize) DN_OLD_MAX_BONUSLEN||DN_BONUS_SIZE(DNODE_MIN_SIZE) diff --git a/lustre/doc/llapi_hsm_copytool_register.3 b/lustre/doc/llapi_hsm_copytool_register.3 index 22e5047..01dee2a 100644 --- a/lustre/doc/llapi_hsm_copytool_register.3 +++ b/lustre/doc/llapi_hsm_copytool_register.3 @@ -125,7 +125,7 @@ with the register copytool. On error, a negative errno is returned. .UNINDENT .sp \fBllapi_hsm_copytool_recv\fP returns 0 when a message is available. If -the copytool was set to non\-blocking operation, \-EWOULDBLOCK is +the copytool was set to non\-blocking operation, \-EAGAIN is immediately returned if no message is available. On error, a negative errno is returned. .SH ERRORS @@ -139,7 +139,7 @@ registered, ... .sp \fB\-EPROTO\fP Lustre protocol error. .sp -\fB\-EWOULDBLOCK\fP No HSM message is available, and the copytool was set +\fB\-EAGAIN\fP No HSM message is available, and the copytool was set to not block on receives. .SH SEE ALSO .sp diff --git a/lustre/fld/fld_request.c b/lustre/fld/fld_request.c index 7853428..cf79176 100644 --- a/lustre/fld/fld_request.c +++ b/lustre/fld/fld_request.c @@ -385,7 +385,7 @@ int fld_client_rpc(struct obd_export *exp, if (OBD_FAIL_CHECK(OBD_FAIL_FLD_QUERY_REQ && req->rq_no_delay)) { /* the same error returned by ptlrpc_import_delay_req */ - rc = -EWOULDBLOCK; + rc = -EAGAIN; req->rq_status = rc; } else { obd_get_request_slot(&exp->exp_obd->u.cli); diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index c5acbf9..486e695 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -1628,11 +1628,11 @@ struct cl_io_operations { * \ingroup cl_lock */ enum cl_enq_flags { - /** - * instruct server to not block, if conflicting lock is found. Instead - * -EWOULDBLOCK is returned immediately. - */ - CEF_NONBLOCK = 0x00000001, + /** + * instruct server to not block, if conflicting lock is found. Instead + * -EAGAIN is returned immediately. + */ + CEF_NONBLOCK = 0x00000001, /** * Tell lower layers this is a glimpse request, translated to * LDLM_FL_HAS_INTENT at LDLM layer. diff --git a/lustre/ldlm/ldlm_extent.c b/lustre/ldlm/ldlm_extent.c index 56a8c73..d557f49 100644 --- a/lustre/ldlm/ldlm_extent.c +++ b/lustre/ldlm/ldlm_extent.c @@ -380,7 +380,7 @@ static enum interval_iter ldlm_extent_compat_cb(struct interval_node *n, * \retval 1 if the lock is compatible * \retval 2 if \a req is a group lock and it is compatible and requires * no further checking - * \retval negative error, such as EWOULDBLOCK for group locks + * \retval negative error, such as EAGAIN for group locks */ static int ldlm_extent_compat_queue(struct list_head *queue, struct ldlm_lock *req, @@ -434,7 +434,7 @@ ldlm_extent_compat_queue(struct list_head *queue, struct ldlm_lock *req, if (tree->lit_mode == LCK_GROUP) { if (*flags & (LDLM_FL_BLOCK_NOWAIT | LDLM_FL_SPECULATIVE)) { - compat = -EWOULDBLOCK; + compat = -EAGAIN; goto destroylock; } @@ -463,7 +463,7 @@ ldlm_extent_compat_queue(struct list_head *queue, struct ldlm_lock *req, if (!work_list) { RETURN(0); } else { - compat = -EWOULDBLOCK; + compat = -EAGAIN; goto destroylock; } } @@ -537,7 +537,7 @@ ldlm_extent_compat_queue(struct list_head *queue, struct ldlm_lock *req, * immediately */ if (*flags & (LDLM_FL_BLOCK_NOWAIT | LDLM_FL_SPECULATIVE)) { - compat = -EWOULDBLOCK; + compat = -EAGAIN; goto destroylock; } /* If this group lock is compatible with another @@ -577,7 +577,7 @@ ldlm_extent_compat_queue(struct list_head *queue, struct ldlm_lock *req, * range does not matter */ if (*flags & (LDLM_FL_BLOCK_NOWAIT | LDLM_FL_SPECULATIVE)) { - compat = -EWOULDBLOCK; + compat = -EAGAIN; goto destroylock; } } else if (lock->l_policy_data.l_extent.end < req_start || @@ -594,7 +594,7 @@ ldlm_extent_compat_queue(struct list_head *queue, struct ldlm_lock *req, RETURN(0); if (*flags & LDLM_FL_SPECULATIVE) { - compat = -EWOULDBLOCK; + compat = -EAGAIN; goto destroylock; } @@ -760,9 +760,9 @@ int ldlm_process_extent_lock(struct ldlm_lock *lock, __u64 *flags, *err = ELDLM_OK; if (intention == LDLM_PROCESS_RESCAN) { - /* Careful observers will note that we don't handle -EWOULDBLOCK + /* Careful observers will note that we don't handle -EAGAIN * here, but it's ok for a non-obvious reason -- compat_queue - * can only return -EWOULDBLOCK if (flags & BLOCK_NOWAIT | + * can only return -EAGAIN if (flags & BLOCK_NOWAIT | * SPECULATIVE). flags should always be zero here, and if that * ever stops being true, we want to find out. */ LASSERT(*flags == 0); diff --git a/lustre/llite/glimpse.c b/lustre/llite/glimpse.c index bc09c33..4f98d6d 100644 --- a/lustre/llite/glimpse.c +++ b/lustre/llite/glimpse.c @@ -211,7 +211,7 @@ int cl_glimpse_size0(struct inode *inode, int agl) } else if (result == 0) { result = cl_glimpse_lock(env, io, inode, io->ci_obj, agl); - if (!agl && result == -EWOULDBLOCK) + if (!agl && result == -EAGAIN) io->ci_need_restart = 1; } diff --git a/lustre/llite/vvp_page.c b/lustre/llite/vvp_page.c index fb9c387..0bac264 100644 --- a/lustre/llite/vvp_page.c +++ b/lustre/llite/vvp_page.c @@ -283,7 +283,7 @@ static void vvp_page_completion_read(const struct lu_env *env, cl_page_export(env, page, 1); } else if (vpg->vpg_defer_uptodate) { vpg->vpg_defer_uptodate = 0; - if (ioret == -EWOULDBLOCK) { + if (ioret == -EAGAIN) { /* mirror read failed, it needs to destroy the page * because subpage would be from wrong osc when trying * to read from a new mirror diff --git a/lustre/obdclass/cl_io.c b/lustre/obdclass/cl_io.c index 7d42ff0..425567f 100644 --- a/lustre/obdclass/cl_io.c +++ b/lustre/obdclass/cl_io.c @@ -763,7 +763,7 @@ int cl_io_loop(const struct lu_env *env, struct cl_io *io) if (rc && !result) result = rc; - if (result == -EWOULDBLOCK && io->ci_ndelay) { + if (result == -EAGAIN && io->ci_ndelay) { io->ci_need_restart = 1; result = 0; } diff --git a/lustre/osc/osc_io.c b/lustre/osc/osc_io.c index 9b67d4b..0cdd2ea 100644 --- a/lustre/osc/osc_io.c +++ b/lustre/osc/osc_io.c @@ -407,7 +407,7 @@ int osc_io_iter_init(const struct lu_env *env, const struct cl_io_slice *ios) */ if (ios->cis_io->ci_type == CIT_READ && ios->cis_io->ci_ndelay && !ios->cis_io->ci_tried_all_mirrors && osc_import_not_healthy(imp)) { - rc = -EWOULDBLOCK; + rc = -EAGAIN; } else if (likely(!imp->imp_invalid)) { atomic_inc(&osc->oo_nr_ios); oio->oi_is_active = 1; diff --git a/lustre/osc/osc_lock.c b/lustre/osc/osc_lock.c index 62da056..9e46679 100644 --- a/lustre/osc/osc_lock.c +++ b/lustre/osc/osc_lock.c @@ -309,7 +309,7 @@ static int osc_lock_upcall(void *cookie, struct lustre_handle *lockh, /* Hide the error. */ rc = 0; } else if (rc < 0 && oscl->ols_flags & LDLM_FL_NDELAY) { - rc = -EWOULDBLOCK; + rc = -EAGAIN; } if (oscl->ols_owner != NULL) diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 6dbfcee..030c999 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -2410,7 +2410,7 @@ static int brw_interpret(const struct lu_env *env, list_for_each_entry_safe(ext, tmp, &aa->aa_exts, oe_link) { list_del_init(&ext->oe_link); osc_extent_finish(env, ext, 1, - rc && req->rq_no_delay ? -EWOULDBLOCK : rc); + rc && req->rq_no_delay ? -EAGAIN : rc); } LASSERT(list_empty(&aa->aa_exts)); LASSERT(list_empty(&aa->aa_oaps)); diff --git a/lustre/osp/osp_precreate.c b/lustre/osp/osp_precreate.c index 60ecc66..6a0a435 100644 --- a/lustre/osp/osp_precreate.c +++ b/lustre/osp/osp_precreate.c @@ -1636,12 +1636,12 @@ int osp_object_truncate(const struct lu_env *env, struct dt_object *dt, * XXX: decide how do we do here with resend * if we don't resend, then client may see wrong file size * if we do resend, then MDS thread can get stuck for quite long - * and if we don't resend, then client will also get -EWOULDBLOCK !! + * and if we don't resend, then client will also get -EAGAIN !! * (see LU-7975 and sanity/test_27F use cases) * but let's decide not to resend/delay this truncate request to OST * and allow Client to decide to resend, in a less agressive way from * after_reply(), by returning -EINPROGRESS instead of - * -EAGAIN/-EWOULDBLOCK upon return from ptlrpc_queue_wait() at the + * -EAGAIN/-EAGAIN upon return from ptlrpc_queue_wait() at the * end of this routine */ req->rq_no_resend = req->rq_no_delay = 1; @@ -1671,14 +1671,14 @@ int osp_object_truncate(const struct lu_env *env, struct dt_object *dt, rc = ptlrpc_queue_wait(req); if (rc) { - /* -EWOULDBLOCK/-EAGAIN means OST is unreachable at the moment + /* -EAGAIN/-EWOULDBLOCK means OST is unreachable at the moment * since we have decided not to resend/delay, but this could * lead to wrong size to be seen at Client side and even process * trying to open to exit/fail if not itself handling -EAGAIN. * So it should be better to return -EINPROGRESS instead and * leave the decision to resend at Client side in after_reply() */ - if (rc == -EWOULDBLOCK) { + if (rc == -EAGAIN) { rc = -EINPROGRESS; CDEBUG(D_HA, "returning -EINPROGRESS instead of " "-EWOULDBLOCK/-EAGAIN to allow Client to " diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 7ee5324..22c831c 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -1291,7 +1291,7 @@ static int ptlrpc_import_delay_req(struct obd_import *imp, } else if (req->rq_no_delay && imp->imp_generation != imp->imp_initiated_at) { /* ignore nodelay for requests initiating connections */ - *status = -EWOULDBLOCK; + *status = -EAGAIN; } else if (req->rq_allow_replay && (imp->imp_state == LUSTRE_IMP_REPLAY || imp->imp_state == LUSTRE_IMP_REPLAY_LOCKS || diff --git a/lustre/ptlrpc/errno.c b/lustre/ptlrpc/errno.c index a3d31a8..987803b 100644 --- a/lustre/ptlrpc/errno.c +++ b/lustre/ptlrpc/errno.c @@ -35,8 +35,8 @@ * The two translation tables below must define a one-to-one mapping between * host and network errnos. * - * EWOULDBLOCK is equal to EAGAIN on all architectures except for parisc, which - * appears irrelevant. Thus, existing references to EWOULDBLOCK are fine. + * EAGAIN is equal to EAGAIN on all architectures except for parisc, which + * appears irrelevant. Thus, existing references to EAGAIN are fine. * * EDEADLOCK is equal to EDEADLK on x86 but not on sparc, at least. A sparc * host has no context-free way to determine if a LUSTRE_EDEADLK represents an diff --git a/lustre/ptlrpc/sec.c b/lustre/ptlrpc/sec.c index dc2f7c8..4203371 100644 --- a/lustre/ptlrpc/sec.c +++ b/lustre/ptlrpc/sec.c @@ -790,7 +790,7 @@ again: spin_unlock(&ctx->cc_lock); if (timeout == 0) - RETURN(-EWOULDBLOCK); + RETURN(-EAGAIN); /* Clear any flags that may be present from previous sends */ LASSERT(req->rq_receiving_reply == 0); diff --git a/lustre/tests/llapi_hsm_test.c b/lustre/tests/llapi_hsm_test.c index 01a701c..32998af 100644 --- a/lustre/tests/llapi_hsm_test.c +++ b/lustre/tests/llapi_hsm_test.c @@ -201,7 +201,7 @@ int test5(void) /* Hopefully there is nothing lingering */ for (i = 0; i < 1000; i++) { rc = llapi_hsm_copytool_recv(ctdata, &hal, &msgsize); - ASSERTF(rc == -EWOULDBLOCK, "llapi_hsm_copytool_recv error: %s", + ASSERTF(rc == -EAGAIN, "llapi_hsm_copytool_recv error: %s", strerror(-rc)); } @@ -272,7 +272,7 @@ int test7(void) rc, strerror(errno)); rc = llapi_hsm_copytool_recv(ctdata, &hal, &msgsize); - ASSERTF(rc == -EWOULDBLOCK, "llapi_hsm_copytool_recv error: %s", + ASSERTF(rc == -EAGAIN, "llapi_hsm_copytool_recv error: %s", strerror(-rc)); fds[0].fd = fd; diff --git a/lustre/tests/mpi/parallel_grouplock.c b/lustre/tests/mpi/parallel_grouplock.c index dfddd4f..1ece6e2 100644 --- a/lustre/tests/mpi/parallel_grouplock.c +++ b/lustre/tests/mpi/parallel_grouplock.c @@ -616,9 +616,9 @@ void grouplock_test4(char *filename, int fd) /* * task0 attempts GR(gid=1) -- granted - * task1 attempts PR on non-blocking fd -> should return -EWOULDBLOCK - * task2 attempts PW on non-blocking fd -> should return -EWOULDBLOCK - * task3 attempts GR(gid=2) on non-blocking fd -> should return -EWOULDBLOCK + * task1 attempts PR on non-blocking fd -> should return -EAGAIN + * task2 attempts PW on non-blocking fd -> should return -EAGAIN + * task3 attempts GR(gid=2) on non-blocking fd -> should return -EAGAIN */ void grouplock_nonblock_test(char *filename, int fd) { @@ -643,14 +643,14 @@ void grouplock_nonblock_test(char *filename, int fd) switch (rank) { case 1: rc = read(fd, buf, sizeof(buf)); - if ((rc != -1) || (errno != EWOULDBLOCK)) + if ((rc != -1) || (errno != EAGAIN)) FAIL("PR lock succeeded while incompatible GROUP LOCK (gid=1) is still held\n"); MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD); break; case 2: rc = write(fd, buf, sizeof(buf)); - if ((rc != -1) || (errno != EWOULDBLOCK)) + if ((rc != -1) || (errno != EAGAIN)) FAIL("PW lock succeeded while incompatible GROUP LOCK (gid=1) is still held\n"); MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD); @@ -658,7 +658,7 @@ void grouplock_nonblock_test(char *filename, int fd) case 3: gid = 2; rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid); - if ((rc != -1) || (errno != EWOULDBLOCK)) + if ((rc != -1) || (errno != EAGAIN)) FAIL("GROUP_LOCK (gid=2) succeeded while incompatible GROUP LOCK (gid=1) is still held.\n"); MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD); -- 1.8.3.1