All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs/locks.c Partially fixes leases issue
@ 2003-12-03 11:48 Joseph D. Wagner
  2003-12-04  2:55 ` Jamie Lokier
  0 siblings, 1 reply; 5+ messages in thread
From: Joseph D. Wagner @ 2003-12-03 11:48 UTC (permalink / raw)
  To: matthew, willy; +Cc: linux-fsdevel

I apologize for being rude earlier.  It's just so frustrating to a newbie 
programmer -- or perhaps phrased better -- a programmer new to Linux kernel 
programming.

I hope my temper does not keep you from including a valid, useful patch in 
the Linux kernel.  This patch can be applied to both the 2.4.x and 2.6.x 
series.

Everything you need to know about the patch is documented in the patch 
itself.  I hope you find it useful, and I hope that my poor first 
impression will not prevent us from working together on filesystem 
development in the future.

Sincerely and apologetically,

Joseph D. Wagner

--- /old/src/linux-2.4.22/fs/locks.c    2003-08-25 17:44:43.000000000 +0600
+++ /new/src/linux-2.4.22/fs/locks.c    2003-11-28 00:05:11.000000000 +0600
@@ -111,10 +111,17 @@
  *  Matthew Wilcox <willy@thepuffingroup.com>, March, 2000.
  *
  *  Leases and LOCK_MAND
  *  Matthew Wilcox <willy@linuxcare.com>, June, 2000.
  *  Stephen Rothwell <sfr@canb.auug.org.au>, June, 2000.
+ *
+ *  PARTIALLY FIXED Leases Issue -- Function fcntl_setlease would only
+ *  check if a file had been opened before granting a F_WRLCK, a.k.a. a
+ *  write lease.  It would not check if the file had be opened for
+ *  writing before granting a F_RDLCK, a.k.a. a read lease.  This issue
+ *  has been partially resolved.  See FIXME below.
+ *  Joseph D. Wagner <wagnerjd@users.sourceforge.net> November 2003
  */

 #include <linux/slab.h>
 #include <linux/file.h>
 #include <linux/smp_lock.h>
@@ -1287,14 +1294,33 @@

        lock_kernel();

        time_out_leases(inode);
 
-       /*
-        * FIXME: What about F_RDLCK and files open for writing?
-        */
        error = -EAGAIN;
+       if ((arg == F_RDLCK)
+           && ((atomic_read(&dentry->d_count) > 1)
+               || (atomic_read(&inode->i_count) > 1))) {
+
+               /*
+                * FIXME: Theoretically, what would happen next
+                * is a loop which checks each open file to see
+                * if the file is open for writing (i.e. O_WRONLY,
+                * O_RDWR, O_CREAT, or O_TRUNC).  However, since
+                * that would require major overhauls in other
+                * files, it is simply assumed that if a file is
+                * open that the file is open for writing.  In
+                * effect, this creates an exclusive read lease
+                * such that only one process can obtain a read
+                * lease at any given time.  Theoretically, a file
+                * should be able to have a virtually limitless
+                * number of read leases provided that no process
+                * has the file open for writing.
+                */
+
+               goto out_unlock;
+       }
        if ((arg == F_WRLCK)
            && ((atomic_read(&dentry->d_count) > 1)
                || (atomic_read(&inode->i_count) > 1)))
                goto out_unlock;



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

end of thread, other threads:[~2003-12-04 13:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-03 11:48 [PATCH] fs/locks.c Partially fixes leases issue Joseph D. Wagner
2003-12-04  2:55 ` Jamie Lokier
2003-12-03 15:49   ` Joseph D. Wagner
2003-12-04  5:15     ` Jamie Lokier
2003-12-04 13:31     ` Matthew Wilcox

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.