LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: Trond.Myklebust@netapp.com, swhiteho@redhat.com,
	sfrench@samba.org, vandrove@vc.cvut.cz,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	akpm@osdl.org
Subject: [PATCH] [8/18] BKL-removal: Remove BKL from remote_llseek
Date: Sun, 27 Jan 2008 03:17:14 +0100 (CET)	[thread overview]
Message-ID: <20080127021714.A223614D2E@wotan.suse.de> (raw)
In-Reply-To: <20080127317.043953000@suse.de>


- Replace remote_llseek with remote_llseek_unlocked (to force compilation 
failures in all users)
- Change all users to either use remote_llseek directly or take the
BKL around. I changed the file systems who don't use the BKL
for anything (CIFS, GFS) to call it directly. NCPFS and SMBFS and NFS
take the BKL, but explicitely in their own source now.

I moved them all over in a single patch to avoid unbisectable sections.

Cc: Trond.Myklebust@netapp.com
Cc: swhiteho@redhat.com
Cc: sfrench@samba.org
Cc: vandrove@vc.cvut.cz

Signed-off-by: Andi Kleen <ak@suse.de>

---
 fs/cifs/cifsfs.c   |    2 +-
 fs/gfs2/ops_file.c |    4 ++--
 fs/ncpfs/file.c    |   12 +++++++++++-
 fs/nfs/file.c      |    6 +++++-
 fs/read_write.c    |    7 +++----
 fs/smbfs/file.c    |   11 ++++++++++-
 include/linux/fs.h |    3 ++-
 7 files changed, 34 insertions(+), 11 deletions(-)

Index: linux/fs/cifs/cifsfs.c
===================================================================
--- linux.orig/fs/cifs/cifsfs.c
+++ linux/fs/cifs/cifsfs.c
@@ -549,7 +549,7 @@ static loff_t cifs_llseek(struct file *f
 		if (retval < 0)
 			return (loff_t)retval;
 	}
-	return remote_llseek(file, offset, origin);
+	return remote_llseek_unlocked(file, offset, origin);
 }
 
 static struct file_system_type cifs_fs_type = {
Index: linux/fs/gfs2/ops_file.c
===================================================================
--- linux.orig/fs/gfs2/ops_file.c
+++ linux/fs/gfs2/ops_file.c
@@ -107,11 +107,11 @@ static loff_t gfs2_llseek(struct file *f
 		error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
 					   &i_gh);
 		if (!error) {
-			error = remote_llseek(file, offset, origin);
+			error = remote_llseek_unlocked(file, offset, origin);
 			gfs2_glock_dq_uninit(&i_gh);
 		}
 	} else
-		error = remote_llseek(file, offset, origin);
+		error = remote_llseek_unlocked(file, offset, origin);
 
 	return error;
 }
Index: linux/fs/ncpfs/file.c
===================================================================
--- linux.orig/fs/ncpfs/file.c
+++ linux/fs/ncpfs/file.c
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 
 #include <linux/ncp_fs.h>
 #include "ncplib_kernel.h"
@@ -281,9 +282,18 @@ static int ncp_release(struct inode *ino
 	return 0;
 }
 
+static loff_t ncp_remote_llseek(struct file *file, loff_t offset, int origin)
+{
+	loff_t ret;
+	lock_kernel();
+	ret = remote_llseek_unlocked(file, offset, origin);
+	unlock_kernel();
+	return ret;
+}
+
 const struct file_operations ncp_file_operations =
 {
-	.llseek		= remote_llseek,
+	.llseek 	= ncp_remote_llseek,
 	.read		= ncp_file_read,
 	.write		= ncp_file_write,
 	.ioctl		= ncp_ioctl,
Index: linux/fs/read_write.c
===================================================================
--- linux.orig/fs/read_write.c
+++ linux/fs/read_write.c
@@ -58,11 +58,10 @@ loff_t generic_file_llseek(struct file *
 
 EXPORT_SYMBOL(generic_file_llseek);
 
-loff_t remote_llseek(struct file *file, loff_t offset, int origin)
+loff_t remote_llseek_unlocked(struct file *file, loff_t offset, int origin)
 {
 	long long retval;
 
-	lock_kernel();
 	switch (origin) {
 		case SEEK_END:
 			offset += i_size_read(file->f_path.dentry->d_inode);
@@ -73,15 +72,15 @@ loff_t remote_llseek(struct file *file, 
 	retval = -EINVAL;
 	if (offset>=0 && offset<=file->f_path.dentry->d_inode->i_sb->s_maxbytes) {
 		if (offset != file->f_pos) {
+			/* AK: do we need a lock for those? */
 			file->f_pos = offset;
 			file->f_version = 0;
 		}
 		retval = offset;
 	}
-	unlock_kernel();
 	return retval;
 }
-EXPORT_SYMBOL(remote_llseek);
+EXPORT_SYMBOL(remote_llseek_unlocked);
 
 loff_t no_llseek(struct file *file, loff_t offset, int origin)
 {
Index: linux/fs/smbfs/file.c
===================================================================
--- linux.orig/fs/smbfs/file.c
+++ linux/fs/smbfs/file.c
@@ -422,9 +422,18 @@ smb_file_permission(struct inode *inode,
 	return error;
 }
 
+static loff_t smb_remote_llseek(struct file *file, loff_t offset, int origin)
+{
+	loff_t ret;
+	lock_kernel();
+	ret = remote_llseek_unlocked(file, offset, origin);
+	unlock_kernel();
+	return ret;
+}
+
 const struct file_operations smb_file_operations =
 {
-	.llseek		= remote_llseek,
+	.llseek 	= smb_remote_llseek,
 	.read		= do_sync_read,
 	.aio_read	= smb_file_aio_read,
 	.write		= do_sync_write,
Index: linux/include/linux/fs.h
===================================================================
--- linux.orig/include/linux/fs.h
+++ linux/include/linux/fs.h
@@ -1825,7 +1825,8 @@ extern void
 file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
 extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
 extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
-extern loff_t remote_llseek(struct file *file, loff_t offset, int origin);
+extern loff_t remote_llseek_unlocked(struct file *file, loff_t offset,
+			int origin);
 extern int generic_file_open(struct inode * inode, struct file * filp);
 extern int nonseekable_open(struct inode * inode, struct file * filp);
 
Index: linux/fs/nfs/file.c
===================================================================
--- linux.orig/fs/nfs/file.c
+++ linux/fs/nfs/file.c
@@ -166,6 +166,7 @@ force_reval:
 
 static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin)
 {
+	loff_t loff;
 	/* origin == SEEK_END => we must revalidate the cached file length */
 	if (origin == SEEK_END) {
 		struct inode *inode = filp->f_mapping->host;
@@ -173,7 +174,10 @@ static loff_t nfs_file_llseek(struct fil
 		if (retval < 0)
 			return (loff_t)retval;
 	}
-	return remote_llseek(filp, offset, origin);
+	lock_kernel();	/* BKL needed? */
+	loff = remote_llseek_unlocked(filp, offset, origin);
+	unlock_kernel();
+	return loff;
 }
 
 /*

  parent reply	other threads:[~2008-01-27  2:19 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-27  2:17 [PATCH] [0/18] Implement some low hanging BKL removal fruit in fs/* Andi Kleen
2008-01-27  2:17 ` [PATCH] [1/18] BKL-removal: Convert ext2 over to use unlocked_ioctl Andi Kleen
2008-01-27  2:17 ` [PATCH] [2/18] BKL-removal: Remove incorrect BKL comment in ext2 Andi Kleen
2008-01-27  2:17 ` [PATCH] [3/18] BKL-removal: Convert ext3 to use unlocked_ioctl Andi Kleen
2008-01-28  5:33   ` Andrew Morton
2008-01-28  6:02     ` Andi Kleen
2008-01-27  2:17 ` [PATCH] [4/18] ext3: Remove incorrect BKL comment Andi Kleen
2008-01-27  2:17 ` [PATCH] [5/18] BKL-removal: Remove incorrect comment refering to lock_kernel() from jbd/jbd2 Andi Kleen
2008-01-27  2:17 ` [PATCH] [6/18] BKL-removal: Convert ext4 to use unlocked_ioctl Andi Kleen
2008-01-27  2:17 ` [PATCH] [7/18] BKL-removal: Remove incorrect comments refering to BKL from ext4 Andi Kleen
2008-01-27  2:17 ` Andi Kleen [this message]
2008-01-27 16:57   ` [PATCH] [8/18] BKL-removal: Remove BKL from remote_llseek Steve French
2008-01-27 17:56     ` Trond Myklebust
2008-01-27 22:18       ` Steve French
2008-01-27 23:08         ` Trond Myklebust
2008-01-28  2:58           ` Andi Kleen
2008-01-28  4:13             ` Trond Myklebust
2008-01-28  4:38               ` Andi Kleen
2008-01-28  4:51                 ` Trond Myklebust
2008-01-28  5:13                 ` Andrew Morton
2008-01-28  8:17                   ` Andi Kleen
2008-01-28 18:33                     ` Steve French
2008-01-28 19:34                       ` Dave Kleikamp
2008-01-28 12:56                   ` Alan Cox
2008-01-28 13:27                     ` Andi Kleen
2008-01-28 13:38                       ` Alan Cox
2008-01-28 14:10                         ` Andi Kleen
2008-01-28 14:50                           ` Alan Cox
2008-01-28 15:13                           ` Diego Calleja
2008-01-28  2:44         ` Andi Kleen
2008-01-28  2:43     ` Andi Kleen
2008-01-27  2:17 ` [PATCH] [9/18] BKL-removal: Use unlocked_ioctl for jfs Andi Kleen
2008-01-27 23:05   ` Dave Kleikamp
2008-01-27  2:17 ` [PATCH] [10/18] BKL-removal: Implement a compat_ioctl handler for JFS Andi Kleen
2008-01-27 23:05   ` Dave Kleikamp
2008-01-27  2:17 ` [PATCH] [11/18] BKL-removal: Convert ocfs2 over to unlocked_ioctl Andi Kleen
2008-01-27  2:17 ` [PATCH] [12/18] BKL-removal: Convert CIFS " Andi Kleen
2008-01-27  2:17 ` [PATCH] [13/18] BKL-removal: Add compat_ioctl for cifs Andi Kleen
2008-01-27  2:17 ` [PATCH] [14/18] BKL-removal: Add unlocked_fasync Andi Kleen
2008-01-27  7:05   ` KOSAKI Motohiro
2008-01-27  2:17 ` [PATCH] [15/18] BKL-removal: Convert pipe over to unlocked_fasync Andi Kleen
2008-01-27  2:17 ` [PATCH] [16/18] BKL-removal: Convert socket fasync " Andi Kleen
2008-01-27  2:17 ` [PATCH] [17/18] BKL-removal: Convert fuse " Andi Kleen
2008-01-27  2:17 ` [PATCH] [18/18] BKL-removal: Convert bad_inode " Andi Kleen
2008-01-28  1:59 ` [PATCH] [0/18] Implement some low hanging BKL removal fruit in fs/* Nick Piggin
2008-01-28  3:15   ` Andi Kleen
     [not found] <9Q5hR-3MI-9@gated-at.bofh.it>
     [not found] ` <9Qsob-7is-1@gated-at.bofh.it>
     [not found]   ` <9QtDz-121-11@gated-at.bofh.it>
     [not found]     ` <9QtWX-1qg-15@gated-at.bofh.it>
     [not found]       ` <9Qugj-1PK-1@gated-at.bofh.it>
2008-01-28  9:44         ` [PATCH] [8/18] BKL-removal: Remove BKL from remote_llseek Bodo Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080127021714.A223614D2E@wotan.suse.de \
    --to=ak@suse.de \
    --cc=Trond.Myklebust@netapp.com \
    --cc=akpm@osdl.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfrench@samba.org \
    --cc=swhiteho@redhat.com \
    --cc=vandrove@vc.cvut.cz \
    --subject='Re: [PATCH] [8/18] BKL-removal: Remove BKL from remote_llseek' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).