]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] 2.5.4-pre1: further llseek cleanup (2/3)
authorRobert Love <rml@tech9.net>
Wed, 6 Feb 2002 02:46:42 +0000 (18:46 -0800)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Wed, 6 Feb 2002 02:46:42 +0000 (18:46 -0800)
This is the second patch of three implementing further llseek cleanups,
against 2.5.4-pre1.  It does not depend on the other patches.

This patch cleans up various code and quite nicely removes much more
code than it adds.  Specifically:

- remove static lseek method which merely reimplements
  the standard no_llseek in the following seven files:
  hci_vhci.c, ite8172.c, nec_vrc5477.c, auerswald.c,
  pipe.c, netlink_dev.c, and socket.c

- remove fs/ufs/file.c::ufs_file_lseek -- Al says it is
  reimplementing generic_file_llseek, so let's use that
  instead (the comment about 32-bit sizes shouldn't be
  an issue, the generic method checks size)

- include smp_lock.h in 3 files missed from previous
  'remove bkl' patch

- Documentation/filesystem/Locking update

Please, apply.

Robert Love

12 files changed:
Documentation/filesystems/Locking
drivers/bluetooth/hci_vhci.c
drivers/sound/ite8172.c
drivers/sound/nec_vrc5477.c
drivers/usb/auerswald.c
fs/hfs/file_cap.c
fs/hfs/file_hdr.c
fs/ncpfs/file.c
fs/pipe.c
fs/ufs/file.c
net/netlink/netlink_dev.c
net/socket.c

index e40aecd5c0a92cb1ba0c163a722d712905c7a5fc..3a5eec4d1be8f96051bd8470b92ea6f68af9151a 100644 (file)
@@ -237,7 +237,10 @@ writev:            no
 
 ->llseek() locking has moved from llseek to the individual llseek
 implementations.  If your fs is not using generic_file_llseek, you
-need to acquire and release the BKL in your ->llseek().
+need to acquire and release the appropriate locks in your ->llseek().
+For many filesystems, it is probably safe to acquire the inode
+semaphore.  Note some filesystems (i.e. remote ones) provide no
+protection for i_size so you will need to use the BKL.
 
 ->open() locking is in-transit: big lock partially moved into the methods.
 The only exception is ->open() in the instances of file_operations that never
index dc47bbc87e649cd96640ed3de52c42177c084c13..4fe439a995cc9637c6182cc2f8e352980e7c842c 100644 (file)
@@ -221,11 +221,6 @@ static ssize_t hci_vhci_chr_read(struct file * file, char * buf, size_t count, l
        return ret;
 }
 
