From patchwork Wed Sep 23 21:20:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 7252621 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B6F5BBEEC1 for ; Wed, 23 Sep 2015 21:20:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DE5B420681 for ; Wed, 23 Sep 2015 21:20:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E3DB22061E for ; Wed, 23 Sep 2015 21:20:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755738AbbIWVUx (ORCPT ); Wed, 23 Sep 2015 17:20:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53030 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755726AbbIWVUx (ORCPT ); Wed, 23 Sep 2015 17:20:53 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 514482F5187; Wed, 23 Sep 2015 21:20:53 +0000 (UTC) Received: from smallhat.boston.devel.redhat.com (vpn-55-253.rdu2.redhat.com [10.10.55.253]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8NLKqrE012690; Wed, 23 Sep 2015 17:20:52 -0400 From: Steve Dickson To: Linux NFS Mailing list Cc: Systemd Mailing List Subject: [PATCH] gssd: Improve scalability by not waiting for child processes Date: Wed, 23 Sep 2015 17:20:50 -0400 Message-Id: <1443043250-25703-1-git-send-email-steved@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of waiting on every fork, which would become a bottle neck during a mount storm, simply set a SIGCHLD signal handler to do the wait on the child process Signed-off-by: Steve Dickson Acked-by: Jeff Layton --- utils/gssd/gssd.c | 18 ++++++++++++++++++ utils/gssd/gssd_proc.c | 11 ++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/utils/gssd/gssd.c b/utils/gssd/gssd.c index e480349..8b778cb 100644 --- a/utils/gssd/gssd.c +++ b/utils/gssd/gssd.c @@ -44,11 +44,13 @@ #define _GNU_SOURCE #endif +#include #include #include #include #include #include +#include #include #include #include @@ -736,6 +738,21 @@ sig_die(int signal) printerr(1, "exiting on signal %d\n", signal); exit(0); } +static void +sig_child(int signal) +{ + int err; + pid_t pid; + + /* Parent: just wait on child to exit and return */ + do { + pid = wait(&err); + } while(pid == -1 && errno != -ECHILD); + + if (WIFSIGNALED(err)) + printerr(0, "WARNING: forked child was killed" + "with signal %d\n", WTERMSIG(err)); +} static void usage(char *progname) @@ -902,6 +919,7 @@ main(int argc, char *argv[]) signal(SIGINT, sig_die); signal(SIGTERM, sig_die); + signal(SIGCHLD, sig_child); signal_set(&sighup_ev, SIGHUP, gssd_scan_cb, NULL); signal_add(&sighup_ev, NULL); event_set(&inotify_ev, inotify_fd, EV_READ | EV_PERSIST, gssd_inotify_cb, NULL); diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c index 11168b2..8f5ca03 100644 --- a/utils/gssd/gssd_proc.c +++ b/utils/gssd/gssd_proc.c @@ -656,16 +656,9 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname, /* fork() failed! */ printerr(0, "WARNING: unable to fork() to handle" "upcall: %s\n", strerror(errno)); - return; + /* FALLTHROUGH */ default: - /* Parent: just wait on child to exit and return */ - do { - pid = wait(&err); - } while(pid == -1 && errno != -ECHILD); - - if (WIFSIGNALED(err)) - printerr(0, "WARNING: forked child was killed" - "with signal %d\n", WTERMSIG(err)); + /* Parent: Return and wait for the SIGCHLD */ return; } no_fork: