Linux NFS development
 help / color / mirror / Atom feed
* [PATCH] gssd:  unblock DNOTIFY_SIGNAL in case it was blocked.
@ 2008-11-10 22:29 Neil Brown
       [not found] ` <18712.46537.9006.490726-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Neil Brown @ 2008-11-10 22:29 UTC (permalink / raw)
  To: kwc, linux-nfs


I have a situation where rpc.gssd appears to not be working.
Mount attempts which need to communicate with it block.

I've narrowed down the problem to that fact that all realtime signals
have been blocked.  This means that DNOTIFY_SIGNAL (which is a
realtime signal) is never delivered, so gssd never rescans the
rpc_pipe/nfs directory.

I haven't figured out why the signals are blocked yet, but having
rpc.gssd fail mysteriously in that situation isn't pleasant.

So I wonder what people think of the following patch.  It simply
unblocks the signal.  Alternately we can check if it is blocked and
warn - I'm not really sure of the significance of blocking all these
signals.  Maybe it's wrong to just unblock them.


As an aside, maybe we could change gssd_run to use "ppoll" rather than
"poll".  Then it would not have to wake up every 500msec to see if it
missed a signal. We would probably have to check kernel version was at
least 2.6.16....

NeilBrown



diff --git a/utils/gssd/gssd_main_loop.c b/utils/gssd/gssd_main_loop.c
index 84f04e9..b9f3a06 100644
--- a/utils/gssd/gssd_main_loop.c
+++ b/utils/gssd/gssd_main_loop.c
@@ -99,6 +99,7 @@ gssd_run()
 	int			ret;
 	struct sigaction	dn_act;
 	int			fd;
+	sigset_t		set;
 
 	/* Taken from linux/Documentation/dnotify.txt: */
 	dn_act.sa_sigaction = dir_notify_handler;
@@ -106,6 +107,11 @@ gssd_run()
 	dn_act.sa_flags = SA_SIGINFO;
 	sigaction(DNOTIFY_SIGNAL, &dn_act, NULL);
 
+	/* just in case the signal is blocked... */
+	sigemptyset(&set);
+	sigaddset(&set, DNOTIFY_SIGNAL);
+	sigprocmask(SIG_UNBLOCK, &set, NULL);
+
 	if ((fd = open(pipefs_nfsdir, O_RDONLY)) == -1) {
 		printerr(0, "ERROR: failed to open %s: %s\n",
 			 pipefs_nfsdir, strerror(errno));

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] gssd: unblock DNOTIFY_SIGNAL in case it was blocked.
       [not found] ` <18712.46537.9006.490726-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
