Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs/: do not fallback to default_llseek() when readdir() uses BKL

Do not use the fallback default_llseek() if the readdir operation of the
filesystem still uses the big kernel lock.

Since llseek() modifies
file->f_pos of the directory directly it may need locking to not confuse
readdir which usually uses file->f_pos directly as well

Since the special characteristics of the BKL (unlocked on schedule) are
not necessary in this case, the inode mutex can be used for locking as
provided by generic_file_llseek(). This is only possible since all
filesystems, except reiserfs, either use a directory as a flat file or
with disk address offsets. Reiserfs on the other hand uses a 32bit hash
off the filename as the offset so generic_file_llseek() can get used as
well since the hash is always smaller than sb->s_maxbytes (= (512 << 32) -
blocksize).

Signed-off-by: Jan Blunck <jblunck@suse.de>
Acked-by: Jan Kara <jack@suse.cz>
Acked-by: Anders Larsen <al@alarsen.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

jan Blunck and committed by
Linus Torvalds
ca572727 b4d878e2

+9
+1
fs/autofs/root.c
··· 28 28 static int autofs_root_ioctl(struct inode *, struct file *,unsigned int,unsigned long); 29 29 30 30 const struct file_operations autofs_root_operations = { 31 + .llseek = generic_file_llseek, 31 32 .read = generic_read_dir, 32 33 .readdir = autofs_root_readdir, 33 34 .ioctl = autofs_root_ioctl,
+2
fs/freevxfs/vxfs_lookup.c
··· 57 57 }; 58 58 59 59 const struct file_operations vxfs_dir_operations = { 60 + .llseek = generic_file_llseek, 61 + .read = generic_read_dir, 60 62 .readdir = vxfs_readdir, 61 63 }; 62 64
+1
fs/isofs/dir.c
··· 272 272 273 273 const struct file_operations isofs_dir_operations = 274 274 { 275 + .llseek = generic_file_llseek, 275 276 .read = generic_read_dir, 276 277 .readdir = isofs_readdir, 277 278 };
+1
fs/ncpfs/dir.c
··· 49 49 50 50 const struct file_operations ncp_dir_operations = 51 51 { 52 + .llseek = generic_file_llseek, 52 53 .read = generic_read_dir, 53 54 .readdir = ncp_readdir, 54 55 .unlocked_ioctl = ncp_ioctl,
+1
fs/qnx4/dir.c
··· 77 77 78 78 const struct file_operations qnx4_dir_operations = 79 79 { 80 + .llseek = generic_file_llseek, 80 81 .read = generic_read_dir, 81 82 .readdir = qnx4_readdir, 82 83 .fsync = simple_fsync,
+1
fs/reiserfs/dir.c
··· 18 18 int datasync); 19 19 20 20 const struct file_operations reiserfs_dir_operations = { 21 + .llseek = generic_file_llseek, 21 22 .read = generic_read_dir, 22 23 .readdir = reiserfs_readdir, 23 24 .fsync = reiserfs_dir_fsync,
+1
fs/smbfs/dir.c
··· 37 37 38 38 const struct file_operations smb_dir_operations = 39 39 { 40 + .llseek = generic_file_llseek, 40 41 .read = generic_read_dir, 41 42 .readdir = smb_readdir, 42 43 .unlocked_ioctl = smb_ioctl,
+1
fs/udf/dir.c
··· 207 207 208 208 /* readdir and lookup functions */ 209 209 const struct file_operations udf_dir_operations = { 210 + .llseek = generic_file_llseek, 210 211 .read = generic_read_dir, 211 212 .readdir = udf_readdir, 212 213 .unlocked_ioctl = udf_ioctl,