From: "J. Bruce Fields" <bfields@fieldses.org>
To: Jeff Layton <jlayton@redhat.com>
Cc: linux-nfs@vger.kernel.org, nfsv4@linux-nfs.org
Subject: Re: [PATCH] idmapd: rearm event handler after error in nfsdcb()
Date: Thu, 10 Sep 2009 16:28:25 -0400 [thread overview]
Message-ID: <20090910202825.GL14406@fieldses.org> (raw)
In-Reply-To: <1252611727-19078-1-git-send-email-jlayton@redhat.com>
On Thu, Sep 10, 2009 at 03:42:07PM -0400, Jeff Layton wrote:
> A couple of years ago, Bruce committed a patch to make knfsd send
> unsigned uid's and gid's to idmapd, rather than signed values. Part
> of that earlier discussion is here:
>
> http://linux-nfs.org/pipermail/nfsv4/2007-December/007321.html
>
> While this fixed the immediate problem, it doesn't appear that anything
> was ever done to make idmapd continue working when it gets a bogus
> upcall.
Thanks for following up on this!
>
> idmapd uses libevent for its main event handling loop. When idmapd gets
> an upcall from knfsd it will service the request and then rearm the
> event by calling event_add on the event structure again.
>
> When it hits an error though, it returns in most cases w/o rearming the
> event. That prevents idmapd from servicing any further requests from
> knfsd.
>
> I've made another change too. If an error is encountered while reading
> the channel file, this patch has it close and reopen the file prior to
> rearming the event.
>
> I've not been able to test this patch directly, but I have tested a
> backport of it to earlier idmapd code and verified that it did prevent
> idmapd from hanging when it got a badly formatted upcall from knfsd.
>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
> utils/idmapd/idmapd.c | 18 ++++++++++--------
> 1 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c
> index 65a6a2a..573abaa 100644
> --- a/utils/idmapd/idmapd.c
> +++ b/utils/idmapd/idmapd.c
> @@ -139,6 +139,7 @@ static void nametoidres(struct idmap_msg *);
>
> static int nfsdopen(void);
> static int nfsdopenone(struct idmap_client *);
> +static void nfsdreopen_one(struct idmap_client *);
> static void nfsdreopen(void);
>
> size_t strlcat(char *, const char *, size_t);
> @@ -502,7 +503,8 @@ nfsdcb(int fd, short which, void *data)
> xlog_warn("nfsdcb: read(%s) failed: errno %d (%s)",
> ic->ic_path, len?errno:0,
> len?strerror(errno):"End of File");
> - goto out;
> + nfsdreopen_one(ic);
> + return;
Why the "return"? From your description above ("... close and reopen
the file prior to rearming the event"), I would have thought you'd want
the final event_add() that's done at "out".
--b.
> }
>
> /* Get rid of newline and terminate buffer*/
> @@ -514,11 +516,11 @@ nfsdcb(int fd, short which, void *data)
> /* Authentication name -- ignored for now*/
> if (getfield(&bp, authbuf, sizeof(authbuf)) == -1) {
> xlog_warn("nfsdcb: bad authentication name in upcall\n");
> - return;
> + goto out;
> }
> if (getfield(&bp, typebuf, sizeof(typebuf)) == -1) {
> xlog_warn("nfsdcb: bad type in upcall\n");
> - return;
> + goto out;
> }
> if (verbose > 0)
> xlog_warn("nfsdcb: authbuf=%s authtype=%s",
> @@ -532,26 +534,26 @@ nfsdcb(int fd, short which, void *data)
> im.im_conv = IDMAP_CONV_NAMETOID;
> if (getfield(&bp, im.im_name, sizeof(im.im_name)) == -1) {
> xlog_warn("nfsdcb: bad name in upcall\n");
> - return;
> + goto out;
> }
> break;
> case IC_IDNAME:
> im.im_conv = IDMAP_CONV_IDTONAME;
> if (getfield(&bp, buf1, sizeof(buf1)) == -1) {
> xlog_warn("nfsdcb: bad id in upcall\n");
> - return;
> + goto out;
> }
> tmp = strtoul(buf1, (char **)NULL, 10);
> im.im_id = (u_int32_t)tmp;
> if ((tmp == ULONG_MAX && errno == ERANGE)
> || (unsigned long)im.im_id != tmp) {
> xlog_warn("nfsdcb: id '%s' too big!\n", buf1);
> - return;
> + goto out;
> }
> break;
> default:
> xlog_warn("nfsdcb: Unknown which type %d", ic->ic_which);
> - return;
> + goto out;
> }
>
> imconv(ic, &im);
> @@ -612,7 +614,7 @@ nfsdcb(int fd, short which, void *data)
> break;
> default:
> xlog_warn("nfsdcb: Unknown which type %d", ic->ic_which);
> - return;
> + goto out;
> }
>
> bsiz = sizeof(buf) - bsiz;
> --
> 1.5.5.6
>
> _______________________________________________
> NFSv4 mailing list
> NFSv4@linux-nfs.org
> http://linux-nfs.org/cgi-bin/mailman/listinfo/nfsv4
next prev parent reply other threads:[~2009-09-10 20:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-10 19:42 [PATCH] idmapd: rearm event handler after error in nfsdcb() Jeff Layton
2009-09-10 20:28 ` J. Bruce Fields [this message]
2009-09-10 21:00 ` Jeff Layton
[not found] ` <20090910170024.2853a48e-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2009-09-11 15:39 ` J. Bruce Fields
2009-09-23 10:44 ` a question abount idmapd hongpo gao
[not found] ` <COL101-W29D4B28A8FCF99B81BCAE6A6DB0-MsuGFMq8XAE@public.gmane.org>
2009-09-23 12:47 ` Trond Myklebust
2009-09-14 18:07 ` [PATCH] idmapd: rearm event handler after error in nfsdcb() Steve Dickson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090910202825.GL14406@fieldses.org \
--to=bfields@fieldses.org \
--cc=jlayton@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=nfsv4@linux-nfs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.