@ 2008-11-11  4:13   ` Kevin Coffman
  2008-11-11 19:09   ` J. Bruce Fields
  2008-12-01 19:29   ` Steve Dickson
  2 siblings, 0 replies; 7+ messages in thread
From: Kevin Coffman @ 2008-11-11  4:13 UTC (permalink / raw)
  To: Neil Brown; +Cc: linux-nfs

Hi Neil,
I inherited the signal stuff, so my understanding probably isn't any
better than yours.  I won't be able to look closer at this until
Wednesday.  Meanwhile, maybe someone else has a better understanding.

K.C.

On Mon, Nov 10, 2008 at 5:29 PM, Neil Brown <neilb@suse.de> wrote:
>
> I have a situation where rpc.gssd appears to not be working.
> Mount attempts which need to communicate with it block.
>
> I've narrowed down the problem to that fact that all realtime signals
> have been blocked.  This means that DNOTIFY_SIGNAL (which is a
> realtime signal) is never delivered, so gssd never rescans the
> rpc_pipe/nfs directory.
>
> I haven't figured out why the signals are blocked yet, but having
> rpc.gssd fail mysteriously in that situation isn't pleasant.
>
> So I wonder what people think of the following patch.  It simply
> unblocks the signal.  Alternately we can check if it is blocked and
> warn - I'm not really sure of the significance of blocking all these
> signals.  Maybe it's wrong to just unblock them.
>
>
> As an aside, maybe we could change gssd_run to use "ppoll" rather than
> "poll".  Then it would not have to wake up every 500msec to see if it
> missed a signal. We would probably have to check kernel version was at
> least 2.6.16....
>
> NeilBrown
>
>
>
> diff --git a/utils/gssd/gssd_main_loop.c b/utils/gssd/gssd_main_loop.c
> index 84f04e9..b9f3a06 100644
> --- a/utils/gssd/gssd_main_loop.c
> +++ b/utils/gssd/gssd_main_loop.c
> @@ -99,6 +99,7 @@ gssd_run()
>        int                     ret;
>        struct sigaction        dn_act;
>        int                     fd;
> +       sigset_t                set;
>
>        /* Taken from linux/Documentation/dnotify.txt: */
>        dn_act.sa_sigaction = dir_notify_handler;
> @@ -106,6 +107,11 @@ gssd_run()
>        dn_act.sa_flags = SA_SIGINFO;
>        sigaction(DNOTIFY_SIGNAL, &dn_act, NULL);
>
> +       /* just in case the signal is blocked... */
> +       sigemptyset(&set);
> +       sigaddset(&set, DNOTIFY_SIGNAL);
> +       sigprocmask(SIG_UNBLOCK, &set, NULL);
> +
>        if ((fd = open(pipefs_nfsdir, O_RDONLY)) == -1) {
>                printerr(0, "ERROR: failed to open %s: %s\n",
>                         pipefs_nfsdir, strerror(errno));
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] gssd:  unblock DNOTIFY_SIGNAL in case it was blocked.
       [not found] ` <18712.46537.9006.490726-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
  2008-11-11  4:13   ` Kevin Coffman
@ 2008-11-11 19:09   ` J. Bruce Fields
  2008-11-11 22:20     ` NeilBrown
  2008-12-01 19:29   ` Steve Dickson
  2 siblings, 1 reply; 7+ messages in thread
From: J. Bruce Fields @ 2008-11-11 19:09 UTC (permalink / raw)
  To: Neil Brown; +Cc: kwc, linux-nfs

On Tue, Nov 11, 2008 at 09:29:29AM +1100, Neil Brown wrote:
> 
> I have a situation where rpc.gssd appears to not be working.
> Mount attempts which need to communicate with it block.
> 
> I've narrowed down the problem to that fact that all realtime signals
> have been blocked.  This means that DNOTIFY_SIGNAL (which is a
> realtime signal) is never delivered, so gssd never rescans the
> rpc_pipe/nfs directory.
> 
> I haven't figured out why the signals are blocked yet, but having
> rpc.gssd fail mysteriously in that situation isn't pleasant.
> 
> So I wonder what people think of the following patch.  It simply
> unblocks the signal.  Alternately we can check if it is blocked and
> warn - I'm not really sure of the significance of blocking all these
> signals.  Maybe it's wrong to just unblock them.

So we don't know what it is that's doing the blocking?

> As an aside, maybe we could change gssd_run to use "ppoll" rather than
> "poll".  Then it would not have to wake up every 500msec to see if it
> missed a signal. We would probably have to check kernel version was at
> least 2.6.16....

