Commit 81140ca3 authored by Andrew Morton's avatar Andrew Morton Committed by David S. Miller

[PATCH] remove lock_kernel() from readdir implementations.

Filesystems which are using generic_file_llseek() do not need lock_kernel()
in their readir implementations.  All operations (including llseek) are
serialised by the directory's i_sem.

Just fix ext2 and ext3 for now.  Others may need locking between readdir and
who-knows-what.
parent 29580832
...@@ -259,8 +259,6 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir) ...@@ -259,8 +259,6 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
int need_revalidate = (filp->f_version != inode->i_version); int need_revalidate = (filp->f_version != inode->i_version);
int ret = 0; int ret = 0;
lock_kernel();
if (pos > inode->i_size - EXT2_DIR_REC_LEN(1)) if (pos > inode->i_size - EXT2_DIR_REC_LEN(1))
goto done; goto done;
...@@ -313,7 +311,6 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir) ...@@ -313,7 +311,6 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset; filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset;
filp->f_version = inode->i_version; filp->f_version = inode->i_version;
UPDATE_ATIME(inode); UPDATE_ATIME(inode);
unlock_kernel();
return 0; return 0;
} }
...@@ -660,6 +657,7 @@ int ext2_empty_dir (struct inode * inode) ...@@ -660,6 +657,7 @@ int ext2_empty_dir (struct inode * inode)
} }
struct file_operations ext2_dir_operations = { struct file_operations ext2_dir_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir, .read = generic_read_dir,
.readdir = ext2_readdir, .readdir = ext2_readdir,
.ioctl = ext2_ioctl, .ioctl = ext2_ioctl,
......
...@@ -37,10 +37,11 @@ static int ext3_release_dir (struct inode * inode, ...@@ -37,10 +37,11 @@ static int ext3_release_dir (struct inode * inode,
struct file * filp); struct file * filp);
struct file_operations ext3_dir_operations = { struct file_operations ext3_dir_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir, .read = generic_read_dir,
.readdir = ext3_readdir, /* we take BKL. needed?*/ .readdir = ext3_readdir, /* we take BKL. needed?*/
.ioctl = ext3_ioctl, /* BKL held */ .ioctl = ext3_ioctl, /* BKL held */
.fsync = ext3_sync_file, /* BKL held */ .fsync = ext3_sync_file, /* BKL held */
#ifdef CONFIG_EXT3_INDEX #ifdef CONFIG_EXT3_INDEX
.release = ext3_release_dir, .release = ext3_release_dir,
#endif #endif
...@@ -98,16 +99,15 @@ static int ext3_readdir(struct file * filp, ...@@ -98,16 +99,15 @@ static int ext3_readdir(struct file * filp,
struct super_block * sb; struct super_block * sb;
int err; int err;
struct inode *inode = filp->f_dentry->d_inode; struct inode *inode = filp->f_dentry->d_inode;
int ret = 0;
lock_kernel();
sb = inode->i_sb; sb = inode->i_sb;
if (is_dx(inode)) { if (is_dx(inode)) {
err = ext3_dx_readdir(filp, dirent, filldir); err = ext3_dx_readdir(filp, dirent, filldir);
if (err != ERR_BAD_DX_DIR) { if (err != ERR_BAD_DX_DIR) {
unlock_kernel(); ret = err;
return err; goto out;
} }
/* /*
* We don't set the inode dirty flag since it's not * We don't set the inode dirty flag since it's not
...@@ -186,8 +186,8 @@ static int ext3_readdir(struct file * filp, ...@@ -186,8 +186,8 @@ static int ext3_readdir(struct file * filp,
filp->f_pos = (filp->f_pos | filp->f_pos = (filp->f_pos |
(sb->s_blocksize - 1)) + 1; (sb->s_blocksize - 1)) + 1;
brelse (bh); brelse (bh);
unlock_kernel(); ret = stored;
return stored; goto out;
} }
offset += le16_to_cpu(de->rec_len); offset += le16_to_cpu(de->rec_len);
if (le32_to_cpu(de->inode)) { if (le32_to_cpu(de->inode)) {
...@@ -217,8 +217,8 @@ static int ext3_readdir(struct file * filp, ...@@ -217,8 +217,8 @@ static int ext3_readdir(struct file * filp,
brelse (bh); brelse (bh);
} }
UPDATE_ATIME(inode); UPDATE_ATIME(inode);
unlock_kernel(); out:
return 0; return ret;
} }
#ifdef CONFIG_EXT3_INDEX #ifdef CONFIG_EXT3_INDEX
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment