* [PATCH] [0/11] Repost of old VFS BKL patchkit
@ 2008-05-19 12:31 Andi Kleen
2008-05-19 12:31 ` [PATCH] [1/11] Remove BKL from remote_llseek Andi Kleen
` (10 more replies)
0 siblings, 11 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 12:31 UTC (permalink / raw)
To: corbet, linux-kernel
Since BKL removal seems to be en-vogue again here's the repost
of the unapplied parts of my older VFS BKL patchkit.
Main difference is port to 2.6.26-rc2 and more fasync conversins.
- Converts remote_llseek to be BKL less. This will either eliminate
or push it down in a couple of network file systems (SMBFS, CIFS, OCFS2,
NCPFS, NFS)
- Converts file flags handling to i_mutex
[BTW while looking over the tree I think there are a few
races in this regard in there anyways. Not all people who modify
that take BKL. Auditing all of them is a separate project.
No difference before/after my patch]
- Adds unlocked_fasync
- Converts lots of fasync users to unlocked_fasync
-Andi
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH] [1/11] Remove BKL from remote_llseek
2008-05-19 12:31 [PATCH] [0/11] Repost of old VFS BKL patchkit Andi Kleen
@ 2008-05-19 12:31 ` Andi Kleen
2008-05-19 13:58 ` Trond Myklebust
` (2 more replies)
2008-05-19 12:31 ` [PATCH] [2/11] Add unlocked_fasync Andi Kleen
` (9 subsequent siblings)
10 siblings, 3 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 12:31 UTC (permalink / raw)
To: Trond.Myklebust, swhiteho, sfrench, vandrove, corbet,
linux-kernel
- 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.
Open problem: 32bit kernels can corrupt fpos because its modification
is not atomic, but they can do that anyways because there's other paths who
modify it without BKL.
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>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
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
@@ -581,7 +581,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);
}
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
@@ -62,11 +62,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)
{
loff_t 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
@@ -1871,7 +1871,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
@@ -170,6 +170,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;
@@ -177,7 +178,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;
}
/*
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH] [2/11] Add unlocked_fasync
2008-05-19 12:31 [PATCH] [0/11] Repost of old VFS BKL patchkit Andi Kleen
2008-05-19 12:31 ` [PATCH] [1/11] Remove BKL from remote_llseek Andi Kleen
@ 2008-05-19 12:31 ` Andi Kleen
2008-05-19 14:03 ` Christoph Hellwig
2008-05-19 17:29 ` Randy Dunlap
2008-05-19 12:31 ` [PATCH] [3/11] Convert pipe over to unlocked_fasync Andi Kleen
` (8 subsequent siblings)
10 siblings, 2 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 12:31 UTC (permalink / raw)
To: corbet, linux-kernel
Add a new fops entry point to allow fasync without BKL. While it's arguably
unclear this entry point is called often enough for it really matters
it was still relatively easy to do. And there are far less async users
in the tree than ioctls so it's likely they can be all converted
eventually and then the non unlocked async entry point could be dropped.
There was still the problem of the actual flags change being
protected against other setters of flags. Instead of using BKL
for this use the i_mutex now.
I also added a mutex_lock against one other flags change
that was lockless and could potentially lose updates.
There are a couple of potential problems I added comments about on.
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
Documentation/filesystems/vfs.txt | 5 ++++-
fs/fcntl.c | 6 +++++-
fs/ioctl.c | 5 ++++-
include/linux/fs.h | 1 +
4 files changed, 14 insertions(+), 3 deletions(-)
Index: linux/fs/fcntl.c
===================================================================
--- linux.orig/fs/fcntl.c
+++ linux/fs/fcntl.c
@@ -227,18 +227,26 @@ static int setfl(int fd, struct file * f
if (error)
return error;
- lock_kernel();
+ /* AK: potential race here. Since test is unlocked fasync could
+ be called several times in a row with on. We hope the drivers
+ deal with it. */
if ((arg ^ filp->f_flags) & FASYNC) {
- if (filp->f_op && filp->f_op->fasync) {
- error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0);
- if (error < 0)
- goto out;
+ int on = !!(arg & FASYNC);
+ if (filp->f_op && filp->f_op->unlocked_fasync)
+ error = filp->f_op->unlocked_fasync(fd, filp, on);
+ else if (filp->f_op && filp->f_op->fasync) {
+ lock_kernel();
+ error = filp->f_op->fasync(fd, filp, on);
+ unlock_kernel();
}
+ /* AK: no else error = -EINVAL here? */
+ if (error < 0)
+ return error;
}
+ mutex_lock(&filp->f_dentry->d_inode->i_mutex);
filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK);
- out:
- unlock_kernel();
+ mutex_unlock(&filp->f_dentry->d_inode->i_mutex);
return error;
}
Index: linux/fs/ioctl.c
===================================================================
--- linux.orig/fs/ioctl.c
+++ linux/fs/ioctl.c
@@ -103,10 +103,13 @@ static int ioctl_fionbio(struct file *fi
if (O_NONBLOCK != O_NDELAY)
flag |= O_NDELAY;
#endif
+ /* Protect f_flags */
+ mutex_lock(&filp->f_dentry->d_inode->i_mutex);
if (on)
filp->f_flags |= flag;
else
filp->f_flags &= ~flag;
+ mutex_unlock(&filp->f_dentry->d_inode->i_mutex);
return error;
}
@@ -122,8 +125,13 @@ static int ioctl_fioasync(unsigned int f
flag = on ? FASYNC : 0;
/* Did FASYNC state change ? */
+ /* AK: potential race here: ->fasync could be called with on two times
+ in a row. We hope the drivers deal with it. */
if ((flag ^ filp->f_flags) & FASYNC) {
- if (filp->f_op && filp->f_op->fasync) {
+ if (filp->f_op && filp->f_op->unlocked_fasync) {
+ error = filp->f_op->unlocked_fasync(fd,
+ filp, on);
+ } else if (filp->f_op && filp->f_op->fasync) {
lock_kernel();
error = filp->f_op->fasync(fd, filp, on);
unlock_kernel();
@@ -133,10 +141,13 @@ static int ioctl_fioasync(unsigned int f
if (error)
return error;
+ /* Protect f_flags */
+ mutex_lock(&filp->f_dentry->d_inode->i_mutex);
if (on)
filp->f_flags |= FASYNC;
else
filp->f_flags &= ~FASYNC;
+ mutex_unlock(&filp->f_dentry->d_inode->i_mutex);
return error;
}
Index: linux/include/linux/fs.h
===================================================================
--- linux.orig/include/linux/fs.h
+++ linux/include/linux/fs.h
@@ -1237,6 +1237,7 @@ struct file_operations {
int (*fsync) (struct file *, struct dentry *, int datasync);
int (*aio_fsync) (struct kiocb *, int datasync);
int (*fasync) (int, struct file *, int);
+ int (*unlocked_fasync) (int, struct file *, int);
int (*lock) (struct file *, int, struct file_lock *);
ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
Index: linux/Documentation/filesystems/vfs.txt
===================================================================
--- linux.orig/Documentation/filesystems/vfs.txt
+++ linux/Documentation/filesystems/vfs.txt
@@ -755,6 +755,7 @@ struct file_operations {
int (*fsync) (struct file *, struct dentry *, int datasync);
int (*aio_fsync) (struct kiocb *, int datasync);
int (*fasync) (int, struct file *, int);
+ int (*unlocked_fasync) (int, struct file *, int);
int (*lock) (struct file *, int, struct file_lock *);
ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
@@ -814,7 +815,9 @@ otherwise noted.
fsync: called by the fsync(2) system call
fasync: called by the fcntl(2) system call when asynchronous
- (non-blocking) mode is enabled for a file
+ (non-blocking) mode is enabled for a file. BKL hold
+
+ unlocked_fasync: like fasync, but without BKL
lock: called by the fcntl(2) system call for F_GETLK, F_SETLK, and F_SETLKW
commands
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH] [3/11] Convert pipe over to unlocked_fasync
2008-05-19 12:31 [PATCH] [0/11] Repost of old VFS BKL patchkit Andi Kleen
2008-05-19 12:31 ` [PATCH] [1/11] Remove BKL from remote_llseek Andi Kleen
2008-05-19 12:31 ` [PATCH] [2/11] Add unlocked_fasync Andi Kleen
@ 2008-05-19 12:31 ` Andi Kleen
2008-05-19 12:31 ` [PATCH] [4/11] Convert socket fasync " Andi Kleen
` (7 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 12:31 UTC (permalink / raw)
To: corbet, linux-kernel
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
fs/pipe.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Index: linux/fs/pipe.c
===================================================================
--- linux.orig/fs/pipe.c
+++ linux/fs/pipe.c
@@ -787,7 +787,7 @@ const struct file_operations read_fifo_f
.unlocked_ioctl = pipe_ioctl,
.open = pipe_read_open,
.release = pipe_read_release,
- .fasync = pipe_read_fasync,
+ .unlocked_fasync = pipe_read_fasync,
};
const struct file_operations write_fifo_fops = {
@@ -799,7 +799,7 @@ const struct file_operations write_fifo_
.unlocked_ioctl = pipe_ioctl,
.open = pipe_write_open,
.release = pipe_write_release,
- .fasync = pipe_write_fasync,
+ .unlocked_fasync = pipe_write_fasync,
};
const struct file_operations rdwr_fifo_fops = {
@@ -812,7 +812,7 @@ const struct file_operations rdwr_fifo_f
.unlocked_ioctl = pipe_ioctl,
.open = pipe_rdwr_open,
.release = pipe_rdwr_release,
- .fasync = pipe_rdwr_fasync,
+ .unlocked_fasync = pipe_rdwr_fasync,
};
static const struct file_operations read_pipe_fops = {
@@ -824,7 +824,7 @@ static const struct file_operations read
.unlocked_ioctl = pipe_ioctl,
.open = pipe_read_open,
.release = pipe_read_release,
- .fasync = pipe_read_fasync,
+ .unlocked_fasync = pipe_read_fasync,
};
static const struct file_operations write_pipe_fops = {
@@ -836,7 +836,7 @@ static const struct file_operations writ
.unlocked_ioctl = pipe_ioctl,
.open = pipe_write_open,
.release = pipe_write_release,
- .fasync = pipe_write_fasync,
+ .unlocked_fasync = pipe_write_fasync,
};
static const struct file_operations rdwr_pipe_fops = {
@@ -849,7 +849,7 @@ static const struct file_operations rdwr
.unlocked_ioctl = pipe_ioctl,
.open = pipe_rdwr_open,
.release = pipe_rdwr_release,
- .fasync = pipe_rdwr_fasync,
+ .unlocked_fasync = pipe_rdwr_fasync,
};
struct pipe_inode_info * alloc_pipe_info(struct inode *inode)
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH] [4/11] Convert socket fasync to unlocked_fasync
2008-05-19 12:31 [PATCH] [0/11] Repost of old VFS BKL patchkit Andi Kleen
` (2 preceding siblings ...)
2008-05-19 12:31 ` [PATCH] [3/11] Convert pipe over to unlocked_fasync Andi Kleen
@ 2008-05-19 12:31 ` Andi Kleen
2008-05-19 12:31 ` [PATCH] [5/11] Convert fuse " Andi Kleen
` (6 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 12:31 UTC (permalink / raw)
To: davem, corbet, linux-kernel
Pretty sure the socket layer has no BKL requirements.
Cc: davem@davemloft.net
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
net/socket.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux/net/socket.c
===================================================================
--- linux.orig/net/socket.c
+++ linux/net/socket.c
@@ -134,7 +134,7 @@ static const struct file_operations sock
.mmap = sock_mmap,
.open = sock_no_open, /* special open code to disallow open via /proc */
.release = sock_close,
- .fasync = sock_fasync,
+ .unlocked_fasync = sock_fasync,
.sendpage = sock_sendpage,
.splice_write = generic_splice_sendpage,
.splice_read = sock_splice_read,
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH] [5/11] Convert fuse to unlocked_fasync
2008-05-19 12:31 [PATCH] [0/11] Repost of old VFS BKL patchkit Andi Kleen
` (3 preceding siblings ...)
2008-05-19 12:31 ` [PATCH] [4/11] Convert socket fasync " Andi Kleen
@ 2008-05-19 12:31 ` Andi Kleen
2008-05-19 12:31 ` [PATCH] [6/11] Convert bad_inode " Andi Kleen
` (5 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 12:31 UTC (permalink / raw)
To: miklos, corbet, linux-kernel
Cc: miklos@szeredi.hu
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
fs/fuse/dev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux/fs/fuse/dev.c
===================================================================
--- linux.orig/fs/fuse/dev.c
+++ linux/fs/fuse/dev.c
@@ -1040,7 +1040,7 @@ const struct file_operations fuse_dev_op
.aio_write = fuse_dev_write,
.poll = fuse_dev_poll,
.release = fuse_dev_release,
- .fasync = fuse_dev_fasync,
+ .unlocked_fasync = fuse_dev_fasync,
};
static struct miscdevice fuse_miscdevice = {
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH] [6/11] Convert bad_inode to unlocked_fasync
2008-05-19 12:31 [PATCH] [0/11] Repost of old VFS BKL patchkit Andi Kleen
` (4 preceding siblings ...)
2008-05-19 12:31 ` [PATCH] [5/11] Convert fuse " Andi Kleen
@ 2008-05-19 12:31 ` Andi Kleen
2008-05-19 12:31 ` [PATCH] [7/11] Convert DRM " Andi Kleen
` (4 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 12:31 UTC (permalink / raw)
To: corbet, linux-kernel
Not that it matters much, but it was easy.
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
fs/bad_inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux/fs/bad_inode.c
===================================================================
--- linux.orig/fs/bad_inode.c
+++ linux/fs/bad_inode.c
@@ -174,7 +174,7 @@ static const struct file_operations bad_
.release = bad_file_release,
.fsync = bad_file_fsync,
.aio_fsync = bad_file_aio_fsync,
- .fasync = bad_file_fasync,
+ .unlocked_fasync = bad_file_fasync,
.lock = bad_file_lock,
.sendpage = bad_file_sendpage,
.get_unmapped_area = bad_file_get_unmapped_area,
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH] [7/11] Convert DRM to unlocked_fasync
2008-05-19 12:31 [PATCH] [0/11] Repost of old VFS BKL patchkit Andi Kleen
` (5 preceding siblings ...)
2008-05-19 12:31 ` [PATCH] [6/11] Convert bad_inode " Andi Kleen
@ 2008-05-19 12:31 ` Andi Kleen
2008-05-19 12:31 ` [PATCH] [8/11] Use unlocked_fasync in random.c Andi Kleen
` (3 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 12:31 UTC (permalink / raw)
To: airlied, corbet, linux-kernel
Doesn't need BKL because it just uses fasync_helper and minor->dev is
protected by the file reference count.
Cc: airlied@linux.ie
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Index: linux/drivers/char/drm/i810_dma.c
===================================================================
--- linux.orig/drivers/char/drm/i810_dma.c
+++ linux/drivers/char/drm/i810_dma.c
@@ -117,7 +117,7 @@ static const struct file_operations i810
.release = drm_release,
.ioctl = drm_ioctl,
.mmap = i810_mmap_buffers,
- .fasync = drm_fasync,
+ .unlocked_fasync = drm_fasync,
};
static int i810_map_buffer(struct drm_buf * buf, struct drm_file *file_priv)
Index: linux/drivers/char/drm/i810_drv.c
===================================================================
--- linux.orig/drivers/char/drm/i810_drv.c
+++ linux/drivers/char/drm/i810_drv.c
@@ -62,7 +62,7 @@ static struct drm_driver driver = {
.ioctl = drm_ioctl,
.mmap = drm_mmap,
.poll = drm_poll,
- .fasync = drm_fasync,
+ .unlocked_fasync = drm_fasync,
},
.pci_driver = {
Index: linux/drivers/char/drm/i830_dma.c
===================================================================
--- linux.orig/drivers/char/drm/i830_dma.c
+++ linux/drivers/char/drm/i830_dma.c
@@ -119,7 +119,7 @@ static const struct file_operations i830
.release = drm_release,
.ioctl = drm_ioctl,
.mmap = i830_mmap_buffers,
- .fasync = drm_fasync,
+ .unlocked_fasync = drm_fasync,
};
static int i830_map_buffer(struct drm_buf * buf, struct drm_file *file_priv)
Index: linux/drivers/char/drm/i830_drv.c
===================================================================
--- linux.orig/drivers/char/drm/i830_drv.c
+++ linux/drivers/char/drm/i830_drv.c
@@ -73,7 +73,7 @@ static struct drm_driver driver = {
.ioctl = drm_ioctl,
.mmap = drm_mmap,
.poll = drm_poll,
- .fasync = drm_fasync,
+ .unlocked_fasync = drm_fasync,
},
.pci_driver = {
Index: linux/drivers/char/drm/i915_drv.c
===================================================================
--- linux.orig/drivers/char/drm/i915_drv.c
+++ linux/drivers/char/drm/i915_drv.c
@@ -559,7 +559,7 @@ static struct drm_driver driver = {
.ioctl = drm_ioctl,
.mmap = drm_mmap,
.poll = drm_poll,
- .fasync = drm_fasync,
+ .unlocked_fasync = drm_fasync,
#ifdef CONFIG_COMPAT
.compat_ioctl = i915_compat_ioctl,
#endif
Index: linux/drivers/char/drm/mga_drv.c
===================================================================
--- linux.orig/drivers/char/drm/mga_drv.c
+++ linux/drivers/char/drm/mga_drv.c
@@ -71,7 +71,7 @@ static struct drm_driver driver = {
.ioctl = drm_ioctl,
.mmap = drm_mmap,
.poll = drm_poll,
- .fasync = drm_fasync,
+ .unlocked_fasync = drm_fasync,
#ifdef CONFIG_COMPAT
.compat_ioctl = mga_compat_ioctl,
#endif
Index: linux/drivers/char/drm/r128_drv.c
===================================================================
--- linux.orig/drivers/char/drm/r128_drv.c
+++ linux/drivers/char/drm/r128_drv.c
@@ -66,7 +66,7 @@ static struct drm_driver driver = {
.ioctl = drm_ioctl,
.mmap = drm_mmap,
.poll = drm_poll,
- .fasync = drm_fasync,
+ .unlocked_fasync = drm_fasync,
#ifdef CONFIG_COMPAT
.compat_ioctl = r128_compat_ioctl,
#endif
Index: linux/drivers/char/drm/radeon_drv.c
===================================================================
--- linux.orig/drivers/char/drm/radeon_drv.c
+++ linux/drivers/char/drm/radeon_drv.c
@@ -88,7 +88,7 @@ static struct drm_driver driver = {
.ioctl = drm_ioctl,
.mmap = drm_mmap,
.poll = drm_poll,
- .fasync = drm_fasync,
+ .unlocked_fasync = drm_fasync,
#ifdef CONFIG_COMPAT
.compat_ioctl = radeon_compat_ioctl,
#endif
Index: linux/drivers/char/drm/savage_drv.c
===================================================================
--- linux.orig/drivers/char/drm/savage_drv.c
+++ linux/drivers/char/drm/savage_drv.c
@@ -53,7 +53,7 @@ static struct drm_driver driver = {
.ioctl = drm_ioctl,
.mmap = drm_mmap,
.poll = drm_poll,
- .fasync = drm_fasync,
+ .unlocked_fasync = drm_fasync,
},
.pci_driver = {
Index: linux/drivers/char/drm/sis_drv.c
===================================================================
--- linux.orig/drivers/char/drm/sis_drv.c
+++ linux/drivers/char/drm/sis_drv.c
@@ -83,7 +83,7 @@ static struct drm_driver driver = {
.ioctl = drm_ioctl,
.mmap = drm_mmap,
.poll = drm_poll,
- .fasync = drm_fasync,
+ .unlocked_fasync = drm_fasync,
},
.pci_driver = {
.name = DRIVER_NAME,
Index: linux/drivers/char/drm/tdfx_drv.c
===================================================================
--- linux.orig/drivers/char/drm/tdfx_drv.c
+++ linux/drivers/char/drm/tdfx_drv.c
@@ -51,7 +51,7 @@ static struct drm_driver driver = {
.ioctl = drm_ioctl,
.mmap = drm_mmap,
.poll = drm_poll,
- .fasync = drm_fasync,
+ .unlocked_fasync = drm_fasync,
},
.pci_driver = {
.name = DRIVER_NAME,
Index: linux/drivers/char/drm/via_drv.c
===================================================================
--- linux.orig/drivers/char/drm/via_drv.c
+++ linux/drivers/char/drm/via_drv.c
@@ -67,7 +67,7 @@ static struct drm_driver driver = {
.ioctl = drm_ioctl,
.mmap = drm_mmap,
.poll = drm_poll,
- .fasync = drm_fasync,
+ .unlocked_fasync = drm_fasync,
},
.pci_driver = {
.name = DRIVER_NAME,
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH] [8/11] Use unlocked_fasync in random.c
2008-05-19 12:31 [PATCH] [0/11] Repost of old VFS BKL patchkit Andi Kleen
` (6 preceding siblings ...)
2008-05-19 12:31 ` [PATCH] [7/11] Convert DRM " Andi Kleen
@ 2008-05-19 12:31 ` Andi Kleen
2008-05-19 12:31 ` [PATCH] [9/11] Convert hpet to unlocked_fasync Andi Kleen
` (2 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 12:31 UTC (permalink / raw)
To: mpm, corbet, linux-kernel
Just uses fasync_helper which does its own locking
Cc: mpm@selenic.com
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Index: linux/drivers/char/random.c
===================================================================
--- linux.orig/drivers/char/random.c
+++ linux/drivers/char/random.c
@@ -1121,7 +1121,7 @@ const struct file_operations random_fops
.write = random_write,
.poll = random_poll,
.unlocked_ioctl = random_ioctl,
- .fasync = random_fasync,
+ .unlocked_fasync = random_fasync,
.release = random_release,
};
@@ -1129,7 +1129,7 @@ const struct file_operations urandom_fop
.read = urandom_read,
.write = random_write,
.unlocked_ioctl = random_ioctl,
- .fasync = random_fasync,
+ .unlocked_fasync = random_fasync,
.release = random_release,
};
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH] [9/11] Convert hpet to unlocked_fasync
2008-05-19 12:31 [PATCH] [0/11] Repost of old VFS BKL patchkit Andi Kleen
` (7 preceding siblings ...)
2008-05-19 12:31 ` [PATCH] [8/11] Use unlocked_fasync in random.c Andi Kleen
@ 2008-05-19 12:31 ` Andi Kleen
2008-05-19 12:31 ` [PATCH] [10/11] Use unlocked_fasync in RTC Andi Kleen
2008-05-19 12:31 ` [PATCH] [11/11] Convert uio to fasync_unlocked Andi Kleen
10 siblings, 0 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 12:31 UTC (permalink / raw)
To: clemens, corbet, linux-kernel
Just calls fasync_helper and private structure is protected by
file reference count.
Cc: clemens@ladisch.de
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Index: linux/drivers/char/hpet.c
===================================================================
--- linux.orig/drivers/char/hpet.c
+++ linux/drivers/char/hpet.c
@@ -585,7 +585,7 @@ static const struct file_operations hpet
.ioctl = hpet_ioctl,
.open = hpet_open,
.release = hpet_release,
- .fasync = hpet_fasync,
+ .unlocked_fasync = hpet_fasync,
.mmap = hpet_mmap,
};
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH] [10/11] Use unlocked_fasync in RTC
2008-05-19 12:31 [PATCH] [0/11] Repost of old VFS BKL patchkit Andi Kleen
` (8 preceding siblings ...)
2008-05-19 12:31 ` [PATCH] [9/11] Convert hpet to unlocked_fasync Andi Kleen
@ 2008-05-19 12:31 ` Andi Kleen
2008-05-19 12:31 ` [PATCH] [11/11] Convert uio to fasync_unlocked Andi Kleen
10 siblings, 0 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 12:31 UTC (permalink / raw)
To: corbet, linux-kernel
Just uses fasync_helper
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Index: linux/drivers/char/rtc.c
===================================================================
--- linux.orig/drivers/char/rtc.c
+++ linux/drivers/char/rtc.c
@@ -913,7 +913,7 @@ static const struct file_operations rtc_
.ioctl = rtc_ioctl,
.open = rtc_open,
.release = rtc_release,
- .fasync = rtc_fasync,
+ .unlocked_fasync = rtc_fasync,
};
static struct miscdevice rtc_dev = {
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH] [11/11] Convert uio to fasync_unlocked
2008-05-19 12:31 [PATCH] [0/11] Repost of old VFS BKL patchkit Andi Kleen
` (9 preceding siblings ...)
2008-05-19 12:31 ` [PATCH] [10/11] Use unlocked_fasync in RTC Andi Kleen
@ 2008-05-19 12:31 ` Andi Kleen
2008-05-19 12:48 ` Andi Kleen
10 siblings, 1 reply; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 12:31 UTC (permalink / raw)
To: hjk, corbet, linux-kernel
Just calls fasync_helper
Cc: hjk@linutronix.de
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [11/11] Convert uio to fasync_unlocked
2008-05-19 12:31 ` [PATCH] [11/11] Convert uio to fasync_unlocked Andi Kleen
@ 2008-05-19 12:48 ` Andi Kleen
2008-05-19 13:30 ` Hans J. Koch
0 siblings, 1 reply; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 12:48 UTC (permalink / raw)
To: hjk; +Cc: corbet, linux-kernel
Andi Kleen <andi@firstfloor.org> writes:
> Just calls fasync_helper
>
> Cc: hjk@linutronix.de
Sorry that one was missing a quilt refresh. Here's the real patch.
Not very exciting.
-Andi
---
Convert uio to fasync_unlocked
Just calls fasync_helper
Cc: hjk@linutronix.de
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Index: linux/drivers/uio/uio.c
===================================================================
--- linux.orig/drivers/uio/uio.c
+++ linux/drivers/uio/uio.c
@@ -541,7 +541,7 @@ static const struct file_operations uio_
.read = uio_read,
.mmap = uio_mmap,
.poll = uio_poll,
- .fasync = uio_fasync,
+ .unlocked_fasync = uio_fasync,
};
static int uio_major_init(void)
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [11/11] Convert uio to fasync_unlocked
2008-05-19 12:48 ` Andi Kleen
@ 2008-05-19 13:30 ` Hans J. Koch
0 siblings, 0 replies; 26+ messages in thread
From: Hans J. Koch @ 2008-05-19 13:30 UTC (permalink / raw)
To: Andi Kleen; +Cc: hjk, corbet, linux-kernel, gregkh
On Mon, May 19, 2008 at 02:48:32PM +0200, Andi Kleen wrote:
> Andi Kleen <andi@firstfloor.org> writes:
>
> > Just calls fasync_helper
> >
> > Cc: hjk@linutronix.de
>
> Sorry that one was missing a quilt refresh. Here's the real patch.
> Not very exciting.
Patch looks alright to me, but Greg KH should be cc'ed for UIO patches
as well.
>
> -Andi
>
> ---
>
> Convert uio to fasync_unlocked
>
> Just calls fasync_helper
>
> Cc: hjk@linutronix.de
Cc: gregkh@suse.de
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Hans J. Koch <hjk@linutronix.de>
>
> Index: linux/drivers/uio/uio.c
> ===================================================================
> --- linux.orig/drivers/uio/uio.c
> +++ linux/drivers/uio/uio.c
> @@ -541,7 +541,7 @@ static const struct file_operations uio_
> .read = uio_read,
> .mmap = uio_mmap,
> .poll = uio_poll,
> - .fasync = uio_fasync,
> + .unlocked_fasync = uio_fasync,
> };
>
> static int uio_major_init(void)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [1/11] Remove BKL from remote_llseek
2008-05-19 12:31 ` [PATCH] [1/11] Remove BKL from remote_llseek Andi Kleen
@ 2008-05-19 13:58 ` Trond Myklebust
2008-05-19 14:41 ` Andi Kleen
2008-05-19 14:02 ` Christoph Hellwig
2008-05-19 16:09 ` Steve French
2 siblings, 1 reply; 26+ messages in thread
From: Trond Myklebust @ 2008-05-19 13:58 UTC (permalink / raw)
To: Andi Kleen; +Cc: swhiteho, sfrench, vandrove, corbet, linux-kernel
On Mon, 2008-05-19 at 14:31 +0200, Andi Kleen wrote:
> - 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.
>
> Open problem: 32bit kernels can corrupt fpos because its modification
> is not atomic, but they can do that anyways because there's other paths who
> modify it without BKL.
>
> 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>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
>
> ---
> 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
> @@ -581,7 +581,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);
> }
>
> 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
> @@ -62,11 +62,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)
> {
> loff_t 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
> @@ -1871,7 +1871,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
> @@ -170,6 +170,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;
> @@ -177,7 +178,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;
The NFS client shouldn't need any special locking around remote_llseek()
beyond whatever is required at the VFS level.
The one case in nfs_file_llseek() where we might care is the call to
nfs_revalidate_file_size() ('cos I still haven't finished auditing BKL
dependencies in the inode attributes). However that case should already
be covered without introducing any new lock_kernel/unlock_kernel calls
since __nfs_revalidate_inode() already grabs the BKL.
Cheers
Trond
--
Trond Myklebust
Linux NFS client maintainer
NetApp
Trond.Myklebust@netapp.com
www.netapp.com
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [1/11] Remove BKL from remote_llseek
2008-05-19 12:31 ` [PATCH] [1/11] Remove BKL from remote_llseek Andi Kleen
2008-05-19 13:58 ` Trond Myklebust
@ 2008-05-19 14:02 ` Christoph Hellwig
2008-05-19 15:13 ` Andi Kleen
2008-05-19 16:09 ` Steve French
2 siblings, 1 reply; 26+ messages in thread
From: Christoph Hellwig @ 2008-05-19 14:02 UTC (permalink / raw)
To: Andi Kleen
Cc: Trond.Myklebust, swhiteho, sfrench, vandrove, corbet,
linux-kernel
On Mon, May 19, 2008 at 02:31:10PM +0200, Andi Kleen wrote:
>
> - 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.
Good idea, but it could be done a little bit nicer still.
Your new remote_llseek_unlocked is the same as generic_file_llseek
except for the fact that it doesn't take i_mutex. So I'd rather
call it generic_file_llseek_nolock and make generic_file_llseek call
it. While you're at it you could also add some kerneldoc documents
describing them.
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [2/11] Add unlocked_fasync
2008-05-19 12:31 ` [PATCH] [2/11] Add unlocked_fasync Andi Kleen
@ 2008-05-19 14:03 ` Christoph Hellwig
2008-05-19 14:43 ` Andi Kleen
2008-05-19 17:29 ` Randy Dunlap
1 sibling, 1 reply; 26+ messages in thread
From: Christoph Hellwig @ 2008-05-19 14:03 UTC (permalink / raw)
To: Andi Kleen; +Cc: corbet, linux-kernel
On Mon, May 19, 2008 at 02:31:11PM +0200, Andi Kleen wrote:
>
> Add a new fops entry point to allow fasync without BKL. While it's arguably
> unclear this entry point is called often enough for it really matters
> it was still relatively easy to do. And there are far less async users
> in the tree than ioctls so it's likely they can be all converted
> eventually and then the non unlocked async entry point could be dropped.
>
> There was still the problem of the actual flags change being
> protected against other setters of flags. Instead of using BKL
> for this use the i_mutex now.
>
> I also added a mutex_lock against one other flags change
> that was lockless and could potentially lose updates.
>
> There are a couple of potential problems I added comments about on.
I'd rather do a properly flag day and move lock_kernel into the
instances instead of adding this _unlocked gunk.
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [1/11] Remove BKL from remote_llseek
2008-05-19 13:58 ` Trond Myklebust
@ 2008-05-19 14:41 ` Andi Kleen
0 siblings, 0 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 14:41 UTC (permalink / raw)
To: Trond Myklebust; +Cc: swhiteho, sfrench, vandrove, corbet, linux-kernel
> The one case in nfs_file_llseek() where we might care is the call to
> nfs_revalidate_file_size() ('cos I still haven't finished auditing BKL
> dependencies in the inode attributes). However that case should already
> be covered without introducing any new lock_kernel/unlock_kernel calls
> since __nfs_revalidate_inode() already grabs the BKL.
Thanks. I'll keep it for now with the explicit lock_kernel() and when you're
finished your audit and the patches are in before you can just remove them
yourself. I guess that's the best way to handle it.
-Andi
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [2/11] Add unlocked_fasync
2008-05-19 14:03 ` Christoph Hellwig
@ 2008-05-19 14:43 ` Andi Kleen
2008-05-19 15:12 ` Alan Cox
0 siblings, 1 reply; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 14:43 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: corbet, linux-kernel
> I'd rather do a properly flag day and move lock_kernel into the
> instances instead of adding this _unlocked gunk.
I've considered that, but it's a bit too many fasync instances
all over the tree, so I chose this method.
-Andi
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [2/11] Add unlocked_fasync
2008-05-19 14:43 ` Andi Kleen
@ 2008-05-19 15:12 ` Alan Cox
2008-05-19 15:29 ` Andi Kleen
0 siblings, 1 reply; 26+ messages in thread
From: Alan Cox @ 2008-05-19 15:12 UTC (permalink / raw)
To: Andi Kleen; +Cc: Christoph Hellwig, corbet, linux-kernel
On Mon, 19 May 2008 16:43:05 +0200
Andi Kleen <andi@firstfloor.org> wrote:
>
> > I'd rather do a properly flag day and move lock_kernel into the
> > instances instead of adding this _unlocked gunk.
>
> I've considered that, but it's a bit too many fasync instances
> all over the tree, so I chose this method.
If I can do all the watchdog drivers in one go then we can do all the
fasync interfaces in one go. It isn't that hard other than making sure
people didn't hide them in odd places on platforms not usually built.
Alan
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [1/11] Remove BKL from remote_llseek
2008-05-19 14:02 ` Christoph Hellwig
@ 2008-05-19 15:13 ` Andi Kleen
0 siblings, 0 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 15:13 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Trond.Myklebust, swhiteho, sfrench, vandrove, corbet,
linux-kernel
> Your new remote_llseek_unlocked is the same as generic_file_llseek
> except for the fact that it doesn't take i_mutex. So I'd rather
> call it generic_file_llseek_nolock and make generic_file_llseek call
> it.
Done. There's also default_llseek btw which is nearly similar,
but i didn't touch that one.
> While you're at it you could also add some kerneldoc documents
> describing them.
Off topic for the series, left that to someone else.
-Andi
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [2/11] Add unlocked_fasync
2008-05-19 15:29 ` Andi Kleen
@ 2008-05-19 15:22 ` Alan Cox
2008-05-19 15:45 ` Andi Kleen
0 siblings, 1 reply; 26+ messages in thread
From: Alan Cox @ 2008-05-19 15:22 UTC (permalink / raw)
To: Andi Kleen; +Cc: Christoph Hellwig, corbet, linux-kernel
> The good news is that none of them I looked at actually needed BKL
> (or perhaps I just missed it)
Far better to send an initial patch that simply adds all the lock/unlocks
then remove them later than worry about it immediately - that makes it
easier to verify changes and to do testing
Alan
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [2/11] Add unlocked_fasync
2008-05-19 15:12 ` Alan Cox
@ 2008-05-19 15:29 ` Andi Kleen
2008-05-19 15:22 ` Alan Cox
0 siblings, 1 reply; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 15:29 UTC (permalink / raw)
To: Alan Cox; +Cc: Christoph Hellwig, corbet, linux-kernel
Alan Cox wrote:
> On Mon, 19 May 2008 16:43:05 +0200
> Andi Kleen <andi@firstfloor.org> wrote:
>
>>> I'd rather do a properly flag day and move lock_kernel into the
>>> instances instead of adding this _unlocked gunk.
>> I've considered that, but it's a bit too many fasync instances
>> all over the tree, so I chose this method.
>
> If I can do all the watchdog drivers in one go then we can do all the
> fasync interfaces in one go. It isn't that hard other than making sure
> people didn't hide them in odd places on platforms not usually built.
If it's that easy for you please audit the ones then I didn't cover yet and send
me a list.
The good news is that none of them I looked at actually needed BKL
(or perhaps I just missed it)
-Andi
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [2/11] Add unlocked_fasync
2008-05-19 15:22 ` Alan Cox
@ 2008-05-19 15:45 ` Andi Kleen
0 siblings, 0 replies; 26+ messages in thread
From: Andi Kleen @ 2008-05-19 15:45 UTC (permalink / raw)
To: Alan Cox; +Cc: Christoph Hellwig, corbet, linux-kernel
Alan Cox wrote:
>> The good news is that none of them I looked at actually needed BKL
>> (or perhaps I just missed it)
>
> Far better to send an initial patch that simply adds all the lock/unlocks
> then remove them later than worry about it immediately - that makes it
> easier to verify changes and to do testing
I fail to see how that makes it easier than with ->fasync_unlocked.
-Andi
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [1/11] Remove BKL from remote_llseek
2008-05-19 12:31 ` [PATCH] [1/11] Remove BKL from remote_llseek Andi Kleen
2008-05-19 13:58 ` Trond Myklebust
2008-05-19 14:02 ` Christoph Hellwig
@ 2008-05-19 16:09 ` Steve French
2 siblings, 0 replies; 26+ messages in thread
From: Steve French @ 2008-05-19 16:09 UTC (permalink / raw)
To: Andi Kleen
Cc: Trond.Myklebust, swhiteho, sfrench, vandrove, corbet,
linux-kernel
Acked. The cifs change looks fine to me.
On Mon, May 19, 2008 at 7:31 AM, Andi Kleen <andi@firstfloor.org> wrote:
>
> - 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.
>
> Open problem: 32bit kernels can corrupt fpos because its modification
> is not atomic, but they can do that anyways because there's other paths who
> modify it without BKL.
>
> 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>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
>
> ---
> 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
> @@ -581,7 +581,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);
> }
>
> 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
> @@ -62,11 +62,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)
> {
> loff_t 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
> @@ -1871,7 +1871,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
> @@ -170,6 +170,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;
> @@ -177,7 +178,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;
> }
>
> /*
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] [2/11] Add unlocked_fasync
2008-05-19 12:31 ` [PATCH] [2/11] Add unlocked_fasync Andi Kleen
2008-05-19 14:03 ` Christoph Hellwig
@ 2008-05-19 17:29 ` Randy Dunlap
1 sibling, 0 replies; 26+ messages in thread
From: Randy Dunlap @ 2008-05-19 17:29 UTC (permalink / raw)
To: Andi Kleen; +Cc: corbet, linux-kernel
On Mon, 19 May 2008 14:31:11 +0200 (CEST) Andi Kleen wrote:
> Index: linux/Documentation/filesystems/vfs.txt
> ===================================================================
> --- linux.orig/Documentation/filesystems/vfs.txt
> +++ linux/Documentation/filesystems/vfs.txt
> @@ -755,6 +755,7 @@ struct file_operations {
> int (*fsync) (struct file *, struct dentry *, int datasync);
> int (*aio_fsync) (struct kiocb *, int datasync);
> int (*fasync) (int, struct file *, int);
> + int (*unlocked_fasync) (int, struct file *, int);
> int (*lock) (struct file *, int, struct file_lock *);
> ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
> ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
> @@ -814,7 +815,9 @@ otherwise noted.
> fsync: called by the fsync(2) system call
>
> fasync: called by the fcntl(2) system call when asynchronous
> - (non-blocking) mode is enabled for a file
> + (non-blocking) mode is enabled for a file. BKL hold
? BKL is held.
> +
> + unlocked_fasync: like fasync, but without BKL
>
> lock: called by the fcntl(2) system call for F_GETLK, F_SETLK, and F_SETLKW
> commands
---
~Randy
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2008-05-19 17:29 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-19 12:31 [PATCH] [0/11] Repost of old VFS BKL patchkit Andi Kleen
2008-05-19 12:31 ` [PATCH] [1/11] Remove BKL from remote_llseek Andi Kleen
2008-05-19 13:58 ` Trond Myklebust
2008-05-19 14:41 ` Andi Kleen
2008-05-19 14:02 ` Christoph Hellwig
2008-05-19 15:13 ` Andi Kleen
2008-05-19 16:09 ` Steve French
2008-05-19 12:31 ` [PATCH] [2/11] Add unlocked_fasync Andi Kleen
2008-05-19 14:03 ` Christoph Hellwig
2008-05-19 14:43 ` Andi Kleen
2008-05-19 15:12 ` Alan Cox
2008-05-19 15:29 ` Andi Kleen
2008-05-19 15:22 ` Alan Cox
2008-05-19 15:45 ` Andi Kleen
2008-05-19 17:29 ` Randy Dunlap
2008-05-19 12:31 ` [PATCH] [3/11] Convert pipe over to unlocked_fasync Andi Kleen
2008-05-19 12:31 ` [PATCH] [4/11] Convert socket fasync " Andi Kleen
2008-05-19 12:31 ` [PATCH] [5/11] Convert fuse " Andi Kleen
2008-05-19 12:31 ` [PATCH] [6/11] Convert bad_inode " Andi Kleen
2008-05-19 12:31 ` [PATCH] [7/11] Convert DRM " Andi Kleen
2008-05-19 12:31 ` [PATCH] [8/11] Use unlocked_fasync in random.c Andi Kleen
2008-05-19 12:31 ` [PATCH] [9/11] Convert hpet to unlocked_fasync Andi Kleen
2008-05-19 12:31 ` [PATCH] [10/11] Use unlocked_fasync in RTC Andi Kleen
2008-05-19 12:31 ` [PATCH] [11/11] Convert uio to fasync_unlocked Andi Kleen
2008-05-19 12:48 ` Andi Kleen
2008-05-19 13:30 ` Hans J. Koch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox