[PATCH] ieee1394: char device files are not seekable (BKL removal)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Stefan Richter
Date: Saturday, March 27, 2010 - 2:20 am

The raw1394 character device file ABI is based on
  - write() or ioctl() to initiate actions,
    with write being used exactly like _IOW ioctls,
  - read() to consume events,
  - mmap() for isochronous I/O DMA buffers.

The video1394 character device file ABI is based on
  - ioctl() to initiate actions,
  - mmap() for isochronous I/O DMA buffers.

The dv1394 character device file ABI is based on
  - ioctl() to initiate actions,
  - read() and write() for simple serial reception and transmission of
    DV streams with a copy_to/from_user,
  - mmap() for isochronous I/O DMA buffers for I/O without user copy.

lseek(), pread(), pwrite() on the other hand are not applicable to
/dev/raw1394, /dev/video1394/*, and /dev/dv1394/* device files.

Alas, file_operations.llseek == NULL causes lseek() to call
fs/read_write.c::default_llseek per default.  This looks like not doing
any harm in either of the three drivers, but it grabs the Big Kernel
Lock.  We don't want that, and we should return an error on lseek() and
friends.  This is provided by fs/read_write.c::no_llseek which we get if
we clear the FMODE_LSEEK (and FMODE_PREAD, FMODE_PWRITE) flag by means
of nonseekable_open().

Side note:  Apart from this oversight regarding default_llseek, the
raw1394, video1394, and dv1394 interfaces have been converted away from
BKL usage some time ago.  Although all this is legacy code which should
be left in peace until it is eventually removed (as it is superseded by
firewire-core's <linux/firewire-cdev.h> ABI), this change seems still
worth doing to further minimize the presence of BKL usage in the kernel.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---

Somebody correct me if I misunderstood anything of these ABIs.

This patch is motivated by Arnd's
"bkl removal: make unlocked_ioctl mandatory"
http://git.kernel.org/?p=linux/kernel/git/arnd/playground.git;a=blobdiff;f=drivers/iee...
etc., and
"BKL removal: mark remaining users as 'depends on BKL'"
http://git.kernel.org/?p=linux/kernel/git/arnd/playground.git;a=blobdiff;f=drivers/iee...


 drivers/ieee1394/dv1394.c    |    2 +-
 drivers/ieee1394/raw1394.c   |    2 +-
 drivers/ieee1394/video1394.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Index: b/drivers/ieee1394/dv1394.c
===================================================================
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -1824,7 +1824,7 @@ static int dv1394_open(struct inode *ino
 	       "and will not be available in the new firewire driver stack. "
 	       "Try libraw1394 based programs instead.\n", current->comm);
 
-	return 0;
+	return nonseekable_open(inode, file);
 }
 
 
Index: b/drivers/ieee1394/raw1394.c
===================================================================
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -2834,7 +2834,7 @@ static int raw1394_open(struct inode *in
 
 	file->private_data = fi;
 
-	return 0;
+	return nonseekable_open(inode, file);
 }
 
 static int raw1394_release(struct inode *inode, struct file *file)
Index: b/drivers/ieee1394/video1394.c
===================================================================
--- a/drivers/ieee1394/video1394.c
+++ b/drivers/ieee1394/video1394.c
@@ -1239,7 +1239,7 @@ static int video1394_open(struct inode *
 	ctx->current_ctx = NULL;
 	file->private_data = ctx;
 
-	return 0;
+	return nonseekable_open(inode, file);
 }
 
 static int video1394_release(struct inode *inode, struct file *file)

-- 
Stefan Richter
-=====-==-=- --== ==-==
http://arcgraph.de/sr/

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [GIT, RFC] Killing the Big Kernel Lock, Andrew Morton, (Wed Mar 24, 2:07 pm)
[GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Wed Mar 24, 2:40 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Roland Dreier, (Wed Mar 24, 2:53 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Wed Mar 24, 2:59 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Alan Cox, (Wed Mar 24, 3:10 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Ingo Molnar, (Wed Mar 24, 3:23 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Wed Mar 24, 3:25 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Thu Mar 25, 3:26 am)
Re: [GIT, RFC] Killing the Big Kernel Lock, Jiri Kosina, (Thu Mar 25, 5:55 am)
Re: [GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Thu Mar 25, 6:06 am)
Re: [GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Thu Mar 25, 6:38 am)
Re: [GIT, RFC] Killing the Big Kernel Lock, Dan Carpenter, (Thu Mar 25, 6:40 am)
Re: [GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Thu Mar 25, 7:14 am)
Re: [GIT, RFC] Killing the Big Kernel Lock, Stefan Richter, (Fri Mar 26, 4:47 pm)
[PATCH] ieee1394: char device files are not seekable (BKL ..., Stefan Richter, (Sat Mar 27, 2:20 am)
Re: [GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Sat Mar 27, 7:37 am)
Re: [GIT, RFC] Killing the Big Kernel Lock, Stefan Richter, (Sun Mar 28, 5:27 am)
Re: [GIT, RFC] Killing the Big Kernel Lock, Frederic Weisbecker, (Sun Mar 28, 1:04 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Sun Mar 28, 1:05 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Frederic Weisbecker, (Sun Mar 28, 1:11 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Frederic Weisbecker, (Sun Mar 28, 1:15 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Frederic Weisbecker, (Sun Mar 28, 1:33 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Sun Mar 28, 2:34 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Andi Kleen, (Sun Mar 28, 2:58 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Frederic Weisbecker, (Sun Mar 28, 4:18 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Frederic Weisbecker, (Sun Mar 28, 4:24 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Frederic Weisbecker, (Sun Mar 28, 4:38 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock II, Andi Kleen, (Sun Mar 28, 6:07 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Mon Mar 29, 4:04 am)
Re: [GIT, RFC] Killing the Big Kernel Lock II, Arnd Bergmann, (Mon Mar 29, 4:48 am)
Re: [GIT, RFC] Killing the Big Kernel Lock II, Andi Kleen, (Mon Mar 29, 5:30 am)
Re: [GIT, RFC] Killing the Big Kernel Lock, John Kacur, (Mon Mar 29, 5:45 am)
Re: [GIT, RFC] Killing the Big Kernel Lock II, Arnd Bergmann, (Mon Mar 29, 7:43 am)
Re: [GIT, RFC] Killing the Big Kernel Lock, Frederic Weisbecker, (Mon Mar 29, 10:59 am)
Re: [GIT, RFC] Killing the Big Kernel Lock II, Andi Kleen, (Mon Mar 29, 1:11 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Mon Mar 29, 2:18 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Roland Dreier, (Tue Mar 30, 10:22 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Roland Dreier, (Wed Mar 31, 3:11 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Frederic Weisbecker, (Wed Mar 31, 3:20 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Thu Apr 1, 1:50 am)
Re: [GIT, RFC] Killing the Big Kernel Lock, Jan Blunck, (Thu Apr 8, 1:45 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Arnd Bergmann, (Thu Apr 8, 2:27 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Frederic Weisbecker, (Thu Apr 8, 2:30 pm)
Re: [GIT, RFC] Killing the Big Kernel Lock, Jan Blunck, (Fri Apr 9, 4:02 am)
Re: [GIT, RFC] Killing the Big Kernel Lock, Stefan Richter, (Sat Apr 10, 8:13 am)