From 925e11c2d8c277d3e39b17fd53b06ea33ec7a560 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Fri, 16 Sep 2022 18:02:51 +0200 Subject: [PATCH] LU-16165 sec: retry mechanism for identity cache Implement a retry mechanism in the identity cache in case the identity up call times out. Lustre-change: https://review.whamcloud.com/48579 Lustre-commit: 61c3b3a9bb848e256845462ffd79b15565cd23ad Signed-off-by: Sebastien Buisson Change-Id: Ib70d3b851a6da3cf66dfed49b03be51da7886d01 Reviewed-by: Andreas Dilger Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49747 Tested-by: jenkins Tested-by: Maloo --- lustre/obdclass/upcall_cache.c | 7 +++++++ lustre/utils/l_getidentity.c | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lustre/obdclass/upcall_cache.c b/lustre/obdclass/upcall_cache.c index b1a4210..911a5ea 100644 --- a/lustre/obdclass/upcall_cache.c +++ b/lustre/obdclass/upcall_cache.c @@ -193,6 +193,7 @@ struct upcall_cache_entry *upcall_cache_get_entry(struct upcall_cache *cache, struct upcall_cache_entry *entry = NULL, *new = NULL, *next; struct lu_ucred *uc = (struct lu_ucred *)args; gid_t *grouplist = NULL, *glist_p; + bool failedacquiring = false; struct list_head *head; wait_queue_entry_t wait; int rc, found, i, ngroups = 0; @@ -348,6 +349,12 @@ find_again: CERROR("acquire for key %llu: error %d\n", entry->ue_key, rc); put_entry(cache, entry); + if (!failedacquiring) { + spin_unlock(&cache->uc_lock); + failedacquiring = true; + new = NULL; + goto find_again; + } GOTO(out, entry = ERR_PTR(rc)); } } diff --git a/lustre/utils/l_getidentity.c b/lustre/utils/l_getidentity.c index df80258..5d572b8 100644 --- a/lustre/utils/l_getidentity.c +++ b/lustre/utils/l_getidentity.c @@ -409,6 +409,7 @@ int main(int argc, char **argv) glob_t path; unsigned long uid; int fd, rc = -EINVAL, size, maxgroups; + bool alreadyfailed = false; progname = basename(argv[0]); if (argc != 3) { @@ -430,10 +431,15 @@ int main(int argc, char **argv) goto out; } +retry: size = offsetof(struct identity_downcall_data, idd_groups[maxgroups]); data = malloc(size); if (!data) { errlog("malloc identity downcall data(%d) failed!\n", size); + if (!alreadyfailed) { + alreadyfailed = true; + goto retry; + } rc = -ENOMEM; goto out; } @@ -476,6 +482,13 @@ downcall: close(fd); if (rc != size) { errlog("partial write ret %d: %s\n", rc, strerror(errno)); + if (!alreadyfailed) { + alreadyfailed = true; + cfs_free_param_data(&path); + if (data) + free(data); + goto retry; + } rc = -1; } else { rc = 0; -- 1.8.3.1