[PATCH] firewire: 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:16 am

The <linux/firewire-cdev.h> character device file ABI is based on
  - ioctl() to initiate actions,
  - read() to consume events,
  - mmap() for isochronous I/O DMA buffers.
lseek(), pread(), pwrite() (or any kind of write() at all) on the other
hand are not applicable to /dev/fw* device files.

Alas, whereas for example file_operations.write == NULL causes write()
to be failed with an appropriate error, file_operations.llseek == NULL
causes fs/read_write.c::default_llseek to be called on lseek() per
default.

This looks like not doing any harm, 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:  The firewire-cdev interface has always been free of any BKL
usage apart from this oversight regarding default_llseek (and from
involuntary BKL usage by open() in older kernels).

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

Somebody correct me if I got anything wrong in my patch description.

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/fir...
"BKL removal: mark remaining users as 'depends on BKL'"
http://git.kernel.org/?p=linux/kernel/git/arnd/playground.git;a=blobdiff;f=drivers/fir...


 drivers/firewire/core-cdev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: b/drivers/firewire/core-cdev.c
===================================================================
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -226,7 +226,7 @@ static int fw_device_op_open(struct inod
 	list_add_tail(&client->link, &device->client_list);
 	mutex_unlock(&device->client_list_mutex);
 
-	return 0;
+	return nonseekable_open(inode, file);
 }
 
 static void queue_event(struct client *client, struct event *event,

-- 
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] firewire: char device files are not seekable (BKL ..., Stefan Richter, (Sat Mar 27, 2:16 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)