-static loff_t hci_vhci_chr_lseek(struct file * file, loff_t offset, int origin)
-{
-       return -ESPIPE;
-}
-
 static int hci_vhci_chr_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
 {
        return -EINVAL;
@@ -296,7 +291,7 @@ static int hci_vhci_chr_close(struct inode *inode, struct file *file)
 
 static struct file_operations hci_vhci_fops = {
        owner:  THIS_MODULE,    
-       llseek: hci_vhci_chr_lseek,
+       llseek: no_lseek,
        read:   hci_vhci_chr_read,
        write:  hci_vhci_chr_write,
        poll:   hci_vhci_chr_poll,
index 22844c9c903713f287819e401e2b001d5f4370af..3534696663de367b35479b72838da736ad01089c 100644 (file)
@@ -824,12 +824,6 @@ static void it8172_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 
 /* --------------------------------------------------------------------- */
 
-static loff_t it8172_llseek(struct file *file, loff_t offset, int origin)
-{
-    return -ESPIPE;
-}
-
-
 static int it8172_open_mixdev(struct inode *inode, struct file *file)
 {
     int minor = MINOR(inode->i_rdev);
@@ -870,7 +864,7 @@ static int it8172_ioctl_mixdev(struct inode *inode, struct file *file,
 
 static /*const*/ struct file_operations it8172_mixer_fops = {
     owner:     THIS_MODULE,
-    llseek:    it8172_llseek,
+    llseek:    no_llseek,
     ioctl:     it8172_ioctl_mixdev,
     open:      it8172_open_mixdev,
     release:   it8172_release_mixdev,
@@ -1633,7 +1627,7 @@ static int it8172_release(struct inode *inode, struct file *file)
 
 static /*const*/ struct file_operations it8172_audio_fops = {
     owner:     THIS_MODULE,
-    llseek:    it8172_llseek,
+    llseek:    no_llseek,
     read:      it8172_read,
     write:     it8172_write,
     poll:      it8172_poll,
index f9589ce8bf8ebfa28dfe74d6a4b68a5a37730a4d..2fe779caf9f27f6f2539124ca56d47da1bf9fbfb 100644 (file)
@@ -805,12 +805,6 @@ static void vrc5477_ac97_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 
 /* --------------------------------------------------------------------- */
 
-static loff_t vrc5477_ac97_llseek(struct file *file, loff_t offset, int origin)
-{
-       return -ESPIPE;
-}
-
-
 static int vrc5477_ac97_open_mixdev(struct inode *inode, struct file *file)
 {
        int minor = MINOR(inode->i_rdev);
@@ -852,7 +846,7 @@ static int vrc5477_ac97_ioctl_mixdev(struct inode *inode, struct file *file,
 
 static /*const*/ struct file_operations vrc5477_ac97_mixer_fops = {
        owner:          THIS_MODULE,
-       llseek:         vrc5477_ac97_llseek,
+       llseek:         no_llseek,
        ioctl:          vrc5477_ac97_ioctl_mixdev,
        open:           vrc5477_ac97_open_mixdev,
        release:        vrc5477_ac97_release_mixdev,
@@ -1618,7 +1612,7 @@ static int vrc5477_ac97_release(struct inode *inode, struct file *file)
 
 static /*const*/ struct file_operations vrc5477_ac97_audio_fops = {
        owner:  THIS_MODULE,
-       llseek:         vrc5477_ac97_llseek,
+       llseek:         no_llseek,
        read:           vrc5477_ac97_read,
        write:          vrc5477_ac97_write,
        poll:           vrc5477_ac97_poll,
index 24490c47d4089a08ef2316efbb80531c97f2790c..6180418620a97a782a0e18c0c4717e9eb7864508 100644 (file)
@@ -1553,15 +1553,6 @@ static int auerchar_ioctl (struct inode *inode, struct file *file, unsigned int
        return ret;
 }
 
-
-/* Seek is not supported */
-static loff_t auerchar_llseek (struct file *file, loff_t offset, int origin)
-{
-        dbg ("auerchar_seek");
-        return -ESPIPE;
-}
-
-
 /* Read data from the device */
 static ssize_t auerchar_read (struct file *file, char *buf, size_t count, loff_t * ppos)
 {
@@ -1843,7 +1834,7 @@ static int auerchar_release (struct inode *inode, struct file *file)
 static struct file_operations auerswald_fops =
 {
        owner:          THIS_MODULE,
-       llseek:         auerchar_llseek,
+       llseek:         no_llseek,
        read:           auerchar_read,
        write:          auerchar_write,
        ioctl:          auerchar_ioctl,
index 494d43249c44fe255fc477f75ba44f605b5a99f5..7a02ebaa6154552932efced8598e84eac01c84d2 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/hfs_fs_sb.h>
 #include <linux/hfs_fs_i.h>
 #include <linux/hfs_fs.h>
+#include <linux/smp_lock.h>
 
 /*================ Forward declarations ================*/
 static loff_t      cap_info_llseek(struct file *, loff_t,
index 2ac3182437a709c8a8ee63f3cf9e9c6a289f1bef..8dad9e76d20befca5968714e9344a1c9f115d17e 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/hfs_fs_sb.h>
 #include <linux/hfs_fs_i.h>
 #include <linux/hfs_fs.h>
+#include <linux/smp_lock.h>
 
 /* prodos types */
 #define PRODOSI_FTYPE_DIR   0x0F
index fbd2c3137dd407464359a704fdcea93ab4c6603e..bc7b38e5530c0dec8ab31cfc327db2440337cd1f 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/locks.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
+#include <linux/smp_lock.h>
 
 #include <linux/ncp_fs.h>
 #include "ncplib_kernel.h"
index 5910c168288f6e63ec7827f8c653d8028fa9c9b9..5a053913f5d6f5f1349c65e372745cdba6dc53e5 100644 (file)
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -246,12 +246,6 @@ sigpipe:
        return -EPIPE;
 }
 
-static loff_t
-pipe_lseek(struct file *file, loff_t offset, int orig)
-{
-       return -ESPIPE;
-}
-
 static ssize_t
 bad_pipe_r(struct file *filp, char *buf, size_t count, loff_t *ppos)
 {
@@ -381,7 +375,7 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
  * are also used in linux/fs/fifo.c to do operations on FIFOs.
  */
 struct file_operations read_fifo_fops = {
-       llseek:         pipe_lseek,
+       llseek:         no_llseek,
        read:           pipe_read,
        write:          bad_pipe_w,
        poll:           fifo_poll,
@@ -391,7 +385,7 @@ struct file_operations read_fifo_fops = {
 };
 
 struct file_operations write_fifo_fops = {
-       llseek:         pipe_lseek,
+       llseek:         no_llseek,
        read:           bad_pipe_r,
        write:          pipe_write,
        poll:           fifo_poll,
@@ -401,7 +395,7 @@ struct file_operations write_fifo_fops = {
 };
 
 struct file_operations rdwr_fifo_fops = {
-       llseek:         pipe_lseek,
+       llseek:         no_llseek,
        read:           pipe_read,
        write:          pipe_write,
        poll:           fifo_poll,
@@ -411,7 +405,7 @@ struct file_operations rdwr_fifo_fops = {
 };
 
 struct file_operations read_pipe_fops = {
-       llseek:         pipe_lseek,
+       llseek:         no_llseek,
        read:           pipe_read,
        write:          bad_pipe_w,
        poll:           pipe_poll,
@@ -421,7 +415,7 @@ struct file_operations read_pipe_fops = {
 };
 
 struct file_operations write_pipe_fops = {
-       llseek:         pipe_lseek,
+       llseek:         no_llseek,
        read:           bad_pipe_r,
        write:          pipe_write,
        poll:           pipe_poll,
@@ -431,7 +425,7 @@ struct file_operations write_pipe_fops = {
 };
 
 struct file_operations rdwr_pipe_fops = {
-       llseek:         pipe_lseek,
+       llseek:         no_llseek,
        read:           pipe_read,
        write:          pipe_write,
        poll:           pipe_poll,
index 7af092555ad0196bf5ec7871c89afb965efc384e..819e6945b112e8ba834f109029218ce7f5bf3a7e 100644 (file)
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
 
-/*
- * Make sure the offset never goes beyond the 32-bit mark..
- */
-static long long ufs_file_lseek(
-       struct file *file,
-       long long offset,
-       int origin )
-{
-       long long retval;
-       struct inode *inode = file->f_dentry->d_inode;
-
-       lock_kernel();
-
-       switch (origin) {
-               case 2:
-                       offset += inode->i_size;
-                       break;
-               case 1:
-                       offset += file->f_pos;
-       }
-       retval = -EINVAL;
-       /* make sure the offset fits in 32 bits */
-       if (((unsigned long long) offset >> 32) == 0) {
-               if (offset != file->f_pos) {
-                       file->f_pos = offset;
-                       file->f_reada = 0;
-                       file->f_version = ++event;
-               }
-               retval = offset;
-       }
-       unlock_kernel();
-       return retval;
-}
-
 /*
  * We have mostly NULL's here: the current defaults are ok for
  * the ufs filesystem.
  */
  
 struct file_operations ufs_file_operations = {
-       llseek:         ufs_file_lseek,
+       llseek:         generic_file_llseek,
        read:           generic_file_read,
        write:          generic_file_write,
        mmap:           generic_file_mmap,
index 8c13461ed29a0a8e60a0f72742cf666f63d8523d..a5bb25ab50891eba4534b4cd1c58bdd72572d151 100644 (file)
@@ -98,11 +98,6 @@ static ssize_t netlink_read(struct file * file, char * buf,
        return sock_recvmsg(sock, &msg, count, msg.msg_flags);
 }
 
-static loff_t netlink_lseek(struct file * file, loff_t offset, int origin)
-{
-       return -ESPIPE;
-}
-
 static int netlink_open(struct inode * inode, struct file * file)
 {
        unsigned int minor = minor(inode->i_rdev);
@@ -166,7 +161,7 @@ static int netlink_ioctl(struct inode *inode, struct file *file,
 
 static struct file_operations netlink_fops = {
        owner:          THIS_MODULE,
-       llseek:         netlink_lseek,
+       llseek:         no_llseek,
        read:           netlink_read,
        write:          netlink_write,
        poll:           netlink_poll,
index 7d8d0e6b2a2d8e7d32f87358f1356aa80ce9a393..8343b63d552b0f7353b12ac571f99e923319736b 100644 (file)
@@ -86,7 +86,6 @@
 #include <linux/netfilter.h>
 
 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
-static loff_t sock_lseek(struct file *file, loff_t offset, int whence);
 static ssize_t sock_read(struct file *file, char *buf,
                         size_t size, loff_t *ppos);
 static ssize_t sock_write(struct file *file, const char *buf,
@@ -113,7 +112,7 @@ static ssize_t sock_sendpage(struct file *file, struct page *page,
  */
 
 static struct file_operations socket_file_ops = {
-       llseek:         sock_lseek,
+       llseek:         no_llseek,
        read:           sock_read,
        write:          sock_write,
        poll:           sock_poll,
@@ -559,15 +558,6 @@ int sock_recvmsg(struct socket *sock, struct msghdr *msg, int size, int flags)
 }
 
 
-/*
- *     Sockets are not seekable.
- */
-
-static loff_t sock_lseek(struct file *file, loff_t offset, int whence)
-{
-       return -ESPIPE;
-}
-
 /*
  *     Read data from a socket. ubuf is a user mode pointer. We make sure the user
  *     area ubuf...ubuf+size-1 is writable before asking the protocol.