mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [2.4.13] [devfs 0.119 (20011009)] base.c: devfsd_ioctl
@ 2001-10-28 12:03 Kari Hurtta
  2001-10-29  5:22 ` Richard Gooch
  0 siblings, 1 reply; 2+ messages in thread
From: Kari Hurtta @ 2001-10-28 12:03 UTC (permalink / raw)
  To: rgooch; +Cc: linux-kernel


Can you say where I have wrong?

Code on devfsd_ioctl() [base.c]:

        if (fs_info->devfsd_task == NULL)
        {
            if ( !spin_trylock (&lock) ) return -EBUSY;
            fs_info->devfsd_task = current;
            spin_unlock (&lock);

To me that spinlock looks like it is useless.
Either

	1) If it is mean that lock protects two CPUs settting
            fs_info->devfsd_task when another is set it,
	    then test about fs_info->devfsd_task == NULL
	    should be inside of locked code
or     2) this is protected with some other lock as comment
          perhaps indicates:

        /*  Ensure only one reader has access to the queue. This scheme will
            work even if the global kernel lock were to be removed, because it
            doesn't matter who gets in first, as long as only one gets it
        */
        if (fs_info->devfsd_task == NULL)
        {
            if ( !spin_trylock (&lock) ) return -EBUSY;

Should this be:

--- fs/devfs/base.c.old	Thu Oct 11 09:23:24 2001
+++ fs/devfs/base.c	Sun Oct 28 14:59:03 2001
@@ -3227,6 +3227,11 @@
 	if (fs_info->devfsd_task == NULL)
 	{
 	    if ( !spin_trylock (&lock) ) return -EBUSY;
+	    if (fs_info->devfsd_task != NULL) {
+	         /* We lost race ... */
+	         spin_unlock (&lock);
+		 return -EBUSY;
+	    }
 	    fs_info->devfsd_task = current;
 	    spin_unlock (&lock);
 	    fs_info->devfsd_file = file;


-- 
          /"\                           |  Kari 
          \ /     ASCII Ribbon Campaign |    Hurtta
           X      Against HTML Mail     |
          / \                           |

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

end of thread, other threads:[~2001-10-29  5:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-28 12:03 [2.4.13] [devfs 0.119 (20011009)] base.c: devfsd_ioctl Kari Hurtta
2001-10-29  5:22 ` Richard Gooch

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

all inboxes | Powered by JetHome®