Yes. (What does glibc itself do in the ppoll library call if the kernel
doesn't support it?)

--b.

> diff --git a/utils/gssd/gssd_main_loop.c b/utils/gssd/gssd_main_loop.c
> index 84f04e9..b9f3a06 100644
> --- a/utils/gssd/gssd_main_loop.c
> +++ b/utils/gssd/gssd_main_loop.c
> @@ -99,6 +99,7 @@ gssd_run()
>  	int			ret;
>  	struct sigaction	dn_act;
>  	int			fd;
> +	sigset_t		set;
>  
>  	/* Taken from linux/Documentation/dnotify.txt: */
>  	dn_act.sa_sigaction = dir_notify_handler;
> @@ -106,6 +107,11 @@ gssd_run()
>  	dn_act.sa_flags = SA_SIGINFO;
>  	sigaction(DNOTIFY_SIGNAL, &dn_act, NULL);
>  
> +	/* just in case the signal is blocked... */
> +	sigemptyset(&set);
> +	sigaddset(&set, DNOTIFY_SIGNAL);
> +	sigprocmask(SIG_UNBLOCK, &set, NULL);
> +
>  	if ((fd = open(pipefs_nfsdir, O_RDONLY)) == -1) {
>  		printerr(0, "ERROR: failed to open %s: %s\n",
>  			 pipefs_nfsdir, strerror(errno));
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] gssd:  unblock DNOTIFY_SIGNAL in case it was blocked.
  2008-11-11 19:09   ` J. Bruce Fields
@ 2008-11-11 22:20     ` NeilBrown
       [not found]       ` <ced7f54f33cb02088b6d9c10603c047e.squirrel-eq65iwfR9nKIECXXMXunQA@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: NeilBrown @ 2008-11-11 22:20 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: kwc, linux-nfs

On Wed, November 12, 2008 6:09 am, J. Bruce Fields wrote:
> On Tue, Nov 11, 2008 at 09:29:29AM +1100, Neil Brown wrote:
>>
>> I have a situation where rpc.gssd appears to not be working.
>> Mount attempts which need to communicate with it block.
>>
>> I've narrowed down the problem to that fact that all realtime signals
>> have been blocked.  This means that DNOTIFY_SIGNAL (which is a
>> realtime signal) is never delivered, so gssd never rescans the
>> rpc_pipe/nfs directory.
>>
>> I haven't figured out why the signals are blocked yet, but having
>> rpc.gssd fail mysteriously in that situation isn't pleasant.
>>
>> So I wonder what people think of the following patch.  It simply
>> unblocks the signal.  Alternately we can check if it is blocked and
>> warn - I'm not really sure of the significance of blocking all these
>> signals.  Maybe it's wrong to just unblock them.
>
> So we don't know what it is that's doing the blocking?

That information has just come to hand.  It seems to be kde.
start_kde (or whatever it is called) and all descendants have these
signals blocked.  xfce seems to do the same thing.  gnome doesn't.

So if you start rpc.gssd from a terminal window while logged in via
KDE, it doesn't behave as expected.

>
>> As an aside, maybe we could change gssd_run to use "ppoll" rather than
>> "poll".  Then it would not have to wake up every 500msec to see if it
>> missed a signal. We would probably have to check kernel version was at
>> least 2.6.16....
>
> Yes. (What does glibc itself do in the ppoll library call if the kernel
> doesn't support it?)

Probably tries to fake it and ends up with a racy implementation.  That
is what it does with pselect.

An alternate would be to not use signals at all (generally a very good
idea) by use inotify instead of dnotify.  But that hasn't always worked
either.

Here is a question:  On which kernel did GSS support first become a really
usable option?  If that is sufficiently recent that it includes either
ppoll or inotify-on-rpc_pipe, then we could just use the modern technology
and tell people that rpc.gssd isn't supported on older kernels because
it doesn't really work anyway.  Would that get us anywhere?

Another alternate.  rpc.gssd currently wakes up every 500msec to check
a global variable that might have been set by a signal arriving.
There would be little extra cost if doing a 'stat' of the rpc_pipe/nfs
directory to see if it had changed (is the timestamp updated when a
change happens?).  This would just be one quick syscall.  Then we could
be much less dependent on correct delivery of the signal.  We could even
not use dnotify at all.


NeilBrown


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] gssd:  unblock DNOTIFY_SIGNAL in case it was blocked.
       [not found]       ` <ced7f54f33cb02088b6d9c10603c047e.squirrel-eq65iwfR9nKIECXXMXunQA@public.gmane.org>
@ 2008-11-13  4:37         ` J. Bruce Fields
  2008-11-25 15:00           ` Steve Dickson
  0 siblings, 1 reply; 7+ messages in thread
From: J. Bruce Fields @ 2008-11-13  4:37 UTC (permalink / raw)
  To: NeilBrown; +Cc: kwc, linux-nfs

On Wed, Nov 12, 2008 at 09:20:20AM +1100, NeilBrown wrote:
> On Wed, November 12, 2008 6:09 am, J. Bruce Fields wrote:
> > On Tue, Nov 11, 2008 at 09:29:29AM +1100, Neil Brown wrote:
> >>
> >> I have a situation where rpc.gssd appears to not be working.
> >> Mount attempts which need to communicate with it block.
> >>
> >> I've narrowed down the problem to that fact that all realtime signals
> >> have been blocked.  This means that DNOTIFY_SIGNAL (which is a
> >> realtime signal) is never delivered, so gssd never rescans the
> >> rpc_pipe/nfs directory.
> >>
> >> I haven't figured out why the signals are blocked yet, but having
> >> rpc.gssd fail mysteriously in that situation isn't pleasant.
> >>
> >> So I wonder what people think of the following patch.  It simply
> >> unblocks the signal.  Alternately we can check if it is blocked and
> >> warn - I'm not really sure of the significance of blocking all these
> >> signals.  Maybe it's wrong to just unblock them.
> >
> > So we don't know what it is that's doing the blocking?
> 
> That information has just come to hand.  It seems to be kde.
> start_kde (or whatever it is called) and all descendants have these
> signals blocked.  xfce seems to do the same thing.  gnome doesn't.
> 
> So if you start rpc.gssd from a terminal window while logged in via
> KDE, it doesn't behave as expected.

Whoops.  I guess I (stupidly?) didn't realize signal masks where
inherited across fork.  So we just need to clear the signal mask at the
very start and we're done?

> >> As an aside, maybe we could change gssd_run to use "ppoll" rather than
> >> "poll".  Then it would not have to wake up every 500msec to see if it
> >> missed a signal. We would probably have to check kernel version was at
> >> least 2.6.16....
> >
> > Yes. (What does glibc itself do in the ppoll library call if the kernel
> > doesn't support it?)
> 
> Probably tries to fake it and ends up with a racy implementation.  That
> is what it does with pselect.
> 
> An alternate would be to not use signals at all (generally a very good
> idea) by use inotify instead of dnotify.  But that hasn't always worked
> either.
> 
> Here is a question:  On which kernel did GSS support first become a really
> usable option?  If that is sufficiently recent that it includes either
> ppoll or inotify-on-rpc_pipe, then we could just use the modern technology
> and tell people that rpc.gssd isn't supported on older kernels because
> it doesn't really work anyway.  Would that get us anywhere?

It looks to me like gss has been usable to some degree since the
beginning of git history (2.6.12-rc2), while the ppoll man page says it
was added in 2.6.16.

> Another alternate.  rpc.gssd currently wakes up every 500msec to check
> a global variable that might have been set by a signal arriving.
> There would be little extra cost if doing a 'stat' of the rpc_pipe/nfs
> directory to see if it had changed (is the timestamp updated when a
> change happens?).  This would just be one quick syscall.  Then we could
> be much less dependent on correct delivery of the signal.  We could even
> not use dnotify at all.

I'd rather just get rid of the 500msec wakeup (if nothing else it's
annoying when you're trying to debug with strace!).  So a wrapper around
ppoll that falls back on polling with poll might be the way to go.

--b.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] gssd:  unblock DNOTIFY_SIGNAL in case it was blocked.
  2008-11-13  4:37         ` J. Bruce Fields
@ 2008-11-25 15:00           ` Steve Dickson
  0 siblings, 0 replies; 7+ messages in thread
From: Steve Dickson @ 2008-11-25 15:00 UTC (permalink / raw)
  To: NeilBrown; +Cc: J. Bruce Fields, kwc, linux-nfs

J. Bruce Fields wrote:
> On Wed, Nov 12, 2008 at 09:20:20AM +1100, NeilBrown wrote:
>> On Wed, November 12, 2008 6:09 am, J. Bruce Fields wrote:
>>> On Tue, Nov 11, 2008 at 09:29:29AM +1100, Neil Brown wrote:
>>>> I have a situation where rpc.gssd appears to not be working.
>>>> Mount attempts which need to communicate with it block.
>>>>
>>>> I've narrowed down the problem to that fact that all realtime signals
>>>> have been blocked.  This means that DNOTIFY_SIGNAL (which is a
>>>> realtime signal) is never delivered, so gssd never rescans the
>>>> rpc_pipe/nfs directory.
>>>>
>>>> I haven't figured out why the signals are blocked yet, but having
>>>> rpc.gssd fail mysteriously in that situation isn't pleasant.
>>>>
>>>> So I wonder what people think of the following patch.  It simply
>>>> unblocks the signal.  Alternately we can check if it is blocked and
>>>> warn - I'm not really sure of the significance of blocking all these
>>>> signals.  Maybe it's wrong to just unblock them.
>>> So we don't know what it is that's doing the blocking?
>> That information has just come to hand.  It seems to be kde.
>> start_kde (or whatever it is called) and all descendants have these
>> signals blocked.  xfce seems to do the same thing.  gnome doesn't.
>>
>> So if you start rpc.gssd from a terminal window while logged in via
>> KDE, it doesn't behave as expected.
> 
> Whoops.  I guess I (stupidly?) didn't realize signal masks where
> inherited across fork.  So we just need to clear the signal mask at the
> very start and we're done?
Neil? Will this work as well? 

This approach seems a bit more straightforward to me... 

steved.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] gssd:  unblock DNOTIFY_SIGNAL in case it was blocked.
       [not found] ` <18712.46537.9006.490726-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
  2008-11-11  4:13   ` Kevin Coffman
  2008-11-11 19:09   ` J. Bruce Fields
@ 2008-12-01 19:29   ` Steve Dickson
  2 siblings, 0 replies; 7+ messages in thread
