From 61c3b3a9bb848e256845462ffd79b15565cd23ad 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. Signed-off-by: Sebastien Buisson Change-Id: Ib70d3b851a6da3cf66dfed49b03be51da7886d01 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48579 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- 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 76f13e7..94a150b 100644 --- a/lustre/obdclass/upcall_cache.c +++ b/lustre/obdclass/upcall_cache.c @@ -146,6 +146,7 @@ struct upcall_cache_entry *upcall_cache_get_entry(struct upcall_cache *cache, __u64 key, void *args) { struct upcall_cache_entry *entry = NULL, *new = NULL, *next; + bool failedacquiring = false; struct list_head *head; wait_queue_entry_t wait; int rc, found; @@ -231,6 +232,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 cd4b041..52fd150 100644 --- a/lustre/utils/l_getidentity.c +++ b/lustre/utils/l_getidentity.c @@ -408,6 +408,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) { @@ -429,10 +430,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; } @@ -475,6 +481,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