From: Steve Dickson @ 2008-12-01 19:29 UTC (permalink / raw)
  To: Neil Brown; +Cc: kwc, linux-nfs



Neil Brown wrote:
> I have a situation where rpc.gssd appears to not be working.
> Mount attempts which need to communicate with it block.
> 
> I've narrowed down the problem to that fact that all realtime signals
> have been blocked.  This means that DNOTIFY_SIGNAL (which is a
> realtime signal) is never delivered, so gssd never rescans the
> rpc_pipe/nfs directory.
> 
> I haven't figured out why the signals are blocked yet, but having
> rpc.gssd fail mysteriously in that situation isn't pleasant.
> 
> So I wonder what people think of the following patch.  It simply
> unblocks the signal.  Alternately we can check if it is blocked and
> warn - I'm not really sure of the significance of blocking all these
> signals.  Maybe it's wrong to just unblock them.
> 
> 
> As an aside, maybe we could change gssd_run to use "ppoll" rather than
> "poll".  Then it would not have to wake up every 500msec to see if it
> missed a signal. We would probably have to check kernel version was at
> least 2.6.16....
> 
Committed...

steved.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-12-01 19:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-10 22:29 [PATCH] gssd: unblock DNOTIFY_SIGNAL in case it was blocked Neil Brown
     [not found] ` <18712.46537.9006.490726-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2008-11-11  4:13   ` Kevin Coffman
2008-11-11 19:09   ` J. Bruce Fields
2008-11-11 22:20     ` NeilBrown
     [not found]       ` <ced7f54f33cb02088b6d9c10603c047e.squirrel-eq65iwfR9nKIECXXMXunQA@public.gmane.org>
2008-11-13  4:37         ` J. Bruce Fields
2008-11-25 15:00           ` Steve Dickson
2008-12-01 19:29   ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox