diff options
Diffstat (limited to 'fs')
253 files changed, 4379 insertions, 3722 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 22f7ccd58d38..0f628041e3f7 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c | |||
@@ -460,8 +460,10 @@ static int __init init_v9fs(void) | |||
460 | 460 | ||
461 | ret = v9fs_mux_global_init(); | 461 | ret = v9fs_mux_global_init(); |
462 | if (!ret) | 462 | if (!ret) |
463 | ret = register_filesystem(&v9fs_fs_type); | 463 | return ret; |
464 | 464 | ret = register_filesystem(&v9fs_fs_type); | |
465 | if (!ret) | ||
466 | v9fs_mux_global_exit(); | ||
465 | return ret; | 467 | return ret; |
466 | } | 468 | } |
467 | 469 | ||
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 7a7ec2d1d2f4..5241c600ce28 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -233,7 +233,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) | |||
233 | inode->i_op = &v9fs_symlink_inode_operations; | 233 | inode->i_op = &v9fs_symlink_inode_operations; |
234 | break; | 234 | break; |
235 | case S_IFDIR: | 235 | case S_IFDIR: |
236 | inode->i_nlink++; | 236 | inc_nlink(inode); |
237 | if(v9ses->extended) | 237 | if(v9ses->extended) |
238 | inode->i_op = &v9fs_dir_inode_operations_ext; | 238 | inode->i_op = &v9fs_dir_inode_operations_ext; |
239 | else | 239 | else |
diff --git a/fs/Kconfig b/fs/Kconfig index c968b9c7e581..fa64867d6ed6 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
@@ -4,6 +4,8 @@ | |||
4 | 4 | ||
5 | menu "File systems" | 5 | menu "File systems" |
6 | 6 | ||
7 | if BLOCK | ||
8 | |||
7 | config EXT2_FS | 9 | config EXT2_FS |
8 | tristate "Second extended fs support" | 10 | tristate "Second extended fs support" |
9 | help | 11 | help |
@@ -400,6 +402,8 @@ config ROMFS_FS | |||
400 | If you don't know whether you need it, then you don't need it: | 402 | If you don't know whether you need it, then you don't need it: |
401 | answer N. | 403 | answer N. |
402 | 404 | ||
405 | endif | ||
406 | |||
403 | config INOTIFY | 407 | config INOTIFY |
404 | bool "Inotify file change notification support" | 408 | bool "Inotify file change notification support" |
405 | default y | 409 | default y |
@@ -531,6 +535,7 @@ config FUSE_FS | |||
531 | If you want to develop a userspace FS, or if you want to use | 535 | If you want to develop a userspace FS, or if you want to use |
532 | a filesystem based on FUSE, answer Y or M. | 536 | a filesystem based on FUSE, answer Y or M. |
533 | 537 | ||
538 | if BLOCK | ||
534 | menu "CD-ROM/DVD Filesystems" | 539 | menu "CD-ROM/DVD Filesystems" |
535 | 540 | ||
536 | config ISO9660_FS | 541 | config ISO9660_FS |
@@ -598,7 +603,9 @@ config UDF_NLS | |||
598 | depends on (UDF_FS=m && NLS) || (UDF_FS=y && NLS=y) | 603 | depends on (UDF_FS=m && NLS) || (UDF_FS=y && NLS=y) |
599 | 604 | ||
600 | endmenu | 605 | endmenu |
606 | endif | ||
601 | 607 | ||
608 | if BLOCK | ||
602 | menu "DOS/FAT/NT Filesystems" | 609 | menu "DOS/FAT/NT Filesystems" |
603 | 610 | ||
604 | config FAT_FS | 611 | config FAT_FS |
@@ -783,6 +790,7 @@ config NTFS_RW | |||
783 | It is perfectly safe to say N here. | 790 | It is perfectly safe to say N here. |
784 | 791 | ||
785 | endmenu | 792 | endmenu |
793 | endif | ||
786 | 794 | ||
787 | menu "Pseudo filesystems" | 795 | menu "Pseudo filesystems" |
788 | 796 | ||
@@ -882,6 +890,19 @@ config TMPFS | |||
882 | 890 | ||
883 | See <file:Documentation/filesystems/tmpfs.txt> for details. | 891 | See <file:Documentation/filesystems/tmpfs.txt> for details. |
884 | 892 | ||
893 | config TMPFS_POSIX_ACL | ||
894 | bool "Tmpfs POSIX Access Control Lists" | ||
895 | depends on TMPFS | ||
896 | select GENERIC_ACL | ||
897 | help | ||
898 | POSIX Access Control Lists (ACLs) support permissions for users and | ||
899 | groups beyond the owner/group/world scheme. | ||
900 | |||
901 | To learn more about Access Control Lists, visit the POSIX ACLs for | ||
902 | Linux website <http://acl.bestbits.at/>. | ||
903 | |||
904 | If you don't know what Access Control Lists are, say N. | ||
905 | |||
885 | config HUGETLBFS | 906 | config HUGETLBFS |
886 | bool "HugeTLB file system support" | 907 | bool "HugeTLB file system support" |
887 | depends X86 || IA64 || PPC64 || SPARC64 || SUPERH || BROKEN | 908 | depends X86 || IA64 || PPC64 || SPARC64 || SUPERH || BROKEN |
@@ -927,7 +948,7 @@ menu "Miscellaneous filesystems" | |||
927 | 948 | ||
928 | config ADFS_FS | 949 | config ADFS_FS |
929 | tristate "ADFS file system support (EXPERIMENTAL)" | 950 | tristate "ADFS file system support (EXPERIMENTAL)" |
930 | depends on EXPERIMENTAL | 951 | depends on BLOCK && EXPERIMENTAL |
931 | help | 952 | help |
932 | The Acorn Disc Filing System is the standard file system of the | 953 | The Acorn Disc Filing System is the standard file system of the |
933 | RiscOS operating system which runs on Acorn's ARM-based Risc PC | 954 | RiscOS operating system which runs on Acorn's ARM-based Risc PC |
@@ -955,7 +976,7 @@ config ADFS_FS_RW | |||
955 | 976 | ||
956 | config AFFS_FS | 977 | config AFFS_FS |
957 | tristate "Amiga FFS file system support (EXPERIMENTAL)" | 978 | tristate "Amiga FFS file system support (EXPERIMENTAL)" |
958 | depends on EXPERIMENTAL | 979 | depends on BLOCK && EXPERIMENTAL |
959 | help | 980 | help |
960 | The Fast File System (FFS) is the common file system used on hard | 981 | The Fast File System (FFS) is the common file system used on hard |
961 | disks by Amiga(tm) systems since AmigaOS Version 1.3 (34.20). Say Y | 982 | disks by Amiga(tm) systems since AmigaOS Version 1.3 (34.20). Say Y |
@@ -977,7 +998,7 @@ config AFFS_FS | |||
977 | 998 | ||
978 | config HFS_FS | 999 | config HFS_FS |
979 | tristate "Apple Macintosh file system support (EXPERIMENTAL)" | 1000 | tristate "Apple Macintosh file system support (EXPERIMENTAL)" |
980 | depends on EXPERIMENTAL | 1001 | depends on BLOCK && EXPERIMENTAL |
981 | select NLS | 1002 | select NLS |
982 | help | 1003 | help |
983 | If you say Y here, you will be able to mount Macintosh-formatted | 1004 | If you say Y here, you will be able to mount Macintosh-formatted |
@@ -990,6 +1011,7 @@ config HFS_FS | |||
990 | 1011 | ||
991 | config HFSPLUS_FS | 1012 | config HFSPLUS_FS |
992 | tristate "Apple Extended HFS file system support" | 1013 | tristate "Apple Extended HFS file system support" |
1014 | depends on BLOCK | ||
993 | select NLS | 1015 | select NLS |
994 | select NLS_UTF8 | 1016 | select NLS_UTF8 |
995 | help | 1017 | help |
@@ -1003,7 +1025,7 @@ config HFSPLUS_FS | |||
1003 | 1025 | ||
1004 | config BEFS_FS | 1026 | config BEFS_FS |
1005 | tristate "BeOS file system (BeFS) support (read only) (EXPERIMENTAL)" | 1027 | tristate "BeOS file system (BeFS) support (read only) (EXPERIMENTAL)" |
1006 | depends on EXPERIMENTAL | 1028 | depends on BLOCK && EXPERIMENTAL |
1007 | select NLS | 1029 | select NLS |
1008 | help | 1030 | help |
1009 | The BeOS File System (BeFS) is the native file system of Be, Inc's | 1031 | The BeOS File System (BeFS) is the native file system of Be, Inc's |
@@ -1030,7 +1052,7 @@ config BEFS_DEBUG | |||
1030 | 1052 | ||
1031 | config BFS_FS | 1053 | config BFS_FS |
1032 | tristate "BFS file system support (EXPERIMENTAL)" | 1054 | tristate "BFS file system support (EXPERIMENTAL)" |
1033 | depends on EXPERIMENTAL | 1055 | depends on BLOCK && EXPERIMENTAL |
1034 | help | 1056 | help |
1035 | Boot File System (BFS) is a file system used under SCO UnixWare to | 1057 | Boot File System (BFS) is a file system used under SCO UnixWare to |
1036 | allow the bootloader access to the kernel image and other important | 1058 | allow the bootloader access to the kernel image and other important |
@@ -1052,7 +1074,7 @@ config BFS_FS | |||
1052 | 1074 | ||
1053 | config EFS_FS | 1075 | config EFS_FS |
1054 | tristate "EFS file system support (read only) (EXPERIMENTAL)" | 1076 | tristate "EFS file system support (read only) (EXPERIMENTAL)" |
1055 | depends on EXPERIMENTAL | 1077 | depends on BLOCK && EXPERIMENTAL |
1056 | help | 1078 | help |
1057 | EFS is an older file system used for non-ISO9660 CD-ROMs and hard | 1079 | EFS is an older file system used for non-ISO9660 CD-ROMs and hard |
1058 | disk partitions by SGI's IRIX operating system (IRIX 6.0 and newer | 1080 | disk partitions by SGI's IRIX operating system (IRIX 6.0 and newer |
@@ -1067,7 +1089,7 @@ config EFS_FS | |||
1067 | 1089 | ||
1068 | config JFFS_FS | 1090 | config JFFS_FS |
1069 | tristate "Journalling Flash File System (JFFS) support" | 1091 | tristate "Journalling Flash File System (JFFS) support" |
1070 | depends on MTD | 1092 | depends on MTD && BLOCK |
1071 | help | 1093 | help |
1072 | JFFS is the Journaling Flash File System developed by Axis | 1094 | JFFS is the Journaling Flash File System developed by Axis |
1073 | Communications in Sweden, aimed at providing a crash/powerdown-safe | 1095 | Communications in Sweden, aimed at providing a crash/powerdown-safe |
@@ -1252,6 +1274,7 @@ endchoice | |||
1252 | 1274 | ||
1253 | config CRAMFS | 1275 | config CRAMFS |
1254 | tristate "Compressed ROM file system support (cramfs)" | 1276 | tristate "Compressed ROM file system support (cramfs)" |
1277 | depends on BLOCK | ||
1255 | select ZLIB_INFLATE | 1278 | select ZLIB_INFLATE |
1256 | help | 1279 | help |
1257 | Saying Y here includes support for CramFs (Compressed ROM File | 1280 | Saying Y here includes support for CramFs (Compressed ROM File |
@@ -1271,6 +1294,7 @@ config CRAMFS | |||
1271 | 1294 | ||
1272 | config VXFS_FS | 1295 | config VXFS_FS |
1273 | tristate "FreeVxFS file system support (VERITAS VxFS(TM) compatible)" | 1296 | tristate "FreeVxFS file system support (VERITAS VxFS(TM) compatible)" |
1297 | depends on BLOCK | ||
1274 | help | 1298 | help |
1275 | FreeVxFS is a file system driver that support the VERITAS VxFS(TM) | 1299 | FreeVxFS is a file system driver that support the VERITAS VxFS(TM) |
1276 | file system format. VERITAS VxFS(TM) is the standard file system | 1300 | file system format. VERITAS VxFS(TM) is the standard file system |
@@ -1288,6 +1312,7 @@ config VXFS_FS | |||
1288 | 1312 | ||
1289 | config HPFS_FS | 1313 | config HPFS_FS |
1290 | tristate "OS/2 HPFS file system support" | 1314 | tristate "OS/2 HPFS file system support" |
1315 | depends on BLOCK | ||
1291 | help | 1316 | help |
1292 | OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS | 1317 | OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS |
1293 | is the file system used for organizing files on OS/2 hard disk | 1318 | is the file system used for organizing files on OS/2 hard disk |
@@ -1304,6 +1329,7 @@ config HPFS_FS | |||
1304 | 1329 | ||
1305 | config QNX4FS_FS | 1330 | config QNX4FS_FS |
1306 | tristate "QNX4 file system support (read only)" | 1331 | tristate "QNX4 file system support (read only)" |
1332 | depends on BLOCK | ||
1307 | help | 1333 | help |
1308 | This is the file system used by the real-time operating systems | 1334 | This is the file system used by the real-time operating systems |
1309 | QNX 4 and QNX 6 (the latter is also called QNX RTP). | 1335 | QNX 4 and QNX 6 (the latter is also called QNX RTP). |
@@ -1331,6 +1357,7 @@ config QNX4FS_RW | |||
1331 | 1357 | ||
1332 | config SYSV_FS | 1358 | config SYSV_FS |
1333 | tristate "System V/Xenix/V7/Coherent file system support" | 1359 | tristate "System V/Xenix/V7/Coherent file system support" |
1360 | depends on BLOCK | ||
1334 | help | 1361 | help |
1335 | SCO, Xenix and Coherent are commercial Unix systems for Intel | 1362 | SCO, Xenix and Coherent are commercial Unix systems for Intel |
1336 | machines, and Version 7 was used on the DEC PDP-11. Saying Y | 1363 | machines, and Version 7 was used on the DEC PDP-11. Saying Y |
@@ -1369,6 +1396,7 @@ config SYSV_FS | |||
1369 | 1396 | ||
1370 | config UFS_FS | 1397 | config UFS_FS |
1371 | tristate "UFS file system support (read only)" | 1398 | tristate "UFS file system support (read only)" |
1399 | depends on BLOCK | ||
1372 | help | 1400 | help |
1373 | BSD and derivate versions of Unix (such as SunOS, FreeBSD, NetBSD, | 1401 | BSD and derivate versions of Unix (such as SunOS, FreeBSD, NetBSD, |
1374 | OpenBSD and NeXTstep) use a file system called UFS. Some System V | 1402 | OpenBSD and NeXTstep) use a file system called UFS. Some System V |
@@ -1941,13 +1969,19 @@ config 9P_FS | |||
1941 | 1969 | ||
1942 | If unsure, say N. | 1970 | If unsure, say N. |
1943 | 1971 | ||
1972 | config GENERIC_ACL | ||
1973 | bool | ||
1974 | select FS_POSIX_ACL | ||
1975 | |||
1944 | endmenu | 1976 | endmenu |
1945 | 1977 | ||
1978 | if BLOCK | ||
1946 | menu "Partition Types" | 1979 | menu "Partition Types" |
1947 | 1980 | ||
1948 | source "fs/partitions/Kconfig" | 1981 | source "fs/partitions/Kconfig" |
1949 | 1982 | ||
1950 | endmenu | 1983 | endmenu |
1984 | endif | ||
1951 | 1985 | ||
1952 | source "fs/nls/Kconfig" | 1986 | source "fs/nls/Kconfig" |
1953 | source "fs/dlm/Kconfig" | 1987 | source "fs/dlm/Kconfig" |
diff --git a/fs/Makefile b/fs/Makefile index 64df11047ccc..215f70378177 100644 --- a/fs/Makefile +++ b/fs/Makefile | |||
@@ -5,12 +5,18 @@ | |||
5 | # Rewritten to use lists instead of if-statements. | 5 | # Rewritten to use lists instead of if-statements. |
6 | # | 6 | # |
7 | 7 | ||
8 | obj-y := open.o read_write.o file_table.o buffer.o bio.o super.o \ | 8 | obj-y := open.o read_write.o file_table.o super.o \ |
9 | block_dev.o char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \ | 9 | char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \ |
10 | ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \ | 10 | ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \ |
11 | attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ | 11 | attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ |
12 | seq_file.o xattr.o libfs.o fs-writeback.o mpage.o direct-io.o \ | 12 | seq_file.o xattr.o libfs.o fs-writeback.o \ |
13 | ioprio.o pnode.o drop_caches.o splice.o sync.o | 13 | pnode.o drop_caches.o splice.o sync.o utimes.o |
14 | |||
15 | ifeq ($(CONFIG_BLOCK),y) | ||
16 | obj-y += buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o | ||
17 | else | ||
18 | obj-y += no-block.o | ||
19 | endif | ||
14 | 20 | ||
15 | obj-$(CONFIG_INOTIFY) += inotify.o | 21 | obj-$(CONFIG_INOTIFY) += inotify.o |
16 | obj-$(CONFIG_INOTIFY_USER) += inotify_user.o | 22 | obj-$(CONFIG_INOTIFY_USER) += inotify_user.o |
@@ -35,6 +41,7 @@ obj-$(CONFIG_BINFMT_FLAT) += binfmt_flat.o | |||
35 | obj-$(CONFIG_FS_MBCACHE) += mbcache.o | 41 | obj-$(CONFIG_FS_MBCACHE) += mbcache.o |
36 | obj-$(CONFIG_FS_POSIX_ACL) += posix_acl.o xattr_acl.o | 42 | obj-$(CONFIG_FS_POSIX_ACL) += posix_acl.o xattr_acl.o |
37 | obj-$(CONFIG_NFS_COMMON) += nfs_common/ | 43 | obj-$(CONFIG_NFS_COMMON) += nfs_common/ |
44 | obj-$(CONFIG_GENERIC_ACL) += generic_acl.o | ||
38 | 45 | ||
39 | obj-$(CONFIG_QUOTA) += dquot.o | 46 | obj-$(CONFIG_QUOTA) += dquot.o |
40 | obj-$(CONFIG_QFMT_V1) += quota_v1.o | 47 | obj-$(CONFIG_QFMT_V1) += quota_v1.o |
diff --git a/fs/adfs/file.c b/fs/adfs/file.c index 1014b9f2117b..6101ea679cb1 100644 --- a/fs/adfs/file.c +++ b/fs/adfs/file.c | |||
@@ -27,10 +27,12 @@ | |||
27 | 27 | ||
28 | const struct file_operations adfs_file_operations = { | 28 | const struct file_operations adfs_file_operations = { |
29 | .llseek = generic_file_llseek, | 29 | .llseek = generic_file_llseek, |
30 | .read = generic_file_read, | 30 | .read = do_sync_read, |
31 | .aio_read = generic_file_aio_read, | ||
31 | .mmap = generic_file_mmap, | 32 | .mmap = generic_file_mmap, |
32 | .fsync = file_fsync, | 33 | .fsync = file_fsync, |
33 | .write = generic_file_write, | 34 | .write = do_sync_write, |
35 | .aio_write = generic_file_aio_write, | ||
34 | .sendfile = generic_file_sendfile, | 36 | .sendfile = generic_file_sendfile, |
35 | }; | 37 | }; |
36 | 38 | ||
diff --git a/fs/affs/file.c b/fs/affs/file.c index 3de8590e4f6a..05b5e22de759 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c | |||
@@ -27,8 +27,10 @@ static int affs_file_release(struct inode *inode, struct file *filp); | |||
27 | 27 | ||
28 | const struct file_operations affs_file_operations = { | 28 | const struct file_operations affs_file_operations = { |
29 | .llseek = generic_file_llseek, | 29 | .llseek = generic_file_llseek, |
30 | .read = generic_file_read, | 30 | .read = do_sync_read, |
31 | .write = generic_file_write, | 31 | .aio_read = generic_file_aio_read, |
32 | .write = do_sync_write, | ||
33 | .aio_write = generic_file_aio_write, | ||
32 | .mmap = generic_file_mmap, | 34 | .mmap = generic_file_mmap, |
33 | .open = affs_file_open, | 35 | .open = affs_file_open, |
34 | .release = affs_file_release, | 36 | .release = affs_file_release, |
diff --git a/fs/afs/file.c b/fs/afs/file.c index 67d6634101fd..2e8c42639eaa 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
18 | #include <linux/pagemap.h> | 18 | #include <linux/pagemap.h> |
19 | #include <linux/buffer_head.h> | ||
20 | #include "volume.h" | 19 | #include "volume.h" |
21 | #include "vnode.h" | 20 | #include "vnode.h" |
22 | #include <rxrpc/call.h> | 21 | #include <rxrpc/call.h> |
@@ -37,7 +36,6 @@ struct inode_operations afs_file_inode_operations = { | |||
37 | 36 | ||
38 | const struct address_space_operations afs_fs_aops = { | 37 | const struct address_space_operations afs_fs_aops = { |
39 | .readpage = afs_file_readpage, | 38 | .readpage = afs_file_readpage, |
40 | .sync_page = block_sync_page, | ||
41 | .set_page_dirty = __set_page_dirty_nobuffers, | 39 | .set_page_dirty = __set_page_dirty_nobuffers, |
42 | .releasepage = afs_file_releasepage, | 40 | .releasepage = afs_file_releasepage, |
43 | .invalidatepage = afs_file_invalidatepage, | 41 | .invalidatepage = afs_file_invalidatepage, |
diff --git a/fs/afs/proc.c b/fs/afs/proc.c index 101d21b6c037..86463ec9ccb4 100644 --- a/fs/afs/proc.c +++ b/fs/afs/proc.c | |||
@@ -775,6 +775,7 @@ static int afs_proc_cell_servers_release(struct inode *inode, | |||
775 | * first item | 775 | * first item |
776 | */ | 776 | */ |
777 | static void *afs_proc_cell_servers_start(struct seq_file *m, loff_t *_pos) | 777 | static void *afs_proc_cell_servers_start(struct seq_file *m, loff_t *_pos) |
778 | __acquires(m->private->sv_lock) | ||
778 | { | 779 | { |
779 | struct list_head *_p; | 780 | struct list_head *_p; |
780 | struct afs_cell *cell = m->private; | 781 | struct afs_cell *cell = m->private; |
@@ -823,6 +824,7 @@ static void *afs_proc_cell_servers_next(struct seq_file *p, void *v, | |||
823 | * clean up after reading from the cells list | 824 | * clean up after reading from the cells list |
824 | */ | 825 | */ |
825 | static void afs_proc_cell_servers_stop(struct seq_file *p, void *v) | 826 | static void afs_proc_cell_servers_stop(struct seq_file *p, void *v) |
827 | __releases(p->private->sv_lock) | ||
826 | { | 828 | { |
827 | struct afs_cell *cell = p->private; | 829 | struct afs_cell *cell = p->private; |
828 | 830 | ||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/aio_abi.h> | 15 | #include <linux/aio_abi.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/syscalls.h> | 17 | #include <linux/syscalls.h> |
18 | #include <linux/uio.h> | ||
18 | 19 | ||
19 | #define DEBUG 0 | 20 | #define DEBUG 0 |
20 | 21 | ||
@@ -414,6 +415,7 @@ static struct kiocb fastcall *__aio_get_req(struct kioctx *ctx) | |||
414 | req->ki_retry = NULL; | 415 | req->ki_retry = NULL; |
415 | req->ki_dtor = NULL; | 416 | req->ki_dtor = NULL; |
416 | req->private = NULL; | 417 | req->private = NULL; |
418 | req->ki_iovec = NULL; | ||
417 | INIT_LIST_HEAD(&req->ki_run_list); | 419 | INIT_LIST_HEAD(&req->ki_run_list); |
418 | 420 | ||
419 | /* Check if the completion queue has enough free space to | 421 | /* Check if the completion queue has enough free space to |
@@ -459,6 +461,8 @@ static inline void really_put_req(struct kioctx *ctx, struct kiocb *req) | |||
459 | 461 | ||
460 | if (req->ki_dtor) | 462 | if (req->ki_dtor) |
461 | req->ki_dtor(req); | 463 | req->ki_dtor(req); |
464 | if (req->ki_iovec != &req->ki_inline_vec) | ||
465 | kfree(req->ki_iovec); | ||
462 | kmem_cache_free(kiocb_cachep, req); | 466 | kmem_cache_free(kiocb_cachep, req); |
463 | ctx->reqs_active--; | 467 | ctx->reqs_active--; |
464 | 468 | ||
@@ -1300,63 +1304,63 @@ asmlinkage long sys_io_destroy(aio_context_t ctx) | |||
1300 | return -EINVAL; | 1304 | return -EINVAL; |
1301 | } | 1305 | } |
1302 | 1306 | ||
1303 | /* | 1307 | static void aio_advance_iovec(struct kiocb *iocb, ssize_t ret) |
1304 | * aio_p{read,write} are the default ki_retry methods for | ||
1305 | * IO_CMD_P{READ,WRITE}. They maintains kiocb retry state around potentially | ||
1306 | * multiple calls to f_op->aio_read(). They loop around partial progress | ||
1307 | * instead of returning -EIOCBRETRY because they don't have the means to call | ||
1308 | * kick_iocb(). | ||
1309 | */ | ||
1310 | static ssize_t aio_pread(struct kiocb *iocb) | ||
1311 | { | 1308 | { |
1312 | struct file *file = iocb->ki_filp; | 1309 | struct iovec *iov = &iocb->ki_iovec[iocb->ki_cur_seg]; |
1313 | struct address_space *mapping = file->f_mapping; | 1310 | |
1314 | struct inode *inode = mapping->host; | 1311 | BUG_ON(ret <= 0); |
1315 | ssize_t ret = 0; | 1312 | |
1316 | 1313 | while (iocb->ki_cur_seg < iocb->ki_nr_segs && ret > 0) { | |
1317 | do { | 1314 | ssize_t this = min((ssize_t)iov->iov_len, ret); |
1318 | ret = file->f_op->aio_read(iocb, iocb->ki_buf, | 1315 | iov->iov_base += this; |
1319 | iocb->ki_left, iocb->ki_pos); | 1316 | iov->iov_len -= this; |
1320 | /* | 1317 | iocb->ki_left -= this; |
1321 | * Can't just depend on iocb->ki_left to determine | 1318 | ret -= this; |
1322 | * whether we are done. This may have been a short read. | 1319 | if (iov->iov_len == 0) { |
1323 | */ | 1320 | iocb->ki_cur_seg++; |
1324 | if (ret > 0) { | 1321 | iov++; |
1325 | iocb->ki_buf += ret; | ||
1326 | iocb->ki_left -= ret; | ||
1327 | } | 1322 | } |
1323 | } | ||
1328 | 1324 | ||
1329 | /* | 1325 | /* the caller should not have done more io than what fit in |
1330 | * For pipes and sockets we return once we have some data; for | 1326 | * the remaining iovecs */ |
1331 | * regular files we retry till we complete the entire read or | 1327 | BUG_ON(ret > 0 && iocb->ki_left == 0); |
1332 | * find that we can't read any more data (e.g short reads). | ||
1333 | */ | ||
1334 | } while (ret > 0 && iocb->ki_left > 0 && | ||
1335 | !S_ISFIFO(inode->i_mode) && !S_ISSOCK(inode->i_mode)); | ||
1336 | |||
1337 | /* This means we must have transferred all that we could */ | ||
1338 | /* No need to retry anymore */ | ||
1339 | if ((ret == 0) || (iocb->ki_left == 0)) | ||
1340 | ret = iocb->ki_nbytes - iocb->ki_left; | ||
1341 | |||
1342 | return ret; | ||
1343 | } | 1328 | } |
1344 | 1329 | ||
1345 | /* see aio_pread() */ | 1330 | static ssize_t aio_rw_vect_retry(struct kiocb *iocb) |
1346 | static ssize_t aio_pwrite(struct kiocb *iocb) | ||
1347 | { | 1331 | { |
1348 | struct file *file = iocb->ki_filp; | 1332 | struct file *file = iocb->ki_filp; |
1333 | struct address_space *mapping = file->f_mapping; | ||
1334 | struct inode *inode = mapping->host; | ||
1335 | ssize_t (*rw_op)(struct kiocb *, const struct iovec *, | ||
1336 | unsigned long, loff_t); | ||
1349 | ssize_t ret = 0; | 1337 | ssize_t ret = 0; |
1338 | unsigned short opcode; | ||
1339 | |||
1340 | if ((iocb->ki_opcode == IOCB_CMD_PREADV) || | ||
1341 | (iocb->ki_opcode == IOCB_CMD_PREAD)) { | ||
1342 | rw_op = file->f_op->aio_read; | ||
1343 | opcode = IOCB_CMD_PREADV; | ||
1344 | } else { | ||
1345 | rw_op = file->f_op->aio_write; | ||
1346 | opcode = IOCB_CMD_PWRITEV; | ||
1347 | } | ||
1350 | 1348 | ||
1351 | do { | 1349 | do { |
1352 | ret = file->f_op->aio_write(iocb, iocb->ki_buf, | 1350 | ret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg], |
1353 | iocb->ki_left, iocb->ki_pos); | 1351 | iocb->ki_nr_segs - iocb->ki_cur_seg, |
1354 | if (ret > 0) { | 1352 | iocb->ki_pos); |
1355 | iocb->ki_buf += ret; | 1353 | if (ret > 0) |
1356 | iocb->ki_left -= ret; | 1354 | aio_advance_iovec(iocb, ret); |
1357 | } | 1355 | |
1358 | } while (ret > 0 && iocb->ki_left > 0); | 1356 | /* retry all partial writes. retry partial reads as long as its a |
1357 | * regular file. */ | ||
1358 | } while (ret > 0 && iocb->ki_left > 0 && | ||
1359 | (opcode == IOCB_CMD_PWRITEV || | ||
1360 | (!S_ISFIFO(inode->i_mode) && !S_ISSOCK(inode->i_mode)))); | ||
1359 | 1361 | ||
1362 | /* This means we must have transferred all that we could */ | ||
1363 | /* No need to retry anymore */ | ||
1360 | if ((ret == 0) || (iocb->ki_left == 0)) | 1364 | if ((ret == 0) || (iocb->ki_left == 0)) |
1361 | ret = iocb->ki_nbytes - iocb->ki_left; | 1365 | ret = iocb->ki_nbytes - iocb->ki_left; |
1362 | 1366 | ||
@@ -1383,6 +1387,38 @@ static ssize_t aio_fsync(struct kiocb *iocb) | |||
1383 | return ret; | 1387 | return ret; |
1384 | } | 1388 | } |
1385 | 1389 | ||
1390 | static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb) | ||
1391 | { | ||
1392 | ssize_t ret; | ||
1393 | |||
1394 | ret = rw_copy_check_uvector(type, (struct iovec __user *)kiocb->ki_buf, | ||
1395 | kiocb->ki_nbytes, 1, | ||
1396 | &kiocb->ki_inline_vec, &kiocb->ki_iovec); | ||
1397 | if (ret < 0) | ||
1398 | goto out; | ||
1399 | |||
1400 | kiocb->ki_nr_segs = kiocb->ki_nbytes; | ||
1401 | kiocb->ki_cur_seg = 0; | ||
1402 | /* ki_nbytes/left now reflect bytes instead of segs */ | ||
1403 | kiocb->ki_nbytes = ret; | ||
1404 | kiocb->ki_left = ret; | ||
1405 | |||
1406 | ret = 0; | ||
1407 | out: | ||
1408 | return ret; | ||
1409 | } | ||
1410 | |||
1411 | static ssize_t aio_setup_single_vector(struct kiocb *kiocb) | ||
1412 | { | ||
1413 | kiocb->ki_iovec = &kiocb->ki_inline_vec; | ||
1414 | kiocb->ki_iovec->iov_base = kiocb->ki_buf; | ||
1415 | kiocb->ki_iovec->iov_len = kiocb->ki_left; | ||
1416 | kiocb->ki_nr_segs = 1; | ||
1417 | kiocb->ki_cur_seg = 0; | ||
1418 | kiocb->ki_nbytes = kiocb->ki_left; | ||
1419 | return 0; | ||
1420 | } | ||
1421 | |||
1386 | /* | 1422 | /* |
1387 | * aio_setup_iocb: | 1423 | * aio_setup_iocb: |
1388 | * Performs the initial checks and aio retry method | 1424 | * Performs the initial checks and aio retry method |
@@ -1405,9 +1441,12 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb) | |||
1405 | ret = security_file_permission(file, MAY_READ); | 1441 | ret = security_file_permission(file, MAY_READ); |
1406 | if (unlikely(ret)) | 1442 | if (unlikely(ret)) |
1407 | break; | 1443 | break; |
1444 | ret = aio_setup_single_vector(kiocb); | ||
1445 | if (ret) | ||
1446 | break; | ||
1408 | ret = -EINVAL; | 1447 | ret = -EINVAL; |
1409 | if (file->f_op->aio_read) | 1448 | if (file->f_op->aio_read) |
1410 | kiocb->ki_retry = aio_pread; | 1449 | kiocb->ki_retry = aio_rw_vect_retry; |
1411 | break; | 1450 | break; |
1412 | case IOCB_CMD_PWRITE: | 1451 | case IOCB_CMD_PWRITE: |
1413 | ret = -EBADF; | 1452 | ret = -EBADF; |
@@ -1420,9 +1459,40 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb) | |||
1420 | ret = security_file_permission(file, MAY_WRITE); | 1459 | ret = security_file_permission(file, MAY_WRITE); |
1421 | if (unlikely(ret)) | 1460 | if (unlikely(ret)) |
1422 | break; | 1461 | break; |
1462 | ret = aio_setup_single_vector(kiocb); | ||
1463 | if (ret) | ||
1464 | break; | ||
1465 | ret = -EINVAL; | ||
1466 | if (file->f_op->aio_write) | ||
1467 | kiocb->ki_retry = aio_rw_vect_retry; | ||
1468 | break; | ||
1469 | case IOCB_CMD_PREADV: | ||
1470 | ret = -EBADF; | ||
1471 | if (unlikely(!(file->f_mode & FMODE_READ))) | ||
1472 | break; | ||
1473 | ret = security_file_permission(file, MAY_READ); | ||
1474 | if (unlikely(ret)) | ||
1475 | break; | ||
1476 | ret = aio_setup_vectored_rw(READ, kiocb); | ||
1477 | if (ret) | ||
1478 | break; | ||
1479 | ret = -EINVAL; | ||
1480 | if (file->f_op->aio_read) | ||
1481 | kiocb->ki_retry = aio_rw_vect_retry; | ||
1482 | break; | ||
1483 | case IOCB_CMD_PWRITEV: | ||
1484 | ret = -EBADF; | ||
1485 | if (unlikely(!(file->f_mode & FMODE_WRITE))) | ||
1486 | break; | ||
1487 | ret = security_file_permission(file, MAY_WRITE); | ||
1488 | if (unlikely(ret)) | ||
1489 | break; | ||
1490 | ret = aio_setup_vectored_rw(WRITE, kiocb); | ||
1491 | if (ret) | ||
1492 | break; | ||
1423 | ret = -EINVAL; | 1493 | ret = -EINVAL; |
1424 | if (file->f_op->aio_write) | 1494 | if (file->f_op->aio_write) |
1425 | kiocb->ki_retry = aio_pwrite; | 1495 | kiocb->ki_retry = aio_rw_vect_retry; |
1426 | break; | 1496 | break; |
1427 | case IOCB_CMD_FDSYNC: | 1497 | case IOCB_CMD_FDSYNC: |
1428 | ret = -EINVAL; | 1498 | ret = -EINVAL; |
diff --git a/fs/autofs/root.c b/fs/autofs/root.c index 9cac08d6a873..368a1c33a3c8 100644 --- a/fs/autofs/root.c +++ b/fs/autofs/root.c | |||
@@ -414,7 +414,7 @@ static int autofs_root_rmdir(struct inode *dir, struct dentry *dentry) | |||
414 | 414 | ||
415 | dentry->d_time = (unsigned long)(struct autofs_dir_ent *)NULL; | 415 | dentry->d_time = (unsigned long)(struct autofs_dir_ent *)NULL; |
416 | autofs_hash_delete(ent); | 416 | autofs_hash_delete(ent); |
417 | dir->i_nlink--; | 417 | drop_nlink(dir); |
418 | d_drop(dentry); | 418 | d_drop(dentry); |
419 | unlock_kernel(); | 419 | unlock_kernel(); |
420 | 420 | ||
@@ -466,7 +466,7 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
466 | ent->dentry = dentry; | 466 | ent->dentry = dentry; |
467 | autofs_hash_insert(dh,ent); | 467 | autofs_hash_insert(dh,ent); |
468 | 468 | ||
469 | dir->i_nlink++; | 469 | inc_nlink(dir); |
470 | d_instantiate(dentry, iget(dir->i_sb,ino)); | 470 | d_instantiate(dentry, iget(dir->i_sb,ino)); |
471 | unlock_kernel(); | 471 | unlock_kernel(); |
472 | 472 | ||
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index 27e17f96cada..c1493524da4d 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c | |||
@@ -281,9 +281,6 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags) | |||
281 | 281 | ||
282 | DPRINTK("mount done status=%d", status); | 282 | DPRINTK("mount done status=%d", status); |
283 | 283 | ||
284 | if (status && dentry->d_inode) | ||
285 | return status; /* Try to get the kernel to invalidate this dentry */ | ||
286 | |||
287 | /* Turn this into a real negative dentry? */ | 284 | /* Turn this into a real negative dentry? */ |
288 | if (status == -ENOENT) { | 285 | if (status == -ENOENT) { |
289 | spin_lock(&dentry->d_lock); | 286 | spin_lock(&dentry->d_lock); |
@@ -359,7 +356,7 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
359 | * don't try to mount it again. | 356 | * don't try to mount it again. |
360 | */ | 357 | */ |
361 | spin_lock(&dcache_lock); | 358 | spin_lock(&dcache_lock); |
362 | if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) { | 359 | if (!d_mountpoint(dentry) && __simple_empty(dentry)) { |
363 | spin_unlock(&dcache_lock); | 360 | spin_unlock(&dcache_lock); |
364 | 361 | ||
365 | status = try_to_fill_dentry(dentry, 0); | 362 | status = try_to_fill_dentry(dentry, 0); |
@@ -540,6 +537,9 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s | |||
540 | return ERR_PTR(-ERESTARTNOINTR); | 537 | return ERR_PTR(-ERESTARTNOINTR); |
541 | } | 538 | } |
542 | } | 539 | } |
540 | spin_lock(&dentry->d_lock); | ||
541 | dentry->d_flags &= ~DCACHE_AUTOFS_PENDING; | ||
542 | spin_unlock(&dentry->d_lock); | ||
543 | } | 543 | } |
544 | 544 | ||
545 | /* | 545 | /* |
@@ -638,7 +638,7 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry) | |||
638 | dput(ino->dentry); | 638 | dput(ino->dentry); |
639 | 639 | ||
640 | dentry->d_inode->i_size = 0; | 640 | dentry->d_inode->i_size = 0; |
641 | dentry->d_inode->i_nlink = 0; | 641 | clear_nlink(dentry->d_inode); |
642 | 642 | ||
643 | dir->i_mtime = CURRENT_TIME; | 643 | dir->i_mtime = CURRENT_TIME; |
644 | 644 | ||
@@ -673,10 +673,10 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry) | |||
673 | } | 673 | } |
674 | dput(ino->dentry); | 674 | dput(ino->dentry); |
675 | dentry->d_inode->i_size = 0; | 675 | dentry->d_inode->i_size = 0; |
676 | dentry->d_inode->i_nlink = 0; | 676 | clear_nlink(dentry->d_inode); |
677 | 677 | ||
678 | if (dir->i_nlink) | 678 | if (dir->i_nlink) |
679 | dir->i_nlink--; | 679 | drop_nlink(dir); |
680 | 680 | ||
681 | return 0; | 681 | return 0; |
682 | } | 682 | } |
@@ -713,7 +713,7 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
713 | if (p_ino && dentry->d_parent != dentry) | 713 | if (p_ino && dentry->d_parent != dentry) |
714 | atomic_inc(&p_ino->count); | 714 | atomic_inc(&p_ino->count); |
715 | ino->inode = inode; | 715 | ino->inode = inode; |
716 | dir->i_nlink++; | 716 | inc_nlink(dir); |
717 | dir->i_mtime = CURRENT_TIME; | 717 | dir->i_mtime = CURRENT_TIME; |
718 | 718 | ||
719 | return 0; | 719 | return 0; |
diff --git a/fs/bad_inode.c b/fs/bad_inode.c index 80599ae33966..34e6d7b220c3 100644 --- a/fs/bad_inode.c +++ b/fs/bad_inode.c | |||
@@ -40,8 +40,6 @@ static const struct file_operations bad_file_ops = | |||
40 | .aio_fsync = EIO_ERROR, | 40 | .aio_fsync = EIO_ERROR, |
41 | .fasync = EIO_ERROR, | 41 | .fasync = EIO_ERROR, |
42 | .lock = EIO_ERROR, | 42 | .lock = EIO_ERROR, |
43 | .readv = EIO_ERROR, | ||
44 | .writev = EIO_ERROR, | ||
45 | .sendfile = EIO_ERROR, | 43 | .sendfile = EIO_ERROR, |
46 | .sendpage = EIO_ERROR, | 44 | .sendpage = EIO_ERROR, |
47 | .get_unmapped_area = EIO_ERROR, | 45 | .get_unmapped_area = EIO_ERROR, |
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c index dcf04cb13283..a650f1d0b85e 100644 --- a/fs/bfs/dir.c +++ b/fs/bfs/dir.c | |||
@@ -117,8 +117,7 @@ static int bfs_create(struct inode * dir, struct dentry * dentry, int mode, | |||
117 | 117 | ||
118 | err = bfs_add_entry(dir, dentry->d_name.name, dentry->d_name.len, inode->i_ino); | 118 | err = bfs_add_entry(dir, dentry->d_name.name, dentry->d_name.len, inode->i_ino); |
119 | if (err) { | 119 | if (err) { |
120 | inode->i_nlink--; | 120 | inode_dec_link_count(inode); |
121 | mark_inode_dirty(inode); | ||
122 | iput(inode); | 121 | iput(inode); |
123 | unlock_kernel(); | 122 | unlock_kernel(); |
124 | return err; | 123 | return err; |
@@ -164,7 +163,7 @@ static int bfs_link(struct dentry * old, struct inode * dir, struct dentry * new | |||
164 | unlock_kernel(); | 163 | unlock_kernel(); |
165 | return err; | 164 | return err; |
166 | } | 165 | } |
167 | inode->i_nlink++; | 166 | inc_nlink(inode); |
168 | inode->i_ctime = CURRENT_TIME_SEC; | 167 | inode->i_ctime = CURRENT_TIME_SEC; |
169 | mark_inode_dirty(inode); | 168 | mark_inode_dirty(inode); |
170 | atomic_inc(&inode->i_count); | 169 | atomic_inc(&inode->i_count); |
@@ -196,9 +195,8 @@ static int bfs_unlink(struct inode * dir, struct dentry * dentry) | |||
196 | mark_buffer_dirty(bh); | 195 | mark_buffer_dirty(bh); |
197 | dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; | 196 | dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; |
198 | mark_inode_dirty(dir); | 197 | mark_inode_dirty(dir); |
199 | inode->i_nlink--; | ||
200 | inode->i_ctime = dir->i_ctime; | 198 | inode->i_ctime = dir->i_ctime; |
201 | mark_inode_dirty(inode); | 199 | inode_dec_link_count(inode); |
202 | error = 0; | 200 | error = 0; |
203 | 201 | ||
204 | out_brelse: | 202 | out_brelse: |
@@ -249,9 +247,8 @@ static int bfs_rename(struct inode * old_dir, struct dentry * old_dentry, | |||
249 | old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC; | 247 | old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC; |
250 | mark_inode_dirty(old_dir); | 248 | mark_inode_dirty(old_dir); |
251 | if (new_inode) { | 249 | if (new_inode) { |
252 | new_inode->i_nlink--; | ||
253 | new_inode->i_ctime = CURRENT_TIME_SEC; | 250 | new_inode->i_ctime = CURRENT_TIME_SEC; |
254 | mark_inode_dirty(new_inode); | 251 | inode_dec_link_count(new_inode); |
255 | } | 252 | } |
256 | mark_buffer_dirty(old_bh); | 253 | mark_buffer_dirty(old_bh); |
257 | error = 0; | 254 | error = 0; |
diff --git a/fs/bfs/file.c b/fs/bfs/file.c index 3d5aca28a0a0..a9164a87f8de 100644 --- a/fs/bfs/file.c +++ b/fs/bfs/file.c | |||
@@ -19,8 +19,10 @@ | |||
19 | 19 | ||
20 | const struct file_operations bfs_file_operations = { | 20 | const struct file_operations bfs_file_operations = { |
21 | .llseek = generic_file_llseek, | 21 | .llseek = generic_file_llseek, |
22 | .read = generic_file_read, | 22 | .read = do_sync_read, |
23 | .write = generic_file_write, | 23 | .aio_read = generic_file_aio_read, |
24 | .write = do_sync_write, | ||
25 | .aio_write = generic_file_aio_write, | ||
24 | .mmap = generic_file_mmap, | 26 | .mmap = generic_file_mmap, |
25 | .sendfile = generic_file_sendfile, | 27 | .sendfile = generic_file_sendfile, |
26 | }; | 28 | }; |
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index f312103434d4..517e111bb7ef 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c | |||
@@ -278,6 +278,13 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs) | |||
278 | return -ENOEXEC; | 278 | return -ENOEXEC; |
279 | } | 279 | } |
280 | 280 | ||
281 | /* | ||
282 | * Requires a mmap handler. This prevents people from using a.out | ||
283 | * as part of an exploit attack against /proc-related vulnerabilities. | ||
284 | */ | ||
285 | if (!bprm->file->f_op || !bprm->file->f_op->mmap) | ||
286 | return -ENOEXEC; | ||
287 | |||
281 | fd_offset = N_TXTOFF(ex); | 288 | fd_offset = N_TXTOFF(ex); |
282 | 289 | ||
283 | /* Check initial limits. This avoids letting people circumvent | 290 | /* Check initial limits. This avoids letting people circumvent |
@@ -476,6 +483,13 @@ static int load_aout_library(struct file *file) | |||
476 | goto out; | 483 | goto out; |
477 | } | 484 | } |
478 | 485 | ||
486 | /* | ||
487 | * Requires a mmap handler. This prevents people from using a.out | ||
488 | * as part of an exploit attack against /proc-related vulnerabilities. | ||
489 | */ | ||
490 | if (!file->f_op || !file->f_op->mmap) | ||
491 | goto out; | ||
492 | |||
479 | if (N_FLAGS(ex)) | 493 | if (N_FLAGS(ex)) |
480 | goto out; | 494 | goto out; |
481 | 495 | ||
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index dfd8cfb7fb5d..06435f3665f4 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -46,7 +46,6 @@ | |||
46 | static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs); | 46 | static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs); |
47 | static int load_elf_library(struct file *); | 47 | static int load_elf_library(struct file *); |
48 | static unsigned long elf_map (struct file *, unsigned long, struct elf_phdr *, int, int); | 48 | static unsigned long elf_map (struct file *, unsigned long, struct elf_phdr *, int, int); |
49 | extern int dump_fpu (struct pt_regs *, elf_fpregset_t *); | ||
50 | 49 | ||
51 | #ifndef elf_addr_t | 50 | #ifndef elf_addr_t |
52 | #define elf_addr_t unsigned long | 51 | #define elf_addr_t unsigned long |
@@ -1038,10 +1037,8 @@ out_free_interp: | |||
1038 | out_free_file: | 1037 | out_free_file: |
1039 | sys_close(elf_exec_fileno); | 1038 | sys_close(elf_exec_fileno); |
1040 | out_free_fh: | 1039 | out_free_fh: |
1041 | if (files) { | 1040 | if (files) |
1042 | put_files_struct(current->files); | 1041 | reset_files_struct(current, files); |
1043 | current->files = files; | ||
1044 | } | ||
1045 | out_free_ph: | 1042 | out_free_ph: |
1046 | kfree(elf_phdata); | 1043 | kfree(elf_phdata); |
1047 | goto out; | 1044 | goto out; |
@@ -1154,11 +1151,23 @@ static int dump_write(struct file *file, const void *addr, int nr) | |||
1154 | 1151 | ||
1155 | static int dump_seek(struct file *file, loff_t off) | 1152 | static int dump_seek(struct file *file, loff_t off) |
1156 | { | 1153 | { |
1157 | if (file->f_op->llseek) { | 1154 | if (file->f_op->llseek && file->f_op->llseek != no_llseek) { |
1158 | if (file->f_op->llseek(file, off, 0) != off) | 1155 | if (file->f_op->llseek(file, off, 1) != off) |
1159 | return 0; | 1156 | return 0; |
1160 | } else | 1157 | } else { |
1161 | file->f_pos = off; | 1158 | char *buf = (char *)get_zeroed_page(GFP_KERNEL); |
1159 | if (!buf) | ||
1160 | return 0; | ||
1161 | while (off > 0) { | ||
1162 | unsigned long n = off; | ||
1163 | if (n > PAGE_SIZE) | ||
1164 | n = PAGE_SIZE; | ||
1165 | if (!dump_write(file, buf, n)) | ||
1166 | return 0; | ||
1167 | off -= n; | ||
1168 | } | ||
1169 | free_page((unsigned long)buf); | ||
1170 | } | ||
1162 | return 1; | 1171 | return 1; |
1163 | } | 1172 | } |
1164 | 1173 | ||
@@ -1206,30 +1215,35 @@ static int notesize(struct memelfnote *en) | |||
1206 | return sz; | 1215 | return sz; |
1207 | } | 1216 | } |
1208 | 1217 | ||
1209 | #define DUMP_WRITE(addr, nr) \ | 1218 | #define DUMP_WRITE(addr, nr, foffset) \ |
1210 | do { if (!dump_write(file, (addr), (nr))) return 0; } while(0) | 1219 | do { if (!dump_write(file, (addr), (nr))) return 0; *foffset += (nr); } while(0) |
1211 | #define DUMP_SEEK(off) \ | ||
1212 | do { if (!dump_seek(file, (off))) return 0; } while(0) | ||
1213 | 1220 | ||
1214 | static int writenote(struct memelfnote *men, struct file *file) | 1221 | static int alignfile(struct file *file, loff_t *foffset) |
1215 | { | 1222 | { |
1216 | struct elf_note en; | 1223 | char buf[4] = { 0, }; |
1224 | DUMP_WRITE(buf, roundup(*foffset, 4) - *foffset, foffset); | ||
1225 | return 1; | ||
1226 | } | ||
1217 | 1227 | ||
1228 | static int writenote(struct memelfnote *men, struct file *file, | ||
1229 | loff_t *foffset) | ||
1230 | { | ||
1231 | struct elf_note en; | ||
1218 | en.n_namesz = strlen(men->name) + 1; | 1232 | en.n_namesz = strlen(men->name) + 1; |
1219 | en.n_descsz = men->datasz; | 1233 | en.n_descsz = men->datasz; |
1220 | en.n_type = men->type; | 1234 | en.n_type = men->type; |
1221 | 1235 | ||
1222 | DUMP_WRITE(&en, sizeof(en)); | 1236 | DUMP_WRITE(&en, sizeof(en), foffset); |
1223 | DUMP_WRITE(men->name, en.n_namesz); | 1237 | DUMP_WRITE(men->name, en.n_namesz, foffset); |
1224 | /* XXX - cast from long long to long to avoid need for libgcc.a */ | 1238 | if (!alignfile(file, foffset)) |
1225 | DUMP_SEEK(roundup((unsigned long)file->f_pos, 4)); /* XXX */ | 1239 | return 0; |
1226 | DUMP_WRITE(men->data, men->datasz); | 1240 | DUMP_WRITE(men->data, men->datasz, foffset); |
1227 | DUMP_SEEK(roundup((unsigned long)file->f_pos, 4)); /* XXX */ | 1241 | if (!alignfile(file, foffset)) |
1242 | return 0; | ||
1228 | 1243 | ||
1229 | return 1; | 1244 | return 1; |
1230 | } | 1245 | } |
1231 | #undef DUMP_WRITE | 1246 | #undef DUMP_WRITE |
1232 | #undef DUMP_SEEK | ||
1233 | 1247 | ||
1234 | #define DUMP_WRITE(addr, nr) \ | 1248 | #define DUMP_WRITE(addr, nr) \ |
1235 | if ((size += (nr)) > limit || !dump_write(file, (addr), (nr))) \ | 1249 | if ((size += (nr)) > limit || !dump_write(file, (addr), (nr))) \ |
@@ -1429,7 +1443,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file) | |||
1429 | int i; | 1443 | int i; |
1430 | struct vm_area_struct *vma; | 1444 | struct vm_area_struct *vma; |
1431 | struct elfhdr *elf = NULL; | 1445 | struct elfhdr *elf = NULL; |
1432 | loff_t offset = 0, dataoff; | 1446 | loff_t offset = 0, dataoff, foffset; |
1433 | unsigned long limit = current->signal->rlim[RLIMIT_CORE].rlim_cur; | 1447 | unsigned long limit = current->signal->rlim[RLIMIT_CORE].rlim_cur; |
1434 | int numnote; | 1448 | int numnote; |
1435 | struct memelfnote *notes = NULL; | 1449 | struct memelfnote *notes = NULL; |
@@ -1481,20 +1495,19 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file) | |||
1481 | 1495 | ||
1482 | if (signr) { | 1496 | if (signr) { |
1483 | struct elf_thread_status *tmp; | 1497 | struct elf_thread_status *tmp; |
1484 | read_lock(&tasklist_lock); | 1498 | rcu_read_lock(); |
1485 | do_each_thread(g,p) | 1499 | do_each_thread(g,p) |
1486 | if (current->mm == p->mm && current != p) { | 1500 | if (current->mm == p->mm && current != p) { |
1487 | tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC); | 1501 | tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC); |
1488 | if (!tmp) { | 1502 | if (!tmp) { |
1489 | read_unlock(&tasklist_lock); | 1503 | rcu_read_unlock(); |
1490 | goto cleanup; | 1504 | goto cleanup; |
1491 | } | 1505 | } |
1492 | INIT_LIST_HEAD(&tmp->list); | ||
1493 | tmp->thread = p; | 1506 | tmp->thread = p; |
1494 | list_add(&tmp->list, &thread_list); | 1507 | list_add(&tmp->list, &thread_list); |
1495 | } | 1508 | } |
1496 | while_each_thread(g,p); | 1509 | while_each_thread(g,p); |
1497 | read_unlock(&tasklist_lock); | 1510 | rcu_read_unlock(); |
1498 | list_for_each(t, &thread_list) { | 1511 | list_for_each(t, &thread_list) { |
1499 | struct elf_thread_status *tmp; | 1512 | struct elf_thread_status *tmp; |
1500 | int sz; | 1513 | int sz; |
@@ -1573,7 +1586,8 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file) | |||
1573 | DUMP_WRITE(&phdr, sizeof(phdr)); | 1586 | DUMP_WRITE(&phdr, sizeof(phdr)); |
1574 | } | 1587 | } |
1575 | 1588 | ||
1576 | /* Page-align dumped data */ | 1589 | foffset = offset; |
1590 | |||
1577 | dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE); | 1591 | dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE); |
1578 | 1592 | ||
1579 | /* Write program headers for segments dump */ | 1593 | /* Write program headers for segments dump */ |
@@ -1598,6 +1612,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file) | |||
1598 | phdr.p_align = ELF_EXEC_PAGESIZE; | 1612 | phdr.p_align = ELF_EXEC_PAGESIZE; |
1599 | 1613 | ||
1600 | DUMP_WRITE(&phdr, sizeof(phdr)); | 1614 | DUMP_WRITE(&phdr, sizeof(phdr)); |
1615 | foffset += sizeof(phdr); | ||
1601 | } | 1616 | } |
1602 | 1617 | ||
1603 | #ifdef ELF_CORE_WRITE_EXTRA_PHDRS | 1618 | #ifdef ELF_CORE_WRITE_EXTRA_PHDRS |
@@ -1606,7 +1621,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file) | |||
1606 | 1621 | ||
1607 | /* write out the notes section */ | 1622 | /* write out the notes section */ |
1608 | for (i = 0; i < numnote; i++) | 1623 | for (i = 0; i < numnote; i++) |
1609 | if (!writenote(notes + i, file)) | 1624 | if (!writenote(notes + i, file, &foffset)) |
1610 | goto end_coredump; | 1625 | goto end_coredump; |
1611 | 1626 | ||
1612 | /* write out the thread status notes section */ | 1627 | /* write out the thread status notes section */ |
@@ -1615,11 +1630,12 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file) | |||
1615 | list_entry(t, struct elf_thread_status, list); | 1630 | list_entry(t, struct elf_thread_status, list); |
1616 | 1631 | ||
1617 | for (i = 0; i < tmp->num_notes; i++) | 1632 | for (i = 0; i < tmp->num_notes; i++) |
1618 | if (!writenote(&tmp->notes[i], file)) | 1633 | if (!writenote(&tmp->notes[i], file, &foffset)) |
1619 | goto end_coredump; | 1634 | goto end_coredump; |
1620 | } | 1635 | } |
1621 | 1636 | ||
1622 | DUMP_SEEK(dataoff); | 1637 | /* Align to page */ |
1638 | DUMP_SEEK(dataoff - foffset); | ||
1623 | 1639 | ||
1624 | for (vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) { | 1640 | for (vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) { |
1625 | unsigned long addr; | 1641 | unsigned long addr; |
@@ -1635,10 +1651,10 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file) | |||
1635 | 1651 | ||
1636 | if (get_user_pages(current, current->mm, addr, 1, 0, 1, | 1652 | if (get_user_pages(current, current->mm, addr, 1, 0, 1, |
1637 | &page, &vma) <= 0) { | 1653 | &page, &vma) <= 0) { |
1638 | DUMP_SEEK(file->f_pos + PAGE_SIZE); | 1654 | DUMP_SEEK(PAGE_SIZE); |
1639 | } else { | 1655 | } else { |
1640 | if (page == ZERO_PAGE(addr)) { | 1656 | if (page == ZERO_PAGE(addr)) { |
1641 | DUMP_SEEK(file->f_pos + PAGE_SIZE); | 1657 | DUMP_SEEK(PAGE_SIZE); |
1642 | } else { | 1658 | } else { |
1643 | void *kaddr; | 1659 | void *kaddr; |
1644 | flush_cache_page(vma, addr, | 1660 | flush_cache_page(vma, addr, |
@@ -1662,13 +1678,6 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file) | |||
1662 | ELF_CORE_WRITE_EXTRA_DATA; | 1678 | ELF_CORE_WRITE_EXTRA_DATA; |
1663 | #endif | 1679 | #endif |
1664 | 1680 | ||
1665 | if (file->f_pos != offset) { | ||
1666 | /* Sanity check */ | ||
1667 | printk(KERN_WARNING | ||
1668 | "elf_core_dump: file->f_pos (%Ld) != offset (%Ld)\n", | ||
1669 | file->f_pos, offset); | ||
1670 | } | ||
1671 | |||
1672 | end_coredump: | 1681 | end_coredump: |
1673 | set_fs(fs); | 1682 | set_fs(fs); |
1674 | 1683 | ||
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index 2f3365829229..f86d5c9ce5eb 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
@@ -1597,20 +1597,19 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | |||
1597 | 1597 | ||
1598 | if (signr) { | 1598 | if (signr) { |
1599 | struct elf_thread_status *tmp; | 1599 | struct elf_thread_status *tmp; |
1600 | read_lock(&tasklist_lock); | 1600 | rcu_read_lock(); |
1601 | do_each_thread(g,p) | 1601 | do_each_thread(g,p) |
1602 | if (current->mm == p->mm && current != p) { | 1602 | if (current->mm == p->mm && current != p) { |
1603 | tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC); | 1603 | tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC); |
1604 | if (!tmp) { | 1604 | if (!tmp) { |
1605 | read_unlock(&tasklist_lock); | 1605 | rcu_read_unlock(); |
1606 | goto cleanup; | 1606 | goto cleanup; |
1607 | } | 1607 | } |
1608 | INIT_LIST_HEAD(&tmp->list); | ||
1609 | tmp->thread = p; | 1608 | tmp->thread = p; |
1610 | list_add(&tmp->list, &thread_list); | 1609 | list_add(&tmp->list, &thread_list); |
1611 | } | 1610 | } |
1612 | while_each_thread(g,p); | 1611 | while_each_thread(g,p); |
1613 | read_unlock(&tasklist_lock); | 1612 | rcu_read_unlock(); |
1614 | list_for_each(t, &thread_list) { | 1613 | list_for_each(t, &thread_list) { |
1615 | struct elf_thread_status *tmp; | 1614 | struct elf_thread_status *tmp; |
1616 | int sz; | 1615 | int sz; |
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 66ba137f8661..1713c48fef54 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c | |||
@@ -215,10 +215,8 @@ _error: | |||
215 | bprm->interp_flags = 0; | 215 | bprm->interp_flags = 0; |
216 | bprm->interp_data = 0; | 216 | bprm->interp_data = 0; |
217 | _unshare: | 217 | _unshare: |
218 | if (files) { | 218 | if (files) |
219 | put_files_struct(current->files); | 219 | reset_files_struct(current, files); |
220 | current->files = files; | ||
221 | } | ||
222 | goto _ret; | 220 | goto _ret; |
223 | } | 221 | } |
224 | 222 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Jens Axboe <axboe@suse.de> | 2 | * Copyright (C) 2001 Jens Axboe <axboe@kernel.dk> |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License version 2 as | 5 | * it under the terms of the GNU General Public License version 2 as |
@@ -1142,7 +1142,7 @@ static int biovec_create_pools(struct bio_set *bs, int pool_entries, int scale) | |||
1142 | struct biovec_slab *bp = bvec_slabs + i; | 1142 | struct biovec_slab *bp = bvec_slabs + i; |
1143 | mempool_t **bvp = bs->bvec_pools + i; | 1143 | mempool_t **bvp = bs->bvec_pools + i; |
1144 | 1144 | ||
1145 | if (i >= scale) | 1145 | if (pool_entries > 1 && i >= scale) |
1146 | pool_entries >>= 1; | 1146 | pool_entries >>= 1; |
1147 | 1147 | ||
1148 | *bvp = mempool_create_slab_pool(pool_entries, bp->slab); | 1148 | *bvp = mempool_create_slab_pool(pool_entries, bp->slab); |
diff --git a/fs/block_dev.c b/fs/block_dev.c index 045f98854f14..bc8f27cc4483 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -17,11 +17,13 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/blkpg.h> | 18 | #include <linux/blkpg.h> |
19 | #include <linux/buffer_head.h> | 19 | #include <linux/buffer_head.h> |
20 | #include <linux/writeback.h> | ||
20 | #include <linux/mpage.h> | 21 | #include <linux/mpage.h> |
21 | #include <linux/mount.h> | 22 | #include <linux/mount.h> |
22 | #include <linux/uio.h> | 23 | #include <linux/uio.h> |
23 | #include <linux/namei.h> | 24 | #include <linux/namei.h> |
24 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
26 | #include "internal.h" | ||
25 | 27 | ||
26 | struct bdev_inode { | 28 | struct bdev_inode { |
27 | struct block_device bdev; | 29 | struct block_device bdev; |
@@ -543,11 +545,11 @@ static struct kobject *bdev_get_holder(struct block_device *bdev) | |||
543 | return kobject_get(bdev->bd_disk->holder_dir); | 545 | return kobject_get(bdev->bd_disk->holder_dir); |
544 | } | 546 | } |
545 | 547 | ||
546 | static void add_symlink(struct kobject *from, struct kobject *to) | 548 | static int add_symlink(struct kobject *from, struct kobject *to) |
547 | { | 549 | { |
548 | if (!from || !to) | 550 | if (!from || !to) |
549 | return; | 551 | return 0; |
550 | sysfs_create_link(from, to, kobject_name(to)); | 552 | return sysfs_create_link(from, to, kobject_name(to)); |
551 | } | 553 | } |
552 | 554 | ||
553 | static void del_symlink(struct kobject *from, struct kobject *to) | 555 | static void del_symlink(struct kobject *from, struct kobject *to) |
@@ -648,30 +650,38 @@ static void free_bd_holder(struct bd_holder *bo) | |||
648 | * If there is no matching entry with @bo in @bdev->bd_holder_list, | 650 | * If there is no matching entry with @bo in @bdev->bd_holder_list, |
649 | * add @bo to the list, create symlinks. | 651 | * add @bo to the list, create symlinks. |
650 | * | 652 | * |
651 | * Returns 1 if @bo was added to the list. | 653 | * Returns 0 if symlinks are created or already there. |
652 | * Returns 0 if @bo wasn't used by any reason and should be freed. | 654 | * Returns -ve if something fails and @bo can be freed. |
653 | */ | 655 | */ |
654 | static int add_bd_holder(struct block_device *bdev, struct bd_holder *bo) | 656 | static int add_bd_holder(struct block_device *bdev, struct bd_holder *bo) |
655 | { | 657 | { |
656 | struct bd_holder *tmp; | 658 | struct bd_holder *tmp; |
659 | int ret; | ||
657 | 660 | ||
658 | if (!bo) | 661 | if (!bo) |
659 | return 0; | 662 | return -EINVAL; |
660 | 663 | ||
661 | list_for_each_entry(tmp, &bdev->bd_holder_list, list) { | 664 | list_for_each_entry(tmp, &bdev->bd_holder_list, list) { |
662 | if (tmp->sdir == bo->sdir) { | 665 | if (tmp->sdir == bo->sdir) { |
663 | tmp->count++; | 666 | tmp->count++; |
667 | /* We've already done what we need to do here. */ | ||
668 | free_bd_holder(bo); | ||
664 | return 0; | 669 | return 0; |
665 | } | 670 | } |
666 | } | 671 | } |
667 | 672 | ||
668 | if (!bd_holder_grab_dirs(bdev, bo)) | 673 | if (!bd_holder_grab_dirs(bdev, bo)) |
669 | return 0; | 674 | return -EBUSY; |
670 | 675 | ||
671 | add_symlink(bo->sdir, bo->sdev); | 676 | ret = add_symlink(bo->sdir, bo->sdev); |
672 | add_symlink(bo->hdir, bo->hdev); | 677 | if (ret == 0) { |
673 | list_add_tail(&bo->list, &bdev->bd_holder_list); | 678 | ret = add_symlink(bo->hdir, bo->hdev); |
674 | return 1; | 679 | if (ret) |
680 | del_symlink(bo->sdir, bo->sdev); | ||
681 | } | ||
682 | if (ret == 0) | ||
683 | list_add_tail(&bo->list, &bdev->bd_holder_list); | ||
684 | return ret; | ||
675 | } | 685 | } |
676 | 686 | ||
677 | /** | 687 | /** |
@@ -741,7 +751,9 @@ static int bd_claim_by_kobject(struct block_device *bdev, void *holder, | |||
741 | 751 | ||
742 | mutex_lock_nested(&bdev->bd_mutex, BD_MUTEX_PARTITION); | 752 | mutex_lock_nested(&bdev->bd_mutex, BD_MUTEX_PARTITION); |
743 | res = bd_claim(bdev, holder); | 753 | res = bd_claim(bdev, holder); |
744 | if (res || !add_bd_holder(bdev, bo)) | 754 | if (res == 0) |
755 | res = add_bd_holder(bdev, bo); | ||
756 | if (res) | ||
745 | free_bd_holder(bo); | 757 | free_bd_holder(bo); |
746 | mutex_unlock(&bdev->bd_mutex); | 758 | mutex_unlock(&bdev->bd_mutex); |
747 | 759 | ||
@@ -1021,7 +1033,7 @@ do_open(struct block_device *bdev, struct file *file, unsigned int subclass) | |||
1021 | rescan_partitions(bdev->bd_disk, bdev); | 1033 | rescan_partitions(bdev->bd_disk, bdev); |
1022 | } else { | 1034 | } else { |
1023 | mutex_lock_nested(&bdev->bd_contains->bd_mutex, | 1035 | mutex_lock_nested(&bdev->bd_contains->bd_mutex, |
1024 | BD_MUTEX_PARTITION); | 1036 | BD_MUTEX_WHOLE); |
1025 | bdev->bd_contains->bd_part_count++; | 1037 | bdev->bd_contains->bd_part_count++; |
1026 | mutex_unlock(&bdev->bd_contains->bd_mutex); | 1038 | mutex_unlock(&bdev->bd_contains->bd_mutex); |
1027 | } | 1039 | } |
@@ -1142,22 +1154,6 @@ static int blkdev_close(struct inode * inode, struct file * filp) | |||
1142 | return blkdev_put(bdev); | 1154 | return blkdev_put(bdev); |
1143 | } | 1155 | } |
1144 | 1156 | ||
1145 | static ssize_t blkdev_file_write(struct file *file, const char __user *buf, | ||
1146 | size_t count, loff_t *ppos) | ||
1147 | { | ||
1148 | struct iovec local_iov = { .iov_base = (void __user *)buf, .iov_len = count }; | ||
1149 | |||
1150 | return generic_file_write_nolock(file, &local_iov, 1, ppos); | ||
1151 | } | ||
1152 | |||
1153 | static ssize_t blkdev_file_aio_write(struct kiocb *iocb, const char __user *buf, | ||
1154 | size_t count, loff_t pos) | ||
1155 | { | ||
1156 | struct iovec local_iov = { .iov_base = (void __user *)buf, .iov_len = count }; | ||
1157 | |||
1158 | return generic_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos); | ||
1159 | } | ||
1160 | |||
1161 | static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg) | 1157 | static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg) |
1162 | { | 1158 | { |
1163 | return blkdev_ioctl(file->f_mapping->host, file, cmd, arg); | 1159 | return blkdev_ioctl(file->f_mapping->host, file, cmd, arg); |
@@ -1177,18 +1173,16 @@ const struct file_operations def_blk_fops = { | |||
1177 | .open = blkdev_open, | 1173 | .open = blkdev_open, |
1178 | .release = blkdev_close, | 1174 | .release = blkdev_close, |
1179 | .llseek = block_llseek, | 1175 | .llseek = block_llseek, |
1180 | .read = generic_file_read, | 1176 | .read = do_sync_read, |
1181 | .write = blkdev_file_write, | 1177 | .write = do_sync_write, |
1182 | .aio_read = generic_file_aio_read, | 1178 | .aio_read = generic_file_aio_read, |
1183 | .aio_write = blkdev_file_aio_write, | 1179 | .aio_write = generic_file_aio_write_nolock, |
1184 | .mmap = generic_file_mmap, | 1180 | .mmap = generic_file_mmap, |
1185 | .fsync = block_fsync, | 1181 | .fsync = block_fsync, |
1186 | .unlocked_ioctl = block_ioctl, | 1182 | .unlocked_ioctl = block_ioctl, |
1187 | #ifdef CONFIG_COMPAT | 1183 | #ifdef CONFIG_COMPAT |
1188 | .compat_ioctl = compat_blkdev_ioctl, | 1184 | .compat_ioctl = compat_blkdev_ioctl, |
1189 | #endif | 1185 | #endif |
1190 | .readv = generic_file_readv, | ||
1191 | .writev = generic_file_write_nolock, | ||
1192 | .sendfile = generic_file_sendfile, | 1186 | .sendfile = generic_file_sendfile, |
1193 | .splice_read = generic_file_splice_read, | 1187 | .splice_read = generic_file_splice_read, |
1194 | .splice_write = generic_file_splice_write, | 1188 | .splice_write = generic_file_splice_write, |
@@ -1303,3 +1297,24 @@ void close_bdev_excl(struct block_device *bdev) | |||
1303 | } | 1297 | } |
1304 | 1298 | ||
1305 | EXPORT_SYMBOL(close_bdev_excl); | 1299 | EXPORT_SYMBOL(close_bdev_excl); |
1300 | |||
1301 | int __invalidate_device(struct block_device *bdev) | ||
1302 | { | ||
1303 | struct super_block *sb = get_super(bdev); | ||
1304 | int res = 0; | ||
1305 | |||
1306 | if (sb) { | ||
1307 | /* | ||
1308 | * no need to lock the super, get_super holds the | ||
1309 | * read mutex so the filesystem cannot go away | ||
1310 | * under us (->put_super runs with the write lock | ||
1311 | * hold). | ||
1312 | */ | ||
1313 | shrink_dcache_sb(sb); | ||
1314 | res = invalidate_inodes(sb); | ||
1315 | drop_super(sb); | ||
1316 | } | ||
1317 | invalidate_bdev(bdev, 0); | ||
1318 | return res; | ||
1319 | } | ||
1320 | EXPORT_SYMBOL(__invalidate_device); | ||
diff --git a/fs/buffer.c b/fs/buffer.c index 3b6d701073e7..16cfbcd254f1 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -159,31 +159,6 @@ int sync_blockdev(struct block_device *bdev) | |||
159 | } | 159 | } |
160 | EXPORT_SYMBOL(sync_blockdev); | 160 | EXPORT_SYMBOL(sync_blockdev); |
161 | 161 | ||
162 | static void __fsync_super(struct super_block *sb) | ||
163 | { | ||
164 | sync_inodes_sb(sb, 0); | ||
165 | DQUOT_SYNC(sb); | ||
166 | lock_super(sb); | ||
167 | if (sb->s_dirt && sb->s_op->write_super) | ||
168 | sb->s_op->write_super(sb); | ||
169 | unlock_super(sb); | ||
170 | if (sb->s_op->sync_fs) | ||
171 | sb->s_op->sync_fs(sb, 1); | ||
172 | sync_blockdev(sb->s_bdev); | ||
173 | sync_inodes_sb(sb, 1); | ||
174 | } | ||
175 | |||
176 | /* | ||
177 | * Write out and wait upon all dirty data associated with this | ||
178 | * superblock. Filesystem data as well as the underlying block | ||
179 | * device. Takes the superblock lock. | ||
180 | */ | ||
181 | int fsync_super(struct super_block *sb) | ||
182 | { | ||
183 | __fsync_super(sb); | ||
184 | return sync_blockdev(sb->s_bdev); | ||
185 | } | ||
186 | |||
187 | /* | 162 | /* |
188 | * Write out and wait upon all dirty data associated with this | 163 | * Write out and wait upon all dirty data associated with this |
189 | * device. Filesystem data as well as the underlying block | 164 | * device. Filesystem data as well as the underlying block |
@@ -260,118 +235,6 @@ void thaw_bdev(struct block_device *bdev, struct super_block *sb) | |||
260 | EXPORT_SYMBOL(thaw_bdev); | 235 | EXPORT_SYMBOL(thaw_bdev); |
261 | 236 | ||
262 | /* | 237 | /* |
263 | * sync everything. Start out by waking pdflush, because that writes back | ||
264 | * all queues in parallel. | ||
265 | */ | ||
266 | static void do_sync(unsigned long wait) | ||
267 | { | ||
268 | wakeup_pdflush(0); | ||
269 | sync_inodes(0); /* All mappings, inodes and their blockdevs */ | ||
270 | DQUOT_SYNC(NULL); | ||
271 | sync_supers(); /* Write the superblocks */ | ||
272 | sync_filesystems(0); /* Start syncing the filesystems */ | ||
273 | sync_filesystems(wait); /* Waitingly sync the filesystems */ | ||
274 | sync_inodes(wait); /* Mappings, inodes and blockdevs, again. */ | ||
275 | if (!wait) | ||
276 | printk("Emergency Sync complete\n"); | ||
277 | if (unlikely(laptop_mode)) | ||
278 | laptop_sync_completion(); | ||
279 | } | ||
280 | |||
281 | asmlinkage long sys_sync(void) | ||
282 | { | ||
283 | do_sync(1); | ||
284 | return 0; | ||
285 | } | ||
286 | |||
287 | void emergency_sync(void) | ||
288 | { | ||
289 | pdflush_operation(do_sync, 0); | ||
290 | } | ||
291 | |||
292 | /* | ||
293 | * Generic function to fsync a file. | ||
294 | * | ||
295 | * filp may be NULL if called via the msync of a vma. | ||
296 | */ | ||
297 | |||
298 | int file_fsync(struct file *filp, struct dentry *dentry, int datasync) | ||
299 | { | ||
300 | struct inode * inode = dentry->d_inode; | ||
301 | struct super_block * sb; | ||
302 | int ret, err; | ||
303 | |||
304 | /* sync the inode to buffers */ | ||
305 | ret = write_inode_now(inode, 0); | ||
306 | |||
307 | /* sync the superblock to buffers */ | ||
308 | sb = inode->i_sb; | ||
309 | lock_super(sb); | ||
310 | if (sb->s_op->write_super) | ||
311 | sb->s_op->write_super(sb); | ||
312 | unlock_super(sb); | ||
313 | |||
314 | /* .. finally sync the buffers to disk */ | ||
315 | err = sync_blockdev(sb->s_bdev); | ||
316 | if (!ret) | ||
317 | ret = err; | ||
318 | return ret; | ||
319 | } | ||
320 | |||
321 | long do_fsync(struct file *file, int datasync) | ||
322 | { | ||
323 | int ret; | ||
324 | int err; | ||
325 | struct address_space *mapping = file->f_mapping; | ||
326 | |||
327 | if (!file->f_op || !file->f_op->fsync) { | ||
328 | /* Why? We can still call filemap_fdatawrite */ | ||
329 | ret = -EINVAL; | ||
330 | goto out; | ||
331 | } | ||
332 | |||
333 | ret = filemap_fdatawrite(mapping); | ||
334 | |||
335 | /* | ||
336 | * We need to protect against concurrent writers, which could cause | ||
337 | * livelocks in fsync_buffers_list(). | ||
338 | */ | ||
339 | mutex_lock(&mapping->host->i_mutex); | ||
340 | err = file->f_op->fsync(file, file->f_dentry, datasync); | ||
341 | if (!ret) | ||
342 | ret = err; | ||
343 | mutex_unlock(&mapping->host->i_mutex); | ||
344 | err = filemap_fdatawait(mapping); | ||
345 | if (!ret) | ||
346 | ret = err; | ||
347 | out: | ||
348 | return ret; | ||
349 | } | ||
350 | |||
351 | static long __do_fsync(unsigned int fd, int datasync) | ||
352 | { | ||
353 | struct file *file; | ||
354 | int ret = -EBADF; | ||
355 | |||
356 | file = fget(fd); | ||
357 | if (file) { | ||
358 | ret = do_fsync(file, datasync); | ||
359 | fput(file); | ||
360 | } | ||
361 | return ret; | ||
362 | } | ||
363 | |||
364 | asmlinkage long sys_fsync(unsigned int fd) | ||
365 | { | ||
366 | return __do_fsync(fd, 0); | ||
367 | } | ||
368 | |||
369 | asmlinkage long sys_fdatasync(unsigned int fd) | ||
370 | { | ||
371 | return __do_fsync(fd, 1); | ||
372 | } | ||
373 | |||
374 | /* | ||
375 | * Various filesystems appear to want __find_get_block to be non-blocking. | 238 | * Various filesystems appear to want __find_get_block to be non-blocking. |
376 | * But it's the page lock which protects the buffers. To get around this, | 239 | * But it's the page lock which protects the buffers. To get around this, |
377 | * we get exclusion from try_to_free_buffers with the blockdev mapping's | 240 | * we get exclusion from try_to_free_buffers with the blockdev mapping's |
@@ -1551,35 +1414,6 @@ static void discard_buffer(struct buffer_head * bh) | |||
1551 | } | 1414 | } |
1552 | 1415 | ||
1553 | /** | 1416 | /** |
1554 | * try_to_release_page() - release old fs-specific metadata on a page | ||
1555 | * | ||
1556 | * @page: the page which the kernel is trying to free | ||
1557 | * @gfp_mask: memory allocation flags (and I/O mode) | ||
1558 | * | ||
1559 | * The address_space is to try to release any data against the page | ||
1560 | * (presumably at page->private). If the release was successful, return `1'. | ||
1561 | * Otherwise return zero. | ||
1562 | * | ||
1563 | * The @gfp_mask argument specifies whether I/O may be performed to release | ||
1564 | * this page (__GFP_IO), and whether the call may block (__GFP_WAIT). | ||
1565 | * | ||
1566 | * NOTE: @gfp_mask may go away, and this function may become non-blocking. | ||
1567 | */ | ||
1568 | int try_to_release_page(struct page *page, gfp_t gfp_mask) | ||
1569 | { | ||
1570 | struct address_space * const mapping = page->mapping; | ||
1571 | |||
1572 | BUG_ON(!PageLocked(page)); | ||
1573 | if (PageWriteback(page)) | ||
1574 | return 0; | ||
1575 | |||
1576 | if (mapping && mapping->a_ops->releasepage) | ||
1577 | return mapping->a_ops->releasepage(page, gfp_mask); | ||
1578 | return try_to_free_buffers(page); | ||
1579 | } | ||
1580 | EXPORT_SYMBOL(try_to_release_page); | ||
1581 | |||
1582 | /** | ||
1583 | * block_invalidatepage - invalidate part of all of a buffer-backed page | 1417 | * block_invalidatepage - invalidate part of all of a buffer-backed page |
1584 | * | 1418 | * |
1585 | * @page: the page which is affected | 1419 | * @page: the page which is affected |
@@ -1630,14 +1464,6 @@ out: | |||
1630 | } | 1464 | } |
1631 | EXPORT_SYMBOL(block_invalidatepage); | 1465 | EXPORT_SYMBOL(block_invalidatepage); |
1632 | 1466 | ||
1633 | void do_invalidatepage(struct page *page, unsigned long offset) | ||
1634 | { | ||
1635 | void (*invalidatepage)(struct page *, unsigned long); | ||
1636 | invalidatepage = page->mapping->a_ops->invalidatepage ? : | ||
1637 | block_invalidatepage; | ||
1638 | (*invalidatepage)(page, offset); | ||
1639 | } | ||
1640 | |||
1641 | /* | 1467 | /* |
1642 | * We attach and possibly dirty the buffers atomically wrt | 1468 | * We attach and possibly dirty the buffers atomically wrt |
1643 | * __set_page_dirty_buffers() via private_lock. try_to_free_buffers | 1469 | * __set_page_dirty_buffers() via private_lock. try_to_free_buffers |
diff --git a/fs/char_dev.c b/fs/char_dev.c index 0009346d827f..a885f46ca001 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #ifdef CONFIG_KMOD | 24 | #ifdef CONFIG_KMOD |
25 | #include <linux/kmod.h> | 25 | #include <linux/kmod.h> |
26 | #endif | 26 | #endif |
27 | #include "internal.h" | ||
27 | 28 | ||
28 | /* | 29 | /* |
29 | * capabilities for /dev/mem, /dev/kmem and similar directly mappable character | 30 | * capabilities for /dev/mem, /dev/kmem and similar directly mappable character |
@@ -128,13 +129,31 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, | |||
128 | 129 | ||
129 | for (cp = &chrdevs[i]; *cp; cp = &(*cp)->next) | 130 | for (cp = &chrdevs[i]; *cp; cp = &(*cp)->next) |
130 | if ((*cp)->major > major || | 131 | if ((*cp)->major > major || |
131 | ((*cp)->major == major && (*cp)->baseminor >= baseminor)) | 132 | ((*cp)->major == major && |
133 | (((*cp)->baseminor >= baseminor) || | ||
134 | ((*cp)->baseminor + (*cp)->minorct > baseminor)))) | ||
132 | break; | 135 | break; |
133 | if (*cp && (*cp)->major == major && | 136 | |
134 | (*cp)->baseminor < baseminor + minorct) { | 137 | /* Check for overlapping minor ranges. */ |
135 | ret = -EBUSY; | 138 | if (*cp && (*cp)->major == major) { |
136 | goto out; | 139 | int old_min = (*cp)->baseminor; |
140 | int old_max = (*cp)->baseminor + (*cp)->minorct - 1; | ||
141 | int new_min = baseminor; | ||
142 | int new_max = baseminor + minorct - 1; | ||
143 | |||
144 | /* New driver overlaps from the left. */ | ||
145 | if (new_max >= old_min && new_max <= old_max) { | ||
146 | ret = -EBUSY; | ||
147 | goto out; | ||
148 | } | ||
149 | |||
150 | /* New driver overlaps from the right. */ | ||
151 | if (new_min <= old_max && new_min >= old_min) { | ||
152 | ret = -EBUSY; | ||
153 | goto out; | ||
154 | } | ||
137 | } | 155 | } |
156 | |||
138 | cd->next = *cp; | 157 | cd->next = *cp; |
139 | *cp = cd; | 158 | *cp = cd; |
140 | mutex_unlock(&chrdevs_lock); | 159 | mutex_unlock(&chrdevs_lock); |
@@ -165,6 +184,15 @@ __unregister_chrdev_region(unsigned major, unsigned baseminor, int minorct) | |||
165 | return cd; | 184 | return cd; |
166 | } | 185 | } |
167 | 186 | ||
187 | /** | ||
188 | * register_chrdev_region() - register a range of device numbers | ||
189 | * @from: the first in the desired range of device numbers; must include | ||
190 | * the major number. | ||
191 | * @count: the number of consecutive device numbers required | ||
192 | * @name: the name of the device or driver. | ||
193 | * | ||
194 | * Return value is zero on success, a negative error code on failure. | ||
195 | */ | ||
168 | int register_chrdev_region(dev_t from, unsigned count, const char *name) | 196 | int register_chrdev_region(dev_t from, unsigned count, const char *name) |
169 | { | 197 | { |
170 | struct char_device_struct *cd; | 198 | struct char_device_struct *cd; |
@@ -190,6 +218,17 @@ fail: | |||
190 | return PTR_ERR(cd); | 218 | return PTR_ERR(cd); |
191 | } | 219 | } |
192 | 220 | ||
221 | /** | ||
222 | * alloc_chrdev_region() - register a range of char device numbers | ||
223 | * @dev: output parameter for first assigned number | ||
224 | * @baseminor: first of the requested range of minor numbers | ||
225 | * @count: the number of minor numbers required | ||
226 | * @name: the name of the associated device or driver | ||
227 | * | ||
228 | * Allocates a range of char device numbers. The major number will be | ||
229 | * chosen dynamically, and returned (along with the first minor number) | ||
230 | * in @dev. Returns zero or a negative error code. | ||
231 | */ | ||
193 | int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, | 232 | int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, |
194 | const char *name) | 233 | const char *name) |
195 | { | 234 | { |
@@ -259,6 +298,15 @@ out2: | |||
259 | return err; | 298 | return err; |
260 | } | 299 | } |
261 | 300 | ||
301 | /** | ||
302 | * unregister_chrdev_region() - return a range of device numbers | ||
303 | * @from: the first in the range of numbers to unregister | ||
304 | * @count: the number of device numbers to unregister | ||
305 | * | ||
306 | * This function will unregister a range of @count device numbers, | ||
307 | * starting with @from. The caller should normally be the one who | ||
308 | * allocated those numbers in the first place... | ||
309 | */ | ||
262 | void unregister_chrdev_region(dev_t from, unsigned count) | 310 | void unregister_chrdev_region(dev_t from, unsigned count) |
263 | { | 311 | { |
264 | dev_t to = from + count; | 312 | dev_t to = from + count; |
@@ -396,6 +444,16 @@ static int exact_lock(dev_t dev, void *data) | |||
396 | return cdev_get(p) ? 0 : -1; | 444 | return cdev_get(p) ? 0 : -1; |
397 | } | 445 | } |
398 | 446 | ||
447 | /** | ||
448 | * cdev_add() - add a char device to the system | ||
449 | * @p: the cdev structure for the device | ||
450 | * @dev: the first device number for which this device is responsible | ||
451 | * @count: the number of consecutive minor numbers corresponding to this | ||
452 | * device | ||
453 | * | ||
454 | * cdev_add() adds the device represented by @p to the system, making it | ||
455 | * live immediately. A negative error code is returned on failure. | ||
456 | */ | ||
399 | int cdev_add(struct cdev *p, dev_t dev, unsigned count) | 457 | int cdev_add(struct cdev *p, dev_t dev, unsigned count) |
400 | { | 458 | { |
401 | p->dev = dev; | 459 | p->dev = dev; |
@@ -408,6 +466,13 @@ static void cdev_unmap(dev_t dev, unsigned count) | |||
408 | kobj_unmap(cdev_map, dev, count); | 466 | kobj_unmap(cdev_map, dev, count); |
409 | } | 467 | } |
410 | 468 | ||
469 | /** | ||
470 | * cdev_del() - remove a cdev from the system | ||
471 | * @p: the cdev structure to be removed | ||
472 | * | ||
473 | * cdev_del() removes @p from the system, possibly freeing the structure | ||
474 | * itself. | ||
475 | */ | ||
411 | void cdev_del(struct cdev *p) | 476 | void cdev_del(struct cdev *p) |
412 | { | 477 | { |
413 | cdev_unmap(p->dev, p->count); | 478 | cdev_unmap(p->dev, p->count); |
@@ -436,6 +501,11 @@ static struct kobj_type ktype_cdev_dynamic = { | |||
436 | .release = cdev_dynamic_release, | 501 | .release = cdev_dynamic_release, |
437 | }; | 502 | }; |
438 | 503 | ||
504 | /** | ||
505 | * cdev_alloc() - allocate a cdev structure | ||
506 | * | ||
507 | * Allocates and returns a cdev structure, or NULL on failure. | ||
508 | */ | ||
439 | struct cdev *cdev_alloc(void) | 509 | struct cdev *cdev_alloc(void) |
440 | { | 510 | { |
441 | struct cdev *p = kzalloc(sizeof(struct cdev), GFP_KERNEL); | 511 | struct cdev *p = kzalloc(sizeof(struct cdev), GFP_KERNEL); |
@@ -447,6 +517,14 @@ struct cdev *cdev_alloc(void) | |||
447 | return p; | 517 | return p; |
448 | } | 518 | } |
449 | 519 | ||
520 | /** | ||
521 | * cdev_init() - initialize a cdev structure | ||
522 | * @cdev: the structure to initialize | ||
523 | * @fops: the file_operations for this device | ||
524 | * | ||
525 | * Initializes @cdev, remembering @fops, making it ready to add to the | ||
526 | * system with cdev_add(). | ||
527 | */ | ||
450 | void cdev_init(struct cdev *cdev, const struct file_operations *fops) | 528 | void cdev_init(struct cdev *cdev, const struct file_operations *fops) |
451 | { | 529 | { |
452 | memset(cdev, 0, sizeof *cdev); | 530 | memset(cdev, 0, sizeof *cdev); |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 22bcf4d7e7ae..c00c654f2e11 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -480,25 +480,13 @@ cifs_get_sb(struct file_system_type *fs_type, | |||
480 | return simple_set_mnt(mnt, sb); | 480 | return simple_set_mnt(mnt, sb); |
481 | } | 481 | } |
482 | 482 | ||
483 | static ssize_t cifs_file_writev(struct file *file, const struct iovec *iov, | 483 | static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, |
484 | unsigned long nr_segs, loff_t *ppos) | 484 | unsigned long nr_segs, loff_t pos) |
485 | { | ||
486 | struct inode *inode = file->f_dentry->d_inode; | ||
487 | ssize_t written; | ||
488 | |||
489 | written = generic_file_writev(file, iov, nr_segs, ppos); | ||
490 | if (!CIFS_I(inode)->clientCanCacheAll) | ||
491 | filemap_fdatawrite(inode->i_mapping); | ||
492 | return written; | ||
493 | } | ||
494 | |||
495 | static ssize_t cifs_file_aio_write(struct kiocb *iocb, const char __user *buf, | ||
496 | size_t count, loff_t pos) | ||
497 | { | 485 | { |
498 | struct inode *inode = iocb->ki_filp->f_dentry->d_inode; | 486 | struct inode *inode = iocb->ki_filp->f_dentry->d_inode; |
499 | ssize_t written; | 487 | ssize_t written; |
500 | 488 | ||
501 | written = generic_file_aio_write(iocb, buf, count, pos); | 489 | written = generic_file_aio_write(iocb, iov, nr_segs, pos); |
502 | if (!CIFS_I(inode)->clientCanCacheAll) | 490 | if (!CIFS_I(inode)->clientCanCacheAll) |
503 | filemap_fdatawrite(inode->i_mapping); | 491 | filemap_fdatawrite(inode->i_mapping); |
504 | return written; | 492 | return written; |
@@ -577,8 +565,6 @@ struct inode_operations cifs_symlink_inode_ops = { | |||
577 | const struct file_operations cifs_file_ops = { | 565 | const struct file_operations cifs_file_ops = { |
578 | .read = do_sync_read, | 566 | .read = do_sync_read, |
579 | .write = do_sync_write, | 567 | .write = do_sync_write, |
580 | .readv = generic_file_readv, | ||
581 | .writev = cifs_file_writev, | ||
582 | .aio_read = generic_file_aio_read, | 568 | .aio_read = generic_file_aio_read, |
583 | .aio_write = cifs_file_aio_write, | 569 | .aio_write = cifs_file_aio_write, |
584 | .open = cifs_open, | 570 | .open = cifs_open, |
@@ -620,8 +606,6 @@ const struct file_operations cifs_file_direct_ops = { | |||
620 | const struct file_operations cifs_file_nobrl_ops = { | 606 | const struct file_operations cifs_file_nobrl_ops = { |
621 | .read = do_sync_read, | 607 | .read = do_sync_read, |
622 | .write = do_sync_write, | 608 | .write = do_sync_write, |
623 | .readv = generic_file_readv, | ||
624 | .writev = cifs_file_writev, | ||
625 | .aio_read = generic_file_aio_read, | 609 | .aio_read = generic_file_aio_read, |
626 | .aio_write = cifs_file_aio_write, | 610 | .aio_write = cifs_file_aio_write, |
627 | .open = cifs_open, | 611 | .open = cifs_open, |
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index ddb012a68023..976a691c5a68 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/backing-dev.h> | 25 | #include <linux/backing-dev.h> |
26 | #include <linux/stat.h> | 26 | #include <linux/stat.h> |
27 | #include <linux/fcntl.h> | 27 | #include <linux/fcntl.h> |
28 | #include <linux/mpage.h> | ||
29 | #include <linux/pagemap.h> | 28 | #include <linux/pagemap.h> |
30 | #include <linux/pagevec.h> | 29 | #include <linux/pagevec.h> |
31 | #include <linux/smp_lock.h> | 30 | #include <linux/smp_lock.h> |
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index b88147c1dc27..6b90ef98e4cf 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -19,7 +19,6 @@ | |||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | */ | 20 | */ |
21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
22 | #include <linux/buffer_head.h> | ||
23 | #include <linux/stat.h> | 22 | #include <linux/stat.h> |
24 | #include <linux/pagemap.h> | 23 | #include <linux/pagemap.h> |
25 | #include <asm/div64.h> | 24 | #include <asm/div64.h> |
@@ -591,7 +590,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
591 | 590 | ||
592 | if (!rc) { | 591 | if (!rc) { |
593 | if (direntry->d_inode) | 592 | if (direntry->d_inode) |
594 | direntry->d_inode->i_nlink--; | 593 | drop_nlink(direntry->d_inode); |
595 | } else if (rc == -ENOENT) { | 594 | } else if (rc == -ENOENT) { |
596 | d_drop(direntry); | 595 | d_drop(direntry); |
597 | } else if (rc == -ETXTBSY) { | 596 | } else if (rc == -ETXTBSY) { |
@@ -610,7 +609,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
610 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 609 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
611 | CIFSSMBClose(xid, pTcon, netfid); | 610 | CIFSSMBClose(xid, pTcon, netfid); |
612 | if (direntry->d_inode) | 611 | if (direntry->d_inode) |
613 | direntry->d_inode->i_nlink--; | 612 | drop_nlink(direntry->d_inode); |
614 | } | 613 | } |
615 | } else if (rc == -EACCES) { | 614 | } else if (rc == -EACCES) { |
616 | /* try only if r/o attribute set in local lookup data? */ | 615 | /* try only if r/o attribute set in local lookup data? */ |
@@ -664,7 +663,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
664 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 663 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
665 | if (!rc) { | 664 | if (!rc) { |
666 | if (direntry->d_inode) | 665 | if (direntry->d_inode) |
667 | direntry->d_inode->i_nlink--; | 666 | drop_nlink(direntry->d_inode); |
668 | } else if (rc == -ETXTBSY) { | 667 | } else if (rc == -ETXTBSY) { |
669 | int oplock = FALSE; | 668 | int oplock = FALSE; |
670 | __u16 netfid; | 669 | __u16 netfid; |
@@ -685,7 +684,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
685 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 684 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
686 | CIFSSMBClose(xid, pTcon, netfid); | 685 | CIFSSMBClose(xid, pTcon, netfid); |
687 | if (direntry->d_inode) | 686 | if (direntry->d_inode) |
688 | direntry->d_inode->i_nlink--; | 687 | drop_nlink(direntry->d_inode); |
689 | } | 688 | } |
690 | /* BB if rc = -ETXTBUSY goto the rename logic BB */ | 689 | /* BB if rc = -ETXTBUSY goto the rename logic BB */ |
691 | } | 690 | } |
@@ -736,7 +735,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
736 | cFYI(1, ("cifs_mkdir returned 0x%x", rc)); | 735 | cFYI(1, ("cifs_mkdir returned 0x%x", rc)); |
737 | d_drop(direntry); | 736 | d_drop(direntry); |
738 | } else { | 737 | } else { |
739 | inode->i_nlink++; | 738 | inc_nlink(inode); |
740 | if (pTcon->ses->capabilities & CAP_UNIX) | 739 | if (pTcon->ses->capabilities & CAP_UNIX) |
741 | rc = cifs_get_inode_info_unix(&newinode, full_path, | 740 | rc = cifs_get_inode_info_unix(&newinode, full_path, |
742 | inode->i_sb,xid); | 741 | inode->i_sb,xid); |
@@ -817,9 +816,9 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry) | |||
817 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 816 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
818 | 817 | ||
819 | if (!rc) { | 818 | if (!rc) { |
820 | inode->i_nlink--; | 819 | drop_nlink(inode); |
821 | i_size_write(direntry->d_inode,0); | 820 | i_size_write(direntry->d_inode,0); |
822 | direntry->d_inode->i_nlink = 0; | 821 | clear_nlink(direntry->d_inode); |
823 | } | 822 | } |
824 | 823 | ||
825 | cifsInode = CIFS_I(direntry->d_inode); | 824 | cifsInode = CIFS_I(direntry->d_inode); |
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c index b0ea6687ab55..e34c7db00f6f 100644 --- a/fs/cifs/ioctl.c +++ b/fs/cifs/ioctl.c | |||
@@ -22,7 +22,6 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/fs.h> | 24 | #include <linux/fs.h> |
25 | #include <linux/ext2_fs.h> | ||
26 | #include "cifspdu.h" | 25 | #include "cifspdu.h" |
27 | #include "cifsglob.h" | 26 | #include "cifsglob.h" |
28 | #include "cifsproto.h" | 27 | #include "cifsproto.h" |
@@ -74,7 +73,7 @@ int cifs_ioctl (struct inode * inode, struct file * filep, | |||
74 | } | 73 | } |
75 | break; | 74 | break; |
76 | #ifdef CONFIG_CIFS_POSIX | 75 | #ifdef CONFIG_CIFS_POSIX |
77 | case EXT2_IOC_GETFLAGS: | 76 | case FS_IOC_GETFLAGS: |
78 | if(CIFS_UNIX_EXTATTR_CAP & caps) { | 77 | if(CIFS_UNIX_EXTATTR_CAP & caps) { |
79 | if (pSMBFile == NULL) | 78 | if (pSMBFile == NULL) |
80 | break; | 79 | break; |
@@ -82,12 +81,12 @@ int cifs_ioctl (struct inode * inode, struct file * filep, | |||
82 | &ExtAttrBits, &ExtAttrMask); | 81 | &ExtAttrBits, &ExtAttrMask); |
83 | if(rc == 0) | 82 | if(rc == 0) |
84 | rc = put_user(ExtAttrBits & | 83 | rc = put_user(ExtAttrBits & |
85 | EXT2_FL_USER_VISIBLE, | 84 | FS_FL_USER_VISIBLE, |
86 | (int __user *)arg); | 85 | (int __user *)arg); |
87 | } | 86 | } |
88 | break; | 87 | break; |
89 | 88 | ||
90 | case EXT2_IOC_SETFLAGS: | 89 | case FS_IOC_SETFLAGS: |
91 | if(CIFS_UNIX_EXTATTR_CAP & caps) { | 90 | if(CIFS_UNIX_EXTATTR_CAP & caps) { |
92 | if(get_user(ExtAttrBits,(int __user *)arg)) { | 91 | if(get_user(ExtAttrBits,(int __user *)arg)) { |
93 | rc = -EFAULT; | 92 | rc = -EFAULT; |
diff --git a/fs/coda/dir.c b/fs/coda/dir.c index 8651ea6a23b7..0102b28a15fb 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c | |||
@@ -304,7 +304,7 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode, | |||
304 | coda_dir_changed(dir_inode, 0); | 304 | coda_dir_changed(dir_inode, 0); |
305 | atomic_inc(&inode->i_count); | 305 | atomic_inc(&inode->i_count); |
306 | d_instantiate(de, inode); | 306 | d_instantiate(de, inode); |
307 | inode->i_nlink++; | 307 | inc_nlink(inode); |
308 | 308 | ||
309 | out: | 309 | out: |
310 | unlock_kernel(); | 310 | unlock_kernel(); |
@@ -367,7 +367,7 @@ int coda_unlink(struct inode *dir, struct dentry *de) | |||
367 | } | 367 | } |
368 | 368 | ||
369 | coda_dir_changed(dir, 0); | 369 | coda_dir_changed(dir, 0); |
370 | de->d_inode->i_nlink--; | 370 | drop_nlink(de->d_inode); |
371 | unlock_kernel(); | 371 | unlock_kernel(); |
372 | 372 | ||
373 | return 0; | 373 | return 0; |
@@ -394,7 +394,7 @@ int coda_rmdir(struct inode *dir, struct dentry *de) | |||
394 | } | 394 | } |
395 | 395 | ||
396 | coda_dir_changed(dir, -1); | 396 | coda_dir_changed(dir, -1); |
397 | de->d_inode->i_nlink--; | 397 | drop_nlink(de->d_inode); |
398 | d_delete(de); | 398 | d_delete(de); |
399 | unlock_kernel(); | 399 | unlock_kernel(); |
400 | 400 | ||
diff --git a/fs/compat.c b/fs/compat.c index ce982f6e8c80..13fb08d096c4 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include <linux/nfsd/syscall.h> | 44 | #include <linux/nfsd/syscall.h> |
45 | #include <linux/personality.h> | 45 | #include <linux/personality.h> |
46 | #include <linux/rwsem.h> | 46 | #include <linux/rwsem.h> |
47 | #include <linux/acct.h> | 47 | #include <linux/tsacct_kern.h> |
48 | #include <linux/mm.h> | 48 | #include <linux/mm.h> |
49 | 49 | ||
50 | #include <net/sock.h> /* siocdevprivate_ioctl */ | 50 | #include <net/sock.h> /* siocdevprivate_ioctl */ |
@@ -52,11 +52,12 @@ | |||
52 | #include <asm/uaccess.h> | 52 | #include <asm/uaccess.h> |
53 | #include <asm/mmu_context.h> | 53 | #include <asm/mmu_context.h> |
54 | #include <asm/ioctls.h> | 54 | #include <asm/ioctls.h> |
55 | 55 | #include "internal.h" | |
56 | extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat); | ||
57 | 56 | ||
58 | int compat_log = 1; | 57 | int compat_log = 1; |
59 | 58 | ||
59 | extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat); | ||
60 | |||
60 | int compat_printk(const char *fmt, ...) | 61 | int compat_printk(const char *fmt, ...) |
61 | { | 62 | { |
62 | va_list ap; | 63 | va_list ap; |
@@ -69,6 +70,8 @@ int compat_printk(const char *fmt, ...) | |||
69 | return ret; | 70 | return ret; |
70 | } | 71 | } |
71 | 72 | ||
73 | #include "read_write.h" | ||
74 | |||
72 | /* | 75 | /* |
73 | * Not all architectures have sys_utime, so implement this in terms | 76 | * Not all architectures have sys_utime, so implement this in terms |
74 | * of sys_utimes. | 77 | * of sys_utimes. |
@@ -313,9 +316,6 @@ out: | |||
313 | #define IOCTL_HASHSIZE 256 | 316 | #define IOCTL_HASHSIZE 256 |
314 | static struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE]; | 317 | static struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE]; |
315 | 318 | ||
316 | extern struct ioctl_trans ioctl_start[]; | ||
317 | extern int ioctl_table_size; | ||
318 | |||
319 | static inline unsigned long ioctl32_hash(unsigned long cmd) | 319 | static inline unsigned long ioctl32_hash(unsigned long cmd) |
320 | { | 320 | { |
321 | return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE; | 321 | return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE; |
@@ -838,8 +838,6 @@ static int do_nfs4_super_data_conv(void *raw_data) | |||
838 | return 0; | 838 | return 0; |
839 | } | 839 | } |
840 | 840 | ||
841 | extern int copy_mount_options (const void __user *, unsigned long *); | ||
842 | |||
843 | #define SMBFS_NAME "smbfs" | 841 | #define SMBFS_NAME "smbfs" |
844 | #define NCPFS_NAME "ncpfs" | 842 | #define NCPFS_NAME "ncpfs" |
845 | #define NFS4_NAME "nfs4" | 843 | #define NFS4_NAME "nfs4" |
@@ -1153,9 +1151,6 @@ static ssize_t compat_do_readv_writev(int type, struct file *file, | |||
1153 | const struct compat_iovec __user *uvector, | 1151 | const struct compat_iovec __user *uvector, |
1154 | unsigned long nr_segs, loff_t *pos) | 1152 | unsigned long nr_segs, loff_t *pos) |
1155 | { | 1153 | { |
1156 | typedef ssize_t (*io_fn_t)(struct file *, char __user *, size_t, loff_t *); | ||
1157 | typedef ssize_t (*iov_fn_t)(struct file *, const struct iovec *, unsigned long, loff_t *); | ||
1158 | |||
1159 | compat_ssize_t tot_len; | 1154 | compat_ssize_t tot_len; |
1160 | struct iovec iovstack[UIO_FASTIOV]; | 1155 | struct iovec iovstack[UIO_FASTIOV]; |
1161 | struct iovec *iov=iovstack, *vector; | 1156 | struct iovec *iov=iovstack, *vector; |
@@ -1238,39 +1233,18 @@ static ssize_t compat_do_readv_writev(int type, struct file *file, | |||
1238 | fnv = NULL; | 1233 | fnv = NULL; |
1239 | if (type == READ) { | 1234 | if (type == READ) { |
1240 | fn = file->f_op->read; | 1235 | fn = file->f_op->read; |
1241 | fnv = file->f_op->readv; | 1236 | fnv = file->f_op->aio_read; |
1242 | } else { | 1237 | } else { |
1243 | fn = (io_fn_t)file->f_op->write; | 1238 | fn = (io_fn_t)file->f_op->write; |
1244 | fnv = file->f_op->writev; | 1239 | fnv = file->f_op->aio_write; |
1245 | } | ||
1246 | if (fnv) { | ||
1247 | ret = fnv(file, iov, nr_segs, pos); | ||
1248 | goto out; | ||
1249 | } | 1240 | } |
1250 | 1241 | ||
1251 | /* Do it by hand, with file-ops */ | 1242 | if (fnv) |
1252 | ret = 0; | 1243 | ret = do_sync_readv_writev(file, iov, nr_segs, tot_len, |
1253 | vector = iov; | 1244 | pos, fnv); |
1254 | while (nr_segs > 0) { | 1245 | else |
1255 | void __user * base; | 1246 | ret = do_loop_readv_writev(file, iov, nr_segs, pos, fn); |
1256 | size_t len; | ||
1257 | ssize_t nr; | ||
1258 | |||
1259 | base = vector->iov_base; | ||
1260 | len = vector->iov_len; | ||
1261 | vector++; | ||
1262 | nr_segs--; | ||
1263 | |||
1264 | nr = fn(file, base, len, pos); | ||
1265 | 1247 | ||
1266 | if (nr < 0) { | ||
1267 | if (!ret) ret = nr; | ||
1268 | break; | ||
1269 | } | ||
1270 | ret += nr; | ||
1271 | if (nr != len) | ||
1272 | break; | ||
1273 | } | ||
1274 | out: | 1248 | out: |
1275 | if (iov != iovstack) | 1249 | if (iov != iovstack) |
1276 | kfree(iov); | 1250 | kfree(iov); |
@@ -1298,7 +1272,7 @@ compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec, unsign | |||
1298 | goto out; | 1272 | goto out; |
1299 | 1273 | ||
1300 | ret = -EINVAL; | 1274 | ret = -EINVAL; |
1301 | if (!file->f_op || (!file->f_op->readv && !file->f_op->read)) | 1275 | if (!file->f_op || (!file->f_op->aio_read && !file->f_op->read)) |
1302 | goto out; | 1276 | goto out; |
1303 | 1277 | ||
1304 | ret = compat_do_readv_writev(READ, file, vec, vlen, &file->f_pos); | 1278 | ret = compat_do_readv_writev(READ, file, vec, vlen, &file->f_pos); |
@@ -1321,7 +1295,7 @@ compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec, unsig | |||
1321 | goto out; | 1295 | goto out; |
1322 | 1296 | ||
1323 | ret = -EINVAL; | 1297 | ret = -EINVAL; |
1324 | if (!file->f_op || (!file->f_op->writev && !file->f_op->write)) | 1298 | if (!file->f_op || (!file->f_op->aio_write && !file->f_op->write)) |
1325 | goto out; | 1299 | goto out; |
1326 | 1300 | ||
1327 | ret = compat_do_readv_writev(WRITE, file, vec, vlen, &file->f_pos); | 1301 | ret = compat_do_readv_writev(WRITE, file, vec, vlen, &file->f_pos); |
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 4063a9396977..27ca1aa30562 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -40,15 +40,11 @@ | |||
40 | #include <linux/if_pppox.h> | 40 | #include <linux/if_pppox.h> |
41 | #include <linux/mtio.h> | 41 | #include <linux/mtio.h> |
42 | #include <linux/cdrom.h> | 42 | #include <linux/cdrom.h> |
43 | #include <linux/loop.h> | ||
44 | #include <linux/auto_fs.h> | 43 | #include <linux/auto_fs.h> |
45 | #include <linux/auto_fs4.h> | 44 | #include <linux/auto_fs4.h> |
46 | #include <linux/tty.h> | 45 | #include <linux/tty.h> |
47 | #include <linux/vt_kern.h> | 46 | #include <linux/vt_kern.h> |
48 | #include <linux/fb.h> | 47 | #include <linux/fb.h> |
49 | #include <linux/ext2_fs.h> | ||
50 | #include <linux/ext3_jbd.h> | ||
51 | #include <linux/ext3_fs.h> | ||
52 | #include <linux/videodev.h> | 48 | #include <linux/videodev.h> |
53 | #include <linux/netdevice.h> | 49 | #include <linux/netdevice.h> |
54 | #include <linux/raw.h> | 50 | #include <linux/raw.h> |
@@ -60,12 +56,10 @@ | |||
60 | #include <linux/pci.h> | 56 | #include <linux/pci.h> |
61 | #include <linux/module.h> | 57 | #include <linux/module.h> |
62 | #include <linux/serial.h> | 58 | #include <linux/serial.h> |
63 | #include <linux/reiserfs_fs.h> | ||
64 | #include <linux/if_tun.h> | 59 | #include <linux/if_tun.h> |
65 | #include <linux/ctype.h> | 60 | #include <linux/ctype.h> |
66 | #include <linux/ioctl32.h> | 61 | #include <linux/ioctl32.h> |
67 | #include <linux/syscalls.h> | 62 | #include <linux/syscalls.h> |
68 | #include <linux/ncp_fs.h> | ||
69 | #include <linux/i2c.h> | 63 | #include <linux/i2c.h> |
70 | #include <linux/i2c-dev.h> | 64 | #include <linux/i2c-dev.h> |
71 | #include <linux/wireless.h> | 65 | #include <linux/wireless.h> |
@@ -113,7 +107,6 @@ | |||
113 | #include <linux/nbd.h> | 107 | #include <linux/nbd.h> |
114 | #include <linux/random.h> | 108 | #include <linux/random.h> |
115 | #include <linux/filter.h> | 109 | #include <linux/filter.h> |
116 | #include <linux/msdos_fs.h> | ||
117 | #include <linux/pktcdvd.h> | 110 | #include <linux/pktcdvd.h> |
118 | 111 | ||
119 | #include <linux/hiddev.h> | 112 | #include <linux/hiddev.h> |
@@ -124,21 +117,6 @@ | |||
124 | #include <linux/dvb/video.h> | 117 | #include <linux/dvb/video.h> |
125 | #include <linux/lp.h> | 118 | #include <linux/lp.h> |
126 | 119 | ||
127 | /* Aiee. Someone does not find a difference between int and long */ | ||
128 | #define EXT2_IOC32_GETFLAGS _IOR('f', 1, int) | ||
129 | #define EXT2_IOC32_SETFLAGS _IOW('f', 2, int) | ||
130 | #define EXT3_IOC32_GETVERSION _IOR('f', 3, int) | ||
131 | #define EXT3_IOC32_SETVERSION _IOW('f', 4, int) | ||
132 | #define EXT3_IOC32_GETRSVSZ _IOR('f', 5, int) | ||
133 | #define EXT3_IOC32_SETRSVSZ _IOW('f', 6, int) | ||
134 | #define EXT3_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int) | ||
135 | #ifdef CONFIG_JBD_DEBUG | ||
136 | #define EXT3_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int) | ||
137 | #endif | ||
138 | |||
139 | #define EXT2_IOC32_GETVERSION _IOR('v', 1, int) | ||
140 | #define EXT2_IOC32_SETVERSION _IOW('v', 2, int) | ||
141 | |||
142 | static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, | 120 | static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, |
143 | unsigned long arg, struct file *f) | 121 | unsigned long arg, struct file *f) |
144 | { | 122 | { |
@@ -176,34 +154,6 @@ static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
176 | return err; | 154 | return err; |
177 | } | 155 | } |
178 | 156 | ||
179 | static int do_ext2_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
180 | { | ||
181 | /* These are just misnamed, they actually get/put from/to user an int */ | ||
182 | switch (cmd) { | ||
183 | case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break; | ||
184 | case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break; | ||
185 | case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; break; | ||
186 | case EXT2_IOC32_SETVERSION: cmd = EXT2_IOC_SETVERSION; break; | ||
187 | } | ||
188 | return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg)); | ||
189 | } | ||
190 | |||
191 | static int do_ext3_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
192 | { | ||
193 | /* These are just misnamed, they actually get/put from/to user an int */ | ||
194 | switch (cmd) { | ||
195 | case EXT3_IOC32_GETVERSION: cmd = EXT3_IOC_GETVERSION; break; | ||
196 | case EXT3_IOC32_SETVERSION: cmd = EXT3_IOC_SETVERSION; break; | ||
197 | case EXT3_IOC32_GETRSVSZ: cmd = EXT3_IOC_GETRSVSZ; break; | ||
198 | case EXT3_IOC32_SETRSVSZ: cmd = EXT3_IOC_SETRSVSZ; break; | ||
199 | case EXT3_IOC32_GROUP_EXTEND: cmd = EXT3_IOC_GROUP_EXTEND; break; | ||
200 | #ifdef CONFIG_JBD_DEBUG | ||
201 | case EXT3_IOC32_WAIT_FOR_READONLY: cmd = EXT3_IOC_WAIT_FOR_READONLY; break; | ||
202 | #endif | ||
203 | } | ||
204 | return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg)); | ||
205 | } | ||
206 | |||
207 | struct compat_video_event { | 157 | struct compat_video_event { |
208 | int32_t type; | 158 | int32_t type; |
209 | compat_time_t timestamp; | 159 | compat_time_t timestamp; |
@@ -694,6 +644,7 @@ out: | |||
694 | } | 644 | } |
695 | #endif | 645 | #endif |
696 | 646 | ||
647 | #ifdef CONFIG_BLOCK | ||
697 | struct hd_geometry32 { | 648 | struct hd_geometry32 { |
698 | unsigned char heads; | 649 | unsigned char heads; |
699 | unsigned char sectors; | 650 | unsigned char sectors; |
@@ -918,6 +869,7 @@ static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
918 | } | 869 | } |
919 | return err; | 870 | return err; |
920 | } | 871 | } |
872 | #endif /* CONFIG_BLOCK */ | ||
921 | 873 | ||
922 | struct sock_fprog32 { | 874 | struct sock_fprog32 { |
923 | unsigned short len; | 875 | unsigned short len; |
@@ -1041,6 +993,7 @@ static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
1041 | } | 993 | } |
1042 | 994 | ||
1043 | 995 | ||
996 | #ifdef CONFIG_BLOCK | ||
1044 | struct mtget32 { | 997 | struct mtget32 { |
1045 | compat_long_t mt_type; | 998 | compat_long_t mt_type; |
1046 | compat_long_t mt_resid; | 999 | compat_long_t mt_resid; |
@@ -1213,73 +1166,7 @@ static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long ar | |||
1213 | 1166 | ||
1214 | return err; | 1167 | return err; |
1215 | } | 1168 | } |
1216 | 1169 | #endif /* CONFIG_BLOCK */ | |
1217 | struct loop_info32 { | ||
1218 | compat_int_t lo_number; /* ioctl r/o */ | ||
1219 | compat_dev_t lo_device; /* ioctl r/o */ | ||
1220 | compat_ulong_t lo_inode; /* ioctl r/o */ | ||
1221 | compat_dev_t lo_rdevice; /* ioctl r/o */ | ||
1222 | compat_int_t lo_offset; | ||
1223 | compat_int_t lo_encrypt_type; | ||
1224 | compat_int_t lo_encrypt_key_size; /* ioctl w/o */ | ||
1225 | compat_int_t lo_flags; /* ioctl r/o */ | ||
1226 | char lo_name[LO_NAME_SIZE]; | ||
1227 | unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */ | ||
1228 | compat_ulong_t lo_init[2]; | ||
1229 | char reserved[4]; | ||
1230 | }; | ||
1231 | |||
1232 | static int loop_status(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
1233 | { | ||
1234 | mm_segment_t old_fs = get_fs(); | ||
1235 | struct loop_info l; | ||
1236 | struct loop_info32 __user *ul; | ||
1237 | int err = -EINVAL; | ||
1238 | |||
1239 | ul = compat_ptr(arg); | ||
1240 | switch(cmd) { | ||
1241 | case LOOP_SET_STATUS: | ||
1242 | err = get_user(l.lo_number, &ul->lo_number); | ||
1243 | err |= __get_user(l.lo_device, &ul->lo_device); | ||
1244 | err |= __get_user(l.lo_inode, &ul->lo_inode); | ||
1245 | err |= __get_user(l.lo_rdevice, &ul->lo_rdevice); | ||
1246 | err |= __copy_from_user(&l.lo_offset, &ul->lo_offset, | ||
1247 | 8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset); | ||
1248 | if (err) { | ||
1249 | err = -EFAULT; | ||
1250 | } else { | ||
1251 | set_fs (KERNEL_DS); | ||
1252 | err = sys_ioctl (fd, cmd, (unsigned long)&l); | ||
1253 | set_fs (old_fs); | ||
1254 | } | ||
1255 | break; | ||
1256 | case LOOP_GET_STATUS: | ||
1257 | set_fs (KERNEL_DS); | ||
1258 | err = sys_ioctl (fd, cmd, (unsigned long)&l); | ||
1259 | set_fs (old_fs); | ||
1260 | if (!err) { | ||
1261 | err = put_user(l.lo_number, &ul->lo_number); | ||
1262 | err |= __put_user(l.lo_device, &ul->lo_device); | ||
1263 | err |= __put_user(l.lo_inode, &ul->lo_inode); | ||
1264 | err |= __put_user(l.lo_rdevice, &ul->lo_rdevice); | ||
1265 | err |= __copy_to_user(&ul->lo_offset, &l.lo_offset, | ||
1266 | (unsigned long)l.lo_init - (unsigned long)&l.lo_offset); | ||
1267 | if (err) | ||
1268 | err = -EFAULT; | ||
1269 | } | ||
1270 | break; | ||
1271 | default: { | ||
1272 | static int count; | ||
1273 | if (++count <= 20) | ||
1274 | printk("%s: Unknown loop ioctl cmd, fd(%d) " | ||
1275 | "cmd(%08x) arg(%08lx)\n", | ||
1276 | __FUNCTION__, fd, cmd, arg); | ||
1277 | } | ||
1278 | } | ||
1279 | return err; | ||
1280 | } | ||
1281 | |||
1282 | extern int tty_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg); | ||
1283 | 1170 | ||
1284 | #ifdef CONFIG_VT | 1171 | #ifdef CONFIG_VT |
1285 | 1172 | ||
@@ -1607,6 +1494,7 @@ ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
1607 | return -EINVAL; | 1494 | return -EINVAL; |
1608 | } | 1495 | } |
1609 | 1496 | ||
1497 | #ifdef CONFIG_BLOCK | ||
1610 | static int broken_blkgetsize(unsigned int fd, unsigned int cmd, unsigned long arg) | 1498 | static int broken_blkgetsize(unsigned int fd, unsigned int cmd, unsigned long arg) |
1611 | { | 1499 | { |
1612 | /* The mkswap binary hard codes it to Intel value :-((( */ | 1500 | /* The mkswap binary hard codes it to Intel value :-((( */ |
@@ -1641,12 +1529,14 @@ static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long ar | |||
1641 | 1529 | ||
1642 | return sys_ioctl(fd, cmd, (unsigned long)a); | 1530 | return sys_ioctl(fd, cmd, (unsigned long)a); |
1643 | } | 1531 | } |
1532 | #endif | ||
1644 | 1533 | ||
1645 | static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg) | 1534 | static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg) |
1646 | { | 1535 | { |
1647 | return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg); | 1536 | return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg); |
1648 | } | 1537 | } |
1649 | 1538 | ||
1539 | #ifdef CONFIG_BLOCK | ||
1650 | /* Fix sizeof(sizeof()) breakage */ | 1540 | /* Fix sizeof(sizeof()) breakage */ |
1651 | #define BLKBSZGET_32 _IOR(0x12,112,int) | 1541 | #define BLKBSZGET_32 _IOR(0x12,112,int) |
1652 | #define BLKBSZSET_32 _IOW(0x12,113,int) | 1542 | #define BLKBSZSET_32 _IOW(0x12,113,int) |
@@ -1667,6 +1557,7 @@ static int do_blkgetsize64(unsigned int fd, unsigned int cmd, | |||
1667 | { | 1557 | { |
1668 | return sys_ioctl(fd, BLKGETSIZE64, (unsigned long)compat_ptr(arg)); | 1558 | return sys_ioctl(fd, BLKGETSIZE64, (unsigned long)compat_ptr(arg)); |
1669 | } | 1559 | } |
1560 | #endif | ||
1670 | 1561 | ||
1671 | /* Bluetooth ioctls */ | 1562 | /* Bluetooth ioctls */ |
1672 | #define HCIUARTSETPROTO _IOW('U', 200, int) | 1563 | #define HCIUARTSETPROTO _IOW('U', 200, int) |
@@ -1687,6 +1578,7 @@ static int do_blkgetsize64(unsigned int fd, unsigned int cmd, | |||
1687 | #define HIDPGETCONNLIST _IOR('H', 210, int) | 1578 | #define HIDPGETCONNLIST _IOR('H', 210, int) |
1688 | #define HIDPGETCONNINFO _IOR('H', 211, int) | 1579 | #define HIDPGETCONNINFO _IOR('H', 211, int) |
1689 | 1580 | ||
1581 | #ifdef CONFIG_BLOCK | ||
1690 | struct floppy_struct32 { | 1582 | struct floppy_struct32 { |
1691 | compat_uint_t size; | 1583 | compat_uint_t size; |
1692 | compat_uint_t sect; | 1584 | compat_uint_t sect; |
@@ -2011,6 +1903,7 @@ out: | |||
2011 | kfree(karg); | 1903 | kfree(karg); |
2012 | return err; | 1904 | return err; |
2013 | } | 1905 | } |
1906 | #endif | ||
2014 | 1907 | ||
2015 | struct mtd_oob_buf32 { | 1908 | struct mtd_oob_buf32 { |
2016 | u_int32_t start; | 1909 | u_int32_t start; |
@@ -2052,61 +1945,7 @@ static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
2052 | return err; | 1945 | return err; |
2053 | } | 1946 | } |
2054 | 1947 | ||
2055 | #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2]) | 1948 | #ifdef CONFIG_BLOCK |
2056 | #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2]) | ||
2057 | |||
2058 | static long | ||
2059 | put_dirent32 (struct dirent *d, struct compat_dirent __user *d32) | ||
2060 | { | ||
2061 | if (!access_ok(VERIFY_WRITE, d32, sizeof(struct compat_dirent))) | ||
2062 | return -EFAULT; | ||
2063 | |||
2064 | __put_user(d->d_ino, &d32->d_ino); | ||
2065 | __put_user(d->d_off, &d32->d_off); | ||
2066 | __put_user(d->d_reclen, &d32->d_reclen); | ||
2067 | if (__copy_to_user(d32->d_name, d->d_name, d->d_reclen)) | ||
2068 | return -EFAULT; | ||
2069 | |||
2070 | return 0; | ||
2071 | } | ||
2072 | |||
2073 | static int vfat_ioctl32(unsigned fd, unsigned cmd, unsigned long arg) | ||
2074 | { | ||
2075 | struct compat_dirent __user *p = compat_ptr(arg); | ||
2076 | int ret; | ||
2077 | mm_segment_t oldfs = get_fs(); | ||
2078 | struct dirent d[2]; | ||
2079 | |||
2080 | switch(cmd) | ||
2081 | { | ||
2082 | case VFAT_IOCTL_READDIR_BOTH32: | ||
2083 | cmd = VFAT_IOCTL_READDIR_BOTH; | ||
2084 | break; | ||
2085 | case VFAT_IOCTL_READDIR_SHORT32: | ||
2086 | cmd = VFAT_IOCTL_READDIR_SHORT; | ||
2087 | break; | ||
2088 | } | ||
2089 | |||
2090 | set_fs(KERNEL_DS); | ||
2091 | ret = sys_ioctl(fd,cmd,(unsigned long)&d); | ||
2092 | set_fs(oldfs); | ||
2093 | if (ret >= 0) { | ||
2094 | ret |= put_dirent32(&d[0], p); | ||
2095 | ret |= put_dirent32(&d[1], p + 1); | ||
2096 | } | ||
2097 | return ret; | ||
2098 | } | ||
2099 | |||
2100 | #define REISERFS_IOC_UNPACK32 _IOW(0xCD,1,int) | ||
2101 | |||
2102 | static int reiserfs_ioctl32(unsigned fd, unsigned cmd, unsigned long ptr) | ||
2103 | { | ||
2104 | if (cmd == REISERFS_IOC_UNPACK32) | ||
2105 | cmd = REISERFS_IOC_UNPACK; | ||
2106 | |||
2107 | return sys_ioctl(fd,cmd,ptr); | ||
2108 | } | ||
2109 | |||
2110 | struct raw32_config_request | 1949 | struct raw32_config_request |
2111 | { | 1950 | { |
2112 | compat_int_t raw_minor; | 1951 | compat_int_t raw_minor; |
@@ -2171,6 +2010,7 @@ static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | |||
2171 | } | 2010 | } |
2172 | return ret; | 2011 | return ret; |
2173 | } | 2012 | } |
2013 | #endif /* CONFIG_BLOCK */ | ||
2174 | 2014 | ||
2175 | struct serial_struct32 { | 2015 | struct serial_struct32 { |
2176 | compat_int_t type; | 2016 | compat_int_t type; |
@@ -2507,193 +2347,6 @@ static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | |||
2507 | } | 2347 | } |
2508 | } | 2348 | } |
2509 | 2349 | ||
2510 | #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE) | ||
2511 | struct ncp_ioctl_request_32 { | ||
2512 | u32 function; | ||
2513 | u32 size; | ||
2514 | compat_caddr_t data; | ||
2515 | }; | ||
2516 | |||
2517 | struct ncp_fs_info_v2_32 { | ||
2518 | s32 version; | ||
2519 | u32 mounted_uid; | ||
2520 | u32 connection; | ||
2521 | u32 buffer_size; | ||
2522 | |||
2523 | u32 volume_number; | ||
2524 | u32 directory_id; | ||
2525 | |||
2526 | u32 dummy1; | ||
2527 | u32 dummy2; | ||
2528 | u32 dummy3; | ||
2529 | }; | ||
2530 | |||
2531 | struct ncp_objectname_ioctl_32 | ||
2532 | { | ||
2533 | s32 auth_type; | ||
2534 | u32 object_name_len; | ||
2535 | compat_caddr_t object_name; /* an userspace data, in most cases user name */ | ||
2536 | }; | ||
2537 | |||
2538 | struct ncp_privatedata_ioctl_32 | ||
2539 | { | ||
2540 | u32 len; | ||
2541 | compat_caddr_t data; /* ~1000 for NDS */ | ||
2542 | }; | ||
2543 | |||
2544 | #define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct ncp_ioctl_request_32) | ||
2545 | #define NCP_IOC_GETMOUNTUID2_32 _IOW('n', 2, u32) | ||
2546 | #define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct ncp_fs_info_v2_32) | ||
2547 | #define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct ncp_objectname_ioctl_32) | ||
2548 | #define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct ncp_objectname_ioctl_32) | ||
2549 | #define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct ncp_privatedata_ioctl_32) | ||
2550 | #define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct ncp_privatedata_ioctl_32) | ||
2551 | |||
2552 | static int do_ncp_ncprequest(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
2553 | { | ||
2554 | struct ncp_ioctl_request_32 n32; | ||
2555 | struct ncp_ioctl_request __user *p = compat_alloc_user_space(sizeof(*p)); | ||
2556 | |||
2557 | if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)) || | ||
2558 | put_user(n32.function, &p->function) || | ||
2559 | put_user(n32.size, &p->size) || | ||
2560 | put_user(compat_ptr(n32.data), &p->data)) | ||
2561 | return -EFAULT; | ||
2562 | |||
2563 | return sys_ioctl(fd, NCP_IOC_NCPREQUEST, (unsigned long)p); | ||
2564 | } | ||
2565 | |||
2566 | static int do_ncp_getmountuid2(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
2567 | { | ||
2568 | mm_segment_t old_fs = get_fs(); | ||
2569 | __kernel_uid_t kuid; | ||
2570 | int err; | ||
2571 | |||
2572 | cmd = NCP_IOC_GETMOUNTUID2; | ||
2573 | |||
2574 | set_fs(KERNEL_DS); | ||
2575 | err = sys_ioctl(fd, cmd, (unsigned long)&kuid); | ||
2576 | set_fs(old_fs); | ||
2577 | |||
2578 | if (!err) | ||
2579 | err = put_user(kuid, | ||
2580 | (unsigned int __user *) compat_ptr(arg)); | ||
2581 | |||
2582 | return err; | ||
2583 | } | ||
2584 | |||
2585 | static int do_ncp_getfsinfo2(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
2586 | { | ||
2587 | mm_segment_t old_fs = get_fs(); | ||
2588 | struct ncp_fs_info_v2_32 n32; | ||
2589 | struct ncp_fs_info_v2 n; | ||
2590 | int err; | ||
2591 | |||
2592 | if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32))) | ||
2593 | return -EFAULT; | ||
2594 | if (n32.version != NCP_GET_FS_INFO_VERSION_V2) | ||
2595 | return -EINVAL; | ||
2596 | n.version = NCP_GET_FS_INFO_VERSION_V2; | ||
2597 | |||
2598 | set_fs(KERNEL_DS); | ||
2599 | err = sys_ioctl(fd, NCP_IOC_GET_FS_INFO_V2, (unsigned long)&n); | ||
2600 | set_fs(old_fs); | ||
2601 | |||
2602 | if (!err) { | ||
2603 | n32.version = n.version; | ||
2604 | n32.mounted_uid = n.mounted_uid; | ||
2605 | n32.connection = n.connection; | ||
2606 | n32.buffer_size = n.buffer_size; | ||
2607 | n32.volume_number = n.volume_number; | ||
2608 | n32.directory_id = n.directory_id; | ||
2609 | n32.dummy1 = n.dummy1; | ||
2610 | n32.dummy2 = n.dummy2; | ||
2611 | n32.dummy3 = n.dummy3; | ||
2612 | err = copy_to_user(compat_ptr(arg), &n32, sizeof(n32)) ? -EFAULT : 0; | ||
2613 | } | ||
2614 | return err; | ||
2615 | } | ||
2616 | |||
2617 | static int do_ncp_getobjectname(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
2618 | { | ||
2619 | struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg); | ||
2620 | struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p)); | ||
2621 | s32 auth_type; | ||
2622 | u32 name_len; | ||
2623 | int err; | ||
2624 | |||
2625 | if (copy_from_user(&n32, p32, sizeof(n32)) || | ||
2626 | put_user(n32.object_name_len, &p->object_name_len) || | ||
2627 | put_user(compat_ptr(n32.object_name), &p->object_name)) | ||
2628 | return -EFAULT; | ||
2629 | |||
2630 | err = sys_ioctl(fd, NCP_IOC_GETOBJECTNAME, (unsigned long)p); | ||
2631 | if (err) | ||
2632 | return err; | ||
2633 | |||
2634 | if (get_user(auth_type, &p->auth_type) || | ||
2635 | put_user(auth_type, &p32->auth_type) || | ||
2636 | get_user(name_len, &p->object_name_len) || | ||
2637 | put_user(name_len, &p32->object_name_len)) | ||
2638 | return -EFAULT; | ||
2639 | |||
2640 | return 0; | ||
2641 | } | ||
2642 | |||
2643 | static int do_ncp_setobjectname(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
2644 | { | ||
2645 | struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg); | ||
2646 | struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p)); | ||
2647 | |||
2648 | if (copy_from_user(&n32, p32, sizeof(n32)) || | ||
2649 | put_user(n32.auth_type, &p->auth_type) || | ||
2650 | put_user(n32.object_name_len, &p->object_name_len) || | ||
2651 | put_user(compat_ptr(n32.object_name), &p->object_name)) | ||
2652 | return -EFAULT; | ||
2653 | |||
2654 | return sys_ioctl(fd, NCP_IOC_SETOBJECTNAME, (unsigned long)p); | ||
2655 | } | ||
2656 | |||
2657 | static int do_ncp_getprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
2658 | { | ||
2659 | struct ncp_privatedata_ioctl_32 n32, __user *p32 = compat_ptr(arg); | ||
2660 | struct ncp_privatedata_ioctl __user *p = | ||
2661 | compat_alloc_user_space(sizeof(*p)); | ||
2662 | u32 len; | ||
2663 | int err; | ||
2664 | |||
2665 | if (copy_from_user(&n32, p32, sizeof(n32)) || | ||
2666 | put_user(n32.len, &p->len) || | ||
2667 | put_user(compat_ptr(n32.data), &p->data)) | ||
2668 | return -EFAULT; | ||
2669 | |||
2670 | err = sys_ioctl(fd, NCP_IOC_GETPRIVATEDATA, (unsigned long)p); | ||
2671 | if (err) | ||
2672 | return err; | ||
2673 | |||
2674 | if (get_user(len, &p->len) || | ||
2675 | put_user(len, &p32->len)) | ||
2676 | return -EFAULT; | ||
2677 | |||
2678 | return 0; | ||
2679 | } | ||
2680 | |||
2681 | static int do_ncp_setprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
2682 | { | ||
2683 | struct ncp_privatedata_ioctl_32 n32; | ||
2684 | struct ncp_privatedata_ioctl_32 __user *p32 = compat_ptr(arg); | ||
2685 | struct ncp_privatedata_ioctl __user *p = | ||
2686 | compat_alloc_user_space(sizeof(*p)); | ||
2687 | |||
2688 | if (copy_from_user(&n32, p32, sizeof(n32)) || | ||
2689 | put_user(n32.len, &p->len) || | ||
2690 | put_user(compat_ptr(n32.data), &p->data)) | ||
2691 | return -EFAULT; | ||
2692 | |||
2693 | return sys_ioctl(fd, NCP_IOC_SETPRIVATEDATA, (unsigned long)p); | ||
2694 | } | ||
2695 | #endif | ||
2696 | |||
2697 | static int | 2350 | static int |
2698 | lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 2351 | lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
2699 | { | 2352 | { |
@@ -2777,6 +2430,7 @@ HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc) | |||
2777 | HANDLE_IOCTL(SIOCRTMSG, ret_einval) | 2430 | HANDLE_IOCTL(SIOCRTMSG, ret_einval) |
2778 | HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp) | 2431 | HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp) |
2779 | #endif | 2432 | #endif |
2433 | #ifdef CONFIG_BLOCK | ||
2780 | HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo) | 2434 | HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo) |
2781 | HANDLE_IOCTL(BLKRAGET, w_long) | 2435 | HANDLE_IOCTL(BLKRAGET, w_long) |
2782 | HANDLE_IOCTL(BLKGETSIZE, w_long) | 2436 | HANDLE_IOCTL(BLKGETSIZE, w_long) |
@@ -2802,16 +2456,17 @@ HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans) | |||
2802 | HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans) | 2456 | HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans) |
2803 | HANDLE_IOCTL(SG_IO,sg_ioctl_trans) | 2457 | HANDLE_IOCTL(SG_IO,sg_ioctl_trans) |
2804 | HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans) | 2458 | HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans) |
2459 | #endif | ||
2805 | HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans) | 2460 | HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans) |
2806 | HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans) | 2461 | HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans) |
2807 | HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans) | 2462 | HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans) |
2808 | HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans) | 2463 | HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans) |
2464 | #ifdef CONFIG_BLOCK | ||
2809 | HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans) | 2465 | HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans) |
2810 | HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans) | 2466 | HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans) |
2811 | HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans) | 2467 | HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans) |
2812 | HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans) | 2468 | HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans) |
2813 | HANDLE_IOCTL(LOOP_SET_STATUS, loop_status) | 2469 | #endif |
2814 | HANDLE_IOCTL(LOOP_GET_STATUS, loop_status) | ||
2815 | #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int) | 2470 | #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int) |
2816 | HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout) | 2471 | HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout) |
2817 | #ifdef CONFIG_VT | 2472 | #ifdef CONFIG_VT |
@@ -2821,19 +2476,6 @@ HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl) | |||
2821 | HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl) | 2476 | HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl) |
2822 | HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl) | 2477 | HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl) |
2823 | #endif | 2478 | #endif |
2824 | HANDLE_IOCTL(EXT2_IOC32_GETFLAGS, do_ext2_ioctl) | ||
2825 | HANDLE_IOCTL(EXT2_IOC32_SETFLAGS, do_ext2_ioctl) | ||
2826 | HANDLE_IOCTL(EXT2_IOC32_GETVERSION, do_ext2_ioctl) | ||
2827 | HANDLE_IOCTL(EXT2_IOC32_SETVERSION, do_ext2_ioctl) | ||
2828 | HANDLE_IOCTL(EXT3_IOC32_GETVERSION, do_ext3_ioctl) | ||
2829 | HANDLE_IOCTL(EXT3_IOC32_SETVERSION, do_ext3_ioctl) | ||
2830 | HANDLE_IOCTL(EXT3_IOC32_GETRSVSZ, do_ext3_ioctl) | ||
2831 | HANDLE_IOCTL(EXT3_IOC32_SETRSVSZ, do_ext3_ioctl) | ||
2832 | HANDLE_IOCTL(EXT3_IOC32_GROUP_EXTEND, do_ext3_ioctl) | ||
2833 | COMPATIBLE_IOCTL(EXT3_IOC_GROUP_ADD) | ||
2834 | #ifdef CONFIG_JBD_DEBUG | ||
2835 | HANDLE_IOCTL(EXT3_IOC32_WAIT_FOR_READONLY, do_ext3_ioctl) | ||
2836 | #endif | ||
2837 | /* One SMB ioctl needs translations. */ | 2479 | /* One SMB ioctl needs translations. */ |
2838 | #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) | 2480 | #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) |
2839 | HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid) | 2481 | HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid) |
@@ -2863,16 +2505,14 @@ HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl) | |||
2863 | HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl) | 2505 | HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl) |
2864 | HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl) | 2506 | HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl) |
2865 | /* block stuff */ | 2507 | /* block stuff */ |
2508 | #ifdef CONFIG_BLOCK | ||
2866 | HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget) | 2509 | HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget) |
2867 | HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset) | 2510 | HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset) |
2868 | HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64) | 2511 | HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64) |
2869 | /* vfat */ | ||
2870 | HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32) | ||
2871 | HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32) | ||
2872 | HANDLE_IOCTL(REISERFS_IOC_UNPACK32, reiserfs_ioctl32) | ||
2873 | /* Raw devices */ | 2512 | /* Raw devices */ |
2874 | HANDLE_IOCTL(RAW_SETBIND, raw_ioctl) | 2513 | HANDLE_IOCTL(RAW_SETBIND, raw_ioctl) |
2875 | HANDLE_IOCTL(RAW_GETBIND, raw_ioctl) | 2514 | HANDLE_IOCTL(RAW_GETBIND, raw_ioctl) |
2515 | #endif | ||
2876 | /* Serial */ | 2516 | /* Serial */ |
2877 | HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl) | 2517 | HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl) |
2878 | HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl) | 2518 | HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl) |
@@ -2920,16 +2560,6 @@ HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl) | |||
2920 | HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl) | 2560 | HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl) |
2921 | HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl) | 2561 | HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl) |
2922 | 2562 | ||
2923 | #if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE) | ||
2924 | HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest) | ||
2925 | HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32, do_ncp_getmountuid2) | ||
2926 | HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32, do_ncp_getfsinfo2) | ||
2927 | HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32, do_ncp_getobjectname) | ||
2928 | HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, do_ncp_setobjectname) | ||
2929 | HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata) | ||
2930 | HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata) | ||
2931 | #endif | ||
2932 | |||
2933 | /* dvb */ | 2563 | /* dvb */ |
2934 | HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event) | 2564 | HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event) |
2935 | HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture) | 2565 | HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture) |
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 816e8ef64560..8a3b6a1a6ad1 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -139,7 +139,7 @@ static int init_dir(struct inode * inode) | |||
139 | inode->i_fop = &configfs_dir_operations; | 139 | inode->i_fop = &configfs_dir_operations; |
140 | 140 | ||
141 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | 141 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ |
142 | inode->i_nlink++; | 142 | inc_nlink(inode); |
143 | return 0; | 143 | return 0; |
144 | } | 144 | } |
145 | 145 | ||
@@ -169,7 +169,7 @@ static int create_dir(struct config_item * k, struct dentry * p, | |||
169 | if (!error) { | 169 | if (!error) { |
170 | error = configfs_create(d, mode, init_dir); | 170 | error = configfs_create(d, mode, init_dir); |
171 | if (!error) { | 171 | if (!error) { |
172 | p->d_inode->i_nlink++; | 172 | inc_nlink(p->d_inode); |
173 | (d)->d_op = &configfs_dentry_ops; | 173 | (d)->d_op = &configfs_dentry_ops; |
174 | } else { | 174 | } else { |
175 | struct configfs_dirent *sd = d->d_fsdata; | 175 | struct configfs_dirent *sd = d->d_fsdata; |
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c index 3e5fe843e1df..68bd5c93ca52 100644 --- a/fs/configfs/mount.c +++ b/fs/configfs/mount.c | |||
@@ -84,7 +84,7 @@ static int configfs_fill_super(struct super_block *sb, void *data, int silent) | |||
84 | inode->i_op = &configfs_dir_inode_operations; | 84 | inode->i_op = &configfs_dir_inode_operations; |
85 | inode->i_fop = &configfs_dir_operations; | 85 | inode->i_fop = &configfs_dir_operations; |
86 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | 86 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ |
87 | inode->i_nlink++; | 87 | inc_nlink(inode); |
88 | } else { | 88 | } else { |
89 | pr_debug("configfs: could not get root inode\n"); | 89 | pr_debug("configfs: could not get root inode\n"); |
90 | return -ENOMEM; | 90 | return -ENOMEM; |
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index ad96b6990715..a624c3ec8189 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c | |||
@@ -543,8 +543,15 @@ static struct file_system_type cramfs_fs_type = { | |||
543 | 543 | ||
544 | static int __init init_cramfs_fs(void) | 544 | static int __init init_cramfs_fs(void) |
545 | { | 545 | { |
546 | cramfs_uncompress_init(); | 546 | int rv; |
547 | return register_filesystem(&cramfs_fs_type); | 547 | |
548 | rv = cramfs_uncompress_init(); | ||
549 | if (rv < 0) | ||
550 | return rv; | ||
551 | rv = register_filesystem(&cramfs_fs_type); | ||
552 | if (rv < 0) | ||
553 | cramfs_uncompress_exit(); | ||
554 | return rv; | ||
548 | } | 555 | } |
549 | 556 | ||
550 | static void __exit exit_cramfs_fs(void) | 557 | static void __exit exit_cramfs_fs(void) |
diff --git a/fs/cramfs/uncompress.c b/fs/cramfs/uncompress.c index 8def89f2c438..fc3ccb74626f 100644 --- a/fs/cramfs/uncompress.c +++ b/fs/cramfs/uncompress.c | |||
@@ -68,11 +68,10 @@ int cramfs_uncompress_init(void) | |||
68 | return 0; | 68 | return 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | int cramfs_uncompress_exit(void) | 71 | void cramfs_uncompress_exit(void) |
72 | { | 72 | { |
73 | if (!--initialized) { | 73 | if (!--initialized) { |
74 | zlib_inflateEnd(&stream); | 74 | zlib_inflateEnd(&stream); |
75 | vfree(stream.workspace); | 75 | vfree(stream.workspace); |
76 | } | 76 | } |
77 | return 0; | ||
78 | } | 77 | } |
diff --git a/fs/dcache.c b/fs/dcache.c index 17b392a2049e..fc2faa44f8d1 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/seqlock.h> | 32 | #include <linux/seqlock.h> |
33 | #include <linux/swap.h> | 33 | #include <linux/swap.h> |
34 | #include <linux/bootmem.h> | 34 | #include <linux/bootmem.h> |
35 | #include "internal.h" | ||
35 | 36 | ||
36 | 37 | ||
37 | int sysctl_vfs_cache_pressure __read_mostly = 100; | 38 | int sysctl_vfs_cache_pressure __read_mostly = 100; |
@@ -1877,9 +1878,6 @@ kmem_cache_t *filp_cachep __read_mostly; | |||
1877 | 1878 | ||
1878 | EXPORT_SYMBOL(d_genocide); | 1879 | EXPORT_SYMBOL(d_genocide); |
1879 | 1880 | ||
1880 | extern void bdev_cache_init(void); | ||
1881 | extern void chrdev_init(void); | ||
1882 | |||
1883 | void __init vfs_caches_init_early(void) | 1881 | void __init vfs_caches_init_early(void) |
1884 | { | 1882 | { |
1885 | dcache_init_early(); | 1883 | dcache_init_early(); |
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 269e649e6dc6..ecf3da9edf21 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
@@ -54,7 +54,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d | |||
54 | inode->i_fop = &simple_dir_operations; | 54 | inode->i_fop = &simple_dir_operations; |
55 | 55 | ||
56 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | 56 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ |
57 | inode->i_nlink++; | 57 | inc_nlink(inode); |
58 | break; | 58 | break; |
59 | } | 59 | } |
60 | } | 60 | } |
@@ -87,7 +87,7 @@ static int debugfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
87 | mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR; | 87 | mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR; |
88 | res = debugfs_mknod(dir, dentry, mode, 0); | 88 | res = debugfs_mknod(dir, dentry, mode, 0); |
89 | if (!res) | 89 | if (!res) |
90 | dir->i_nlink++; | 90 | inc_nlink(dir); |
91 | return res; | 91 | return res; |
92 | } | 92 | } |
93 | 93 | ||
diff --git a/fs/dquot.c b/fs/dquot.c index 0122a279106a..9af789567e51 100644 --- a/fs/dquot.c +++ b/fs/dquot.c | |||
@@ -834,6 +834,9 @@ static void print_warning(struct dquot *dquot, const char warntype) | |||
834 | if (!need_print_warning(dquot) || (flag && test_and_set_bit(flag, &dquot->dq_flags))) | 834 | if (!need_print_warning(dquot) || (flag && test_and_set_bit(flag, &dquot->dq_flags))) |
835 | return; | 835 | return; |
836 | 836 | ||
837 | mutex_lock(&tty_mutex); | ||
838 | if (!current->signal->tty) | ||
839 | goto out_lock; | ||
837 | tty_write_message(current->signal->tty, dquot->dq_sb->s_id); | 840 | tty_write_message(current->signal->tty, dquot->dq_sb->s_id); |
838 | if (warntype == ISOFTWARN || warntype == BSOFTWARN) | 841 | if (warntype == ISOFTWARN || warntype == BSOFTWARN) |
839 | tty_write_message(current->signal->tty, ": warning, "); | 842 | tty_write_message(current->signal->tty, ": warning, "); |
@@ -861,6 +864,8 @@ static void print_warning(struct dquot *dquot, const char warntype) | |||
861 | break; | 864 | break; |
862 | } | 865 | } |
863 | tty_write_message(current->signal->tty, msg); | 866 | tty_write_message(current->signal->tty, msg); |
867 | out_lock: | ||
868 | mutex_unlock(&tty_mutex); | ||
864 | } | 869 | } |
865 | 870 | ||
866 | static inline void flush_warnings(struct dquot **dquots, char *warntype) | 871 | static inline void flush_warnings(struct dquot **dquots, char *warntype) |
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/security.h> | 46 | #include <linux/security.h> |
47 | #include <linux/syscalls.h> | 47 | #include <linux/syscalls.h> |
48 | #include <linux/rmap.h> | 48 | #include <linux/rmap.h> |
49 | #include <linux/acct.h> | 49 | #include <linux/tsacct_kern.h> |
50 | #include <linux/cn_proc.h> | 50 | #include <linux/cn_proc.h> |
51 | #include <linux/audit.h> | 51 | #include <linux/audit.h> |
52 | 52 | ||
@@ -58,7 +58,7 @@ | |||
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | int core_uses_pid; | 60 | int core_uses_pid; |
61 | char core_pattern[65] = "core"; | 61 | char core_pattern[128] = "core"; |
62 | int suid_dumpable = 0; | 62 | int suid_dumpable = 0; |
63 | 63 | ||
64 | EXPORT_SYMBOL(suid_dumpable); | 64 | EXPORT_SYMBOL(suid_dumpable); |
@@ -898,8 +898,7 @@ int flush_old_exec(struct linux_binprm * bprm) | |||
898 | return 0; | 898 | return 0; |
899 | 899 | ||
900 | mmap_failed: | 900 | mmap_failed: |
901 | put_files_struct(current->files); | 901 | reset_files_struct(current, files); |
902 | current->files = files; | ||
903 | out: | 902 | out: |
904 | return retval; | 903 | return retval; |
905 | } | 904 | } |
@@ -1464,6 +1463,7 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs) | |||
1464 | int retval = 0; | 1463 | int retval = 0; |
1465 | int fsuid = current->fsuid; | 1464 | int fsuid = current->fsuid; |
1466 | int flag = 0; | 1465 | int flag = 0; |
1466 | int ispipe = 0; | ||
1467 | 1467 | ||
1468 | binfmt = current->binfmt; | 1468 | binfmt = current->binfmt; |
1469 | if (!binfmt || !binfmt->core_dump) | 1469 | if (!binfmt || !binfmt->core_dump) |
@@ -1505,22 +1505,34 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs) | |||
1505 | lock_kernel(); | 1505 | lock_kernel(); |
1506 | format_corename(corename, core_pattern, signr); | 1506 | format_corename(corename, core_pattern, signr); |
1507 | unlock_kernel(); | 1507 | unlock_kernel(); |
1508 | file = filp_open(corename, O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag, 0600); | 1508 | if (corename[0] == '|') { |
1509 | /* SIGPIPE can happen, but it's just never processed */ | ||
1510 | if(call_usermodehelper_pipe(corename+1, NULL, NULL, &file)) { | ||
1511 | printk(KERN_INFO "Core dump to %s pipe failed\n", | ||
1512 | corename); | ||
1513 | goto fail_unlock; | ||
1514 | } | ||
1515 | ispipe = 1; | ||
1516 | } else | ||
1517 | file = filp_open(corename, | ||
1518 | O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE, 0600); | ||
1509 | if (IS_ERR(file)) | 1519 | if (IS_ERR(file)) |
1510 | goto fail_unlock; | 1520 | goto fail_unlock; |
1511 | inode = file->f_dentry->d_inode; | 1521 | inode = file->f_dentry->d_inode; |
1512 | if (inode->i_nlink > 1) | 1522 | if (inode->i_nlink > 1) |
1513 | goto close_fail; /* multiple links - don't dump */ | 1523 | goto close_fail; /* multiple links - don't dump */ |
1514 | if (d_unhashed(file->f_dentry)) | 1524 | if (!ispipe && d_unhashed(file->f_dentry)) |
1515 | goto close_fail; | 1525 | goto close_fail; |
1516 | 1526 | ||
1517 | if (!S_ISREG(inode->i_mode)) | 1527 | /* AK: actually i see no reason to not allow this for named pipes etc., |
1528 | but keep the previous behaviour for now. */ | ||
1529 | if (!ispipe && !S_ISREG(inode->i_mode)) | ||
1518 | goto close_fail; | 1530 | goto close_fail; |
1519 | if (!file->f_op) | 1531 | if (!file->f_op) |
1520 | goto close_fail; | 1532 | goto close_fail; |
1521 | if (!file->f_op->write) | 1533 | if (!file->f_op->write) |
1522 | goto close_fail; | 1534 | goto close_fail; |
1523 | if (do_truncate(file->f_dentry, 0, 0, file) != 0) | 1535 | if (!ispipe && do_truncate(file->f_dentry, 0, 0, file) != 0) |
1524 | goto close_fail; | 1536 | goto close_fail; |
1525 | 1537 | ||
1526 | retval = binfmt->core_dump(signr, regs, file); | 1538 | retval = binfmt->core_dump(signr, regs, file); |
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index 92ea8265d7d5..3e7a84a1e509 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c | |||
@@ -661,5 +661,8 @@ const struct file_operations ext2_dir_operations = { | |||
661 | .read = generic_read_dir, | 661 | .read = generic_read_dir, |
662 | .readdir = ext2_readdir, | 662 | .readdir = ext2_readdir, |
663 | .ioctl = ext2_ioctl, | 663 | .ioctl = ext2_ioctl, |
664 | #ifdef CONFIG_COMPAT | ||
665 | .compat_ioctl = ext2_compat_ioctl, | ||
666 | #endif | ||
664 | .fsync = ext2_sync_file, | 667 | .fsync = ext2_sync_file, |
665 | }; | 668 | }; |
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index e65a019fc7a5..c19ac153f56b 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h | |||
@@ -137,6 +137,7 @@ extern void ext2_set_inode_flags(struct inode *inode); | |||
137 | /* ioctl.c */ | 137 | /* ioctl.c */ |
138 | extern int ext2_ioctl (struct inode *, struct file *, unsigned int, | 138 | extern int ext2_ioctl (struct inode *, struct file *, unsigned int, |
139 | unsigned long); | 139 | unsigned long); |
140 | extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long); | ||
140 | 141 | ||
141 | /* namei.c */ | 142 | /* namei.c */ |
142 | struct dentry *ext2_get_parent(struct dentry *child); | 143 | struct dentry *ext2_get_parent(struct dentry *child); |
diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 23e2c7ccec1d..2dba473c524a 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c | |||
@@ -41,17 +41,18 @@ static int ext2_release_file (struct inode * inode, struct file * filp) | |||
41 | */ | 41 | */ |
42 | const struct file_operations ext2_file_operations = { | 42 | const struct file_operations ext2_file_operations = { |
43 | .llseek = generic_file_llseek, | 43 | .llseek = generic_file_llseek, |
44 | .read = generic_file_read, | 44 | .read = do_sync_read, |
45 | .write = generic_file_write, | 45 | .write = do_sync_write, |
46 | .aio_read = generic_file_aio_read, | 46 | .aio_read = generic_file_aio_read, |
47 | .aio_write = generic_file_aio_write, | 47 | .aio_write = generic_file_aio_write, |
48 | .ioctl = ext2_ioctl, | 48 | .ioctl = ext2_ioctl, |
49 | #ifdef CONFIG_COMPAT | ||
50 | .compat_ioctl = ext2_compat_ioctl, | ||
51 | #endif | ||
49 | .mmap = generic_file_mmap, | 52 | .mmap = generic_file_mmap, |
50 | .open = generic_file_open, | 53 | .open = generic_file_open, |
51 | .release = ext2_release_file, | 54 | .release = ext2_release_file, |
52 | .fsync = ext2_sync_file, | 55 | .fsync = ext2_sync_file, |
53 | .readv = generic_file_readv, | ||
54 | .writev = generic_file_writev, | ||
55 | .sendfile = generic_file_sendfile, | 56 | .sendfile = generic_file_sendfile, |
56 | .splice_read = generic_file_splice_read, | 57 | .splice_read = generic_file_splice_read, |
57 | .splice_write = generic_file_splice_write, | 58 | .splice_write = generic_file_splice_write, |
@@ -63,6 +64,9 @@ const struct file_operations ext2_xip_file_operations = { | |||
63 | .read = xip_file_read, | 64 | .read = xip_file_read, |
64 | .write = xip_file_write, | 65 | .write = xip_file_write, |
65 | .ioctl = ext2_ioctl, | 66 | .ioctl = ext2_ioctl, |
67 | #ifdef CONFIG_COMPAT | ||
68 | .compat_ioctl = ext2_compat_ioctl, | ||
69 | #endif | ||
66 | .mmap = xip_file_mmap, | 70 | .mmap = xip_file_mmap, |
67 | .open = generic_file_open, | 71 | .open = generic_file_open, |
68 | .release = ext2_release_file, | 72 | .release = ext2_release_file, |
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c index 3ca9afdf713d..1dfba77eab10 100644 --- a/fs/ext2/ioctl.c +++ b/fs/ext2/ioctl.c | |||
@@ -11,6 +11,8 @@ | |||
11 | #include <linux/capability.h> | 11 | #include <linux/capability.h> |
12 | #include <linux/time.h> | 12 | #include <linux/time.h> |
13 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
14 | #include <linux/compat.h> | ||
15 | #include <linux/smp_lock.h> | ||
14 | #include <asm/current.h> | 16 | #include <asm/current.h> |
15 | #include <asm/uaccess.h> | 17 | #include <asm/uaccess.h> |
16 | 18 | ||
@@ -80,3 +82,33 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, | |||
80 | return -ENOTTY; | 82 | return -ENOTTY; |
81 | } | 83 | } |
82 | } | 84 | } |
85 | |||
86 | #ifdef CONFIG_COMPAT | ||
87 | long ext2_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
88 | { | ||
89 | struct inode *inode = file->f_dentry->d_inode; | ||
90 | int ret; | ||
91 | |||
92 | /* These are just misnamed, they actually get/put from/to user an int */ | ||
93 | switch (cmd) { | ||
94 | case EXT2_IOC32_GETFLAGS: | ||
95 | cmd = EXT2_IOC_GETFLAGS; | ||
96 | break; | ||
97 | case EXT2_IOC32_SETFLAGS: | ||
98 | cmd = EXT2_IOC_SETFLAGS; | ||
99 | break; | ||
100 | case EXT2_IOC32_GETVERSION: | ||
101 | cmd = EXT2_IOC_GETVERSION; | ||
102 | break; | ||
103 | case EXT2_IOC32_SETVERSION: | ||
104 | cmd = EXT2_IOC_SETVERSION; | ||
105 | break; | ||
106 | default: | ||
107 | return -ENOIOCTLCMD; | ||
108 | } | ||
109 | lock_kernel(); | ||
110 | ret = ext2_ioctl(inode, file, cmd, (unsigned long) compat_ptr(arg)); | ||
111 | unlock_kernel(); | ||
112 | return ret; | ||
113 | } | ||
114 | #endif | ||
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index 4ca824985321..e1af5b4cf80c 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c | |||
@@ -326,7 +326,7 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry, | |||
326 | ext2_set_link(new_dir, new_de, new_page, old_inode); | 326 | ext2_set_link(new_dir, new_de, new_page, old_inode); |
327 | new_inode->i_ctime = CURRENT_TIME_SEC; | 327 | new_inode->i_ctime = CURRENT_TIME_SEC; |
328 | if (dir_de) | 328 | if (dir_de) |
329 | new_inode->i_nlink--; | 329 | drop_nlink(new_inode); |
330 | inode_dec_link_count(new_inode); | 330 | inode_dec_link_count(new_inode); |
331 | } else { | 331 | } else { |
332 | if (dir_de) { | 332 | if (dir_de) { |
diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c index 429acbb4e064..d0b54f30b914 100644 --- a/fs/ext3/dir.c +++ b/fs/ext3/dir.c | |||
@@ -44,6 +44,9 @@ const struct file_operations ext3_dir_operations = { | |||
44 | .read = generic_read_dir, | 44 | .read = generic_read_dir, |
45 | .readdir = ext3_readdir, /* we take BKL. needed?*/ | 45 | .readdir = ext3_readdir, /* we take BKL. needed?*/ |
46 | .ioctl = ext3_ioctl, /* BKL held */ | 46 | .ioctl = ext3_ioctl, /* BKL held */ |
47 | #ifdef CONFIG_COMPAT | ||
48 | .compat_ioctl = ext3_compat_ioctl, | ||
49 | #endif | ||
47 | .fsync = ext3_sync_file, /* BKL held */ | 50 | .fsync = ext3_sync_file, /* BKL held */ |
48 | #ifdef CONFIG_EXT3_INDEX | 51 | #ifdef CONFIG_EXT3_INDEX |
49 | .release = ext3_release_dir, | 52 | .release = ext3_release_dir, |
diff --git a/fs/ext3/file.c b/fs/ext3/file.c index 994efd189f4e..e96c388047e0 100644 --- a/fs/ext3/file.c +++ b/fs/ext3/file.c | |||
@@ -48,14 +48,15 @@ static int ext3_release_file (struct inode * inode, struct file * filp) | |||
48 | } | 48 | } |
49 | 49 | ||
50 | static ssize_t | 50 | static ssize_t |
51 | ext3_file_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t pos) | 51 | ext3_file_write(struct kiocb *iocb, const struct iovec *iov, |
52 | unsigned long nr_segs, loff_t pos) | ||
52 | { | 53 | { |
53 | struct file *file = iocb->ki_filp; | 54 | struct file *file = iocb->ki_filp; |
54 | struct inode *inode = file->f_dentry->d_inode; | 55 | struct inode *inode = file->f_dentry->d_inode; |
55 | ssize_t ret; | 56 | ssize_t ret; |
56 | int err; | 57 | int err; |
57 | 58 | ||
58 | ret = generic_file_aio_write(iocb, buf, count, pos); | 59 | ret = generic_file_aio_write(iocb, iov, nr_segs, pos); |
59 | 60 | ||
60 | /* | 61 | /* |
61 | * Skip flushing if there was an error, or if nothing was written. | 62 | * Skip flushing if there was an error, or if nothing was written. |
@@ -111,9 +112,10 @@ const struct file_operations ext3_file_operations = { | |||
111 | .write = do_sync_write, | 112 | .write = do_sync_write, |
112 | .aio_read = generic_file_aio_read, | 113 | .aio_read = generic_file_aio_read, |
113 | .aio_write = ext3_file_write, | 114 | .aio_write = ext3_file_write, |
114 | .readv = generic_file_readv, | ||
115 | .writev = generic_file_writev, | ||
116 | .ioctl = ext3_ioctl, | 115 | .ioctl = ext3_ioctl, |
116 | #ifdef CONFIG_COMPAT | ||
117 | .compat_ioctl = ext3_compat_ioctl, | ||
118 | #endif | ||
117 | .mmap = generic_file_mmap, | 119 | .mmap = generic_file_mmap, |
118 | .open = generic_file_open, | 120 | .open = generic_file_open, |
119 | .release = ext3_release_file, | 121 | .release = ext3_release_file, |
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index dcf4f1dd108b..03ba5bcab186 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/writeback.h> | 36 | #include <linux/writeback.h> |
37 | #include <linux/mpage.h> | 37 | #include <linux/mpage.h> |
38 | #include <linux/uio.h> | 38 | #include <linux/uio.h> |
39 | #include <linux/bio.h> | ||
39 | #include "xattr.h" | 40 | #include "xattr.h" |
40 | #include "acl.h" | 41 | #include "acl.h" |
41 | 42 | ||
@@ -1073,7 +1074,7 @@ struct buffer_head *ext3_bread(handle_t *handle, struct inode *inode, | |||
1073 | return bh; | 1074 | return bh; |
1074 | if (buffer_uptodate(bh)) | 1075 | if (buffer_uptodate(bh)) |
1075 | return bh; | 1076 | return bh; |
1076 | ll_rw_block(READ, 1, &bh); | 1077 | ll_rw_block(READ_META, 1, &bh); |
1077 | wait_on_buffer(bh); | 1078 | wait_on_buffer(bh); |
1078 | if (buffer_uptodate(bh)) | 1079 | if (buffer_uptodate(bh)) |
1079 | return bh; | 1080 | return bh; |
@@ -2540,7 +2541,7 @@ make_io: | |||
2540 | */ | 2541 | */ |
2541 | get_bh(bh); | 2542 | get_bh(bh); |
2542 | bh->b_end_io = end_buffer_read_sync; | 2543 | bh->b_end_io = end_buffer_read_sync; |
2543 | submit_bh(READ, bh); | 2544 | submit_bh(READ_META, bh); |
2544 | wait_on_buffer(bh); | 2545 | wait_on_buffer(bh); |
2545 | if (!buffer_uptodate(bh)) { | 2546 | if (!buffer_uptodate(bh)) { |
2546 | ext3_error(inode->i_sb, "ext3_get_inode_loc", | 2547 | ext3_error(inode->i_sb, "ext3_get_inode_loc", |
diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c index 3a6b012d120c..12daa6869572 100644 --- a/fs/ext3/ioctl.c +++ b/fs/ext3/ioctl.c | |||
@@ -13,9 +13,10 @@ | |||
13 | #include <linux/ext3_fs.h> | 13 | #include <linux/ext3_fs.h> |
14 | #include <linux/ext3_jbd.h> | 14 | #include <linux/ext3_jbd.h> |
15 | #include <linux/time.h> | 15 | #include <linux/time.h> |
16 | #include <linux/compat.h> | ||
17 | #include <linux/smp_lock.h> | ||
16 | #include <asm/uaccess.h> | 18 | #include <asm/uaccess.h> |
17 | 19 | ||
18 | |||
19 | int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, | 20 | int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, |
20 | unsigned long arg) | 21 | unsigned long arg) |
21 | { | 22 | { |
@@ -252,3 +253,55 @@ flags_err: | |||
252 | return -ENOTTY; | 253 | return -ENOTTY; |
253 | } | 254 | } |
254 | } | 255 | } |
256 | |||
257 | #ifdef CONFIG_COMPAT | ||
258 | long ext3_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
259 | { | ||
260 | struct inode *inode = file->f_dentry->d_inode; | ||
261 | int ret; | ||
262 | |||
263 | /* These are just misnamed, they actually get/put from/to user an int */ | ||
264 | switch (cmd) { | ||
265 | case EXT3_IOC32_GETFLAGS: | ||
266 | cmd = EXT3_IOC_GETFLAGS; | ||
267 | break; | ||
268 | case EXT3_IOC32_SETFLAGS: | ||
269 | cmd = EXT3_IOC_SETFLAGS; | ||
270 | break; | ||
271 | case EXT3_IOC32_GETVERSION: | ||
272 | cmd = EXT3_IOC_GETVERSION; | ||
273 | break; | ||
274 | case EXT3_IOC32_SETVERSION: | ||
275 | cmd = EXT3_IOC_SETVERSION; | ||
276 | break; | ||
277 | case EXT3_IOC32_GROUP_EXTEND: | ||
278 | cmd = EXT3_IOC_GROUP_EXTEND; | ||
279 | break; | ||
280 | case EXT3_IOC32_GETVERSION_OLD: | ||
281 | cmd = EXT3_IOC_GETVERSION_OLD; | ||
282 | break; | ||
283 | case EXT3_IOC32_SETVERSION_OLD: | ||
284 | cmd = EXT3_IOC_SETVERSION_OLD; | ||
285 | break; | ||
286 | #ifdef CONFIG_JBD_DEBUG | ||
287 | case EXT3_IOC32_WAIT_FOR_READONLY: | ||
288 | cmd = EXT3_IOC_WAIT_FOR_READONLY; | ||
289 | break; | ||
290 | #endif | ||
291 | case EXT3_IOC32_GETRSVSZ: | ||
292 | cmd = EXT3_IOC_GETRSVSZ; | ||
293 | break; | ||
294 | case EXT3_IOC32_SETRSVSZ: | ||
295 | cmd = EXT3_IOC_SETRSVSZ; | ||
296 | break; | ||
297 | case EXT3_IOC_GROUP_ADD: | ||
298 | break; | ||
299 | default: | ||
300 | return -ENOIOCTLCMD; | ||
301 | } | ||
302 | lock_kernel(); | ||
303 | ret = ext3_ioctl(inode, file, cmd, (unsigned long) compat_ptr(arg)); | ||
304 | unlock_kernel(); | ||
305 | return ret; | ||
306 | } | ||
307 | #endif | ||
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 85d132c37ee0..906731a20f1a 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/string.h> | 35 | #include <linux/string.h> |
36 | #include <linux/quotaops.h> | 36 | #include <linux/quotaops.h> |
37 | #include <linux/buffer_head.h> | 37 | #include <linux/buffer_head.h> |
38 | #include <linux/bio.h> | ||
38 | #include <linux/smp_lock.h> | 39 | #include <linux/smp_lock.h> |
39 | 40 | ||
40 | #include "namei.h" | 41 | #include "namei.h" |
@@ -870,7 +871,7 @@ restart: | |||
870 | bh = ext3_getblk(NULL, dir, b++, 0, &err); | 871 | bh = ext3_getblk(NULL, dir, b++, 0, &err); |
871 | bh_use[ra_max] = bh; | 872 | bh_use[ra_max] = bh; |
872 | if (bh) | 873 | if (bh) |
873 | ll_rw_block(READ, 1, &bh); | 874 | ll_rw_block(READ_META, 1, &bh); |
874 | } | 875 | } |
875 | } | 876 | } |
876 | if ((bh = bh_use[ra_ptr++]) == NULL) | 877 | if ((bh = bh_use[ra_ptr++]) == NULL) |
@@ -1615,12 +1616,12 @@ static int ext3_delete_entry (handle_t *handle, | |||
1615 | */ | 1616 | */ |
1616 | static inline void ext3_inc_count(handle_t *handle, struct inode *inode) | 1617 | static inline void ext3_inc_count(handle_t *handle, struct inode *inode) |
1617 | { | 1618 | { |
1618 | inode->i_nlink++; | 1619 | inc_nlink(inode); |
1619 | } | 1620 | } |
1620 | 1621 | ||
1621 | static inline void ext3_dec_count(handle_t *handle, struct inode *inode) | 1622 | static inline void ext3_dec_count(handle_t *handle, struct inode *inode) |
1622 | { | 1623 | { |
1623 | inode->i_nlink--; | 1624 | drop_nlink(inode); |
1624 | } | 1625 | } |
1625 | 1626 | ||
1626 | static int ext3_add_nondir(handle_t *handle, | 1627 | static int ext3_add_nondir(handle_t *handle, |
@@ -1742,7 +1743,7 @@ retry: | |||
1742 | inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize; | 1743 | inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize; |
1743 | dir_block = ext3_bread (handle, inode, 0, 1, &err); | 1744 | dir_block = ext3_bread (handle, inode, 0, 1, &err); |
1744 | if (!dir_block) { | 1745 | if (!dir_block) { |
1745 | inode->i_nlink--; /* is this nlink == 0? */ | 1746 | drop_nlink(inode); /* is this nlink == 0? */ |
1746 | ext3_mark_inode_dirty(handle, inode); | 1747 | ext3_mark_inode_dirty(handle, inode); |
1747 | iput (inode); | 1748 | iput (inode); |
1748 | goto out_stop; | 1749 | goto out_stop; |
@@ -1774,7 +1775,7 @@ retry: | |||
1774 | iput (inode); | 1775 | iput (inode); |
1775 | goto out_stop; | 1776 | goto out_stop; |
1776 | } | 1777 | } |
1777 | dir->i_nlink++; | 1778 | inc_nlink(dir); |
1778 | ext3_update_dx_flag(dir); | 1779 | ext3_update_dx_flag(dir); |
1779 | ext3_mark_inode_dirty(handle, dir); | 1780 | ext3_mark_inode_dirty(handle, dir); |
1780 | d_instantiate(dentry, inode); | 1781 | d_instantiate(dentry, inode); |
@@ -2044,7 +2045,7 @@ static int ext3_rmdir (struct inode * dir, struct dentry *dentry) | |||
2044 | "empty directory has nlink!=2 (%d)", | 2045 | "empty directory has nlink!=2 (%d)", |
2045 | inode->i_nlink); | 2046 | inode->i_nlink); |
2046 | inode->i_version++; | 2047 | inode->i_version++; |
2047 | inode->i_nlink = 0; | 2048 | clear_nlink(inode); |
2048 | /* There's no need to set i_disksize: the fact that i_nlink is | 2049 | /* There's no need to set i_disksize: the fact that i_nlink is |
2049 | * zero will ensure that the right thing happens during any | 2050 | * zero will ensure that the right thing happens during any |
2050 | * recovery. */ | 2051 | * recovery. */ |
@@ -2052,7 +2053,7 @@ static int ext3_rmdir (struct inode * dir, struct dentry *dentry) | |||
2052 | ext3_orphan_add(handle, inode); | 2053 | ext3_orphan_add(handle, inode); |
2053 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; | 2054 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; |
2054 | ext3_mark_inode_dirty(handle, inode); | 2055 | ext3_mark_inode_dirty(handle, inode); |
2055 | dir->i_nlink--; | 2056 | drop_nlink(dir); |
2056 | ext3_update_dx_flag(dir); | 2057 | ext3_update_dx_flag(dir); |
2057 | ext3_mark_inode_dirty(handle, dir); | 2058 | ext3_mark_inode_dirty(handle, dir); |
2058 | 2059 | ||
@@ -2103,7 +2104,7 @@ static int ext3_unlink(struct inode * dir, struct dentry *dentry) | |||
2103 | dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; | 2104 | dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; |
2104 | ext3_update_dx_flag(dir); | 2105 | ext3_update_dx_flag(dir); |
2105 | ext3_mark_inode_dirty(handle, dir); | 2106 | ext3_mark_inode_dirty(handle, dir); |
2106 | inode->i_nlink--; | 2107 | drop_nlink(inode); |
2107 | if (!inode->i_nlink) | 2108 | if (!inode->i_nlink) |
2108 | ext3_orphan_add(handle, inode); | 2109 | ext3_orphan_add(handle, inode); |
2109 | inode->i_ctime = dir->i_ctime; | 2110 | inode->i_ctime = dir->i_ctime; |
@@ -2325,7 +2326,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry, | |||
2325 | } | 2326 | } |
2326 | 2327 | ||
2327 | if (new_inode) { | 2328 | if (new_inode) { |
2328 | new_inode->i_nlink--; | 2329 | drop_nlink(new_inode); |
2329 | new_inode->i_ctime = CURRENT_TIME_SEC; | 2330 | new_inode->i_ctime = CURRENT_TIME_SEC; |
2330 | } | 2331 | } |
2331 | old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC; | 2332 | old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC; |
@@ -2336,11 +2337,11 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry, | |||
2336 | PARENT_INO(dir_bh->b_data) = cpu_to_le32(new_dir->i_ino); | 2337 | PARENT_INO(dir_bh->b_data) = cpu_to_le32(new_dir->i_ino); |
2337 | BUFFER_TRACE(dir_bh, "call ext3_journal_dirty_metadata"); | 2338 | BUFFER_TRACE(dir_bh, "call ext3_journal_dirty_metadata"); |
2338 | ext3_journal_dirty_metadata(handle, dir_bh); | 2339 | ext3_journal_dirty_metadata(handle, dir_bh); |
2339 | old_dir->i_nlink--; | 2340 | drop_nlink(old_dir); |
2340 | if (new_inode) { | 2341 | if (new_inode) { |
2341 | new_inode->i_nlink--; | 2342 | drop_nlink(new_inode); |
2342 | } else { | 2343 | } else { |
2343 | new_dir->i_nlink++; | 2344 | inc_nlink(new_dir); |
2344 | ext3_update_dx_flag(new_dir); | 2345 | ext3_update_dx_flag(new_dir); |
2345 | ext3_mark_inode_dirty(handle, new_dir); | 2346 | ext3_mark_inode_dirty(handle, new_dir); |
2346 | } | 2347 | } |
diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 698b85bb1dd4..3e50a4166283 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/dirent.h> | 20 | #include <linux/dirent.h> |
21 | #include <linux/smp_lock.h> | 21 | #include <linux/smp_lock.h> |
22 | #include <linux/buffer_head.h> | 22 | #include <linux/buffer_head.h> |
23 | #include <linux/compat.h> | ||
23 | #include <asm/uaccess.h> | 24 | #include <asm/uaccess.h> |
24 | 25 | ||
25 | static inline loff_t fat_make_i_pos(struct super_block *sb, | 26 | static inline loff_t fat_make_i_pos(struct super_block *sb, |
@@ -741,10 +742,65 @@ static int fat_dir_ioctl(struct inode * inode, struct file * filp, | |||
741 | return ret; | 742 | return ret; |
742 | } | 743 | } |
743 | 744 | ||
745 | #ifdef CONFIG_COMPAT | ||
746 | #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2]) | ||
747 | #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2]) | ||
748 | |||
749 | static long fat_compat_put_dirent32(struct dirent *d, | ||
750 | struct compat_dirent __user *d32) | ||
751 | { | ||
752 | if (!access_ok(VERIFY_WRITE, d32, sizeof(struct compat_dirent))) | ||
753 | return -EFAULT; | ||
754 | |||
755 | __put_user(d->d_ino, &d32->d_ino); | ||
756 | __put_user(d->d_off, &d32->d_off); | ||
757 | __put_user(d->d_reclen, &d32->d_reclen); | ||
758 | if (__copy_to_user(d32->d_name, d->d_name, d->d_reclen)) | ||
759 | return -EFAULT; | ||
760 | |||
761 | return 0; | ||
762 | } | ||
763 | |||
764 | static long fat_compat_dir_ioctl(struct file *file, unsigned cmd, | ||
765 | unsigned long arg) | ||
766 | { | ||
767 | struct compat_dirent __user *p = compat_ptr(arg); | ||
768 | int ret; | ||
769 | mm_segment_t oldfs = get_fs(); | ||
770 | struct dirent d[2]; | ||
771 | |||
772 | switch (cmd) { | ||
773 | case VFAT_IOCTL_READDIR_BOTH32: | ||
774 | cmd = VFAT_IOCTL_READDIR_BOTH; | ||
775 | break; | ||
776 | case VFAT_IOCTL_READDIR_SHORT32: | ||
777 | cmd = VFAT_IOCTL_READDIR_SHORT; | ||
778 | break; | ||
779 | default: | ||
780 | return -ENOIOCTLCMD; | ||
781 | } | ||
782 | |||
783 | set_fs(KERNEL_DS); | ||
784 | lock_kernel(); | ||
785 | ret = fat_dir_ioctl(file->f_dentry->d_inode, file, | ||
786 | cmd, (unsigned long) &d); | ||
787 | unlock_kernel(); | ||
788 | set_fs(oldfs); | ||
789 | if (ret >= 0) { | ||
790 | ret |= fat_compat_put_dirent32(&d[0], p); | ||
791 | ret |= fat_compat_put_dirent32(&d[1], p + 1); | ||
792 | } | ||
793 | return ret; | ||
794 | } | ||
795 | #endif /* CONFIG_COMPAT */ | ||
796 | |||
744 | const struct file_operations fat_dir_operations = { | 797 | const struct file_operations fat_dir_operations = { |
745 | .read = generic_read_dir, | 798 | .read = generic_read_dir, |
746 | .readdir = fat_readdir, | 799 | .readdir = fat_readdir, |
747 | .ioctl = fat_dir_ioctl, | 800 | .ioctl = fat_dir_ioctl, |
801 | #ifdef CONFIG_COMPAT | ||
802 | .compat_ioctl = fat_compat_dir_ioctl, | ||
803 | #endif | ||
748 | .fsync = file_fsync, | 804 | .fsync = file_fsync, |
749 | }; | 805 | }; |
750 | 806 | ||
diff --git a/fs/fat/file.c b/fs/fat/file.c index 1ee25232e6af..f4b8f8b3fbdd 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/smp_lock.h> | 13 | #include <linux/smp_lock.h> |
14 | #include <linux/buffer_head.h> | 14 | #include <linux/buffer_head.h> |
15 | #include <linux/writeback.h> | 15 | #include <linux/writeback.h> |
16 | #include <linux/blkdev.h> | ||
16 | 17 | ||
17 | int fat_generic_ioctl(struct inode *inode, struct file *filp, | 18 | int fat_generic_ioctl(struct inode *inode, struct file *filp, |
18 | unsigned int cmd, unsigned long arg) | 19 | unsigned int cmd, unsigned long arg) |
@@ -112,15 +113,24 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp, | |||
112 | } | 113 | } |
113 | } | 114 | } |
114 | 115 | ||
116 | static int fat_file_release(struct inode *inode, struct file *filp) | ||
117 | { | ||
118 | if ((filp->f_mode & FMODE_WRITE) && | ||
119 | MSDOS_SB(inode->i_sb)->options.flush) { | ||
120 | fat_flush_inodes(inode->i_sb, inode, NULL); | ||
121 | blk_congestion_wait(WRITE, HZ/10); | ||
122 | } | ||
123 | return 0; | ||
124 | } | ||
125 | |||
115 | const struct file_operations fat_file_operations = { | 126 | const struct file_operations fat_file_operations = { |
116 | .llseek = generic_file_llseek, | 127 | .llseek = generic_file_llseek, |
117 | .read = do_sync_read, | 128 | .read = do_sync_read, |
118 | .write = do_sync_write, | 129 | .write = do_sync_write, |
119 | .readv = generic_file_readv, | ||
120 | .writev = generic_file_writev, | ||
121 | .aio_read = generic_file_aio_read, | 130 | .aio_read = generic_file_aio_read, |
122 | .aio_write = generic_file_aio_write, | 131 | .aio_write = generic_file_aio_write, |
123 | .mmap = generic_file_mmap, | 132 | .mmap = generic_file_mmap, |
133 | .release = fat_file_release, | ||
124 | .ioctl = fat_generic_ioctl, | 134 | .ioctl = fat_generic_ioctl, |
125 | .fsync = file_fsync, | 135 | .fsync = file_fsync, |
126 | .sendfile = generic_file_sendfile, | 136 | .sendfile = generic_file_sendfile, |
@@ -289,6 +299,7 @@ void fat_truncate(struct inode *inode) | |||
289 | lock_kernel(); | 299 | lock_kernel(); |
290 | fat_free(inode, nr_clusters); | 300 | fat_free(inode, nr_clusters); |
291 | unlock_kernel(); | 301 | unlock_kernel(); |
302 | fat_flush_inodes(inode->i_sb, inode, NULL); | ||
292 | } | 303 | } |
293 | 304 | ||
294 | struct inode_operations fat_file_inode_operations = { | 305 | struct inode_operations fat_file_inode_operations = { |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index ab96ae823753..045738032a83 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/vfs.h> | 24 | #include <linux/vfs.h> |
25 | #include <linux/parser.h> | 25 | #include <linux/parser.h> |
26 | #include <linux/uio.h> | 26 | #include <linux/uio.h> |
27 | #include <linux/writeback.h> | ||
27 | #include <asm/unaligned.h> | 28 | #include <asm/unaligned.h> |
28 | 29 | ||
29 | #ifndef CONFIG_FAT_DEFAULT_IOCHARSET | 30 | #ifndef CONFIG_FAT_DEFAULT_IOCHARSET |
@@ -853,7 +854,7 @@ enum { | |||
853 | Opt_charset, Opt_shortname_lower, Opt_shortname_win95, | 854 | Opt_charset, Opt_shortname_lower, Opt_shortname_win95, |
854 | Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes, | 855 | Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes, |
855 | Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, | 856 | Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, |
856 | Opt_obsolate, Opt_err, | 857 | Opt_obsolate, Opt_flush, Opt_err, |
857 | }; | 858 | }; |
858 | 859 | ||
859 | static match_table_t fat_tokens = { | 860 | static match_table_t fat_tokens = { |
@@ -885,7 +886,8 @@ static match_table_t fat_tokens = { | |||
885 | {Opt_obsolate, "cvf_format=%20s"}, | 886 | {Opt_obsolate, "cvf_format=%20s"}, |
886 | {Opt_obsolate, "cvf_options=%100s"}, | 887 | {Opt_obsolate, "cvf_options=%100s"}, |
887 | {Opt_obsolate, "posix"}, | 888 | {Opt_obsolate, "posix"}, |
888 | {Opt_err, NULL} | 889 | {Opt_flush, "flush"}, |
890 | {Opt_err, NULL}, | ||
889 | }; | 891 | }; |
890 | static match_table_t msdos_tokens = { | 892 | static match_table_t msdos_tokens = { |
891 | {Opt_nodots, "nodots"}, | 893 | {Opt_nodots, "nodots"}, |
@@ -1026,6 +1028,9 @@ static int parse_options(char *options, int is_vfat, int silent, int *debug, | |||
1026 | return 0; | 1028 | return 0; |
1027 | opts->codepage = option; | 1029 | opts->codepage = option; |
1028 | break; | 1030 | break; |
1031 | case Opt_flush: | ||
1032 | opts->flush = 1; | ||
1033 | break; | ||
1029 | 1034 | ||
1030 | /* msdos specific */ | 1035 | /* msdos specific */ |
1031 | case Opt_dots: | 1036 | case Opt_dots: |
@@ -1425,6 +1430,56 @@ out_fail: | |||
1425 | 1430 | ||
1426 | EXPORT_SYMBOL_GPL(fat_fill_super); | 1431 | EXPORT_SYMBOL_GPL(fat_fill_super); |
1427 | 1432 | ||
1433 | /* | ||
1434 | * helper function for fat_flush_inodes. This writes both the inode | ||
1435 | * and the file data blocks, waiting for in flight data blocks before | ||
1436 | * the start of the call. It does not wait for any io started | ||
1437 | * during the call | ||
1438 | */ | ||
1439 | static int writeback_inode(struct inode *inode) | ||
1440 | { | ||
1441 | |||
1442 | int ret; | ||
1443 | struct address_space *mapping = inode->i_mapping; | ||
1444 | struct writeback_control wbc = { | ||
1445 | .sync_mode = WB_SYNC_NONE, | ||
1446 | .nr_to_write = 0, | ||
1447 | }; | ||
1448 | /* if we used WB_SYNC_ALL, sync_inode waits for the io for the | ||
1449 | * inode to finish. So WB_SYNC_NONE is sent down to sync_inode | ||
1450 | * and filemap_fdatawrite is used for the data blocks | ||
1451 | */ | ||
1452 | ret = sync_inode(inode, &wbc); | ||
1453 | if (!ret) | ||
1454 | ret = filemap_fdatawrite(mapping); | ||
1455 | return ret; | ||
1456 | } | ||
1457 | |||
1458 | /* | ||
1459 | * write data and metadata corresponding to i1 and i2. The io is | ||
1460 | * started but we do not wait for any of it to finish. | ||
1461 | * | ||
1462 | * filemap_flush is used for the block device, so if there is a dirty | ||
1463 | * page for a block already in flight, we will not wait and start the | ||
1464 | * io over again | ||
1465 | */ | ||
1466 | int fat_flush_inodes(struct super_block *sb, struct inode *i1, struct inode *i2) | ||
1467 | { | ||
1468 | int ret = 0; | ||
1469 | if (!MSDOS_SB(sb)->options.flush) | ||
1470 | return 0; | ||
1471 | if (i1) | ||
1472 | ret = writeback_inode(i1); | ||
1473 | if (!ret && i2) | ||
1474 | ret = writeback_inode(i2); | ||
1475 | if (!ret && sb) { | ||
1476 | struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping; | ||
1477 | ret = filemap_flush(mapping); | ||
1478 | } | ||
1479 | return ret; | ||
1480 | } | ||
1481 | EXPORT_SYMBOL_GPL(fat_flush_inodes); | ||
1482 | |||
1428 | static int __init init_fat_fs(void) | 1483 | static int __init init_fat_fs(void) |
1429 | { | 1484 | { |
1430 | int err; | 1485 | int err; |
@@ -288,71 +288,63 @@ out: | |||
288 | } | 288 | } |
289 | 289 | ||
290 | /* | 290 | /* |
291 | * Expands the file descriptor table - it will allocate a new fdtable and | 291 | * Expand the file descriptor table. |
292 | * both fd array and fdset. It is expected to be called with the | 292 | * This function will allocate a new fdtable and both fd array and fdset, of |
293 | * files_lock held. | 293 | * the given size. |
294 | * Return <0 error code on error; 1 on successful completion. | ||
295 | * The files->file_lock should be held on entry, and will be held on exit. | ||
294 | */ | 296 | */ |
295 | static int expand_fdtable(struct files_struct *files, int nr) | 297 | static int expand_fdtable(struct files_struct *files, int nr) |
296 | __releases(files->file_lock) | 298 | __releases(files->file_lock) |
297 | __acquires(files->file_lock) | 299 | __acquires(files->file_lock) |
298 | { | 300 | { |
299 | int error = 0; | 301 | struct fdtable *new_fdt, *cur_fdt; |
300 | struct fdtable *fdt; | ||
301 | struct fdtable *nfdt = NULL; | ||
302 | 302 | ||
303 | spin_unlock(&files->file_lock); | 303 | spin_unlock(&files->file_lock); |
304 | nfdt = alloc_fdtable(nr); | 304 | new_fdt = alloc_fdtable(nr); |
305 | if (!nfdt) { | ||
306 | error = -ENOMEM; | ||
307 | spin_lock(&files->file_lock); | ||
308 | goto out; | ||
309 | } | ||
310 | |||
311 | spin_lock(&files->file_lock); | 305 | spin_lock(&files->file_lock); |
312 | fdt = files_fdtable(files); | 306 | if (!new_fdt) |
307 | return -ENOMEM; | ||
313 | /* | 308 | /* |
314 | * Check again since another task may have expanded the | 309 | * Check again since another task may have expanded the fd table while |
315 | * fd table while we dropped the lock | 310 | * we dropped the lock |
316 | */ | 311 | */ |
317 | if (nr >= fdt->max_fds || nr >= fdt->max_fdset) { | 312 | cur_fdt = files_fdtable(files); |
318 | copy_fdtable(nfdt, fdt); | 313 | if (nr >= cur_fdt->max_fds || nr >= cur_fdt->max_fdset) { |
314 | /* Continue as planned */ | ||
315 | copy_fdtable(new_fdt, cur_fdt); | ||
316 | rcu_assign_pointer(files->fdt, new_fdt); | ||
317 | free_fdtable(cur_fdt); | ||
319 | } else { | 318 | } else { |
320 | /* Somebody expanded while we dropped file_lock */ | 319 | /* Somebody else expanded, so undo our attempt */ |
321 | spin_unlock(&files->file_lock); | 320 | __free_fdtable(new_fdt); |
322 | __free_fdtable(nfdt); | ||
323 | spin_lock(&files->file_lock); | ||
324 | goto out; | ||
325 | } | 321 | } |
326 | rcu_assign_pointer(files->fdt, nfdt); | 322 | return 1; |
327 | free_fdtable(fdt); | ||
328 | out: | ||
329 | return error; | ||
330 | } | 323 | } |
331 | 324 | ||
332 | /* | 325 | /* |
333 | * Expand files. | 326 | * Expand files. |
334 | * Return <0 on error; 0 nothing done; 1 files expanded, we may have blocked. | 327 | * This function will expand the file structures, if the requested size exceeds |
335 | * Should be called with the files->file_lock spinlock held for write. | 328 | * the current capacity and there is room for expansion. |
329 | * Return <0 error code on error; 0 when nothing done; 1 when files were | ||
330 | * expanded and execution may have blocked. | ||
331 | * The files->file_lock should be held on entry, and will be held on exit. | ||
336 | */ | 332 | */ |
337 | int expand_files(struct files_struct *files, int nr) | 333 | int expand_files(struct files_struct *files, int nr) |
338 | { | 334 | { |
339 | int err, expand = 0; | ||
340 | struct fdtable *fdt; | 335 | struct fdtable *fdt; |
341 | 336 | ||
342 | fdt = files_fdtable(files); | 337 | fdt = files_fdtable(files); |
343 | if (nr >= fdt->max_fdset || nr >= fdt->max_fds) { | 338 | /* Do we need to expand? */ |
344 | if (fdt->max_fdset >= NR_OPEN || | 339 | if (nr < fdt->max_fdset && nr < fdt->max_fds) |
345 | fdt->max_fds >= NR_OPEN || nr >= NR_OPEN) { | 340 | return 0; |
346 | err = -EMFILE; | 341 | /* Can we expand? */ |
347 | goto out; | 342 | if (fdt->max_fdset >= NR_OPEN || fdt->max_fds >= NR_OPEN || |
348 | } | 343 | nr >= NR_OPEN) |
349 | expand = 1; | 344 | return -EMFILE; |
350 | if ((err = expand_fdtable(files, nr))) | 345 | |
351 | goto out; | 346 | /* All good, so we try */ |
352 | } | 347 | return expand_fdtable(files, nr); |
353 | err = expand; | ||
354 | out: | ||
355 | return err; | ||
356 | } | 348 | } |
357 | 349 | ||
358 | static void __devinit fdtable_defer_list_init(int cpu) | 350 | static void __devinit fdtable_defer_list_init(int cpu) |
diff --git a/fs/filesystems.c b/fs/filesystems.c index 9f1072836c8e..e3fa77c6ed56 100644 --- a/fs/filesystems.c +++ b/fs/filesystems.c | |||
@@ -69,8 +69,6 @@ int register_filesystem(struct file_system_type * fs) | |||
69 | int res = 0; | 69 | int res = 0; |
70 | struct file_system_type ** p; | 70 | struct file_system_type ** p; |
71 | 71 | ||
72 | if (!fs) | ||
73 | return -EINVAL; | ||
74 | if (fs->next) | 72 | if (fs->next) |
75 | return -EBUSY; | 73 | return -EBUSY; |
76 | INIT_LIST_HEAD(&fs->fs_supers); | 74 | INIT_LIST_HEAD(&fs->fs_supers); |
diff --git a/fs/freevxfs/vxfs_super.c b/fs/freevxfs/vxfs_super.c index b74b791fc23b..ac28b0835ffc 100644 --- a/fs/freevxfs/vxfs_super.c +++ b/fs/freevxfs/vxfs_super.c | |||
@@ -260,12 +260,17 @@ static struct file_system_type vxfs_fs_type = { | |||
260 | static int __init | 260 | static int __init |
261 | vxfs_init(void) | 261 | vxfs_init(void) |
262 | { | 262 | { |
263 | int rv; | ||
264 | |||
263 | vxfs_inode_cachep = kmem_cache_create("vxfs_inode", | 265 | vxfs_inode_cachep = kmem_cache_create("vxfs_inode", |
264 | sizeof(struct vxfs_inode_info), 0, | 266 | sizeof(struct vxfs_inode_info), 0, |
265 | SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL, NULL); | 267 | SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL, NULL); |
266 | if (vxfs_inode_cachep) | 268 | if (!vxfs_inode_cachep) |
267 | return register_filesystem(&vxfs_fs_type); | 269 | return -ENOMEM; |
268 | return -ENOMEM; | 270 | rv = register_filesystem(&vxfs_fs_type); |
271 | if (rv < 0) | ||
272 | kmem_cache_destroy(vxfs_inode_cachep); | ||
273 | return rv; | ||
269 | } | 274 | } |
270 | 275 | ||
271 | static void __exit | 276 | static void __exit |
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 892643dc9af1..c403b66ec83c 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -22,8 +22,7 @@ | |||
22 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
23 | #include <linux/backing-dev.h> | 23 | #include <linux/backing-dev.h> |
24 | #include <linux/buffer_head.h> | 24 | #include <linux/buffer_head.h> |
25 | 25 | #include "internal.h" | |
26 | extern struct super_block *blockdev_superblock; | ||
27 | 26 | ||
28 | /** | 27 | /** |
29 | * __mark_inode_dirty - internal function | 28 | * __mark_inode_dirty - internal function |
@@ -320,7 +319,7 @@ sync_sb_inodes(struct super_block *sb, struct writeback_control *wbc) | |||
320 | 319 | ||
321 | if (!bdi_cap_writeback_dirty(bdi)) { | 320 | if (!bdi_cap_writeback_dirty(bdi)) { |
322 | list_move(&inode->i_list, &sb->s_dirty); | 321 | list_move(&inode->i_list, &sb->s_dirty); |
323 | if (sb == blockdev_superblock) { | 322 | if (sb_is_blkdev_sb(sb)) { |
324 | /* | 323 | /* |
325 | * Dirty memory-backed blockdev: the ramdisk | 324 | * Dirty memory-backed blockdev: the ramdisk |
326 | * driver does this. Skip just this inode | 325 | * driver does this. Skip just this inode |
@@ -337,14 +336,14 @@ sync_sb_inodes(struct super_block *sb, struct writeback_control *wbc) | |||
337 | 336 | ||
338 | if (wbc->nonblocking && bdi_write_congested(bdi)) { | 337 | if (wbc->nonblocking && bdi_write_congested(bdi)) { |
339 | wbc->encountered_congestion = 1; | 338 | wbc->encountered_congestion = 1; |
340 | if (sb != blockdev_superblock) | 339 | if (!sb_is_blkdev_sb(sb)) |
341 | break; /* Skip a congested fs */ | 340 | break; /* Skip a congested fs */ |
342 | list_move(&inode->i_list, &sb->s_dirty); | 341 | list_move(&inode->i_list, &sb->s_dirty); |
343 | continue; /* Skip a congested blockdev */ | 342 | continue; /* Skip a congested blockdev */ |
344 | } | 343 | } |
345 | 344 | ||
346 | if (wbc->bdi && bdi != wbc->bdi) { | 345 | if (wbc->bdi && bdi != wbc->bdi) { |
347 | if (sb != blockdev_superblock) | 346 | if (!sb_is_blkdev_sb(sb)) |
348 | break; /* fs has the wrong queue */ | 347 | break; /* fs has the wrong queue */ |
349 | list_move(&inode->i_list, &sb->s_dirty); | 348 | list_move(&inode->i_list, &sb->s_dirty); |
350 | continue; /* blockdev has wrong queue */ | 349 | continue; /* blockdev has wrong queue */ |
diff --git a/fs/fuse/control.c b/fs/fuse/control.c index 79ec1f23d4d2..16b39c053d47 100644 --- a/fs/fuse/control.c +++ b/fs/fuse/control.c | |||
@@ -116,7 +116,7 @@ int fuse_ctl_add_conn(struct fuse_conn *fc) | |||
116 | return 0; | 116 | return 0; |
117 | 117 | ||
118 | parent = fuse_control_sb->s_root; | 118 | parent = fuse_control_sb->s_root; |
119 | parent->d_inode->i_nlink++; | 119 | inc_nlink(parent->d_inode); |
120 | sprintf(name, "%llu", (unsigned long long) fc->id); | 120 | sprintf(name, "%llu", (unsigned long long) fc->id); |
121 | parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 2, | 121 | parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 2, |
122 | &simple_dir_inode_operations, | 122 | &simple_dir_inode_operations, |
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 1e2006caf158..66571eafbb1e 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
@@ -212,6 +212,7 @@ void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req) | |||
212 | * Called with fc->lock, unlocks it | 212 | * Called with fc->lock, unlocks it |
213 | */ | 213 | */ |
214 | static void request_end(struct fuse_conn *fc, struct fuse_req *req) | 214 | static void request_end(struct fuse_conn *fc, struct fuse_req *req) |
215 | __releases(fc->lock) | ||
215 | { | 216 | { |
216 | void (*end) (struct fuse_conn *, struct fuse_req *) = req->end; | 217 | void (*end) (struct fuse_conn *, struct fuse_req *) = req->end; |
217 | req->end = NULL; | 218 | req->end = NULL; |
@@ -640,6 +641,7 @@ static void request_wait(struct fuse_conn *fc) | |||
640 | */ | 641 | */ |
641 | static int fuse_read_interrupt(struct fuse_conn *fc, struct fuse_req *req, | 642 | static int fuse_read_interrupt(struct fuse_conn *fc, struct fuse_req *req, |
642 | const struct iovec *iov, unsigned long nr_segs) | 643 | const struct iovec *iov, unsigned long nr_segs) |
644 | __releases(fc->lock) | ||
643 | { | 645 | { |
644 | struct fuse_copy_state cs; | 646 | struct fuse_copy_state cs; |
645 | struct fuse_in_header ih; | 647 | struct fuse_in_header ih; |
@@ -678,14 +680,15 @@ static int fuse_read_interrupt(struct fuse_conn *fc, struct fuse_req *req, | |||
678 | * request_end(). Otherwise add it to the processing list, and set | 680 | * request_end(). Otherwise add it to the processing list, and set |
679 | * the 'sent' flag. | 681 | * the 'sent' flag. |
680 | */ | 682 | */ |
681 | static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov, | 683 | static ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov, |
682 | unsigned long nr_segs, loff_t *off) | 684 | unsigned long nr_segs, loff_t pos) |
683 | { | 685 | { |
684 | int err; | 686 | int err; |
685 | struct fuse_req *req; | 687 | struct fuse_req *req; |
686 | struct fuse_in *in; | 688 | struct fuse_in *in; |
687 | struct fuse_copy_state cs; | 689 | struct fuse_copy_state cs; |
688 | unsigned reqsize; | 690 | unsigned reqsize; |
691 | struct file *file = iocb->ki_filp; | ||
689 | struct fuse_conn *fc = fuse_get_conn(file); | 692 | struct fuse_conn *fc = fuse_get_conn(file); |
690 | if (!fc) | 693 | if (!fc) |
691 | return -EPERM; | 694 | return -EPERM; |
@@ -759,15 +762,6 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov, | |||
759 | return err; | 762 | return err; |
760 | } | 763 | } |
761 | 764 | ||
762 | static ssize_t fuse_dev_read(struct file *file, char __user *buf, | ||
763 | size_t nbytes, loff_t *off) | ||
764 | { | ||
765 | struct iovec iov; | ||
766 | iov.iov_len = nbytes; | ||
767 | iov.iov_base = buf; | ||
768 | return fuse_dev_readv(file, &iov, 1, off); | ||
769 | } | ||
770 | |||
771 | /* Look up request on processing list by unique ID */ | 765 | /* Look up request on processing list by unique ID */ |
772 | static struct fuse_req *request_find(struct fuse_conn *fc, u64 unique) | 766 | static struct fuse_req *request_find(struct fuse_conn *fc, u64 unique) |
773 | { | 767 | { |
@@ -812,15 +806,15 @@ static int copy_out_args(struct fuse_copy_state *cs, struct fuse_out *out, | |||
812 | * it from the list and copy the rest of the buffer to the request. | 806 | * it from the list and copy the rest of the buffer to the request. |
813 | * The request is finished by calling request_end() | 807 | * The request is finished by calling request_end() |
814 | */ | 808 | */ |
815 | static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov, | 809 | static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov, |
816 | unsigned long nr_segs, loff_t *off) | 810 | unsigned long nr_segs, loff_t pos) |
817 | { | 811 | { |
818 | int err; | 812 | int err; |
819 | unsigned nbytes = iov_length(iov, nr_segs); | 813 | unsigned nbytes = iov_length(iov, nr_segs); |
820 | struct fuse_req *req; | 814 | struct fuse_req *req; |
821 | struct fuse_out_header oh; | 815 | struct fuse_out_header oh; |
822 | struct fuse_copy_state cs; | 816 | struct fuse_copy_state cs; |
823 | struct fuse_conn *fc = fuse_get_conn(file); | 817 | struct fuse_conn *fc = fuse_get_conn(iocb->ki_filp); |
824 | if (!fc) | 818 | if (!fc) |
825 | return -EPERM; | 819 | return -EPERM; |
826 | 820 | ||
@@ -896,15 +890,6 @@ static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov, | |||
896 | return err; | 890 | return err; |
897 | } | 891 | } |
898 | 892 | ||
899 | static ssize_t fuse_dev_write(struct file *file, const char __user *buf, | ||
900 | size_t nbytes, loff_t *off) | ||
901 | { | ||
902 | struct iovec iov; | ||
903 | iov.iov_len = nbytes; | ||
904 | iov.iov_base = (char __user *) buf; | ||
905 | return fuse_dev_writev(file, &iov, 1, off); | ||
906 | } | ||
907 | |||
908 | static unsigned fuse_dev_poll(struct file *file, poll_table *wait) | 893 | static unsigned fuse_dev_poll(struct file *file, poll_table *wait) |
909 | { | 894 | { |
910 | unsigned mask = POLLOUT | POLLWRNORM; | 895 | unsigned mask = POLLOUT | POLLWRNORM; |
@@ -1039,10 +1024,10 @@ static int fuse_dev_fasync(int fd, struct file *file, int on) | |||
1039 | const struct file_operations fuse_dev_operations = { | 1024 | const struct file_operations fuse_dev_operations = { |
1040 | .owner = THIS_MODULE, | 1025 | .owner = THIS_MODULE, |
1041 | .llseek = no_llseek, | 1026 | .llseek = no_llseek, |
1042 | .read = fuse_dev_read, | 1027 | .read = do_sync_read, |
1043 | .readv = fuse_dev_readv, | 1028 | .aio_read = fuse_dev_read, |
1044 | .write = fuse_dev_write, | 1029 | .write = do_sync_write, |
1045 | .writev = fuse_dev_writev, | 1030 | .aio_write = fuse_dev_write, |
1046 | .poll = fuse_dev_poll, | 1031 | .poll = fuse_dev_poll, |
1047 | .release = fuse_dev_release, | 1032 | .release = fuse_dev_release, |
1048 | .fasync = fuse_dev_fasync, | 1033 | .fasync = fuse_dev_fasync, |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 409ce6a7cca4..8605155db171 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -508,7 +508,7 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry) | |||
508 | /* Set nlink to zero so the inode can be cleared, if | 508 | /* Set nlink to zero so the inode can be cleared, if |
509 | the inode does have more links this will be | 509 | the inode does have more links this will be |
510 | discovered at the next lookup/getattr */ | 510 | discovered at the next lookup/getattr */ |
511 | inode->i_nlink = 0; | 511 | clear_nlink(inode); |
512 | fuse_invalidate_attr(inode); | 512 | fuse_invalidate_attr(inode); |
513 | fuse_invalidate_attr(dir); | 513 | fuse_invalidate_attr(dir); |
514 | fuse_invalidate_entry_cache(entry); | 514 | fuse_invalidate_entry_cache(entry); |
@@ -534,7 +534,7 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry) | |||
534 | err = req->out.h.error; | 534 | err = req->out.h.error; |
535 | fuse_put_request(fc, req); | 535 | fuse_put_request(fc, req); |
536 | if (!err) { | 536 | if (!err) { |
537 | entry->d_inode->i_nlink = 0; | 537 | clear_nlink(entry->d_inode); |
538 | fuse_invalidate_attr(dir); | 538 | fuse_invalidate_attr(dir); |
539 | fuse_invalidate_entry_cache(entry); | 539 | fuse_invalidate_entry_cache(entry); |
540 | } else if (err == -EINTR) | 540 | } else if (err == -EINTR) |
@@ -776,7 +776,7 @@ static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd) | |||
776 | if ((mask & MAY_EXEC) && !S_ISDIR(mode) && !(mode & S_IXUGO)) | 776 | if ((mask & MAY_EXEC) && !S_ISDIR(mode) && !(mode & S_IXUGO)) |
777 | return -EACCES; | 777 | return -EACCES; |
778 | 778 | ||
779 | if (nd && (nd->flags & LOOKUP_ACCESS)) | 779 | if (nd && (nd->flags & (LOOKUP_ACCESS | LOOKUP_CHDIR))) |
780 | return fuse_access(inode, mask); | 780 | return fuse_access(inode, mask); |
781 | return 0; | 781 | return 0; |
782 | } | 782 | } |
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 5c4fcd1dbf59..183626868eea 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -753,8 +753,10 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) | |||
753 | 753 | ||
754 | static const struct file_operations fuse_file_operations = { | 754 | static const struct file_operations fuse_file_operations = { |
755 | .llseek = generic_file_llseek, | 755 | .llseek = generic_file_llseek, |
756 | .read = generic_file_read, | 756 | .read = do_sync_read, |
757 | .write = generic_file_write, | 757 | .aio_read = generic_file_aio_read, |
758 | .write = do_sync_write, | ||
759 | .aio_write = generic_file_aio_write, | ||
758 | .mmap = fuse_file_mmap, | 760 | .mmap = fuse_file_mmap, |
759 | .open = fuse_open, | 761 | .open = fuse_open, |
760 | .flush = fuse_flush, | 762 | .flush = fuse_flush, |
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index cb7cadb0b790..7d0a9aee01f2 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -251,6 +251,7 @@ static int fuse_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
251 | memset(&outarg, 0, sizeof(outarg)); | 251 | memset(&outarg, 0, sizeof(outarg)); |
252 | req->in.numargs = 0; | 252 | req->in.numargs = 0; |
253 | req->in.h.opcode = FUSE_STATFS; | 253 | req->in.h.opcode = FUSE_STATFS; |
254 | req->in.h.nodeid = get_node_id(dentry->d_inode); | ||
254 | req->out.numargs = 1; | 255 | req->out.numargs = 1; |
255 | req->out.args[0].size = | 256 | req->out.args[0].size = |
256 | fc->minor < 4 ? FUSE_COMPAT_STATFS_SIZE : sizeof(outarg); | 257 | fc->minor < 4 ? FUSE_COMPAT_STATFS_SIZE : sizeof(outarg); |
diff --git a/fs/generic_acl.c b/fs/generic_acl.c new file mode 100644 index 000000000000..9ccb78947171 --- /dev/null +++ b/fs/generic_acl.c | |||
@@ -0,0 +1,197 @@ | |||
1 | /* | ||
2 | * fs/generic_acl.c | ||
3 | * | ||
4 | * (C) 2005 Andreas Gruenbacher <agruen@suse.de> | ||
5 | * | ||
6 | * This file is released under the GPL. | ||
7 | */ | ||
8 | |||
9 | #include <linux/sched.h> | ||
10 | #include <linux/fs.h> | ||
11 | #include <linux/generic_acl.h> | ||
12 | |||
13 | /** | ||
14 | * generic_acl_list - Generic xattr_handler->list() operation | ||
15 | * @ops: Filesystem specific getacl and setacl callbacks | ||
16 | */ | ||
17 | size_t | ||
18 | generic_acl_list(struct inode *inode, struct generic_acl_operations *ops, | ||
19 | int type, char *list, size_t list_size) | ||
20 | { | ||
21 | struct posix_acl *acl; | ||
22 | const char *name; | ||
23 | size_t size; | ||
24 | |||
25 | acl = ops->getacl(inode, type); | ||
26 | if (!acl) | ||
27 | return 0; | ||
28 | posix_acl_release(acl); | ||
29 | |||
30 | switch(type) { | ||
31 | case ACL_TYPE_ACCESS: | ||
32 | name = POSIX_ACL_XATTR_ACCESS; | ||
33 | break; | ||
34 | |||
35 | case ACL_TYPE_DEFAULT: | ||
36 | name = POSIX_ACL_XATTR_DEFAULT; | ||
37 | break; | ||
38 | |||
39 | default: | ||
40 | return 0; | ||
41 | } | ||
42 | size = strlen(name) + 1; | ||
43 | if (list && size <= list_size) | ||
44 | memcpy(list, name, size); | ||
45 | return size; | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * generic_acl_get - Generic xattr_handler->get() operation | ||
50 | * @ops: Filesystem specific getacl and setacl callbacks | ||
51 | */ | ||
52 | int | ||
53 | generic_acl_get(struct inode *inode, struct generic_acl_operations *ops, | ||
54 | int type, void *buffer, size_t size) | ||
55 | { | ||
56 | struct posix_acl *acl; | ||
57 | int error; | ||
58 | |||
59 | acl = ops->getacl(inode, type); | ||
60 | if (!acl) | ||
61 | return -ENODATA; | ||
62 | error = posix_acl_to_xattr(acl, buffer, size); | ||
63 | posix_acl_release(acl); | ||
64 | |||
65 | return error; | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * generic_acl_set - Generic xattr_handler->set() operation | ||
70 | * @ops: Filesystem specific getacl and setacl callbacks | ||
71 | */ | ||
72 | int | ||
73 | generic_acl_set(struct inode *inode, struct generic_acl_operations *ops, | ||
74 | int type, const void *value, size_t size) | ||
75 | { | ||
76 | struct posix_acl *acl = NULL; | ||
77 | int error; | ||
78 | |||
79 | if (S_ISLNK(inode->i_mode)) | ||
80 | return -EOPNOTSUPP; | ||
81 | if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) | ||
82 | return -EPERM; | ||
83 | if (value) { | ||
84 | acl = posix_acl_from_xattr(value, size); | ||
85 | if (IS_ERR(acl)) | ||
86 | return PTR_ERR(acl); | ||
87 | } | ||
88 | if (acl) { | ||
89 | mode_t mode; | ||
90 | |||
91 | error = posix_acl_valid(acl); | ||
92 | if (error) | ||
93 | goto failed; | ||
94 | switch(type) { | ||
95 | case ACL_TYPE_ACCESS: | ||
96 | mode = inode->i_mode; | ||
97 | error = posix_acl_equiv_mode(acl, &mode); | ||
98 | if (error < 0) | ||
99 | goto failed; | ||
100 | inode->i_mode = mode; | ||
101 | if (error == 0) { | ||
102 | posix_acl_release(acl); | ||
103 | acl = NULL; | ||
104 | } | ||
105 | break; | ||
106 | |||
107 | case ACL_TYPE_DEFAULT: | ||
108 | if (!S_ISDIR(inode->i_mode)) { | ||
109 | error = -EINVAL; | ||
110 | goto failed; | ||
111 | } | ||
112 | break; | ||
113 | } | ||
114 | } | ||
115 | ops->setacl(inode, type, acl); | ||
116 | error = 0; | ||
117 | failed: | ||
118 | posix_acl_release(acl); | ||
119 | return error; | ||
120 | } | ||
121 | |||
122 | /** | ||
123 | * generic_acl_init - Take care of acl inheritance at @inode create time | ||
124 | * @ops: Filesystem specific getacl and setacl callbacks | ||
125 | * | ||
126 | * Files created inside a directory with a default ACL inherit the | ||
127 | * directory's default ACL. | ||
128 | */ | ||
129 | int | ||
130 | generic_acl_init(struct inode *inode, struct inode *dir, | ||
131 | struct generic_acl_operations *ops) | ||
132 | { | ||
133 | struct posix_acl *acl = NULL; | ||
134 | mode_t mode = inode->i_mode; | ||
135 | int error; | ||
136 | |||
137 | inode->i_mode = mode & ~current->fs->umask; | ||
138 | if (!S_ISLNK(inode->i_mode)) | ||
139 | acl = ops->getacl(dir, ACL_TYPE_DEFAULT); | ||
140 | if (acl) { | ||
141 | struct posix_acl *clone; | ||
142 | |||
143 | if (S_ISDIR(inode->i_mode)) { | ||
144 | clone = posix_acl_clone(acl, GFP_KERNEL); | ||
145 | error = -ENOMEM; | ||
146 | if (!clone) | ||
147 | goto cleanup; | ||
148 | ops->setacl(inode, ACL_TYPE_DEFAULT, clone); | ||
149 | posix_acl_release(clone); | ||
150 | } | ||
151 | clone = posix_acl_clone(acl, GFP_KERNEL); | ||
152 | error = -ENOMEM; | ||
153 | if (!clone) | ||
154 | goto cleanup; | ||
155 | error = posix_acl_create_masq(clone, &mode); | ||
156 | if (error >= 0) { | ||
157 | inode->i_mode = mode; | ||
158 | if (error > 0) | ||
159 | ops->setacl(inode, ACL_TYPE_ACCESS, clone); | ||
160 | } | ||
161 | posix_acl_release(clone); | ||
162 | } | ||
163 | error = 0; | ||
164 | |||
165 | cleanup: | ||
166 | posix_acl_release(acl); | ||
167 | return error; | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * generic_acl_chmod - change the access acl of @inode upon chmod() | ||
172 | * @ops: FIlesystem specific getacl and setacl callbacks | ||
173 | * | ||
174 | * A chmod also changes the permissions of the owner, group/mask, and | ||
175 | * other ACL entries. | ||
176 | */ | ||
177 | int | ||
178 | generic_acl_chmod(struct inode *inode, struct generic_acl_operations *ops) | ||
179 | { | ||
180 | struct posix_acl *acl, *clone; | ||
181 | int error = 0; | ||
182 | |||
183 | if (S_ISLNK(inode->i_mode)) | ||
184 | return -EOPNOTSUPP; | ||
185 | acl = ops->getacl(inode, ACL_TYPE_ACCESS); | ||
186 | if (acl) { | ||
187 | clone = posix_acl_clone(acl, GFP_KERNEL); | ||
188 | posix_acl_release(acl); | ||
189 | if (!clone) | ||
190 | return -ENOMEM; | ||
191 | error = posix_acl_chmod_masq(clone, inode->i_mode); | ||
192 | if (!error) | ||
193 | ops->setacl(inode, ACL_TYPE_ACCESS, clone); | ||
194 | posix_acl_release(clone); | ||
195 | } | ||
196 | return error; | ||
197 | } | ||
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c index 7cd8cc03aea7..37d681b4f216 100644 --- a/fs/hfs/dir.c +++ b/fs/hfs/dir.c | |||
@@ -246,7 +246,7 @@ static int hfs_unlink(struct inode *dir, struct dentry *dentry) | |||
246 | if (res) | 246 | if (res) |
247 | return res; | 247 | return res; |
248 | 248 | ||
249 | inode->i_nlink--; | 249 | drop_nlink(inode); |
250 | hfs_delete_inode(inode); | 250 | hfs_delete_inode(inode); |
251 | inode->i_ctime = CURRENT_TIME_SEC; | 251 | inode->i_ctime = CURRENT_TIME_SEC; |
252 | mark_inode_dirty(inode); | 252 | mark_inode_dirty(inode); |
@@ -273,7 +273,7 @@ static int hfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
273 | res = hfs_cat_delete(inode->i_ino, dir, &dentry->d_name); | 273 | res = hfs_cat_delete(inode->i_ino, dir, &dentry->d_name); |
274 | if (res) | 274 | if (res) |
275 | return res; | 275 | return res; |
276 | inode->i_nlink = 0; | 276 | clear_nlink(inode); |
277 | inode->i_ctime = CURRENT_TIME_SEC; | 277 | inode->i_ctime = CURRENT_TIME_SEC; |
278 | hfs_delete_inode(inode); | 278 | hfs_delete_inode(inode); |
279 | mark_inode_dirty(inode); | 279 | mark_inode_dirty(inode); |
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c index d05641c35fc9..02f5573e0349 100644 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c | |||
@@ -601,8 +601,10 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr) | |||
601 | 601 | ||
602 | static const struct file_operations hfs_file_operations = { | 602 | static const struct file_operations hfs_file_operations = { |
603 | .llseek = generic_file_llseek, | 603 | .llseek = generic_file_llseek, |
604 | .read = generic_file_read, | 604 | .read = do_sync_read, |
605 | .write = generic_file_write, | 605 | .aio_read = generic_file_aio_read, |
606 | .write = do_sync_write, | ||
607 | .aio_write = generic_file_aio_write, | ||
606 | .mmap = generic_file_mmap, | 608 | .mmap = generic_file_mmap, |
607 | .sendfile = generic_file_sendfile, | 609 | .sendfile = generic_file_sendfile, |
608 | .fsync = file_fsync, | 610 | .fsync = file_fsync, |
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index 1f9ece0de326..7e309751645f 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c | |||
@@ -298,7 +298,7 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir, | |||
298 | if (res) | 298 | if (res) |
299 | return res; | 299 | return res; |
300 | 300 | ||
301 | inode->i_nlink++; | 301 | inc_nlink(inode); |
302 | hfsplus_instantiate(dst_dentry, inode, cnid); | 302 | hfsplus_instantiate(dst_dentry, inode, cnid); |
303 | atomic_inc(&inode->i_count); | 303 | atomic_inc(&inode->i_count); |
304 | inode->i_ctime = CURRENT_TIME_SEC; | 304 | inode->i_ctime = CURRENT_TIME_SEC; |
@@ -338,7 +338,7 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry) | |||
338 | return res; | 338 | return res; |
339 | 339 | ||
340 | if (inode->i_nlink > 0) | 340 | if (inode->i_nlink > 0) |
341 | inode->i_nlink--; | 341 | drop_nlink(inode); |
342 | hfsplus_delete_inode(inode); | 342 | hfsplus_delete_inode(inode); |
343 | if (inode->i_ino != cnid && !inode->i_nlink) { | 343 | if (inode->i_ino != cnid && !inode->i_nlink) { |
344 | if (!atomic_read(&HFSPLUS_I(inode).opencnt)) { | 344 | if (!atomic_read(&HFSPLUS_I(inode).opencnt)) { |
@@ -348,7 +348,7 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry) | |||
348 | } else | 348 | } else |
349 | inode->i_flags |= S_DEAD; | 349 | inode->i_flags |= S_DEAD; |
350 | } else | 350 | } else |
351 | inode->i_nlink = 0; | 351 | clear_nlink(inode); |
352 | inode->i_ctime = CURRENT_TIME_SEC; | 352 | inode->i_ctime = CURRENT_TIME_SEC; |
353 | mark_inode_dirty(inode); | 353 | mark_inode_dirty(inode); |
354 | 354 | ||
@@ -387,7 +387,7 @@ static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry) | |||
387 | res = hfsplus_delete_cat(inode->i_ino, dir, &dentry->d_name); | 387 | res = hfsplus_delete_cat(inode->i_ino, dir, &dentry->d_name); |
388 | if (res) | 388 | if (res) |
389 | return res; | 389 | return res; |
390 | inode->i_nlink = 0; | 390 | clear_nlink(inode); |
391 | inode->i_ctime = CURRENT_TIME_SEC; | 391 | inode->i_ctime = CURRENT_TIME_SEC; |
392 | hfsplus_delete_inode(inode); | 392 | hfsplus_delete_inode(inode); |
393 | mark_inode_dirty(inode); | 393 | mark_inode_dirty(inode); |
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index 8a1ca5ef7ada..3915635b4470 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h | |||
@@ -246,12 +246,8 @@ struct hfsplus_readdir_data { | |||
246 | 246 | ||
247 | /* ext2 ioctls (EXT2_IOC_GETFLAGS and EXT2_IOC_SETFLAGS) to support | 247 | /* ext2 ioctls (EXT2_IOC_GETFLAGS and EXT2_IOC_SETFLAGS) to support |
248 | * chattr/lsattr */ | 248 | * chattr/lsattr */ |
249 | #define HFSPLUS_IOC_EXT2_GETFLAGS _IOR('f', 1, long) | 249 | #define HFSPLUS_IOC_EXT2_GETFLAGS FS_IOC_GETFLAGS |
250 | #define HFSPLUS_IOC_EXT2_SETFLAGS _IOW('f', 2, long) | 250 | #define HFSPLUS_IOC_EXT2_SETFLAGS FS_IOC_SETFLAGS |
251 | |||
252 | #define EXT2_FLAG_IMMUTABLE 0x00000010 /* Immutable file */ | ||
253 | #define EXT2_FLAG_APPEND 0x00000020 /* writes to file may only append */ | ||
254 | #define EXT2_FLAG_NODUMP 0x00000040 /* do not dump file */ | ||
255 | 251 | ||
256 | 252 | ||
257 | /* | 253 | /* |
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index 0eb1a6092668..9e3675249633 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c | |||
@@ -282,8 +282,10 @@ static struct inode_operations hfsplus_file_inode_operations = { | |||
282 | 282 | ||
283 | static const struct file_operations hfsplus_file_operations = { | 283 | static const struct file_operations hfsplus_file_operations = { |
284 | .llseek = generic_file_llseek, | 284 | .llseek = generic_file_llseek, |
285 | .read = generic_file_read, | 285 | .read = do_sync_read, |
286 | .write = generic_file_write, | 286 | .aio_read = generic_file_aio_read, |
287 | .write = do_sync_write, | ||
288 | .aio_write = generic_file_aio_write, | ||
287 | .mmap = generic_file_mmap, | 289 | .mmap = generic_file_mmap, |
288 | .sendfile = generic_file_sendfile, | 290 | .sendfile = generic_file_sendfile, |
289 | .fsync = file_fsync, | 291 | .fsync = file_fsync, |
diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c index 13cf848ac833..79fd10402ea3 100644 --- a/fs/hfsplus/ioctl.c +++ b/fs/hfsplus/ioctl.c | |||
@@ -28,11 +28,11 @@ int hfsplus_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | |||
28 | case HFSPLUS_IOC_EXT2_GETFLAGS: | 28 | case HFSPLUS_IOC_EXT2_GETFLAGS: |
29 | flags = 0; | 29 | flags = 0; |
30 | if (HFSPLUS_I(inode).rootflags & HFSPLUS_FLG_IMMUTABLE) | 30 | if (HFSPLUS_I(inode).rootflags & HFSPLUS_FLG_IMMUTABLE) |
31 | flags |= EXT2_FLAG_IMMUTABLE; /* EXT2_IMMUTABLE_FL */ | 31 | flags |= FS_IMMUTABLE_FL; /* EXT2_IMMUTABLE_FL */ |
32 | if (HFSPLUS_I(inode).rootflags & HFSPLUS_FLG_APPEND) | 32 | if (HFSPLUS_I(inode).rootflags & HFSPLUS_FLG_APPEND) |
33 | flags |= EXT2_FLAG_APPEND; /* EXT2_APPEND_FL */ | 33 | flags |= FS_APPEND_FL; /* EXT2_APPEND_FL */ |
34 | if (HFSPLUS_I(inode).userflags & HFSPLUS_FLG_NODUMP) | 34 | if (HFSPLUS_I(inode).userflags & HFSPLUS_FLG_NODUMP) |
35 | flags |= EXT2_FLAG_NODUMP; /* EXT2_NODUMP_FL */ | 35 | flags |= FS_NODUMP_FL; /* EXT2_NODUMP_FL */ |
36 | return put_user(flags, (int __user *)arg); | 36 | return put_user(flags, (int __user *)arg); |
37 | case HFSPLUS_IOC_EXT2_SETFLAGS: { | 37 | case HFSPLUS_IOC_EXT2_SETFLAGS: { |
38 | if (IS_RDONLY(inode)) | 38 | if (IS_RDONLY(inode)) |
@@ -44,32 +44,31 @@ int hfsplus_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | |||
44 | if (get_user(flags, (int __user *)arg)) | 44 | if (get_user(flags, (int __user *)arg)) |
45 | return -EFAULT; | 45 | return -EFAULT; |
46 | 46 | ||
47 | if (flags & (EXT2_FLAG_IMMUTABLE|EXT2_FLAG_APPEND) || | 47 | if (flags & (FS_IMMUTABLE_FL|FS_APPEND_FL) || |
48 | HFSPLUS_I(inode).rootflags & (HFSPLUS_FLG_IMMUTABLE|HFSPLUS_FLG_APPEND)) { | 48 | HFSPLUS_I(inode).rootflags & (HFSPLUS_FLG_IMMUTABLE|HFSPLUS_FLG_APPEND)) { |
49 | if (!capable(CAP_LINUX_IMMUTABLE)) | 49 | if (!capable(CAP_LINUX_IMMUTABLE)) |
50 | return -EPERM; | 50 | return -EPERM; |
51 | } | 51 | } |
52 | 52 | ||
53 | /* don't silently ignore unsupported ext2 flags */ | 53 | /* don't silently ignore unsupported ext2 flags */ |
54 | if (flags & ~(EXT2_FLAG_IMMUTABLE|EXT2_FLAG_APPEND| | 54 | if (flags & ~(FS_IMMUTABLE_FL|FS_APPEND_FL|FS_NODUMP_FL)) |
55 | EXT2_FLAG_NODUMP)) | ||
56 | return -EOPNOTSUPP; | 55 | return -EOPNOTSUPP; |
57 | 56 | ||
58 | if (flags & EXT2_FLAG_IMMUTABLE) { /* EXT2_IMMUTABLE_FL */ | 57 | if (flags & FS_IMMUTABLE_FL) { /* EXT2_IMMUTABLE_FL */ |
59 | inode->i_flags |= S_IMMUTABLE; | 58 | inode->i_flags |= S_IMMUTABLE; |
60 | HFSPLUS_I(inode).rootflags |= HFSPLUS_FLG_IMMUTABLE; | 59 | HFSPLUS_I(inode).rootflags |= HFSPLUS_FLG_IMMUTABLE; |
61 | } else { | 60 | } else { |
62 | inode->i_flags &= ~S_IMMUTABLE; | 61 | inode->i_flags &= ~S_IMMUTABLE; |
63 | HFSPLUS_I(inode).rootflags &= ~HFSPLUS_FLG_IMMUTABLE; | 62 | HFSPLUS_I(inode).rootflags &= ~HFSPLUS_FLG_IMMUTABLE; |
64 | } | 63 | } |
65 | if (flags & EXT2_FLAG_APPEND) { /* EXT2_APPEND_FL */ | 64 | if (flags & FS_APPEND_FL) { /* EXT2_APPEND_FL */ |
66 | inode->i_flags |= S_APPEND; | 65 | inode->i_flags |= S_APPEND; |
67 | HFSPLUS_I(inode).rootflags |= HFSPLUS_FLG_APPEND; | 66 | HFSPLUS_I(inode).rootflags |= HFSPLUS_FLG_APPEND; |
68 | } else { | 67 | } else { |
69 | inode->i_flags &= ~S_APPEND; | 68 | inode->i_flags &= ~S_APPEND; |
70 | HFSPLUS_I(inode).rootflags &= ~HFSPLUS_FLG_APPEND; | 69 | HFSPLUS_I(inode).rootflags &= ~HFSPLUS_FLG_APPEND; |
71 | } | 70 | } |
72 | if (flags & EXT2_FLAG_NODUMP) /* EXT2_NODUMP_FL */ | 71 | if (flags & FS_NODUMP_FL) /* EXT2_NODUMP_FL */ |
73 | HFSPLUS_I(inode).userflags |= HFSPLUS_FLG_NODUMP; | 72 | HFSPLUS_I(inode).userflags |= HFSPLUS_FLG_NODUMP; |
74 | else | 73 | else |
75 | HFSPLUS_I(inode).userflags &= ~HFSPLUS_FLG_NODUMP; | 74 | HFSPLUS_I(inode).userflags &= ~HFSPLUS_FLG_NODUMP; |
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 322e876c35ed..b6bd33ca3731 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -385,13 +385,11 @@ int hostfs_fsync(struct file *file, struct dentry *dentry, int datasync) | |||
385 | 385 | ||
386 | static const struct file_operations hostfs_file_fops = { | 386 | static const struct file_operations hostfs_file_fops = { |
387 | .llseek = generic_file_llseek, | 387 | .llseek = generic_file_llseek, |
388 | .read = generic_file_read, | 388 | .read = do_sync_read, |
389 | .sendfile = generic_file_sendfile, | 389 | .sendfile = generic_file_sendfile, |
390 | .aio_read = generic_file_aio_read, | 390 | .aio_read = generic_file_aio_read, |
391 | .aio_write = generic_file_aio_write, | 391 | .aio_write = generic_file_aio_write, |
392 | .readv = generic_file_readv, | 392 | .write = do_sync_write, |
393 | .writev = generic_file_writev, | ||
394 | .write = generic_file_write, | ||
395 | .mmap = generic_file_mmap, | 393 | .mmap = generic_file_mmap, |
396 | .open = hostfs_file_open, | 394 | .open = hostfs_file_open, |
397 | .release = NULL, | 395 | .release = NULL, |
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c index d9eb19b7b8ae..8b94d24855f0 100644 --- a/fs/hpfs/file.c +++ b/fs/hpfs/file.c | |||
@@ -113,7 +113,7 @@ static ssize_t hpfs_file_write(struct file *file, const char __user *buf, | |||
113 | { | 113 | { |
114 | ssize_t retval; | 114 | ssize_t retval; |
115 | 115 | ||
116 | retval = generic_file_write(file, buf, count, ppos); | 116 | retval = do_sync_write(file, buf, count, ppos); |
117 | if (retval > 0) | 117 | if (retval > 0) |
118 | hpfs_i(file->f_dentry->d_inode)->i_dirty = 1; | 118 | hpfs_i(file->f_dentry->d_inode)->i_dirty = 1; |
119 | return retval; | 119 | return retval; |
@@ -122,8 +122,10 @@ static ssize_t hpfs_file_write(struct file *file, const char __user *buf, | |||
122 | const struct file_operations hpfs_file_ops = | 122 | const struct file_operations hpfs_file_ops = |
123 | { | 123 | { |
124 | .llseek = generic_file_llseek, | 124 | .llseek = generic_file_llseek, |
125 | .read = generic_file_read, | 125 | .read = do_sync_read, |
126 | .aio_read = generic_file_aio_read, | ||
126 | .write = hpfs_file_write, | 127 | .write = hpfs_file_write, |
128 | .aio_write = generic_file_aio_write, | ||
127 | .mmap = generic_file_mmap, | 129 | .mmap = generic_file_mmap, |
128 | .release = hpfs_file_release, | 130 | .release = hpfs_file_release, |
129 | .fsync = hpfs_file_fsync, | 131 | .fsync = hpfs_file_fsync, |
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c index 59e7dc182a0c..2507e7393f3c 100644 --- a/fs/hpfs/namei.c +++ b/fs/hpfs/namei.c | |||
@@ -89,7 +89,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
89 | brelse(bh); | 89 | brelse(bh); |
90 | hpfs_mark_4buffers_dirty(&qbh0); | 90 | hpfs_mark_4buffers_dirty(&qbh0); |
91 | hpfs_brelse4(&qbh0); | 91 | hpfs_brelse4(&qbh0); |
92 | dir->i_nlink++; | 92 | inc_nlink(dir); |
93 | insert_inode_hash(result); | 93 | insert_inode_hash(result); |
94 | 94 | ||
95 | if (result->i_uid != current->fsuid || | 95 | if (result->i_uid != current->fsuid || |
@@ -434,7 +434,7 @@ again: | |||
434 | unlock_kernel(); | 434 | unlock_kernel(); |
435 | return -ENOSPC; | 435 | return -ENOSPC; |
436 | default: | 436 | default: |
437 | inode->i_nlink--; | 437 | drop_nlink(inode); |
438 | err = 0; | 438 | err = 0; |
439 | } | 439 | } |
440 | goto out; | 440 | goto out; |
@@ -494,8 +494,8 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
494 | err = -ENOSPC; | 494 | err = -ENOSPC; |
495 | break; | 495 | break; |
496 | default: | 496 | default: |
497 | dir->i_nlink--; | 497 | drop_nlink(dir); |
498 | inode->i_nlink = 0; | 498 | clear_nlink(inode); |
499 | err = 0; | 499 | err = 0; |
500 | } | 500 | } |
501 | goto out; | 501 | goto out; |
@@ -590,7 +590,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
590 | int r; | 590 | int r; |
591 | if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 1)) != 2) { | 591 | if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 1)) != 2) { |
592 | if ((nde = map_dirent(new_dir, hpfs_i(new_dir)->i_dno, (char *)new_name, new_len, NULL, &qbh1))) { | 592 | if ((nde = map_dirent(new_dir, hpfs_i(new_dir)->i_dno, (char *)new_name, new_len, NULL, &qbh1))) { |
593 | new_inode->i_nlink = 0; | 593 | clear_nlink(new_inode); |
594 | copy_de(nde, &de); | 594 | copy_de(nde, &de); |
595 | memcpy(nde->name, new_name, new_len); | 595 | memcpy(nde->name, new_name, new_len); |
596 | hpfs_mark_4buffers_dirty(&qbh1); | 596 | hpfs_mark_4buffers_dirty(&qbh1); |
@@ -635,8 +635,8 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
635 | end: | 635 | end: |
636 | hpfs_i(i)->i_parent_dir = new_dir->i_ino; | 636 | hpfs_i(i)->i_parent_dir = new_dir->i_ino; |
637 | if (S_ISDIR(i->i_mode)) { | 637 | if (S_ISDIR(i->i_mode)) { |
638 | new_dir->i_nlink++; | 638 | inc_nlink(new_dir); |
639 | old_dir->i_nlink--; | 639 | drop_nlink(old_dir); |
640 | } | 640 | } |
641 | if ((fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) { | 641 | if ((fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) { |
642 | fnode->up = new_dir->i_ino; | 642 | fnode->up = new_dir->i_ino; |
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index e025a31b4c64..5e03b2f67b93 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -229,7 +229,7 @@ static void hugetlbfs_delete_inode(struct inode *inode) | |||
229 | clear_inode(inode); | 229 | clear_inode(inode); |
230 | } | 230 | } |
231 | 231 | ||
232 | static void hugetlbfs_forget_inode(struct inode *inode) | 232 | static void hugetlbfs_forget_inode(struct inode *inode) __releases(inode_lock) |
233 | { | 233 | { |
234 | struct super_block *sb = inode->i_sb; | 234 | struct super_block *sb = inode->i_sb; |
235 | 235 | ||
@@ -377,7 +377,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, | |||
377 | inode->i_fop = &simple_dir_operations; | 377 | inode->i_fop = &simple_dir_operations; |
378 | 378 | ||
379 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | 379 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ |
380 | inode->i_nlink++; | 380 | inc_nlink(inode); |
381 | break; | 381 | break; |
382 | case S_IFLNK: | 382 | case S_IFLNK: |
383 | inode->i_op = &page_symlink_inode_operations; | 383 | inode->i_op = &page_symlink_inode_operations; |
@@ -418,7 +418,7 @@ static int hugetlbfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
418 | { | 418 | { |
419 | int retval = hugetlbfs_mknod(dir, dentry, mode | S_IFDIR, 0); | 419 | int retval = hugetlbfs_mknod(dir, dentry, mode | S_IFDIR, 0); |
420 | if (!retval) | 420 | if (!retval) |
421 | dir->i_nlink++; | 421 | inc_nlink(dir); |
422 | return retval; | 422 | return retval; |
423 | } | 423 | } |
424 | 424 | ||
diff --git a/fs/inode.c b/fs/inode.c index f5c04dd9ae8a..ada7643104e1 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -133,7 +133,6 @@ static struct inode *alloc_inode(struct super_block *sb) | |||
133 | inode->i_bdev = NULL; | 133 | inode->i_bdev = NULL; |
134 | inode->i_cdev = NULL; | 134 | inode->i_cdev = NULL; |
135 | inode->i_rdev = 0; | 135 | inode->i_rdev = 0; |
136 | inode->i_security = NULL; | ||
137 | inode->dirtied_when = 0; | 136 | inode->dirtied_when = 0; |
138 | if (security_inode_alloc(inode)) { | 137 | if (security_inode_alloc(inode)) { |
139 | if (inode->i_sb->s_op->destroy_inode) | 138 | if (inode->i_sb->s_op->destroy_inode) |
@@ -363,27 +362,6 @@ int invalidate_inodes(struct super_block * sb) | |||
363 | } | 362 | } |
364 | 363 | ||
365 | EXPORT_SYMBOL(invalidate_inodes); | 364 | EXPORT_SYMBOL(invalidate_inodes); |
366 | |||
367 | int __invalidate_device(struct block_device *bdev) | ||
368 | { | ||
369 | struct super_block *sb = get_super(bdev); | ||
370 | int res = 0; | ||
371 | |||
372 | if (sb) { | ||
373 | /* | ||
374 | * no need to lock the super, get_super holds the | ||
375 | * read mutex so the filesystem cannot go away | ||
376 | * under us (->put_super runs with the write lock | ||
377 | * hold). | ||
378 | */ | ||
379 | shrink_dcache_sb(sb); | ||
380 | res = invalidate_inodes(sb); | ||
381 | drop_super(sb); | ||
382 | } | ||
383 | invalidate_bdev(bdev, 0); | ||
384 | return res; | ||
385 | } | ||
386 | EXPORT_SYMBOL(__invalidate_device); | ||
387 | 365 | ||
388 | static int can_unuse(struct inode *inode) | 366 | static int can_unuse(struct inode *inode) |
389 | { | 367 | { |
diff --git a/fs/internal.h b/fs/internal.h new file mode 100644 index 000000000000..ea00126c9a59 --- /dev/null +++ b/fs/internal.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /* fs/ internal definitions | ||
2 | * | ||
3 | * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved. | ||
4 | * Written by David Howells (dhowells@redhat.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/ioctl32.h> | ||
13 | |||
14 | struct super_block; | ||
15 | |||
16 | /* | ||
17 | * block_dev.c | ||
18 | */ | ||
19 | #ifdef CONFIG_BLOCK | ||
20 | extern struct super_block *blockdev_superblock; | ||
21 | extern void __init bdev_cache_init(void); | ||
22 | |||
23 | static inline int sb_is_blkdev_sb(struct super_block *sb) | ||
24 | { | ||
25 | return sb == blockdev_superblock; | ||
26 | } | ||
27 | |||
28 | #else | ||
29 | static inline void bdev_cache_init(void) | ||
30 | { | ||
31 | } | ||
32 | |||
33 | static inline int sb_is_blkdev_sb(struct super_block *sb) | ||
34 | { | ||
35 | return 0; | ||
36 | } | ||
37 | #endif | ||
38 | |||
39 | /* | ||
40 | * char_dev.c | ||
41 | */ | ||
42 | extern void __init chrdev_init(void); | ||
43 | |||
44 | /* | ||
45 | * compat_ioctl.c | ||
46 | */ | ||
47 | #ifdef CONFIG_COMPAT | ||
48 | extern struct ioctl_trans ioctl_start[]; | ||
49 | extern int ioctl_table_size; | ||
50 | #endif | ||
51 | |||
52 | /* | ||
53 | * namespace.c | ||
54 | */ | ||
55 | extern int copy_mount_options(const void __user *, unsigned long *); | ||
diff --git a/fs/ioprio.c b/fs/ioprio.c index 78b1deae3fa2..6dc6721d9e82 100644 --- a/fs/ioprio.c +++ b/fs/ioprio.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * fs/ioprio.c | 2 | * fs/ioprio.c |
3 | * | 3 | * |
4 | * Copyright (C) 2004 Jens Axboe <axboe@suse.de> | 4 | * Copyright (C) 2004 Jens Axboe <axboe@kernel.dk> |
5 | * | 5 | * |
6 | * Helper functions for setting/querying io priorities of processes. The | 6 | * Helper functions for setting/querying io priorities of processes. The |
7 | * system calls closely mimmick getpriority/setpriority, see the man page for | 7 | * system calls closely mimmick getpriority/setpriority, see the man page for |
@@ -47,8 +47,8 @@ static int set_task_ioprio(struct task_struct *task, int ioprio) | |||
47 | /* see wmb() in current_io_context() */ | 47 | /* see wmb() in current_io_context() */ |
48 | smp_read_barrier_depends(); | 48 | smp_read_barrier_depends(); |
49 | 49 | ||
50 | if (ioc && ioc->set_ioprio) | 50 | if (ioc) |
51 | ioc->set_ioprio(ioc, ioprio); | 51 | ioc->ioprio_changed = 1; |
52 | 52 | ||
53 | task_unlock(task); | 53 | task_unlock(task); |
54 | return 0; | 54 | return 0; |
@@ -81,7 +81,12 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio) | |||
81 | } | 81 | } |
82 | 82 | ||
83 | ret = -ESRCH; | 83 | ret = -ESRCH; |
84 | read_lock_irq(&tasklist_lock); | 84 | /* |
85 | * We want IOPRIO_WHO_PGRP/IOPRIO_WHO_USER to be "atomic", | ||
86 | * so we can't use rcu_read_lock(). See re-copy of ->ioprio | ||
87 | * in copy_process(). | ||
88 | */ | ||
89 | read_lock(&tasklist_lock); | ||
85 | switch (which) { | 90 | switch (which) { |
86 | case IOPRIO_WHO_PROCESS: | 91 | case IOPRIO_WHO_PROCESS: |
87 | if (!who) | 92 | if (!who) |
@@ -124,7 +129,7 @@ free_uid: | |||
124 | ret = -EINVAL; | 129 | ret = -EINVAL; |
125 | } | 130 | } |
126 | 131 | ||
127 | read_unlock_irq(&tasklist_lock); | 132 | read_unlock(&tasklist_lock); |
128 | return ret; | 133 | return ret; |
129 | } | 134 | } |
130 | 135 | ||
@@ -170,7 +175,7 @@ asmlinkage long sys_ioprio_get(int which, int who) | |||
170 | int ret = -ESRCH; | 175 | int ret = -ESRCH; |
171 | int tmpio; | 176 | int tmpio; |
172 | 177 | ||
173 | read_lock_irq(&tasklist_lock); | 178 | read_lock(&tasklist_lock); |
174 | switch (which) { | 179 | switch (which) { |
175 | case IOPRIO_WHO_PROCESS: | 180 | case IOPRIO_WHO_PROCESS: |
176 | if (!who) | 181 | if (!who) |
@@ -221,7 +226,7 @@ asmlinkage long sys_ioprio_get(int which, int who) | |||
221 | ret = -EINVAL; | 226 | ret = -EINVAL; |
222 | } | 227 | } |
223 | 228 | ||
224 | read_unlock_irq(&tasklist_lock); | 229 | read_unlock(&tasklist_lock); |
225 | return ret; | 230 | return ret; |
226 | } | 231 | } |
227 | 232 | ||
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 4527692f432b..c34b862cdbf2 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c | |||
@@ -960,30 +960,30 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s, | |||
960 | goto abort; | 960 | goto abort; |
961 | } | 961 | } |
962 | 962 | ||
963 | if (nextblk) { | 963 | /* On the last section, nextblk == 0, section size is likely to |
964 | while (b_off >= (offset + sect_size)) { | 964 | * exceed sect_size by a partial block, and access beyond the |
965 | struct inode *ninode; | 965 | * end of the file will reach beyond the section size, too. |
966 | 966 | */ | |
967 | offset += sect_size; | 967 | while (nextblk && (b_off >= (offset + sect_size))) { |
968 | if (nextblk == 0) | 968 | struct inode *ninode; |
969 | goto abort; | 969 | |
970 | ninode = isofs_iget(inode->i_sb, nextblk, nextoff); | 970 | offset += sect_size; |
971 | if (!ninode) | 971 | ninode = isofs_iget(inode->i_sb, nextblk, nextoff); |
972 | goto abort; | 972 | if (!ninode) |
973 | firstext = ISOFS_I(ninode)->i_first_extent; | 973 | goto abort; |
974 | sect_size = ISOFS_I(ninode)->i_section_size >> ISOFS_BUFFER_BITS(ninode); | 974 | firstext = ISOFS_I(ninode)->i_first_extent; |
975 | nextblk = ISOFS_I(ninode)->i_next_section_block; | 975 | sect_size = ISOFS_I(ninode)->i_section_size >> ISOFS_BUFFER_BITS(ninode); |
976 | nextoff = ISOFS_I(ninode)->i_next_section_offset; | 976 | nextblk = ISOFS_I(ninode)->i_next_section_block; |
977 | iput(ninode); | 977 | nextoff = ISOFS_I(ninode)->i_next_section_offset; |
978 | 978 | iput(ninode); | |
979 | if (++section > 100) { | 979 | |
980 | printk("isofs_get_blocks: More than 100 file sections ?!?, aborting...\n"); | 980 | if (++section > 100) { |
981 | printk("isofs_get_blocks: block=%ld firstext=%u sect_size=%u " | 981 | printk("isofs_get_blocks: More than 100 file sections ?!?, aborting...\n"); |
982 | "nextblk=%lu nextoff=%lu\n", | 982 | printk("isofs_get_blocks: block=%ld firstext=%u sect_size=%u " |
983 | iblock, firstext, (unsigned) sect_size, | 983 | "nextblk=%lu nextoff=%lu\n", |
984 | nextblk, nextoff); | 984 | iblock, firstext, (unsigned) sect_size, |
985 | goto abort; | 985 | nextblk, nextoff); |
986 | } | 986 | goto abort; |
987 | } | 987 | } |
988 | } | 988 | } |
989 | 989 | ||
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index 2fc66c3e6681..7af6099c911c 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c | |||
@@ -715,18 +715,8 @@ journal_t * journal_init_dev(struct block_device *bdev, | |||
715 | if (!journal) | 715 | if (!journal) |
716 | return NULL; | 716 | return NULL; |
717 | 717 | ||
718 | journal->j_dev = bdev; | ||
719 | journal->j_fs_dev = fs_dev; | ||
720 | journal->j_blk_offset = start; | ||
721 | journal->j_maxlen = len; | ||
722 | journal->j_blocksize = blocksize; | ||
723 | |||
724 | bh = __getblk(journal->j_dev, start, journal->j_blocksize); | ||
725 | J_ASSERT(bh != NULL); | ||
726 | journal->j_sb_buffer = bh; | ||
727 | journal->j_superblock = (journal_superblock_t *)bh->b_data; | ||
728 | |||
729 | /* journal descriptor can store up to n blocks -bzzz */ | 718 | /* journal descriptor can store up to n blocks -bzzz */ |
719 | journal->j_blocksize = blocksize; | ||
730 | n = journal->j_blocksize / sizeof(journal_block_tag_t); | 720 | n = journal->j_blocksize / sizeof(journal_block_tag_t); |
731 | journal->j_wbufsize = n; | 721 | journal->j_wbufsize = n; |
732 | journal->j_wbuf = kmalloc(n * sizeof(struct buffer_head*), GFP_KERNEL); | 722 | journal->j_wbuf = kmalloc(n * sizeof(struct buffer_head*), GFP_KERNEL); |
@@ -736,6 +726,15 @@ journal_t * journal_init_dev(struct block_device *bdev, | |||
736 | kfree(journal); | 726 | kfree(journal); |
737 | journal = NULL; | 727 | journal = NULL; |
738 | } | 728 | } |
729 | journal->j_dev = bdev; | ||
730 | journal->j_fs_dev = fs_dev; | ||
731 | journal->j_blk_offset = start; | ||
732 | journal->j_maxlen = len; | ||
733 | |||
734 | bh = __getblk(journal->j_dev, start, journal->j_blocksize); | ||
735 | J_ASSERT(bh != NULL); | ||
736 | journal->j_sb_buffer = bh; | ||
737 | journal->j_superblock = (journal_superblock_t *)bh->b_data; | ||
739 | 738 | ||
740 | return journal; | 739 | return journal; |
741 | } | 740 | } |
diff --git a/fs/jbd/recovery.c b/fs/jbd/recovery.c index 445eed6ce5dc..11563fe2a52b 100644 --- a/fs/jbd/recovery.c +++ b/fs/jbd/recovery.c | |||
@@ -46,7 +46,7 @@ static int scan_revoke_records(journal_t *, struct buffer_head *, | |||
46 | #ifdef __KERNEL__ | 46 | #ifdef __KERNEL__ |
47 | 47 | ||
48 | /* Release readahead buffers after use */ | 48 | /* Release readahead buffers after use */ |
49 | void journal_brelse_array(struct buffer_head *b[], int n) | 49 | static void journal_brelse_array(struct buffer_head *b[], int n) |
50 | { | 50 | { |
51 | while (--n >= 0) | 51 | while (--n >= 0) |
52 | brelse (b[n]); | 52 | brelse (b[n]); |
diff --git a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c index f5cf9c93e243..3f7899ea4cba 100644 --- a/fs/jffs/inode-v23.c +++ b/fs/jffs/inode-v23.c | |||
@@ -1052,9 +1052,8 @@ jffs_remove(struct inode *dir, struct dentry *dentry, int type) | |||
1052 | 1052 | ||
1053 | dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; | 1053 | dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; |
1054 | mark_inode_dirty(dir); | 1054 | mark_inode_dirty(dir); |
1055 | inode->i_nlink--; | ||
1056 | inode->i_ctime = dir->i_ctime; | 1055 | inode->i_ctime = dir->i_ctime; |
1057 | mark_inode_dirty(inode); | 1056 | inode_dec_link_count(inode); |
1058 | 1057 | ||
1059 | d_delete(dentry); /* This also frees the inode */ | 1058 | d_delete(dentry); /* This also frees the inode */ |
1060 | 1059 | ||
@@ -1632,8 +1631,10 @@ static const struct file_operations jffs_file_operations = | |||
1632 | { | 1631 | { |
1633 | .open = generic_file_open, | 1632 | .open = generic_file_open, |
1634 | .llseek = generic_file_llseek, | 1633 | .llseek = generic_file_llseek, |
1635 | .read = generic_file_read, | 1634 | .read = do_sync_read, |
1636 | .write = generic_file_write, | 1635 | .aio_read = generic_file_aio_read, |
1636 | .write = do_sync_write, | ||
1637 | .aio_write = generic_file_aio_write, | ||
1637 | .ioctl = jffs_ioctl, | 1638 | .ioctl = jffs_ioctl, |
1638 | .mmap = generic_file_readonly_mmap, | 1639 | .mmap = generic_file_readonly_mmap, |
1639 | .fsync = jffs_fsync, | 1640 | .fsync = jffs_fsync, |
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index edd8371fc6a5..9def6adf4a5d 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c | |||
@@ -588,7 +588,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) | |||
588 | } | 588 | } |
589 | 589 | ||
590 | dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime)); | 590 | dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime)); |
591 | dir_i->i_nlink++; | 591 | inc_nlink(dir_i); |
592 | 592 | ||
593 | jffs2_free_raw_dirent(rd); | 593 | jffs2_free_raw_dirent(rd); |
594 | 594 | ||
@@ -615,7 +615,7 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry) | |||
615 | } | 615 | } |
616 | ret = jffs2_unlink(dir_i, dentry); | 616 | ret = jffs2_unlink(dir_i, dentry); |
617 | if (!ret) | 617 | if (!ret) |
618 | dir_i->i_nlink--; | 618 | drop_nlink(dir_i); |
619 | return ret; | 619 | return ret; |
620 | } | 620 | } |
621 | 621 | ||
@@ -823,7 +823,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
823 | 823 | ||
824 | if (victim_f) { | 824 | if (victim_f) { |
825 | /* There was a victim. Kill it off nicely */ | 825 | /* There was a victim. Kill it off nicely */ |
826 | new_dentry->d_inode->i_nlink--; | 826 | drop_nlink(new_dentry->d_inode); |
827 | /* Don't oops if the victim was a dirent pointing to an | 827 | /* Don't oops if the victim was a dirent pointing to an |
828 | inode which didn't exist. */ | 828 | inode which didn't exist. */ |
829 | if (victim_f->inocache) { | 829 | if (victim_f->inocache) { |
@@ -836,7 +836,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
836 | /* If it was a directory we moved, and there was no victim, | 836 | /* If it was a directory we moved, and there was no victim, |
837 | increase i_nlink on its new parent */ | 837 | increase i_nlink on its new parent */ |
838 | if (S_ISDIR(old_dentry->d_inode->i_mode) && !victim_f) | 838 | if (S_ISDIR(old_dentry->d_inode->i_mode) && !victim_f) |
839 | new_dir_i->i_nlink++; | 839 | inc_nlink(new_dir_i); |
840 | 840 | ||
841 | /* Unlink the original */ | 841 | /* Unlink the original */ |
842 | ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i), | 842 | ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i), |
@@ -848,7 +848,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
848 | /* Oh shit. We really ought to make a single node which can do both atomically */ | 848 | /* Oh shit. We really ought to make a single node which can do both atomically */ |
849 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(old_dentry->d_inode); | 849 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(old_dentry->d_inode); |
850 | down(&f->sem); | 850 | down(&f->sem); |
851 | old_dentry->d_inode->i_nlink++; | 851 | inc_nlink(old_dentry->d_inode); |
852 | if (f->inocache) | 852 | if (f->inocache) |
853 | f->inocache->nlink++; | 853 | f->inocache->nlink++; |
854 | up(&f->sem); | 854 | up(&f->sem); |
@@ -862,7 +862,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
862 | } | 862 | } |
863 | 863 | ||
864 | if (S_ISDIR(old_dentry->d_inode->i_mode)) | 864 | if (S_ISDIR(old_dentry->d_inode->i_mode)) |
865 | old_dir_i->i_nlink--; | 865 | drop_nlink(old_dir_i); |
866 | 866 | ||
867 | new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = ITIME(now); | 867 | new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = ITIME(now); |
868 | 868 | ||
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index 3ed6e3e120b6..242875f77cb3 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c | |||
@@ -42,8 +42,10 @@ const struct file_operations jffs2_file_operations = | |||
42 | { | 42 | { |
43 | .llseek = generic_file_llseek, | 43 | .llseek = generic_file_llseek, |
44 | .open = generic_file_open, | 44 | .open = generic_file_open, |
45 | .read = generic_file_read, | 45 | .read = do_sync_read, |
46 | .write = generic_file_write, | 46 | .aio_read = generic_file_aio_read, |
47 | .write = do_sync_write, | ||
48 | .aio_write = generic_file_aio_write, | ||
47 | .ioctl = jffs2_ioctl, | 49 | .ioctl = jffs2_ioctl, |
48 | .mmap = generic_file_readonly_mmap, | 50 | .mmap = generic_file_readonly_mmap, |
49 | .fsync = jffs2_fsync, | 51 | .fsync = jffs2_fsync, |
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index 72d9909d95ff..7bc1a4201c0c 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c | |||
@@ -277,13 +277,13 @@ void jffs2_read_inode (struct inode *inode) | |||
277 | 277 | ||
278 | for (fd=f->dents; fd; fd = fd->next) { | 278 | for (fd=f->dents; fd; fd = fd->next) { |
279 | if (fd->type == DT_DIR && fd->ino) | 279 | if (fd->type == DT_DIR && fd->ino) |
280 | inode->i_nlink++; | 280 | inc_nlink(inode); |
281 | } | 281 | } |
282 | /* and '..' */ | 282 | /* and '..' */ |
283 | inode->i_nlink++; | 283 | inc_nlink(inode); |
284 | /* Root dir gets i_nlink 3 for some reason */ | 284 | /* Root dir gets i_nlink 3 for some reason */ |
285 | if (inode->i_ino == 1) | 285 | if (inode->i_ino == 1) |
286 | inode->i_nlink++; | 286 | inc_nlink(inode); |
287 | 287 | ||
288 | inode->i_op = &jffs2_dir_inode_operations; | 288 | inode->i_op = &jffs2_dir_inode_operations; |
289 | inode->i_fop = &jffs2_dir_operations; | 289 | inode->i_fop = &jffs2_dir_operations; |
diff --git a/fs/jfs/file.c b/fs/jfs/file.c index 1c9745be5ada..976e90dc2d1b 100644 --- a/fs/jfs/file.c +++ b/fs/jfs/file.c | |||
@@ -103,13 +103,11 @@ struct inode_operations jfs_file_inode_operations = { | |||
103 | const struct file_operations jfs_file_operations = { | 103 | const struct file_operations jfs_file_operations = { |
104 | .open = jfs_open, | 104 | .open = jfs_open, |
105 | .llseek = generic_file_llseek, | 105 | .llseek = generic_file_llseek, |
106 | .write = generic_file_write, | 106 | .write = do_sync_write, |
107 | .read = generic_file_read, | 107 | .read = do_sync_read, |
108 | .aio_read = generic_file_aio_read, | 108 | .aio_read = generic_file_aio_read, |
109 | .aio_write = generic_file_aio_write, | 109 | .aio_write = generic_file_aio_write, |
110 | .mmap = generic_file_mmap, | 110 | .mmap = generic_file_mmap, |
111 | .readv = generic_file_readv, | ||
112 | .writev = generic_file_writev, | ||
113 | .sendfile = generic_file_sendfile, | 111 | .sendfile = generic_file_sendfile, |
114 | .fsync = jfs_fsync, | 112 | .fsync = jfs_fsync, |
115 | .release = jfs_release, | 113 | .release = jfs_release, |
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c index a223cf4faa9b..a8cc169235d9 100644 --- a/fs/jfs/inode.c +++ b/fs/jfs/inode.c | |||
@@ -227,7 +227,7 @@ int jfs_get_block(struct inode *ip, sector_t lblock, | |||
227 | #ifdef _JFS_4K | 227 | #ifdef _JFS_4K |
228 | if ((rc = extHint(ip, lblock64 << ip->i_sb->s_blocksize_bits, &xad))) | 228 | if ((rc = extHint(ip, lblock64 << ip->i_sb->s_blocksize_bits, &xad))) |
229 | goto unlock; | 229 | goto unlock; |
230 | rc = extAlloc(ip, xlen, lblock64, &xad, FALSE); | 230 | rc = extAlloc(ip, xlen, lblock64, &xad, false); |
231 | if (rc) | 231 | if (rc) |
232 | goto unlock; | 232 | goto unlock; |
233 | 233 | ||
diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c index 67b3774820eb..37db52488262 100644 --- a/fs/jfs/ioctl.c +++ b/fs/jfs/ioctl.c | |||
@@ -6,7 +6,6 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <linux/fs.h> | 8 | #include <linux/fs.h> |
9 | #include <linux/ext2_fs.h> | ||
10 | #include <linux/ctype.h> | 9 | #include <linux/ctype.h> |
11 | #include <linux/capability.h> | 10 | #include <linux/capability.h> |
12 | #include <linux/time.h> | 11 | #include <linux/time.h> |
@@ -22,13 +21,13 @@ static struct { | |||
22 | long jfs_flag; | 21 | long jfs_flag; |
23 | long ext2_flag; | 22 | long ext2_flag; |
24 | } jfs_map[] = { | 23 | } jfs_map[] = { |
25 | {JFS_NOATIME_FL, EXT2_NOATIME_FL}, | 24 | {JFS_NOATIME_FL, FS_NOATIME_FL}, |
26 | {JFS_DIRSYNC_FL, EXT2_DIRSYNC_FL}, | 25 | {JFS_DIRSYNC_FL, FS_DIRSYNC_FL}, |
27 | {JFS_SYNC_FL, EXT2_SYNC_FL}, | 26 | {JFS_SYNC_FL, FS_SYNC_FL}, |
28 | {JFS_SECRM_FL, EXT2_SECRM_FL}, | 27 | {JFS_SECRM_FL, FS_SECRM_FL}, |
29 | {JFS_UNRM_FL, EXT2_UNRM_FL}, | 28 | {JFS_UNRM_FL, FS_UNRM_FL}, |
30 | {JFS_APPEND_FL, EXT2_APPEND_FL}, | 29 | {JFS_APPEND_FL, FS_APPEND_FL}, |
31 | {JFS_IMMUTABLE_FL, EXT2_IMMUTABLE_FL}, | 30 | {JFS_IMMUTABLE_FL, FS_IMMUTABLE_FL}, |
32 | {0, 0}, | 31 | {0, 0}, |
33 | }; | 32 | }; |
34 | 33 | ||
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index c161c98954e0..f05ebb629182 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c | |||
@@ -403,8 +403,8 @@ int dbFree(struct inode *ip, s64 blkno, s64 nblocks) | |||
403 | * | 403 | * |
404 | * PARAMETERS: | 404 | * PARAMETERS: |
405 | * ipbmap - pointer to in-core inode for the block map. | 405 | * ipbmap - pointer to in-core inode for the block map. |
406 | * free - TRUE if block range is to be freed from the persistent | 406 | * free - 'true' if block range is to be freed from the persistent |
407 | * map; FALSE if it is to be allocated. | 407 | * map; 'false' if it is to be allocated. |
408 | * blkno - starting block number of the range. | 408 | * blkno - starting block number of the range. |
409 | * nblocks - number of contiguous blocks in the range. | 409 | * nblocks - number of contiguous blocks in the range. |
410 | * tblk - transaction block; | 410 | * tblk - transaction block; |
@@ -2394,7 +2394,7 @@ static int dbFreeBits(struct bmap * bmp, struct dmap * dp, s64 blkno, | |||
2394 | * requires the dmap control page to be adjusted. | 2394 | * requires the dmap control page to be adjusted. |
2395 | * newval - the new value of the lower level dmap or dmap control | 2395 | * newval - the new value of the lower level dmap or dmap control |
2396 | * page root. | 2396 | * page root. |
2397 | * alloc - TRUE if adjustment is due to an allocation. | 2397 | * alloc - 'true' if adjustment is due to an allocation. |
2398 | * level - current level of dmap control page (i.e. L0, L1, L2) to | 2398 | * level - current level of dmap control page (i.e. L0, L1, L2) to |
2399 | * be adjusted. | 2399 | * be adjusted. |
2400 | * | 2400 | * |
@@ -3290,7 +3290,7 @@ int dbExtendFS(struct inode *ipbmap, s64 blkno, s64 nblocks) | |||
3290 | { | 3290 | { |
3291 | struct jfs_sb_info *sbi = JFS_SBI(ipbmap->i_sb); | 3291 | struct jfs_sb_info *sbi = JFS_SBI(ipbmap->i_sb); |
3292 | int nbperpage = sbi->nbperpage; | 3292 | int nbperpage = sbi->nbperpage; |
3293 | int i, i0 = TRUE, j, j0 = TRUE, k, n; | 3293 | int i, i0 = true, j, j0 = true, k, n; |
3294 | s64 newsize; | 3294 | s64 newsize; |
3295 | s64 p; | 3295 | s64 p; |
3296 | struct metapage *mp, *l2mp, *l1mp = NULL, *l0mp = NULL; | 3296 | struct metapage *mp, *l2mp, *l1mp = NULL, *l0mp = NULL; |
@@ -3398,7 +3398,7 @@ int dbExtendFS(struct inode *ipbmap, s64 blkno, s64 nblocks) | |||
3398 | j = (blkno & (MAXL1SIZE - 1)) >> L2MAXL0SIZE; | 3398 | j = (blkno & (MAXL1SIZE - 1)) >> L2MAXL0SIZE; |
3399 | l1leaf = l1dcp->stree + CTLLEAFIND + j; | 3399 | l1leaf = l1dcp->stree + CTLLEAFIND + j; |
3400 | p = BLKTOL0(blkno, sbi->l2nbperpage); | 3400 | p = BLKTOL0(blkno, sbi->l2nbperpage); |
3401 | j0 = FALSE; | 3401 | j0 = false; |
3402 | } else { | 3402 | } else { |
3403 | /* assign/init L1 page */ | 3403 | /* assign/init L1 page */ |
3404 | l1mp = get_metapage(ipbmap, p, PSIZE, 0); | 3404 | l1mp = get_metapage(ipbmap, p, PSIZE, 0); |
@@ -3432,7 +3432,7 @@ int dbExtendFS(struct inode *ipbmap, s64 blkno, s64 nblocks) | |||
3432 | l0leaf = l0dcp->stree + CTLLEAFIND + i; | 3432 | l0leaf = l0dcp->stree + CTLLEAFIND + i; |
3433 | p = BLKTODMAP(blkno, | 3433 | p = BLKTODMAP(blkno, |
3434 | sbi->l2nbperpage); | 3434 | sbi->l2nbperpage); |
3435 | i0 = FALSE; | 3435 | i0 = false; |
3436 | } else { | 3436 | } else { |
3437 | /* assign/init L0 page */ | 3437 | /* assign/init L0 page */ |
3438 | l0mp = get_metapage(ipbmap, p, PSIZE, 0); | 3438 | l0mp = get_metapage(ipbmap, p, PSIZE, 0); |
diff --git a/fs/jfs/jfs_extent.c b/fs/jfs/jfs_extent.c index 4c74f0944f7e..933b7457bfbd 100644 --- a/fs/jfs/jfs_extent.c +++ b/fs/jfs/jfs_extent.c | |||
@@ -74,7 +74,7 @@ static s64 extRoundDown(s64 nb); | |||
74 | * extent that is used as an allocation hint if the | 74 | * extent that is used as an allocation hint if the |
75 | * xaddr of the xad is non-zero. on successful exit, | 75 | * xaddr of the xad is non-zero. on successful exit, |
76 | * the xad describes the newly allocated extent. | 76 | * the xad describes the newly allocated extent. |
77 | * abnr - boolean_t indicating whether the newly allocated extent | 77 | * abnr - bool indicating whether the newly allocated extent |
78 | * should be marked as allocated but not recorded. | 78 | * should be marked as allocated but not recorded. |
79 | * | 79 | * |
80 | * RETURN VALUES: | 80 | * RETURN VALUES: |
@@ -83,7 +83,7 @@ static s64 extRoundDown(s64 nb); | |||
83 | * -ENOSPC - insufficient disk resources. | 83 | * -ENOSPC - insufficient disk resources. |
84 | */ | 84 | */ |
85 | int | 85 | int |
86 | extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, boolean_t abnr) | 86 | extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, bool abnr) |
87 | { | 87 | { |
88 | struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb); | 88 | struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb); |
89 | s64 nxlen, nxaddr, xoff, hint, xaddr = 0; | 89 | s64 nxlen, nxaddr, xoff, hint, xaddr = 0; |
@@ -117,7 +117,7 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, boolean_t abnr) | |||
117 | * following the hint extent. | 117 | * following the hint extent. |
118 | */ | 118 | */ |
119 | if (offsetXAD(xp) + nxlen == xoff && | 119 | if (offsetXAD(xp) + nxlen == xoff && |
120 | abnr == ((xp->flag & XAD_NOTRECORDED) ? TRUE : FALSE)) | 120 | abnr == ((xp->flag & XAD_NOTRECORDED) ? true : false)) |
121 | xaddr = hint + nxlen; | 121 | xaddr = hint + nxlen; |
122 | 122 | ||
123 | /* adjust the hint to the last block of the extent */ | 123 | /* adjust the hint to the last block of the extent */ |
@@ -148,7 +148,7 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, boolean_t abnr) | |||
148 | } | 148 | } |
149 | 149 | ||
150 | /* determine the value of the extent flag */ | 150 | /* determine the value of the extent flag */ |
151 | xflag = (abnr == TRUE) ? XAD_NOTRECORDED : 0; | 151 | xflag = abnr ? XAD_NOTRECORDED : 0; |
152 | 152 | ||
153 | /* if we can extend the hint extent to cover the current request, | 153 | /* if we can extend the hint extent to cover the current request, |
154 | * extend it. otherwise, insert a new extent to | 154 | * extend it. otherwise, insert a new extent to |
@@ -203,7 +203,7 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, boolean_t abnr) | |||
203 | * xlen - request size of the resulting extent. | 203 | * xlen - request size of the resulting extent. |
204 | * xp - pointer to an xad. on successful exit, the xad | 204 | * xp - pointer to an xad. on successful exit, the xad |
205 | * describes the newly allocated extent. | 205 | * describes the newly allocated extent. |
206 | * abnr - boolean_t indicating whether the newly allocated extent | 206 | * abnr - bool indicating whether the newly allocated extent |
207 | * should be marked as allocated but not recorded. | 207 | * should be marked as allocated but not recorded. |
208 | * | 208 | * |
209 | * RETURN VALUES: | 209 | * RETURN VALUES: |
@@ -211,7 +211,7 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, boolean_t abnr) | |||
211 | * -EIO - i/o error. | 211 | * -EIO - i/o error. |
212 | * -ENOSPC - insufficient disk resources. | 212 | * -ENOSPC - insufficient disk resources. |
213 | */ | 213 | */ |
214 | int extRealloc(struct inode *ip, s64 nxlen, xad_t * xp, boolean_t abnr) | 214 | int extRealloc(struct inode *ip, s64 nxlen, xad_t * xp, bool abnr) |
215 | { | 215 | { |
216 | struct super_block *sb = ip->i_sb; | 216 | struct super_block *sb = ip->i_sb; |
217 | s64 xaddr, xlen, nxaddr, delta, xoff; | 217 | s64 xaddr, xlen, nxaddr, delta, xoff; |
@@ -476,7 +476,7 @@ int extFill(struct inode *ip, xad_t * xp) | |||
476 | XADaddress(xp, 0); | 476 | XADaddress(xp, 0); |
477 | 477 | ||
478 | /* allocate an extent to fill the hole */ | 478 | /* allocate an extent to fill the hole */ |
479 | if ((rc = extAlloc(ip, nbperpage, blkno, xp, FALSE))) | 479 | if ((rc = extAlloc(ip, nbperpage, blkno, xp, false))) |
480 | return (rc); | 480 | return (rc); |
481 | 481 | ||
482 | assert(lengthPXD(xp) == nbperpage); | 482 | assert(lengthPXD(xp) == nbperpage); |
diff --git a/fs/jfs/jfs_extent.h b/fs/jfs/jfs_extent.h index e80fc7ced87d..3a7f3f22e989 100644 --- a/fs/jfs/jfs_extent.h +++ b/fs/jfs/jfs_extent.h | |||
@@ -22,10 +22,10 @@ | |||
22 | #define INOHINT(ip) \ | 22 | #define INOHINT(ip) \ |
23 | (addressPXD(&(JFS_IP(ip)->ixpxd)) + lengthPXD(&(JFS_IP(ip)->ixpxd)) - 1) | 23 | (addressPXD(&(JFS_IP(ip)->ixpxd)) + lengthPXD(&(JFS_IP(ip)->ixpxd)) - 1) |
24 | 24 | ||
25 | extern int extAlloc(struct inode *, s64, s64, xad_t *, boolean_t); | 25 | extern int extAlloc(struct inode *, s64, s64, xad_t *, bool); |
26 | extern int extFill(struct inode *, xad_t *); | 26 | extern int extFill(struct inode *, xad_t *); |
27 | extern int extHint(struct inode *, s64, xad_t *); | 27 | extern int extHint(struct inode *, s64, xad_t *); |
28 | extern int extRealloc(struct inode *, s64, xad_t *, boolean_t); | 28 | extern int extRealloc(struct inode *, s64, xad_t *, bool); |
29 | extern int extRecord(struct inode *, xad_t *); | 29 | extern int extRecord(struct inode *, xad_t *); |
30 | 30 | ||
31 | #endif /* _H_JFS_EXTENT */ | 31 | #endif /* _H_JFS_EXTENT */ |
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index 369d7f39c040..a45ee2489580 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c | |||
@@ -78,8 +78,8 @@ static HLIST_HEAD(aggregate_hash); | |||
78 | /* | 78 | /* |
79 | * forward references | 79 | * forward references |
80 | */ | 80 | */ |
81 | static int diAllocAG(struct inomap *, int, boolean_t, struct inode *); | 81 | static int diAllocAG(struct inomap *, int, bool, struct inode *); |
82 | static int diAllocAny(struct inomap *, int, boolean_t, struct inode *); | 82 | static int diAllocAny(struct inomap *, int, bool, struct inode *); |
83 | static int diAllocBit(struct inomap *, struct iag *, int); | 83 | static int diAllocBit(struct inomap *, struct iag *, int); |
84 | static int diAllocExt(struct inomap *, int, struct inode *); | 84 | static int diAllocExt(struct inomap *, int, struct inode *); |
85 | static int diAllocIno(struct inomap *, int, struct inode *); | 85 | static int diAllocIno(struct inomap *, int, struct inode *); |
@@ -1345,7 +1345,7 @@ diInitInode(struct inode *ip, int iagno, int ino, int extno, struct iag * iagp) | |||
1345 | * | 1345 | * |
1346 | * PARAMETERS: | 1346 | * PARAMETERS: |
1347 | * pip - pointer to incore inode for the parent inode. | 1347 | * pip - pointer to incore inode for the parent inode. |
1348 | * dir - TRUE if the new disk inode is for a directory. | 1348 | * dir - 'true' if the new disk inode is for a directory. |
1349 | * ip - pointer to a new inode | 1349 | * ip - pointer to a new inode |
1350 | * | 1350 | * |
1351 | * RETURN VALUES: | 1351 | * RETURN VALUES: |
@@ -1353,7 +1353,7 @@ diInitInode(struct inode *ip, int iagno, int ino, int extno, struct iag * iagp) | |||
1353 | * -ENOSPC - insufficient disk resources. | 1353 | * -ENOSPC - insufficient disk resources. |
1354 | * -EIO - i/o error. | 1354 | * -EIO - i/o error. |
1355 | */ | 1355 | */ |
1356 | int diAlloc(struct inode *pip, boolean_t dir, struct inode *ip) | 1356 | int diAlloc(struct inode *pip, bool dir, struct inode *ip) |
1357 | { | 1357 | { |
1358 | int rc, ino, iagno, addext, extno, bitno, sword; | 1358 | int rc, ino, iagno, addext, extno, bitno, sword; |
1359 | int nwords, rem, i, agno; | 1359 | int nwords, rem, i, agno; |
@@ -1375,7 +1375,7 @@ int diAlloc(struct inode *pip, boolean_t dir, struct inode *ip) | |||
1375 | /* for a directory, the allocation policy is to start | 1375 | /* for a directory, the allocation policy is to start |
1376 | * at the ag level using the preferred ag. | 1376 | * at the ag level using the preferred ag. |
1377 | */ | 1377 | */ |
1378 | if (dir == TRUE) { | 1378 | if (dir) { |
1379 | agno = dbNextAG(JFS_SBI(pip->i_sb)->ipbmap); | 1379 | agno = dbNextAG(JFS_SBI(pip->i_sb)->ipbmap); |
1380 | AG_LOCK(imap, agno); | 1380 | AG_LOCK(imap, agno); |
1381 | goto tryag; | 1381 | goto tryag; |
@@ -1651,7 +1651,7 @@ int diAlloc(struct inode *pip, boolean_t dir, struct inode *ip) | |||
1651 | * PARAMETERS: | 1651 | * PARAMETERS: |
1652 | * imap - pointer to inode map control structure. | 1652 | * imap - pointer to inode map control structure. |
1653 | * agno - allocation group to allocate from. | 1653 | * agno - allocation group to allocate from. |
1654 | * dir - TRUE if the new disk inode is for a directory. | 1654 | * dir - 'true' if the new disk inode is for a directory. |
1655 | * ip - pointer to the new inode to be filled in on successful return | 1655 | * ip - pointer to the new inode to be filled in on successful return |
1656 | * with the disk inode number allocated, its extent address | 1656 | * with the disk inode number allocated, its extent address |
1657 | * and the start of the ag. | 1657 | * and the start of the ag. |
@@ -1662,7 +1662,7 @@ int diAlloc(struct inode *pip, boolean_t dir, struct inode *ip) | |||
1662 | * -EIO - i/o error. | 1662 | * -EIO - i/o error. |
1663 | */ | 1663 | */ |
1664 | static int | 1664 | static int |
1665 | diAllocAG(struct inomap * imap, int agno, boolean_t dir, struct inode *ip) | 1665 | diAllocAG(struct inomap * imap, int agno, bool dir, struct inode *ip) |
1666 | { | 1666 | { |
1667 | int rc, addext, numfree, numinos; | 1667 | int rc, addext, numfree, numinos; |
1668 | 1668 | ||
@@ -1682,7 +1682,7 @@ diAllocAG(struct inomap * imap, int agno, boolean_t dir, struct inode *ip) | |||
1682 | * if there are a small number of free inodes or number of free | 1682 | * if there are a small number of free inodes or number of free |
1683 | * inodes is a small percentage of the number of backed inodes. | 1683 | * inodes is a small percentage of the number of backed inodes. |
1684 | */ | 1684 | */ |
1685 | if (dir == TRUE) | 1685 | if (dir) |
1686 | addext = (numfree < 64 || | 1686 | addext = (numfree < 64 || |
1687 | (numfree < 256 | 1687 | (numfree < 256 |
1688 | && ((numfree * 100) / numinos) <= 20)); | 1688 | && ((numfree * 100) / numinos) <= 20)); |
@@ -1721,7 +1721,7 @@ diAllocAG(struct inomap * imap, int agno, boolean_t dir, struct inode *ip) | |||
1721 | * PARAMETERS: | 1721 | * PARAMETERS: |
1722 | * imap - pointer to inode map control structure. | 1722 | * imap - pointer to inode map control structure. |
1723 | * agno - primary allocation group (to avoid). | 1723 | * agno - primary allocation group (to avoid). |
1724 | * dir - TRUE if the new disk inode is for a directory. | 1724 | * dir - 'true' if the new disk inode is for a directory. |
1725 | * ip - pointer to a new inode to be filled in on successful return | 1725 | * ip - pointer to a new inode to be filled in on successful return |
1726 | * with the disk inode number allocated, its extent address | 1726 | * with the disk inode number allocated, its extent address |
1727 | * and the start of the ag. | 1727 | * and the start of the ag. |
@@ -1732,7 +1732,7 @@ diAllocAG(struct inomap * imap, int agno, boolean_t dir, struct inode *ip) | |||
1732 | * -EIO - i/o error. | 1732 | * -EIO - i/o error. |
1733 | */ | 1733 | */ |
1734 | static int | 1734 | static int |
1735 | diAllocAny(struct inomap * imap, int agno, boolean_t dir, struct inode *ip) | 1735 | diAllocAny(struct inomap * imap, int agno, bool dir, struct inode *ip) |
1736 | { | 1736 | { |
1737 | int ag, rc; | 1737 | int ag, rc; |
1738 | int maxag = JFS_SBI(imap->im_ipimap->i_sb)->bmap->db_maxag; | 1738 | int maxag = JFS_SBI(imap->im_ipimap->i_sb)->bmap->db_maxag; |
@@ -2749,7 +2749,7 @@ static int diFindFree(u32 word, int start) | |||
2749 | * PARAMETERS: | 2749 | * PARAMETERS: |
2750 | * ipimap - Incore inode map inode | 2750 | * ipimap - Incore inode map inode |
2751 | * inum - Number of inode to mark in permanent map | 2751 | * inum - Number of inode to mark in permanent map |
2752 | * is_free - If TRUE indicates inode should be marked freed, otherwise | 2752 | * is_free - If 'true' indicates inode should be marked freed, otherwise |
2753 | * indicates inode should be marked allocated. | 2753 | * indicates inode should be marked allocated. |
2754 | * | 2754 | * |
2755 | * RETURN VALUES: | 2755 | * RETURN VALUES: |
@@ -2757,7 +2757,7 @@ static int diFindFree(u32 word, int start) | |||
2757 | */ | 2757 | */ |
2758 | int | 2758 | int |
2759 | diUpdatePMap(struct inode *ipimap, | 2759 | diUpdatePMap(struct inode *ipimap, |
2760 | unsigned long inum, boolean_t is_free, struct tblock * tblk) | 2760 | unsigned long inum, bool is_free, struct tblock * tblk) |
2761 | { | 2761 | { |
2762 | int rc; | 2762 | int rc; |
2763 | struct iag *iagp; | 2763 | struct iag *iagp; |
@@ -2796,7 +2796,7 @@ diUpdatePMap(struct inode *ipimap, | |||
2796 | /* | 2796 | /* |
2797 | * mark the inode free in persistent map: | 2797 | * mark the inode free in persistent map: |
2798 | */ | 2798 | */ |
2799 | if (is_free == TRUE) { | 2799 | if (is_free) { |
2800 | /* The inode should have been allocated both in working | 2800 | /* The inode should have been allocated both in working |
2801 | * map and in persistent map; | 2801 | * map and in persistent map; |
2802 | * the inode will be freed from working map at the release | 2802 | * the inode will be freed from working map at the release |
diff --git a/fs/jfs/jfs_imap.h b/fs/jfs/jfs_imap.h index 6e24465f0f98..e3b7db47db6b 100644 --- a/fs/jfs/jfs_imap.h +++ b/fs/jfs/jfs_imap.h | |||
@@ -159,11 +159,11 @@ struct inomap { | |||
159 | #define im_maxag im_imap.in_maxag | 159 | #define im_maxag im_imap.in_maxag |
160 | 160 | ||
161 | extern int diFree(struct inode *); | 161 | extern int diFree(struct inode *); |
162 | extern int diAlloc(struct inode *, boolean_t, struct inode *); | 162 | extern int diAlloc(struct inode *, bool, struct inode *); |
163 | extern int diSync(struct inode *); | 163 | extern int diSync(struct inode *); |
164 | /* external references */ | 164 | /* external references */ |
165 | extern int diUpdatePMap(struct inode *ipimap, unsigned long inum, | 165 | extern int diUpdatePMap(struct inode *ipimap, unsigned long inum, |
166 | boolean_t is_free, struct tblock * tblk); | 166 | bool is_free, struct tblock * tblk); |
167 | extern int diExtendFS(struct inode *ipimap, struct inode *ipbmap); | 167 | extern int diExtendFS(struct inode *ipimap, struct inode *ipbmap); |
168 | extern int diMount(struct inode *); | 168 | extern int diMount(struct inode *); |
169 | extern int diUnmount(struct inode *, int); | 169 | extern int diUnmount(struct inode *, int); |
diff --git a/fs/jfs/jfs_metapage.h b/fs/jfs/jfs_metapage.h index d17a3290f5aa..01a5a455e012 100644 --- a/fs/jfs/jfs_metapage.h +++ b/fs/jfs/jfs_metapage.h | |||
@@ -65,10 +65,10 @@ extern struct metapage *__get_metapage(struct inode *inode, | |||
65 | int absolute, unsigned long new); | 65 | int absolute, unsigned long new); |
66 | 66 | ||
67 | #define read_metapage(inode, lblock, size, absolute)\ | 67 | #define read_metapage(inode, lblock, size, absolute)\ |
68 | __get_metapage(inode, lblock, size, absolute, FALSE) | 68 | __get_metapage(inode, lblock, size, absolute, false) |
69 | 69 | ||
70 | #define get_metapage(inode, lblock, size, absolute)\ | 70 | #define get_metapage(inode, lblock, size, absolute)\ |
71 | __get_metapage(inode, lblock, size, absolute, TRUE) | 71 | __get_metapage(inode, lblock, size, absolute, true) |
72 | 72 | ||
73 | extern void release_metapage(struct metapage *); | 73 | extern void release_metapage(struct metapage *); |
74 | extern void grab_metapage(struct metapage *); | 74 | extern void grab_metapage(struct metapage *); |
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c index 3856efc399c1..ebfa6c061d78 100644 --- a/fs/jfs/jfs_txnmgr.c +++ b/fs/jfs/jfs_txnmgr.c | |||
@@ -2393,7 +2393,7 @@ static void txUpdateMap(struct tblock * tblk) | |||
2393 | * unlock mapper/write lock | 2393 | * unlock mapper/write lock |
2394 | */ | 2394 | */ |
2395 | if (tblk->xflag & COMMIT_CREATE) { | 2395 | if (tblk->xflag & COMMIT_CREATE) { |
2396 | diUpdatePMap(ipimap, tblk->ino, FALSE, tblk); | 2396 | diUpdatePMap(ipimap, tblk->ino, false, tblk); |
2397 | /* update persistent block allocation map | 2397 | /* update persistent block allocation map |
2398 | * for the allocation of inode extent; | 2398 | * for the allocation of inode extent; |
2399 | */ | 2399 | */ |
@@ -2403,7 +2403,7 @@ static void txUpdateMap(struct tblock * tblk) | |||
2403 | txAllocPMap(ipimap, (struct maplock *) & pxdlock, tblk); | 2403 | txAllocPMap(ipimap, (struct maplock *) & pxdlock, tblk); |
2404 | } else if (tblk->xflag & COMMIT_DELETE) { | 2404 | } else if (tblk->xflag & COMMIT_DELETE) { |
2405 | ip = tblk->u.ip; | 2405 | ip = tblk->u.ip; |
2406 | diUpdatePMap(ipimap, ip->i_ino, TRUE, tblk); | 2406 | diUpdatePMap(ipimap, ip->i_ino, true, tblk); |
2407 | iput(ip); | 2407 | iput(ip); |
2408 | } | 2408 | } |
2409 | } | 2409 | } |
@@ -2451,7 +2451,7 @@ static void txAllocPMap(struct inode *ip, struct maplock * maplock, | |||
2451 | if (xad->flag & (XAD_NEW | XAD_EXTENDED)) { | 2451 | if (xad->flag & (XAD_NEW | XAD_EXTENDED)) { |
2452 | xaddr = addressXAD(xad); | 2452 | xaddr = addressXAD(xad); |
2453 | xlen = lengthXAD(xad); | 2453 | xlen = lengthXAD(xad); |
2454 | dbUpdatePMap(ipbmap, FALSE, xaddr, | 2454 | dbUpdatePMap(ipbmap, false, xaddr, |
2455 | (s64) xlen, tblk); | 2455 | (s64) xlen, tblk); |
2456 | xad->flag &= ~(XAD_NEW | XAD_EXTENDED); | 2456 | xad->flag &= ~(XAD_NEW | XAD_EXTENDED); |
2457 | jfs_info("allocPMap: xaddr:0x%lx xlen:%d", | 2457 | jfs_info("allocPMap: xaddr:0x%lx xlen:%d", |
@@ -2462,7 +2462,7 @@ static void txAllocPMap(struct inode *ip, struct maplock * maplock, | |||
2462 | pxdlock = (struct pxd_lock *) maplock; | 2462 | pxdlock = (struct pxd_lock *) maplock; |
2463 | xaddr = addressPXD(&pxdlock->pxd); | 2463 | xaddr = addressPXD(&pxdlock->pxd); |
2464 | xlen = lengthPXD(&pxdlock->pxd); | 2464 | xlen = lengthPXD(&pxdlock->pxd); |
2465 | dbUpdatePMap(ipbmap, FALSE, xaddr, (s64) xlen, tblk); | 2465 | dbUpdatePMap(ipbmap, false, xaddr, (s64) xlen, tblk); |
2466 | jfs_info("allocPMap: xaddr:0x%lx xlen:%d", (ulong) xaddr, xlen); | 2466 | jfs_info("allocPMap: xaddr:0x%lx xlen:%d", (ulong) xaddr, xlen); |
2467 | } else { /* (maplock->flag & mlckALLOCPXDLIST) */ | 2467 | } else { /* (maplock->flag & mlckALLOCPXDLIST) */ |
2468 | 2468 | ||
@@ -2471,7 +2471,7 @@ static void txAllocPMap(struct inode *ip, struct maplock * maplock, | |||
2471 | for (n = 0; n < pxdlistlock->count; n++, pxd++) { | 2471 | for (n = 0; n < pxdlistlock->count; n++, pxd++) { |
2472 | xaddr = addressPXD(pxd); | 2472 | xaddr = addressPXD(pxd); |
2473 | xlen = lengthPXD(pxd); | 2473 | xlen = lengthPXD(pxd); |
2474 | dbUpdatePMap(ipbmap, FALSE, xaddr, (s64) xlen, | 2474 | dbUpdatePMap(ipbmap, false, xaddr, (s64) xlen, |
2475 | tblk); | 2475 | tblk); |
2476 | jfs_info("allocPMap: xaddr:0x%lx xlen:%d", | 2476 | jfs_info("allocPMap: xaddr:0x%lx xlen:%d", |
2477 | (ulong) xaddr, xlen); | 2477 | (ulong) xaddr, xlen); |
@@ -2513,7 +2513,7 @@ void txFreeMap(struct inode *ip, | |||
2513 | if (!(xad->flag & XAD_NEW)) { | 2513 | if (!(xad->flag & XAD_NEW)) { |
2514 | xaddr = addressXAD(xad); | 2514 | xaddr = addressXAD(xad); |
2515 | xlen = lengthXAD(xad); | 2515 | xlen = lengthXAD(xad); |
2516 | dbUpdatePMap(ipbmap, TRUE, xaddr, | 2516 | dbUpdatePMap(ipbmap, true, xaddr, |
2517 | (s64) xlen, tblk); | 2517 | (s64) xlen, tblk); |
2518 | jfs_info("freePMap: xaddr:0x%lx " | 2518 | jfs_info("freePMap: xaddr:0x%lx " |
2519 | "xlen:%d", | 2519 | "xlen:%d", |
@@ -2524,7 +2524,7 @@ void txFreeMap(struct inode *ip, | |||
2524 | pxdlock = (struct pxd_lock *) maplock; | 2524 | pxdlock = (struct pxd_lock *) maplock; |
2525 | xaddr = addressPXD(&pxdlock->pxd); | 2525 | xaddr = addressPXD(&pxdlock->pxd); |
2526 | xlen = lengthPXD(&pxdlock->pxd); | 2526 | xlen = lengthPXD(&pxdlock->pxd); |
2527 | dbUpdatePMap(ipbmap, TRUE, xaddr, (s64) xlen, | 2527 | dbUpdatePMap(ipbmap, true, xaddr, (s64) xlen, |
2528 | tblk); | 2528 | tblk); |
2529 | jfs_info("freePMap: xaddr:0x%lx xlen:%d", | 2529 | jfs_info("freePMap: xaddr:0x%lx xlen:%d", |
2530 | (ulong) xaddr, xlen); | 2530 | (ulong) xaddr, xlen); |
@@ -2535,7 +2535,7 @@ void txFreeMap(struct inode *ip, | |||
2535 | for (n = 0; n < pxdlistlock->count; n++, pxd++) { | 2535 | for (n = 0; n < pxdlistlock->count; n++, pxd++) { |
2536 | xaddr = addressPXD(pxd); | 2536 | xaddr = addressPXD(pxd); |
2537 | xlen = lengthPXD(pxd); | 2537 | xlen = lengthPXD(pxd); |
2538 | dbUpdatePMap(ipbmap, TRUE, xaddr, | 2538 | dbUpdatePMap(ipbmap, true, xaddr, |
2539 | (s64) xlen, tblk); | 2539 | (s64) xlen, tblk); |
2540 | jfs_info("freePMap: xaddr:0x%lx xlen:%d", | 2540 | jfs_info("freePMap: xaddr:0x%lx xlen:%d", |
2541 | (ulong) xaddr, xlen); | 2541 | (ulong) xaddr, xlen); |
diff --git a/fs/jfs/jfs_types.h b/fs/jfs/jfs_types.h index 5bfad39a2078..09b252958687 100644 --- a/fs/jfs/jfs_types.h +++ b/fs/jfs/jfs_types.h | |||
@@ -57,10 +57,6 @@ struct timestruc_t { | |||
57 | #define HIGHORDER 0x80000000u /* high order bit on */ | 57 | #define HIGHORDER 0x80000000u /* high order bit on */ |
58 | #define ONES 0xffffffffu /* all bit on */ | 58 | #define ONES 0xffffffffu /* all bit on */ |
59 | 59 | ||
60 | typedef int boolean_t; | ||
61 | #define TRUE 1 | ||
62 | #define FALSE 0 | ||
63 | |||
64 | /* | 60 | /* |
65 | * logical xd (lxd) | 61 | * logical xd (lxd) |
66 | */ | 62 | */ |
diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c index e72f4ebb6e9c..c92307d3a57e 100644 --- a/fs/jfs/jfs_xtree.c +++ b/fs/jfs/jfs_xtree.c | |||
@@ -2964,7 +2964,7 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ | |||
2964 | cmSetXD(ip, cp, pno, dxaddr, nblks); | 2964 | cmSetXD(ip, cp, pno, dxaddr, nblks); |
2965 | 2965 | ||
2966 | /* release the cbuf, mark it as modified */ | 2966 | /* release the cbuf, mark it as modified */ |
2967 | cmPut(cp, TRUE); | 2967 | cmPut(cp, true); |
2968 | 2968 | ||
2969 | dxaddr += nblks; | 2969 | dxaddr += nblks; |
2970 | sxaddr += nblks; | 2970 | sxaddr += nblks; |
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 295268ad231b..b8d16a6aa88f 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c | |||
@@ -292,7 +292,7 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) | |||
292 | mark_inode_dirty(ip); | 292 | mark_inode_dirty(ip); |
293 | 293 | ||
294 | /* update parent directory inode */ | 294 | /* update parent directory inode */ |
295 | dip->i_nlink++; /* for '..' from child directory */ | 295 | inc_nlink(dip); /* for '..' from child directory */ |
296 | dip->i_ctime = dip->i_mtime = CURRENT_TIME; | 296 | dip->i_ctime = dip->i_mtime = CURRENT_TIME; |
297 | mark_inode_dirty(dip); | 297 | mark_inode_dirty(dip); |
298 | 298 | ||
@@ -393,9 +393,8 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry) | |||
393 | /* update parent directory's link count corresponding | 393 | /* update parent directory's link count corresponding |
394 | * to ".." entry of the target directory deleted | 394 | * to ".." entry of the target directory deleted |
395 | */ | 395 | */ |
396 | dip->i_nlink--; | ||
397 | dip->i_ctime = dip->i_mtime = CURRENT_TIME; | 396 | dip->i_ctime = dip->i_mtime = CURRENT_TIME; |
398 | mark_inode_dirty(dip); | 397 | inode_dec_link_count(dip); |
399 | 398 | ||
400 | /* | 399 | /* |
401 | * OS/2 could have created EA and/or ACL | 400 | * OS/2 could have created EA and/or ACL |
@@ -415,7 +414,7 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry) | |||
415 | JFS_IP(ip)->acl.flag = 0; | 414 | JFS_IP(ip)->acl.flag = 0; |
416 | 415 | ||
417 | /* mark the target directory as deleted */ | 416 | /* mark the target directory as deleted */ |
418 | ip->i_nlink = 0; | 417 | clear_nlink(ip); |
419 | mark_inode_dirty(ip); | 418 | mark_inode_dirty(ip); |
420 | 419 | ||
421 | rc = txCommit(tid, 2, &iplist[0], 0); | 420 | rc = txCommit(tid, 2, &iplist[0], 0); |
@@ -515,8 +514,7 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry) | |||
515 | mark_inode_dirty(dip); | 514 | mark_inode_dirty(dip); |
516 | 515 | ||
517 | /* update target's inode */ | 516 | /* update target's inode */ |
518 | ip->i_nlink--; | 517 | inode_dec_link_count(ip); |
519 | mark_inode_dirty(ip); | ||
520 | 518 | ||
521 | /* | 519 | /* |
522 | * commit zero link count object | 520 | * commit zero link count object |
@@ -824,7 +822,7 @@ static int jfs_link(struct dentry *old_dentry, | |||
824 | goto free_dname; | 822 | goto free_dname; |
825 | 823 | ||
826 | /* update object inode */ | 824 | /* update object inode */ |
827 | ip->i_nlink++; /* for new link */ | 825 | inc_nlink(ip); /* for new link */ |
828 | ip->i_ctime = CURRENT_TIME; | 826 | ip->i_ctime = CURRENT_TIME; |
829 | dir->i_ctime = dir->i_mtime = CURRENT_TIME; | 827 | dir->i_ctime = dir->i_mtime = CURRENT_TIME; |
830 | mark_inode_dirty(dir); | 828 | mark_inode_dirty(dir); |
@@ -835,7 +833,7 @@ static int jfs_link(struct dentry *old_dentry, | |||
835 | rc = txCommit(tid, 2, &iplist[0], 0); | 833 | rc = txCommit(tid, 2, &iplist[0], 0); |
836 | 834 | ||
837 | if (rc) { | 835 | if (rc) { |
838 | ip->i_nlink--; | 836 | ip->i_nlink--; /* never instantiated */ |
839 | iput(ip); | 837 | iput(ip); |
840 | } else | 838 | } else |
841 | d_instantiate(dentry, ip); | 839 | d_instantiate(dentry, ip); |
@@ -1155,9 +1153,9 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1155 | old_ip->i_ino, JFS_RENAME); | 1153 | old_ip->i_ino, JFS_RENAME); |
1156 | if (rc) | 1154 | if (rc) |
1157 | goto out4; | 1155 | goto out4; |
1158 | new_ip->i_nlink--; | 1156 | drop_nlink(new_ip); |
1159 | if (S_ISDIR(new_ip->i_mode)) { | 1157 | if (S_ISDIR(new_ip->i_mode)) { |
1160 | new_ip->i_nlink--; | 1158 | drop_nlink(new_ip); |
1161 | if (new_ip->i_nlink) { | 1159 | if (new_ip->i_nlink) { |
1162 | mutex_unlock(&JFS_IP(new_ip)->commit_mutex); | 1160 | mutex_unlock(&JFS_IP(new_ip)->commit_mutex); |
1163 | if (old_dir != new_dir) | 1161 | if (old_dir != new_dir) |
@@ -1208,7 +1206,7 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1208 | goto out4; | 1206 | goto out4; |
1209 | } | 1207 | } |
1210 | if (S_ISDIR(old_ip->i_mode)) | 1208 | if (S_ISDIR(old_ip->i_mode)) |
1211 | new_dir->i_nlink++; | 1209 | inc_nlink(new_dir); |
1212 | } | 1210 | } |
1213 | /* | 1211 | /* |
1214 | * Remove old directory entry | 1212 | * Remove old directory entry |
@@ -1223,7 +1221,7 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1223 | goto out4; | 1221 | goto out4; |
1224 | } | 1222 | } |
1225 | if (S_ISDIR(old_ip->i_mode)) { | 1223 | if (S_ISDIR(old_ip->i_mode)) { |
1226 | old_dir->i_nlink--; | 1224 | drop_nlink(old_dir); |
1227 | if (old_dir != new_dir) { | 1225 | if (old_dir != new_dir) { |
1228 | /* | 1226 | /* |
1229 | * Change inode number of parent for moved directory | 1227 | * Change inode number of parent for moved directory |
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c index 9bc5b7c055ce..7a10e1928961 100644 --- a/fs/jfs/xattr.c +++ b/fs/jfs/xattr.c | |||
@@ -97,26 +97,26 @@ static inline int is_os2_xattr(struct jfs_ea *ea) | |||
97 | */ | 97 | */ |
98 | if ((ea->namelen >= XATTR_SYSTEM_PREFIX_LEN) && | 98 | if ((ea->namelen >= XATTR_SYSTEM_PREFIX_LEN) && |
99 | !strncmp(ea->name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) | 99 | !strncmp(ea->name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) |
100 | return FALSE; | 100 | return false; |
101 | /* | 101 | /* |
102 | * Check for "user." | 102 | * Check for "user." |
103 | */ | 103 | */ |
104 | if ((ea->namelen >= XATTR_USER_PREFIX_LEN) && | 104 | if ((ea->namelen >= XATTR_USER_PREFIX_LEN) && |
105 | !strncmp(ea->name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) | 105 | !strncmp(ea->name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) |
106 | return FALSE; | 106 | return false; |
107 | /* | 107 | /* |
108 | * Check for "security." | 108 | * Check for "security." |
109 | */ | 109 | */ |
110 | if ((ea->namelen >= XATTR_SECURITY_PREFIX_LEN) && | 110 | if ((ea->namelen >= XATTR_SECURITY_PREFIX_LEN) && |
111 | !strncmp(ea->name, XATTR_SECURITY_PREFIX, | 111 | !strncmp(ea->name, XATTR_SECURITY_PREFIX, |
112 | XATTR_SECURITY_PREFIX_LEN)) | 112 | XATTR_SECURITY_PREFIX_LEN)) |
113 | return FALSE; | 113 | return false; |
114 | /* | 114 | /* |
115 | * Check for "trusted." | 115 | * Check for "trusted." |
116 | */ | 116 | */ |
117 | if ((ea->namelen >= XATTR_TRUSTED_PREFIX_LEN) && | 117 | if ((ea->namelen >= XATTR_TRUSTED_PREFIX_LEN) && |
118 | !strncmp(ea->name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) | 118 | !strncmp(ea->name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) |
119 | return FALSE; | 119 | return false; |
120 | /* | 120 | /* |
121 | * Add any other valid namespace prefixes here | 121 | * Add any other valid namespace prefixes here |
122 | */ | 122 | */ |
@@ -124,7 +124,7 @@ static inline int is_os2_xattr(struct jfs_ea *ea) | |||
124 | /* | 124 | /* |
125 | * We assume it's OS/2's flat namespace | 125 | * We assume it's OS/2's flat namespace |
126 | */ | 126 | */ |
127 | return TRUE; | 127 | return true; |
128 | } | 128 | } |
129 | 129 | ||
130 | static inline int name_size(struct jfs_ea *ea) | 130 | static inline int name_size(struct jfs_ea *ea) |
diff --git a/fs/libfs.c b/fs/libfs.c index 8db5afb7b0a7..bd08e0e64a8c 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -243,7 +243,7 @@ int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *den | |||
243 | struct inode *inode = old_dentry->d_inode; | 243 | struct inode *inode = old_dentry->d_inode; |
244 | 244 | ||
245 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; | 245 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; |
246 | inode->i_nlink++; | 246 | inc_nlink(inode); |
247 | atomic_inc(&inode->i_count); | 247 | atomic_inc(&inode->i_count); |
248 | dget(dentry); | 248 | dget(dentry); |
249 | d_instantiate(dentry, inode); | 249 | d_instantiate(dentry, inode); |
@@ -275,7 +275,7 @@ int simple_unlink(struct inode *dir, struct dentry *dentry) | |||
275 | struct inode *inode = dentry->d_inode; | 275 | struct inode *inode = dentry->d_inode; |
276 | 276 | ||
277 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; | 277 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; |
278 | inode->i_nlink--; | 278 | drop_nlink(inode); |
279 | dput(dentry); | 279 | dput(dentry); |
280 | return 0; | 280 | return 0; |
281 | } | 281 | } |
@@ -285,9 +285,9 @@ int simple_rmdir(struct inode *dir, struct dentry *dentry) | |||
285 | if (!simple_empty(dentry)) | 285 | if (!simple_empty(dentry)) |
286 | return -ENOTEMPTY; | 286 | return -ENOTEMPTY; |
287 | 287 | ||
288 | dentry->d_inode->i_nlink--; | 288 | drop_nlink(dentry->d_inode); |
289 | simple_unlink(dir, dentry); | 289 | simple_unlink(dir, dentry); |
290 | dir->i_nlink--; | 290 | drop_nlink(dir); |
291 | return 0; | 291 | return 0; |
292 | } | 292 | } |
293 | 293 | ||
@@ -303,10 +303,10 @@ int simple_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
303 | if (new_dentry->d_inode) { | 303 | if (new_dentry->d_inode) { |
304 | simple_unlink(new_dir, new_dentry); | 304 | simple_unlink(new_dir, new_dentry); |
305 | if (they_are_dirs) | 305 | if (they_are_dirs) |
306 | old_dir->i_nlink--; | 306 | drop_nlink(old_dir); |
307 | } else if (they_are_dirs) { | 307 | } else if (they_are_dirs) { |
308 | old_dir->i_nlink--; | 308 | drop_nlink(old_dir); |
309 | new_dir->i_nlink++; | 309 | inc_nlink(new_dir); |
310 | } | 310 | } |
311 | 311 | ||
312 | old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime = | 312 | old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime = |
@@ -317,17 +317,9 @@ int simple_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
317 | 317 | ||
318 | int simple_readpage(struct file *file, struct page *page) | 318 | int simple_readpage(struct file *file, struct page *page) |
319 | { | 319 | { |
320 | void *kaddr; | 320 | clear_highpage(page); |
321 | |||
322 | if (PageUptodate(page)) | ||
323 | goto out; | ||
324 | |||
325 | kaddr = kmap_atomic(page, KM_USER0); | ||
326 | memset(kaddr, 0, PAGE_CACHE_SIZE); | ||
327 | kunmap_atomic(kaddr, KM_USER0); | ||
328 | flush_dcache_page(page); | 321 | flush_dcache_page(page); |
329 | SetPageUptodate(page); | 322 | SetPageUptodate(page); |
330 | out: | ||
331 | unlock_page(page); | 323 | unlock_page(page); |
332 | return 0; | 324 | return 0; |
333 | } | 325 | } |
diff --git a/fs/locks.c b/fs/locks.c index d7c53392cac1..21dfadfca2bc 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -314,13 +314,13 @@ static int flock_to_posix_lock(struct file *filp, struct file_lock *fl, | |||
314 | off_t start, end; | 314 | off_t start, end; |
315 | 315 | ||
316 | switch (l->l_whence) { | 316 | switch (l->l_whence) { |
317 | case 0: /*SEEK_SET*/ | 317 | case SEEK_SET: |
318 | start = 0; | 318 | start = 0; |
319 | break; | 319 | break; |
320 | case 1: /*SEEK_CUR*/ | 320 | case SEEK_CUR: |
321 | start = filp->f_pos; | 321 | start = filp->f_pos; |
322 | break; | 322 | break; |
323 | case 2: /*SEEK_END*/ | 323 | case SEEK_END: |
324 | start = i_size_read(filp->f_dentry->d_inode); | 324 | start = i_size_read(filp->f_dentry->d_inode); |
325 | break; | 325 | break; |
326 | default: | 326 | default: |
@@ -364,13 +364,13 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl, | |||
364 | loff_t start; | 364 | loff_t start; |
365 | 365 | ||
366 | switch (l->l_whence) { | 366 | switch (l->l_whence) { |
367 | case 0: /*SEEK_SET*/ | 367 | case SEEK_SET: |
368 | start = 0; | 368 | start = 0; |
369 | break; | 369 | break; |
370 | case 1: /*SEEK_CUR*/ | 370 | case SEEK_CUR: |
371 | start = filp->f_pos; | 371 | start = filp->f_pos; |
372 | break; | 372 | break; |
373 | case 2: /*SEEK_END*/ | 373 | case SEEK_END: |
374 | start = i_size_read(filp->f_dentry->d_inode); | 374 | start = i_size_read(filp->f_dentry->d_inode); |
375 | break; | 375 | break; |
376 | default: | 376 | default: |
diff --git a/fs/mbcache.c b/fs/mbcache.c index e4fde1ab22cd..0ff71256e65b 100644 --- a/fs/mbcache.c +++ b/fs/mbcache.c | |||
@@ -160,6 +160,7 @@ __mb_cache_entry_forget(struct mb_cache_entry *ce, gfp_t gfp_mask) | |||
160 | 160 | ||
161 | static void | 161 | static void |
162 | __mb_cache_entry_release_unlock(struct mb_cache_entry *ce) | 162 | __mb_cache_entry_release_unlock(struct mb_cache_entry *ce) |
163 | __releases(mb_cache_spinlock) | ||
163 | { | 164 | { |
164 | /* Wake up all processes queuing for this cache entry. */ | 165 | /* Wake up all processes queuing for this cache entry. */ |
165 | if (ce->e_queued) | 166 | if (ce->e_queued) |
diff --git a/fs/minix/file.c b/fs/minix/file.c index 420b32882a10..40eac2e60d25 100644 --- a/fs/minix/file.c +++ b/fs/minix/file.c | |||
@@ -17,8 +17,10 @@ int minix_sync_file(struct file *, struct dentry *, int); | |||
17 | 17 | ||
18 | const struct file_operations minix_file_operations = { | 18 | const struct file_operations minix_file_operations = { |
19 | .llseek = generic_file_llseek, | 19 | .llseek = generic_file_llseek, |
20 | .read = generic_file_read, | 20 | .read = do_sync_read, |
21 | .write = generic_file_write, | 21 | .aio_read = generic_file_aio_read, |
22 | .write = do_sync_write, | ||
23 | .aio_write = generic_file_aio_write, | ||
22 | .mmap = generic_file_mmap, | 24 | .mmap = generic_file_mmap, |
23 | .fsync = minix_sync_file, | 25 | .fsync = minix_sync_file, |
24 | .sendfile = generic_file_sendfile, | 26 | .sendfile = generic_file_sendfile, |
diff --git a/fs/minix/namei.c b/fs/minix/namei.c index 5b6a4540a05b..299bb66e3bde 100644 --- a/fs/minix/namei.c +++ b/fs/minix/namei.c | |||
@@ -249,7 +249,7 @@ static int minix_rename(struct inode * old_dir, struct dentry *old_dentry, | |||
249 | minix_set_link(new_de, new_page, old_inode); | 249 | minix_set_link(new_de, new_page, old_inode); |
250 | new_inode->i_ctime = CURRENT_TIME_SEC; | 250 | new_inode->i_ctime = CURRENT_TIME_SEC; |
251 | if (dir_de) | 251 | if (dir_de) |
252 | new_inode->i_nlink--; | 252 | drop_nlink(new_inode); |
253 | inode_dec_link_count(new_inode); | 253 | inode_dec_link_count(new_inode); |
254 | } else { | 254 | } else { |
255 | if (dir_de) { | 255 | if (dir_de) { |
diff --git a/fs/mpage.c b/fs/mpage.c index 1e4598247d0b..692a3e578fc8 100644 --- a/fs/mpage.c +++ b/fs/mpage.c | |||
@@ -693,6 +693,8 @@ out: | |||
693 | * the call was made get new I/O started against them. If wbc->sync_mode is | 693 | * the call was made get new I/O started against them. If wbc->sync_mode is |
694 | * WB_SYNC_ALL then we were called for data integrity and we must wait for | 694 | * WB_SYNC_ALL then we were called for data integrity and we must wait for |
695 | * existing IO to complete. | 695 | * existing IO to complete. |
696 | * | ||
697 | * If you fix this you should check generic_writepages() also! | ||
696 | */ | 698 | */ |
697 | int | 699 | int |
698 | mpage_writepages(struct address_space *mapping, | 700 | mpage_writepages(struct address_space *mapping, |
diff --git a/fs/msdos/namei.c b/fs/msdos/namei.c index 9e44158a7540..b0f01b3b0536 100644 --- a/fs/msdos/namei.c +++ b/fs/msdos/namei.c | |||
@@ -280,7 +280,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, int mode, | |||
280 | struct nameidata *nd) | 280 | struct nameidata *nd) |
281 | { | 281 | { |
282 | struct super_block *sb = dir->i_sb; | 282 | struct super_block *sb = dir->i_sb; |
283 | struct inode *inode; | 283 | struct inode *inode = NULL; |
284 | struct fat_slot_info sinfo; | 284 | struct fat_slot_info sinfo; |
285 | struct timespec ts; | 285 | struct timespec ts; |
286 | unsigned char msdos_name[MSDOS_NAME]; | 286 | unsigned char msdos_name[MSDOS_NAME]; |
@@ -316,6 +316,8 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, int mode, | |||
316 | d_instantiate(dentry, inode); | 316 | d_instantiate(dentry, inode); |
317 | out: | 317 | out: |
318 | unlock_kernel(); | 318 | unlock_kernel(); |
319 | if (!err) | ||
320 | err = fat_flush_inodes(sb, dir, inode); | ||
319 | return err; | 321 | return err; |
320 | } | 322 | } |
321 | 323 | ||
@@ -341,13 +343,15 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry) | |||
341 | err = fat_remove_entries(dir, &sinfo); /* and releases bh */ | 343 | err = fat_remove_entries(dir, &sinfo); /* and releases bh */ |
342 | if (err) | 344 | if (err) |
343 | goto out; | 345 | goto out; |
344 | dir->i_nlink--; | 346 | drop_nlink(dir); |
345 | 347 | ||
346 | inode->i_nlink = 0; | 348 | clear_nlink(inode); |
347 | inode->i_ctime = CURRENT_TIME_SEC; | 349 | inode->i_ctime = CURRENT_TIME_SEC; |
348 | fat_detach(inode); | 350 | fat_detach(inode); |
349 | out: | 351 | out: |
350 | unlock_kernel(); | 352 | unlock_kernel(); |
353 | if (!err) | ||
354 | err = fat_flush_inodes(inode->i_sb, dir, inode); | ||
351 | 355 | ||
352 | return err; | 356 | return err; |
353 | } | 357 | } |
@@ -385,7 +389,7 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
385 | err = msdos_add_entry(dir, msdos_name, 1, is_hid, cluster, &ts, &sinfo); | 389 | err = msdos_add_entry(dir, msdos_name, 1, is_hid, cluster, &ts, &sinfo); |
386 | if (err) | 390 | if (err) |
387 | goto out_free; | 391 | goto out_free; |
388 | dir->i_nlink++; | 392 | inc_nlink(dir); |
389 | 393 | ||
390 | inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); | 394 | inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); |
391 | brelse(sinfo.bh); | 395 | brelse(sinfo.bh); |
@@ -401,6 +405,7 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
401 | d_instantiate(dentry, inode); | 405 | d_instantiate(dentry, inode); |
402 | 406 | ||
403 | unlock_kernel(); | 407 | unlock_kernel(); |
408 | fat_flush_inodes(sb, dir, inode); | ||
404 | return 0; | 409 | return 0; |
405 | 410 | ||
406 | out_free: | 411 | out_free: |
@@ -425,11 +430,13 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry) | |||
425 | err = fat_remove_entries(dir, &sinfo); /* and releases bh */ | 430 | err = fat_remove_entries(dir, &sinfo); /* and releases bh */ |
426 | if (err) | 431 | if (err) |
427 | goto out; | 432 | goto out; |
428 | inode->i_nlink = 0; | 433 | clear_nlink(inode); |
429 | inode->i_ctime = CURRENT_TIME_SEC; | 434 | inode->i_ctime = CURRENT_TIME_SEC; |
430 | fat_detach(inode); | 435 | fat_detach(inode); |
431 | out: | 436 | out: |
432 | unlock_kernel(); | 437 | unlock_kernel(); |
438 | if (!err) | ||
439 | err = fat_flush_inodes(inode->i_sb, dir, inode); | ||
433 | 440 | ||
434 | return err; | 441 | return err; |
435 | } | 442 | } |
@@ -542,9 +549,9 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name, | |||
542 | if (err) | 549 | if (err) |
543 | goto error_dotdot; | 550 | goto error_dotdot; |
544 | } | 551 | } |
545 | old_dir->i_nlink--; | 552 | drop_nlink(old_dir); |
546 | if (!new_inode) | 553 | if (!new_inode) |
547 | new_dir->i_nlink++; | 554 | inc_nlink(new_dir); |
548 | } | 555 | } |
549 | 556 | ||
550 | err = fat_remove_entries(old_dir, &old_sinfo); /* and releases bh */ | 557 | err = fat_remove_entries(old_dir, &old_sinfo); /* and releases bh */ |
@@ -559,10 +566,9 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name, | |||
559 | mark_inode_dirty(old_dir); | 566 | mark_inode_dirty(old_dir); |
560 | 567 | ||
561 | if (new_inode) { | 568 | if (new_inode) { |
569 | drop_nlink(new_inode); | ||
562 | if (is_dir) | 570 | if (is_dir) |
563 | new_inode->i_nlink -= 2; | 571 | drop_nlink(new_inode); |
564 | else | ||
565 | new_inode->i_nlink--; | ||
566 | new_inode->i_ctime = ts; | 572 | new_inode->i_ctime = ts; |
567 | } | 573 | } |
568 | out: | 574 | out: |
@@ -635,6 +641,8 @@ static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
635 | new_dir, new_msdos_name, new_dentry, is_hid); | 641 | new_dir, new_msdos_name, new_dentry, is_hid); |
636 | out: | 642 | out: |
637 | unlock_kernel(); | 643 | unlock_kernel(); |
644 | if (!err) | ||
645 | err = fat_flush_inodes(old_dir->i_sb, old_dir, new_dir); | ||
638 | return err; | 646 | return err; |
639 | } | 647 | } |
640 | 648 | ||
diff --git a/fs/namei.c b/fs/namei.c index 808e4ea2bb94..28d49b301d55 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -518,18 +518,20 @@ static int __emul_lookup_dentry(const char *, struct nameidata *); | |||
518 | static __always_inline int | 518 | static __always_inline int |
519 | walk_init_root(const char *name, struct nameidata *nd) | 519 | walk_init_root(const char *name, struct nameidata *nd) |
520 | { | 520 | { |
521 | read_lock(¤t->fs->lock); | 521 | struct fs_struct *fs = current->fs; |
522 | if (current->fs->altroot && !(nd->flags & LOOKUP_NOALT)) { | 522 | |
523 | nd->mnt = mntget(current->fs->altrootmnt); | 523 | read_lock(&fs->lock); |
524 | nd->dentry = dget(current->fs->altroot); | 524 | if (fs->altroot && !(nd->flags & LOOKUP_NOALT)) { |
525 | read_unlock(¤t->fs->lock); | 525 | nd->mnt = mntget(fs->altrootmnt); |
526 | nd->dentry = dget(fs->altroot); | ||
527 | read_unlock(&fs->lock); | ||
526 | if (__emul_lookup_dentry(name,nd)) | 528 | if (__emul_lookup_dentry(name,nd)) |
527 | return 0; | 529 | return 0; |
528 | read_lock(¤t->fs->lock); | 530 | read_lock(&fs->lock); |
529 | } | 531 | } |
530 | nd->mnt = mntget(current->fs->rootmnt); | 532 | nd->mnt = mntget(fs->rootmnt); |
531 | nd->dentry = dget(current->fs->root); | 533 | nd->dentry = dget(fs->root); |
532 | read_unlock(¤t->fs->lock); | 534 | read_unlock(&fs->lock); |
533 | return 1; | 535 | return 1; |
534 | } | 536 | } |
535 | 537 | ||
@@ -724,17 +726,19 @@ int follow_down(struct vfsmount **mnt, struct dentry **dentry) | |||
724 | 726 | ||
725 | static __always_inline void follow_dotdot(struct nameidata *nd) | 727 | static __always_inline void follow_dotdot(struct nameidata *nd) |
726 | { | 728 | { |
729 | struct fs_struct *fs = current->fs; | ||
730 | |||
727 | while(1) { | 731 | while(1) { |
728 | struct vfsmount *parent; | 732 | struct vfsmount *parent; |
729 | struct dentry *old = nd->dentry; | 733 | struct dentry *old = nd->dentry; |
730 | 734 | ||
731 | read_lock(¤t->fs->lock); | 735 | read_lock(&fs->lock); |
732 | if (nd->dentry == current->fs->root && | 736 | if (nd->dentry == fs->root && |
733 | nd->mnt == current->fs->rootmnt) { | 737 | nd->mnt == fs->rootmnt) { |
734 | read_unlock(¤t->fs->lock); | 738 | read_unlock(&fs->lock); |
735 | break; | 739 | break; |
736 | } | 740 | } |
737 | read_unlock(¤t->fs->lock); | 741 | read_unlock(&fs->lock); |
738 | spin_lock(&dcache_lock); | 742 | spin_lock(&dcache_lock); |
739 | if (nd->dentry != nd->mnt->mnt_root) { | 743 | if (nd->dentry != nd->mnt->mnt_root) { |
740 | nd->dentry = dget(nd->dentry->d_parent); | 744 | nd->dentry = dget(nd->dentry->d_parent); |
@@ -1042,15 +1046,17 @@ static int __emul_lookup_dentry(const char *name, struct nameidata *nd) | |||
1042 | struct vfsmount *old_mnt = nd->mnt; | 1046 | struct vfsmount *old_mnt = nd->mnt; |
1043 | struct qstr last = nd->last; | 1047 | struct qstr last = nd->last; |
1044 | int last_type = nd->last_type; | 1048 | int last_type = nd->last_type; |
1049 | struct fs_struct *fs = current->fs; | ||
1050 | |||
1045 | /* | 1051 | /* |
1046 | * NAME was not found in alternate root or it's a directory. Try to find | 1052 | * NAME was not found in alternate root or it's a directory. |
1047 | * it in the normal root: | 1053 | * Try to find it in the normal root: |
1048 | */ | 1054 | */ |
1049 | nd->last_type = LAST_ROOT; | 1055 | nd->last_type = LAST_ROOT; |
1050 | read_lock(¤t->fs->lock); | 1056 | read_lock(&fs->lock); |
1051 | nd->mnt = mntget(current->fs->rootmnt); | 1057 | nd->mnt = mntget(fs->rootmnt); |
1052 | nd->dentry = dget(current->fs->root); | 1058 | nd->dentry = dget(fs->root); |
1053 | read_unlock(¤t->fs->lock); | 1059 | read_unlock(&fs->lock); |
1054 | if (path_walk(name, nd) == 0) { | 1060 | if (path_walk(name, nd) == 0) { |
1055 | if (nd->dentry->d_inode) { | 1061 | if (nd->dentry->d_inode) { |
1056 | dput(old_dentry); | 1062 | dput(old_dentry); |
@@ -1074,6 +1080,7 @@ void set_fs_altroot(void) | |||
1074 | struct vfsmount *mnt = NULL, *oldmnt; | 1080 | struct vfsmount *mnt = NULL, *oldmnt; |
1075 | struct dentry *dentry = NULL, *olddentry; | 1081 | struct dentry *dentry = NULL, *olddentry; |
1076 | int err; | 1082 | int err; |
1083 | struct fs_struct *fs = current->fs; | ||
1077 | 1084 | ||
1078 | if (!emul) | 1085 | if (!emul) |
1079 | goto set_it; | 1086 | goto set_it; |
@@ -1083,12 +1090,12 @@ void set_fs_altroot(void) | |||
1083 | dentry = nd.dentry; | 1090 | dentry = nd.dentry; |
1084 | } | 1091 | } |
1085 | set_it: | 1092 | set_it: |
1086 | write_lock(¤t->fs->lock); | 1093 | write_lock(&fs->lock); |
1087 | oldmnt = current->fs->altrootmnt; | 1094 | oldmnt = fs->altrootmnt; |
1088 | olddentry = current->fs->altroot; | 1095 | olddentry = fs->altroot; |
1089 | current->fs->altrootmnt = mnt; | 1096 | fs->altrootmnt = mnt; |
1090 | current->fs->altroot = dentry; | 1097 | fs->altroot = dentry; |
1091 | write_unlock(¤t->fs->lock); | 1098 | write_unlock(&fs->lock); |
1092 | if (olddentry) { | 1099 | if (olddentry) { |
1093 | dput(olddentry); | 1100 | dput(olddentry); |
1094 | mntput(oldmnt); | 1101 | mntput(oldmnt); |
@@ -1102,29 +1109,30 @@ static int fastcall do_path_lookup(int dfd, const char *name, | |||
1102 | int retval = 0; | 1109 | int retval = 0; |
1103 | int fput_needed; | 1110 | int fput_needed; |
1104 | struct file *file; | 1111 | struct file *file; |
1112 | struct fs_struct *fs = current->fs; | ||
1105 | 1113 | ||
1106 | nd->last_type = LAST_ROOT; /* if there are only slashes... */ | 1114 | nd->last_type = LAST_ROOT; /* if there are only slashes... */ |
1107 | nd->flags = flags; | 1115 | nd->flags = flags; |
1108 | nd->depth = 0; | 1116 | nd->depth = 0; |
1109 | 1117 | ||
1110 | if (*name=='/') { | 1118 | if (*name=='/') { |
1111 | read_lock(¤t->fs->lock); | 1119 | read_lock(&fs->lock); |
1112 | if (current->fs->altroot && !(nd->flags & LOOKUP_NOALT)) { | 1120 | if (fs->altroot && !(nd->flags & LOOKUP_NOALT)) { |
1113 | nd->mnt = mntget(current->fs->altrootmnt); | 1121 | nd->mnt = mntget(fs->altrootmnt); |
1114 | nd->dentry = dget(current->fs->altroot); | 1122 | nd->dentry = dget(fs->altroot); |
1115 | read_unlock(¤t->fs->lock); | 1123 | read_unlock(&fs->lock); |
1116 | if (__emul_lookup_dentry(name,nd)) | 1124 | if (__emul_lookup_dentry(name,nd)) |
1117 | goto out; /* found in altroot */ | 1125 | goto out; /* found in altroot */ |
1118 | read_lock(¤t->fs->lock); | 1126 | read_lock(&fs->lock); |
1119 | } | 1127 | } |
1120 | nd->mnt = mntget(current->fs->rootmnt); | 1128 | nd->mnt = mntget(fs->rootmnt); |
1121 | nd->dentry = dget(current->fs->root); | 1129 | nd->dentry = dget(fs->root); |
1122 | read_unlock(¤t->fs->lock); | 1130 | read_unlock(&fs->lock); |
1123 | } else if (dfd == AT_FDCWD) { | 1131 | } else if (dfd == AT_FDCWD) { |
1124 | read_lock(¤t->fs->lock); | 1132 | read_lock(&fs->lock); |
1125 | nd->mnt = mntget(current->fs->pwdmnt); | 1133 | nd->mnt = mntget(fs->pwdmnt); |
1126 | nd->dentry = dget(current->fs->pwd); | 1134 | nd->dentry = dget(fs->pwd); |
1127 | read_unlock(¤t->fs->lock); | 1135 | read_unlock(&fs->lock); |
1128 | } else { | 1136 | } else { |
1129 | struct dentry *dentry; | 1137 | struct dentry *dentry; |
1130 | 1138 | ||
@@ -1587,6 +1595,24 @@ int may_open(struct nameidata *nd, int acc_mode, int flag) | |||
1587 | return 0; | 1595 | return 0; |
1588 | } | 1596 | } |
1589 | 1597 | ||
1598 | static int open_namei_create(struct nameidata *nd, struct path *path, | ||
1599 | int flag, int mode) | ||
1600 | { | ||
1601 | int error; | ||
1602 | struct dentry *dir = nd->dentry; | ||
1603 | |||
1604 | if (!IS_POSIXACL(dir->d_inode)) | ||
1605 | mode &= ~current->fs->umask; | ||
1606 | error = vfs_create(dir->d_inode, path->dentry, mode, nd); | ||
1607 | mutex_unlock(&dir->d_inode->i_mutex); | ||
1608 | dput(nd->dentry); | ||
1609 | nd->dentry = path->dentry; | ||
1610 | if (error) | ||
1611 | return error; | ||
1612 | /* Don't check for write permission, don't truncate */ | ||
1613 | return may_open(nd, 0, flag & ~O_TRUNC); | ||
1614 | } | ||
1615 | |||
1590 | /* | 1616 | /* |
1591 | * open_namei() | 1617 | * open_namei() |
1592 | * | 1618 | * |
@@ -1668,18 +1694,10 @@ do_last: | |||
1668 | 1694 | ||
1669 | /* Negative dentry, just create the file */ | 1695 | /* Negative dentry, just create the file */ |
1670 | if (!path.dentry->d_inode) { | 1696 | if (!path.dentry->d_inode) { |
1671 | if (!IS_POSIXACL(dir->d_inode)) | 1697 | error = open_namei_create(nd, &path, flag, mode); |
1672 | mode &= ~current->fs->umask; | ||
1673 | error = vfs_create(dir->d_inode, path.dentry, mode, nd); | ||
1674 | mutex_unlock(&dir->d_inode->i_mutex); | ||
1675 | dput(nd->dentry); | ||
1676 | nd->dentry = path.dentry; | ||
1677 | if (error) | 1698 | if (error) |
1678 | goto exit; | 1699 | goto exit; |
1679 | /* Don't check for write permission, don't truncate */ | 1700 | return 0; |
1680 | acc_mode = 0; | ||
1681 | flag &= ~O_TRUNC; | ||
1682 | goto ok; | ||
1683 | } | 1701 | } |
1684 | 1702 | ||
1685 | /* | 1703 | /* |
@@ -1926,30 +1944,32 @@ asmlinkage long sys_mkdirat(int dfd, const char __user *pathname, int mode) | |||
1926 | { | 1944 | { |
1927 | int error = 0; | 1945 | int error = 0; |
1928 | char * tmp; | 1946 | char * tmp; |
1947 | struct dentry *dentry; | ||
1948 | struct nameidata nd; | ||
1929 | 1949 | ||
1930 | tmp = getname(pathname); | 1950 | tmp = getname(pathname); |
1931 | error = PTR_ERR(tmp); | 1951 | error = PTR_ERR(tmp); |
1932 | if (!IS_ERR(tmp)) { | 1952 | if (IS_ERR(tmp)) |
1933 | struct dentry *dentry; | 1953 | goto out_err; |
1934 | struct nameidata nd; | ||
1935 | 1954 | ||
1936 | error = do_path_lookup(dfd, tmp, LOOKUP_PARENT, &nd); | 1955 | error = do_path_lookup(dfd, tmp, LOOKUP_PARENT, &nd); |
1937 | if (error) | 1956 | if (error) |
1938 | goto out; | 1957 | goto out; |
1939 | dentry = lookup_create(&nd, 1); | 1958 | dentry = lookup_create(&nd, 1); |
1940 | error = PTR_ERR(dentry); | 1959 | error = PTR_ERR(dentry); |
1941 | if (!IS_ERR(dentry)) { | 1960 | if (IS_ERR(dentry)) |
1942 | if (!IS_POSIXACL(nd.dentry->d_inode)) | 1961 | goto out_unlock; |
1943 | mode &= ~current->fs->umask; | ||
1944 | error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); | ||
1945 | dput(dentry); | ||
1946 | } | ||
1947 | mutex_unlock(&nd.dentry->d_inode->i_mutex); | ||
1948 | path_release(&nd); | ||
1949 | out: | ||
1950 | putname(tmp); | ||
1951 | } | ||
1952 | 1962 | ||
1963 | if (!IS_POSIXACL(nd.dentry->d_inode)) | ||
1964 | mode &= ~current->fs->umask; | ||
1965 | error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); | ||
1966 | dput(dentry); | ||
1967 | out_unlock: | ||
1968 | mutex_unlock(&nd.dentry->d_inode->i_mutex); | ||
1969 | path_release(&nd); | ||
1970 | out: | ||
1971 | putname(tmp); | ||
1972 | out_err: | ||
1953 | return error; | 1973 | return error; |
1954 | } | 1974 | } |
1955 | 1975 | ||
@@ -2048,10 +2068,11 @@ static long do_rmdir(int dfd, const char __user *pathname) | |||
2048 | mutex_lock_nested(&nd.dentry->d_inode->i_mutex, I_MUTEX_PARENT); | 2068 | mutex_lock_nested(&nd.dentry->d_inode->i_mutex, I_MUTEX_PARENT); |
2049 | dentry = lookup_hash(&nd); | 2069 | dentry = lookup_hash(&nd); |
2050 | error = PTR_ERR(dentry); | 2070 | error = PTR_ERR(dentry); |
2051 | if (!IS_ERR(dentry)) { | 2071 | if (IS_ERR(dentry)) |
2052 | error = vfs_rmdir(nd.dentry->d_inode, dentry); | 2072 | goto exit2; |
2053 | dput(dentry); | 2073 | error = vfs_rmdir(nd.dentry->d_inode, dentry); |
2054 | } | 2074 | dput(dentry); |
2075 | exit2: | ||
2055 | mutex_unlock(&nd.dentry->d_inode->i_mutex); | 2076 | mutex_unlock(&nd.dentry->d_inode->i_mutex); |
2056 | exit1: | 2077 | exit1: |
2057 | path_release(&nd); | 2078 | path_release(&nd); |
@@ -2191,30 +2212,33 @@ asmlinkage long sys_symlinkat(const char __user *oldname, | |||
2191 | int error = 0; | 2212 | int error = 0; |
2192 | char * from; | 2213 | char * from; |
2193 | char * to; | 2214 | char * to; |
2215 | struct dentry *dentry; | ||
2216 | struct nameidata nd; | ||
2194 | 2217 | ||
2195 | from = getname(oldname); | 2218 | from = getname(oldname); |
2196 | if(IS_ERR(from)) | 2219 | if(IS_ERR(from)) |
2197 | return PTR_ERR(from); | 2220 | return PTR_ERR(from); |
2198 | to = getname(newname); | 2221 | to = getname(newname); |
2199 | error = PTR_ERR(to); | 2222 | error = PTR_ERR(to); |
2200 | if (!IS_ERR(to)) { | 2223 | if (IS_ERR(to)) |
2201 | struct dentry *dentry; | 2224 | goto out_putname; |
2202 | struct nameidata nd; | ||
2203 | 2225 | ||
2204 | error = do_path_lookup(newdfd, to, LOOKUP_PARENT, &nd); | 2226 | error = do_path_lookup(newdfd, to, LOOKUP_PARENT, &nd); |
2205 | if (error) | 2227 | if (error) |
2206 | goto out; | 2228 | goto out; |
2207 | dentry = lookup_create(&nd, 0); | 2229 | dentry = lookup_create(&nd, 0); |
2208 | error = PTR_ERR(dentry); | 2230 | error = PTR_ERR(dentry); |
2209 | if (!IS_ERR(dentry)) { | 2231 | if (IS_ERR(dentry)) |
2210 | error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); | 2232 | goto out_unlock; |
2211 | dput(dentry); | 2233 | |
2212 | } | 2234 | error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
2213 | mutex_unlock(&nd.dentry->d_inode->i_mutex); | 2235 | dput(dentry); |
2214 | path_release(&nd); | 2236 | out_unlock: |
2237 | mutex_unlock(&nd.dentry->d_inode->i_mutex); | ||
2238 | path_release(&nd); | ||
2215 | out: | 2239 | out: |
2216 | putname(to); | 2240 | putname(to); |
2217 | } | 2241 | out_putname: |
2218 | putname(from); | 2242 | putname(from); |
2219 | return error; | 2243 | return error; |
2220 | } | 2244 | } |
@@ -2300,10 +2324,11 @@ asmlinkage long sys_linkat(int olddfd, const char __user *oldname, | |||
2300 | goto out_release; | 2324 | goto out_release; |
2301 | new_dentry = lookup_create(&nd, 0); | 2325 | new_dentry = lookup_create(&nd, 0); |
2302 | error = PTR_ERR(new_dentry); | 2326 | error = PTR_ERR(new_dentry); |
2303 | if (!IS_ERR(new_dentry)) { | 2327 | if (IS_ERR(new_dentry)) |
2304 | error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); | 2328 | goto out_unlock; |
2305 | dput(new_dentry); | 2329 | error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
2306 | } | 2330 | dput(new_dentry); |
2331 | out_unlock: | ||
2307 | mutex_unlock(&nd.dentry->d_inode->i_mutex); | 2332 | mutex_unlock(&nd.dentry->d_inode->i_mutex); |
2308 | out_release: | 2333 | out_release: |
2309 | path_release(&nd); | 2334 | path_release(&nd); |
diff --git a/fs/namespace.c b/fs/namespace.c index 36d180858136..66d921e14fee 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
14 | #include <linux/smp_lock.h> | 14 | #include <linux/smp_lock.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/kernel.h> | ||
16 | #include <linux/quotaops.h> | 17 | #include <linux/quotaops.h> |
17 | #include <linux/acct.h> | 18 | #include <linux/acct.h> |
18 | #include <linux/capability.h> | 19 | #include <linux/capability.h> |
@@ -23,12 +24,11 @@ | |||
23 | #include <linux/namei.h> | 24 | #include <linux/namei.h> |
24 | #include <linux/security.h> | 25 | #include <linux/security.h> |
25 | #include <linux/mount.h> | 26 | #include <linux/mount.h> |
27 | #include <linux/ramfs.h> | ||
26 | #include <asm/uaccess.h> | 28 | #include <asm/uaccess.h> |
27 | #include <asm/unistd.h> | 29 | #include <asm/unistd.h> |
28 | #include "pnode.h" | 30 | #include "pnode.h" |
29 | 31 | ||
30 | extern int __init init_rootfs(void); | ||
31 | |||
32 | /* spinlock for vfsmount related operations, inplace of dcache_lock */ | 32 | /* spinlock for vfsmount related operations, inplace of dcache_lock */ |
33 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock); | 33 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock); |
34 | 34 | ||
@@ -1813,6 +1813,7 @@ void __init mnt_init(unsigned long mempages) | |||
1813 | struct list_head *d; | 1813 | struct list_head *d; |
1814 | unsigned int nr_hash; | 1814 | unsigned int nr_hash; |
1815 | int i; | 1815 | int i; |
1816 | int err; | ||
1816 | 1817 | ||
1817 | init_rwsem(&namespace_sem); | 1818 | init_rwsem(&namespace_sem); |
1818 | 1819 | ||
@@ -1853,8 +1854,14 @@ void __init mnt_init(unsigned long mempages) | |||
1853 | d++; | 1854 | d++; |
1854 | i--; | 1855 | i--; |
1855 | } while (i); | 1856 | } while (i); |
1856 | sysfs_init(); | 1857 | err = sysfs_init(); |
1857 | subsystem_register(&fs_subsys); | 1858 | if (err) |
1859 | printk(KERN_WARNING "%s: sysfs_init error: %d\n", | ||
1860 | __FUNCTION__, err); | ||
1861 | err = subsystem_register(&fs_subsys); | ||
1862 | if (err) | ||
1863 | printk(KERN_WARNING "%s: subsystem_register error: %d\n", | ||
1864 | __FUNCTION__, err); | ||
1858 | init_rootfs(); | 1865 | init_rootfs(); |
1859 | init_mount_tree(); | 1866 | init_mount_tree(); |
1860 | } | 1867 | } |
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index b4ee89250e95..458b3b785194 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c | |||
@@ -53,6 +53,9 @@ const struct file_operations ncp_dir_operations = | |||
53 | .read = generic_read_dir, | 53 | .read = generic_read_dir, |
54 | .readdir = ncp_readdir, | 54 | .readdir = ncp_readdir, |
55 | .ioctl = ncp_ioctl, | 55 | .ioctl = ncp_ioctl, |
56 | #ifdef CONFIG_COMPAT | ||
57 | .compat_ioctl = ncp_compat_ioctl, | ||
58 | #endif | ||
56 | }; | 59 | }; |
57 | 60 | ||
58 | struct inode_operations ncp_dir_inode_operations = | 61 | struct inode_operations ncp_dir_inode_operations = |
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c index e6b7c67cf057..df37524b85db 100644 --- a/fs/ncpfs/file.c +++ b/fs/ncpfs/file.c | |||
@@ -289,6 +289,9 @@ const struct file_operations ncp_file_operations = | |||
289 | .read = ncp_file_read, | 289 | .read = ncp_file_read, |
290 | .write = ncp_file_write, | 290 | .write = ncp_file_write, |
291 | .ioctl = ncp_ioctl, | 291 | .ioctl = ncp_ioctl, |
292 | #ifdef CONFIG_COMPAT | ||
293 | .compat_ioctl = ncp_compat_ioctl, | ||
294 | #endif | ||
292 | .mmap = ncp_mmap, | 295 | .mmap = ncp_mmap, |
293 | .release = ncp_release, | 296 | .release = ncp_release, |
294 | .fsync = ncp_fsync, | 297 | .fsync = ncp_fsync, |
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c index 42039fe0653c..a89ac84a8241 100644 --- a/fs/ncpfs/ioctl.c +++ b/fs/ncpfs/ioctl.c | |||
@@ -7,19 +7,21 @@ | |||
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | 9 | ||
10 | |||
11 | #include <asm/uaccess.h> | ||
12 | #include <linux/capability.h> | 10 | #include <linux/capability.h> |
11 | #include <linux/compat.h> | ||
13 | #include <linux/errno.h> | 12 | #include <linux/errno.h> |
14 | #include <linux/fs.h> | 13 | #include <linux/fs.h> |
15 | #include <linux/ioctl.h> | 14 | #include <linux/ioctl.h> |
16 | #include <linux/time.h> | 15 | #include <linux/time.h> |
17 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
18 | #include <linux/highuid.h> | 17 | #include <linux/highuid.h> |
18 | #include <linux/smp_lock.h> | ||
19 | #include <linux/vmalloc.h> | 19 | #include <linux/vmalloc.h> |
20 | 20 | ||
21 | #include <linux/ncp_fs.h> | 21 | #include <linux/ncp_fs.h> |
22 | 22 | ||
23 | #include <asm/uaccess.h> | ||
24 | |||
23 | #include "ncplib_kernel.h" | 25 | #include "ncplib_kernel.h" |
24 | 26 | ||
25 | /* maximum limit for ncp_objectname_ioctl */ | 27 | /* maximum limit for ncp_objectname_ioctl */ |
@@ -89,6 +91,82 @@ ncp_get_fs_info_v2(struct ncp_server * server, struct file *file, | |||
89 | return 0; | 91 | return 0; |
90 | } | 92 | } |
91 | 93 | ||
94 | #ifdef CONFIG_COMPAT | ||
95 | struct compat_ncp_objectname_ioctl | ||
96 | { | ||
97 | s32 auth_type; | ||
98 | u32 object_name_len; | ||
99 | compat_caddr_t object_name; /* an userspace data, in most cases user name */ | ||
100 | }; | ||
101 | |||
102 | struct compat_ncp_fs_info_v2 { | ||
103 | s32 version; | ||
104 | u32 mounted_uid; | ||
105 | u32 connection; | ||
106 | u32 buffer_size; | ||
107 | |||
108 | u32 volume_number; | ||
109 | u32 directory_id; | ||
110 | |||
111 | u32 dummy1; | ||
112 | u32 dummy2; | ||
113 | u32 dummy3; | ||
114 | }; | ||
115 | |||
116 | struct compat_ncp_ioctl_request { | ||
117 | u32 function; | ||
118 | u32 size; | ||
119 | compat_caddr_t data; | ||
120 | }; | ||
121 | |||
122 | struct compat_ncp_privatedata_ioctl | ||
123 | { | ||
124 | u32 len; | ||
125 | compat_caddr_t data; /* ~1000 for NDS */ | ||
126 | }; | ||
127 | |||
128 | #define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct compat_ncp_fs_info_v2) | ||
129 | #define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct compat_ncp_ioctl_request) | ||
130 | #define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct compat_ncp_objectname_ioctl) | ||
131 | #define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct compat_ncp_objectname_ioctl) | ||
132 | #define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct compat_ncp_privatedata_ioctl) | ||
133 | #define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct compat_ncp_privatedata_ioctl) | ||
134 | |||
135 | static int | ||
136 | ncp_get_compat_fs_info_v2(struct ncp_server * server, struct file *file, | ||
137 | struct compat_ncp_fs_info_v2 __user * arg) | ||
138 | { | ||
139 | struct inode *inode = file->f_dentry->d_inode; | ||
140 | struct compat_ncp_fs_info_v2 info2; | ||
141 | |||
142 | if ((file_permission(file, MAY_WRITE) != 0) | ||
143 | && (current->uid != server->m.mounted_uid)) { | ||
144 | return -EACCES; | ||
145 | } | ||
146 | if (copy_from_user(&info2, arg, sizeof(info2))) | ||
147 | return -EFAULT; | ||
148 | |||
149 | if (info2.version != NCP_GET_FS_INFO_VERSION_V2) { | ||
150 | DPRINTK("info.version invalid: %d\n", info2.version); | ||
151 | return -EINVAL; | ||
152 | } | ||
153 | info2.mounted_uid = server->m.mounted_uid; | ||
154 | info2.connection = server->connection; | ||
155 | info2.buffer_size = server->buffer_size; | ||
156 | info2.volume_number = NCP_FINFO(inode)->volNumber; | ||
157 | info2.directory_id = NCP_FINFO(inode)->DosDirNum; | ||
158 | info2.dummy1 = info2.dummy2 = info2.dummy3 = 0; | ||
159 | |||
160 | if (copy_to_user(arg, &info2, sizeof(info2))) | ||
161 | return -EFAULT; | ||
162 | return 0; | ||
163 | } | ||
164 | #endif | ||
165 | |||
166 | #define NCP_IOC_GETMOUNTUID16 _IOW('n', 2, u16) | ||
167 | #define NCP_IOC_GETMOUNTUID32 _IOW('n', 2, u32) | ||
168 | #define NCP_IOC_GETMOUNTUID64 _IOW('n', 2, u64) | ||
169 | |||
92 | #ifdef CONFIG_NCPFS_NLS | 170 | #ifdef CONFIG_NCPFS_NLS |
93 | /* Here we are select the iocharset and the codepage for NLS. | 171 | /* Here we are select the iocharset and the codepage for NLS. |
94 | * Thanks Petr Vandrovec for idea and many hints. | 172 | * Thanks Petr Vandrovec for idea and many hints. |
@@ -192,12 +270,24 @@ int ncp_ioctl(struct inode *inode, struct file *filp, | |||
192 | void __user *argp = (void __user *)arg; | 270 | void __user *argp = (void __user *)arg; |
193 | 271 | ||
194 | switch (cmd) { | 272 | switch (cmd) { |
273 | #ifdef CONFIG_COMPAT | ||
274 | case NCP_IOC_NCPREQUEST_32: | ||
275 | #endif | ||
195 | case NCP_IOC_NCPREQUEST: | 276 | case NCP_IOC_NCPREQUEST: |
196 | |||
197 | if ((file_permission(filp, MAY_WRITE) != 0) | 277 | if ((file_permission(filp, MAY_WRITE) != 0) |
198 | && (current->uid != server->m.mounted_uid)) { | 278 | && (current->uid != server->m.mounted_uid)) { |
199 | return -EACCES; | 279 | return -EACCES; |
200 | } | 280 | } |
281 | #ifdef CONFIG_COMPAT | ||
282 | if (cmd == NCP_IOC_NCPREQUEST_32) { | ||
283 | struct compat_ncp_ioctl_request request32; | ||
284 | if (copy_from_user(&request32, argp, sizeof(request32))) | ||
285 | return -EFAULT; | ||
286 | request.function = request32.function; | ||
287 | request.size = request32.size; | ||
288 | request.data = compat_ptr(request32.data); | ||
289 | } else | ||
290 | #endif | ||
201 | if (copy_from_user(&request, argp, sizeof(request))) | 291 | if (copy_from_user(&request, argp, sizeof(request))) |
202 | return -EFAULT; | 292 | return -EFAULT; |
203 | 293 | ||
@@ -254,19 +344,35 @@ int ncp_ioctl(struct inode *inode, struct file *filp, | |||
254 | case NCP_IOC_GET_FS_INFO_V2: | 344 | case NCP_IOC_GET_FS_INFO_V2: |
255 | return ncp_get_fs_info_v2(server, filp, argp); | 345 | return ncp_get_fs_info_v2(server, filp, argp); |
256 | 346 | ||
257 | case NCP_IOC_GETMOUNTUID2: | 347 | #ifdef CONFIG_COMPAT |
258 | { | 348 | case NCP_IOC_GET_FS_INFO_V2_32: |
259 | unsigned long tmp = server->m.mounted_uid; | 349 | return ncp_get_compat_fs_info_v2(server, filp, argp); |
260 | 350 | #endif | |
261 | if ((file_permission(filp, MAY_READ) != 0) | 351 | /* we have too many combinations of CONFIG_COMPAT, |
262 | && (current->uid != server->m.mounted_uid)) | 352 | * CONFIG_64BIT and CONFIG_UID16, so just handle |
263 | { | 353 | * any of the possible ioctls */ |
264 | return -EACCES; | 354 | case NCP_IOC_GETMOUNTUID16: |
265 | } | 355 | case NCP_IOC_GETMOUNTUID32: |
266 | if (put_user(tmp, (unsigned long __user *)argp)) | 356 | case NCP_IOC_GETMOUNTUID64: |
357 | if ((file_permission(filp, MAY_READ) != 0) | ||
358 | && (current->uid != server->m.mounted_uid)) { | ||
359 | return -EACCES; | ||
360 | } | ||
361 | if (cmd == NCP_IOC_GETMOUNTUID16) { | ||
362 | u16 uid; | ||
363 | SET_UID(uid, server->m.mounted_uid); | ||
364 | if (put_user(uid, (u16 __user *)argp)) | ||
365 | return -EFAULT; | ||
366 | } else if (cmd == NCP_IOC_GETMOUNTUID32) { | ||
367 | if (put_user(server->m.mounted_uid, | ||
368 | (u32 __user *)argp)) | ||
369 | return -EFAULT; | ||
370 | } else { | ||
371 | if (put_user(server->m.mounted_uid, | ||
372 | (u64 __user *)argp)) | ||
267 | return -EFAULT; | 373 | return -EFAULT; |
268 | return 0; | ||
269 | } | 374 | } |
375 | return 0; | ||
270 | 376 | ||
271 | case NCP_IOC_GETROOT: | 377 | case NCP_IOC_GETROOT: |
272 | { | 378 | { |
@@ -476,6 +582,32 @@ outrel: | |||
476 | } | 582 | } |
477 | #endif /* CONFIG_NCPFS_IOCTL_LOCKING */ | 583 | #endif /* CONFIG_NCPFS_IOCTL_LOCKING */ |
478 | 584 | ||
585 | #ifdef CONFIG_COMPAT | ||
586 | case NCP_IOC_GETOBJECTNAME_32: | ||
587 | if (current->uid != server->m.mounted_uid) { | ||
588 | return -EACCES; | ||
589 | } | ||
590 | { | ||
591 | struct compat_ncp_objectname_ioctl user; | ||
592 | size_t outl; | ||
593 | |||
594 | if (copy_from_user(&user, argp, sizeof(user))) | ||
595 | return -EFAULT; | ||
596 | user.auth_type = server->auth.auth_type; | ||
597 | outl = user.object_name_len; | ||
598 | user.object_name_len = server->auth.object_name_len; | ||
599 | if (outl > user.object_name_len) | ||
600 | outl = user.object_name_len; | ||
601 | if (outl) { | ||
602 | if (copy_to_user(compat_ptr(user.object_name), | ||
603 | server->auth.object_name, | ||
604 | outl)) return -EFAULT; | ||
605 | } | ||
606 | if (copy_to_user(argp, &user, sizeof(user))) | ||
607 | return -EFAULT; | ||
608 | return 0; | ||
609 | } | ||
610 | #endif | ||
479 | case NCP_IOC_GETOBJECTNAME: | 611 | case NCP_IOC_GETOBJECTNAME: |
480 | if (current->uid != server->m.mounted_uid) { | 612 | if (current->uid != server->m.mounted_uid) { |
481 | return -EACCES; | 613 | return -EACCES; |
@@ -500,6 +632,9 @@ outrel: | |||
500 | return -EFAULT; | 632 | return -EFAULT; |
501 | return 0; | 633 | return 0; |
502 | } | 634 | } |
635 | #ifdef CONFIG_COMPAT | ||
636 | case NCP_IOC_SETOBJECTNAME_32: | ||
637 | #endif | ||
503 | case NCP_IOC_SETOBJECTNAME: | 638 | case NCP_IOC_SETOBJECTNAME: |
504 | if (current->uid != server->m.mounted_uid) { | 639 | if (current->uid != server->m.mounted_uid) { |
505 | return -EACCES; | 640 | return -EACCES; |
@@ -512,8 +647,19 @@ outrel: | |||
512 | void* oldprivate; | 647 | void* oldprivate; |
513 | size_t oldprivatelen; | 648 | size_t oldprivatelen; |
514 | 649 | ||
650 | #ifdef CONFIG_COMPAT | ||
651 | if (cmd == NCP_IOC_SETOBJECTNAME_32) { | ||
652 | struct compat_ncp_objectname_ioctl user32; | ||
653 | if (copy_from_user(&user32, argp, sizeof(user32))) | ||
654 | return -EFAULT; | ||
655 | user.auth_type = user32.auth_type; | ||
656 | user.object_name_len = user32.object_name_len; | ||
657 | user.object_name = compat_ptr(user32.object_name); | ||
658 | } else | ||
659 | #endif | ||
515 | if (copy_from_user(&user, argp, sizeof(user))) | 660 | if (copy_from_user(&user, argp, sizeof(user))) |
516 | return -EFAULT; | 661 | return -EFAULT; |
662 | |||
517 | if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN) | 663 | if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN) |
518 | return -ENOMEM; | 664 | return -ENOMEM; |
519 | if (user.object_name_len) { | 665 | if (user.object_name_len) { |
@@ -544,6 +690,9 @@ outrel: | |||
544 | kfree(oldname); | 690 | kfree(oldname); |
545 | return 0; | 691 | return 0; |
546 | } | 692 | } |
693 | #ifdef CONFIG_COMPAT | ||
694 | case NCP_IOC_GETPRIVATEDATA_32: | ||
695 | #endif | ||
547 | case NCP_IOC_GETPRIVATEDATA: | 696 | case NCP_IOC_GETPRIVATEDATA: |
548 | if (current->uid != server->m.mounted_uid) { | 697 | if (current->uid != server->m.mounted_uid) { |
549 | return -EACCES; | 698 | return -EACCES; |
@@ -552,8 +701,18 @@ outrel: | |||
552 | struct ncp_privatedata_ioctl user; | 701 | struct ncp_privatedata_ioctl user; |
553 | size_t outl; | 702 | size_t outl; |
554 | 703 | ||
704 | #ifdef CONFIG_COMPAT | ||
705 | if (cmd == NCP_IOC_GETPRIVATEDATA_32) { | ||
706 | struct compat_ncp_privatedata_ioctl user32; | ||
707 | if (copy_from_user(&user32, argp, sizeof(user32))) | ||
708 | return -EFAULT; | ||
709 | user.len = user32.len; | ||
710 | user.data = compat_ptr(user32.data); | ||
711 | } else | ||
712 | #endif | ||
555 | if (copy_from_user(&user, argp, sizeof(user))) | 713 | if (copy_from_user(&user, argp, sizeof(user))) |
556 | return -EFAULT; | 714 | return -EFAULT; |
715 | |||
557 | outl = user.len; | 716 | outl = user.len; |
558 | user.len = server->priv.len; | 717 | user.len = server->priv.len; |
559 | if (outl > user.len) outl = user.len; | 718 | if (outl > user.len) outl = user.len; |
@@ -562,10 +721,23 @@ outrel: | |||
562 | server->priv.data, | 721 | server->priv.data, |
563 | outl)) return -EFAULT; | 722 | outl)) return -EFAULT; |
564 | } | 723 | } |
724 | #ifdef CONFIG_COMPAT | ||
725 | if (cmd == NCP_IOC_GETPRIVATEDATA_32) { | ||
726 | struct compat_ncp_privatedata_ioctl user32; | ||
727 | user32.len = user.len; | ||
728 | user32.data = (unsigned long) user.data; | ||
729 | if (copy_to_user(&user32, argp, sizeof(user32))) | ||
730 | return -EFAULT; | ||
731 | } else | ||
732 | #endif | ||
565 | if (copy_to_user(argp, &user, sizeof(user))) | 733 | if (copy_to_user(argp, &user, sizeof(user))) |
566 | return -EFAULT; | 734 | return -EFAULT; |
735 | |||
567 | return 0; | 736 | return 0; |
568 | } | 737 | } |
738 | #ifdef CONFIG_COMPAT | ||
739 | case NCP_IOC_SETPRIVATEDATA_32: | ||
740 | #endif | ||
569 | case NCP_IOC_SETPRIVATEDATA: | 741 | case NCP_IOC_SETPRIVATEDATA: |
570 | if (current->uid != server->m.mounted_uid) { | 742 | if (current->uid != server->m.mounted_uid) { |
571 | return -EACCES; | 743 | return -EACCES; |
@@ -576,8 +748,18 @@ outrel: | |||
576 | void* old; | 748 | void* old; |
577 | size_t oldlen; | 749 | size_t oldlen; |
578 | 750 | ||
751 | #ifdef CONFIG_COMPAT | ||
752 | if (cmd == NCP_IOC_SETPRIVATEDATA_32) { | ||
753 | struct compat_ncp_privatedata_ioctl user32; | ||
754 | if (copy_from_user(&user32, argp, sizeof(user32))) | ||
755 | return -EFAULT; | ||
756 | user.len = user32.len; | ||
757 | user.data = compat_ptr(user32.data); | ||
758 | } else | ||
759 | #endif | ||
579 | if (copy_from_user(&user, argp, sizeof(user))) | 760 | if (copy_from_user(&user, argp, sizeof(user))) |
580 | return -EFAULT; | 761 | return -EFAULT; |
762 | |||
581 | if (user.len > NCP_PRIVATE_DATA_MAX_LEN) | 763 | if (user.len > NCP_PRIVATE_DATA_MAX_LEN) |
582 | return -ENOMEM; | 764 | return -ENOMEM; |
583 | if (user.len) { | 765 | if (user.len) { |
@@ -636,20 +818,19 @@ outrel: | |||
636 | } | 818 | } |
637 | 819 | ||
638 | } | 820 | } |
639 | /* #ifdef CONFIG_UID16 */ | ||
640 | /* NCP_IOC_GETMOUNTUID may be same as NCP_IOC_GETMOUNTUID2, | ||
641 | so we have this out of switch */ | ||
642 | if (cmd == NCP_IOC_GETMOUNTUID) { | ||
643 | __kernel_uid_t uid = 0; | ||
644 | if ((file_permission(filp, MAY_READ) != 0) | ||
645 | && (current->uid != server->m.mounted_uid)) { | ||
646 | return -EACCES; | ||
647 | } | ||
648 | SET_UID(uid, server->m.mounted_uid); | ||
649 | if (put_user(uid, (__kernel_uid_t __user *)argp)) | ||
650 | return -EFAULT; | ||
651 | return 0; | ||
652 | } | ||
653 | /* #endif */ | ||
654 | return -EINVAL; | 821 | return -EINVAL; |
655 | } | 822 | } |
823 | |||
824 | #ifdef CONFIG_COMPAT | ||
825 | long ncp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
826 | { | ||
827 | struct inode *inode = file->f_dentry->d_inode; | ||
828 | int ret; | ||
829 | |||
830 | lock_kernel(); | ||
831 | arg = (unsigned long) compat_ptr(arg); | ||
832 | ret = ncp_ioctl(inode, file, cmd, arg); | ||
833 | unlock_kernel(); | ||
834 | return ret; | ||
835 | } | ||
836 | #endif | ||
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 7432f1a43f3d..481f8892a919 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -843,7 +843,7 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode) | |||
843 | nfs_inode_return_delegation(inode); | 843 | nfs_inode_return_delegation(inode); |
844 | if (dentry->d_flags & DCACHE_NFSFS_RENAMED) { | 844 | if (dentry->d_flags & DCACHE_NFSFS_RENAMED) { |
845 | lock_kernel(); | 845 | lock_kernel(); |
846 | inode->i_nlink--; | 846 | drop_nlink(inode); |
847 | nfs_complete_unlink(dentry); | 847 | nfs_complete_unlink(dentry); |
848 | unlock_kernel(); | 848 | unlock_kernel(); |
849 | } | 849 | } |
@@ -1286,7 +1286,7 @@ static int nfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
1286 | error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); | 1286 | error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); |
1287 | /* Ensure the VFS deletes this inode */ | 1287 | /* Ensure the VFS deletes this inode */ |
1288 | if (error == 0 && dentry->d_inode != NULL) | 1288 | if (error == 0 && dentry->d_inode != NULL) |
1289 | dentry->d_inode->i_nlink = 0; | 1289 | clear_nlink(dentry->d_inode); |
1290 | nfs_end_data_update(dir); | 1290 | nfs_end_data_update(dir); |
1291 | unlock_kernel(); | 1291 | unlock_kernel(); |
1292 | 1292 | ||
@@ -1401,7 +1401,7 @@ static int nfs_safe_remove(struct dentry *dentry) | |||
1401 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); | 1401 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); |
1402 | /* The VFS may want to delete this inode */ | 1402 | /* The VFS may want to delete this inode */ |
1403 | if (error == 0) | 1403 | if (error == 0) |
1404 | inode->i_nlink--; | 1404 | drop_nlink(inode); |
1405 | nfs_mark_for_revalidate(inode); | 1405 | nfs_mark_for_revalidate(inode); |
1406 | nfs_end_data_update(inode); | 1406 | nfs_end_data_update(inode); |
1407 | } else | 1407 | } else |
@@ -1639,7 +1639,7 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1639 | goto out; | 1639 | goto out; |
1640 | } | 1640 | } |
1641 | } else | 1641 | } else |
1642 | new_inode->i_nlink--; | 1642 | drop_nlink(new_inode); |
1643 | 1643 | ||
1644 | go_ahead: | 1644 | go_ahead: |
1645 | /* | 1645 | /* |
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 377839bed172..9f7f8b9ea1e2 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
@@ -707,8 +707,8 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, unsigned long user_addr, siz | |||
707 | /** | 707 | /** |
708 | * nfs_file_direct_read - file direct read operation for NFS files | 708 | * nfs_file_direct_read - file direct read operation for NFS files |
709 | * @iocb: target I/O control block | 709 | * @iocb: target I/O control block |
710 | * @buf: user's buffer into which to read data | 710 | * @iov: vector of user buffers into which to read data |
711 | * @count: number of bytes to read | 711 | * @nr_segs: size of iov vector |
712 | * @pos: byte offset in file where reading starts | 712 | * @pos: byte offset in file where reading starts |
713 | * | 713 | * |
714 | * We use this function for direct reads instead of calling | 714 | * We use this function for direct reads instead of calling |
@@ -725,17 +725,24 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, unsigned long user_addr, siz | |||
725 | * client must read the updated atime from the server back into its | 725 | * client must read the updated atime from the server back into its |
726 | * cache. | 726 | * cache. |
727 | */ | 727 | */ |
728 | ssize_t nfs_file_direct_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t pos) | 728 | ssize_t nfs_file_direct_read(struct kiocb *iocb, const struct iovec *iov, |
729 | unsigned long nr_segs, loff_t pos) | ||
729 | { | 730 | { |
730 | ssize_t retval = -EINVAL; | 731 | ssize_t retval = -EINVAL; |
731 | struct file *file = iocb->ki_filp; | 732 | struct file *file = iocb->ki_filp; |
732 | struct address_space *mapping = file->f_mapping; | 733 | struct address_space *mapping = file->f_mapping; |
734 | /* XXX: temporary */ | ||
735 | const char __user *buf = iov[0].iov_base; | ||
736 | size_t count = iov[0].iov_len; | ||
733 | 737 | ||
734 | dprintk("nfs: direct read(%s/%s, %lu@%Ld)\n", | 738 | dprintk("nfs: direct read(%s/%s, %lu@%Ld)\n", |
735 | file->f_dentry->d_parent->d_name.name, | 739 | file->f_dentry->d_parent->d_name.name, |
736 | file->f_dentry->d_name.name, | 740 | file->f_dentry->d_name.name, |
737 | (unsigned long) count, (long long) pos); | 741 | (unsigned long) count, (long long) pos); |
738 | 742 | ||
743 | if (nr_segs != 1) | ||
744 | return -EINVAL; | ||
745 | |||
739 | if (count < 0) | 746 | if (count < 0) |
740 | goto out; | 747 | goto out; |
741 | retval = -EFAULT; | 748 | retval = -EFAULT; |
@@ -760,8 +767,8 @@ out: | |||
760 | /** | 767 | /** |
761 | * nfs_file_direct_write - file direct write operation for NFS files | 768 | * nfs_file_direct_write - file direct write operation for NFS files |
762 | * @iocb: target I/O control block | 769 | * @iocb: target I/O control block |
763 | * @buf: user's buffer from which to write data | 770 | * @iov: vector of user buffers from which to write data |
764 | * @count: number of bytes to write | 771 | * @nr_segs: size of iov vector |
765 | * @pos: byte offset in file where writing starts | 772 | * @pos: byte offset in file where writing starts |
766 | * | 773 | * |
767 | * We use this function for direct writes instead of calling | 774 | * We use this function for direct writes instead of calling |
@@ -782,17 +789,24 @@ out: | |||
782 | * Note that O_APPEND is not supported for NFS direct writes, as there | 789 | * Note that O_APPEND is not supported for NFS direct writes, as there |
783 | * is no atomic O_APPEND write facility in the NFS protocol. | 790 | * is no atomic O_APPEND write facility in the NFS protocol. |
784 | */ | 791 | */ |
785 | ssize_t nfs_file_direct_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t pos) | 792 | ssize_t nfs_file_direct_write(struct kiocb *iocb, const struct iovec *iov, |
793 | unsigned long nr_segs, loff_t pos) | ||
786 | { | 794 | { |
787 | ssize_t retval; | 795 | ssize_t retval; |
788 | struct file *file = iocb->ki_filp; | 796 | struct file *file = iocb->ki_filp; |
789 | struct address_space *mapping = file->f_mapping; | 797 | struct address_space *mapping = file->f_mapping; |
798 | /* XXX: temporary */ | ||
799 | const char __user *buf = iov[0].iov_base; | ||
800 | size_t count = iov[0].iov_len; | ||
790 | 801 | ||
791 | dfprintk(VFS, "nfs: direct write(%s/%s, %lu@%Ld)\n", | 802 | dfprintk(VFS, "nfs: direct write(%s/%s, %lu@%Ld)\n", |
792 | file->f_dentry->d_parent->d_name.name, | 803 | file->f_dentry->d_parent->d_name.name, |
793 | file->f_dentry->d_name.name, | 804 | file->f_dentry->d_name.name, |
794 | (unsigned long) count, (long long) pos); | 805 | (unsigned long) count, (long long) pos); |
795 | 806 | ||
807 | if (nr_segs != 1) | ||
808 | return -EINVAL; | ||
809 | |||
796 | retval = generic_write_checks(file, &pos, &count, 0); | 810 | retval = generic_write_checks(file, &pos, &count, 0); |
797 | if (retval) | 811 | if (retval) |
798 | goto out; | 812 | goto out; |
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index be997d649127..cc93865cea93 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c | |||
@@ -41,8 +41,10 @@ static int nfs_file_release(struct inode *, struct file *); | |||
41 | static loff_t nfs_file_llseek(struct file *file, loff_t offset, int origin); | 41 | static loff_t nfs_file_llseek(struct file *file, loff_t offset, int origin); |
42 | static int nfs_file_mmap(struct file *, struct vm_area_struct *); | 42 | static int nfs_file_mmap(struct file *, struct vm_area_struct *); |
43 | static ssize_t nfs_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *); | 43 | static ssize_t nfs_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *); |
44 | static ssize_t nfs_file_read(struct kiocb *, char __user *, size_t, loff_t); | 44 | static ssize_t nfs_file_read(struct kiocb *, const struct iovec *iov, |
45 | static ssize_t nfs_file_write(struct kiocb *, const char __user *, size_t, loff_t); | 45 | unsigned long nr_segs, loff_t pos); |
46 | static ssize_t nfs_file_write(struct kiocb *, const struct iovec *iov, | ||
47 | unsigned long nr_segs, loff_t pos); | ||
46 | static int nfs_file_flush(struct file *, fl_owner_t id); | 48 | static int nfs_file_flush(struct file *, fl_owner_t id); |
47 | static int nfs_fsync(struct file *, struct dentry *dentry, int datasync); | 49 | static int nfs_fsync(struct file *, struct dentry *dentry, int datasync); |
48 | static int nfs_check_flags(int flags); | 50 | static int nfs_check_flags(int flags); |
@@ -53,8 +55,8 @@ const struct file_operations nfs_file_operations = { | |||
53 | .llseek = nfs_file_llseek, | 55 | .llseek = nfs_file_llseek, |
54 | .read = do_sync_read, | 56 | .read = do_sync_read, |
55 | .write = do_sync_write, | 57 | .write = do_sync_write, |
56 | .aio_read = nfs_file_read, | 58 | .aio_read = nfs_file_read, |
57 | .aio_write = nfs_file_write, | 59 | .aio_write = nfs_file_write, |
58 | .mmap = nfs_file_mmap, | 60 | .mmap = nfs_file_mmap, |
59 | .open = nfs_file_open, | 61 | .open = nfs_file_open, |
60 | .flush = nfs_file_flush, | 62 | .flush = nfs_file_flush, |
@@ -196,15 +198,17 @@ nfs_file_flush(struct file *file, fl_owner_t id) | |||
196 | } | 198 | } |
197 | 199 | ||
198 | static ssize_t | 200 | static ssize_t |
199 | nfs_file_read(struct kiocb *iocb, char __user * buf, size_t count, loff_t pos) | 201 | nfs_file_read(struct kiocb *iocb, const struct iovec *iov, |
202 | unsigned long nr_segs, loff_t pos) | ||
200 | { | 203 | { |
201 | struct dentry * dentry = iocb->ki_filp->f_dentry; | 204 | struct dentry * dentry = iocb->ki_filp->f_dentry; |
202 | struct inode * inode = dentry->d_inode; | 205 | struct inode * inode = dentry->d_inode; |
203 | ssize_t result; | 206 | ssize_t result; |
207 | size_t count = iov_length(iov, nr_segs); | ||
204 | 208 | ||
205 | #ifdef CONFIG_NFS_DIRECTIO | 209 | #ifdef CONFIG_NFS_DIRECTIO |
206 | if (iocb->ki_filp->f_flags & O_DIRECT) | 210 | if (iocb->ki_filp->f_flags & O_DIRECT) |
207 | return nfs_file_direct_read(iocb, buf, count, pos); | 211 | return nfs_file_direct_read(iocb, iov, nr_segs, pos); |
208 | #endif | 212 | #endif |
209 | 213 | ||
210 | dfprintk(VFS, "nfs: read(%s/%s, %lu@%lu)\n", | 214 | dfprintk(VFS, "nfs: read(%s/%s, %lu@%lu)\n", |
@@ -214,7 +218,7 @@ nfs_file_read(struct kiocb *iocb, char __user * buf, size_t count, loff_t pos) | |||
214 | result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); | 218 | result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); |
215 | nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, count); | 219 | nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, count); |
216 | if (!result) | 220 | if (!result) |
217 | result = generic_file_aio_read(iocb, buf, count, pos); | 221 | result = generic_file_aio_read(iocb, iov, nr_segs, pos); |
218 | return result; | 222 | return result; |
219 | } | 223 | } |
220 | 224 | ||
@@ -336,24 +340,22 @@ const struct address_space_operations nfs_file_aops = { | |||
336 | #endif | 340 | #endif |
337 | }; | 341 | }; |
338 | 342 | ||
339 | /* | 343 | static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, |
340 | * Write to a file (through the page cache). | 344 | unsigned long nr_segs, loff_t pos) |
341 | */ | ||
342 | static ssize_t | ||
343 | nfs_file_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t pos) | ||
344 | { | 345 | { |
345 | struct dentry * dentry = iocb->ki_filp->f_dentry; | 346 | struct dentry * dentry = iocb->ki_filp->f_dentry; |
346 | struct inode * inode = dentry->d_inode; | 347 | struct inode * inode = dentry->d_inode; |
347 | ssize_t result; | 348 | ssize_t result; |
349 | size_t count = iov_length(iov, nr_segs); | ||
348 | 350 | ||
349 | #ifdef CONFIG_NFS_DIRECTIO | 351 | #ifdef CONFIG_NFS_DIRECTIO |
350 | if (iocb->ki_filp->f_flags & O_DIRECT) | 352 | if (iocb->ki_filp->f_flags & O_DIRECT) |
351 | return nfs_file_direct_write(iocb, buf, count, pos); | 353 | return nfs_file_direct_write(iocb, iov, nr_segs, pos); |
352 | #endif | 354 | #endif |
353 | 355 | ||
354 | dfprintk(VFS, "nfs: write(%s/%s(%ld), %lu@%lu)\n", | 356 | dfprintk(VFS, "nfs: write(%s/%s(%ld), %lu@%Ld)\n", |
355 | dentry->d_parent->d_name.name, dentry->d_name.name, | 357 | dentry->d_parent->d_name.name, dentry->d_name.name, |
356 | inode->i_ino, (unsigned long) count, (unsigned long) pos); | 358 | inode->i_ino, (unsigned long) count, (long long) pos); |
357 | 359 | ||
358 | result = -EBUSY; | 360 | result = -EBUSY; |
359 | if (IS_SWAPFILE(inode)) | 361 | if (IS_SWAPFILE(inode)) |
@@ -372,7 +374,7 @@ nfs_file_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t | |||
372 | goto out; | 374 | goto out; |
373 | 375 | ||
374 | nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count); | 376 | nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count); |
375 | result = generic_file_aio_write(iocb, buf, count, pos); | 377 | result = generic_file_aio_write(iocb, iov, nr_segs, pos); |
376 | out: | 378 | out: |
377 | return result; | 379 | return result; |
378 | 380 | ||
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index b674462793d3..f6675d2c386c 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -51,7 +51,6 @@ | |||
51 | #include <linux/mm.h> | 51 | #include <linux/mm.h> |
52 | #include <linux/pagemap.h> | 52 | #include <linux/pagemap.h> |
53 | #include <linux/file.h> | 53 | #include <linux/file.h> |
54 | #include <linux/mpage.h> | ||
55 | #include <linux/writeback.h> | 54 | #include <linux/writeback.h> |
56 | 55 | ||
57 | #include <linux/sunrpc/clnt.h> | 56 | #include <linux/sunrpc/clnt.h> |
diff --git a/fs/no-block.c b/fs/no-block.c new file mode 100644 index 000000000000..d269a93d3467 --- /dev/null +++ b/fs/no-block.c | |||
@@ -0,0 +1,22 @@ | |||
1 | /* no-block.c: implementation of routines required for non-BLOCK configuration | ||
2 | * | ||
3 | * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved. | ||
4 | * Written by David Howells (dhowells@redhat.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/fs.h> | ||
14 | |||
15 | static int no_blkdev_open(struct inode * inode, struct file * filp) | ||
16 | { | ||
17 | return -ENODEV; | ||
18 | } | ||
19 | |||
20 | const struct file_operations def_blk_fops = { | ||
21 | .open = no_blkdev_open, | ||
22 | }; | ||
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index bc579bfdfbd8..7b2c8f4f6a6f 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c | |||
@@ -254,7 +254,7 @@ static int ntfs_read_block(struct page *page) | |||
254 | bh->b_bdev = vol->sb->s_bdev; | 254 | bh->b_bdev = vol->sb->s_bdev; |
255 | /* Is the block within the allowed limits? */ | 255 | /* Is the block within the allowed limits? */ |
256 | if (iblock < lblock) { | 256 | if (iblock < lblock) { |
257 | BOOL is_retry = FALSE; | 257 | bool is_retry = false; |
258 | 258 | ||
259 | /* Convert iblock into corresponding vcn and offset. */ | 259 | /* Convert iblock into corresponding vcn and offset. */ |
260 | vcn = (VCN)iblock << blocksize_bits >> | 260 | vcn = (VCN)iblock << blocksize_bits >> |
@@ -292,7 +292,7 @@ lock_retry_remap: | |||
292 | goto handle_hole; | 292 | goto handle_hole; |
293 | /* If first try and runlist unmapped, map and retry. */ | 293 | /* If first try and runlist unmapped, map and retry. */ |
294 | if (!is_retry && lcn == LCN_RL_NOT_MAPPED) { | 294 | if (!is_retry && lcn == LCN_RL_NOT_MAPPED) { |
295 | is_retry = TRUE; | 295 | is_retry = true; |
296 | /* | 296 | /* |
297 | * Attempt to map runlist, dropping lock for | 297 | * Attempt to map runlist, dropping lock for |
298 | * the duration. | 298 | * the duration. |
@@ -558,7 +558,7 @@ static int ntfs_write_block(struct page *page, struct writeback_control *wbc) | |||
558 | unsigned long flags; | 558 | unsigned long flags; |
559 | unsigned int blocksize, vcn_ofs; | 559 | unsigned int blocksize, vcn_ofs; |
560 | int err; | 560 | int err; |
561 | BOOL need_end_writeback; | 561 | bool need_end_writeback; |
562 | unsigned char blocksize_bits; | 562 | unsigned char blocksize_bits; |
563 | 563 | ||
564 | vi = page->mapping->host; | 564 | vi = page->mapping->host; |
@@ -626,7 +626,7 @@ static int ntfs_write_block(struct page *page, struct writeback_control *wbc) | |||
626 | rl = NULL; | 626 | rl = NULL; |
627 | err = 0; | 627 | err = 0; |
628 | do { | 628 | do { |
629 | BOOL is_retry = FALSE; | 629 | bool is_retry = false; |
630 | 630 | ||
631 | if (unlikely(block >= dblock)) { | 631 | if (unlikely(block >= dblock)) { |
632 | /* | 632 | /* |
@@ -768,7 +768,7 @@ lock_retry_remap: | |||
768 | } | 768 | } |
769 | /* If first try and runlist unmapped, map and retry. */ | 769 | /* If first try and runlist unmapped, map and retry. */ |
770 | if (!is_retry && lcn == LCN_RL_NOT_MAPPED) { | 770 | if (!is_retry && lcn == LCN_RL_NOT_MAPPED) { |
771 | is_retry = TRUE; | 771 | is_retry = true; |
772 | /* | 772 | /* |
773 | * Attempt to map runlist, dropping lock for | 773 | * Attempt to map runlist, dropping lock for |
774 | * the duration. | 774 | * the duration. |
@@ -874,12 +874,12 @@ lock_retry_remap: | |||
874 | set_page_writeback(page); /* Keeps try_to_free_buffers() away. */ | 874 | set_page_writeback(page); /* Keeps try_to_free_buffers() away. */ |
875 | 875 | ||
876 | /* Submit the prepared buffers for i/o. */ | 876 | /* Submit the prepared buffers for i/o. */ |
877 | need_end_writeback = TRUE; | 877 | need_end_writeback = true; |
878 | do { | 878 | do { |
879 | struct buffer_head *next = bh->b_this_page; | 879 | struct buffer_head *next = bh->b_this_page; |
880 | if (buffer_async_write(bh)) { | 880 | if (buffer_async_write(bh)) { |
881 | submit_bh(WRITE, bh); | 881 | submit_bh(WRITE, bh); |
882 | need_end_writeback = FALSE; | 882 | need_end_writeback = false; |
883 | } | 883 | } |
884 | bh = next; | 884 | bh = next; |
885 | } while (bh != head); | 885 | } while (bh != head); |
@@ -932,7 +932,7 @@ static int ntfs_write_mst_block(struct page *page, | |||
932 | runlist_element *rl; | 932 | runlist_element *rl; |
933 | int i, nr_locked_nis, nr_recs, nr_bhs, max_bhs, bhs_per_rec, err, err2; | 933 | int i, nr_locked_nis, nr_recs, nr_bhs, max_bhs, bhs_per_rec, err, err2; |
934 | unsigned bh_size, rec_size_bits; | 934 | unsigned bh_size, rec_size_bits; |
935 | BOOL sync, is_mft, page_is_dirty, rec_is_dirty; | 935 | bool sync, is_mft, page_is_dirty, rec_is_dirty; |
936 | unsigned char bh_size_bits; | 936 | unsigned char bh_size_bits; |
937 | 937 | ||
938 | ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index " | 938 | ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index " |
@@ -975,10 +975,10 @@ static int ntfs_write_mst_block(struct page *page, | |||
975 | 975 | ||
976 | rl = NULL; | 976 | rl = NULL; |
977 | err = err2 = nr_bhs = nr_recs = nr_locked_nis = 0; | 977 | err = err2 = nr_bhs = nr_recs = nr_locked_nis = 0; |
978 | page_is_dirty = rec_is_dirty = FALSE; | 978 | page_is_dirty = rec_is_dirty = false; |
979 | rec_start_bh = NULL; | 979 | rec_start_bh = NULL; |
980 | do { | 980 | do { |
981 | BOOL is_retry = FALSE; | 981 | bool is_retry = false; |
982 | 982 | ||
983 | if (likely(block < rec_block)) { | 983 | if (likely(block < rec_block)) { |
984 | if (unlikely(block >= dblock)) { | 984 | if (unlikely(block >= dblock)) { |
@@ -1009,10 +1009,10 @@ static int ntfs_write_mst_block(struct page *page, | |||
1009 | } | 1009 | } |
1010 | if (!buffer_dirty(bh)) { | 1010 | if (!buffer_dirty(bh)) { |
1011 | /* Clean records are not written out. */ | 1011 | /* Clean records are not written out. */ |
1012 | rec_is_dirty = FALSE; | 1012 | rec_is_dirty = false; |
1013 | continue; | 1013 | continue; |
1014 | } | 1014 | } |
1015 | rec_is_dirty = TRUE; | 1015 | rec_is_dirty = true; |
1016 | rec_start_bh = bh; | 1016 | rec_start_bh = bh; |
1017 | } | 1017 | } |
1018 | /* Need to map the buffer if it is not mapped already. */ | 1018 | /* Need to map the buffer if it is not mapped already. */ |
@@ -1053,7 +1053,7 @@ lock_retry_remap: | |||
1053 | */ | 1053 | */ |
1054 | if (!is_mft && !is_retry && | 1054 | if (!is_mft && !is_retry && |
1055 | lcn == LCN_RL_NOT_MAPPED) { | 1055 | lcn == LCN_RL_NOT_MAPPED) { |
1056 | is_retry = TRUE; | 1056 | is_retry = true; |
1057 | /* | 1057 | /* |
1058 | * Attempt to map runlist, dropping | 1058 | * Attempt to map runlist, dropping |
1059 | * lock for the duration. | 1059 | * lock for the duration. |
@@ -1063,7 +1063,7 @@ lock_retry_remap: | |||
1063 | if (likely(!err2)) | 1063 | if (likely(!err2)) |
1064 | goto lock_retry_remap; | 1064 | goto lock_retry_remap; |
1065 | if (err2 == -ENOMEM) | 1065 | if (err2 == -ENOMEM) |
1066 | page_is_dirty = TRUE; | 1066 | page_is_dirty = true; |
1067 | lcn = err2; | 1067 | lcn = err2; |
1068 | } else { | 1068 | } else { |
1069 | err2 = -EIO; | 1069 | err2 = -EIO; |
@@ -1145,7 +1145,7 @@ lock_retry_remap: | |||
1145 | * means we need to redirty the page before | 1145 | * means we need to redirty the page before |
1146 | * returning. | 1146 | * returning. |
1147 | */ | 1147 | */ |
1148 | page_is_dirty = TRUE; | 1148 | page_is_dirty = true; |
1149 | /* | 1149 | /* |
1150 | * Remove the buffers in this mft record from | 1150 | * Remove the buffers in this mft record from |
1151 | * the list of buffers to write. | 1151 | * the list of buffers to write. |
diff --git a/fs/ntfs/aops.h b/fs/ntfs/aops.h index 325ce261a107..9393f4b1e298 100644 --- a/fs/ntfs/aops.h +++ b/fs/ntfs/aops.h | |||
@@ -80,7 +80,7 @@ static inline void ntfs_unmap_page(struct page *page) | |||
80 | * | 80 | * |
81 | * The unlocked and uptodate page is returned on success or an encoded error | 81 | * The unlocked and uptodate page is returned on success or an encoded error |
82 | * on failure. Caller has to test for error using the IS_ERR() macro on the | 82 | * on failure. Caller has to test for error using the IS_ERR() macro on the |
83 | * return value. If that evaluates to TRUE, the negative error code can be | 83 | * return value. If that evaluates to 'true', the negative error code can be |
84 | * obtained using PTR_ERR() on the return value of ntfs_map_page(). | 84 | * obtained using PTR_ERR() on the return value of ntfs_map_page(). |
85 | */ | 85 | */ |
86 | static inline struct page *ntfs_map_page(struct address_space *mapping, | 86 | static inline struct page *ntfs_map_page(struct address_space *mapping, |
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index 6708e1d68a9e..9f08e851cfb6 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c | |||
@@ -67,7 +67,7 @@ | |||
67 | * the attribute has zero allocated size, i.e. there simply is no runlist. | 67 | * the attribute has zero allocated size, i.e. there simply is no runlist. |
68 | * | 68 | * |
69 | * WARNING: If @ctx is supplied, regardless of whether success or failure is | 69 | * WARNING: If @ctx is supplied, regardless of whether success or failure is |
70 | * returned, you need to check IS_ERR(@ctx->mrec) and if TRUE the @ctx | 70 | * returned, you need to check IS_ERR(@ctx->mrec) and if 'true' the @ctx |
71 | * is no longer valid, i.e. you need to either call | 71 | * is no longer valid, i.e. you need to either call |
72 | * ntfs_attr_reinit_search_ctx() or ntfs_attr_put_search_ctx() on it. | 72 | * ntfs_attr_reinit_search_ctx() or ntfs_attr_put_search_ctx() on it. |
73 | * In that case PTR_ERR(@ctx->mrec) will give you the error code for | 73 | * In that case PTR_ERR(@ctx->mrec) will give you the error code for |
@@ -90,7 +90,7 @@ int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn, ntfs_attr_search_ctx *ctx) | |||
90 | runlist_element *rl; | 90 | runlist_element *rl; |
91 | struct page *put_this_page = NULL; | 91 | struct page *put_this_page = NULL; |
92 | int err = 0; | 92 | int err = 0; |
93 | BOOL ctx_is_temporary, ctx_needs_reset; | 93 | bool ctx_is_temporary, ctx_needs_reset; |
94 | ntfs_attr_search_ctx old_ctx = { NULL, }; | 94 | ntfs_attr_search_ctx old_ctx = { NULL, }; |
95 | 95 | ||
96 | ntfs_debug("Mapping runlist part containing vcn 0x%llx.", | 96 | ntfs_debug("Mapping runlist part containing vcn 0x%llx.", |
@@ -100,7 +100,7 @@ int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn, ntfs_attr_search_ctx *ctx) | |||
100 | else | 100 | else |
101 | base_ni = ni->ext.base_ntfs_ino; | 101 | base_ni = ni->ext.base_ntfs_ino; |
102 | if (!ctx) { | 102 | if (!ctx) { |
103 | ctx_is_temporary = ctx_needs_reset = TRUE; | 103 | ctx_is_temporary = ctx_needs_reset = true; |
104 | m = map_mft_record(base_ni); | 104 | m = map_mft_record(base_ni); |
105 | if (IS_ERR(m)) | 105 | if (IS_ERR(m)) |
106 | return PTR_ERR(m); | 106 | return PTR_ERR(m); |
@@ -115,7 +115,7 @@ int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn, ntfs_attr_search_ctx *ctx) | |||
115 | BUG_ON(IS_ERR(ctx->mrec)); | 115 | BUG_ON(IS_ERR(ctx->mrec)); |
116 | a = ctx->attr; | 116 | a = ctx->attr; |
117 | BUG_ON(!a->non_resident); | 117 | BUG_ON(!a->non_resident); |
118 | ctx_is_temporary = FALSE; | 118 | ctx_is_temporary = false; |
119 | end_vcn = sle64_to_cpu(a->data.non_resident.highest_vcn); | 119 | end_vcn = sle64_to_cpu(a->data.non_resident.highest_vcn); |
120 | read_lock_irqsave(&ni->size_lock, flags); | 120 | read_lock_irqsave(&ni->size_lock, flags); |
121 | allocated_size_vcn = ni->allocated_size >> | 121 | allocated_size_vcn = ni->allocated_size >> |
@@ -136,7 +136,7 @@ int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn, ntfs_attr_search_ctx *ctx) | |||
136 | ni->name, ni->name_len) && | 136 | ni->name, ni->name_len) && |
137 | sle64_to_cpu(a->data.non_resident.lowest_vcn) | 137 | sle64_to_cpu(a->data.non_resident.lowest_vcn) |
138 | <= vcn && end_vcn >= vcn)) | 138 | <= vcn && end_vcn >= vcn)) |
139 | ctx_needs_reset = FALSE; | 139 | ctx_needs_reset = false; |
140 | else { | 140 | else { |
141 | /* Save the old search context. */ | 141 | /* Save the old search context. */ |
142 | old_ctx = *ctx; | 142 | old_ctx = *ctx; |
@@ -158,7 +158,7 @@ int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn, ntfs_attr_search_ctx *ctx) | |||
158 | * needed attribute extent. | 158 | * needed attribute extent. |
159 | */ | 159 | */ |
160 | ntfs_attr_reinit_search_ctx(ctx); | 160 | ntfs_attr_reinit_search_ctx(ctx); |
161 | ctx_needs_reset = TRUE; | 161 | ctx_needs_reset = true; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | if (ctx_needs_reset) { | 164 | if (ctx_needs_reset) { |
@@ -336,16 +336,16 @@ int ntfs_map_runlist(ntfs_inode *ni, VCN vcn) | |||
336 | * LCN_EIO Critical error (runlist/file is corrupt, i/o error, etc). | 336 | * LCN_EIO Critical error (runlist/file is corrupt, i/o error, etc). |
337 | * | 337 | * |
338 | * Locking: - The runlist must be locked on entry and is left locked on return. | 338 | * Locking: - The runlist must be locked on entry and is left locked on return. |
339 | * - If @write_locked is FALSE, i.e. the runlist is locked for reading, | 339 | * - If @write_locked is 'false', i.e. the runlist is locked for reading, |
340 | * the lock may be dropped inside the function so you cannot rely on | 340 | * the lock may be dropped inside the function so you cannot rely on |
341 | * the runlist still being the same when this function returns. | 341 | * the runlist still being the same when this function returns. |
342 | */ | 342 | */ |
343 | LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, const VCN vcn, | 343 | LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, const VCN vcn, |
344 | const BOOL write_locked) | 344 | const bool write_locked) |
345 | { | 345 | { |
346 | LCN lcn; | 346 | LCN lcn; |
347 | unsigned long flags; | 347 | unsigned long flags; |
348 | BOOL is_retry = FALSE; | 348 | bool is_retry = false; |
349 | 349 | ||
350 | ntfs_debug("Entering for i_ino 0x%lx, vcn 0x%llx, %s_locked.", | 350 | ntfs_debug("Entering for i_ino 0x%lx, vcn 0x%llx, %s_locked.", |
351 | ni->mft_no, (unsigned long long)vcn, | 351 | ni->mft_no, (unsigned long long)vcn, |
@@ -390,7 +390,7 @@ retry_remap: | |||
390 | down_read(&ni->runlist.lock); | 390 | down_read(&ni->runlist.lock); |
391 | } | 391 | } |
392 | if (likely(!err)) { | 392 | if (likely(!err)) { |
393 | is_retry = TRUE; | 393 | is_retry = true; |
394 | goto retry_remap; | 394 | goto retry_remap; |
395 | } | 395 | } |
396 | if (err == -ENOENT) | 396 | if (err == -ENOENT) |
@@ -449,7 +449,7 @@ retry_remap: | |||
449 | * -EIO - Critical error (runlist/file is corrupt, i/o error, etc). | 449 | * -EIO - Critical error (runlist/file is corrupt, i/o error, etc). |
450 | * | 450 | * |
451 | * WARNING: If @ctx is supplied, regardless of whether success or failure is | 451 | * WARNING: If @ctx is supplied, regardless of whether success or failure is |
452 | * returned, you need to check IS_ERR(@ctx->mrec) and if TRUE the @ctx | 452 | * returned, you need to check IS_ERR(@ctx->mrec) and if 'true' the @ctx |
453 | * is no longer valid, i.e. you need to either call | 453 | * is no longer valid, i.e. you need to either call |
454 | * ntfs_attr_reinit_search_ctx() or ntfs_attr_put_search_ctx() on it. | 454 | * ntfs_attr_reinit_search_ctx() or ntfs_attr_put_search_ctx() on it. |
455 | * In that case PTR_ERR(@ctx->mrec) will give you the error code for | 455 | * In that case PTR_ERR(@ctx->mrec) will give you the error code for |
@@ -469,7 +469,7 @@ runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni, const VCN vcn, | |||
469 | unsigned long flags; | 469 | unsigned long flags; |
470 | runlist_element *rl; | 470 | runlist_element *rl; |
471 | int err = 0; | 471 | int err = 0; |
472 | BOOL is_retry = FALSE; | 472 | bool is_retry = false; |
473 | 473 | ||
474 | ntfs_debug("Entering for i_ino 0x%lx, vcn 0x%llx, with%s ctx.", | 474 | ntfs_debug("Entering for i_ino 0x%lx, vcn 0x%llx, with%s ctx.", |
475 | ni->mft_no, (unsigned long long)vcn, ctx ? "" : "out"); | 475 | ni->mft_no, (unsigned long long)vcn, ctx ? "" : "out"); |
@@ -518,7 +518,7 @@ retry_remap: | |||
518 | */ | 518 | */ |
519 | err = ntfs_map_runlist_nolock(ni, vcn, ctx); | 519 | err = ntfs_map_runlist_nolock(ni, vcn, ctx); |
520 | if (likely(!err)) { | 520 | if (likely(!err)) { |
521 | is_retry = TRUE; | 521 | is_retry = true; |
522 | goto retry_remap; | 522 | goto retry_remap; |
523 | } | 523 | } |
524 | } | 524 | } |
@@ -558,8 +558,8 @@ retry_remap: | |||
558 | * On actual error, ntfs_attr_find() returns -EIO. In this case @ctx->attr is | 558 | * On actual error, ntfs_attr_find() returns -EIO. In this case @ctx->attr is |
559 | * undefined and in particular do not rely on it not changing. | 559 | * undefined and in particular do not rely on it not changing. |
560 | * | 560 | * |
561 | * If @ctx->is_first is TRUE, the search begins with @ctx->attr itself. If it | 561 | * If @ctx->is_first is 'true', the search begins with @ctx->attr itself. If it |
562 | * is FALSE, the search begins after @ctx->attr. | 562 | * is 'false', the search begins after @ctx->attr. |
563 | * | 563 | * |
564 | * If @ic is IGNORE_CASE, the @name comparisson is not case sensitive and | 564 | * If @ic is IGNORE_CASE, the @name comparisson is not case sensitive and |
565 | * @ctx->ntfs_ino must be set to the ntfs inode to which the mft record | 565 | * @ctx->ntfs_ino must be set to the ntfs inode to which the mft record |
@@ -599,11 +599,11 @@ static int ntfs_attr_find(const ATTR_TYPE type, const ntfschar *name, | |||
599 | 599 | ||
600 | /* | 600 | /* |
601 | * Iterate over attributes in mft record starting at @ctx->attr, or the | 601 | * Iterate over attributes in mft record starting at @ctx->attr, or the |
602 | * attribute following that, if @ctx->is_first is TRUE. | 602 | * attribute following that, if @ctx->is_first is 'true'. |
603 | */ | 603 | */ |
604 | if (ctx->is_first) { | 604 | if (ctx->is_first) { |
605 | a = ctx->attr; | 605 | a = ctx->attr; |
606 | ctx->is_first = FALSE; | 606 | ctx->is_first = false; |
607 | } else | 607 | } else |
608 | a = (ATTR_RECORD*)((u8*)ctx->attr + | 608 | a = (ATTR_RECORD*)((u8*)ctx->attr + |
609 | le32_to_cpu(ctx->attr->length)); | 609 | le32_to_cpu(ctx->attr->length)); |
@@ -890,11 +890,11 @@ static int ntfs_external_attr_find(const ATTR_TYPE type, | |||
890 | ctx->al_entry = (ATTR_LIST_ENTRY*)al_start; | 890 | ctx->al_entry = (ATTR_LIST_ENTRY*)al_start; |
891 | /* | 891 | /* |
892 | * Iterate over entries in attribute list starting at @ctx->al_entry, | 892 | * Iterate over entries in attribute list starting at @ctx->al_entry, |
893 | * or the entry following that, if @ctx->is_first is TRUE. | 893 | * or the entry following that, if @ctx->is_first is 'true'. |
894 | */ | 894 | */ |
895 | if (ctx->is_first) { | 895 | if (ctx->is_first) { |
896 | al_entry = ctx->al_entry; | 896 | al_entry = ctx->al_entry; |
897 | ctx->is_first = FALSE; | 897 | ctx->is_first = false; |
898 | } else | 898 | } else |
899 | al_entry = (ATTR_LIST_ENTRY*)((u8*)ctx->al_entry + | 899 | al_entry = (ATTR_LIST_ENTRY*)((u8*)ctx->al_entry + |
900 | le16_to_cpu(ctx->al_entry->length)); | 900 | le16_to_cpu(ctx->al_entry->length)); |
@@ -1127,7 +1127,7 @@ not_found: | |||
1127 | ctx->mrec = ctx->base_mrec; | 1127 | ctx->mrec = ctx->base_mrec; |
1128 | ctx->attr = (ATTR_RECORD*)((u8*)ctx->mrec + | 1128 | ctx->attr = (ATTR_RECORD*)((u8*)ctx->mrec + |
1129 | le16_to_cpu(ctx->mrec->attrs_offset)); | 1129 | le16_to_cpu(ctx->mrec->attrs_offset)); |
1130 | ctx->is_first = TRUE; | 1130 | ctx->is_first = true; |
1131 | ctx->ntfs_ino = base_ni; | 1131 | ctx->ntfs_ino = base_ni; |
1132 | ctx->base_ntfs_ino = NULL; | 1132 | ctx->base_ntfs_ino = NULL; |
1133 | ctx->base_mrec = NULL; | 1133 | ctx->base_mrec = NULL; |
@@ -1224,7 +1224,7 @@ static inline void ntfs_attr_init_search_ctx(ntfs_attr_search_ctx *ctx, | |||
1224 | /* Sanity checks are performed elsewhere. */ | 1224 | /* Sanity checks are performed elsewhere. */ |
1225 | .attr = (ATTR_RECORD*)((u8*)mrec + | 1225 | .attr = (ATTR_RECORD*)((u8*)mrec + |
1226 | le16_to_cpu(mrec->attrs_offset)), | 1226 | le16_to_cpu(mrec->attrs_offset)), |
1227 | .is_first = TRUE, | 1227 | .is_first = true, |
1228 | .ntfs_ino = ni, | 1228 | .ntfs_ino = ni, |
1229 | }; | 1229 | }; |
1230 | } | 1230 | } |
@@ -1243,7 +1243,7 @@ void ntfs_attr_reinit_search_ctx(ntfs_attr_search_ctx *ctx) | |||
1243 | { | 1243 | { |
1244 | if (likely(!ctx->base_ntfs_ino)) { | 1244 | if (likely(!ctx->base_ntfs_ino)) { |
1245 | /* No attribute list. */ | 1245 | /* No attribute list. */ |
1246 | ctx->is_first = TRUE; | 1246 | ctx->is_first = true; |
1247 | /* Sanity checks are performed elsewhere. */ | 1247 | /* Sanity checks are performed elsewhere. */ |
1248 | ctx->attr = (ATTR_RECORD*)((u8*)ctx->mrec + | 1248 | ctx->attr = (ATTR_RECORD*)((u8*)ctx->mrec + |
1249 | le16_to_cpu(ctx->mrec->attrs_offset)); | 1249 | le16_to_cpu(ctx->mrec->attrs_offset)); |
@@ -1585,7 +1585,7 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size) | |||
1585 | return -ENOMEM; | 1585 | return -ENOMEM; |
1586 | /* Start by allocating clusters to hold the attribute value. */ | 1586 | /* Start by allocating clusters to hold the attribute value. */ |
1587 | rl = ntfs_cluster_alloc(vol, 0, new_size >> | 1587 | rl = ntfs_cluster_alloc(vol, 0, new_size >> |
1588 | vol->cluster_size_bits, -1, DATA_ZONE, TRUE); | 1588 | vol->cluster_size_bits, -1, DATA_ZONE, true); |
1589 | if (IS_ERR(rl)) { | 1589 | if (IS_ERR(rl)) { |
1590 | err = PTR_ERR(rl); | 1590 | err = PTR_ERR(rl); |
1591 | ntfs_debug("Failed to allocate cluster%s, error code " | 1591 | ntfs_debug("Failed to allocate cluster%s, error code " |
@@ -1919,7 +1919,7 @@ s64 ntfs_attr_extend_allocation(ntfs_inode *ni, s64 new_alloc_size, | |||
1919 | unsigned long flags; | 1919 | unsigned long flags; |
1920 | int err, mp_size; | 1920 | int err, mp_size; |
1921 | u32 attr_len = 0; /* Silence stupid gcc warning. */ | 1921 | u32 attr_len = 0; /* Silence stupid gcc warning. */ |
1922 | BOOL mp_rebuilt; | 1922 | bool mp_rebuilt; |
1923 | 1923 | ||
1924 | #ifdef NTFS_DEBUG | 1924 | #ifdef NTFS_DEBUG |
1925 | read_lock_irqsave(&ni->size_lock, flags); | 1925 | read_lock_irqsave(&ni->size_lock, flags); |
@@ -2222,7 +2222,7 @@ first_alloc: | |||
2222 | rl2 = ntfs_cluster_alloc(vol, allocated_size >> vol->cluster_size_bits, | 2222 | rl2 = ntfs_cluster_alloc(vol, allocated_size >> vol->cluster_size_bits, |
2223 | (new_alloc_size - allocated_size) >> | 2223 | (new_alloc_size - allocated_size) >> |
2224 | vol->cluster_size_bits, (rl && (rl->lcn >= 0)) ? | 2224 | vol->cluster_size_bits, (rl && (rl->lcn >= 0)) ? |
2225 | rl->lcn + rl->length : -1, DATA_ZONE, TRUE); | 2225 | rl->lcn + rl->length : -1, DATA_ZONE, true); |
2226 | if (IS_ERR(rl2)) { | 2226 | if (IS_ERR(rl2)) { |
2227 | err = PTR_ERR(rl2); | 2227 | err = PTR_ERR(rl2); |
2228 | if (start < 0 || start >= allocated_size) | 2228 | if (start < 0 || start >= allocated_size) |
@@ -2265,7 +2265,7 @@ first_alloc: | |||
2265 | BUG_ON(!rl2); | 2265 | BUG_ON(!rl2); |
2266 | BUG_ON(!rl2->length); | 2266 | BUG_ON(!rl2->length); |
2267 | BUG_ON(rl2->lcn < LCN_HOLE); | 2267 | BUG_ON(rl2->lcn < LCN_HOLE); |
2268 | mp_rebuilt = FALSE; | 2268 | mp_rebuilt = false; |
2269 | /* Get the size for the new mapping pairs array for this extent. */ | 2269 | /* Get the size for the new mapping pairs array for this extent. */ |
2270 | mp_size = ntfs_get_size_for_mapping_pairs(vol, rl2, ll, -1); | 2270 | mp_size = ntfs_get_size_for_mapping_pairs(vol, rl2, ll, -1); |
2271 | if (unlikely(mp_size <= 0)) { | 2271 | if (unlikely(mp_size <= 0)) { |
@@ -2300,7 +2300,7 @@ first_alloc: | |||
2300 | err = -EOPNOTSUPP; | 2300 | err = -EOPNOTSUPP; |
2301 | goto undo_alloc; | 2301 | goto undo_alloc; |
2302 | } | 2302 | } |
2303 | mp_rebuilt = TRUE; | 2303 | mp_rebuilt = true; |
2304 | /* Generate the mapping pairs array directly into the attr record. */ | 2304 | /* Generate the mapping pairs array directly into the attr record. */ |
2305 | err = ntfs_mapping_pairs_build(vol, (u8*)a + | 2305 | err = ntfs_mapping_pairs_build(vol, (u8*)a + |
2306 | le16_to_cpu(a->data.non_resident.mapping_pairs_offset), | 2306 | le16_to_cpu(a->data.non_resident.mapping_pairs_offset), |
diff --git a/fs/ntfs/attrib.h b/fs/ntfs/attrib.h index 9074886b44ba..3c8b74c99b80 100644 --- a/fs/ntfs/attrib.h +++ b/fs/ntfs/attrib.h | |||
@@ -40,10 +40,10 @@ | |||
40 | * Structure must be initialized to zero before the first call to one of the | 40 | * Structure must be initialized to zero before the first call to one of the |
41 | * attribute search functions. Initialize @mrec to point to the mft record to | 41 | * attribute search functions. Initialize @mrec to point to the mft record to |
42 | * search, and @attr to point to the first attribute within @mrec (not necessary | 42 | * search, and @attr to point to the first attribute within @mrec (not necessary |
43 | * if calling the _first() functions), and set @is_first to TRUE (not necessary | 43 | * if calling the _first() functions), and set @is_first to 'true' (not necessary |
44 | * if calling the _first() functions). | 44 | * if calling the _first() functions). |
45 | * | 45 | * |
46 | * If @is_first is TRUE, the search begins with @attr. If @is_first is FALSE, | 46 | * If @is_first is 'true', the search begins with @attr. If @is_first is 'false', |
47 | * the search begins after @attr. This is so that, after the first call to one | 47 | * the search begins after @attr. This is so that, after the first call to one |
48 | * of the search attribute functions, we can call the function again, without | 48 | * of the search attribute functions, we can call the function again, without |
49 | * any modification of the search context, to automagically get the next | 49 | * any modification of the search context, to automagically get the next |
@@ -52,7 +52,7 @@ | |||
52 | typedef struct { | 52 | typedef struct { |
53 | MFT_RECORD *mrec; | 53 | MFT_RECORD *mrec; |
54 | ATTR_RECORD *attr; | 54 | ATTR_RECORD *attr; |
55 | BOOL is_first; | 55 | bool is_first; |
56 | ntfs_inode *ntfs_ino; | 56 | ntfs_inode *ntfs_ino; |
57 | ATTR_LIST_ENTRY *al_entry; | 57 | ATTR_LIST_ENTRY *al_entry; |
58 | ntfs_inode *base_ntfs_ino; | 58 | ntfs_inode *base_ntfs_ino; |
@@ -65,7 +65,7 @@ extern int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn, | |||
65 | extern int ntfs_map_runlist(ntfs_inode *ni, VCN vcn); | 65 | extern int ntfs_map_runlist(ntfs_inode *ni, VCN vcn); |
66 | 66 | ||
67 | extern LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, const VCN vcn, | 67 | extern LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, const VCN vcn, |
68 | const BOOL write_locked); | 68 | const bool write_locked); |
69 | 69 | ||
70 | extern runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni, | 70 | extern runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni, |
71 | const VCN vcn, ntfs_attr_search_ctx *ctx); | 71 | const VCN vcn, ntfs_attr_search_ctx *ctx); |
diff --git a/fs/ntfs/bitmap.c b/fs/ntfs/bitmap.c index 7a190cdc60e2..0809cf876098 100644 --- a/fs/ntfs/bitmap.c +++ b/fs/ntfs/bitmap.c | |||
@@ -34,18 +34,18 @@ | |||
34 | * @start_bit: first bit to set | 34 | * @start_bit: first bit to set |
35 | * @count: number of bits to set | 35 | * @count: number of bits to set |
36 | * @value: value to set the bits to (i.e. 0 or 1) | 36 | * @value: value to set the bits to (i.e. 0 or 1) |
37 | * @is_rollback: if TRUE this is a rollback operation | 37 | * @is_rollback: if 'true' this is a rollback operation |
38 | * | 38 | * |
39 | * Set @count bits starting at bit @start_bit in the bitmap described by the | 39 | * Set @count bits starting at bit @start_bit in the bitmap described by the |
40 | * vfs inode @vi to @value, where @value is either 0 or 1. | 40 | * vfs inode @vi to @value, where @value is either 0 or 1. |
41 | * | 41 | * |
42 | * @is_rollback should always be FALSE, it is for internal use to rollback | 42 | * @is_rollback should always be 'false', it is for internal use to rollback |
43 | * errors. You probably want to use ntfs_bitmap_set_bits_in_run() instead. | 43 | * errors. You probably want to use ntfs_bitmap_set_bits_in_run() instead. |
44 | * | 44 | * |
45 | * Return 0 on success and -errno on error. | 45 | * Return 0 on success and -errno on error. |
46 | */ | 46 | */ |
47 | int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const s64 start_bit, | 47 | int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const s64 start_bit, |
48 | const s64 count, const u8 value, const BOOL is_rollback) | 48 | const s64 count, const u8 value, const bool is_rollback) |
49 | { | 49 | { |
50 | s64 cnt = count; | 50 | s64 cnt = count; |
51 | pgoff_t index, end_index; | 51 | pgoff_t index, end_index; |
@@ -172,7 +172,7 @@ rollback: | |||
172 | return PTR_ERR(page); | 172 | return PTR_ERR(page); |
173 | if (count != cnt) | 173 | if (count != cnt) |
174 | pos = __ntfs_bitmap_set_bits_in_run(vi, start_bit, count - cnt, | 174 | pos = __ntfs_bitmap_set_bits_in_run(vi, start_bit, count - cnt, |
175 | value ? 0 : 1, TRUE); | 175 | value ? 0 : 1, true); |
176 | else | 176 | else |
177 | pos = 0; | 177 | pos = 0; |
178 | if (!pos) { | 178 | if (!pos) { |
diff --git a/fs/ntfs/bitmap.h b/fs/ntfs/bitmap.h index bb50d6bc9212..72c9ad8be70d 100644 --- a/fs/ntfs/bitmap.h +++ b/fs/ntfs/bitmap.h | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "types.h" | 30 | #include "types.h" |
31 | 31 | ||
32 | extern int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const s64 start_bit, | 32 | extern int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const s64 start_bit, |
33 | const s64 count, const u8 value, const BOOL is_rollback); | 33 | const s64 count, const u8 value, const bool is_rollback); |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * ntfs_bitmap_set_bits_in_run - set a run of bits in a bitmap to a value | 36 | * ntfs_bitmap_set_bits_in_run - set a run of bits in a bitmap to a value |
@@ -48,7 +48,7 @@ static inline int ntfs_bitmap_set_bits_in_run(struct inode *vi, | |||
48 | const s64 start_bit, const s64 count, const u8 value) | 48 | const s64 start_bit, const s64 count, const u8 value) |
49 | { | 49 | { |
50 | return __ntfs_bitmap_set_bits_in_run(vi, start_bit, count, value, | 50 | return __ntfs_bitmap_set_bits_in_run(vi, start_bit, count, value, |
51 | FALSE); | 51 | false); |
52 | } | 52 | } |
53 | 53 | ||
54 | /** | 54 | /** |
diff --git a/fs/ntfs/collate.h b/fs/ntfs/collate.h index e027f36fcc2f..aba83347e5fe 100644 --- a/fs/ntfs/collate.h +++ b/fs/ntfs/collate.h | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "types.h" | 26 | #include "types.h" |
27 | #include "volume.h" | 27 | #include "volume.h" |
28 | 28 | ||
29 | static inline BOOL ntfs_is_collation_rule_supported(COLLATION_RULE cr) { | 29 | static inline bool ntfs_is_collation_rule_supported(COLLATION_RULE cr) { |
30 | int i; | 30 | int i; |
31 | 31 | ||
32 | /* | 32 | /* |
@@ -35,12 +35,12 @@ static inline BOOL ntfs_is_collation_rule_supported(COLLATION_RULE cr) { | |||
35 | * now. | 35 | * now. |
36 | */ | 36 | */ |
37 | if (unlikely(cr != COLLATION_BINARY && cr != COLLATION_NTOFS_ULONG)) | 37 | if (unlikely(cr != COLLATION_BINARY && cr != COLLATION_NTOFS_ULONG)) |
38 | return FALSE; | 38 | return false; |
39 | i = le32_to_cpu(cr); | 39 | i = le32_to_cpu(cr); |
40 | if (likely(((i >= 0) && (i <= 0x02)) || | 40 | if (likely(((i >= 0) && (i <= 0x02)) || |
41 | ((i >= 0x10) && (i <= 0x13)))) | 41 | ((i >= 0x10) && (i <= 0x13)))) |
42 | return TRUE; | 42 | return true; |
43 | return FALSE; | 43 | return false; |
44 | } | 44 | } |
45 | 45 | ||
46 | extern int ntfs_collate(ntfs_volume *vol, COLLATION_RULE cr, | 46 | extern int ntfs_collate(ntfs_volume *vol, COLLATION_RULE cr, |
diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c index 68a607ff9fd3..d98daf59e0b6 100644 --- a/fs/ntfs/compress.c +++ b/fs/ntfs/compress.c | |||
@@ -600,7 +600,7 @@ do_next_cb: | |||
600 | rl = NULL; | 600 | rl = NULL; |
601 | for (vcn = start_vcn, start_vcn += cb_clusters; vcn < start_vcn; | 601 | for (vcn = start_vcn, start_vcn += cb_clusters; vcn < start_vcn; |
602 | vcn++) { | 602 | vcn++) { |
603 | BOOL is_retry = FALSE; | 603 | bool is_retry = false; |
604 | 604 | ||
605 | if (!rl) { | 605 | if (!rl) { |
606 | lock_retry_remap: | 606 | lock_retry_remap: |
@@ -626,7 +626,7 @@ lock_retry_remap: | |||
626 | break; | 626 | break; |
627 | if (is_retry || lcn != LCN_RL_NOT_MAPPED) | 627 | if (is_retry || lcn != LCN_RL_NOT_MAPPED) |
628 | goto rl_err; | 628 | goto rl_err; |
629 | is_retry = TRUE; | 629 | is_retry = true; |
630 | /* | 630 | /* |
631 | * Attempt to map runlist, dropping lock for the | 631 | * Attempt to map runlist, dropping lock for the |
632 | * duration. | 632 | * duration. |
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index 2e42c2dcae12..ae2fe0016d2c 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c | |||
@@ -509,7 +509,7 @@ static int ntfs_prepare_pages_for_non_resident_write(struct page **pages, | |||
509 | u32 attr_rec_len = 0; | 509 | u32 attr_rec_len = 0; |
510 | unsigned blocksize, u; | 510 | unsigned blocksize, u; |
511 | int err, mp_size; | 511 | int err, mp_size; |
512 | BOOL rl_write_locked, was_hole, is_retry; | 512 | bool rl_write_locked, was_hole, is_retry; |
513 | unsigned char blocksize_bits; | 513 | unsigned char blocksize_bits; |
514 | struct { | 514 | struct { |
515 | u8 runlist_merged:1; | 515 | u8 runlist_merged:1; |
@@ -543,13 +543,13 @@ static int ntfs_prepare_pages_for_non_resident_write(struct page **pages, | |||
543 | return -ENOMEM; | 543 | return -ENOMEM; |
544 | } | 544 | } |
545 | } while (++u < nr_pages); | 545 | } while (++u < nr_pages); |
546 | rl_write_locked = FALSE; | 546 | rl_write_locked = false; |
547 | rl = NULL; | 547 | rl = NULL; |
548 | err = 0; | 548 | err = 0; |
549 | vcn = lcn = -1; | 549 | vcn = lcn = -1; |
550 | vcn_len = 0; | 550 | vcn_len = 0; |
551 | lcn_block = -1; | 551 | lcn_block = -1; |
552 | was_hole = FALSE; | 552 | was_hole = false; |
553 | cpos = pos >> vol->cluster_size_bits; | 553 | cpos = pos >> vol->cluster_size_bits; |
554 | end = pos + bytes; | 554 | end = pos + bytes; |
555 | cend = (end + vol->cluster_size - 1) >> vol->cluster_size_bits; | 555 | cend = (end + vol->cluster_size - 1) >> vol->cluster_size_bits; |
@@ -760,7 +760,7 @@ map_buffer_cached: | |||
760 | } | 760 | } |
761 | continue; | 761 | continue; |
762 | } | 762 | } |
763 | is_retry = FALSE; | 763 | is_retry = false; |
764 | if (!rl) { | 764 | if (!rl) { |
765 | down_read(&ni->runlist.lock); | 765 | down_read(&ni->runlist.lock); |
766 | retry_remap: | 766 | retry_remap: |
@@ -776,7 +776,7 @@ retry_remap: | |||
776 | * Successful remap, setup the map cache and | 776 | * Successful remap, setup the map cache and |
777 | * use that to deal with the buffer. | 777 | * use that to deal with the buffer. |
778 | */ | 778 | */ |
779 | was_hole = FALSE; | 779 | was_hole = false; |
780 | vcn = bh_cpos; | 780 | vcn = bh_cpos; |
781 | vcn_len = rl[1].vcn - vcn; | 781 | vcn_len = rl[1].vcn - vcn; |
782 | lcn_block = lcn << (vol->cluster_size_bits - | 782 | lcn_block = lcn << (vol->cluster_size_bits - |
@@ -792,7 +792,7 @@ retry_remap: | |||
792 | if (likely(vcn + vcn_len >= cend)) { | 792 | if (likely(vcn + vcn_len >= cend)) { |
793 | if (rl_write_locked) { | 793 | if (rl_write_locked) { |
794 | up_write(&ni->runlist.lock); | 794 | up_write(&ni->runlist.lock); |
795 | rl_write_locked = FALSE; | 795 | rl_write_locked = false; |
796 | } else | 796 | } else |
797 | up_read(&ni->runlist.lock); | 797 | up_read(&ni->runlist.lock); |
798 | rl = NULL; | 798 | rl = NULL; |
@@ -818,13 +818,13 @@ retry_remap: | |||
818 | */ | 818 | */ |
819 | up_read(&ni->runlist.lock); | 819 | up_read(&ni->runlist.lock); |
820 | down_write(&ni->runlist.lock); | 820 | down_write(&ni->runlist.lock); |
821 | rl_write_locked = TRUE; | 821 | rl_write_locked = true; |
822 | goto retry_remap; | 822 | goto retry_remap; |
823 | } | 823 | } |
824 | err = ntfs_map_runlist_nolock(ni, bh_cpos, | 824 | err = ntfs_map_runlist_nolock(ni, bh_cpos, |
825 | NULL); | 825 | NULL); |
826 | if (likely(!err)) { | 826 | if (likely(!err)) { |
827 | is_retry = TRUE; | 827 | is_retry = true; |
828 | goto retry_remap; | 828 | goto retry_remap; |
829 | } | 829 | } |
830 | /* | 830 | /* |
@@ -903,7 +903,7 @@ rl_not_mapped_enoent: | |||
903 | if (!rl_write_locked) { | 903 | if (!rl_write_locked) { |
904 | up_read(&ni->runlist.lock); | 904 | up_read(&ni->runlist.lock); |
905 | down_write(&ni->runlist.lock); | 905 | down_write(&ni->runlist.lock); |
906 | rl_write_locked = TRUE; | 906 | rl_write_locked = true; |
907 | goto retry_remap; | 907 | goto retry_remap; |
908 | } | 908 | } |
909 | /* Find the previous last allocated cluster. */ | 909 | /* Find the previous last allocated cluster. */ |
@@ -917,7 +917,7 @@ rl_not_mapped_enoent: | |||
917 | } | 917 | } |
918 | } | 918 | } |
919 | rl2 = ntfs_cluster_alloc(vol, bh_cpos, 1, lcn, DATA_ZONE, | 919 | rl2 = ntfs_cluster_alloc(vol, bh_cpos, 1, lcn, DATA_ZONE, |
920 | FALSE); | 920 | false); |
921 | if (IS_ERR(rl2)) { | 921 | if (IS_ERR(rl2)) { |
922 | err = PTR_ERR(rl2); | 922 | err = PTR_ERR(rl2); |
923 | ntfs_debug("Failed to allocate cluster, error code %i.", | 923 | ntfs_debug("Failed to allocate cluster, error code %i.", |
@@ -1093,7 +1093,7 @@ rl_not_mapped_enoent: | |||
1093 | status.mft_attr_mapped = 0; | 1093 | status.mft_attr_mapped = 0; |
1094 | status.mp_rebuilt = 0; | 1094 | status.mp_rebuilt = 0; |
1095 | /* Setup the map cache and use that to deal with the buffer. */ | 1095 | /* Setup the map cache and use that to deal with the buffer. */ |
1096 | was_hole = TRUE; | 1096 | was_hole = true; |
1097 | vcn = bh_cpos; | 1097 | vcn = bh_cpos; |
1098 | vcn_len = 1; | 1098 | vcn_len = 1; |
1099 | lcn_block = lcn << (vol->cluster_size_bits - blocksize_bits); | 1099 | lcn_block = lcn << (vol->cluster_size_bits - blocksize_bits); |
@@ -1105,7 +1105,7 @@ rl_not_mapped_enoent: | |||
1105 | */ | 1105 | */ |
1106 | if (likely(vcn + vcn_len >= cend)) { | 1106 | if (likely(vcn + vcn_len >= cend)) { |
1107 | up_write(&ni->runlist.lock); | 1107 | up_write(&ni->runlist.lock); |
1108 | rl_write_locked = FALSE; | 1108 | rl_write_locked = false; |
1109 | rl = NULL; | 1109 | rl = NULL; |
1110 | } | 1110 | } |
1111 | goto map_buffer_cached; | 1111 | goto map_buffer_cached; |
@@ -1117,7 +1117,7 @@ rl_not_mapped_enoent: | |||
1117 | if (likely(!err)) { | 1117 | if (likely(!err)) { |
1118 | if (unlikely(rl_write_locked)) { | 1118 | if (unlikely(rl_write_locked)) { |
1119 | up_write(&ni->runlist.lock); | 1119 | up_write(&ni->runlist.lock); |
1120 | rl_write_locked = FALSE; | 1120 | rl_write_locked = false; |
1121 | } else if (unlikely(rl)) | 1121 | } else if (unlikely(rl)) |
1122 | up_read(&ni->runlist.lock); | 1122 | up_read(&ni->runlist.lock); |
1123 | rl = NULL; | 1123 | rl = NULL; |
@@ -1528,19 +1528,19 @@ static inline int ntfs_commit_pages_after_non_resident_write( | |||
1528 | do { | 1528 | do { |
1529 | s64 bh_pos; | 1529 | s64 bh_pos; |
1530 | struct page *page; | 1530 | struct page *page; |
1531 | BOOL partial; | 1531 | bool partial; |
1532 | 1532 | ||
1533 | page = pages[u]; | 1533 | page = pages[u]; |
1534 | bh_pos = (s64)page->index << PAGE_CACHE_SHIFT; | 1534 | bh_pos = (s64)page->index << PAGE_CACHE_SHIFT; |
1535 | bh = head = page_buffers(page); | 1535 | bh = head = page_buffers(page); |
1536 | partial = FALSE; | 1536 | partial = false; |
1537 | do { | 1537 | do { |
1538 | s64 bh_end; | 1538 | s64 bh_end; |
1539 | 1539 | ||
1540 | bh_end = bh_pos + blocksize; | 1540 | bh_end = bh_pos + blocksize; |
1541 | if (bh_end <= pos || bh_pos >= end) { | 1541 | if (bh_end <= pos || bh_pos >= end) { |
1542 | if (!buffer_uptodate(bh)) | 1542 | if (!buffer_uptodate(bh)) |
1543 | partial = TRUE; | 1543 | partial = true; |
1544 | } else { | 1544 | } else { |
1545 | set_buffer_uptodate(bh); | 1545 | set_buffer_uptodate(bh); |
1546 | mark_buffer_dirty(bh); | 1546 | mark_buffer_dirty(bh); |
@@ -1997,7 +1997,7 @@ static ssize_t ntfs_file_buffered_write(struct kiocb *iocb, | |||
1997 | */ | 1997 | */ |
1998 | down_read(&ni->runlist.lock); | 1998 | down_read(&ni->runlist.lock); |
1999 | lcn = ntfs_attr_vcn_to_lcn_nolock(ni, pos >> | 1999 | lcn = ntfs_attr_vcn_to_lcn_nolock(ni, pos >> |
2000 | vol->cluster_size_bits, FALSE); | 2000 | vol->cluster_size_bits, false); |
2001 | up_read(&ni->runlist.lock); | 2001 | up_read(&ni->runlist.lock); |
2002 | if (unlikely(lcn < LCN_HOLE)) { | 2002 | if (unlikely(lcn < LCN_HOLE)) { |
2003 | status = -EIO; | 2003 | status = -EIO; |
@@ -2176,20 +2176,18 @@ out: | |||
2176 | /** | 2176 | /** |
2177 | * ntfs_file_aio_write - | 2177 | * ntfs_file_aio_write - |
2178 | */ | 2178 | */ |
2179 | static ssize_t ntfs_file_aio_write(struct kiocb *iocb, const char __user *buf, | 2179 | static ssize_t ntfs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, |
2180 | size_t count, loff_t pos) | 2180 | unsigned long nr_segs, loff_t pos) |
2181 | { | 2181 | { |
2182 | struct file *file = iocb->ki_filp; | 2182 | struct file *file = iocb->ki_filp; |
2183 | struct address_space *mapping = file->f_mapping; | 2183 | struct address_space *mapping = file->f_mapping; |
2184 | struct inode *inode = mapping->host; | 2184 | struct inode *inode = mapping->host; |
2185 | ssize_t ret; | 2185 | ssize_t ret; |
2186 | struct iovec local_iov = { .iov_base = (void __user *)buf, | ||
2187 | .iov_len = count }; | ||
2188 | 2186 | ||
2189 | BUG_ON(iocb->ki_pos != pos); | 2187 | BUG_ON(iocb->ki_pos != pos); |
2190 | 2188 | ||
2191 | mutex_lock(&inode->i_mutex); | 2189 | mutex_lock(&inode->i_mutex); |
2192 | ret = ntfs_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos); | 2190 | ret = ntfs_file_aio_write_nolock(iocb, iov, nr_segs, &iocb->ki_pos); |
2193 | mutex_unlock(&inode->i_mutex); | 2191 | mutex_unlock(&inode->i_mutex); |
2194 | if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { | 2192 | if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { |
2195 | int err = sync_page_range(inode, mapping, pos, ret); | 2193 | int err = sync_page_range(inode, mapping, pos, ret); |
@@ -2298,13 +2296,11 @@ static int ntfs_file_fsync(struct file *filp, struct dentry *dentry, | |||
2298 | 2296 | ||
2299 | const struct file_operations ntfs_file_ops = { | 2297 | const struct file_operations ntfs_file_ops = { |
2300 | .llseek = generic_file_llseek, /* Seek inside file. */ | 2298 | .llseek = generic_file_llseek, /* Seek inside file. */ |
2301 | .read = generic_file_read, /* Read from file. */ | 2299 | .read = do_sync_read, /* Read from file. */ |
2302 | .aio_read = generic_file_aio_read, /* Async read from file. */ | 2300 | .aio_read = generic_file_aio_read, /* Async read from file. */ |
2303 | .readv = generic_file_readv, /* Read from file. */ | ||
2304 | #ifdef NTFS_RW | 2301 | #ifdef NTFS_RW |
2305 | .write = ntfs_file_write, /* Write to file. */ | 2302 | .write = ntfs_file_write, /* Write to file. */ |
2306 | .aio_write = ntfs_file_aio_write, /* Async write to file. */ | 2303 | .aio_write = ntfs_file_aio_write, /* Async write to file. */ |
2307 | .writev = ntfs_file_writev, /* Write to file. */ | ||
2308 | /*.release = ,*/ /* Last file is closed. See | 2304 | /*.release = ,*/ /* Last file is closed. See |
2309 | fs/ext2/file.c:: | 2305 | fs/ext2/file.c:: |
2310 | ext2_release_file() for | 2306 | ext2_release_file() for |
diff --git a/fs/ntfs/index.c b/fs/ntfs/index.c index 9f5427c2d105..e32cde486362 100644 --- a/fs/ntfs/index.c +++ b/fs/ntfs/index.c | |||
@@ -204,7 +204,7 @@ int ntfs_index_lookup(const void *key, const int key_len, | |||
204 | if ((key_len == le16_to_cpu(ie->key_length)) && !memcmp(key, | 204 | if ((key_len == le16_to_cpu(ie->key_length)) && !memcmp(key, |
205 | &ie->key, key_len)) { | 205 | &ie->key, key_len)) { |
206 | ir_done: | 206 | ir_done: |
207 | ictx->is_in_root = TRUE; | 207 | ictx->is_in_root = true; |
208 | ictx->ir = ir; | 208 | ictx->ir = ir; |
209 | ictx->actx = actx; | 209 | ictx->actx = actx; |
210 | ictx->base_ni = base_ni; | 210 | ictx->base_ni = base_ni; |
@@ -374,7 +374,7 @@ fast_descend_into_child_node: | |||
374 | if ((key_len == le16_to_cpu(ie->key_length)) && !memcmp(key, | 374 | if ((key_len == le16_to_cpu(ie->key_length)) && !memcmp(key, |
375 | &ie->key, key_len)) { | 375 | &ie->key, key_len)) { |
376 | ia_done: | 376 | ia_done: |
377 | ictx->is_in_root = FALSE; | 377 | ictx->is_in_root = false; |
378 | ictx->actx = NULL; | 378 | ictx->actx = NULL; |
379 | ictx->base_ni = NULL; | 379 | ictx->base_ni = NULL; |
380 | ictx->ia = ia; | 380 | ictx->ia = ia; |
diff --git a/fs/ntfs/index.h b/fs/ntfs/index.h index 846a489e8692..8745469c3989 100644 --- a/fs/ntfs/index.h +++ b/fs/ntfs/index.h | |||
@@ -37,12 +37,12 @@ | |||
37 | * @entry: index entry (points into @ir or @ia) | 37 | * @entry: index entry (points into @ir or @ia) |
38 | * @data: index entry data (points into @entry) | 38 | * @data: index entry data (points into @entry) |
39 | * @data_len: length in bytes of @data | 39 | * @data_len: length in bytes of @data |
40 | * @is_in_root: TRUE if @entry is in @ir and FALSE if it is in @ia | 40 | * @is_in_root: 'true' if @entry is in @ir and 'false' if it is in @ia |
41 | * @ir: index root if @is_in_root and NULL otherwise | 41 | * @ir: index root if @is_in_root and NULL otherwise |
42 | * @actx: attribute search context if @is_in_root and NULL otherwise | 42 | * @actx: attribute search context if @is_in_root and NULL otherwise |
43 | * @base_ni: base inode if @is_in_root and NULL otherwise | 43 | * @base_ni: base inode if @is_in_root and NULL otherwise |
44 | * @ia: index block if @is_in_root is FALSE and NULL otherwise | 44 | * @ia: index block if @is_in_root is 'false' and NULL otherwise |
45 | * @page: page if @is_in_root is FALSE and NULL otherwise | 45 | * @page: page if @is_in_root is 'false' and NULL otherwise |
46 | * | 46 | * |
47 | * @idx_ni is the index inode this context belongs to. | 47 | * @idx_ni is the index inode this context belongs to. |
48 | * | 48 | * |
@@ -50,11 +50,11 @@ | |||
50 | * are the index entry data and its length in bytes, respectively. @data | 50 | * are the index entry data and its length in bytes, respectively. @data |
51 | * simply points into @entry. This is probably what the user is interested in. | 51 | * simply points into @entry. This is probably what the user is interested in. |
52 | * | 52 | * |
53 | * If @is_in_root is TRUE, @entry is in the index root attribute @ir described | 53 | * If @is_in_root is 'true', @entry is in the index root attribute @ir described |
54 | * by the attribute search context @actx and the base inode @base_ni. @ia and | 54 | * by the attribute search context @actx and the base inode @base_ni. @ia and |
55 | * @page are NULL in this case. | 55 | * @page are NULL in this case. |
56 | * | 56 | * |
57 | * If @is_in_root is FALSE, @entry is in the index allocation attribute and @ia | 57 | * If @is_in_root is 'false', @entry is in the index allocation attribute and @ia |
58 | * and @page point to the index allocation block and the mapped, locked page it | 58 | * and @page point to the index allocation block and the mapped, locked page it |
59 | * is in, respectively. @ir, @actx and @base_ni are NULL in this case. | 59 | * is in, respectively. @ir, @actx and @base_ni are NULL in this case. |
60 | * | 60 | * |
@@ -77,7 +77,7 @@ typedef struct { | |||
77 | INDEX_ENTRY *entry; | 77 | INDEX_ENTRY *entry; |
78 | void *data; | 78 | void *data; |
79 | u16 data_len; | 79 | u16 data_len; |
80 | BOOL is_in_root; | 80 | bool is_in_root; |
81 | INDEX_ROOT *ir; | 81 | INDEX_ROOT *ir; |
82 | ntfs_attr_search_ctx *actx; | 82 | ntfs_attr_search_ctx *actx; |
83 | ntfs_inode *base_ni; | 83 | ntfs_inode *base_ni; |
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 933dbd89c2a4..2d3de9c89818 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c | |||
@@ -2301,7 +2301,7 @@ void ntfs_clear_big_inode(struct inode *vi) | |||
2301 | } | 2301 | } |
2302 | #ifdef NTFS_RW | 2302 | #ifdef NTFS_RW |
2303 | if (NInoDirty(ni)) { | 2303 | if (NInoDirty(ni)) { |
2304 | BOOL was_bad = (is_bad_inode(vi)); | 2304 | bool was_bad = (is_bad_inode(vi)); |
2305 | 2305 | ||
2306 | /* Committing the inode also commits all extent inodes. */ | 2306 | /* Committing the inode also commits all extent inodes. */ |
2307 | ntfs_commit_inode(vi); | 2307 | ntfs_commit_inode(vi); |
@@ -3015,7 +3015,7 @@ int ntfs_write_inode(struct inode *vi, int sync) | |||
3015 | MFT_RECORD *m; | 3015 | MFT_RECORD *m; |
3016 | STANDARD_INFORMATION *si; | 3016 | STANDARD_INFORMATION *si; |
3017 | int err = 0; | 3017 | int err = 0; |
3018 | BOOL modified = FALSE; | 3018 | bool modified = false; |
3019 | 3019 | ||
3020 | ntfs_debug("Entering for %sinode 0x%lx.", NInoAttr(ni) ? "attr " : "", | 3020 | ntfs_debug("Entering for %sinode 0x%lx.", NInoAttr(ni) ? "attr " : "", |
3021 | vi->i_ino); | 3021 | vi->i_ino); |
@@ -3057,7 +3057,7 @@ int ntfs_write_inode(struct inode *vi, int sync) | |||
3057 | sle64_to_cpu(si->last_data_change_time), | 3057 | sle64_to_cpu(si->last_data_change_time), |
3058 | (long long)sle64_to_cpu(nt)); | 3058 | (long long)sle64_to_cpu(nt)); |
3059 | si->last_data_change_time = nt; | 3059 | si->last_data_change_time = nt; |
3060 | modified = TRUE; | 3060 | modified = true; |
3061 | } | 3061 | } |
3062 | nt = utc2ntfs(vi->i_ctime); | 3062 | nt = utc2ntfs(vi->i_ctime); |
3063 | if (si->last_mft_change_time != nt) { | 3063 | if (si->last_mft_change_time != nt) { |
@@ -3066,7 +3066,7 @@ int ntfs_write_inode(struct inode *vi, int sync) | |||
3066 | sle64_to_cpu(si->last_mft_change_time), | 3066 | sle64_to_cpu(si->last_mft_change_time), |
3067 | (long long)sle64_to_cpu(nt)); | 3067 | (long long)sle64_to_cpu(nt)); |
3068 | si->last_mft_change_time = nt; | 3068 | si->last_mft_change_time = nt; |
3069 | modified = TRUE; | 3069 | modified = true; |
3070 | } | 3070 | } |
3071 | nt = utc2ntfs(vi->i_atime); | 3071 | nt = utc2ntfs(vi->i_atime); |
3072 | if (si->last_access_time != nt) { | 3072 | if (si->last_access_time != nt) { |
@@ -3075,7 +3075,7 @@ int ntfs_write_inode(struct inode *vi, int sync) | |||
3075 | (long long)sle64_to_cpu(si->last_access_time), | 3075 | (long long)sle64_to_cpu(si->last_access_time), |
3076 | (long long)sle64_to_cpu(nt)); | 3076 | (long long)sle64_to_cpu(nt)); |
3077 | si->last_access_time = nt; | 3077 | si->last_access_time = nt; |
3078 | modified = TRUE; | 3078 | modified = true; |
3079 | } | 3079 | } |
3080 | /* | 3080 | /* |
3081 | * If we just modified the standard information attribute we need to | 3081 | * If we just modified the standard information attribute we need to |
diff --git a/fs/ntfs/layout.h b/fs/ntfs/layout.h index d34b93cb8b48..1e383328eceb 100644 --- a/fs/ntfs/layout.h +++ b/fs/ntfs/layout.h | |||
@@ -142,13 +142,13 @@ typedef le32 NTFS_RECORD_TYPE; | |||
142 | * operator! (-8 | 142 | * operator! (-8 |
143 | */ | 143 | */ |
144 | 144 | ||
145 | static inline BOOL __ntfs_is_magic(le32 x, NTFS_RECORD_TYPE r) | 145 | static inline bool __ntfs_is_magic(le32 x, NTFS_RECORD_TYPE r) |
146 | { | 146 | { |
147 | return (x == r); | 147 | return (x == r); |
148 | } | 148 | } |
149 | #define ntfs_is_magic(x, m) __ntfs_is_magic(x, magic_##m) | 149 | #define ntfs_is_magic(x, m) __ntfs_is_magic(x, magic_##m) |
150 | 150 | ||
151 | static inline BOOL __ntfs_is_magicp(le32 *p, NTFS_RECORD_TYPE r) | 151 | static inline bool __ntfs_is_magicp(le32 *p, NTFS_RECORD_TYPE r) |
152 | { | 152 | { |
153 | return (*p == r); | 153 | return (*p == r); |
154 | } | 154 | } |
@@ -323,7 +323,7 @@ typedef le64 leMFT_REF; | |||
323 | #define MREF_LE(x) ((unsigned long)(le64_to_cpu(x) & MFT_REF_MASK_CPU)) | 323 | #define MREF_LE(x) ((unsigned long)(le64_to_cpu(x) & MFT_REF_MASK_CPU)) |
324 | #define MSEQNO_LE(x) ((u16)((le64_to_cpu(x) >> 48) & 0xffff)) | 324 | #define MSEQNO_LE(x) ((u16)((le64_to_cpu(x) >> 48) & 0xffff)) |
325 | 325 | ||
326 | #define IS_ERR_MREF(x) (((x) & 0x0000800000000000ULL) ? 1 : 0) | 326 | #define IS_ERR_MREF(x) (((x) & 0x0000800000000000ULL) ? true : false) |
327 | #define ERR_MREF(x) ((u64)((s64)(x))) | 327 | #define ERR_MREF(x) ((u64)((s64)(x))) |
328 | #define MREF_ERR(x) ((int)((s64)(x))) | 328 | #define MREF_ERR(x) ((int)((s64)(x))) |
329 | 329 | ||
diff --git a/fs/ntfs/lcnalloc.c b/fs/ntfs/lcnalloc.c index 29cabf93d2d2..1711b710b641 100644 --- a/fs/ntfs/lcnalloc.c +++ b/fs/ntfs/lcnalloc.c | |||
@@ -76,7 +76,7 @@ int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, | |||
76 | * @count: number of clusters to allocate | 76 | * @count: number of clusters to allocate |
77 | * @start_lcn: starting lcn at which to allocate the clusters (or -1 if none) | 77 | * @start_lcn: starting lcn at which to allocate the clusters (or -1 if none) |
78 | * @zone: zone from which to allocate the clusters | 78 | * @zone: zone from which to allocate the clusters |
79 | * @is_extension: if TRUE, this is an attribute extension | 79 | * @is_extension: if 'true', this is an attribute extension |
80 | * | 80 | * |
81 | * Allocate @count clusters preferably starting at cluster @start_lcn or at the | 81 | * Allocate @count clusters preferably starting at cluster @start_lcn or at the |
82 | * current allocator position if @start_lcn is -1, on the mounted ntfs volume | 82 | * current allocator position if @start_lcn is -1, on the mounted ntfs volume |
@@ -87,11 +87,11 @@ int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, | |||
87 | * @start_vcn specifies the vcn of the first allocated cluster. This makes | 87 | * @start_vcn specifies the vcn of the first allocated cluster. This makes |
88 | * merging the resulting runlist with the old runlist easier. | 88 | * merging the resulting runlist with the old runlist easier. |
89 | * | 89 | * |
90 | * If @is_extension is TRUE, the caller is allocating clusters to extend an | 90 | * If @is_extension is 'true', the caller is allocating clusters to extend an |
91 | * attribute and if it is FALSE, the caller is allocating clusters to fill a | 91 | * attribute and if it is 'false', the caller is allocating clusters to fill a |
92 | * hole in an attribute. Practically the difference is that if @is_extension | 92 | * hole in an attribute. Practically the difference is that if @is_extension |
93 | * is TRUE the returned runlist will be terminated with LCN_ENOENT and if | 93 | * is 'true' the returned runlist will be terminated with LCN_ENOENT and if |
94 | * @is_extension is FALSE the runlist will be terminated with | 94 | * @is_extension is 'false' the runlist will be terminated with |
95 | * LCN_RL_NOT_MAPPED. | 95 | * LCN_RL_NOT_MAPPED. |
96 | * | 96 | * |
97 | * You need to check the return value with IS_ERR(). If this is false, the | 97 | * You need to check the return value with IS_ERR(). If this is false, the |
@@ -146,7 +146,7 @@ int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, | |||
146 | runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn, | 146 | runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn, |
147 | const s64 count, const LCN start_lcn, | 147 | const s64 count, const LCN start_lcn, |
148 | const NTFS_CLUSTER_ALLOCATION_ZONES zone, | 148 | const NTFS_CLUSTER_ALLOCATION_ZONES zone, |
149 | const BOOL is_extension) | 149 | const bool is_extension) |
150 | { | 150 | { |
151 | LCN zone_start, zone_end, bmp_pos, bmp_initial_pos, last_read_pos, lcn; | 151 | LCN zone_start, zone_end, bmp_pos, bmp_initial_pos, last_read_pos, lcn; |
152 | LCN prev_lcn = 0, prev_run_len = 0, mft_zone_size; | 152 | LCN prev_lcn = 0, prev_run_len = 0, mft_zone_size; |
@@ -818,7 +818,7 @@ out: | |||
818 | * Assuming you cache ctx->attr in a variable @a of type ATTR_RECORD * and that | 818 | * Assuming you cache ctx->attr in a variable @a of type ATTR_RECORD * and that |
819 | * you cache ctx->mrec in a variable @m of type MFT_RECORD *. | 819 | * you cache ctx->mrec in a variable @m of type MFT_RECORD *. |
820 | * | 820 | * |
821 | * @is_rollback should always be FALSE, it is for internal use to rollback | 821 | * @is_rollback should always be 'false', it is for internal use to rollback |
822 | * errors. You probably want to use ntfs_cluster_free() instead. | 822 | * errors. You probably want to use ntfs_cluster_free() instead. |
823 | * | 823 | * |
824 | * Note, __ntfs_cluster_free() does not modify the runlist, so you have to | 824 | * Note, __ntfs_cluster_free() does not modify the runlist, so you have to |
@@ -828,7 +828,7 @@ out: | |||
828 | * success and -errno on error. | 828 | * success and -errno on error. |
829 | * | 829 | * |
830 | * WARNING: If @ctx is supplied, regardless of whether success or failure is | 830 | * WARNING: If @ctx is supplied, regardless of whether success or failure is |
831 | * returned, you need to check IS_ERR(@ctx->mrec) and if TRUE the @ctx | 831 | * returned, you need to check IS_ERR(@ctx->mrec) and if 'true' the @ctx |
832 | * is no longer valid, i.e. you need to either call | 832 | * is no longer valid, i.e. you need to either call |
833 | * ntfs_attr_reinit_search_ctx() or ntfs_attr_put_search_ctx() on it. | 833 | * ntfs_attr_reinit_search_ctx() or ntfs_attr_put_search_ctx() on it. |
834 | * In that case PTR_ERR(@ctx->mrec) will give you the error code for | 834 | * In that case PTR_ERR(@ctx->mrec) will give you the error code for |
@@ -847,7 +847,7 @@ out: | |||
847 | * and it will be left mapped on return. | 847 | * and it will be left mapped on return. |
848 | */ | 848 | */ |
849 | s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, s64 count, | 849 | s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, s64 count, |
850 | ntfs_attr_search_ctx *ctx, const BOOL is_rollback) | 850 | ntfs_attr_search_ctx *ctx, const bool is_rollback) |
851 | { | 851 | { |
852 | s64 delta, to_free, total_freed, real_freed; | 852 | s64 delta, to_free, total_freed, real_freed; |
853 | ntfs_volume *vol; | 853 | ntfs_volume *vol; |
@@ -999,7 +999,7 @@ err_out: | |||
999 | * If rollback fails, set the volume errors flag, emit an error | 999 | * If rollback fails, set the volume errors flag, emit an error |
1000 | * message, and return the error code. | 1000 | * message, and return the error code. |
1001 | */ | 1001 | */ |
1002 | delta = __ntfs_cluster_free(ni, start_vcn, total_freed, ctx, TRUE); | 1002 | delta = __ntfs_cluster_free(ni, start_vcn, total_freed, ctx, true); |
1003 | if (delta < 0) { | 1003 | if (delta < 0) { |
1004 | ntfs_error(vol->sb, "Failed to rollback (error %i). Leaving " | 1004 | ntfs_error(vol->sb, "Failed to rollback (error %i). Leaving " |
1005 | "inconsistent metadata! Unmount and run " | 1005 | "inconsistent metadata! Unmount and run " |
diff --git a/fs/ntfs/lcnalloc.h b/fs/ntfs/lcnalloc.h index 72cbca7003b2..2adb04316941 100644 --- a/fs/ntfs/lcnalloc.h +++ b/fs/ntfs/lcnalloc.h | |||
@@ -43,10 +43,10 @@ typedef enum { | |||
43 | extern runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, | 43 | extern runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, |
44 | const VCN start_vcn, const s64 count, const LCN start_lcn, | 44 | const VCN start_vcn, const s64 count, const LCN start_lcn, |
45 | const NTFS_CLUSTER_ALLOCATION_ZONES zone, | 45 | const NTFS_CLUSTER_ALLOCATION_ZONES zone, |
46 | const BOOL is_extension); | 46 | const bool is_extension); |
47 | 47 | ||
48 | extern s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, | 48 | extern s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, |
49 | s64 count, ntfs_attr_search_ctx *ctx, const BOOL is_rollback); | 49 | s64 count, ntfs_attr_search_ctx *ctx, const bool is_rollback); |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * ntfs_cluster_free - free clusters on an ntfs volume | 52 | * ntfs_cluster_free - free clusters on an ntfs volume |
@@ -86,7 +86,7 @@ extern s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, | |||
86 | * success and -errno on error. | 86 | * success and -errno on error. |
87 | * | 87 | * |
88 | * WARNING: If @ctx is supplied, regardless of whether success or failure is | 88 | * WARNING: If @ctx is supplied, regardless of whether success or failure is |
89 | * returned, you need to check IS_ERR(@ctx->mrec) and if TRUE the @ctx | 89 | * returned, you need to check IS_ERR(@ctx->mrec) and if 'true' the @ctx |
90 | * is no longer valid, i.e. you need to either call | 90 | * is no longer valid, i.e. you need to either call |
91 | * ntfs_attr_reinit_search_ctx() or ntfs_attr_put_search_ctx() on it. | 91 | * ntfs_attr_reinit_search_ctx() or ntfs_attr_put_search_ctx() on it. |
92 | * In that case PTR_ERR(@ctx->mrec) will give you the error code for | 92 | * In that case PTR_ERR(@ctx->mrec) will give you the error code for |
@@ -107,7 +107,7 @@ extern s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, | |||
107 | static inline s64 ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, | 107 | static inline s64 ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, |
108 | s64 count, ntfs_attr_search_ctx *ctx) | 108 | s64 count, ntfs_attr_search_ctx *ctx) |
109 | { | 109 | { |
110 | return __ntfs_cluster_free(ni, start_vcn, count, ctx, FALSE); | 110 | return __ntfs_cluster_free(ni, start_vcn, count, ctx, false); |
111 | } | 111 | } |
112 | 112 | ||
113 | extern int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, | 113 | extern int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, |
diff --git a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c index 4af2ad1193ec..acfed325f4ec 100644 --- a/fs/ntfs/logfile.c +++ b/fs/ntfs/logfile.c | |||
@@ -41,18 +41,18 @@ | |||
41 | * @rp: restart page header to check | 41 | * @rp: restart page header to check |
42 | * @pos: position in @vi at which the restart page header resides | 42 | * @pos: position in @vi at which the restart page header resides |
43 | * | 43 | * |
44 | * Check the restart page header @rp for consistency and return TRUE if it is | 44 | * Check the restart page header @rp for consistency and return 'true' if it is |
45 | * consistent and FALSE otherwise. | 45 | * consistent and 'false' otherwise. |
46 | * | 46 | * |
47 | * This function only needs NTFS_BLOCK_SIZE bytes in @rp, i.e. it does not | 47 | * This function only needs NTFS_BLOCK_SIZE bytes in @rp, i.e. it does not |
48 | * require the full restart page. | 48 | * require the full restart page. |
49 | */ | 49 | */ |
50 | static BOOL ntfs_check_restart_page_header(struct inode *vi, | 50 | static bool ntfs_check_restart_page_header(struct inode *vi, |
51 | RESTART_PAGE_HEADER *rp, s64 pos) | 51 | RESTART_PAGE_HEADER *rp, s64 pos) |
52 | { | 52 | { |
53 | u32 logfile_system_page_size, logfile_log_page_size; | 53 | u32 logfile_system_page_size, logfile_log_page_size; |
54 | u16 ra_ofs, usa_count, usa_ofs, usa_end = 0; | 54 | u16 ra_ofs, usa_count, usa_ofs, usa_end = 0; |
55 | BOOL have_usa = TRUE; | 55 | bool have_usa = true; |
56 | 56 | ||
57 | ntfs_debug("Entering."); | 57 | ntfs_debug("Entering."); |
58 | /* | 58 | /* |
@@ -67,7 +67,7 @@ static BOOL ntfs_check_restart_page_header(struct inode *vi, | |||
67 | (logfile_system_page_size - 1) || | 67 | (logfile_system_page_size - 1) || |
68 | logfile_log_page_size & (logfile_log_page_size - 1)) { | 68 | logfile_log_page_size & (logfile_log_page_size - 1)) { |
69 | ntfs_error(vi->i_sb, "$LogFile uses unsupported page size."); | 69 | ntfs_error(vi->i_sb, "$LogFile uses unsupported page size."); |
70 | return FALSE; | 70 | return false; |
71 | } | 71 | } |
72 | /* | 72 | /* |
73 | * We must be either at !pos (1st restart page) or at pos = system page | 73 | * We must be either at !pos (1st restart page) or at pos = system page |
@@ -76,7 +76,7 @@ static BOOL ntfs_check_restart_page_header(struct inode *vi, | |||
76 | if (pos && pos != logfile_system_page_size) { | 76 | if (pos && pos != logfile_system_page_size) { |
77 | ntfs_error(vi->i_sb, "Found restart area in incorrect " | 77 | ntfs_error(vi->i_sb, "Found restart area in incorrect " |
78 | "position in $LogFile."); | 78 | "position in $LogFile."); |
79 | return FALSE; | 79 | return false; |
80 | } | 80 | } |
81 | /* We only know how to handle version 1.1. */ | 81 | /* We only know how to handle version 1.1. */ |
82 | if (sle16_to_cpu(rp->major_ver) != 1 || | 82 | if (sle16_to_cpu(rp->major_ver) != 1 || |
@@ -85,14 +85,14 @@ static BOOL ntfs_check_restart_page_header(struct inode *vi, | |||
85 | "supported. (This driver supports version " | 85 | "supported. (This driver supports version " |
86 | "1.1 only.)", (int)sle16_to_cpu(rp->major_ver), | 86 | "1.1 only.)", (int)sle16_to_cpu(rp->major_ver), |
87 | (int)sle16_to_cpu(rp->minor_ver)); | 87 | (int)sle16_to_cpu(rp->minor_ver)); |
88 | return FALSE; | 88 | return false; |
89 | } | 89 | } |
90 | /* | 90 | /* |
91 | * If chkdsk has been run the restart page may not be protected by an | 91 | * If chkdsk has been run the restart page may not be protected by an |
92 | * update sequence array. | 92 | * update sequence array. |
93 | */ | 93 | */ |
94 | if (ntfs_is_chkd_record(rp->magic) && !le16_to_cpu(rp->usa_count)) { | 94 | if (ntfs_is_chkd_record(rp->magic) && !le16_to_cpu(rp->usa_count)) { |
95 | have_usa = FALSE; | 95 | have_usa = false; |
96 | goto skip_usa_checks; | 96 | goto skip_usa_checks; |
97 | } | 97 | } |
98 | /* Verify the size of the update sequence array. */ | 98 | /* Verify the size of the update sequence array. */ |
@@ -100,7 +100,7 @@ static BOOL ntfs_check_restart_page_header(struct inode *vi, | |||
100 | if (usa_count != le16_to_cpu(rp->usa_count)) { | 100 | if (usa_count != le16_to_cpu(rp->usa_count)) { |
101 | ntfs_error(vi->i_sb, "$LogFile restart page specifies " | 101 | ntfs_error(vi->i_sb, "$LogFile restart page specifies " |
102 | "inconsistent update sequence array count."); | 102 | "inconsistent update sequence array count."); |
103 | return FALSE; | 103 | return false; |
104 | } | 104 | } |
105 | /* Verify the position of the update sequence array. */ | 105 | /* Verify the position of the update sequence array. */ |
106 | usa_ofs = le16_to_cpu(rp->usa_ofs); | 106 | usa_ofs = le16_to_cpu(rp->usa_ofs); |
@@ -109,7 +109,7 @@ static BOOL ntfs_check_restart_page_header(struct inode *vi, | |||
109 | usa_end > NTFS_BLOCK_SIZE - sizeof(u16)) { | 109 | usa_end > NTFS_BLOCK_SIZE - sizeof(u16)) { |
110 | ntfs_error(vi->i_sb, "$LogFile restart page specifies " | 110 | ntfs_error(vi->i_sb, "$LogFile restart page specifies " |
111 | "inconsistent update sequence array offset."); | 111 | "inconsistent update sequence array offset."); |
112 | return FALSE; | 112 | return false; |
113 | } | 113 | } |
114 | skip_usa_checks: | 114 | skip_usa_checks: |
115 | /* | 115 | /* |
@@ -124,7 +124,7 @@ skip_usa_checks: | |||
124 | ra_ofs > logfile_system_page_size) { | 124 | ra_ofs > logfile_system_page_size) { |
125 | ntfs_error(vi->i_sb, "$LogFile restart page specifies " | 125 | ntfs_error(vi->i_sb, "$LogFile restart page specifies " |
126 | "inconsistent restart area offset."); | 126 | "inconsistent restart area offset."); |
127 | return FALSE; | 127 | return false; |
128 | } | 128 | } |
129 | /* | 129 | /* |
130 | * Only restart pages modified by chkdsk are allowed to have chkdsk_lsn | 130 | * Only restart pages modified by chkdsk are allowed to have chkdsk_lsn |
@@ -133,10 +133,10 @@ skip_usa_checks: | |||
133 | if (!ntfs_is_chkd_record(rp->magic) && sle64_to_cpu(rp->chkdsk_lsn)) { | 133 | if (!ntfs_is_chkd_record(rp->magic) && sle64_to_cpu(rp->chkdsk_lsn)) { |
134 | ntfs_error(vi->i_sb, "$LogFile restart page is not modified " | 134 | ntfs_error(vi->i_sb, "$LogFile restart page is not modified " |
135 | "by chkdsk but a chkdsk LSN is specified."); | 135 | "by chkdsk but a chkdsk LSN is specified."); |
136 | return FALSE; | 136 | return false; |
137 | } | 137 | } |
138 | ntfs_debug("Done."); | 138 | ntfs_debug("Done."); |
139 | return TRUE; | 139 | return true; |
140 | } | 140 | } |
141 | 141 | ||
142 | /** | 142 | /** |
@@ -145,7 +145,7 @@ skip_usa_checks: | |||
145 | * @rp: restart page whose restart area to check | 145 | * @rp: restart page whose restart area to check |
146 | * | 146 | * |
147 | * Check the restart area of the restart page @rp for consistency and return | 147 | * Check the restart area of the restart page @rp for consistency and return |
148 | * TRUE if it is consistent and FALSE otherwise. | 148 | * 'true' if it is consistent and 'false' otherwise. |
149 | * | 149 | * |
150 | * This function assumes that the restart page header has already been | 150 | * This function assumes that the restart page header has already been |
151 | * consistency checked. | 151 | * consistency checked. |
@@ -153,7 +153,7 @@ skip_usa_checks: | |||
153 | * This function only needs NTFS_BLOCK_SIZE bytes in @rp, i.e. it does not | 153 | * This function only needs NTFS_BLOCK_SIZE bytes in @rp, i.e. it does not |
154 | * require the full restart page. | 154 | * require the full restart page. |
155 | */ | 155 | */ |
156 | static BOOL ntfs_check_restart_area(struct inode *vi, RESTART_PAGE_HEADER *rp) | 156 | static bool ntfs_check_restart_area(struct inode *vi, RESTART_PAGE_HEADER *rp) |
157 | { | 157 | { |
158 | u64 file_size; | 158 | u64 file_size; |
159 | RESTART_AREA *ra; | 159 | RESTART_AREA *ra; |
@@ -172,7 +172,7 @@ static BOOL ntfs_check_restart_area(struct inode *vi, RESTART_PAGE_HEADER *rp) | |||
172 | NTFS_BLOCK_SIZE - sizeof(u16)) { | 172 | NTFS_BLOCK_SIZE - sizeof(u16)) { |
173 | ntfs_error(vi->i_sb, "$LogFile restart area specifies " | 173 | ntfs_error(vi->i_sb, "$LogFile restart area specifies " |
174 | "inconsistent file offset."); | 174 | "inconsistent file offset."); |
175 | return FALSE; | 175 | return false; |
176 | } | 176 | } |
177 | /* | 177 | /* |
178 | * Now that we can access ra->client_array_offset, make sure everything | 178 | * Now that we can access ra->client_array_offset, make sure everything |
@@ -186,7 +186,7 @@ static BOOL ntfs_check_restart_area(struct inode *vi, RESTART_PAGE_HEADER *rp) | |||
186 | ra_ofs + ca_ofs > NTFS_BLOCK_SIZE - sizeof(u16)) { | 186 | ra_ofs + ca_ofs > NTFS_BLOCK_SIZE - sizeof(u16)) { |
187 | ntfs_error(vi->i_sb, "$LogFile restart area specifies " | 187 | ntfs_error(vi->i_sb, "$LogFile restart area specifies " |
188 | "inconsistent client array offset."); | 188 | "inconsistent client array offset."); |
189 | return FALSE; | 189 | return false; |
190 | } | 190 | } |
191 | /* | 191 | /* |
192 | * The restart area must end within the system page size both when | 192 | * The restart area must end within the system page size both when |
@@ -203,7 +203,7 @@ static BOOL ntfs_check_restart_area(struct inode *vi, RESTART_PAGE_HEADER *rp) | |||
203 | "of the system page size specified by the " | 203 | "of the system page size specified by the " |
204 | "restart page header and/or the specified " | 204 | "restart page header and/or the specified " |
205 | "restart area length is inconsistent."); | 205 | "restart area length is inconsistent."); |
206 | return FALSE; | 206 | return false; |
207 | } | 207 | } |
208 | /* | 208 | /* |
209 | * The ra->client_free_list and ra->client_in_use_list must be either | 209 | * The ra->client_free_list and ra->client_in_use_list must be either |
@@ -218,7 +218,7 @@ static BOOL ntfs_check_restart_area(struct inode *vi, RESTART_PAGE_HEADER *rp) | |||
218 | le16_to_cpu(ra->log_clients))) { | 218 | le16_to_cpu(ra->log_clients))) { |
219 | ntfs_error(vi->i_sb, "$LogFile restart area specifies " | 219 | ntfs_error(vi->i_sb, "$LogFile restart area specifies " |
220 | "overflowing client free and/or in use lists."); | 220 | "overflowing client free and/or in use lists."); |
221 | return FALSE; | 221 | return false; |
222 | } | 222 | } |
223 | /* | 223 | /* |
224 | * Check ra->seq_number_bits against ra->file_size for consistency. | 224 | * Check ra->seq_number_bits against ra->file_size for consistency. |
@@ -233,24 +233,24 @@ static BOOL ntfs_check_restart_area(struct inode *vi, RESTART_PAGE_HEADER *rp) | |||
233 | if (le32_to_cpu(ra->seq_number_bits) != 67 - fs_bits) { | 233 | if (le32_to_cpu(ra->seq_number_bits) != 67 - fs_bits) { |
234 | ntfs_error(vi->i_sb, "$LogFile restart area specifies " | 234 | ntfs_error(vi->i_sb, "$LogFile restart area specifies " |
235 | "inconsistent sequence number bits."); | 235 | "inconsistent sequence number bits."); |
236 | return FALSE; | 236 | return false; |
237 | } | 237 | } |
238 | /* The log record header length must be a multiple of 8. */ | 238 | /* The log record header length must be a multiple of 8. */ |
239 | if (((le16_to_cpu(ra->log_record_header_length) + 7) & ~7) != | 239 | if (((le16_to_cpu(ra->log_record_header_length) + 7) & ~7) != |
240 | le16_to_cpu(ra->log_record_header_length)) { | 240 | le16_to_cpu(ra->log_record_header_length)) { |
241 | ntfs_error(vi->i_sb, "$LogFile restart area specifies " | 241 | ntfs_error(vi->i_sb, "$LogFile restart area specifies " |
242 | "inconsistent log record header length."); | 242 | "inconsistent log record header length."); |
243 | return FALSE; | 243 | return false; |
244 | } | 244 | } |
245 | /* Dito for the log page data offset. */ | 245 | /* Dito for the log page data offset. */ |
246 | if (((le16_to_cpu(ra->log_page_data_offset) + 7) & ~7) != | 246 | if (((le16_to_cpu(ra->log_page_data_offset) + 7) & ~7) != |
247 | le16_to_cpu(ra->log_page_data_offset)) { | 247 | le16_to_cpu(ra->log_page_data_offset)) { |
248 | ntfs_error(vi->i_sb, "$LogFile restart area specifies " | 248 | ntfs_error(vi->i_sb, "$LogFile restart area specifies " |
249 | "inconsistent log page data offset."); | 249 | "inconsistent log page data offset."); |
250 | return FALSE; | 250 | return false; |
251 | } | 251 | } |
252 | ntfs_debug("Done."); | 252 | ntfs_debug("Done."); |
253 | return TRUE; | 253 | return true; |
254 | } | 254 | } |
255 | 255 | ||
256 | /** | 256 | /** |
@@ -259,7 +259,7 @@ static BOOL ntfs_check_restart_area(struct inode *vi, RESTART_PAGE_HEADER *rp) | |||
259 | * @rp: restart page whose log client array to check | 259 | * @rp: restart page whose log client array to check |
260 | * | 260 | * |
261 | * Check the log client array of the restart page @rp for consistency and | 261 | * Check the log client array of the restart page @rp for consistency and |
262 | * return TRUE if it is consistent and FALSE otherwise. | 262 | * return 'true' if it is consistent and 'false' otherwise. |
263 | * | 263 | * |
264 | * This function assumes that the restart page header and the restart area have | 264 | * This function assumes that the restart page header and the restart area have |
265 | * already been consistency checked. | 265 | * already been consistency checked. |
@@ -268,13 +268,13 @@ static BOOL ntfs_check_restart_area(struct inode *vi, RESTART_PAGE_HEADER *rp) | |||
268 | * function needs @rp->system_page_size bytes in @rp, i.e. it requires the full | 268 | * function needs @rp->system_page_size bytes in @rp, i.e. it requires the full |
269 | * restart page and the page must be multi sector transfer deprotected. | 269 | * restart page and the page must be multi sector transfer deprotected. |
270 | */ | 270 | */ |
271 | static BOOL ntfs_check_log_client_array(struct inode *vi, | 271 | static bool ntfs_check_log_client_array(struct inode *vi, |
272 | RESTART_PAGE_HEADER *rp) | 272 | RESTART_PAGE_HEADER *rp) |
273 | { | 273 | { |
274 | RESTART_AREA *ra; | 274 | RESTART_AREA *ra; |
275 | LOG_CLIENT_RECORD *ca, *cr; | 275 | LOG_CLIENT_RECORD *ca, *cr; |
276 | u16 nr_clients, idx; | 276 | u16 nr_clients, idx; |
277 | BOOL in_free_list, idx_is_first; | 277 | bool in_free_list, idx_is_first; |
278 | 278 | ||
279 | ntfs_debug("Entering."); | 279 | ntfs_debug("Entering."); |
280 | ra = (RESTART_AREA*)((u8*)rp + le16_to_cpu(rp->restart_area_offset)); | 280 | ra = (RESTART_AREA*)((u8*)rp + le16_to_cpu(rp->restart_area_offset)); |
@@ -290,9 +290,9 @@ static BOOL ntfs_check_log_client_array(struct inode *vi, | |||
290 | */ | 290 | */ |
291 | nr_clients = le16_to_cpu(ra->log_clients); | 291 | nr_clients = le16_to_cpu(ra->log_clients); |
292 | idx = le16_to_cpu(ra->client_free_list); | 292 | idx = le16_to_cpu(ra->client_free_list); |
293 | in_free_list = TRUE; | 293 | in_free_list = true; |
294 | check_list: | 294 | check_list: |
295 | for (idx_is_first = TRUE; idx != LOGFILE_NO_CLIENT_CPU; nr_clients--, | 295 | for (idx_is_first = true; idx != LOGFILE_NO_CLIENT_CPU; nr_clients--, |
296 | idx = le16_to_cpu(cr->next_client)) { | 296 | idx = le16_to_cpu(cr->next_client)) { |
297 | if (!nr_clients || idx >= le16_to_cpu(ra->log_clients)) | 297 | if (!nr_clients || idx >= le16_to_cpu(ra->log_clients)) |
298 | goto err_out; | 298 | goto err_out; |
@@ -302,20 +302,20 @@ check_list: | |||
302 | if (idx_is_first) { | 302 | if (idx_is_first) { |
303 | if (cr->prev_client != LOGFILE_NO_CLIENT) | 303 | if (cr->prev_client != LOGFILE_NO_CLIENT) |
304 | goto err_out; | 304 | goto err_out; |
305 | idx_is_first = FALSE; | 305 | idx_is_first = false; |
306 | } | 306 | } |
307 | } | 307 | } |
308 | /* Switch to and check the in use list if we just did the free list. */ | 308 | /* Switch to and check the in use list if we just did the free list. */ |
309 | if (in_free_list) { | 309 | if (in_free_list) { |
310 | in_free_list = FALSE; | 310 | in_free_list = false; |
311 | idx = le16_to_cpu(ra->client_in_use_list); | 311 | idx = le16_to_cpu(ra->client_in_use_list); |
312 | goto check_list; | 312 | goto check_list; |
313 | } | 313 | } |
314 | ntfs_debug("Done."); | 314 | ntfs_debug("Done."); |
315 | return TRUE; | 315 | return true; |
316 | err_out: | 316 | err_out: |
317 | ntfs_error(vi->i_sb, "$LogFile log client array is corrupt."); | 317 | ntfs_error(vi->i_sb, "$LogFile log client array is corrupt."); |
318 | return FALSE; | 318 | return false; |
319 | } | 319 | } |
320 | 320 | ||
321 | /** | 321 | /** |
@@ -468,8 +468,8 @@ err_out: | |||
468 | * @log_vi: struct inode of loaded journal $LogFile to check | 468 | * @log_vi: struct inode of loaded journal $LogFile to check |
469 | * @rp: [OUT] on success this is a copy of the current restart page | 469 | * @rp: [OUT] on success this is a copy of the current restart page |
470 | * | 470 | * |
471 | * Check the $LogFile journal for consistency and return TRUE if it is | 471 | * Check the $LogFile journal for consistency and return 'true' if it is |
472 | * consistent and FALSE if not. On success, the current restart page is | 472 | * consistent and 'false' if not. On success, the current restart page is |
473 | * returned in *@rp. Caller must call ntfs_free(*@rp) when finished with it. | 473 | * returned in *@rp. Caller must call ntfs_free(*@rp) when finished with it. |
474 | * | 474 | * |
475 | * At present we only check the two restart pages and ignore the log record | 475 | * At present we only check the two restart pages and ignore the log record |
@@ -480,7 +480,7 @@ err_out: | |||
480 | * if the $LogFile was created on a system with a different page size to ours | 480 | * if the $LogFile was created on a system with a different page size to ours |
481 | * yet and mst deprotection would fail if our page size is smaller. | 481 | * yet and mst deprotection would fail if our page size is smaller. |
482 | */ | 482 | */ |
483 | BOOL ntfs_check_logfile(struct inode *log_vi, RESTART_PAGE_HEADER **rp) | 483 | bool ntfs_check_logfile(struct inode *log_vi, RESTART_PAGE_HEADER **rp) |
484 | { | 484 | { |
485 | s64 size, pos; | 485 | s64 size, pos; |
486 | LSN rstr1_lsn, rstr2_lsn; | 486 | LSN rstr1_lsn, rstr2_lsn; |
@@ -491,7 +491,7 @@ BOOL ntfs_check_logfile(struct inode *log_vi, RESTART_PAGE_HEADER **rp) | |||
491 | RESTART_PAGE_HEADER *rstr1_ph = NULL; | 491 | RESTART_PAGE_HEADER *rstr1_ph = NULL; |
492 | RESTART_PAGE_HEADER *rstr2_ph = NULL; | 492 | RESTART_PAGE_HEADER *rstr2_ph = NULL; |
493 | int log_page_size, log_page_mask, err; | 493 | int log_page_size, log_page_mask, err; |
494 | BOOL logfile_is_empty = TRUE; | 494 | bool logfile_is_empty = true; |
495 | u8 log_page_bits; | 495 | u8 log_page_bits; |
496 | 496 | ||
497 | ntfs_debug("Entering."); | 497 | ntfs_debug("Entering."); |
@@ -527,7 +527,7 @@ BOOL ntfs_check_logfile(struct inode *log_vi, RESTART_PAGE_HEADER **rp) | |||
527 | if (size < log_page_size * 2 || (size - log_page_size * 2) >> | 527 | if (size < log_page_size * 2 || (size - log_page_size * 2) >> |
528 | log_page_bits < MinLogRecordPages) { | 528 | log_page_bits < MinLogRecordPages) { |
529 | ntfs_error(vol->sb, "$LogFile is too small."); | 529 | ntfs_error(vol->sb, "$LogFile is too small."); |
530 | return FALSE; | 530 | return false; |
531 | } | 531 | } |
532 | /* | 532 | /* |
533 | * Read through the file looking for a restart page. Since the restart | 533 | * Read through the file looking for a restart page. Since the restart |
@@ -556,7 +556,7 @@ BOOL ntfs_check_logfile(struct inode *log_vi, RESTART_PAGE_HEADER **rp) | |||
556 | * means we are done. | 556 | * means we are done. |
557 | */ | 557 | */ |
558 | if (!ntfs_is_empty_recordp((le32*)kaddr)) | 558 | if (!ntfs_is_empty_recordp((le32*)kaddr)) |
559 | logfile_is_empty = FALSE; | 559 | logfile_is_empty = false; |
560 | else if (!logfile_is_empty) | 560 | else if (!logfile_is_empty) |
561 | break; | 561 | break; |
562 | /* | 562 | /* |
@@ -615,13 +615,13 @@ BOOL ntfs_check_logfile(struct inode *log_vi, RESTART_PAGE_HEADER **rp) | |||
615 | NVolSetLogFileEmpty(vol); | 615 | NVolSetLogFileEmpty(vol); |
616 | is_empty: | 616 | is_empty: |
617 | ntfs_debug("Done. ($LogFile is empty.)"); | 617 | ntfs_debug("Done. ($LogFile is empty.)"); |
618 | return TRUE; | 618 | return true; |
619 | } | 619 | } |
620 | if (!rstr1_ph) { | 620 | if (!rstr1_ph) { |
621 | BUG_ON(rstr2_ph); | 621 | BUG_ON(rstr2_ph); |
622 | ntfs_error(vol->sb, "Did not find any restart pages in " | 622 | ntfs_error(vol->sb, "Did not find any restart pages in " |
623 | "$LogFile and it was not empty."); | 623 | "$LogFile and it was not empty."); |
624 | return FALSE; | 624 | return false; |
625 | } | 625 | } |
626 | /* If both restart pages were found, use the more recent one. */ | 626 | /* If both restart pages were found, use the more recent one. */ |
627 | if (rstr2_ph) { | 627 | if (rstr2_ph) { |
@@ -648,11 +648,11 @@ is_empty: | |||
648 | else | 648 | else |
649 | ntfs_free(rstr1_ph); | 649 | ntfs_free(rstr1_ph); |
650 | ntfs_debug("Done."); | 650 | ntfs_debug("Done."); |
651 | return TRUE; | 651 | return true; |
652 | err_out: | 652 | err_out: |
653 | if (rstr1_ph) | 653 | if (rstr1_ph) |
654 | ntfs_free(rstr1_ph); | 654 | ntfs_free(rstr1_ph); |
655 | return FALSE; | 655 | return false; |
656 | } | 656 | } |
657 | 657 | ||
658 | /** | 658 | /** |
@@ -660,8 +660,8 @@ err_out: | |||
660 | * @log_vi: struct inode of loaded journal $LogFile to check | 660 | * @log_vi: struct inode of loaded journal $LogFile to check |
661 | * @rp: copy of the current restart page | 661 | * @rp: copy of the current restart page |
662 | * | 662 | * |
663 | * Analyze the $LogFile journal and return TRUE if it indicates the volume was | 663 | * Analyze the $LogFile journal and return 'true' if it indicates the volume was |
664 | * shutdown cleanly and FALSE if not. | 664 | * shutdown cleanly and 'false' if not. |
665 | * | 665 | * |
666 | * At present we only look at the two restart pages and ignore the log record | 666 | * At present we only look at the two restart pages and ignore the log record |
667 | * pages. This is a little bit crude in that there will be a very small number | 667 | * pages. This is a little bit crude in that there will be a very small number |
@@ -675,7 +675,7 @@ err_out: | |||
675 | * is empty this function requires that NVolLogFileEmpty() is true otherwise an | 675 | * is empty this function requires that NVolLogFileEmpty() is true otherwise an |
676 | * empty volume will be reported as dirty. | 676 | * empty volume will be reported as dirty. |
677 | */ | 677 | */ |
678 | BOOL ntfs_is_logfile_clean(struct inode *log_vi, const RESTART_PAGE_HEADER *rp) | 678 | bool ntfs_is_logfile_clean(struct inode *log_vi, const RESTART_PAGE_HEADER *rp) |
679 | { | 679 | { |
680 | ntfs_volume *vol = NTFS_SB(log_vi->i_sb); | 680 | ntfs_volume *vol = NTFS_SB(log_vi->i_sb); |
681 | RESTART_AREA *ra; | 681 | RESTART_AREA *ra; |
@@ -684,7 +684,7 @@ BOOL ntfs_is_logfile_clean(struct inode *log_vi, const RESTART_PAGE_HEADER *rp) | |||
684 | /* An empty $LogFile must have been clean before it got emptied. */ | 684 | /* An empty $LogFile must have been clean before it got emptied. */ |
685 | if (NVolLogFileEmpty(vol)) { | 685 | if (NVolLogFileEmpty(vol)) { |
686 | ntfs_debug("Done. ($LogFile is empty.)"); | 686 | ntfs_debug("Done. ($LogFile is empty.)"); |
687 | return TRUE; | 687 | return true; |
688 | } | 688 | } |
689 | BUG_ON(!rp); | 689 | BUG_ON(!rp); |
690 | if (!ntfs_is_rstr_record(rp->magic) && | 690 | if (!ntfs_is_rstr_record(rp->magic) && |
@@ -693,7 +693,7 @@ BOOL ntfs_is_logfile_clean(struct inode *log_vi, const RESTART_PAGE_HEADER *rp) | |||
693 | "probably a bug in that the $LogFile should " | 693 | "probably a bug in that the $LogFile should " |
694 | "have been consistency checked before calling " | 694 | "have been consistency checked before calling " |
695 | "this function."); | 695 | "this function."); |
696 | return FALSE; | 696 | return false; |
697 | } | 697 | } |
698 | ra = (RESTART_AREA*)((u8*)rp + le16_to_cpu(rp->restart_area_offset)); | 698 | ra = (RESTART_AREA*)((u8*)rp + le16_to_cpu(rp->restart_area_offset)); |
699 | /* | 699 | /* |
@@ -704,25 +704,25 @@ BOOL ntfs_is_logfile_clean(struct inode *log_vi, const RESTART_PAGE_HEADER *rp) | |||
704 | if (ra->client_in_use_list != LOGFILE_NO_CLIENT && | 704 | if (ra->client_in_use_list != LOGFILE_NO_CLIENT && |
705 | !(ra->flags & RESTART_VOLUME_IS_CLEAN)) { | 705 | !(ra->flags & RESTART_VOLUME_IS_CLEAN)) { |
706 | ntfs_debug("Done. $LogFile indicates a dirty shutdown."); | 706 | ntfs_debug("Done. $LogFile indicates a dirty shutdown."); |
707 | return FALSE; | 707 | return false; |
708 | } | 708 | } |
709 | /* $LogFile indicates a clean shutdown. */ | 709 | /* $LogFile indicates a clean shutdown. */ |
710 | ntfs_debug("Done. $LogFile indicates a clean shutdown."); | 710 | ntfs_debug("Done. $LogFile indicates a clean shutdown."); |
711 | return TRUE; | 711 | return true; |
712 | } | 712 | } |
713 | 713 | ||
714 | /** | 714 | /** |
715 | * ntfs_empty_logfile - empty the contents of the $LogFile journal | 715 | * ntfs_empty_logfile - empty the contents of the $LogFile journal |
716 | * @log_vi: struct inode of loaded journal $LogFile to empty | 716 | * @log_vi: struct inode of loaded journal $LogFile to empty |
717 | * | 717 | * |
718 | * Empty the contents of the $LogFile journal @log_vi and return TRUE on | 718 | * Empty the contents of the $LogFile journal @log_vi and return 'true' on |
719 | * success and FALSE on error. | 719 | * success and 'false' on error. |
720 | * | 720 | * |
721 | * This function assumes that the $LogFile journal has already been consistency | 721 | * This function assumes that the $LogFile journal has already been consistency |
722 | * checked by a call to ntfs_check_logfile() and that ntfs_is_logfile_clean() | 722 | * checked by a call to ntfs_check_logfile() and that ntfs_is_logfile_clean() |
723 | * has been used to ensure that the $LogFile is clean. | 723 | * has been used to ensure that the $LogFile is clean. |
724 | */ | 724 | */ |
725 | BOOL ntfs_empty_logfile(struct inode *log_vi) | 725 | bool ntfs_empty_logfile(struct inode *log_vi) |
726 | { | 726 | { |
727 | ntfs_volume *vol = NTFS_SB(log_vi->i_sb); | 727 | ntfs_volume *vol = NTFS_SB(log_vi->i_sb); |
728 | 728 | ||
@@ -735,13 +735,13 @@ BOOL ntfs_empty_logfile(struct inode *log_vi) | |||
735 | if (unlikely(err)) { | 735 | if (unlikely(err)) { |
736 | ntfs_error(vol->sb, "Failed to fill $LogFile with " | 736 | ntfs_error(vol->sb, "Failed to fill $LogFile with " |
737 | "0xff bytes (error code %i).", err); | 737 | "0xff bytes (error code %i).", err); |
738 | return FALSE; | 738 | return false; |
739 | } | 739 | } |
740 | /* Set the flag so we do not have to do it again on remount. */ | 740 | /* Set the flag so we do not have to do it again on remount. */ |
741 | NVolSetLogFileEmpty(vol); | 741 | NVolSetLogFileEmpty(vol); |
742 | } | 742 | } |
743 | ntfs_debug("Done."); | 743 | ntfs_debug("Done."); |
744 | return TRUE; | 744 | return true; |
745 | } | 745 | } |
746 | 746 | ||
747 | #endif /* NTFS_RW */ | 747 | #endif /* NTFS_RW */ |
diff --git a/fs/ntfs/logfile.h b/fs/ntfs/logfile.h index a51f3dd0e9eb..9468e1c45ae3 100644 --- a/fs/ntfs/logfile.h +++ b/fs/ntfs/logfile.h | |||
@@ -296,13 +296,13 @@ typedef struct { | |||
296 | /* sizeof() = 160 (0xa0) bytes */ | 296 | /* sizeof() = 160 (0xa0) bytes */ |
297 | } __attribute__ ((__packed__)) LOG_CLIENT_RECORD; | 297 | } __attribute__ ((__packed__)) LOG_CLIENT_RECORD; |
298 | 298 | ||
299 | extern BOOL ntfs_check_logfile(struct inode *log_vi, | 299 | extern bool ntfs_check_logfile(struct inode *log_vi, |
300 | RESTART_PAGE_HEADER **rp); | 300 | RESTART_PAGE_HEADER **rp); |
301 | 301 | ||
302 | extern BOOL ntfs_is_logfile_clean(struct inode *log_vi, | 302 | extern bool ntfs_is_logfile_clean(struct inode *log_vi, |
303 | const RESTART_PAGE_HEADER *rp); | 303 | const RESTART_PAGE_HEADER *rp); |
304 | 304 | ||
305 | extern BOOL ntfs_empty_logfile(struct inode *log_vi); | 305 | extern bool ntfs_empty_logfile(struct inode *log_vi); |
306 | 306 | ||
307 | #endif /* NTFS_RW */ | 307 | #endif /* NTFS_RW */ |
308 | 308 | ||
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index 584260fd6848..2ad5c8b104b9 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c | |||
@@ -251,7 +251,7 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref, | |||
251 | int i; | 251 | int i; |
252 | unsigned long mft_no = MREF(mref); | 252 | unsigned long mft_no = MREF(mref); |
253 | u16 seq_no = MSEQNO(mref); | 253 | u16 seq_no = MSEQNO(mref); |
254 | BOOL destroy_ni = FALSE; | 254 | bool destroy_ni = false; |
255 | 255 | ||
256 | ntfs_debug("Mapping extent mft record 0x%lx (base mft record 0x%lx).", | 256 | ntfs_debug("Mapping extent mft record 0x%lx (base mft record 0x%lx).", |
257 | mft_no, base_ni->mft_no); | 257 | mft_no, base_ni->mft_no); |
@@ -322,7 +322,7 @@ map_err_out: | |||
322 | if (seq_no && (le16_to_cpu(m->sequence_number) != seq_no)) { | 322 | if (seq_no && (le16_to_cpu(m->sequence_number) != seq_no)) { |
323 | ntfs_error(base_ni->vol->sb, "Found stale extent mft " | 323 | ntfs_error(base_ni->vol->sb, "Found stale extent mft " |
324 | "reference! Corrupt filesystem. Run chkdsk."); | 324 | "reference! Corrupt filesystem. Run chkdsk."); |
325 | destroy_ni = TRUE; | 325 | destroy_ni = true; |
326 | m = ERR_PTR(-EIO); | 326 | m = ERR_PTR(-EIO); |
327 | goto unm_err_out; | 327 | goto unm_err_out; |
328 | } | 328 | } |
@@ -335,7 +335,7 @@ map_err_out: | |||
335 | if (unlikely(!tmp)) { | 335 | if (unlikely(!tmp)) { |
336 | ntfs_error(base_ni->vol->sb, "Failed to allocate " | 336 | ntfs_error(base_ni->vol->sb, "Failed to allocate " |
337 | "internal buffer."); | 337 | "internal buffer."); |
338 | destroy_ni = TRUE; | 338 | destroy_ni = true; |
339 | m = ERR_PTR(-ENOMEM); | 339 | m = ERR_PTR(-ENOMEM); |
340 | goto unm_err_out; | 340 | goto unm_err_out; |
341 | } | 341 | } |
@@ -857,7 +857,7 @@ err_out: | |||
857 | * caller is responsible for unlocking the ntfs inode and unpinning the base | 857 | * caller is responsible for unlocking the ntfs inode and unpinning the base |
858 | * vfs inode. | 858 | * vfs inode. |
859 | * | 859 | * |
860 | * Return TRUE if the mft record may be written out and FALSE if not. | 860 | * Return 'true' if the mft record may be written out and 'false' if not. |
861 | * | 861 | * |
862 | * The caller has locked the page and cleared the uptodate flag on it which | 862 | * The caller has locked the page and cleared the uptodate flag on it which |
863 | * means that we can safely write out any dirty mft records that do not have | 863 | * means that we can safely write out any dirty mft records that do not have |
@@ -868,7 +868,7 @@ err_out: | |||
868 | * Here is a description of the tests we perform: | 868 | * Here is a description of the tests we perform: |
869 | * | 869 | * |
870 | * If the inode is found in icache we know the mft record must be a base mft | 870 | * If the inode is found in icache we know the mft record must be a base mft |
871 | * record. If it is dirty, we do not write it and return FALSE as the vfs | 871 | * record. If it is dirty, we do not write it and return 'false' as the vfs |
872 | * inode write paths will result in the access times being updated which would | 872 | * inode write paths will result in the access times being updated which would |
873 | * cause the base mft record to be redirtied and written out again. (We know | 873 | * cause the base mft record to be redirtied and written out again. (We know |
874 | * the access time update will modify the base mft record because Windows | 874 | * the access time update will modify the base mft record because Windows |
@@ -877,11 +877,11 @@ err_out: | |||
877 | * | 877 | * |
878 | * If the inode is in icache and not dirty, we attempt to lock the mft record | 878 | * If the inode is in icache and not dirty, we attempt to lock the mft record |
879 | * and if we find the lock was already taken, it is not safe to write the mft | 879 | * and if we find the lock was already taken, it is not safe to write the mft |
880 | * record and we return FALSE. | 880 | * record and we return 'false'. |
881 | * | 881 | * |
882 | * If we manage to obtain the lock we have exclusive access to the mft record, | 882 | * If we manage to obtain the lock we have exclusive access to the mft record, |
883 | * which also allows us safe writeout of the mft record. We then set | 883 | * which also allows us safe writeout of the mft record. We then set |
884 | * @locked_ni to the locked ntfs inode and return TRUE. | 884 | * @locked_ni to the locked ntfs inode and return 'true'. |
885 | * | 885 | * |
886 | * Note we cannot just lock the mft record and sleep while waiting for the lock | 886 | * Note we cannot just lock the mft record and sleep while waiting for the lock |
887 | * because this would deadlock due to lock reversal (normally the mft record is | 887 | * because this would deadlock due to lock reversal (normally the mft record is |
@@ -891,24 +891,24 @@ err_out: | |||
891 | * If the inode is not in icache we need to perform further checks. | 891 | * If the inode is not in icache we need to perform further checks. |
892 | * | 892 | * |
893 | * If the mft record is not a FILE record or it is a base mft record, we can | 893 | * If the mft record is not a FILE record or it is a base mft record, we can |
894 | * safely write it and return TRUE. | 894 | * safely write it and return 'true'. |
895 | * | 895 | * |
896 | * We now know the mft record is an extent mft record. We check if the inode | 896 | * We now know the mft record is an extent mft record. We check if the inode |
897 | * corresponding to its base mft record is in icache and obtain a reference to | 897 | * corresponding to its base mft record is in icache and obtain a reference to |
898 | * it if it is. If it is not, we can safely write it and return TRUE. | 898 | * it if it is. If it is not, we can safely write it and return 'true'. |
899 | * | 899 | * |
900 | * We now have the base inode for the extent mft record. We check if it has an | 900 | * We now have the base inode for the extent mft record. We check if it has an |
901 | * ntfs inode for the extent mft record attached and if not it is safe to write | 901 | * ntfs inode for the extent mft record attached and if not it is safe to write |
902 | * the extent mft record and we return TRUE. | 902 | * the extent mft record and we return 'true'. |
903 | * | 903 | * |
904 | * The ntfs inode for the extent mft record is attached to the base inode so we | 904 | * The ntfs inode for the extent mft record is attached to the base inode so we |
905 | * attempt to lock the extent mft record and if we find the lock was already | 905 | * attempt to lock the extent mft record and if we find the lock was already |
906 | * taken, it is not safe to write the extent mft record and we return FALSE. | 906 | * taken, it is not safe to write the extent mft record and we return 'false'. |
907 | * | 907 | * |
908 | * If we manage to obtain the lock we have exclusive access to the extent mft | 908 | * If we manage to obtain the lock we have exclusive access to the extent mft |
909 | * record, which also allows us safe writeout of the extent mft record. We | 909 | * record, which also allows us safe writeout of the extent mft record. We |
910 | * set the ntfs inode of the extent mft record clean and then set @locked_ni to | 910 | * set the ntfs inode of the extent mft record clean and then set @locked_ni to |
911 | * the now locked ntfs inode and return TRUE. | 911 | * the now locked ntfs inode and return 'true'. |
912 | * | 912 | * |
913 | * Note, the reason for actually writing dirty mft records here and not just | 913 | * Note, the reason for actually writing dirty mft records here and not just |
914 | * relying on the vfs inode dirty code paths is that we can have mft records | 914 | * relying on the vfs inode dirty code paths is that we can have mft records |
@@ -922,7 +922,7 @@ err_out: | |||
922 | * appear if the mft record is reused for a new inode before it got written | 922 | * appear if the mft record is reused for a new inode before it got written |
923 | * out. | 923 | * out. |
924 | */ | 924 | */ |
925 | BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | 925 | bool ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, |
926 | const MFT_RECORD *m, ntfs_inode **locked_ni) | 926 | const MFT_RECORD *m, ntfs_inode **locked_ni) |
927 | { | 927 | { |
928 | struct super_block *sb = vol->sb; | 928 | struct super_block *sb = vol->sb; |
@@ -977,7 +977,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | |||
977 | mft_no); | 977 | mft_no); |
978 | atomic_dec(&ni->count); | 978 | atomic_dec(&ni->count); |
979 | iput(vi); | 979 | iput(vi); |
980 | return FALSE; | 980 | return false; |
981 | } | 981 | } |
982 | ntfs_debug("Inode 0x%lx is not dirty.", mft_no); | 982 | ntfs_debug("Inode 0x%lx is not dirty.", mft_no); |
983 | /* The inode is not dirty, try to take the mft record lock. */ | 983 | /* The inode is not dirty, try to take the mft record lock. */ |
@@ -986,7 +986,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | |||
986 | "not write it.", mft_no); | 986 | "not write it.", mft_no); |
987 | atomic_dec(&ni->count); | 987 | atomic_dec(&ni->count); |
988 | iput(vi); | 988 | iput(vi); |
989 | return FALSE; | 989 | return false; |
990 | } | 990 | } |
991 | ntfs_debug("Managed to lock mft record 0x%lx, write it.", | 991 | ntfs_debug("Managed to lock mft record 0x%lx, write it.", |
992 | mft_no); | 992 | mft_no); |
@@ -995,7 +995,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | |||
995 | * return the locked ntfs inode. | 995 | * return the locked ntfs inode. |
996 | */ | 996 | */ |
997 | *locked_ni = ni; | 997 | *locked_ni = ni; |
998 | return TRUE; | 998 | return true; |
999 | } | 999 | } |
1000 | ntfs_debug("Inode 0x%lx is not in icache.", mft_no); | 1000 | ntfs_debug("Inode 0x%lx is not in icache.", mft_no); |
1001 | /* The inode is not in icache. */ | 1001 | /* The inode is not in icache. */ |
@@ -1003,13 +1003,13 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | |||
1003 | if (!ntfs_is_mft_record(m->magic)) { | 1003 | if (!ntfs_is_mft_record(m->magic)) { |
1004 | ntfs_debug("Mft record 0x%lx is not a FILE record, write it.", | 1004 | ntfs_debug("Mft record 0x%lx is not a FILE record, write it.", |
1005 | mft_no); | 1005 | mft_no); |
1006 | return TRUE; | 1006 | return true; |
1007 | } | 1007 | } |
1008 | /* Write the mft record if it is a base inode. */ | 1008 | /* Write the mft record if it is a base inode. */ |
1009 | if (!m->base_mft_record) { | 1009 | if (!m->base_mft_record) { |
1010 | ntfs_debug("Mft record 0x%lx is a base record, write it.", | 1010 | ntfs_debug("Mft record 0x%lx is a base record, write it.", |
1011 | mft_no); | 1011 | mft_no); |
1012 | return TRUE; | 1012 | return true; |
1013 | } | 1013 | } |
1014 | /* | 1014 | /* |
1015 | * This is an extent mft record. Check if the inode corresponding to | 1015 | * This is an extent mft record. Check if the inode corresponding to |
@@ -1033,7 +1033,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | |||
1033 | */ | 1033 | */ |
1034 | ntfs_debug("Base inode 0x%lx is not in icache, write the " | 1034 | ntfs_debug("Base inode 0x%lx is not in icache, write the " |
1035 | "extent record.", na.mft_no); | 1035 | "extent record.", na.mft_no); |
1036 | return TRUE; | 1036 | return true; |
1037 | } | 1037 | } |
1038 | ntfs_debug("Base inode 0x%lx is in icache.", na.mft_no); | 1038 | ntfs_debug("Base inode 0x%lx is in icache.", na.mft_no); |
1039 | /* | 1039 | /* |
@@ -1051,7 +1051,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | |||
1051 | iput(vi); | 1051 | iput(vi); |
1052 | ntfs_debug("Base inode 0x%lx has no attached extent inodes, " | 1052 | ntfs_debug("Base inode 0x%lx has no attached extent inodes, " |
1053 | "write the extent record.", na.mft_no); | 1053 | "write the extent record.", na.mft_no); |
1054 | return TRUE; | 1054 | return true; |
1055 | } | 1055 | } |
1056 | /* Iterate over the attached extent inodes. */ | 1056 | /* Iterate over the attached extent inodes. */ |
1057 | extent_nis = ni->ext.extent_ntfs_inos; | 1057 | extent_nis = ni->ext.extent_ntfs_inos; |
@@ -1075,7 +1075,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | |||
1075 | ntfs_debug("Extent inode 0x%lx is not attached to its base " | 1075 | ntfs_debug("Extent inode 0x%lx is not attached to its base " |
1076 | "inode 0x%lx, write the extent record.", | 1076 | "inode 0x%lx, write the extent record.", |
1077 | mft_no, na.mft_no); | 1077 | mft_no, na.mft_no); |
1078 | return TRUE; | 1078 | return true; |
1079 | } | 1079 | } |
1080 | ntfs_debug("Extent inode 0x%lx is attached to its base inode 0x%lx.", | 1080 | ntfs_debug("Extent inode 0x%lx is attached to its base inode 0x%lx.", |
1081 | mft_no, na.mft_no); | 1081 | mft_no, na.mft_no); |
@@ -1091,7 +1091,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | |||
1091 | iput(vi); | 1091 | iput(vi); |
1092 | ntfs_debug("Extent mft record 0x%lx is already locked, do " | 1092 | ntfs_debug("Extent mft record 0x%lx is already locked, do " |
1093 | "not write it.", mft_no); | 1093 | "not write it.", mft_no); |
1094 | return FALSE; | 1094 | return false; |
1095 | } | 1095 | } |
1096 | ntfs_debug("Managed to lock extent mft record 0x%lx, write it.", | 1096 | ntfs_debug("Managed to lock extent mft record 0x%lx, write it.", |
1097 | mft_no); | 1097 | mft_no); |
@@ -1103,7 +1103,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | |||
1103 | * the locked extent ntfs inode. | 1103 | * the locked extent ntfs inode. |
1104 | */ | 1104 | */ |
1105 | *locked_ni = eni; | 1105 | *locked_ni = eni; |
1106 | return TRUE; | 1106 | return true; |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | static const char *es = " Leaving inconsistent metadata. Unmount and run " | 1109 | static const char *es = " Leaving inconsistent metadata. Unmount and run " |
@@ -1354,7 +1354,7 @@ static int ntfs_mft_bitmap_extend_allocation_nolock(ntfs_volume *vol) | |||
1354 | ntfs_unmap_page(page); | 1354 | ntfs_unmap_page(page); |
1355 | /* Allocate a cluster from the DATA_ZONE. */ | 1355 | /* Allocate a cluster from the DATA_ZONE. */ |
1356 | rl2 = ntfs_cluster_alloc(vol, rl[1].vcn, 1, lcn, DATA_ZONE, | 1356 | rl2 = ntfs_cluster_alloc(vol, rl[1].vcn, 1, lcn, DATA_ZONE, |
1357 | TRUE); | 1357 | true); |
1358 | if (IS_ERR(rl2)) { | 1358 | if (IS_ERR(rl2)) { |
1359 | up_write(&mftbmp_ni->runlist.lock); | 1359 | up_write(&mftbmp_ni->runlist.lock); |
1360 | ntfs_error(vol->sb, "Failed to allocate a cluster for " | 1360 | ntfs_error(vol->sb, "Failed to allocate a cluster for " |
@@ -1724,7 +1724,7 @@ static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol) | |||
1724 | ATTR_RECORD *a = NULL; | 1724 | ATTR_RECORD *a = NULL; |
1725 | int ret, mp_size; | 1725 | int ret, mp_size; |
1726 | u32 old_alen = 0; | 1726 | u32 old_alen = 0; |
1727 | BOOL mp_rebuilt = FALSE; | 1727 | bool mp_rebuilt = false; |
1728 | 1728 | ||
1729 | ntfs_debug("Extending mft data allocation."); | 1729 | ntfs_debug("Extending mft data allocation."); |
1730 | mft_ni = NTFS_I(vol->mft_ino); | 1730 | mft_ni = NTFS_I(vol->mft_ino); |
@@ -1780,7 +1780,7 @@ static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol) | |||
1780 | old_last_vcn = rl[1].vcn; | 1780 | old_last_vcn = rl[1].vcn; |
1781 | do { | 1781 | do { |
1782 | rl2 = ntfs_cluster_alloc(vol, old_last_vcn, nr, lcn, MFT_ZONE, | 1782 | rl2 = ntfs_cluster_alloc(vol, old_last_vcn, nr, lcn, MFT_ZONE, |
1783 | TRUE); | 1783 | true); |
1784 | if (likely(!IS_ERR(rl2))) | 1784 | if (likely(!IS_ERR(rl2))) |
1785 | break; | 1785 | break; |
1786 | if (PTR_ERR(rl2) != -ENOSPC || nr == min_nr) { | 1786 | if (PTR_ERR(rl2) != -ENOSPC || nr == min_nr) { |
@@ -1884,7 +1884,7 @@ static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol) | |||
1884 | ret = -EOPNOTSUPP; | 1884 | ret = -EOPNOTSUPP; |
1885 | goto undo_alloc; | 1885 | goto undo_alloc; |
1886 | } | 1886 | } |
1887 | mp_rebuilt = TRUE; | 1887 | mp_rebuilt = true; |
1888 | /* Generate the mapping pairs array directly into the attr record. */ | 1888 | /* Generate the mapping pairs array directly into the attr record. */ |
1889 | ret = ntfs_mapping_pairs_build(vol, (u8*)a + | 1889 | ret = ntfs_mapping_pairs_build(vol, (u8*)a + |
1890 | le16_to_cpu(a->data.non_resident.mapping_pairs_offset), | 1890 | le16_to_cpu(a->data.non_resident.mapping_pairs_offset), |
@@ -2255,7 +2255,7 @@ ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, const int mode, | |||
2255 | unsigned int ofs; | 2255 | unsigned int ofs; |
2256 | int err; | 2256 | int err; |
2257 | le16 seq_no, usn; | 2257 | le16 seq_no, usn; |
2258 | BOOL record_formatted = FALSE; | 2258 | bool record_formatted = false; |
2259 | 2259 | ||
2260 | if (base_ni) { | 2260 | if (base_ni) { |
2261 | ntfs_debug("Entering (allocating an extent mft record for " | 2261 | ntfs_debug("Entering (allocating an extent mft record for " |
@@ -2454,7 +2454,7 @@ have_alloc_rec: | |||
2454 | mft_ni->initialized_size = new_initialized_size; | 2454 | mft_ni->initialized_size = new_initialized_size; |
2455 | } | 2455 | } |
2456 | write_unlock_irqrestore(&mft_ni->size_lock, flags); | 2456 | write_unlock_irqrestore(&mft_ni->size_lock, flags); |
2457 | record_formatted = TRUE; | 2457 | record_formatted = true; |
2458 | /* Update the mft data attribute record to reflect the new sizes. */ | 2458 | /* Update the mft data attribute record to reflect the new sizes. */ |
2459 | m = map_mft_record(mft_ni); | 2459 | m = map_mft_record(mft_ni); |
2460 | if (IS_ERR(m)) { | 2460 | if (IS_ERR(m)) { |
diff --git a/fs/ntfs/mft.h b/fs/ntfs/mft.h index 639cd1bab08b..b52bf87b99de 100644 --- a/fs/ntfs/mft.h +++ b/fs/ntfs/mft.h | |||
@@ -111,7 +111,7 @@ static inline int write_mft_record(ntfs_inode *ni, MFT_RECORD *m, int sync) | |||
111 | return err; | 111 | return err; |
112 | } | 112 | } |
113 | 113 | ||
114 | extern BOOL ntfs_may_write_mft_record(ntfs_volume *vol, | 114 | extern bool ntfs_may_write_mft_record(ntfs_volume *vol, |
115 | const unsigned long mft_no, const MFT_RECORD *m, | 115 | const unsigned long mft_no, const MFT_RECORD *m, |
116 | ntfs_inode **locked_ni); | 116 | ntfs_inode **locked_ni); |
117 | 117 | ||
diff --git a/fs/ntfs/ntfs.h b/fs/ntfs/ntfs.h index ddd3d503097c..a12847ae467d 100644 --- a/fs/ntfs/ntfs.h +++ b/fs/ntfs/ntfs.h | |||
@@ -105,7 +105,7 @@ extern int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size); | |||
105 | extern void post_write_mst_fixup(NTFS_RECORD *b); | 105 | extern void post_write_mst_fixup(NTFS_RECORD *b); |
106 | 106 | ||
107 | /* From fs/ntfs/unistr.c */ | 107 | /* From fs/ntfs/unistr.c */ |
108 | extern BOOL ntfs_are_names_equal(const ntfschar *s1, size_t s1_len, | 108 | extern bool ntfs_are_names_equal(const ntfschar *s1, size_t s1_len, |
109 | const ntfschar *s2, size_t s2_len, | 109 | const ntfschar *s2, size_t s2_len, |
110 | const IGNORE_CASE_BOOL ic, | 110 | const IGNORE_CASE_BOOL ic, |
111 | const ntfschar *upcase, const u32 upcase_size); | 111 | const ntfschar *upcase, const u32 upcase_size); |
diff --git a/fs/ntfs/quota.c b/fs/ntfs/quota.c index d0ef4182147b..d80e3315cab0 100644 --- a/fs/ntfs/quota.c +++ b/fs/ntfs/quota.c | |||
@@ -31,10 +31,10 @@ | |||
31 | * ntfs_mark_quotas_out_of_date - mark the quotas out of date on an ntfs volume | 31 | * ntfs_mark_quotas_out_of_date - mark the quotas out of date on an ntfs volume |
32 | * @vol: ntfs volume on which to mark the quotas out of date | 32 | * @vol: ntfs volume on which to mark the quotas out of date |
33 | * | 33 | * |
34 | * Mark the quotas out of date on the ntfs volume @vol and return TRUE on | 34 | * Mark the quotas out of date on the ntfs volume @vol and return 'true' on |
35 | * success and FALSE on error. | 35 | * success and 'false' on error. |
36 | */ | 36 | */ |
37 | BOOL ntfs_mark_quotas_out_of_date(ntfs_volume *vol) | 37 | bool ntfs_mark_quotas_out_of_date(ntfs_volume *vol) |
38 | { | 38 | { |
39 | ntfs_index_context *ictx; | 39 | ntfs_index_context *ictx; |
40 | QUOTA_CONTROL_ENTRY *qce; | 40 | QUOTA_CONTROL_ENTRY *qce; |
@@ -46,7 +46,7 @@ BOOL ntfs_mark_quotas_out_of_date(ntfs_volume *vol) | |||
46 | goto done; | 46 | goto done; |
47 | if (!vol->quota_ino || !vol->quota_q_ino) { | 47 | if (!vol->quota_ino || !vol->quota_q_ino) { |
48 | ntfs_error(vol->sb, "Quota inodes are not open."); | 48 | ntfs_error(vol->sb, "Quota inodes are not open."); |
49 | return FALSE; | 49 | return false; |
50 | } | 50 | } |
51 | mutex_lock(&vol->quota_q_ino->i_mutex); | 51 | mutex_lock(&vol->quota_q_ino->i_mutex); |
52 | ictx = ntfs_index_ctx_get(NTFS_I(vol->quota_q_ino)); | 52 | ictx = ntfs_index_ctx_get(NTFS_I(vol->quota_q_ino)); |
@@ -106,12 +106,12 @@ set_done: | |||
106 | NVolSetQuotaOutOfDate(vol); | 106 | NVolSetQuotaOutOfDate(vol); |
107 | done: | 107 | done: |
108 | ntfs_debug("Done."); | 108 | ntfs_debug("Done."); |
109 | return TRUE; | 109 | return true; |
110 | err_out: | 110 | err_out: |
111 | if (ictx) | 111 | if (ictx) |
112 | ntfs_index_ctx_put(ictx); | 112 | ntfs_index_ctx_put(ictx); |
113 | mutex_unlock(&vol->quota_q_ino->i_mutex); | 113 | mutex_unlock(&vol->quota_q_ino->i_mutex); |
114 | return FALSE; | 114 | return false; |
115 | } | 115 | } |
116 | 116 | ||
117 | #endif /* NTFS_RW */ | 117 | #endif /* NTFS_RW */ |
diff --git a/fs/ntfs/quota.h b/fs/ntfs/quota.h index 40e4763aa222..4cbe5594c0b0 100644 --- a/fs/ntfs/quota.h +++ b/fs/ntfs/quota.h | |||
@@ -28,7 +28,7 @@ | |||
28 | #include "types.h" | 28 | #include "types.h" |
29 | #include "volume.h" | 29 | #include "volume.h" |
30 | 30 | ||
31 | extern BOOL ntfs_mark_quotas_out_of_date(ntfs_volume *vol); | 31 | extern bool ntfs_mark_quotas_out_of_date(ntfs_volume *vol); |
32 | 32 | ||
33 | #endif /* NTFS_RW */ | 33 | #endif /* NTFS_RW */ |
34 | 34 | ||
diff --git a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c index eb52b801512b..9afd72c7ad0d 100644 --- a/fs/ntfs/runlist.c +++ b/fs/ntfs/runlist.c | |||
@@ -149,10 +149,10 @@ static inline runlist_element *ntfs_rl_realloc_nofail(runlist_element *rl, | |||
149 | * | 149 | * |
150 | * It is up to the caller to serialize access to the runlists @dst and @src. | 150 | * It is up to the caller to serialize access to the runlists @dst and @src. |
151 | * | 151 | * |
152 | * Return: TRUE Success, the runlists can be merged. | 152 | * Return: true Success, the runlists can be merged. |
153 | * FALSE Failure, the runlists cannot be merged. | 153 | * false Failure, the runlists cannot be merged. |
154 | */ | 154 | */ |
155 | static inline BOOL ntfs_are_rl_mergeable(runlist_element *dst, | 155 | static inline bool ntfs_are_rl_mergeable(runlist_element *dst, |
156 | runlist_element *src) | 156 | runlist_element *src) |
157 | { | 157 | { |
158 | BUG_ON(!dst); | 158 | BUG_ON(!dst); |
@@ -160,19 +160,19 @@ static inline BOOL ntfs_are_rl_mergeable(runlist_element *dst, | |||
160 | 160 | ||
161 | /* We can merge unmapped regions even if they are misaligned. */ | 161 | /* We can merge unmapped regions even if they are misaligned. */ |
162 | if ((dst->lcn == LCN_RL_NOT_MAPPED) && (src->lcn == LCN_RL_NOT_MAPPED)) | 162 | if ((dst->lcn == LCN_RL_NOT_MAPPED) && (src->lcn == LCN_RL_NOT_MAPPED)) |
163 | return TRUE; | 163 | return true; |
164 | /* If the runs are misaligned, we cannot merge them. */ | 164 | /* If the runs are misaligned, we cannot merge them. */ |
165 | if ((dst->vcn + dst->length) != src->vcn) | 165 | if ((dst->vcn + dst->length) != src->vcn) |
166 | return FALSE; | 166 | return false; |
167 | /* If both runs are non-sparse and contiguous, we can merge them. */ | 167 | /* If both runs are non-sparse and contiguous, we can merge them. */ |
168 | if ((dst->lcn >= 0) && (src->lcn >= 0) && | 168 | if ((dst->lcn >= 0) && (src->lcn >= 0) && |
169 | ((dst->lcn + dst->length) == src->lcn)) | 169 | ((dst->lcn + dst->length) == src->lcn)) |
170 | return TRUE; | 170 | return true; |
171 | /* If we are merging two holes, we can merge them. */ | 171 | /* If we are merging two holes, we can merge them. */ |
172 | if ((dst->lcn == LCN_HOLE) && (src->lcn == LCN_HOLE)) | 172 | if ((dst->lcn == LCN_HOLE) && (src->lcn == LCN_HOLE)) |
173 | return TRUE; | 173 | return true; |
174 | /* Cannot merge. */ | 174 | /* Cannot merge. */ |
175 | return FALSE; | 175 | return false; |
176 | } | 176 | } |
177 | 177 | ||
178 | /** | 178 | /** |
@@ -218,7 +218,7 @@ static inline void __ntfs_rl_merge(runlist_element *dst, runlist_element *src) | |||
218 | static inline runlist_element *ntfs_rl_append(runlist_element *dst, | 218 | static inline runlist_element *ntfs_rl_append(runlist_element *dst, |
219 | int dsize, runlist_element *src, int ssize, int loc) | 219 | int dsize, runlist_element *src, int ssize, int loc) |
220 | { | 220 | { |
221 | BOOL right = FALSE; /* Right end of @src needs merging. */ | 221 | bool right = false; /* Right end of @src needs merging. */ |
222 | int marker; /* End of the inserted runs. */ | 222 | int marker; /* End of the inserted runs. */ |
223 | 223 | ||
224 | BUG_ON(!dst); | 224 | BUG_ON(!dst); |
@@ -285,8 +285,8 @@ static inline runlist_element *ntfs_rl_append(runlist_element *dst, | |||
285 | static inline runlist_element *ntfs_rl_insert(runlist_element *dst, | 285 | static inline runlist_element *ntfs_rl_insert(runlist_element *dst, |
286 | int dsize, runlist_element *src, int ssize, int loc) | 286 | int dsize, runlist_element *src, int ssize, int loc) |
287 | { | 287 | { |
288 | BOOL left = FALSE; /* Left end of @src needs merging. */ | 288 | bool left = false; /* Left end of @src needs merging. */ |
289 | BOOL disc = FALSE; /* Discontinuity between @dst and @src. */ | 289 | bool disc = false; /* Discontinuity between @dst and @src. */ |
290 | int marker; /* End of the inserted runs. */ | 290 | int marker; /* End of the inserted runs. */ |
291 | 291 | ||
292 | BUG_ON(!dst); | 292 | BUG_ON(!dst); |
@@ -382,8 +382,8 @@ static inline runlist_element *ntfs_rl_replace(runlist_element *dst, | |||
382 | int dsize, runlist_element *src, int ssize, int loc) | 382 | int dsize, runlist_element *src, int ssize, int loc) |
383 | { | 383 | { |
384 | signed delta; | 384 | signed delta; |
385 | BOOL left = FALSE; /* Left end of @src needs merging. */ | 385 | bool left = false; /* Left end of @src needs merging. */ |
386 | BOOL right = FALSE; /* Right end of @src needs merging. */ | 386 | bool right = false; /* Right end of @src needs merging. */ |
387 | int tail; /* Start of tail of @dst. */ | 387 | int tail; /* Start of tail of @dst. */ |
388 | int marker; /* End of the inserted runs. */ | 388 | int marker; /* End of the inserted runs. */ |
389 | 389 | ||
@@ -620,8 +620,8 @@ runlist_element *ntfs_runlists_merge(runlist_element *drl, | |||
620 | ; | 620 | ; |
621 | 621 | ||
622 | { | 622 | { |
623 | BOOL start; | 623 | bool start; |
624 | BOOL finish; | 624 | bool finish; |
625 | int ds = dend + 1; /* Number of elements in drl & srl */ | 625 | int ds = dend + 1; /* Number of elements in drl & srl */ |
626 | int ss = sfinal - sstart + 1; | 626 | int ss = sfinal - sstart + 1; |
627 | 627 | ||
@@ -635,7 +635,7 @@ runlist_element *ntfs_runlists_merge(runlist_element *drl, | |||
635 | if (finish && !drl[dins].length) | 635 | if (finish && !drl[dins].length) |
636 | ss++; | 636 | ss++; |
637 | if (marker && (drl[dins].vcn + drl[dins].length > srl[send - 1].vcn)) | 637 | if (marker && (drl[dins].vcn + drl[dins].length > srl[send - 1].vcn)) |
638 | finish = FALSE; | 638 | finish = false; |
639 | #if 0 | 639 | #if 0 |
640 | ntfs_debug("dfinal = %i, dend = %i", dfinal, dend); | 640 | ntfs_debug("dfinal = %i, dend = %i", dfinal, dend); |
641 | ntfs_debug("sstart = %i, sfinal = %i, send = %i", sstart, sfinal, send); | 641 | ntfs_debug("sstart = %i, sfinal = %i, send = %i", sstart, sfinal, send); |
@@ -1134,7 +1134,7 @@ int ntfs_get_size_for_mapping_pairs(const ntfs_volume *vol, | |||
1134 | { | 1134 | { |
1135 | LCN prev_lcn; | 1135 | LCN prev_lcn; |
1136 | int rls; | 1136 | int rls; |
1137 | BOOL the_end = FALSE; | 1137 | bool the_end = false; |
1138 | 1138 | ||
1139 | BUG_ON(first_vcn < 0); | 1139 | BUG_ON(first_vcn < 0); |
1140 | BUG_ON(last_vcn < -1); | 1140 | BUG_ON(last_vcn < -1); |
@@ -1168,7 +1168,7 @@ int ntfs_get_size_for_mapping_pairs(const ntfs_volume *vol, | |||
1168 | s64 s1 = last_vcn + 1; | 1168 | s64 s1 = last_vcn + 1; |
1169 | if (unlikely(rl[1].vcn > s1)) | 1169 | if (unlikely(rl[1].vcn > s1)) |
1170 | length = s1 - rl->vcn; | 1170 | length = s1 - rl->vcn; |
1171 | the_end = TRUE; | 1171 | the_end = true; |
1172 | } | 1172 | } |
1173 | delta = first_vcn - rl->vcn; | 1173 | delta = first_vcn - rl->vcn; |
1174 | /* Header byte + length. */ | 1174 | /* Header byte + length. */ |
@@ -1204,7 +1204,7 @@ int ntfs_get_size_for_mapping_pairs(const ntfs_volume *vol, | |||
1204 | s64 s1 = last_vcn + 1; | 1204 | s64 s1 = last_vcn + 1; |
1205 | if (unlikely(rl[1].vcn > s1)) | 1205 | if (unlikely(rl[1].vcn > s1)) |
1206 | length = s1 - rl->vcn; | 1206 | length = s1 - rl->vcn; |
1207 | the_end = TRUE; | 1207 | the_end = true; |
1208 | } | 1208 | } |
1209 | /* Header byte + length. */ | 1209 | /* Header byte + length. */ |
1210 | rls += 1 + ntfs_get_nr_significant_bytes(length); | 1210 | rls += 1 + ntfs_get_nr_significant_bytes(length); |
@@ -1327,7 +1327,7 @@ int ntfs_mapping_pairs_build(const ntfs_volume *vol, s8 *dst, | |||
1327 | LCN prev_lcn; | 1327 | LCN prev_lcn; |
1328 | s8 *dst_max, *dst_next; | 1328 | s8 *dst_max, *dst_next; |
1329 | int err = -ENOSPC; | 1329 | int err = -ENOSPC; |
1330 | BOOL the_end = FALSE; | 1330 | bool the_end = false; |
1331 | s8 len_len, lcn_len; | 1331 | s8 len_len, lcn_len; |
1332 | 1332 | ||
1333 | BUG_ON(first_vcn < 0); | 1333 | BUG_ON(first_vcn < 0); |
@@ -1370,7 +1370,7 @@ int ntfs_mapping_pairs_build(const ntfs_volume *vol, s8 *dst, | |||
1370 | s64 s1 = last_vcn + 1; | 1370 | s64 s1 = last_vcn + 1; |
1371 | if (unlikely(rl[1].vcn > s1)) | 1371 | if (unlikely(rl[1].vcn > s1)) |
1372 | length = s1 - rl->vcn; | 1372 | length = s1 - rl->vcn; |
1373 | the_end = TRUE; | 1373 | the_end = true; |
1374 | } | 1374 | } |
1375 | delta = first_vcn - rl->vcn; | 1375 | delta = first_vcn - rl->vcn; |
1376 | /* Write length. */ | 1376 | /* Write length. */ |
@@ -1422,7 +1422,7 @@ int ntfs_mapping_pairs_build(const ntfs_volume *vol, s8 *dst, | |||
1422 | s64 s1 = last_vcn + 1; | 1422 | s64 s1 = last_vcn + 1; |
1423 | if (unlikely(rl[1].vcn > s1)) | 1423 | if (unlikely(rl[1].vcn > s1)) |
1424 | length = s1 - rl->vcn; | 1424 | length = s1 - rl->vcn; |
1425 | the_end = TRUE; | 1425 | the_end = true; |
1426 | } | 1426 | } |
1427 | /* Write length. */ | 1427 | /* Write length. */ |
1428 | len_len = ntfs_write_significant_bytes(dst + 1, dst_max, | 1428 | len_len = ntfs_write_significant_bytes(dst + 1, dst_max, |
@@ -1541,7 +1541,7 @@ int ntfs_rl_truncate_nolock(const ntfs_volume *vol, runlist *const runlist, | |||
1541 | */ | 1541 | */ |
1542 | if (rl->length) { | 1542 | if (rl->length) { |
1543 | runlist_element *trl; | 1543 | runlist_element *trl; |
1544 | BOOL is_end; | 1544 | bool is_end; |
1545 | 1545 | ||
1546 | ntfs_debug("Shrinking runlist."); | 1546 | ntfs_debug("Shrinking runlist."); |
1547 | /* Determine the runlist size. */ | 1547 | /* Determine the runlist size. */ |
@@ -1555,11 +1555,11 @@ int ntfs_rl_truncate_nolock(const ntfs_volume *vol, runlist *const runlist, | |||
1555 | * If a run was partially truncated, make the following runlist | 1555 | * If a run was partially truncated, make the following runlist |
1556 | * element a terminator. | 1556 | * element a terminator. |
1557 | */ | 1557 | */ |
1558 | is_end = FALSE; | 1558 | is_end = false; |
1559 | if (rl->length) { | 1559 | if (rl->length) { |
1560 | rl++; | 1560 | rl++; |
1561 | if (!rl->length) | 1561 | if (!rl->length) |
1562 | is_end = TRUE; | 1562 | is_end = true; |
1563 | rl->vcn = new_length; | 1563 | rl->vcn = new_length; |
1564 | rl->length = 0; | 1564 | rl->length = 0; |
1565 | } | 1565 | } |
@@ -1648,7 +1648,7 @@ int ntfs_rl_punch_nolock(const ntfs_volume *vol, runlist *const runlist, | |||
1648 | s64 delta; | 1648 | s64 delta; |
1649 | runlist_element *rl, *rl_end, *rl_real_end, *trl; | 1649 | runlist_element *rl, *rl_end, *rl_real_end, *trl; |
1650 | int old_size; | 1650 | int old_size; |
1651 | BOOL lcn_fixup = FALSE; | 1651 | bool lcn_fixup = false; |
1652 | 1652 | ||
1653 | ntfs_debug("Entering for start 0x%llx, length 0x%llx.", | 1653 | ntfs_debug("Entering for start 0x%llx, length 0x%llx.", |
1654 | (long long)start, (long long)length); | 1654 | (long long)start, (long long)length); |
@@ -1862,7 +1862,7 @@ split_end: | |||
1862 | if (rl->lcn >= 0) { | 1862 | if (rl->lcn >= 0) { |
1863 | rl->lcn -= delta; | 1863 | rl->lcn -= delta; |
1864 | /* Need this in case the lcn just became negative. */ | 1864 | /* Need this in case the lcn just became negative. */ |
1865 | lcn_fixup = TRUE; | 1865 | lcn_fixup = true; |
1866 | } | 1866 | } |
1867 | rl->length += delta; | 1867 | rl->length += delta; |
1868 | goto split_end; | 1868 | goto split_end; |
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 6b2712f10dd2..03a391ac7145 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c | |||
@@ -74,18 +74,18 @@ const option_t on_errors_arr[] = { | |||
74 | * | 74 | * |
75 | * Copied from old ntfs driver (which copied from vfat driver). | 75 | * Copied from old ntfs driver (which copied from vfat driver). |
76 | */ | 76 | */ |
77 | static int simple_getbool(char *s, BOOL *setval) | 77 | static int simple_getbool(char *s, bool *setval) |
78 | { | 78 | { |
79 | if (s) { | 79 | if (s) { |
80 | if (!strcmp(s, "1") || !strcmp(s, "yes") || !strcmp(s, "true")) | 80 | if (!strcmp(s, "1") || !strcmp(s, "yes") || !strcmp(s, "true")) |
81 | *setval = TRUE; | 81 | *setval = true; |
82 | else if (!strcmp(s, "0") || !strcmp(s, "no") || | 82 | else if (!strcmp(s, "0") || !strcmp(s, "no") || |
83 | !strcmp(s, "false")) | 83 | !strcmp(s, "false")) |
84 | *setval = FALSE; | 84 | *setval = false; |
85 | else | 85 | else |
86 | return 0; | 86 | return 0; |
87 | } else | 87 | } else |
88 | *setval = TRUE; | 88 | *setval = true; |
89 | return 1; | 89 | return 1; |
90 | } | 90 | } |
91 | 91 | ||
@@ -96,7 +96,7 @@ static int simple_getbool(char *s, BOOL *setval) | |||
96 | * | 96 | * |
97 | * Parse the recognized options in @opt for the ntfs volume described by @vol. | 97 | * Parse the recognized options in @opt for the ntfs volume described by @vol. |
98 | */ | 98 | */ |
99 | static BOOL parse_options(ntfs_volume *vol, char *opt) | 99 | static bool parse_options(ntfs_volume *vol, char *opt) |
100 | { | 100 | { |
101 | char *p, *v, *ov; | 101 | char *p, *v, *ov; |
102 | static char *utf8 = "utf8"; | 102 | static char *utf8 = "utf8"; |
@@ -137,7 +137,7 @@ static BOOL parse_options(ntfs_volume *vol, char *opt) | |||
137 | } | 137 | } |
138 | #define NTFS_GETOPT_BOOL(option, variable) \ | 138 | #define NTFS_GETOPT_BOOL(option, variable) \ |
139 | if (!strcmp(p, option)) { \ | 139 | if (!strcmp(p, option)) { \ |
140 | BOOL val; \ | 140 | bool val; \ |
141 | if (!simple_getbool(v, &val)) \ | 141 | if (!simple_getbool(v, &val)) \ |
142 | goto needs_bool; \ | 142 | goto needs_bool; \ |
143 | variable = val; \ | 143 | variable = val; \ |
@@ -170,7 +170,7 @@ static BOOL parse_options(ntfs_volume *vol, char *opt) | |||
170 | else NTFS_GETOPT_OCTAL("fmask", fmask) | 170 | else NTFS_GETOPT_OCTAL("fmask", fmask) |
171 | else NTFS_GETOPT_OCTAL("dmask", dmask) | 171 | else NTFS_GETOPT_OCTAL("dmask", dmask) |
172 | else NTFS_GETOPT("mft_zone_multiplier", mft_zone_multiplier) | 172 | else NTFS_GETOPT("mft_zone_multiplier", mft_zone_multiplier) |
173 | else NTFS_GETOPT_WITH_DEFAULT("sloppy", sloppy, TRUE) | 173 | else NTFS_GETOPT_WITH_DEFAULT("sloppy", sloppy, true) |
174 | else NTFS_GETOPT_BOOL("show_sys_files", show_sys_files) | 174 | else NTFS_GETOPT_BOOL("show_sys_files", show_sys_files) |
175 | else NTFS_GETOPT_BOOL("case_sensitive", case_sensitive) | 175 | else NTFS_GETOPT_BOOL("case_sensitive", case_sensitive) |
176 | else NTFS_GETOPT_BOOL("disable_sparse", disable_sparse) | 176 | else NTFS_GETOPT_BOOL("disable_sparse", disable_sparse) |
@@ -194,7 +194,7 @@ use_utf8: | |||
194 | if (!old_nls) { | 194 | if (!old_nls) { |
195 | ntfs_error(vol->sb, "NLS character set " | 195 | ntfs_error(vol->sb, "NLS character set " |
196 | "%s not found.", v); | 196 | "%s not found.", v); |
197 | return FALSE; | 197 | return false; |
198 | } | 198 | } |
199 | ntfs_error(vol->sb, "NLS character set %s not " | 199 | ntfs_error(vol->sb, "NLS character set %s not " |
200 | "found. Using previous one %s.", | 200 | "found. Using previous one %s.", |
@@ -205,14 +205,14 @@ use_utf8: | |||
205 | unload_nls(old_nls); | 205 | unload_nls(old_nls); |
206 | } | 206 | } |
207 | } else if (!strcmp(p, "utf8")) { | 207 | } else if (!strcmp(p, "utf8")) { |
208 | BOOL val = FALSE; | 208 | bool val = false; |
209 | ntfs_warning(vol->sb, "Option utf8 is no longer " | 209 | ntfs_warning(vol->sb, "Option utf8 is no longer " |
210 | "supported, using option nls=utf8. Please " | 210 | "supported, using option nls=utf8. Please " |
211 | "use option nls=utf8 in the future and " | 211 | "use option nls=utf8 in the future and " |
212 | "make sure utf8 is compiled either as a " | 212 | "make sure utf8 is compiled either as a " |
213 | "module or into the kernel."); | 213 | "module or into the kernel."); |
214 | if (!v || !*v) | 214 | if (!v || !*v) |
215 | val = TRUE; | 215 | val = true; |
216 | else if (!simple_getbool(v, &val)) | 216 | else if (!simple_getbool(v, &val)) |
217 | goto needs_bool; | 217 | goto needs_bool; |
218 | if (val) { | 218 | if (val) { |
@@ -231,7 +231,7 @@ use_utf8: | |||
231 | } | 231 | } |
232 | no_mount_options: | 232 | no_mount_options: |
233 | if (errors && !sloppy) | 233 | if (errors && !sloppy) |
234 | return FALSE; | 234 | return false; |
235 | if (sloppy) | 235 | if (sloppy) |
236 | ntfs_warning(vol->sb, "Sloppy option given. Ignoring " | 236 | ntfs_warning(vol->sb, "Sloppy option given. Ignoring " |
237 | "unrecognized mount option(s) and continuing."); | 237 | "unrecognized mount option(s) and continuing."); |
@@ -240,14 +240,14 @@ no_mount_options: | |||
240 | if (!on_errors) { | 240 | if (!on_errors) { |
241 | ntfs_error(vol->sb, "Invalid errors option argument " | 241 | ntfs_error(vol->sb, "Invalid errors option argument " |
242 | "or bug in options parser."); | 242 | "or bug in options parser."); |
243 | return FALSE; | 243 | return false; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | if (nls_map) { | 246 | if (nls_map) { |
247 | if (vol->nls_map && vol->nls_map != nls_map) { | 247 | if (vol->nls_map && vol->nls_map != nls_map) { |
248 | ntfs_error(vol->sb, "Cannot change NLS character set " | 248 | ntfs_error(vol->sb, "Cannot change NLS character set " |
249 | "on remount."); | 249 | "on remount."); |
250 | return FALSE; | 250 | return false; |
251 | } /* else (!vol->nls_map) */ | 251 | } /* else (!vol->nls_map) */ |
252 | ntfs_debug("Using NLS character set %s.", nls_map->charset); | 252 | ntfs_debug("Using NLS character set %s.", nls_map->charset); |
253 | vol->nls_map = nls_map; | 253 | vol->nls_map = nls_map; |
@@ -257,7 +257,7 @@ no_mount_options: | |||
257 | if (!vol->nls_map) { | 257 | if (!vol->nls_map) { |
258 | ntfs_error(vol->sb, "Failed to load default " | 258 | ntfs_error(vol->sb, "Failed to load default " |
259 | "NLS character set."); | 259 | "NLS character set."); |
260 | return FALSE; | 260 | return false; |
261 | } | 261 | } |
262 | ntfs_debug("Using default NLS character set (%s).", | 262 | ntfs_debug("Using default NLS character set (%s).", |
263 | vol->nls_map->charset); | 263 | vol->nls_map->charset); |
@@ -268,7 +268,7 @@ no_mount_options: | |||
268 | mft_zone_multiplier) { | 268 | mft_zone_multiplier) { |
269 | ntfs_error(vol->sb, "Cannot change mft_zone_multiplier " | 269 | ntfs_error(vol->sb, "Cannot change mft_zone_multiplier " |
270 | "on remount."); | 270 | "on remount."); |
271 | return FALSE; | 271 | return false; |
272 | } | 272 | } |
273 | if (mft_zone_multiplier < 1 || mft_zone_multiplier > 4) { | 273 | if (mft_zone_multiplier < 1 || mft_zone_multiplier > 4) { |
274 | ntfs_error(vol->sb, "Invalid mft_zone_multiplier. " | 274 | ntfs_error(vol->sb, "Invalid mft_zone_multiplier. " |
@@ -318,16 +318,16 @@ no_mount_options: | |||
318 | NVolSetSparseEnabled(vol); | 318 | NVolSetSparseEnabled(vol); |
319 | } | 319 | } |
320 | } | 320 | } |
321 | return TRUE; | 321 | return true; |
322 | needs_arg: | 322 | needs_arg: |
323 | ntfs_error(vol->sb, "The %s option requires an argument.", p); | 323 | ntfs_error(vol->sb, "The %s option requires an argument.", p); |
324 | return FALSE; | 324 | return false; |
325 | needs_bool: | 325 | needs_bool: |
326 | ntfs_error(vol->sb, "The %s option requires a boolean argument.", p); | 326 | ntfs_error(vol->sb, "The %s option requires a boolean argument.", p); |
327 | return FALSE; | 327 | return false; |
328 | needs_val: | 328 | needs_val: |
329 | ntfs_error(vol->sb, "Invalid %s option argument: %s", p, ov); | 329 | ntfs_error(vol->sb, "Invalid %s option argument: %s", p, ov); |
330 | return FALSE; | 330 | return false; |
331 | } | 331 | } |
332 | 332 | ||
333 | #ifdef NTFS_RW | 333 | #ifdef NTFS_RW |
@@ -543,16 +543,16 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) | |||
543 | * is_boot_sector_ntfs - check whether a boot sector is a valid NTFS boot sector | 543 | * is_boot_sector_ntfs - check whether a boot sector is a valid NTFS boot sector |
544 | * @sb: Super block of the device to which @b belongs. | 544 | * @sb: Super block of the device to which @b belongs. |
545 | * @b: Boot sector of device @sb to check. | 545 | * @b: Boot sector of device @sb to check. |
546 | * @silent: If TRUE, all output will be silenced. | 546 | * @silent: If 'true', all output will be silenced. |
547 | * | 547 | * |
548 | * is_boot_sector_ntfs() checks whether the boot sector @b is a valid NTFS boot | 548 | * is_boot_sector_ntfs() checks whether the boot sector @b is a valid NTFS boot |
549 | * sector. Returns TRUE if it is valid and FALSE if not. | 549 | * sector. Returns 'true' if it is valid and 'false' if not. |
550 | * | 550 | * |
551 | * @sb is only needed for warning/error output, i.e. it can be NULL when silent | 551 | * @sb is only needed for warning/error output, i.e. it can be NULL when silent |
552 | * is TRUE. | 552 | * is 'true'. |
553 | */ | 553 | */ |
554 | static BOOL is_boot_sector_ntfs(const struct super_block *sb, | 554 | static bool is_boot_sector_ntfs(const struct super_block *sb, |
555 | const NTFS_BOOT_SECTOR *b, const BOOL silent) | 555 | const NTFS_BOOT_SECTOR *b, const bool silent) |
556 | { | 556 | { |
557 | /* | 557 | /* |
558 | * Check that checksum == sum of u32 values from b to the checksum | 558 | * Check that checksum == sum of u32 values from b to the checksum |
@@ -620,9 +620,9 @@ static BOOL is_boot_sector_ntfs(const struct super_block *sb, | |||
620 | */ | 620 | */ |
621 | if (!silent && b->end_of_sector_marker != const_cpu_to_le16(0xaa55)) | 621 | if (!silent && b->end_of_sector_marker != const_cpu_to_le16(0xaa55)) |
622 | ntfs_warning(sb, "Invalid end of sector marker."); | 622 | ntfs_warning(sb, "Invalid end of sector marker."); |
623 | return TRUE; | 623 | return true; |
624 | not_ntfs: | 624 | not_ntfs: |
625 | return FALSE; | 625 | return false; |
626 | } | 626 | } |
627 | 627 | ||
628 | /** | 628 | /** |
@@ -732,9 +732,9 @@ hotfix_primary_boot_sector: | |||
732 | * @b: boot sector to parse | 732 | * @b: boot sector to parse |
733 | * | 733 | * |
734 | * Parse the ntfs boot sector @b and store all imporant information therein in | 734 | * Parse the ntfs boot sector @b and store all imporant information therein in |
735 | * the ntfs super block @vol. Return TRUE on success and FALSE on error. | 735 | * the ntfs super block @vol. Return 'true' on success and 'false' on error. |
736 | */ | 736 | */ |
737 | static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | 737 | static bool parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) |
738 | { | 738 | { |
739 | unsigned int sectors_per_cluster_bits, nr_hidden_sects; | 739 | unsigned int sectors_per_cluster_bits, nr_hidden_sects; |
740 | int clusters_per_mft_record, clusters_per_index_record; | 740 | int clusters_per_mft_record, clusters_per_index_record; |
@@ -751,7 +751,7 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
751 | "device block size (%lu). This is not " | 751 | "device block size (%lu). This is not " |
752 | "supported. Sorry.", vol->sector_size, | 752 | "supported. Sorry.", vol->sector_size, |
753 | vol->sb->s_blocksize); | 753 | vol->sb->s_blocksize); |
754 | return FALSE; | 754 | return false; |
755 | } | 755 | } |
756 | ntfs_debug("sectors_per_cluster = 0x%x", b->bpb.sectors_per_cluster); | 756 | ntfs_debug("sectors_per_cluster = 0x%x", b->bpb.sectors_per_cluster); |
757 | sectors_per_cluster_bits = ffs(b->bpb.sectors_per_cluster) - 1; | 757 | sectors_per_cluster_bits = ffs(b->bpb.sectors_per_cluster) - 1; |
@@ -770,7 +770,7 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
770 | ntfs_error(vol->sb, "Cluster size (%i) is smaller than the " | 770 | ntfs_error(vol->sb, "Cluster size (%i) is smaller than the " |
771 | "sector size (%i). This is not supported. " | 771 | "sector size (%i). This is not supported. " |
772 | "Sorry.", vol->cluster_size, vol->sector_size); | 772 | "Sorry.", vol->cluster_size, vol->sector_size); |
773 | return FALSE; | 773 | return false; |
774 | } | 774 | } |
775 | clusters_per_mft_record = b->clusters_per_mft_record; | 775 | clusters_per_mft_record = b->clusters_per_mft_record; |
776 | ntfs_debug("clusters_per_mft_record = %i (0x%x)", | 776 | ntfs_debug("clusters_per_mft_record = %i (0x%x)", |
@@ -802,7 +802,7 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
802 | "PAGE_CACHE_SIZE on your system (%lu). " | 802 | "PAGE_CACHE_SIZE on your system (%lu). " |
803 | "This is not supported. Sorry.", | 803 | "This is not supported. Sorry.", |
804 | vol->mft_record_size, PAGE_CACHE_SIZE); | 804 | vol->mft_record_size, PAGE_CACHE_SIZE); |
805 | return FALSE; | 805 | return false; |
806 | } | 806 | } |
807 | /* We cannot support mft record sizes below the sector size. */ | 807 | /* We cannot support mft record sizes below the sector size. */ |
808 | if (vol->mft_record_size < vol->sector_size) { | 808 | if (vol->mft_record_size < vol->sector_size) { |
@@ -810,7 +810,7 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
810 | "sector size (%i). This is not supported. " | 810 | "sector size (%i). This is not supported. " |
811 | "Sorry.", vol->mft_record_size, | 811 | "Sorry.", vol->mft_record_size, |
812 | vol->sector_size); | 812 | vol->sector_size); |
813 | return FALSE; | 813 | return false; |
814 | } | 814 | } |
815 | clusters_per_index_record = b->clusters_per_index_record; | 815 | clusters_per_index_record = b->clusters_per_index_record; |
816 | ntfs_debug("clusters_per_index_record = %i (0x%x)", | 816 | ntfs_debug("clusters_per_index_record = %i (0x%x)", |
@@ -841,7 +841,7 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
841 | "the sector size (%i). This is not " | 841 | "the sector size (%i). This is not " |
842 | "supported. Sorry.", vol->index_record_size, | 842 | "supported. Sorry.", vol->index_record_size, |
843 | vol->sector_size); | 843 | vol->sector_size); |
844 | return FALSE; | 844 | return false; |
845 | } | 845 | } |
846 | /* | 846 | /* |
847 | * Get the size of the volume in clusters and check for 64-bit-ness. | 847 | * Get the size of the volume in clusters and check for 64-bit-ness. |
@@ -851,7 +851,7 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
851 | ll = sle64_to_cpu(b->number_of_sectors) >> sectors_per_cluster_bits; | 851 | ll = sle64_to_cpu(b->number_of_sectors) >> sectors_per_cluster_bits; |
852 | if ((u64)ll >= 1ULL << 32) { | 852 | if ((u64)ll >= 1ULL << 32) { |
853 | ntfs_error(vol->sb, "Cannot handle 64-bit clusters. Sorry."); | 853 | ntfs_error(vol->sb, "Cannot handle 64-bit clusters. Sorry."); |
854 | return FALSE; | 854 | return false; |
855 | } | 855 | } |
856 | vol->nr_clusters = ll; | 856 | vol->nr_clusters = ll; |
857 | ntfs_debug("vol->nr_clusters = 0x%llx", (long long)vol->nr_clusters); | 857 | ntfs_debug("vol->nr_clusters = 0x%llx", (long long)vol->nr_clusters); |
@@ -867,7 +867,7 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
867 | "Maximum supported is 2TiB. Sorry.", | 867 | "Maximum supported is 2TiB. Sorry.", |
868 | (unsigned long long)ll >> (40 - | 868 | (unsigned long long)ll >> (40 - |
869 | vol->cluster_size_bits)); | 869 | vol->cluster_size_bits)); |
870 | return FALSE; | 870 | return false; |
871 | } | 871 | } |
872 | } | 872 | } |
873 | ll = sle64_to_cpu(b->mft_lcn); | 873 | ll = sle64_to_cpu(b->mft_lcn); |
@@ -875,7 +875,7 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
875 | ntfs_error(vol->sb, "MFT LCN (%lli, 0x%llx) is beyond end of " | 875 | ntfs_error(vol->sb, "MFT LCN (%lli, 0x%llx) is beyond end of " |
876 | "volume. Weird.", (unsigned long long)ll, | 876 | "volume. Weird.", (unsigned long long)ll, |
877 | (unsigned long long)ll); | 877 | (unsigned long long)ll); |
878 | return FALSE; | 878 | return false; |
879 | } | 879 | } |
880 | vol->mft_lcn = ll; | 880 | vol->mft_lcn = ll; |
881 | ntfs_debug("vol->mft_lcn = 0x%llx", (long long)vol->mft_lcn); | 881 | ntfs_debug("vol->mft_lcn = 0x%llx", (long long)vol->mft_lcn); |
@@ -884,7 +884,7 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
884 | ntfs_error(vol->sb, "MFTMirr LCN (%lli, 0x%llx) is beyond end " | 884 | ntfs_error(vol->sb, "MFTMirr LCN (%lli, 0x%llx) is beyond end " |
885 | "of volume. Weird.", (unsigned long long)ll, | 885 | "of volume. Weird.", (unsigned long long)ll, |
886 | (unsigned long long)ll); | 886 | (unsigned long long)ll); |
887 | return FALSE; | 887 | return false; |
888 | } | 888 | } |
889 | vol->mftmirr_lcn = ll; | 889 | vol->mftmirr_lcn = ll; |
890 | ntfs_debug("vol->mftmirr_lcn = 0x%llx", (long long)vol->mftmirr_lcn); | 890 | ntfs_debug("vol->mftmirr_lcn = 0x%llx", (long long)vol->mftmirr_lcn); |
@@ -907,7 +907,7 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
907 | vol->serial_no = le64_to_cpu(b->volume_serial_number); | 907 | vol->serial_no = le64_to_cpu(b->volume_serial_number); |
908 | ntfs_debug("vol->serial_no = 0x%llx", | 908 | ntfs_debug("vol->serial_no = 0x%llx", |
909 | (unsigned long long)vol->serial_no); | 909 | (unsigned long long)vol->serial_no); |
910 | return TRUE; | 910 | return true; |
911 | } | 911 | } |
912 | 912 | ||
913 | /** | 913 | /** |
@@ -1000,9 +1000,9 @@ static void ntfs_setup_allocators(ntfs_volume *vol) | |||
1000 | * load_and_init_mft_mirror - load and setup the mft mirror inode for a volume | 1000 | * load_and_init_mft_mirror - load and setup the mft mirror inode for a volume |
1001 | * @vol: ntfs super block describing device whose mft mirror to load | 1001 | * @vol: ntfs super block describing device whose mft mirror to load |
1002 | * | 1002 | * |
1003 | * Return TRUE on success or FALSE on error. | 1003 | * Return 'true' on success or 'false' on error. |
1004 | */ | 1004 | */ |
1005 | static BOOL load_and_init_mft_mirror(ntfs_volume *vol) | 1005 | static bool load_and_init_mft_mirror(ntfs_volume *vol) |
1006 | { | 1006 | { |
1007 | struct inode *tmp_ino; | 1007 | struct inode *tmp_ino; |
1008 | ntfs_inode *tmp_ni; | 1008 | ntfs_inode *tmp_ni; |
@@ -1014,7 +1014,7 @@ static BOOL load_and_init_mft_mirror(ntfs_volume *vol) | |||
1014 | if (!IS_ERR(tmp_ino)) | 1014 | if (!IS_ERR(tmp_ino)) |
1015 | iput(tmp_ino); | 1015 | iput(tmp_ino); |
1016 | /* Caller will display error message. */ | 1016 | /* Caller will display error message. */ |
1017 | return FALSE; | 1017 | return false; |
1018 | } | 1018 | } |
1019 | /* | 1019 | /* |
1020 | * Re-initialize some specifics about $MFTMirr's inode as | 1020 | * Re-initialize some specifics about $MFTMirr's inode as |
@@ -1041,20 +1041,20 @@ static BOOL load_and_init_mft_mirror(ntfs_volume *vol) | |||
1041 | tmp_ni->itype.index.block_size_bits = vol->mft_record_size_bits; | 1041 | tmp_ni->itype.index.block_size_bits = vol->mft_record_size_bits; |
1042 | vol->mftmirr_ino = tmp_ino; | 1042 | vol->mftmirr_ino = tmp_ino; |
1043 | ntfs_debug("Done."); | 1043 | ntfs_debug("Done."); |
1044 | return TRUE; | 1044 | return true; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | /** | 1047 | /** |
1048 | * check_mft_mirror - compare contents of the mft mirror with the mft | 1048 | * check_mft_mirror - compare contents of the mft mirror with the mft |
1049 | * @vol: ntfs super block describing device whose mft mirror to check | 1049 | * @vol: ntfs super block describing device whose mft mirror to check |
1050 | * | 1050 | * |
1051 | * Return TRUE on success or FALSE on error. | 1051 | * Return 'true' on success or 'false' on error. |
1052 | * | 1052 | * |
1053 | * Note, this function also results in the mft mirror runlist being completely | 1053 | * Note, this function also results in the mft mirror runlist being completely |
1054 | * mapped into memory. The mft mirror write code requires this and will BUG() | 1054 | * mapped into memory. The mft mirror write code requires this and will BUG() |
1055 | * should it find an unmapped runlist element. | 1055 | * should it find an unmapped runlist element. |
1056 | */ | 1056 | */ |
1057 | static BOOL check_mft_mirror(ntfs_volume *vol) | 1057 | static bool check_mft_mirror(ntfs_volume *vol) |
1058 | { | 1058 | { |
1059 | struct super_block *sb = vol->sb; | 1059 | struct super_block *sb = vol->sb; |
1060 | ntfs_inode *mirr_ni; | 1060 | ntfs_inode *mirr_ni; |
@@ -1086,7 +1086,7 @@ static BOOL check_mft_mirror(ntfs_volume *vol) | |||
1086 | index); | 1086 | index); |
1087 | if (IS_ERR(mft_page)) { | 1087 | if (IS_ERR(mft_page)) { |
1088 | ntfs_error(sb, "Failed to read $MFT."); | 1088 | ntfs_error(sb, "Failed to read $MFT."); |
1089 | return FALSE; | 1089 | return false; |
1090 | } | 1090 | } |
1091 | kmft = page_address(mft_page); | 1091 | kmft = page_address(mft_page); |
1092 | /* Get the $MFTMirr page. */ | 1092 | /* Get the $MFTMirr page. */ |
@@ -1110,7 +1110,7 @@ mm_unmap_out: | |||
1110 | ntfs_unmap_page(mirr_page); | 1110 | ntfs_unmap_page(mirr_page); |
1111 | mft_unmap_out: | 1111 | mft_unmap_out: |
1112 | ntfs_unmap_page(mft_page); | 1112 | ntfs_unmap_page(mft_page); |
1113 | return FALSE; | 1113 | return false; |
1114 | } | 1114 | } |
1115 | } | 1115 | } |
1116 | /* Do not check the mirror record if it is not in use. */ | 1116 | /* Do not check the mirror record if it is not in use. */ |
@@ -1169,21 +1169,21 @@ mft_unmap_out: | |||
1169 | ntfs_error(sb, "$MFTMirr location mismatch. " | 1169 | ntfs_error(sb, "$MFTMirr location mismatch. " |
1170 | "Run chkdsk."); | 1170 | "Run chkdsk."); |
1171 | up_read(&mirr_ni->runlist.lock); | 1171 | up_read(&mirr_ni->runlist.lock); |
1172 | return FALSE; | 1172 | return false; |
1173 | } | 1173 | } |
1174 | } while (rl2[i++].length); | 1174 | } while (rl2[i++].length); |
1175 | up_read(&mirr_ni->runlist.lock); | 1175 | up_read(&mirr_ni->runlist.lock); |
1176 | ntfs_debug("Done."); | 1176 | ntfs_debug("Done."); |
1177 | return TRUE; | 1177 | return true; |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | /** | 1180 | /** |
1181 | * load_and_check_logfile - load and check the logfile inode for a volume | 1181 | * load_and_check_logfile - load and check the logfile inode for a volume |
1182 | * @vol: ntfs super block describing device whose logfile to load | 1182 | * @vol: ntfs super block describing device whose logfile to load |
1183 | * | 1183 | * |
1184 | * Return TRUE on success or FALSE on error. | 1184 | * Return 'true' on success or 'false' on error. |
1185 | */ | 1185 | */ |
1186 | static BOOL load_and_check_logfile(ntfs_volume *vol, | 1186 | static bool load_and_check_logfile(ntfs_volume *vol, |
1187 | RESTART_PAGE_HEADER **rp) | 1187 | RESTART_PAGE_HEADER **rp) |
1188 | { | 1188 | { |
1189 | struct inode *tmp_ino; | 1189 | struct inode *tmp_ino; |
@@ -1194,17 +1194,17 @@ static BOOL load_and_check_logfile(ntfs_volume *vol, | |||
1194 | if (!IS_ERR(tmp_ino)) | 1194 | if (!IS_ERR(tmp_ino)) |
1195 | iput(tmp_ino); | 1195 | iput(tmp_ino); |
1196 | /* Caller will display error message. */ | 1196 | /* Caller will display error message. */ |
1197 | return FALSE; | 1197 | return false; |
1198 | } | 1198 | } |
1199 | if (!ntfs_check_logfile(tmp_ino, rp)) { | 1199 | if (!ntfs_check_logfile(tmp_ino, rp)) { |
1200 | iput(tmp_ino); | 1200 | iput(tmp_ino); |
1201 | /* ntfs_check_logfile() will have displayed error output. */ | 1201 | /* ntfs_check_logfile() will have displayed error output. */ |
1202 | return FALSE; | 1202 | return false; |
1203 | } | 1203 | } |
1204 | NInoSetSparseDisabled(NTFS_I(tmp_ino)); | 1204 | NInoSetSparseDisabled(NTFS_I(tmp_ino)); |
1205 | vol->logfile_ino = tmp_ino; | 1205 | vol->logfile_ino = tmp_ino; |
1206 | ntfs_debug("Done."); | 1206 | ntfs_debug("Done."); |
1207 | return TRUE; | 1207 | return true; |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | #define NTFS_HIBERFIL_HEADER_SIZE 4096 | 1210 | #define NTFS_HIBERFIL_HEADER_SIZE 4096 |
@@ -1329,10 +1329,10 @@ iput_out: | |||
1329 | * load_and_init_quota - load and setup the quota file for a volume if present | 1329 | * load_and_init_quota - load and setup the quota file for a volume if present |
1330 | * @vol: ntfs super block describing device whose quota file to load | 1330 | * @vol: ntfs super block describing device whose quota file to load |
1331 | * | 1331 | * |
1332 | * Return TRUE on success or FALSE on error. If $Quota is not present, we | 1332 | * Return 'true' on success or 'false' on error. If $Quota is not present, we |
1333 | * leave vol->quota_ino as NULL and return success. | 1333 | * leave vol->quota_ino as NULL and return success. |
1334 | */ | 1334 | */ |
1335 | static BOOL load_and_init_quota(ntfs_volume *vol) | 1335 | static bool load_and_init_quota(ntfs_volume *vol) |
1336 | { | 1336 | { |
1337 | MFT_REF mref; | 1337 | MFT_REF mref; |
1338 | struct inode *tmp_ino; | 1338 | struct inode *tmp_ino; |
@@ -1366,11 +1366,11 @@ static BOOL load_and_init_quota(ntfs_volume *vol) | |||
1366 | * not enabled. | 1366 | * not enabled. |
1367 | */ | 1367 | */ |
1368 | NVolSetQuotaOutOfDate(vol); | 1368 | NVolSetQuotaOutOfDate(vol); |
1369 | return TRUE; | 1369 | return true; |
1370 | } | 1370 | } |
1371 | /* A real error occured. */ | 1371 | /* A real error occured. */ |
1372 | ntfs_error(vol->sb, "Failed to find inode number for $Quota."); | 1372 | ntfs_error(vol->sb, "Failed to find inode number for $Quota."); |
1373 | return FALSE; | 1373 | return false; |
1374 | } | 1374 | } |
1375 | /* We do not care for the type of match that was found. */ | 1375 | /* We do not care for the type of match that was found. */ |
1376 | kfree(name); | 1376 | kfree(name); |
@@ -1380,25 +1380,25 @@ static BOOL load_and_init_quota(ntfs_volume *vol) | |||
1380 | if (!IS_ERR(tmp_ino)) | 1380 | if (!IS_ERR(tmp_ino)) |
1381 | iput(tmp_ino); | 1381 | iput(tmp_ino); |
1382 | ntfs_error(vol->sb, "Failed to load $Quota."); | 1382 | ntfs_error(vol->sb, "Failed to load $Quota."); |
1383 | return FALSE; | 1383 | return false; |
1384 | } | 1384 | } |
1385 | vol->quota_ino = tmp_ino; | 1385 | vol->quota_ino = tmp_ino; |
1386 | /* Get the $Q index allocation attribute. */ | 1386 | /* Get the $Q index allocation attribute. */ |
1387 | tmp_ino = ntfs_index_iget(vol->quota_ino, Q, 2); | 1387 | tmp_ino = ntfs_index_iget(vol->quota_ino, Q, 2); |
1388 | if (IS_ERR(tmp_ino)) { | 1388 | if (IS_ERR(tmp_ino)) { |
1389 | ntfs_error(vol->sb, "Failed to load $Quota/$Q index."); | 1389 | ntfs_error(vol->sb, "Failed to load $Quota/$Q index."); |
1390 | return FALSE; | 1390 | return false; |
1391 | } | 1391 | } |
1392 | vol->quota_q_ino = tmp_ino; | 1392 | vol->quota_q_ino = tmp_ino; |
1393 | ntfs_debug("Done."); | 1393 | ntfs_debug("Done."); |
1394 | return TRUE; | 1394 | return true; |
1395 | } | 1395 | } |
1396 | 1396 | ||
1397 | /** | 1397 | /** |
1398 | * load_and_init_usnjrnl - load and setup the transaction log if present | 1398 | * load_and_init_usnjrnl - load and setup the transaction log if present |
1399 | * @vol: ntfs super block describing device whose usnjrnl file to load | 1399 | * @vol: ntfs super block describing device whose usnjrnl file to load |
1400 | * | 1400 | * |
1401 | * Return TRUE on success or FALSE on error. | 1401 | * Return 'true' on success or 'false' on error. |
1402 | * | 1402 | * |
1403 | * If $UsnJrnl is not present or in the process of being disabled, we set | 1403 | * If $UsnJrnl is not present or in the process of being disabled, we set |
1404 | * NVolUsnJrnlStamped() and return success. | 1404 | * NVolUsnJrnlStamped() and return success. |
@@ -1408,7 +1408,7 @@ static BOOL load_and_init_quota(ntfs_volume *vol) | |||
1408 | * stamped and nothing has been logged since, we also set NVolUsnJrnlStamped() | 1408 | * stamped and nothing has been logged since, we also set NVolUsnJrnlStamped() |
1409 | * and return success. | 1409 | * and return success. |
1410 | */ | 1410 | */ |
1411 | static BOOL load_and_init_usnjrnl(ntfs_volume *vol) | 1411 | static bool load_and_init_usnjrnl(ntfs_volume *vol) |
1412 | { | 1412 | { |
1413 | MFT_REF mref; | 1413 | MFT_REF mref; |
1414 | struct inode *tmp_ino; | 1414 | struct inode *tmp_ino; |
@@ -1450,12 +1450,12 @@ not_enabled: | |||
1450 | * transaction logging is not enabled. | 1450 | * transaction logging is not enabled. |
1451 | */ | 1451 | */ |
1452 | NVolSetUsnJrnlStamped(vol); | 1452 | NVolSetUsnJrnlStamped(vol); |
1453 | return TRUE; | 1453 | return true; |
1454 | } | 1454 | } |
1455 | /* A real error occured. */ | 1455 | /* A real error occured. */ |
1456 | ntfs_error(vol->sb, "Failed to find inode number for " | 1456 | ntfs_error(vol->sb, "Failed to find inode number for " |
1457 | "$UsnJrnl."); | 1457 | "$UsnJrnl."); |
1458 | return FALSE; | 1458 | return false; |
1459 | } | 1459 | } |
1460 | /* We do not care for the type of match that was found. */ | 1460 | /* We do not care for the type of match that was found. */ |
1461 | kfree(name); | 1461 | kfree(name); |
@@ -1465,7 +1465,7 @@ not_enabled: | |||
1465 | if (!IS_ERR(tmp_ino)) | 1465 | if (!IS_ERR(tmp_ino)) |
1466 | iput(tmp_ino); | 1466 | iput(tmp_ino); |
1467 | ntfs_error(vol->sb, "Failed to load $UsnJrnl."); | 1467 | ntfs_error(vol->sb, "Failed to load $UsnJrnl."); |
1468 | return FALSE; | 1468 | return false; |
1469 | } | 1469 | } |
1470 | vol->usnjrnl_ino = tmp_ino; | 1470 | vol->usnjrnl_ino = tmp_ino; |
1471 | /* | 1471 | /* |
@@ -1483,7 +1483,7 @@ not_enabled: | |||
1483 | if (IS_ERR(tmp_ino)) { | 1483 | if (IS_ERR(tmp_ino)) { |
1484 | ntfs_error(vol->sb, "Failed to load $UsnJrnl/$DATA/$Max " | 1484 | ntfs_error(vol->sb, "Failed to load $UsnJrnl/$DATA/$Max " |
1485 | "attribute."); | 1485 | "attribute."); |
1486 | return FALSE; | 1486 | return false; |
1487 | } | 1487 | } |
1488 | vol->usnjrnl_max_ino = tmp_ino; | 1488 | vol->usnjrnl_max_ino = tmp_ino; |
1489 | if (unlikely(i_size_read(tmp_ino) < sizeof(USN_HEADER))) { | 1489 | if (unlikely(i_size_read(tmp_ino) < sizeof(USN_HEADER))) { |
@@ -1491,14 +1491,14 @@ not_enabled: | |||
1491 | "attribute (size is 0x%llx but should be at " | 1491 | "attribute (size is 0x%llx but should be at " |
1492 | "least 0x%zx bytes).", i_size_read(tmp_ino), | 1492 | "least 0x%zx bytes).", i_size_read(tmp_ino), |
1493 | sizeof(USN_HEADER)); | 1493 | sizeof(USN_HEADER)); |
1494 | return FALSE; | 1494 | return false; |
1495 | } | 1495 | } |
1496 | /* Get the $DATA/$J attribute. */ | 1496 | /* Get the $DATA/$J attribute. */ |
1497 | tmp_ino = ntfs_attr_iget(vol->usnjrnl_ino, AT_DATA, J, 2); | 1497 | tmp_ino = ntfs_attr_iget(vol->usnjrnl_ino, AT_DATA, J, 2); |
1498 | if (IS_ERR(tmp_ino)) { | 1498 | if (IS_ERR(tmp_ino)) { |
1499 | ntfs_error(vol->sb, "Failed to load $UsnJrnl/$DATA/$J " | 1499 | ntfs_error(vol->sb, "Failed to load $UsnJrnl/$DATA/$J " |
1500 | "attribute."); | 1500 | "attribute."); |
1501 | return FALSE; | 1501 | return false; |
1502 | } | 1502 | } |
1503 | vol->usnjrnl_j_ino = tmp_ino; | 1503 | vol->usnjrnl_j_ino = tmp_ino; |
1504 | /* Verify $J is non-resident and sparse. */ | 1504 | /* Verify $J is non-resident and sparse. */ |
@@ -1506,14 +1506,14 @@ not_enabled: | |||
1506 | if (unlikely(!NInoNonResident(tmp_ni) || !NInoSparse(tmp_ni))) { | 1506 | if (unlikely(!NInoNonResident(tmp_ni) || !NInoSparse(tmp_ni))) { |
1507 | ntfs_error(vol->sb, "$UsnJrnl/$DATA/$J attribute is resident " | 1507 | ntfs_error(vol->sb, "$UsnJrnl/$DATA/$J attribute is resident " |
1508 | "and/or not sparse."); | 1508 | "and/or not sparse."); |
1509 | return FALSE; | 1509 | return false; |
1510 | } | 1510 | } |
1511 | /* Read the USN_HEADER from $DATA/$Max. */ | 1511 | /* Read the USN_HEADER from $DATA/$Max. */ |
1512 | page = ntfs_map_page(vol->usnjrnl_max_ino->i_mapping, 0); | 1512 | page = ntfs_map_page(vol->usnjrnl_max_ino->i_mapping, 0); |
1513 | if (IS_ERR(page)) { | 1513 | if (IS_ERR(page)) { |
1514 | ntfs_error(vol->sb, "Failed to read from $UsnJrnl/$DATA/$Max " | 1514 | ntfs_error(vol->sb, "Failed to read from $UsnJrnl/$DATA/$Max " |
1515 | "attribute."); | 1515 | "attribute."); |
1516 | return FALSE; | 1516 | return false; |
1517 | } | 1517 | } |
1518 | uh = (USN_HEADER*)page_address(page); | 1518 | uh = (USN_HEADER*)page_address(page); |
1519 | /* Sanity check the $Max. */ | 1519 | /* Sanity check the $Max. */ |
@@ -1524,7 +1524,7 @@ not_enabled: | |||
1524 | (long long)sle64_to_cpu(uh->allocation_delta), | 1524 | (long long)sle64_to_cpu(uh->allocation_delta), |
1525 | (long long)sle64_to_cpu(uh->maximum_size)); | 1525 | (long long)sle64_to_cpu(uh->maximum_size)); |
1526 | ntfs_unmap_page(page); | 1526 | ntfs_unmap_page(page); |
1527 | return FALSE; | 1527 | return false; |
1528 | } | 1528 | } |
1529 | /* | 1529 | /* |
1530 | * If the transaction log has been stamped and nothing has been written | 1530 | * If the transaction log has been stamped and nothing has been written |
@@ -1548,20 +1548,20 @@ not_enabled: | |||
1548 | (long long)sle64_to_cpu(uh->lowest_valid_usn), | 1548 | (long long)sle64_to_cpu(uh->lowest_valid_usn), |
1549 | i_size_read(vol->usnjrnl_j_ino)); | 1549 | i_size_read(vol->usnjrnl_j_ino)); |
1550 | ntfs_unmap_page(page); | 1550 | ntfs_unmap_page(page); |
1551 | return FALSE; | 1551 | return false; |
1552 | } | 1552 | } |
1553 | ntfs_unmap_page(page); | 1553 | ntfs_unmap_page(page); |
1554 | ntfs_debug("Done."); | 1554 | ntfs_debug("Done."); |
1555 | return TRUE; | 1555 | return true; |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | /** | 1558 | /** |
1559 | * load_and_init_attrdef - load the attribute definitions table for a volume | 1559 | * load_and_init_attrdef - load the attribute definitions table for a volume |
1560 | * @vol: ntfs super block describing device whose attrdef to load | 1560 | * @vol: ntfs super block describing device whose attrdef to load |
1561 | * | 1561 | * |
1562 | * Return TRUE on success or FALSE on error. | 1562 | * Return 'true' on success or 'false' on error. |
1563 | */ | 1563 | */ |
1564 | static BOOL load_and_init_attrdef(ntfs_volume *vol) | 1564 | static bool load_and_init_attrdef(ntfs_volume *vol) |
1565 | { | 1565 | { |
1566 | loff_t i_size; | 1566 | loff_t i_size; |
1567 | struct super_block *sb = vol->sb; | 1567 | struct super_block *sb = vol->sb; |
@@ -1607,7 +1607,7 @@ read_partial_attrdef_page: | |||
1607 | vol->attrdef_size = i_size; | 1607 | vol->attrdef_size = i_size; |
1608 | ntfs_debug("Read %llu bytes from $AttrDef.", i_size); | 1608 | ntfs_debug("Read %llu bytes from $AttrDef.", i_size); |
1609 | iput(ino); | 1609 | iput(ino); |
1610 | return TRUE; | 1610 | return true; |
1611 | free_iput_failed: | 1611 | free_iput_failed: |
1612 | ntfs_free(vol->attrdef); | 1612 | ntfs_free(vol->attrdef); |
1613 | vol->attrdef = NULL; | 1613 | vol->attrdef = NULL; |
@@ -1615,7 +1615,7 @@ iput_failed: | |||
1615 | iput(ino); | 1615 | iput(ino); |
1616 | failed: | 1616 | failed: |
1617 | ntfs_error(sb, "Failed to initialize attribute definition table."); | 1617 | ntfs_error(sb, "Failed to initialize attribute definition table."); |
1618 | return FALSE; | 1618 | return false; |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | #endif /* NTFS_RW */ | 1621 | #endif /* NTFS_RW */ |
@@ -1624,9 +1624,9 @@ failed: | |||
1624 | * load_and_init_upcase - load the upcase table for an ntfs volume | 1624 | * load_and_init_upcase - load the upcase table for an ntfs volume |
1625 | * @vol: ntfs super block describing device whose upcase to load | 1625 | * @vol: ntfs super block describing device whose upcase to load |
1626 | * | 1626 | * |
1627 | * Return TRUE on success or FALSE on error. | 1627 | * Return 'true' on success or 'false' on error. |
1628 | */ | 1628 | */ |
1629 | static BOOL load_and_init_upcase(ntfs_volume *vol) | 1629 | static bool load_and_init_upcase(ntfs_volume *vol) |
1630 | { | 1630 | { |
1631 | loff_t i_size; | 1631 | loff_t i_size; |
1632 | struct super_block *sb = vol->sb; | 1632 | struct super_block *sb = vol->sb; |
@@ -1682,7 +1682,7 @@ read_partial_upcase_page: | |||
1682 | ntfs_debug("Using volume specified $UpCase since default is " | 1682 | ntfs_debug("Using volume specified $UpCase since default is " |
1683 | "not present."); | 1683 | "not present."); |
1684 | mutex_unlock(&ntfs_lock); | 1684 | mutex_unlock(&ntfs_lock); |
1685 | return TRUE; | 1685 | return true; |
1686 | } | 1686 | } |
1687 | max = default_upcase_len; | 1687 | max = default_upcase_len; |
1688 | if (max > vol->upcase_len) | 1688 | if (max > vol->upcase_len) |
@@ -1698,12 +1698,12 @@ read_partial_upcase_page: | |||
1698 | mutex_unlock(&ntfs_lock); | 1698 | mutex_unlock(&ntfs_lock); |
1699 | ntfs_debug("Volume specified $UpCase matches default. Using " | 1699 | ntfs_debug("Volume specified $UpCase matches default. Using " |
1700 | "default."); | 1700 | "default."); |
1701 | return TRUE; | 1701 | return true; |
1702 | } | 1702 | } |
1703 | mutex_unlock(&ntfs_lock); | 1703 | mutex_unlock(&ntfs_lock); |
1704 | ntfs_debug("Using volume specified $UpCase since it does not match " | 1704 | ntfs_debug("Using volume specified $UpCase since it does not match " |
1705 | "the default."); | 1705 | "the default."); |
1706 | return TRUE; | 1706 | return true; |
1707 | iput_upcase_failed: | 1707 | iput_upcase_failed: |
1708 | iput(ino); | 1708 | iput(ino); |
1709 | ntfs_free(vol->upcase); | 1709 | ntfs_free(vol->upcase); |
@@ -1717,11 +1717,11 @@ upcase_failed: | |||
1717 | mutex_unlock(&ntfs_lock); | 1717 | mutex_unlock(&ntfs_lock); |
1718 | ntfs_error(sb, "Failed to load $UpCase from the volume. Using " | 1718 | ntfs_error(sb, "Failed to load $UpCase from the volume. Using " |
1719 | "default."); | 1719 | "default."); |
1720 | return TRUE; | 1720 | return true; |
1721 | } | 1721 | } |
1722 | mutex_unlock(&ntfs_lock); | 1722 | mutex_unlock(&ntfs_lock); |
1723 | ntfs_error(sb, "Failed to initialize upcase table."); | 1723 | ntfs_error(sb, "Failed to initialize upcase table."); |
1724 | return FALSE; | 1724 | return false; |
1725 | } | 1725 | } |
1726 | 1726 | ||
1727 | /* | 1727 | /* |
@@ -1739,9 +1739,9 @@ static struct lock_class_key | |||
1739 | * Open the system files with normal access functions and complete setting up | 1739 | * Open the system files with normal access functions and complete setting up |
1740 | * the ntfs super block @vol. | 1740 | * the ntfs super block @vol. |
1741 | * | 1741 | * |
1742 | * Return TRUE on success or FALSE on error. | 1742 | * Return 'true' on success or 'false' on error. |
1743 | */ | 1743 | */ |
1744 | static BOOL load_system_files(ntfs_volume *vol) | 1744 | static bool load_system_files(ntfs_volume *vol) |
1745 | { | 1745 | { |
1746 | struct super_block *sb = vol->sb; | 1746 | struct super_block *sb = vol->sb; |
1747 | MFT_RECORD *m; | 1747 | MFT_RECORD *m; |
@@ -2067,7 +2067,7 @@ get_ctx_vol_failed: | |||
2067 | #endif /* NTFS_RW */ | 2067 | #endif /* NTFS_RW */ |
2068 | /* If on NTFS versions before 3.0, we are done. */ | 2068 | /* If on NTFS versions before 3.0, we are done. */ |
2069 | if (unlikely(vol->major_ver < 3)) | 2069 | if (unlikely(vol->major_ver < 3)) |
2070 | return TRUE; | 2070 | return true; |
2071 | /* NTFS 3.0+ specific initialization. */ | 2071 | /* NTFS 3.0+ specific initialization. */ |
2072 | /* Get the security descriptors inode. */ | 2072 | /* Get the security descriptors inode. */ |
2073 | vol->secure_ino = ntfs_iget(sb, FILE_Secure); | 2073 | vol->secure_ino = ntfs_iget(sb, FILE_Secure); |
@@ -2173,7 +2173,7 @@ get_ctx_vol_failed: | |||
2173 | NVolSetErrors(vol); | 2173 | NVolSetErrors(vol); |
2174 | } | 2174 | } |
2175 | #endif /* NTFS_RW */ | 2175 | #endif /* NTFS_RW */ |
2176 | return TRUE; | 2176 | return true; |
2177 | #ifdef NTFS_RW | 2177 | #ifdef NTFS_RW |
2178 | iput_usnjrnl_err_out: | 2178 | iput_usnjrnl_err_out: |
2179 | if (vol->usnjrnl_j_ino) | 2179 | if (vol->usnjrnl_j_ino) |
@@ -2229,7 +2229,7 @@ iput_mirr_err_out: | |||
2229 | if (vol->mftmirr_ino) | 2229 | if (vol->mftmirr_ino) |
2230 | iput(vol->mftmirr_ino); | 2230 | iput(vol->mftmirr_ino); |
2231 | #endif /* NTFS_RW */ | 2231 | #endif /* NTFS_RW */ |
2232 | return FALSE; | 2232 | return false; |
2233 | } | 2233 | } |
2234 | 2234 | ||
2235 | /** | 2235 | /** |
diff --git a/fs/ntfs/types.h b/fs/ntfs/types.h index 6e4a7e3343f2..8c8053b66984 100644 --- a/fs/ntfs/types.h +++ b/fs/ntfs/types.h | |||
@@ -62,11 +62,6 @@ typedef s64 USN; | |||
62 | typedef sle64 leUSN; | 62 | typedef sle64 leUSN; |
63 | 63 | ||
64 | typedef enum { | 64 | typedef enum { |
65 | FALSE = 0, | ||
66 | TRUE = 1 | ||
67 | } BOOL; | ||
68 | |||
69 | typedef enum { | ||
70 | CASE_SENSITIVE = 0, | 65 | CASE_SENSITIVE = 0, |
71 | IGNORE_CASE = 1, | 66 | IGNORE_CASE = 1, |
72 | } IGNORE_CASE_BOOL; | 67 | } IGNORE_CASE_BOOL; |
diff --git a/fs/ntfs/unistr.c b/fs/ntfs/unistr.c index a1b572196fe4..6a495f7369f9 100644 --- a/fs/ntfs/unistr.c +++ b/fs/ntfs/unistr.c | |||
@@ -61,16 +61,16 @@ static const u8 legal_ansi_char_array[0x40] = { | |||
61 | * @upcase: upcase table (only if @ic == IGNORE_CASE) | 61 | * @upcase: upcase table (only if @ic == IGNORE_CASE) |
62 | * @upcase_size: length in Unicode characters of @upcase (if present) | 62 | * @upcase_size: length in Unicode characters of @upcase (if present) |
63 | * | 63 | * |
64 | * Compare the names @s1 and @s2 and return TRUE (1) if the names are | 64 | * Compare the names @s1 and @s2 and return 'true' (1) if the names are |
65 | * identical, or FALSE (0) if they are not identical. If @ic is IGNORE_CASE, | 65 | * identical, or 'false' (0) if they are not identical. If @ic is IGNORE_CASE, |
66 | * the @upcase table is used to performa a case insensitive comparison. | 66 | * the @upcase table is used to performa a case insensitive comparison. |
67 | */ | 67 | */ |
68 | BOOL ntfs_are_names_equal(const ntfschar *s1, size_t s1_len, | 68 | bool ntfs_are_names_equal(const ntfschar *s1, size_t s1_len, |
69 | const ntfschar *s2, size_t s2_len, const IGNORE_CASE_BOOL ic, | 69 | const ntfschar *s2, size_t s2_len, const IGNORE_CASE_BOOL ic, |
70 | const ntfschar *upcase, const u32 upcase_size) | 70 | const ntfschar *upcase, const u32 upcase_size) |
71 | { | 71 | { |
72 | if (s1_len != s2_len) | 72 | if (s1_len != s2_len) |
73 | return FALSE; | 73 | return false; |
74 | if (ic == CASE_SENSITIVE) | 74 | if (ic == CASE_SENSITIVE) |
75 | return !ntfs_ucsncmp(s1, s2, s1_len); | 75 | return !ntfs_ucsncmp(s1, s2, s1_len); |
76 | return !ntfs_ucsncasecmp(s1, s2, s1_len, upcase, upcase_size); | 76 | return !ntfs_ucsncasecmp(s1, s2, s1_len, upcase, upcase_size); |
diff --git a/fs/ntfs/usnjrnl.c b/fs/ntfs/usnjrnl.c index 77773240d139..b2bc0d55b036 100644 --- a/fs/ntfs/usnjrnl.c +++ b/fs/ntfs/usnjrnl.c | |||
@@ -39,12 +39,12 @@ | |||
39 | * @vol: ntfs volume on which to stamp the transaction log | 39 | * @vol: ntfs volume on which to stamp the transaction log |
40 | * | 40 | * |
41 | * Stamp the transaction log ($UsnJrnl) on the ntfs volume @vol and return | 41 | * Stamp the transaction log ($UsnJrnl) on the ntfs volume @vol and return |
42 | * TRUE on success and FALSE on error. | 42 | * 'true' on success and 'false' on error. |
43 | * | 43 | * |
44 | * This function assumes that the transaction log has already been loaded and | 44 | * This function assumes that the transaction log has already been loaded and |
45 | * consistency checked by a call to fs/ntfs/super.c::load_and_init_usnjrnl(). | 45 | * consistency checked by a call to fs/ntfs/super.c::load_and_init_usnjrnl(). |
46 | */ | 46 | */ |
47 | BOOL ntfs_stamp_usnjrnl(ntfs_volume *vol) | 47 | bool ntfs_stamp_usnjrnl(ntfs_volume *vol) |
48 | { | 48 | { |
49 | ntfs_debug("Entering."); | 49 | ntfs_debug("Entering."); |
50 | if (likely(!NVolUsnJrnlStamped(vol))) { | 50 | if (likely(!NVolUsnJrnlStamped(vol))) { |
@@ -56,7 +56,7 @@ BOOL ntfs_stamp_usnjrnl(ntfs_volume *vol) | |||
56 | if (IS_ERR(page)) { | 56 | if (IS_ERR(page)) { |
57 | ntfs_error(vol->sb, "Failed to read from " | 57 | ntfs_error(vol->sb, "Failed to read from " |
58 | "$UsnJrnl/$DATA/$Max attribute."); | 58 | "$UsnJrnl/$DATA/$Max attribute."); |
59 | return FALSE; | 59 | return false; |
60 | } | 60 | } |
61 | uh = (USN_HEADER*)page_address(page); | 61 | uh = (USN_HEADER*)page_address(page); |
62 | stamp = get_current_ntfs_time(); | 62 | stamp = get_current_ntfs_time(); |
@@ -78,7 +78,7 @@ BOOL ntfs_stamp_usnjrnl(ntfs_volume *vol) | |||
78 | NVolSetUsnJrnlStamped(vol); | 78 | NVolSetUsnJrnlStamped(vol); |
79 | } | 79 | } |
80 | ntfs_debug("Done."); | 80 | ntfs_debug("Done."); |
81 | return TRUE; | 81 | return true; |
82 | } | 82 | } |
83 | 83 | ||
84 | #endif /* NTFS_RW */ | 84 | #endif /* NTFS_RW */ |
diff --git a/fs/ntfs/usnjrnl.h b/fs/ntfs/usnjrnl.h index ff988b0deb45..3a8af75351e8 100644 --- a/fs/ntfs/usnjrnl.h +++ b/fs/ntfs/usnjrnl.h | |||
@@ -198,7 +198,7 @@ typedef struct { | |||
198 | /* sizeof() = 60 (0x3c) bytes */ | 198 | /* sizeof() = 60 (0x3c) bytes */ |
199 | } __attribute__ ((__packed__)) USN_RECORD; | 199 | } __attribute__ ((__packed__)) USN_RECORD; |
200 | 200 | ||
201 | extern BOOL ntfs_stamp_usnjrnl(ntfs_volume *vol); | 201 | extern bool ntfs_stamp_usnjrnl(ntfs_volume *vol); |
202 | 202 | ||
203 | #endif /* NTFS_RW */ | 203 | #endif /* NTFS_RW */ |
204 | 204 | ||
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c index 0368c6402182..16b8d1ba7066 100644 --- a/fs/ocfs2/dlm/dlmfs.c +++ b/fs/ocfs2/dlm/dlmfs.c | |||
@@ -338,7 +338,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb) | |||
338 | inode->i_blocks = 0; | 338 | inode->i_blocks = 0; |
339 | inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; | 339 | inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; |
340 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 340 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
341 | inode->i_nlink++; | 341 | inc_nlink(inode); |
342 | 342 | ||
343 | inode->i_fop = &simple_dir_operations; | 343 | inode->i_fop = &simple_dir_operations; |
344 | inode->i_op = &dlmfs_root_inode_operations; | 344 | inode->i_op = &dlmfs_root_inode_operations; |
@@ -395,7 +395,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent, | |||
395 | 395 | ||
396 | /* directory inodes start off with i_nlink == | 396 | /* directory inodes start off with i_nlink == |
397 | * 2 (for "." entry) */ | 397 | * 2 (for "." entry) */ |
398 | inode->i_nlink++; | 398 | inc_nlink(inode); |
399 | break; | 399 | break; |
400 | } | 400 | } |
401 | 401 | ||
@@ -449,7 +449,7 @@ static int dlmfs_mkdir(struct inode * dir, | |||
449 | } | 449 | } |
450 | ip->ip_dlm = dlm; | 450 | ip->ip_dlm = dlm; |
451 | 451 | ||
452 | dir->i_nlink++; | 452 | inc_nlink(dir); |
453 | d_instantiate(dentry, inode); | 453 | d_instantiate(dentry, inode); |
454 | dget(dentry); /* Extra count - pin the dentry in core */ | 454 | dget(dentry); /* Extra count - pin the dentry in core */ |
455 | 455 | ||
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 2bbfa17090cf..d9ba0a931a03 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -961,25 +961,23 @@ static inline int ocfs2_write_should_remove_suid(struct inode *inode) | |||
961 | } | 961 | } |
962 | 962 | ||
963 | static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | 963 | static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, |
964 | const char __user *buf, | 964 | const struct iovec *iov, |
965 | size_t count, | 965 | unsigned long nr_segs, |
966 | loff_t pos) | 966 | loff_t pos) |
967 | { | 967 | { |
968 | struct iovec local_iov = { .iov_base = (void __user *)buf, | ||
969 | .iov_len = count }; | ||
970 | int ret, rw_level = -1, meta_level = -1, have_alloc_sem = 0; | 968 | int ret, rw_level = -1, meta_level = -1, have_alloc_sem = 0; |
971 | u32 clusters; | 969 | u32 clusters; |
972 | struct file *filp = iocb->ki_filp; | 970 | struct file *filp = iocb->ki_filp; |
973 | struct inode *inode = filp->f_dentry->d_inode; | 971 | struct inode *inode = filp->f_dentry->d_inode; |
974 | loff_t newsize, saved_pos; | 972 | loff_t newsize, saved_pos; |
975 | 973 | ||
976 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", filp, buf, | 974 | mlog_entry("(0x%p, %u, '%.*s')\n", filp, |
977 | (unsigned int)count, | 975 | (unsigned int)nr_segs, |
978 | filp->f_dentry->d_name.len, | 976 | filp->f_dentry->d_name.len, |
979 | filp->f_dentry->d_name.name); | 977 | filp->f_dentry->d_name.name); |
980 | 978 | ||
981 | /* happy write of zero bytes */ | 979 | /* happy write of zero bytes */ |
982 | if (count == 0) | 980 | if (iocb->ki_left == 0) |
983 | return 0; | 981 | return 0; |
984 | 982 | ||
985 | if (!inode) { | 983 | if (!inode) { |
@@ -1048,7 +1046,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1048 | } else { | 1046 | } else { |
1049 | saved_pos = iocb->ki_pos; | 1047 | saved_pos = iocb->ki_pos; |
1050 | } | 1048 | } |
1051 | newsize = count + saved_pos; | 1049 | newsize = iocb->ki_left + saved_pos; |
1052 | 1050 | ||
1053 | mlog(0, "pos=%lld newsize=%lld cursize=%lld\n", | 1051 | mlog(0, "pos=%lld newsize=%lld cursize=%lld\n", |
1054 | (long long) saved_pos, (long long) newsize, | 1052 | (long long) saved_pos, (long long) newsize, |
@@ -1081,7 +1079,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1081 | if (!clusters) | 1079 | if (!clusters) |
1082 | break; | 1080 | break; |
1083 | 1081 | ||
1084 | ret = ocfs2_extend_file(inode, NULL, newsize, count); | 1082 | ret = ocfs2_extend_file(inode, NULL, newsize, iocb->ki_left); |
1085 | if (ret < 0) { | 1083 | if (ret < 0) { |
1086 | if (ret != -ENOSPC) | 1084 | if (ret != -ENOSPC) |
1087 | mlog_errno(ret); | 1085 | mlog_errno(ret); |
@@ -1098,7 +1096,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1098 | /* communicate with ocfs2_dio_end_io */ | 1096 | /* communicate with ocfs2_dio_end_io */ |
1099 | ocfs2_iocb_set_rw_locked(iocb); | 1097 | ocfs2_iocb_set_rw_locked(iocb); |
1100 | 1098 | ||
1101 | ret = generic_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos); | 1099 | ret = generic_file_aio_write_nolock(iocb, iov, nr_segs, iocb->ki_pos); |
1102 | 1100 | ||
1103 | /* buffered aio wouldn't have proper lock coverage today */ | 1101 | /* buffered aio wouldn't have proper lock coverage today */ |
1104 | BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); | 1102 | BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); |
@@ -1132,16 +1130,16 @@ out: | |||
1132 | } | 1130 | } |
1133 | 1131 | ||
1134 | static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | 1132 | static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, |
1135 | char __user *buf, | 1133 | const struct iovec *iov, |
1136 | size_t count, | 1134 | unsigned long nr_segs, |
1137 | loff_t pos) | 1135 | loff_t pos) |
1138 | { | 1136 | { |
1139 | int ret = 0, rw_level = -1, have_alloc_sem = 0; | 1137 | int ret = 0, rw_level = -1, have_alloc_sem = 0; |
1140 | struct file *filp = iocb->ki_filp; | 1138 | struct file *filp = iocb->ki_filp; |
1141 | struct inode *inode = filp->f_dentry->d_inode; | 1139 | struct inode *inode = filp->f_dentry->d_inode; |
1142 | 1140 | ||
1143 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", filp, buf, | 1141 | mlog_entry("(0x%p, %u, '%.*s')\n", filp, |
1144 | (unsigned int)count, | 1142 | (unsigned int)nr_segs, |
1145 | filp->f_dentry->d_name.len, | 1143 | filp->f_dentry->d_name.len, |
1146 | filp->f_dentry->d_name.name); | 1144 | filp->f_dentry->d_name.name); |
1147 | 1145 | ||
@@ -1185,7 +1183,7 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | |||
1185 | } | 1183 | } |
1186 | ocfs2_meta_unlock(inode, 0); | 1184 | ocfs2_meta_unlock(inode, 0); |
1187 | 1185 | ||
1188 | ret = generic_file_aio_read(iocb, buf, count, iocb->ki_pos); | 1186 | ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos); |
1189 | if (ret == -EINVAL) | 1187 | if (ret == -EINVAL) |
1190 | mlog(ML_ERROR, "generic_file_aio_read returned -EINVAL\n"); | 1188 | mlog(ML_ERROR, "generic_file_aio_read returned -EINVAL\n"); |
1191 | 1189 | ||
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 849c3b4bb94a..259155f0eb2e 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
@@ -429,7 +429,7 @@ static int ocfs2_mknod(struct inode *dir, | |||
429 | mlog_errno(status); | 429 | mlog_errno(status); |
430 | goto leave; | 430 | goto leave; |
431 | } | 431 | } |
432 | dir->i_nlink++; | 432 | inc_nlink(dir); |
433 | } | 433 | } |
434 | 434 | ||
435 | status = ocfs2_add_entry(handle, dentry, inode, | 435 | status = ocfs2_add_entry(handle, dentry, inode, |
@@ -730,7 +730,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
730 | goto bail; | 730 | goto bail; |
731 | } | 731 | } |
732 | 732 | ||
733 | inode->i_nlink++; | 733 | inc_nlink(inode); |
734 | inode->i_ctime = CURRENT_TIME; | 734 | inode->i_ctime = CURRENT_TIME; |
735 | fe->i_links_count = cpu_to_le16(inode->i_nlink); | 735 | fe->i_links_count = cpu_to_le16(inode->i_nlink); |
736 | fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec); | 736 | fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec); |
@@ -739,7 +739,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
739 | err = ocfs2_journal_dirty(handle, fe_bh); | 739 | err = ocfs2_journal_dirty(handle, fe_bh); |
740 | if (err < 0) { | 740 | if (err < 0) { |
741 | le16_add_cpu(&fe->i_links_count, -1); | 741 | le16_add_cpu(&fe->i_links_count, -1); |
742 | inode->i_nlink--; | 742 | drop_nlink(inode); |
743 | mlog_errno(err); | 743 | mlog_errno(err); |
744 | goto bail; | 744 | goto bail; |
745 | } | 745 | } |
@@ -749,7 +749,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
749 | parent_fe_bh, de_bh); | 749 | parent_fe_bh, de_bh); |
750 | if (err) { | 750 | if (err) { |
751 | le16_add_cpu(&fe->i_links_count, -1); | 751 | le16_add_cpu(&fe->i_links_count, -1); |
752 | inode->i_nlink--; | 752 | drop_nlink(inode); |
753 | mlog_errno(err); | 753 | mlog_errno(err); |
754 | goto bail; | 754 | goto bail; |
755 | } | 755 | } |
@@ -795,11 +795,23 @@ static int ocfs2_remote_dentry_delete(struct dentry *dentry) | |||
795 | return ret; | 795 | return ret; |
796 | } | 796 | } |
797 | 797 | ||
798 | static inline int inode_is_unlinkable(struct inode *inode) | ||
799 | { | ||
800 | if (S_ISDIR(inode->i_mode)) { | ||
801 | if (inode->i_nlink == 2) | ||
802 | return 1; | ||
803 | return 0; | ||
804 | } | ||
805 | |||
806 | if (inode->i_nlink == 1) | ||
807 | return 1; | ||
808 | return 0; | ||
809 | } | ||
810 | |||
798 | static int ocfs2_unlink(struct inode *dir, | 811 | static int ocfs2_unlink(struct inode *dir, |
799 | struct dentry *dentry) | 812 | struct dentry *dentry) |
800 | { | 813 | { |
801 | int status; | 814 | int status; |
802 | unsigned int saved_nlink = 0; | ||
803 | struct inode *inode = dentry->d_inode; | 815 | struct inode *inode = dentry->d_inode; |
804 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); | 816 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); |
805 | u64 blkno; | 817 | u64 blkno; |
@@ -874,16 +886,6 @@ static int ocfs2_unlink(struct inode *dir, | |||
874 | } | 886 | } |
875 | } | 887 | } |
876 | 888 | ||
877 | /* There are still a few steps left until we can consider the | ||
878 | * unlink to have succeeded. Save off nlink here before | ||
879 | * modification so we can set it back in case we hit an issue | ||
880 | * before commit. */ | ||
881 | saved_nlink = inode->i_nlink; | ||
882 | if (S_ISDIR(inode->i_mode)) | ||
883 | inode->i_nlink = 0; | ||
884 | else | ||
885 | inode->i_nlink--; | ||
886 | |||
887 | status = ocfs2_remote_dentry_delete(dentry); | 889 | status = ocfs2_remote_dentry_delete(dentry); |
888 | if (status < 0) { | 890 | if (status < 0) { |
889 | /* This vote should succeed under all normal | 891 | /* This vote should succeed under all normal |
@@ -892,7 +894,7 @@ static int ocfs2_unlink(struct inode *dir, | |||
892 | goto leave; | 894 | goto leave; |
893 | } | 895 | } |
894 | 896 | ||
895 | if (!inode->i_nlink) { | 897 | if (inode_is_unlinkable(inode)) { |
896 | status = ocfs2_prepare_orphan_dir(osb, handle, inode, | 898 | status = ocfs2_prepare_orphan_dir(osb, handle, inode, |
897 | orphan_name, | 899 | orphan_name, |
898 | &orphan_entry_bh); | 900 | &orphan_entry_bh); |
@@ -919,7 +921,7 @@ static int ocfs2_unlink(struct inode *dir, | |||
919 | 921 | ||
920 | fe = (struct ocfs2_dinode *) fe_bh->b_data; | 922 | fe = (struct ocfs2_dinode *) fe_bh->b_data; |
921 | 923 | ||
922 | if (!inode->i_nlink) { | 924 | if (inode_is_unlinkable(inode)) { |
923 | status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name, | 925 | status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name, |
924 | orphan_entry_bh); | 926 | orphan_entry_bh); |
925 | if (status < 0) { | 927 | if (status < 0) { |
@@ -935,10 +937,10 @@ static int ocfs2_unlink(struct inode *dir, | |||
935 | goto leave; | 937 | goto leave; |
936 | } | 938 | } |
937 | 939 | ||
938 | /* We can set nlink on the dinode now. clear the saved version | 940 | if (S_ISDIR(inode->i_mode)) |
939 | * so that it doesn't get set later. */ | 941 | drop_nlink(inode); |
942 | drop_nlink(inode); | ||
940 | fe->i_links_count = cpu_to_le16(inode->i_nlink); | 943 | fe->i_links_count = cpu_to_le16(inode->i_nlink); |
941 | saved_nlink = 0; | ||
942 | 944 | ||
943 | status = ocfs2_journal_dirty(handle, fe_bh); | 945 | status = ocfs2_journal_dirty(handle, fe_bh); |
944 | if (status < 0) { | 946 | if (status < 0) { |
@@ -947,19 +949,16 @@ static int ocfs2_unlink(struct inode *dir, | |||
947 | } | 949 | } |
948 | 950 | ||
949 | if (S_ISDIR(inode->i_mode)) { | 951 | if (S_ISDIR(inode->i_mode)) { |
950 | dir->i_nlink--; | 952 | drop_nlink(dir); |
951 | status = ocfs2_mark_inode_dirty(handle, dir, | 953 | status = ocfs2_mark_inode_dirty(handle, dir, |
952 | parent_node_bh); | 954 | parent_node_bh); |
953 | if (status < 0) { | 955 | if (status < 0) { |
954 | mlog_errno(status); | 956 | mlog_errno(status); |
955 | dir->i_nlink++; | 957 | inc_nlink(dir); |
956 | } | 958 | } |
957 | } | 959 | } |
958 | 960 | ||
959 | leave: | 961 | leave: |
960 | if (status < 0 && saved_nlink) | ||
961 | inode->i_nlink = saved_nlink; | ||
962 | |||
963 | if (handle) | 962 | if (handle) |
964 | ocfs2_commit_trans(handle); | 963 | ocfs2_commit_trans(handle); |
965 | 964 | ||
@@ -1382,7 +1381,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1382 | if (new_inode) { | 1381 | if (new_inode) { |
1383 | new_inode->i_nlink--; | 1382 | new_inode->i_nlink--; |
1384 | } else { | 1383 | } else { |
1385 | new_dir->i_nlink++; | 1384 | inc_nlink(new_dir); |
1386 | mark_inode_dirty(new_dir); | 1385 | mark_inode_dirty(new_dir); |
1387 | } | 1386 | } |
1388 | } | 1387 | } |
@@ -6,7 +6,6 @@ | |||
6 | 6 | ||
7 | #include <linux/string.h> | 7 | #include <linux/string.h> |
8 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
9 | #include <linux/utime.h> | ||
10 | #include <linux/file.h> | 9 | #include <linux/file.h> |
11 | #include <linux/smp_lock.h> | 10 | #include <linux/smp_lock.h> |
12 | #include <linux/quotaops.h> | 11 | #include <linux/quotaops.h> |
@@ -29,8 +28,6 @@ | |||
29 | #include <linux/rcupdate.h> | 28 | #include <linux/rcupdate.h> |
30 | #include <linux/audit.h> | 29 | #include <linux/audit.h> |
31 | 30 | ||
32 | #include <asm/unistd.h> | ||
33 | |||
34 | int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) | 31 | int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
35 | { | 32 | { |
36 | int retval = -ENODEV; | 33 | int retval = -ENODEV; |
@@ -353,137 +350,6 @@ asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length) | |||
353 | } | 350 | } |
354 | #endif | 351 | #endif |
355 | 352 | ||
356 | #ifdef __ARCH_WANT_SYS_UTIME | ||
357 | |||
358 | /* | ||
359 | * sys_utime() can be implemented in user-level using sys_utimes(). | ||
360 | * Is this for backwards compatibility? If so, why not move it | ||
361 | * into the appropriate arch directory (for those architectures that | ||
362 | * need it). | ||
363 | */ | ||
364 | |||
365 | /* If times==NULL, set access and modification to current time, | ||
366 | * must be owner or have write permission. | ||
367 | * Else, update from *times, must be owner or super user. | ||
368 | */ | ||
369 | asmlinkage long sys_utime(char __user * filename, struct utimbuf __user * times) | ||
370 | { | ||
371 | int error; | ||
372 | struct nameidata nd; | ||
373 | struct inode * inode; | ||
374 | struct iattr newattrs; | ||
375 | |||
376 | error = user_path_walk(filename, &nd); | ||
377 | if (error) | ||
378 | goto out; | ||
379 | inode = nd.dentry->d_inode; | ||
380 | |||
381 | error = -EROFS; | ||
382 | if (IS_RDONLY(inode)) | ||
383 | goto dput_and_out; | ||
384 | |||
385 | /* Don't worry, the checks are done in inode_change_ok() */ | ||
386 | newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; | ||
387 | if (times) { | ||
388 | error = -EPERM; | ||
389 | if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) | ||
390 | goto dput_and_out; | ||
391 | |||
392 | error = get_user(newattrs.ia_atime.tv_sec, ×->actime); | ||
393 | newattrs.ia_atime.tv_nsec = 0; | ||
394 | if (!error) | ||
395 | error = get_user(newattrs.ia_mtime.tv_sec, ×->modtime); | ||
396 | newattrs.ia_mtime.tv_nsec = 0; | ||
397 | if (error) | ||
398 | goto dput_and_out; | ||
399 | |||
400 | newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET; | ||
401 | } else { | ||
402 | error = -EACCES; | ||
403 | if (IS_IMMUTABLE(inode)) | ||
404 | goto dput_and_out; | ||
405 | |||
406 | if (current->fsuid != inode->i_uid && | ||
407 | (error = vfs_permission(&nd, MAY_WRITE)) != 0) | ||
408 | goto dput_and_out; | ||
409 | } | ||
410 | mutex_lock(&inode->i_mutex); | ||
411 | error = notify_change(nd.dentry, &newattrs); | ||
412 | mutex_unlock(&inode->i_mutex); | ||
413 | dput_and_out: | ||
414 | path_release(&nd); | ||
415 | out: | ||
416 | return error; | ||
417 | } | ||
418 | |||
419 | #endif | ||
420 | |||
421 | /* If times==NULL, set access and modification to current time, | ||
422 | * must be owner or have write permission. | ||
423 | * Else, update from *times, must be owner or super user. | ||
424 | */ | ||
425 | long do_utimes(int dfd, char __user *filename, struct timeval *times) | ||
426 | { | ||
427 | int error; | ||
428 | struct nameidata nd; | ||
429 | struct inode * inode; | ||
430 | struct iattr newattrs; | ||
431 | |||
432 | error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd); | ||
433 | |||
434 | if (error) | ||
435 | goto out; | ||
436 | inode = nd.dentry->d_inode; | ||
437 | |||
438 | error = -EROFS; | ||
439 | if (IS_RDONLY(inode)) | ||
440 | goto dput_and_out; | ||
441 | |||
442 | /* Don't worry, the checks are done in inode_change_ok() */ | ||
443 | newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; | ||
444 | if (times) { | ||
445 | error = -EPERM; | ||
446 | if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) | ||
447 | goto dput_and_out; | ||
448 | |||
449 | newattrs.ia_atime.tv_sec = times[0].tv_sec; | ||
450 | newattrs.ia_atime.tv_nsec = times[0].tv_usec * 1000; | ||
451 | newattrs.ia_mtime.tv_sec = times[1].tv_sec; | ||
452 | newattrs.ia_mtime.tv_nsec = times[1].tv_usec * 1000; | ||
453 | newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET; | ||
454 | } else { | ||
455 | error = -EACCES; | ||
456 | if (IS_IMMUTABLE(inode)) | ||
457 | goto dput_and_out; | ||
458 | |||
459 | if (current->fsuid != inode->i_uid && | ||
460 | (error = vfs_permission(&nd, MAY_WRITE)) != 0) | ||
461 | goto dput_and_out; | ||
462 | } | ||
463 | mutex_lock(&inode->i_mutex); | ||
464 | error = notify_change(nd.dentry, &newattrs); | ||
465 | mutex_unlock(&inode->i_mutex); | ||
466 | dput_and_out: | ||
467 | path_release(&nd); | ||
468 | out: | ||
469 | return error; | ||
470 | } | ||
471 | |||
472 | asmlinkage long sys_futimesat(int dfd, char __user *filename, struct timeval __user *utimes) | ||
473 | { | ||
474 | struct timeval times[2]; | ||
475 | |||
476 | if (utimes && copy_from_user(×, utimes, sizeof(times))) | ||
477 | return -EFAULT; | ||
478 | return do_utimes(dfd, filename, utimes ? times : NULL); | ||
479 | } | ||
480 | |||
481 | asmlinkage long sys_utimes(char __user *filename, struct timeval __user *utimes) | ||
482 | { | ||
483 | return sys_futimesat(AT_FDCWD, filename, utimes); | ||
484 | } | ||
485 | |||
486 | |||
487 | /* | 353 | /* |
488 | * access() needs to use the real uid/gid, not the effective uid/gid. | 354 | * access() needs to use the real uid/gid, not the effective uid/gid. |
489 | * We do this by temporarily clearing all FS-related capabilities and | 355 | * We do this by temporarily clearing all FS-related capabilities and |
@@ -520,15 +386,21 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) | |||
520 | current->cap_effective = current->cap_permitted; | 386 | current->cap_effective = current->cap_permitted; |
521 | 387 | ||
522 | res = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd); | 388 | res = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd); |
523 | if (!res) { | 389 | if (res) |
524 | res = vfs_permission(&nd, mode); | 390 | goto out; |
525 | /* SuS v2 requires we report a read only fs too */ | 391 | |
526 | if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode) | 392 | res = vfs_permission(&nd, mode); |
527 | && !special_file(nd.dentry->d_inode->i_mode)) | 393 | /* SuS v2 requires we report a read only fs too */ |
528 | res = -EROFS; | 394 | if(res || !(mode & S_IWOTH) || |
529 | path_release(&nd); | 395 | special_file(nd.dentry->d_inode->i_mode)) |
530 | } | 396 | goto out_path_release; |
397 | |||
398 | if(IS_RDONLY(nd.dentry->d_inode)) | ||
399 | res = -EROFS; | ||
531 | 400 | ||
401 | out_path_release: | ||
402 | path_release(&nd); | ||
403 | out: | ||
532 | current->fsuid = old_fsuid; | 404 | current->fsuid = old_fsuid; |
533 | current->fsgid = old_fsgid; | 405 | current->fsgid = old_fsgid; |
534 | current->cap_effective = old_cap; | 406 | current->cap_effective = old_cap; |
@@ -546,7 +418,8 @@ asmlinkage long sys_chdir(const char __user * filename) | |||
546 | struct nameidata nd; | 418 | struct nameidata nd; |
547 | int error; | 419 | int error; |
548 | 420 | ||
549 | error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd); | 421 | error = __user_walk(filename, |
422 | LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_CHDIR, &nd); | ||
550 | if (error) | 423 | if (error) |
551 | goto out; | 424 | goto out; |
552 | 425 | ||
@@ -736,10 +609,11 @@ asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group) | |||
736 | int error; | 609 | int error; |
737 | 610 | ||
738 | error = user_path_walk(filename, &nd); | 611 | error = user_path_walk(filename, &nd); |
739 | if (!error) { | 612 | if (error) |
740 | error = chown_common(nd.dentry, user, group); | 613 | goto out; |
741 | path_release(&nd); | 614 | error = chown_common(nd.dentry, user, group); |
742 | } | 615 | path_release(&nd); |
616 | out: | ||
743 | return error; | 617 | return error; |
744 | } | 618 | } |
745 | 619 | ||
@@ -755,10 +629,10 @@ asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, | |||
755 | 629 | ||
756 | follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; | 630 | follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; |
757 | error = __user_walk_fd(dfd, filename, follow, &nd); | 631 | error = __user_walk_fd(dfd, filename, follow, &nd); |
758 | if (!error) { | 632 | if (error) |
759 | error = chown_common(nd.dentry, user, group); | 633 | goto out; |
760 | path_release(&nd); | 634 | error = chown_common(nd.dentry, user, group); |
761 | } | 635 | path_release(&nd); |
762 | out: | 636 | out: |
763 | return error; | 637 | return error; |
764 | } | 638 | } |
@@ -769,10 +643,11 @@ asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group | |||
769 | int error; | 643 | int error; |
770 | 644 | ||
771 | error = user_path_walk_link(filename, &nd); | 645 | error = user_path_walk_link(filename, &nd); |
772 | if (!error) { | 646 | if (error) |
773 | error = chown_common(nd.dentry, user, group); | 647 | goto out; |
774 | path_release(&nd); | 648 | error = chown_common(nd.dentry, user, group); |
775 | } | 649 | path_release(&nd); |
650 | out: | ||
776 | return error; | 651 | return error; |
777 | } | 652 | } |
778 | 653 | ||
@@ -781,15 +656,17 @@ asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group) | |||
781 | { | 656 | { |
782 | struct file * file; | 657 | struct file * file; |
783 | int error = -EBADF; | 658 | int error = -EBADF; |
659 | struct dentry * dentry; | ||
784 | 660 | ||
785 | file = fget(fd); | 661 | file = fget(fd); |
786 | if (file) { | 662 | if (!file) |
787 | struct dentry * dentry; | 663 | goto out; |
788 | dentry = file->f_dentry; | 664 | |
789 | audit_inode(NULL, dentry->d_inode); | 665 | dentry = file->f_dentry; |
790 | error = chown_common(dentry, user, group); | 666 | audit_inode(NULL, dentry->d_inode); |
791 | fput(file); | 667 | error = chown_common(dentry, user, group); |
792 | } | 668 | fput(file); |
669 | out: | ||
793 | return error; | 670 | return error; |
794 | } | 671 | } |
795 | 672 | ||
@@ -1172,6 +1049,7 @@ asmlinkage long sys_close(unsigned int fd) | |||
1172 | struct file * filp; | 1049 | struct file * filp; |
1173 | struct files_struct *files = current->files; | 1050 | struct files_struct *files = current->files; |
1174 | struct fdtable *fdt; | 1051 | struct fdtable *fdt; |
1052 | int retval; | ||
1175 | 1053 | ||
1176 | spin_lock(&files->file_lock); | 1054 | spin_lock(&files->file_lock); |
1177 | fdt = files_fdtable(files); | 1055 | fdt = files_fdtable(files); |
@@ -1184,7 +1062,16 @@ asmlinkage long sys_close(unsigned int fd) | |||
1184 | FD_CLR(fd, fdt->close_on_exec); | 1062 | FD_CLR(fd, fdt->close_on_exec); |
1185 | __put_unused_fd(files, fd); | 1063 | __put_unused_fd(files, fd); |
1186 | spin_unlock(&files->file_lock); | 1064 | spin_unlock(&files->file_lock); |
1187 | return filp_close(filp, files); | 1065 | retval = filp_close(filp, files); |
1066 | |||
1067 | /* can't restart close syscall because file table entry was cleared */ | ||
1068 | if (unlikely(retval == -ERESTARTSYS || | ||
1069 | retval == -ERESTARTNOINTR || | ||
1070 | retval == -ERESTARTNOHAND || | ||
1071 | retval == -ERESTART_RESTARTBLOCK)) | ||
1072 | retval = -EINTR; | ||
1073 | |||
1074 | return retval; | ||
1188 | 1075 | ||
1189 | out_unlock: | 1076 | out_unlock: |
1190 | spin_unlock(&files->file_lock); | 1077 | spin_unlock(&files->file_lock); |
diff --git a/fs/partitions/Makefile b/fs/partitions/Makefile index d713ce6b3e12..67e665fdb7fc 100644 --- a/fs/partitions/Makefile +++ b/fs/partitions/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for the linux kernel. | 2 | # Makefile for the linux kernel. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := check.o | 5 | obj-$(CONFIG_BLOCK) := check.o |
6 | 6 | ||
7 | obj-$(CONFIG_ACORN_PARTITION) += acorn.o | 7 | obj-$(CONFIG_ACORN_PARTITION) += acorn.o |
8 | obj-$(CONFIG_AMIGA_PARTITION) += amiga.o | 8 | obj-$(CONFIG_AMIGA_PARTITION) += amiga.o |
diff --git a/fs/partitions/ldm.c b/fs/partitions/ldm.c index 7ab1c11dca4e..1a60926a4ccd 100644 --- a/fs/partitions/ldm.c +++ b/fs/partitions/ldm.c | |||
@@ -30,11 +30,6 @@ | |||
30 | #include "check.h" | 30 | #include "check.h" |
31 | #include "msdos.h" | 31 | #include "msdos.h" |
32 | 32 | ||
33 | typedef enum { | ||
34 | FALSE = 0, | ||
35 | TRUE = 1 | ||
36 | } BOOL; | ||
37 | |||
38 | /** | 33 | /** |
39 | * ldm_debug/info/error/crit - Output an error message | 34 | * ldm_debug/info/error/crit - Output an error message |
40 | * @f: A printf format string containing the message | 35 | * @f: A printf format string containing the message |
@@ -103,24 +98,24 @@ static int ldm_parse_hexbyte (const u8 *src) | |||
103 | * | 98 | * |
104 | * N.B. The GUID need not be NULL terminated. | 99 | * N.B. The GUID need not be NULL terminated. |
105 | * | 100 | * |
106 | * Return: TRUE @dest contains binary GUID | 101 | * Return: 'true' @dest contains binary GUID |
107 | * FALSE @dest contents are undefined | 102 | * 'false' @dest contents are undefined |
108 | */ | 103 | */ |
109 | static BOOL ldm_parse_guid (const u8 *src, u8 *dest) | 104 | static bool ldm_parse_guid (const u8 *src, u8 *dest) |
110 | { | 105 | { |
111 | static const int size[] = { 4, 2, 2, 2, 6 }; | 106 | static const int size[] = { 4, 2, 2, 2, 6 }; |
112 | int i, j, v; | 107 | int i, j, v; |
113 | 108 | ||
114 | if (src[8] != '-' || src[13] != '-' || | 109 | if (src[8] != '-' || src[13] != '-' || |
115 | src[18] != '-' || src[23] != '-') | 110 | src[18] != '-' || src[23] != '-') |
116 | return FALSE; | 111 | return false; |
117 | 112 | ||
118 | for (j = 0; j < 5; j++, src++) | 113 | for (j = 0; j < 5; j++, src++) |
119 | for (i = 0; i < size[j]; i++, src+=2, *dest++ = v) | 114 | for (i = 0; i < size[j]; i++, src+=2, *dest++ = v) |
120 | if ((v = ldm_parse_hexbyte (src)) < 0) | 115 | if ((v = ldm_parse_hexbyte (src)) < 0) |
121 | return FALSE; | 116 | return false; |
122 | 117 | ||
123 | return TRUE; | 118 | return true; |
124 | } | 119 | } |
125 | 120 | ||
126 | 121 | ||
@@ -132,17 +127,17 @@ static BOOL ldm_parse_guid (const u8 *src, u8 *dest) | |||
132 | * This parses the LDM database PRIVHEAD structure supplied in @data and | 127 | * This parses the LDM database PRIVHEAD structure supplied in @data and |
133 | * sets up the in-memory privhead structure @ph with the obtained information. | 128 | * sets up the in-memory privhead structure @ph with the obtained information. |
134 | * | 129 | * |
135 | * Return: TRUE @ph contains the PRIVHEAD data | 130 | * Return: 'true' @ph contains the PRIVHEAD data |
136 | * FALSE @ph contents are undefined | 131 | * 'false' @ph contents are undefined |
137 | */ | 132 | */ |
138 | static BOOL ldm_parse_privhead (const u8 *data, struct privhead *ph) | 133 | static bool ldm_parse_privhead (const u8 *data, struct privhead *ph) |
139 | { | 134 | { |
140 | BUG_ON (!data || !ph); | 135 | BUG_ON (!data || !ph); |
141 | 136 | ||
142 | if (MAGIC_PRIVHEAD != BE64 (data)) { | 137 | if (MAGIC_PRIVHEAD != BE64 (data)) { |
143 | ldm_error ("Cannot find PRIVHEAD structure. LDM database is" | 138 | ldm_error ("Cannot find PRIVHEAD structure. LDM database is" |
144 | " corrupt. Aborting."); | 139 | " corrupt. Aborting."); |
145 | return FALSE; | 140 | return false; |
146 | } | 141 | } |
147 | 142 | ||
148 | ph->ver_major = BE16 (data + 0x000C); | 143 | ph->ver_major = BE16 (data + 0x000C); |
@@ -155,7 +150,7 @@ static BOOL ldm_parse_privhead (const u8 *data, struct privhead *ph) | |||
155 | if ((ph->ver_major != 2) || (ph->ver_minor != 11)) { | 150 | if ((ph->ver_major != 2) || (ph->ver_minor != 11)) { |
156 | ldm_error ("Expected PRIVHEAD version %d.%d, got %d.%d." | 151 | ldm_error ("Expected PRIVHEAD version %d.%d, got %d.%d." |
157 | " Aborting.", 2, 11, ph->ver_major, ph->ver_minor); | 152 | " Aborting.", 2, 11, ph->ver_major, ph->ver_minor); |
158 | return FALSE; | 153 | return false; |
159 | } | 154 | } |
160 | if (ph->config_size != LDM_DB_SIZE) { /* 1 MiB in sectors. */ | 155 | if (ph->config_size != LDM_DB_SIZE) { /* 1 MiB in sectors. */ |
161 | /* Warn the user and continue, carefully */ | 156 | /* Warn the user and continue, carefully */ |
@@ -166,16 +161,16 @@ static BOOL ldm_parse_privhead (const u8 *data, struct privhead *ph) | |||
166 | if ((ph->logical_disk_size == 0) || | 161 | if ((ph->logical_disk_size == 0) || |
167 | (ph->logical_disk_start + ph->logical_disk_size > ph->config_start)) { | 162 | (ph->logical_disk_start + ph->logical_disk_size > ph->config_start)) { |
168 | ldm_error ("PRIVHEAD disk size doesn't match real disk size"); | 163 | ldm_error ("PRIVHEAD disk size doesn't match real disk size"); |
169 | return FALSE; | 164 | return false; |
170 | } | 165 | } |
171 | 166 | ||
172 | if (!ldm_parse_guid (data + 0x0030, ph->disk_id)) { | 167 | if (!ldm_parse_guid (data + 0x0030, ph->disk_id)) { |
173 | ldm_error ("PRIVHEAD contains an invalid GUID."); | 168 | ldm_error ("PRIVHEAD contains an invalid GUID."); |
174 | return FALSE; | 169 | return false; |
175 | } | 170 | } |
176 | 171 | ||
177 | ldm_debug ("Parsed PRIVHEAD successfully."); | 172 | ldm_debug ("Parsed PRIVHEAD successfully."); |
178 | return TRUE; | 173 | return true; |
179 | } | 174 | } |
180 | 175 | ||
181 | /** | 176 | /** |
@@ -189,16 +184,16 @@ static BOOL ldm_parse_privhead (const u8 *data, struct privhead *ph) | |||
189 | * | 184 | * |
190 | * N.B. The *_start and *_size values returned in @toc are not range-checked. | 185 | * N.B. The *_start and *_size values returned in @toc are not range-checked. |
191 | * | 186 | * |
192 | * Return: TRUE @toc contains the TOCBLOCK data | 187 | * Return: 'true' @toc contains the TOCBLOCK data |
193 | * FALSE @toc contents are undefined | 188 | * 'false' @toc contents are undefined |
194 | */ | 189 | */ |
195 | static BOOL ldm_parse_tocblock (const u8 *data, struct tocblock *toc) | 190 | static bool ldm_parse_tocblock (const u8 *data, struct tocblock *toc) |
196 | { | 191 | { |
197 | BUG_ON (!data || !toc); | 192 | BUG_ON (!data || !toc); |
198 | 193 | ||
199 | if (MAGIC_TOCBLOCK != BE64 (data)) { | 194 | if (MAGIC_TOCBLOCK != BE64 (data)) { |
200 | ldm_crit ("Cannot find TOCBLOCK, database may be corrupt."); | 195 | ldm_crit ("Cannot find TOCBLOCK, database may be corrupt."); |
201 | return FALSE; | 196 | return false; |
202 | } | 197 | } |
203 | strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name)); | 198 | strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name)); |
204 | toc->bitmap1_name[sizeof (toc->bitmap1_name) - 1] = 0; | 199 | toc->bitmap1_name[sizeof (toc->bitmap1_name) - 1] = 0; |
@@ -209,7 +204,7 @@ static BOOL ldm_parse_tocblock (const u8 *data, struct tocblock *toc) | |||
209 | sizeof (toc->bitmap1_name)) != 0) { | 204 | sizeof (toc->bitmap1_name)) != 0) { |
210 | ldm_crit ("TOCBLOCK's first bitmap is '%s', should be '%s'.", | 205 | ldm_crit ("TOCBLOCK's first bitmap is '%s', should be '%s'.", |
211 | TOC_BITMAP1, toc->bitmap1_name); | 206 | TOC_BITMAP1, toc->bitmap1_name); |
212 | return FALSE; | 207 | return false; |
213 | } | 208 | } |
214 | strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name)); | 209 | strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name)); |
215 | toc->bitmap2_name[sizeof (toc->bitmap2_name) - 1] = 0; | 210 | toc->bitmap2_name[sizeof (toc->bitmap2_name) - 1] = 0; |
@@ -219,10 +214,10 @@ static BOOL ldm_parse_tocblock (const u8 *data, struct tocblock *toc) | |||
219 | sizeof (toc->bitmap2_name)) != 0) { | 214 | sizeof (toc->bitmap2_name)) != 0) { |
220 | ldm_crit ("TOCBLOCK's second bitmap is '%s', should be '%s'.", | 215 | ldm_crit ("TOCBLOCK's second bitmap is '%s', should be '%s'.", |
221 | TOC_BITMAP2, toc->bitmap2_name); | 216 | TOC_BITMAP2, toc->bitmap2_name); |
222 | return FALSE; | 217 | return false; |
223 | } | 218 | } |
224 | ldm_debug ("Parsed TOCBLOCK successfully."); | 219 | ldm_debug ("Parsed TOCBLOCK successfully."); |
225 | return TRUE; | 220 | return true; |
226 | } | 221 | } |
227 | 222 | ||
228 | /** | 223 | /** |
@@ -235,16 +230,16 @@ static BOOL ldm_parse_tocblock (const u8 *data, struct tocblock *toc) | |||
235 | * | 230 | * |
236 | * N.B. The *_start, *_size and *_seq values will be range-checked later. | 231 | * N.B. The *_start, *_size and *_seq values will be range-checked later. |
237 | * | 232 | * |
238 | * Return: TRUE @vm contains VMDB info | 233 | * Return: 'true' @vm contains VMDB info |
239 | * FALSE @vm contents are undefined | 234 | * 'false' @vm contents are undefined |
240 | */ | 235 | */ |
241 | static BOOL ldm_parse_vmdb (const u8 *data, struct vmdb *vm) | 236 | static bool ldm_parse_vmdb (const u8 *data, struct vmdb *vm) |
242 | { | 237 | { |
243 | BUG_ON (!data || !vm); | 238 | BUG_ON (!data || !vm); |
244 | 239 | ||
245 | if (MAGIC_VMDB != BE32 (data)) { | 240 | if (MAGIC_VMDB != BE32 (data)) { |
246 | ldm_crit ("Cannot find the VMDB, database may be corrupt."); | 241 | ldm_crit ("Cannot find the VMDB, database may be corrupt."); |
247 | return FALSE; | 242 | return false; |
248 | } | 243 | } |
249 | 244 | ||
250 | vm->ver_major = BE16 (data + 0x12); | 245 | vm->ver_major = BE16 (data + 0x12); |
@@ -252,7 +247,7 @@ static BOOL ldm_parse_vmdb (const u8 *data, struct vmdb *vm) | |||
252 | if ((vm->ver_major != 4) || (vm->ver_minor != 10)) { | 247 | if ((vm->ver_major != 4) || (vm->ver_minor != 10)) { |
253 | ldm_error ("Expected VMDB version %d.%d, got %d.%d. " | 248 | ldm_error ("Expected VMDB version %d.%d, got %d.%d. " |
254 | "Aborting.", 4, 10, vm->ver_major, vm->ver_minor); | 249 | "Aborting.", 4, 10, vm->ver_major, vm->ver_minor); |
255 | return FALSE; | 250 | return false; |
256 | } | 251 | } |
257 | 252 | ||
258 | vm->vblk_size = BE32 (data + 0x08); | 253 | vm->vblk_size = BE32 (data + 0x08); |
@@ -260,7 +255,7 @@ static BOOL ldm_parse_vmdb (const u8 *data, struct vmdb *vm) | |||
260 | vm->last_vblk_seq = BE32 (data + 0x04); | 255 | vm->last_vblk_seq = BE32 (data + 0x04); |
261 | 256 | ||
262 | ldm_debug ("Parsed VMDB successfully."); | 257 | ldm_debug ("Parsed VMDB successfully."); |
263 | return TRUE; | 258 | return true; |
264 | } | 259 | } |
265 | 260 | ||
266 | /** | 261 | /** |
@@ -270,10 +265,10 @@ static BOOL ldm_parse_vmdb (const u8 *data, struct vmdb *vm) | |||
270 | * | 265 | * |
271 | * This compares the two privhead structures @ph1 and @ph2. | 266 | * This compares the two privhead structures @ph1 and @ph2. |
272 | * | 267 | * |
273 | * Return: TRUE Identical | 268 | * Return: 'true' Identical |
274 | * FALSE Different | 269 | * 'false' Different |
275 | */ | 270 | */ |
276 | static BOOL ldm_compare_privheads (const struct privhead *ph1, | 271 | static bool ldm_compare_privheads (const struct privhead *ph1, |
277 | const struct privhead *ph2) | 272 | const struct privhead *ph2) |
278 | { | 273 | { |
279 | BUG_ON (!ph1 || !ph2); | 274 | BUG_ON (!ph1 || !ph2); |
@@ -294,10 +289,10 @@ static BOOL ldm_compare_privheads (const struct privhead *ph1, | |||
294 | * | 289 | * |
295 | * This compares the two tocblock structures @toc1 and @toc2. | 290 | * This compares the two tocblock structures @toc1 and @toc2. |
296 | * | 291 | * |
297 | * Return: TRUE Identical | 292 | * Return: 'true' Identical |
298 | * FALSE Different | 293 | * 'false' Different |
299 | */ | 294 | */ |
300 | static BOOL ldm_compare_tocblocks (const struct tocblock *toc1, | 295 | static bool ldm_compare_tocblocks (const struct tocblock *toc1, |
301 | const struct tocblock *toc2) | 296 | const struct tocblock *toc2) |
302 | { | 297 | { |
303 | BUG_ON (!toc1 || !toc2); | 298 | BUG_ON (!toc1 || !toc2); |
@@ -323,17 +318,17 @@ static BOOL ldm_compare_tocblocks (const struct tocblock *toc1, | |||
323 | * the configuration area (the database). The values are range-checked against | 318 | * the configuration area (the database). The values are range-checked against |
324 | * @hd, which contains the real size of the disk. | 319 | * @hd, which contains the real size of the disk. |
325 | * | 320 | * |
326 | * Return: TRUE Success | 321 | * Return: 'true' Success |
327 | * FALSE Error | 322 | * 'false' Error |
328 | */ | 323 | */ |
329 | static BOOL ldm_validate_privheads (struct block_device *bdev, | 324 | static bool ldm_validate_privheads (struct block_device *bdev, |
330 | struct privhead *ph1) | 325 | struct privhead *ph1) |
331 | { | 326 | { |
332 | static const int off[3] = { OFF_PRIV1, OFF_PRIV2, OFF_PRIV3 }; | 327 | static const int off[3] = { OFF_PRIV1, OFF_PRIV2, OFF_PRIV3 }; |
333 | struct privhead *ph[3] = { ph1 }; | 328 | struct privhead *ph[3] = { ph1 }; |
334 | Sector sect; | 329 | Sector sect; |
335 | u8 *data; | 330 | u8 *data; |
336 | BOOL result = FALSE; | 331 | bool result = false; |
337 | long num_sects; | 332 | long num_sects; |
338 | int i; | 333 | int i; |
339 | 334 | ||
@@ -393,7 +388,7 @@ static BOOL ldm_validate_privheads (struct block_device *bdev, | |||
393 | goto out; | 388 | goto out; |
394 | }*/ | 389 | }*/ |
395 | ldm_debug ("Validated PRIVHEADs successfully."); | 390 | ldm_debug ("Validated PRIVHEADs successfully."); |
396 | result = TRUE; | 391 | result = true; |
397 | out: | 392 | out: |
398 | kfree (ph[1]); | 393 | kfree (ph[1]); |
399 | kfree (ph[2]); | 394 | kfree (ph[2]); |
@@ -411,10 +406,10 @@ out: | |||
411 | * | 406 | * |
412 | * The offsets and sizes of the configs are range-checked against a privhead. | 407 | * The offsets and sizes of the configs are range-checked against a privhead. |
413 | * | 408 | * |
414 | * Return: TRUE @toc1 contains validated TOCBLOCK info | 409 | * Return: 'true' @toc1 contains validated TOCBLOCK info |
415 | * FALSE @toc1 contents are undefined | 410 | * 'false' @toc1 contents are undefined |
416 | */ | 411 | */ |
417 | static BOOL ldm_validate_tocblocks (struct block_device *bdev, | 412 | static bool ldm_validate_tocblocks (struct block_device *bdev, |
418 | unsigned long base, struct ldmdb *ldb) | 413 | unsigned long base, struct ldmdb *ldb) |
419 | { | 414 | { |
420 | static const int off[4] = { OFF_TOCB1, OFF_TOCB2, OFF_TOCB3, OFF_TOCB4}; | 415 | static const int off[4] = { OFF_TOCB1, OFF_TOCB2, OFF_TOCB3, OFF_TOCB4}; |
@@ -422,7 +417,7 @@ static BOOL ldm_validate_tocblocks (struct block_device *bdev, | |||
422 | struct privhead *ph; | 417 | struct privhead *ph; |
423 | Sector sect; | 418 | Sector sect; |
424 | u8 *data; | 419 | u8 *data; |
425 | BOOL result = FALSE; | 420 | bool result = false; |
426 | int i; | 421 | int i; |
427 | 422 | ||
428 | BUG_ON (!bdev || !ldb); | 423 | BUG_ON (!bdev || !ldb); |
@@ -465,7 +460,7 @@ static BOOL ldm_validate_tocblocks (struct block_device *bdev, | |||
465 | } | 460 | } |
466 | 461 | ||
467 | ldm_debug ("Validated TOCBLOCKs successfully."); | 462 | ldm_debug ("Validated TOCBLOCKs successfully."); |
468 | result = TRUE; | 463 | result = true; |
469 | out: | 464 | out: |
470 | kfree (tb[1]); | 465 | kfree (tb[1]); |
471 | kfree (tb[2]); | 466 | kfree (tb[2]); |
@@ -482,15 +477,15 @@ out: | |||
482 | * Find the vmdb of the LDM Database stored on @bdev and return the parsed | 477 | * Find the vmdb of the LDM Database stored on @bdev and return the parsed |
483 | * information in @ldb. | 478 | * information in @ldb. |
484 | * | 479 | * |
485 | * Return: TRUE @ldb contains validated VBDB info | 480 | * Return: 'true' @ldb contains validated VBDB info |
486 | * FALSE @ldb contents are undefined | 481 | * 'false' @ldb contents are undefined |
487 | */ | 482 | */ |
488 | static BOOL ldm_validate_vmdb (struct block_device *bdev, unsigned long base, | 483 | static bool ldm_validate_vmdb (struct block_device *bdev, unsigned long base, |
489 | struct ldmdb *ldb) | 484 | struct ldmdb *ldb) |
490 | { | 485 | { |
491 | Sector sect; | 486 | Sector sect; |
492 | u8 *data; | 487 | u8 *data; |
493 | BOOL result = FALSE; | 488 | bool result = false; |
494 | struct vmdb *vm; | 489 | struct vmdb *vm; |
495 | struct tocblock *toc; | 490 | struct tocblock *toc; |
496 | 491 | ||
@@ -502,7 +497,7 @@ static BOOL ldm_validate_vmdb (struct block_device *bdev, unsigned long base, | |||
502 | data = read_dev_sector (bdev, base + OFF_VMDB, §); | 497 | data = read_dev_sector (bdev, base + OFF_VMDB, §); |
503 | if (!data) { | 498 | if (!data) { |
504 | ldm_crit ("Disk read failed."); | 499 | ldm_crit ("Disk read failed."); |
505 | return FALSE; | 500 | return false; |
506 | } | 501 | } |
507 | 502 | ||
508 | if (!ldm_parse_vmdb (data, vm)) | 503 | if (!ldm_parse_vmdb (data, vm)) |
@@ -527,7 +522,7 @@ static BOOL ldm_validate_vmdb (struct block_device *bdev, unsigned long base, | |||
527 | goto out; | 522 | goto out; |
528 | } | 523 | } |
529 | 524 | ||
530 | result = TRUE; | 525 | result = true; |
531 | out: | 526 | out: |
532 | put_dev_sector (sect); | 527 | put_dev_sector (sect); |
533 | return result; | 528 | return result; |
@@ -547,23 +542,23 @@ out: | |||
547 | * only likely to happen if the underlying device is strange. If that IS | 542 | * only likely to happen if the underlying device is strange. If that IS |
548 | * the case we should return zero to let someone else try. | 543 | * the case we should return zero to let someone else try. |
549 | * | 544 | * |
550 | * Return: TRUE @bdev is a dynamic disk | 545 | * Return: 'true' @bdev is a dynamic disk |
551 | * FALSE @bdev is not a dynamic disk, or an error occurred | 546 | * 'false' @bdev is not a dynamic disk, or an error occurred |
552 | */ | 547 | */ |
553 | static BOOL ldm_validate_partition_table (struct block_device *bdev) | 548 | static bool ldm_validate_partition_table (struct block_device *bdev) |
554 | { | 549 | { |
555 | Sector sect; | 550 | Sector sect; |
556 | u8 *data; | 551 | u8 *data; |
557 | struct partition *p; | 552 | struct partition *p; |
558 | int i; | 553 | int i; |
559 | BOOL result = FALSE; | 554 | bool result = false; |
560 | 555 | ||
561 | BUG_ON (!bdev); | 556 | BUG_ON (!bdev); |
562 | 557 | ||
563 | data = read_dev_sector (bdev, 0, §); | 558 | data = read_dev_sector (bdev, 0, §); |
564 | if (!data) { | 559 | if (!data) { |
565 | ldm_crit ("Disk read failed."); | 560 | ldm_crit ("Disk read failed."); |
566 | return FALSE; | 561 | return false; |
567 | } | 562 | } |
568 | 563 | ||
569 | if (*(__le16*) (data + 0x01FE) != cpu_to_le16 (MSDOS_LABEL_MAGIC)) | 564 | if (*(__le16*) (data + 0x01FE) != cpu_to_le16 (MSDOS_LABEL_MAGIC)) |
@@ -572,7 +567,7 @@ static BOOL ldm_validate_partition_table (struct block_device *bdev) | |||
572 | p = (struct partition*)(data + 0x01BE); | 567 | p = (struct partition*)(data + 0x01BE); |
573 | for (i = 0; i < 4; i++, p++) | 568 | for (i = 0; i < 4; i++, p++) |
574 | if (SYS_IND (p) == WIN2K_DYNAMIC_PARTITION) { | 569 | if (SYS_IND (p) == WIN2K_DYNAMIC_PARTITION) { |
575 | result = TRUE; | 570 | result = true; |
576 | break; | 571 | break; |
577 | } | 572 | } |
578 | 573 | ||
@@ -625,10 +620,10 @@ static struct vblk * ldm_get_disk_objid (const struct ldmdb *ldb) | |||
625 | * N.B. This function creates the partitions in the order it finds partition | 620 | * N.B. This function creates the partitions in the order it finds partition |
626 | * objects in the linked list. | 621 | * objects in the linked list. |
627 | * | 622 | * |
628 | * Return: TRUE Partition created | 623 | * Return: 'true' Partition created |
629 | * FALSE Error, probably a range checking problem | 624 | * 'false' Error, probably a range checking problem |
630 | */ | 625 | */ |
631 | static BOOL ldm_create_data_partitions (struct parsed_partitions *pp, | 626 | static bool ldm_create_data_partitions (struct parsed_partitions *pp, |
632 | const struct ldmdb *ldb) | 627 | const struct ldmdb *ldb) |
633 | { | 628 | { |
634 | struct list_head *item; | 629 | struct list_head *item; |
@@ -642,7 +637,7 @@ static BOOL ldm_create_data_partitions (struct parsed_partitions *pp, | |||
642 | disk = ldm_get_disk_objid (ldb); | 637 | disk = ldm_get_disk_objid (ldb); |
643 | if (!disk) { | 638 | if (!disk) { |
644 | ldm_crit ("Can't find the ID of this disk in the database."); | 639 | ldm_crit ("Can't find the ID of this disk in the database."); |
645 | return FALSE; | 640 | return false; |
646 | } | 641 | } |
647 | 642 | ||
648 | printk (" [LDM]"); | 643 | printk (" [LDM]"); |
@@ -661,7 +656,7 @@ static BOOL ldm_create_data_partitions (struct parsed_partitions *pp, | |||
661 | } | 656 | } |
662 | 657 | ||
663 | printk ("\n"); | 658 | printk ("\n"); |
664 | return TRUE; | 659 | return true; |
665 | } | 660 | } |
666 | 661 | ||
667 | 662 | ||
@@ -766,10 +761,10 @@ static int ldm_get_vstr (const u8 *block, u8 *buffer, int buflen) | |||
766 | * | 761 | * |
767 | * Read a raw VBLK Component object (version 3) into a vblk structure. | 762 | * Read a raw VBLK Component object (version 3) into a vblk structure. |
768 | * | 763 | * |
769 | * Return: TRUE @vb contains a Component VBLK | 764 | * Return: 'true' @vb contains a Component VBLK |
770 | * FALSE @vb contents are not defined | 765 | * 'false' @vb contents are not defined |
771 | */ | 766 | */ |
772 | static BOOL ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb) | 767 | static bool ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb) |
773 | { | 768 | { |
774 | int r_objid, r_name, r_vstate, r_child, r_parent, r_stripe, r_cols, len; | 769 | int r_objid, r_name, r_vstate, r_child, r_parent, r_stripe, r_cols, len; |
775 | struct vblk_comp *comp; | 770 | struct vblk_comp *comp; |
@@ -792,11 +787,11 @@ static BOOL ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb) | |||
792 | len = r_parent; | 787 | len = r_parent; |
793 | } | 788 | } |
794 | if (len < 0) | 789 | if (len < 0) |
795 | return FALSE; | 790 | return false; |
796 | 791 | ||
797 | len += VBLK_SIZE_CMP3; | 792 | len += VBLK_SIZE_CMP3; |
798 | if (len != BE32 (buffer + 0x14)) | 793 | if (len != BE32 (buffer + 0x14)) |
799 | return FALSE; | 794 | return false; |
800 | 795 | ||
801 | comp = &vb->vblk.comp; | 796 | comp = &vb->vblk.comp; |
802 | ldm_get_vstr (buffer + 0x18 + r_name, comp->state, | 797 | ldm_get_vstr (buffer + 0x18 + r_name, comp->state, |
@@ -806,7 +801,7 @@ static BOOL ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb) | |||
806 | comp->parent_id = ldm_get_vnum (buffer + 0x2D + r_child); | 801 | comp->parent_id = ldm_get_vnum (buffer + 0x2D + r_child); |
807 | comp->chunksize = r_stripe ? ldm_get_vnum (buffer+r_parent+0x2E) : 0; | 802 | comp->chunksize = r_stripe ? ldm_get_vnum (buffer+r_parent+0x2E) : 0; |
808 | 803 | ||
809 | return TRUE; | 804 | return true; |
810 | } | 805 | } |
811 | 806 | ||
812 | /** | 807 | /** |
@@ -817,8 +812,8 @@ static BOOL ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb) | |||
817 | * | 812 | * |
818 | * Read a raw VBLK Disk Group object (version 3) into a vblk structure. | 813 | * Read a raw VBLK Disk Group object (version 3) into a vblk structure. |
819 | * | 814 | * |
820 | * Return: TRUE @vb contains a Disk Group VBLK | 815 | * Return: 'true' @vb contains a Disk Group VBLK |
821 | * FALSE @vb contents are not defined | 816 | * 'false' @vb contents are not defined |
822 | */ | 817 | */ |
823 | static int ldm_parse_dgr3 (const u8 *buffer, int buflen, struct vblk *vb) | 818 | static int ldm_parse_dgr3 (const u8 *buffer, int buflen, struct vblk *vb) |
824 | { | 819 | { |
@@ -841,16 +836,16 @@ static int ldm_parse_dgr3 (const u8 *buffer, int buflen, struct vblk *vb) | |||
841 | len = r_diskid; | 836 | len = r_diskid; |
842 | } | 837 | } |
843 | if (len < 0) | 838 | if (len < 0) |
844 | return FALSE; | 839 | return false; |
845 | 840 | ||
846 | len += VBLK_SIZE_DGR3; | 841 | len += VBLK_SIZE_DGR3; |
847 | if (len != BE32 (buffer + 0x14)) | 842 | if (len != BE32 (buffer + 0x14)) |
848 | return FALSE; | 843 | return false; |
849 | 844 | ||
850 | dgrp = &vb->vblk.dgrp; | 845 | dgrp = &vb->vblk.dgrp; |
851 | ldm_get_vstr (buffer + 0x18 + r_name, dgrp->disk_id, | 846 | ldm_get_vstr (buffer + 0x18 + r_name, dgrp->disk_id, |
852 | sizeof (dgrp->disk_id)); | 847 | sizeof (dgrp->disk_id)); |
853 | return TRUE; | 848 | return true; |
854 | } | 849 | } |
855 | 850 | ||
856 | /** | 851 | /** |
@@ -861,10 +856,10 @@ static int ldm_parse_dgr3 (const u8 *buffer, int buflen, struct vblk *vb) | |||
861 | * | 856 | * |
862 | * Read a raw VBLK Disk Group object (version 4) into a vblk structure. | 857 | * Read a raw VBLK Disk Group object (version 4) into a vblk structure. |
863 | * | 858 | * |
864 | * Return: TRUE @vb contains a Disk Group VBLK | 859 | * Return: 'true' @vb contains a Disk Group VBLK |
865 | * FALSE @vb contents are not defined | 860 | * 'false' @vb contents are not defined |
866 | */ | 861 | */ |
867 | static BOOL ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb) | 862 | static bool ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb) |
868 | { | 863 | { |
869 | char buf[64]; | 864 | char buf[64]; |
870 | int r_objid, r_name, r_id1, r_id2, len; | 865 | int r_objid, r_name, r_id1, r_id2, len; |
@@ -885,16 +880,16 @@ static BOOL ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb) | |||
885 | len = r_name; | 880 | len = r_name; |
886 | } | 881 | } |
887 | if (len < 0) | 882 | if (len < 0) |
888 | return FALSE; | 883 | return false; |
889 | 884 | ||
890 | len += VBLK_SIZE_DGR4; | 885 | len += VBLK_SIZE_DGR4; |
891 | if (len != BE32 (buffer + 0x14)) | 886 | if (len != BE32 (buffer + 0x14)) |
892 | return FALSE; | 887 | return false; |
893 | 888 | ||
894 | dgrp = &vb->vblk.dgrp; | 889 | dgrp = &vb->vblk.dgrp; |
895 | 890 | ||
896 | ldm_get_vstr (buffer + 0x18 + r_objid, buf, sizeof (buf)); | 891 | ldm_get_vstr (buffer + 0x18 + r_objid, buf, sizeof (buf)); |
897 | return TRUE; | 892 | return true; |
898 | } | 893 | } |
899 | 894 | ||
900 | /** | 895 | /** |
@@ -905,10 +900,10 @@ static BOOL ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb) | |||
905 | * | 900 | * |
906 | * Read a raw VBLK Disk object (version 3) into a vblk structure. | 901 | * Read a raw VBLK Disk object (version 3) into a vblk structure. |
907 | * | 902 | * |
908 | * Return: TRUE @vb contains a Disk VBLK | 903 | * Return: 'true' @vb contains a Disk VBLK |
909 | * FALSE @vb contents are not defined | 904 | * 'false' @vb contents are not defined |
910 | */ | 905 | */ |
911 | static BOOL ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb) | 906 | static bool ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb) |
912 | { | 907 | { |
913 | int r_objid, r_name, r_diskid, r_altname, len; | 908 | int r_objid, r_name, r_diskid, r_altname, len; |
914 | struct vblk_disk *disk; | 909 | struct vblk_disk *disk; |
@@ -921,19 +916,19 @@ static BOOL ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb) | |||
921 | r_altname = ldm_relative (buffer, buflen, 0x18, r_diskid); | 916 | r_altname = ldm_relative (buffer, buflen, 0x18, r_diskid); |
922 | len = r_altname; | 917 | len = r_altname; |
923 | if (len < 0) | 918 | if (len < 0) |
924 | return FALSE; | 919 | return false; |
925 | 920 | ||
926 | len += VBLK_SIZE_DSK3; | 921 | len += VBLK_SIZE_DSK3; |
927 | if (len != BE32 (buffer + 0x14)) | 922 | if (len != BE32 (buffer + 0x14)) |
928 | return FALSE; | 923 | return false; |
929 | 924 | ||
930 | disk = &vb->vblk.disk; | 925 | disk = &vb->vblk.disk; |
931 | ldm_get_vstr (buffer + 0x18 + r_diskid, disk->alt_name, | 926 | ldm_get_vstr (buffer + 0x18 + r_diskid, disk->alt_name, |
932 | sizeof (disk->alt_name)); | 927 | sizeof (disk->alt_name)); |
933 | if (!ldm_parse_guid (buffer + 0x19 + r_name, disk->disk_id)) | 928 | if (!ldm_parse_guid (buffer + 0x19 + r_name, disk->disk_id)) |
934 | return FALSE; | 929 | return false; |
935 | 930 | ||
936 | return TRUE; | 931 | return true; |
937 | } | 932 | } |
938 | 933 | ||
939 | /** | 934 | /** |
@@ -944,10 +939,10 @@ static BOOL ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb) | |||
944 | * | 939 | * |
945 | * Read a raw VBLK Disk object (version 4) into a vblk structure. | 940 | * Read a raw VBLK Disk object (version 4) into a vblk structure. |
946 | * | 941 | * |
947 | * Return: TRUE @vb contains a Disk VBLK | 942 | * Return: 'true' @vb contains a Disk VBLK |
948 | * FALSE @vb contents are not defined | 943 | * 'false' @vb contents are not defined |
949 | */ | 944 | */ |
950 | static BOOL ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb) | 945 | static bool ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb) |
951 | { | 946 | { |
952 | int r_objid, r_name, len; | 947 | int r_objid, r_name, len; |
953 | struct vblk_disk *disk; | 948 | struct vblk_disk *disk; |
@@ -958,15 +953,15 @@ static BOOL ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb) | |||
958 | r_name = ldm_relative (buffer, buflen, 0x18, r_objid); | 953 | r_name = ldm_relative (buffer, buflen, 0x18, r_objid); |
959 | len = r_name; | 954 | len = r_name; |
960 | if (len < 0) | 955 | if (len < 0) |
961 | return FALSE; | 956 | return false; |
962 | 957 | ||
963 | len += VBLK_SIZE_DSK4; | 958 | len += VBLK_SIZE_DSK4; |
964 | if (len != BE32 (buffer + 0x14)) | 959 | if (len != BE32 (buffer + 0x14)) |
965 | return FALSE; | 960 | return false; |
966 | 961 | ||
967 | disk = &vb->vblk.disk; | 962 | disk = &vb->vblk.disk; |
968 | memcpy (disk->disk_id, buffer + 0x18 + r_name, GUID_SIZE); | 963 | memcpy (disk->disk_id, buffer + 0x18 + r_name, GUID_SIZE); |
969 | return TRUE; | 964 | return true; |
970 | } | 965 | } |
971 | 966 | ||
972 | /** | 967 | /** |
@@ -977,10 +972,10 @@ static BOOL ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb) | |||
977 | * | 972 | * |
978 | * Read a raw VBLK Partition object (version 3) into a vblk structure. | 973 | * Read a raw VBLK Partition object (version 3) into a vblk structure. |
979 | * | 974 | * |
980 | * Return: TRUE @vb contains a Partition VBLK | 975 | * Return: 'true' @vb contains a Partition VBLK |
981 | * FALSE @vb contents are not defined | 976 | * 'false' @vb contents are not defined |
982 | */ | 977 | */ |
983 | static BOOL ldm_parse_prt3 (const u8 *buffer, int buflen, struct vblk *vb) | 978 | static bool ldm_parse_prt3 (const u8 *buffer, int buflen, struct vblk *vb) |
984 | { | 979 | { |
985 | int r_objid, r_name, r_size, r_parent, r_diskid, r_index, len; | 980 | int r_objid, r_name, r_size, r_parent, r_diskid, r_index, len; |
986 | struct vblk_part *part; | 981 | struct vblk_part *part; |
@@ -1001,11 +996,11 @@ static BOOL ldm_parse_prt3 (const u8 *buffer, int buflen, struct vblk *vb) | |||
1001 | len = r_diskid; | 996 | len = r_diskid; |
1002 | } | 997 | } |
1003 | if (len < 0) | 998 | if (len < 0) |
1004 | return FALSE; | 999 | return false; |
1005 | 1000 | ||
1006 | len += VBLK_SIZE_PRT3; | 1001 | len += VBLK_SIZE_PRT3; |
1007 | if (len != BE32 (buffer + 0x14)) | 1002 | if (len != BE32 (buffer + 0x14)) |
1008 | return FALSE; | 1003 | return false; |
1009 | 1004 | ||
1010 | part = &vb->vblk.part; | 1005 | part = &vb->vblk.part; |
1011 | part->start = BE64 (buffer + 0x24 + r_name); | 1006 | part->start = BE64 (buffer + 0x24 + r_name); |
@@ -1018,7 +1013,7 @@ static BOOL ldm_parse_prt3 (const u8 *buffer, int buflen, struct vblk *vb) | |||
1018 | else | 1013 | else |
1019 | part->partnum = 0; | 1014 | part->partnum = 0; |
1020 | 1015 | ||
1021 | return TRUE; | 1016 | return true; |
1022 | } | 1017 | } |
1023 | 1018 | ||
1024 | /** | 1019 | /** |
@@ -1029,10 +1024,10 @@ static BOOL ldm_parse_prt3 (const u8 *buffer, int buflen, struct vblk *vb) | |||
1029 | * | 1024 | * |
1030 | * Read a raw VBLK Volume object (version 5) into a vblk structure. | 1025 | * Read a raw VBLK Volume object (version 5) into a vblk structure. |
1031 | * | 1026 | * |
1032 | * Return: TRUE @vb contains a Volume VBLK | 1027 | * Return: 'true' @vb contains a Volume VBLK |
1033 | * FALSE @vb contents are not defined | 1028 | * 'false' @vb contents are not defined |
1034 | */ | 1029 | */ |
1035 | static BOOL ldm_parse_vol5 (const u8 *buffer, int buflen, struct vblk *vb) | 1030 | static bool ldm_parse_vol5 (const u8 *buffer, int buflen, struct vblk *vb) |
1036 | { | 1031 | { |
1037 | int r_objid, r_name, r_vtype, r_child, r_size, r_id1, r_id2, r_size2; | 1032 | int r_objid, r_name, r_vtype, r_child, r_size, r_id1, r_id2, r_size2; |
1038 | int r_drive, len; | 1033 | int r_drive, len; |
@@ -1068,11 +1063,11 @@ static BOOL ldm_parse_vol5 (const u8 *buffer, int buflen, struct vblk *vb) | |||
1068 | 1063 | ||
1069 | len = r_drive; | 1064 | len = r_drive; |
1070 | if (len < 0) | 1065 | if (len < 0) |
1071 | return FALSE; | 1066 | return false; |
1072 | 1067 | ||
1073 | len += VBLK_SIZE_VOL5; | 1068 | len += VBLK_SIZE_VOL5; |
1074 | if (len != BE32 (buffer + 0x14)) | 1069 | if (len != BE32 (buffer + 0x14)) |
1075 | return FALSE; | 1070 | return false; |
1076 | 1071 | ||
1077 | volu = &vb->vblk.volu; | 1072 | volu = &vb->vblk.volu; |
1078 | 1073 | ||
@@ -1087,7 +1082,7 @@ static BOOL ldm_parse_vol5 (const u8 *buffer, int buflen, struct vblk *vb) | |||
1087 | ldm_get_vstr (buffer + 0x53 + r_size, volu->drive_hint, | 1082 | ldm_get_vstr (buffer + 0x53 + r_size, volu->drive_hint, |
1088 | sizeof (volu->drive_hint)); | 1083 | sizeof (volu->drive_hint)); |
1089 | } | 1084 | } |
1090 | return TRUE; | 1085 | return true; |
1091 | } | 1086 | } |
1092 | 1087 | ||
1093 | /** | 1088 | /** |
@@ -1100,12 +1095,12 @@ static BOOL ldm_parse_vol5 (const u8 *buffer, int buflen, struct vblk *vb) | |||
1100 | * information common to all VBLK types, then delegates the rest of the work to | 1095 | * information common to all VBLK types, then delegates the rest of the work to |
1101 | * helper functions: ldm_parse_*. | 1096 | * helper functions: ldm_parse_*. |
1102 | * | 1097 | * |
1103 | * Return: TRUE @vb contains a VBLK | 1098 | * Return: 'true' @vb contains a VBLK |
1104 | * FALSE @vb contents are not defined | 1099 | * 'false' @vb contents are not defined |
1105 | */ | 1100 | */ |
1106 | static BOOL ldm_parse_vblk (const u8 *buf, int len, struct vblk *vb) | 1101 | static bool ldm_parse_vblk (const u8 *buf, int len, struct vblk *vb) |
1107 | { | 1102 | { |
1108 | BOOL result = FALSE; | 1103 | bool result = false; |
1109 | int r_objid; | 1104 | int r_objid; |
1110 | 1105 | ||
1111 | BUG_ON (!buf || !vb); | 1106 | BUG_ON (!buf || !vb); |
@@ -1113,7 +1108,7 @@ static BOOL ldm_parse_vblk (const u8 *buf, int len, struct vblk *vb) | |||
1113 | r_objid = ldm_relative (buf, len, 0x18, 0); | 1108 | r_objid = ldm_relative (buf, len, 0x18, 0); |
1114 | if (r_objid < 0) { | 1109 | if (r_objid < 0) { |
1115 | ldm_error ("VBLK header is corrupt."); | 1110 | ldm_error ("VBLK header is corrupt."); |
1116 | return FALSE; | 1111 | return false; |
1117 | } | 1112 | } |
1118 | 1113 | ||
1119 | vb->flags = buf[0x12]; | 1114 | vb->flags = buf[0x12]; |
@@ -1152,10 +1147,10 @@ static BOOL ldm_parse_vblk (const u8 *buf, int len, struct vblk *vb) | |||
1152 | * | 1147 | * |
1153 | * N.B. This function does not check the validity of the VBLKs. | 1148 | * N.B. This function does not check the validity of the VBLKs. |
1154 | * | 1149 | * |
1155 | * Return: TRUE The VBLK was added | 1150 | * Return: 'true' The VBLK was added |
1156 | * FALSE An error occurred | 1151 | * 'false' An error occurred |
1157 | */ | 1152 | */ |
1158 | static BOOL ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb) | 1153 | static bool ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb) |
1159 | { | 1154 | { |
1160 | struct vblk *vb; | 1155 | struct vblk *vb; |
1161 | struct list_head *item; | 1156 | struct list_head *item; |
@@ -1165,12 +1160,12 @@ static BOOL ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb) | |||
1165 | vb = kmalloc (sizeof (*vb), GFP_KERNEL); | 1160 | vb = kmalloc (sizeof (*vb), GFP_KERNEL); |
1166 | if (!vb) { | 1161 | if (!vb) { |
1167 | ldm_crit ("Out of memory."); | 1162 | ldm_crit ("Out of memory."); |
1168 | return FALSE; | 1163 | return false; |
1169 | } | 1164 | } |
1170 | 1165 | ||
1171 | if (!ldm_parse_vblk (data, len, vb)) { | 1166 | if (!ldm_parse_vblk (data, len, vb)) { |
1172 | kfree(vb); | 1167 | kfree(vb); |
1173 | return FALSE; /* Already logged */ | 1168 | return false; /* Already logged */ |
1174 | } | 1169 | } |
1175 | 1170 | ||
1176 | /* Put vblk into the correct list. */ | 1171 | /* Put vblk into the correct list. */ |
@@ -1196,13 +1191,13 @@ static BOOL ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb) | |||
1196 | if ((v->vblk.part.disk_id == vb->vblk.part.disk_id) && | 1191 | if ((v->vblk.part.disk_id == vb->vblk.part.disk_id) && |
1197 | (v->vblk.part.start > vb->vblk.part.start)) { | 1192 | (v->vblk.part.start > vb->vblk.part.start)) { |
1198 | list_add_tail (&vb->list, &v->list); | 1193 | list_add_tail (&vb->list, &v->list); |
1199 | return TRUE; | 1194 | return true; |
1200 | } | 1195 | } |
1201 | } | 1196 | } |
1202 | list_add_tail (&vb->list, &ldb->v_part); | 1197 | list_add_tail (&vb->list, &ldb->v_part); |
1203 | break; | 1198 | break; |
1204 | } | 1199 | } |
1205 | return TRUE; | 1200 | return true; |
1206 | } | 1201 | } |
1207 | 1202 | ||
1208 | /** | 1203 | /** |
@@ -1214,10 +1209,10 @@ static BOOL ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb) | |||
1214 | * Fragmented VBLKs may not be consecutive in the database, so they are placed | 1209 | * Fragmented VBLKs may not be consecutive in the database, so they are placed |
1215 | * in a list so they can be pieced together later. | 1210 | * in a list so they can be pieced together later. |
1216 | * | 1211 | * |
1217 | * Return: TRUE Success, the VBLK was added to the list | 1212 | * Return: 'true' Success, the VBLK was added to the list |
1218 | * FALSE Error, a problem occurred | 1213 | * 'false' Error, a problem occurred |
1219 | */ | 1214 | */ |
1220 | static BOOL ldm_frag_add (const u8 *data, int size, struct list_head *frags) | 1215 | static bool ldm_frag_add (const u8 *data, int size, struct list_head *frags) |
1221 | { | 1216 | { |
1222 | struct frag *f; | 1217 | struct frag *f; |
1223 | struct list_head *item; | 1218 | struct list_head *item; |
@@ -1230,7 +1225,7 @@ static BOOL ldm_frag_add (const u8 *data, int size, struct list_head *frags) | |||
1230 | num = BE16 (data + 0x0E); | 1225 | num = BE16 (data + 0x0E); |
1231 | if ((num < 1) || (num > 4)) { | 1226 | if ((num < 1) || (num > 4)) { |
1232 | ldm_error ("A VBLK claims to have %d parts.", num); | 1227 | ldm_error ("A VBLK claims to have %d parts.", num); |
1233 | return FALSE; | 1228 | return false; |
1234 | } | 1229 | } |
1235 | 1230 | ||
1236 | list_for_each (item, frags) { | 1231 | list_for_each (item, frags) { |
@@ -1242,7 +1237,7 @@ static BOOL ldm_frag_add (const u8 *data, int size, struct list_head *frags) | |||
1242 | f = kmalloc (sizeof (*f) + size*num, GFP_KERNEL); | 1237 | f = kmalloc (sizeof (*f) + size*num, GFP_KERNEL); |
1243 | if (!f) { | 1238 | if (!f) { |
1244 | ldm_crit ("Out of memory."); | 1239 | ldm_crit ("Out of memory."); |
1245 | return FALSE; | 1240 | return false; |
1246 | } | 1241 | } |
1247 | 1242 | ||
1248 | f->group = group; | 1243 | f->group = group; |
@@ -1255,7 +1250,7 @@ found: | |||
1255 | if (f->map & (1 << rec)) { | 1250 | if (f->map & (1 << rec)) { |
1256 | ldm_error ("Duplicate VBLK, part %d.", rec); | 1251 | ldm_error ("Duplicate VBLK, part %d.", rec); |
1257 | f->map &= 0x7F; /* Mark the group as broken */ | 1252 | f->map &= 0x7F; /* Mark the group as broken */ |
1258 | return FALSE; | 1253 | return false; |
1259 | } | 1254 | } |
1260 | 1255 | ||
1261 | f->map |= (1 << rec); | 1256 | f->map |= (1 << rec); |
@@ -1266,7 +1261,7 @@ found: | |||
1266 | } | 1261 | } |
1267 | memcpy (f->data+rec*(size-VBLK_SIZE_HEAD)+VBLK_SIZE_HEAD, data, size); | 1262 | memcpy (f->data+rec*(size-VBLK_SIZE_HEAD)+VBLK_SIZE_HEAD, data, size); |
1268 | 1263 | ||
1269 | return TRUE; | 1264 | return true; |
1270 | } | 1265 | } |
1271 | 1266 | ||
1272 | /** | 1267 | /** |
@@ -1295,10 +1290,10 @@ static void ldm_frag_free (struct list_head *list) | |||
1295 | * Now that all the fragmented VBLKs have been collected, they must be added to | 1290 | * Now that all the fragmented VBLKs have been collected, they must be added to |
1296 | * the database for later use. | 1291 | * the database for later use. |
1297 | * | 1292 | * |
1298 | * Return: TRUE All the fragments we added successfully | 1293 | * Return: 'true' All the fragments we added successfully |
1299 | * FALSE One or more of the fragments we invalid | 1294 | * 'false' One or more of the fragments we invalid |
1300 | */ | 1295 | */ |
1301 | static BOOL ldm_frag_commit (struct list_head *frags, struct ldmdb *ldb) | 1296 | static bool ldm_frag_commit (struct list_head *frags, struct ldmdb *ldb) |
1302 | { | 1297 | { |
1303 | struct frag *f; | 1298 | struct frag *f; |
1304 | struct list_head *item; | 1299 | struct list_head *item; |
@@ -1311,13 +1306,13 @@ static BOOL ldm_frag_commit (struct list_head *frags, struct ldmdb *ldb) | |||
1311 | if (f->map != 0xFF) { | 1306 | if (f->map != 0xFF) { |
1312 | ldm_error ("VBLK group %d is incomplete (0x%02x).", | 1307 | ldm_error ("VBLK group %d is incomplete (0x%02x).", |
1313 | f->group, f->map); | 1308 | f->group, f->map); |
1314 | return FALSE; | 1309 | return false; |
1315 | } | 1310 | } |
1316 | 1311 | ||
1317 | if (!ldm_ldmdb_add (f->data, f->num*ldb->vm.vblk_size, ldb)) | 1312 | if (!ldm_ldmdb_add (f->data, f->num*ldb->vm.vblk_size, ldb)) |
1318 | return FALSE; /* Already logged */ | 1313 | return false; /* Already logged */ |
1319 | } | 1314 | } |
1320 | return TRUE; | 1315 | return true; |
1321 | } | 1316 | } |
1322 | 1317 | ||
1323 | /** | 1318 | /** |
@@ -1329,16 +1324,16 @@ static BOOL ldm_frag_commit (struct list_head *frags, struct ldmdb *ldb) | |||
1329 | * To use the information from the VBLKs, they need to be read from the disk, | 1324 | * To use the information from the VBLKs, they need to be read from the disk, |
1330 | * unpacked and validated. We cache them in @ldb according to their type. | 1325 | * unpacked and validated. We cache them in @ldb according to their type. |
1331 | * | 1326 | * |
1332 | * Return: TRUE All the VBLKs were read successfully | 1327 | * Return: 'true' All the VBLKs were read successfully |
1333 | * FALSE An error occurred | 1328 | * 'false' An error occurred |
1334 | */ | 1329 | */ |
1335 | static BOOL ldm_get_vblks (struct block_device *bdev, unsigned long base, | 1330 | static bool ldm_get_vblks (struct block_device *bdev, unsigned long base, |
1336 | struct ldmdb *ldb) | 1331 | struct ldmdb *ldb) |
1337 | { | 1332 | { |
1338 | int size, perbuf, skip, finish, s, v, recs; | 1333 | int size, perbuf, skip, finish, s, v, recs; |
1339 | u8 *data = NULL; | 1334 | u8 *data = NULL; |
1340 | Sector sect; | 1335 | Sector sect; |
1341 | BOOL result = FALSE; | 1336 | bool result = false; |
1342 | LIST_HEAD (frags); | 1337 | LIST_HEAD (frags); |
1343 | 1338 | ||
1344 | BUG_ON (!bdev || !ldb); | 1339 | BUG_ON (!bdev || !ldb); |
diff --git a/fs/partitions/msdos.c b/fs/partitions/msdos.c index 8f12587c3129..4f8df71e49d3 100644 --- a/fs/partitions/msdos.c +++ b/fs/partitions/msdos.c | |||
@@ -58,6 +58,31 @@ msdos_magic_present(unsigned char *p) | |||
58 | return (p[0] == MSDOS_LABEL_MAGIC1 && p[1] == MSDOS_LABEL_MAGIC2); | 58 | return (p[0] == MSDOS_LABEL_MAGIC1 && p[1] == MSDOS_LABEL_MAGIC2); |
59 | } | 59 | } |
60 | 60 | ||
61 | /* Value is EBCDIC 'IBMA' */ | ||
62 | #define AIX_LABEL_MAGIC1 0xC9 | ||
63 | #define AIX_LABEL_MAGIC2 0xC2 | ||
64 | #define AIX_LABEL_MAGIC3 0xD4 | ||
65 | #define AIX_LABEL_MAGIC4 0xC1 | ||
66 | static int aix_magic_present(unsigned char *p, struct block_device *bdev) | ||
67 | { | ||
68 | Sector sect; | ||
69 | unsigned char *d; | ||
70 | int ret = 0; | ||
71 | |||
72 | if (p[0] != AIX_LABEL_MAGIC1 && | ||
73 | p[1] != AIX_LABEL_MAGIC2 && | ||
74 | p[2] != AIX_LABEL_MAGIC3 && | ||
75 | p[3] != AIX_LABEL_MAGIC4) | ||
76 | return 0; | ||
77 | d = read_dev_sector(bdev, 7, §); | ||
78 | if (d) { | ||
79 | if (d[0] == '_' && d[1] == 'L' && d[2] == 'V' && d[3] == 'M') | ||
80 | ret = 1; | ||
81 | put_dev_sector(sect); | ||
82 | }; | ||
83 | return ret; | ||
84 | } | ||
85 | |||
61 | /* | 86 | /* |
62 | * Create devices for each logical partition in an extended partition. | 87 | * Create devices for each logical partition in an extended partition. |
63 | * The logical partitions form a linked list, with each entry being | 88 | * The logical partitions form a linked list, with each entry being |
@@ -393,6 +418,12 @@ int msdos_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
393 | return 0; | 418 | return 0; |
394 | } | 419 | } |
395 | 420 | ||
421 | if (aix_magic_present(data, bdev)) { | ||
422 | put_dev_sector(sect); | ||
423 | printk( " [AIX]"); | ||
424 | return 0; | ||
425 | } | ||
426 | |||
396 | /* | 427 | /* |
397 | * Now that the 55aa signature is present, this is probably | 428 | * Now that the 55aa signature is present, this is probably |
398 | * either the boot sector of a FAT filesystem or a DOS-type | 429 | * either the boot sector of a FAT filesystem or a DOS-type |
@@ -218,9 +218,10 @@ static struct pipe_buf_operations anon_pipe_buf_ops = { | |||
218 | }; | 218 | }; |
219 | 219 | ||
220 | static ssize_t | 220 | static ssize_t |
221 | pipe_readv(struct file *filp, const struct iovec *_iov, | 221 | pipe_read(struct kiocb *iocb, const struct iovec *_iov, |
222 | unsigned long nr_segs, loff_t *ppos) | 222 | unsigned long nr_segs, loff_t pos) |
223 | { | 223 | { |
224 | struct file *filp = iocb->ki_filp; | ||
224 | struct inode *inode = filp->f_dentry->d_inode; | 225 | struct inode *inode = filp->f_dentry->d_inode; |
225 | struct pipe_inode_info *pipe; | 226 | struct pipe_inode_info *pipe; |
226 | int do_wakeup; | 227 | int do_wakeup; |
@@ -330,17 +331,10 @@ redo: | |||
330 | } | 331 | } |
331 | 332 | ||
332 | static ssize_t | 333 | static ssize_t |
333 | pipe_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos) | 334 | pipe_write(struct kiocb *iocb, const struct iovec *_iov, |
334 | { | 335 | unsigned long nr_segs, loff_t ppos) |
335 | struct iovec iov = { .iov_base = buf, .iov_len = count }; | ||
336 | |||
337 | return pipe_readv(filp, &iov, 1, ppos); | ||
338 | } | ||
339 | |||
340 | static ssize_t | ||
341 | pipe_writev(struct file *filp, const struct iovec *_iov, | ||
342 | unsigned long nr_segs, loff_t *ppos) | ||
343 | { | 336 | { |
337 | struct file *filp = iocb->ki_filp; | ||
344 | struct inode *inode = filp->f_dentry->d_inode; | 338 | struct inode *inode = filp->f_dentry->d_inode; |
345 | struct pipe_inode_info *pipe; | 339 | struct pipe_inode_info *pipe; |
346 | ssize_t ret; | 340 | ssize_t ret; |
@@ -510,15 +504,6 @@ out: | |||
510 | } | 504 | } |
511 | 505 | ||
512 | static ssize_t | 506 | static ssize_t |
513 | pipe_write(struct file *filp, const char __user *buf, | ||
514 | size_t count, loff_t *ppos) | ||
515 | { | ||
516 | struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = count }; | ||
517 | |||
518 | return pipe_writev(filp, &iov, 1, ppos); | ||
519 | } | ||
520 | |||
521 | static ssize_t | ||
522 | bad_pipe_r(struct file *filp, char __user *buf, size_t count, loff_t *ppos) | 507 | bad_pipe_r(struct file *filp, char __user *buf, size_t count, loff_t *ppos) |
523 | { | 508 | { |
524 | return -EBADF; | 509 | return -EBADF; |
@@ -736,8 +721,8 @@ pipe_rdwr_open(struct inode *inode, struct file *filp) | |||
736 | */ | 721 | */ |
737 | const struct file_operations read_fifo_fops = { | 722 | const struct file_operations read_fifo_fops = { |
738 | .llseek = no_llseek, | 723 | .llseek = no_llseek, |
739 | .read = pipe_read, | 724 | .read = do_sync_read, |
740 | .readv = pipe_readv, | 725 | .aio_read = pipe_read, |
741 | .write = bad_pipe_w, | 726 | .write = bad_pipe_w, |
742 | .poll = pipe_poll, | 727 | .poll = pipe_poll, |
743 | .ioctl = pipe_ioctl, | 728 | .ioctl = pipe_ioctl, |
@@ -749,8 +734,8 @@ const struct file_operations read_fifo_fops = { | |||
749 | const struct file_operations write_fifo_fops = { | 734 | const struct file_operations write_fifo_fops = { |
750 | .llseek = no_llseek, | 735 | .llseek = no_llseek, |
751 | .read = bad_pipe_r, | 736 | .read = bad_pipe_r, |
752 | .write = pipe_write, | 737 | .write = do_sync_write, |
753 | .writev = pipe_writev, | 738 | .aio_write = pipe_write, |
754 | .poll = pipe_poll, | 739 | .poll = pipe_poll, |
755 | .ioctl = pipe_ioctl, | 740 | .ioctl = pipe_ioctl, |
756 | .open = pipe_write_open, | 741 | .open = pipe_write_open, |
@@ -760,10 +745,10 @@ const struct file_operations write_fifo_fops = { | |||
760 | 745 | ||
761 | const struct file_operations rdwr_fifo_fops = { | 746 | const struct file_operations rdwr_fifo_fops = { |
762 | .llseek = no_llseek, | 747 | .llseek = no_llseek, |
763 | .read = pipe_read, | 748 | .read = do_sync_read, |
764 | .readv = pipe_readv, | 749 | .aio_read = pipe_read, |
765 | .write = pipe_write, | 750 | .write = do_sync_write, |
766 | .writev = pipe_writev, | 751 | .aio_write = pipe_write, |
767 | .poll = pipe_poll, | 752 | .poll = pipe_poll, |
768 | .ioctl = pipe_ioctl, | 753 | .ioctl = pipe_ioctl, |
769 | .open = pipe_rdwr_open, | 754 | .open = pipe_rdwr_open, |
@@ -773,8 +758,8 @@ const struct file_operations rdwr_fifo_fops = { | |||
773 | 758 | ||
774 | static struct file_operations read_pipe_fops = { | 759 | static struct file_operations read_pipe_fops = { |
775 | .llseek = no_llseek, | 760 | .llseek = no_llseek, |
776 | .read = pipe_read, | 761 | .read = do_sync_read, |
777 | .readv = pipe_readv, | 762 | .aio_read = pipe_read, |
778 | .write = bad_pipe_w, | 763 | .write = bad_pipe_w, |
779 | .poll = pipe_poll, | 764 | .poll = pipe_poll, |
780 | .ioctl = pipe_ioctl, | 765 | .ioctl = pipe_ioctl, |
@@ -786,8 +771,8 @@ static struct file_operations read_pipe_fops = { | |||
786 | static struct file_operations write_pipe_fops = { | 771 | static struct file_operations write_pipe_fops = { |
787 | .llseek = no_llseek, | 772 | .llseek = no_llseek, |
788 | .read = bad_pipe_r, | 773 | .read = bad_pipe_r, |
789 | .write = pipe_write, | 774 | .write = do_sync_write, |
790 | .writev = pipe_writev, | 775 | .aio_write = pipe_write, |
791 | .poll = pipe_poll, | 776 | .poll = pipe_poll, |
792 | .ioctl = pipe_ioctl, | 777 | .ioctl = pipe_ioctl, |
793 | .open = pipe_write_open, | 778 | .open = pipe_write_open, |
@@ -797,10 +782,10 @@ static struct file_operations write_pipe_fops = { | |||
797 | 782 | ||
798 | static struct file_operations rdwr_pipe_fops = { | 783 | static struct file_operations rdwr_pipe_fops = { |
799 | .llseek = no_llseek, | 784 | .llseek = no_llseek, |
800 | .read = pipe_read, | 785 | .read = do_sync_read, |
801 | .readv = pipe_readv, | 786 | .aio_read = pipe_read, |
802 | .write = pipe_write, | 787 | .write = do_sync_write, |
803 | .writev = pipe_writev, | 788 | .aio_write = pipe_write, |
804 | .poll = pipe_poll, | 789 | .poll = pipe_poll, |
805 | .ioctl = pipe_ioctl, | 790 | .ioctl = pipe_ioctl, |
806 | .open = pipe_rdwr_open, | 791 | .open = pipe_rdwr_open, |
@@ -889,87 +874,118 @@ fail_inode: | |||
889 | return NULL; | 874 | return NULL; |
890 | } | 875 | } |
891 | 876 | ||
892 | int do_pipe(int *fd) | 877 | struct file *create_write_pipe(void) |
893 | { | 878 | { |
894 | struct qstr this; | 879 | int err; |
895 | char name[32]; | 880 | struct inode *inode; |
881 | struct file *f; | ||
896 | struct dentry *dentry; | 882 | struct dentry *dentry; |
897 | struct inode * inode; | 883 | char name[32]; |
898 | struct file *f1, *f2; | 884 | struct qstr this; |
899 | int error; | ||
900 | int i, j; | ||
901 | |||
902 | error = -ENFILE; | ||
903 | f1 = get_empty_filp(); | ||
904 | if (!f1) | ||
905 | goto no_files; | ||
906 | |||
907 | f2 = get_empty_filp(); | ||
908 | if (!f2) | ||
909 | goto close_f1; | ||
910 | 885 | ||
886 | f = get_empty_filp(); | ||
887 | if (!f) | ||
888 | return ERR_PTR(-ENFILE); | ||
889 | err = -ENFILE; | ||
911 | inode = get_pipe_inode(); | 890 | inode = get_pipe_inode(); |
912 | if (!inode) | 891 | if (!inode) |
913 | goto close_f12; | 892 | goto err_file; |
914 | |||
915 | error = get_unused_fd(); | ||
916 | if (error < 0) | ||
917 | goto close_f12_inode; | ||
918 | i = error; | ||
919 | |||
920 | error = get_unused_fd(); | ||
921 | if (error < 0) | ||
922 | goto close_f12_inode_i; | ||
923 | j = error; | ||
924 | 893 | ||
925 | error = -ENOMEM; | ||
926 | sprintf(name, "[%lu]", inode->i_ino); | 894 | sprintf(name, "[%lu]", inode->i_ino); |
927 | this.name = name; | 895 | this.name = name; |
928 | this.len = strlen(name); | 896 | this.len = strlen(name); |
929 | this.hash = inode->i_ino; /* will go */ | 897 | this.hash = inode->i_ino; /* will go */ |
898 | err = -ENOMEM; | ||
930 | dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this); | 899 | dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this); |
931 | if (!dentry) | 900 | if (!dentry) |
932 | goto close_f12_inode_i_j; | 901 | goto err_inode; |
933 | 902 | ||
934 | dentry->d_op = &pipefs_dentry_operations; | 903 | dentry->d_op = &pipefs_dentry_operations; |
935 | d_add(dentry, inode); | 904 | d_add(dentry, inode); |
936 | f1->f_vfsmnt = f2->f_vfsmnt = mntget(mntget(pipe_mnt)); | 905 | f->f_vfsmnt = mntget(pipe_mnt); |
937 | f1->f_dentry = f2->f_dentry = dget(dentry); | 906 | f->f_dentry = dentry; |
938 | f1->f_mapping = f2->f_mapping = inode->i_mapping; | 907 | f->f_mapping = inode->i_mapping; |
939 | |||
940 | /* read file */ | ||
941 | f1->f_pos = f2->f_pos = 0; | ||
942 | f1->f_flags = O_RDONLY; | ||
943 | f1->f_op = &read_pipe_fops; | ||
944 | f1->f_mode = FMODE_READ; | ||
945 | f1->f_version = 0; | ||
946 | |||
947 | /* write file */ | ||
948 | f2->f_flags = O_WRONLY; | ||
949 | f2->f_op = &write_pipe_fops; | ||
950 | f2->f_mode = FMODE_WRITE; | ||
951 | f2->f_version = 0; | ||
952 | |||
953 | fd_install(i, f1); | ||
954 | fd_install(j, f2); | ||
955 | fd[0] = i; | ||
956 | fd[1] = j; | ||
957 | 908 | ||
958 | return 0; | 909 | f->f_flags = O_WRONLY; |
910 | f->f_op = &write_pipe_fops; | ||
911 | f->f_mode = FMODE_WRITE; | ||
912 | f->f_version = 0; | ||
913 | |||
914 | return f; | ||
959 | 915 | ||
960 | close_f12_inode_i_j: | 916 | err_inode: |
961 | put_unused_fd(j); | ||
962 | close_f12_inode_i: | ||
963 | put_unused_fd(i); | ||
964 | close_f12_inode: | ||
965 | free_pipe_info(inode); | 917 | free_pipe_info(inode); |
966 | iput(inode); | 918 | iput(inode); |
967 | close_f12: | 919 | err_file: |
968 | put_filp(f2); | 920 | put_filp(f); |
969 | close_f1: | 921 | return ERR_PTR(err); |
970 | put_filp(f1); | 922 | } |
971 | no_files: | 923 | |
972 | return error; | 924 | void free_write_pipe(struct file *f) |
925 | { | ||
926 | mntput(f->f_vfsmnt); | ||
927 | dput(f->f_dentry); | ||
928 | put_filp(f); | ||
929 | } | ||
930 | |||
931 | struct file *create_read_pipe(struct file *wrf) | ||
932 | { | ||
933 | struct file *f = get_empty_filp(); | ||
934 | if (!f) | ||
935 | return ERR_PTR(-ENFILE); | ||
936 | |||
937 | /* Grab pipe from the writer */ | ||
938 | f->f_vfsmnt = mntget(wrf->f_vfsmnt); | ||
939 | f->f_dentry = dget(wrf->f_dentry); | ||
940 | f->f_mapping = wrf->f_dentry->d_inode->i_mapping; | ||
941 | |||
942 | f->f_pos = 0; | ||
943 | f->f_flags = O_RDONLY; | ||
944 | f->f_op = &read_pipe_fops; | ||
945 | f->f_mode = FMODE_READ; | ||
946 | f->f_version = 0; | ||
947 | |||
948 | return f; | ||
949 | } | ||
950 | |||
951 | int do_pipe(int *fd) | ||
952 | { | ||
953 | struct file *fw, *fr; | ||
954 | int error; | ||
955 | int fdw, fdr; | ||
956 | |||
957 | fw = create_write_pipe(); | ||
958 | if (IS_ERR(fw)) | ||
959 | return PTR_ERR(fw); | ||
960 | fr = create_read_pipe(fw); | ||
961 | error = PTR_ERR(fr); | ||
962 | if (IS_ERR(fr)) | ||
963 | goto err_write_pipe; | ||
964 | |||
965 | error = get_unused_fd(); | ||
966 | if (error < 0) | ||
967 | goto err_read_pipe; | ||
968 | fdr = error; | ||
969 | |||
970 | error = get_unused_fd(); | ||
971 | if (error < 0) | ||
972 | goto err_fdr; | ||
973 | fdw = error; | ||
974 | |||
975 | fd_install(fdr, fr); | ||
976 | fd_install(fdw, fw); | ||
977 | fd[0] = fdr; | ||
978 | fd[1] = fdw; | ||
979 | |||
980 | return 0; | ||
981 | |||
982 | err_fdr: | ||
983 | put_unused_fd(fdr); | ||
984 | err_read_pipe: | ||
985 | put_filp(fr); | ||
986 | err_write_pipe: | ||
987 | free_write_pipe(fw); | ||
988 | return error; | ||
973 | } | 989 | } |
974 | 990 | ||
975 | /* | 991 | /* |
diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 6c8dcf7613fd..aec931e09973 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c | |||
@@ -58,11 +58,9 @@ posix_acl_clone(const struct posix_acl *acl, gfp_t flags) | |||
58 | if (acl) { | 58 | if (acl) { |
59 | int size = sizeof(struct posix_acl) + acl->a_count * | 59 | int size = sizeof(struct posix_acl) + acl->a_count * |
60 | sizeof(struct posix_acl_entry); | 60 | sizeof(struct posix_acl_entry); |
61 | clone = kmalloc(size, flags); | 61 | clone = kmemdup(acl, size, flags); |
62 | if (clone) { | 62 | if (clone) |
63 | memcpy(clone, acl, size); | ||
64 | atomic_set(&clone->a_refcount, 1); | 63 | atomic_set(&clone->a_refcount, 1); |
65 | } | ||
66 | } | 64 | } |
67 | return clone; | 65 | return clone; |
68 | } | 66 | } |
diff --git a/fs/proc/array.c b/fs/proc/array.c index 0b615d62a159..c0e554971df0 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -347,6 +347,8 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole) | |||
347 | sigemptyset(&sigign); | 347 | sigemptyset(&sigign); |
348 | sigemptyset(&sigcatch); | 348 | sigemptyset(&sigcatch); |
349 | cutime = cstime = utime = stime = cputime_zero; | 349 | cutime = cstime = utime = stime = cputime_zero; |
350 | |||
351 | mutex_lock(&tty_mutex); | ||
350 | read_lock(&tasklist_lock); | 352 | read_lock(&tasklist_lock); |
351 | if (task->sighand) { | 353 | if (task->sighand) { |
352 | spin_lock_irq(&task->sighand->siglock); | 354 | spin_lock_irq(&task->sighand->siglock); |
@@ -388,6 +390,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole) | |||
388 | } | 390 | } |
389 | ppid = pid_alive(task) ? task->group_leader->real_parent->tgid : 0; | 391 | ppid = pid_alive(task) ? task->group_leader->real_parent->tgid : 0; |
390 | read_unlock(&tasklist_lock); | 392 | read_unlock(&tasklist_lock); |
393 | mutex_unlock(&tty_mutex); | ||
391 | 394 | ||
392 | if (!whole || num_threads<2) | 395 | if (!whole || num_threads<2) |
393 | wchan = get_wchan(task); | 396 | wchan = get_wchan(task); |
diff --git a/fs/proc/base.c b/fs/proc/base.c index fe8d55fb17cc..89c20d9d50bf 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -797,7 +797,7 @@ out_no_task: | |||
797 | static ssize_t mem_write(struct file * file, const char * buf, | 797 | static ssize_t mem_write(struct file * file, const char * buf, |
798 | size_t count, loff_t *ppos) | 798 | size_t count, loff_t *ppos) |
799 | { | 799 | { |
800 | int copied = 0; | 800 | int copied; |
801 | char *page; | 801 | char *page; |
802 | struct task_struct *task = get_proc_task(file->f_dentry->d_inode); | 802 | struct task_struct *task = get_proc_task(file->f_dentry->d_inode); |
803 | unsigned long dst = *ppos; | 803 | unsigned long dst = *ppos; |
@@ -814,6 +814,7 @@ static ssize_t mem_write(struct file * file, const char * buf, | |||
814 | if (!page) | 814 | if (!page) |
815 | goto out; | 815 | goto out; |
816 | 816 | ||
817 | copied = 0; | ||
817 | while (count > 0) { | 818 | while (count > 0) { |
818 | int this_len, retval; | 819 | int this_len, retval; |
819 | 820 | ||
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index 3ceff3857272..1294eda4acae 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c | |||
@@ -100,7 +100,7 @@ static int notesize(struct memelfnote *en) | |||
100 | int sz; | 100 | int sz; |
101 | 101 | ||
102 | sz = sizeof(struct elf_note); | 102 | sz = sizeof(struct elf_note); |
103 | sz += roundup(strlen(en->name), 4); | 103 | sz += roundup((strlen(en->name) + 1), 4); |
104 | sz += roundup(en->datasz, 4); | 104 | sz += roundup(en->datasz, 4); |
105 | 105 | ||
106 | return sz; | 106 | return sz; |
@@ -116,7 +116,7 @@ static char *storenote(struct memelfnote *men, char *bufp) | |||
116 | 116 | ||
117 | #define DUMP_WRITE(addr,nr) do { memcpy(bufp,addr,nr); bufp += nr; } while(0) | 117 | #define DUMP_WRITE(addr,nr) do { memcpy(bufp,addr,nr); bufp += nr; } while(0) |
118 | 118 | ||
119 | en.n_namesz = strlen(men->name); | 119 | en.n_namesz = strlen(men->name) + 1; |
120 | en.n_descsz = men->datasz; | 120 | en.n_descsz = men->datasz; |
121 | en.n_type = men->type; | 121 | en.n_type = men->type; |
122 | 122 | ||
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 5bbd60896050..66bc425f2f3d 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c | |||
@@ -277,12 +277,15 @@ static int devinfo_show(struct seq_file *f, void *v) | |||
277 | if (i == 0) | 277 | if (i == 0) |
278 | seq_printf(f, "Character devices:\n"); | 278 | seq_printf(f, "Character devices:\n"); |
279 | chrdev_show(f, i); | 279 | chrdev_show(f, i); |
280 | } else { | 280 | } |
281 | #ifdef CONFIG_BLOCK | ||
282 | else { | ||
281 | i -= CHRDEV_MAJOR_HASH_SIZE; | 283 | i -= CHRDEV_MAJOR_HASH_SIZE; |
282 | if (i == 0) | 284 | if (i == 0) |
283 | seq_printf(f, "\nBlock devices:\n"); | 285 | seq_printf(f, "\nBlock devices:\n"); |
284 | blkdev_show(f, i); | 286 | blkdev_show(f, i); |
285 | } | 287 | } |
288 | #endif | ||
286 | return 0; | 289 | return 0; |
287 | } | 290 | } |
288 | 291 | ||
@@ -355,6 +358,7 @@ static int stram_read_proc(char *page, char **start, off_t off, | |||
355 | } | 358 | } |
356 | #endif | 359 | #endif |
357 | 360 | ||
361 | #ifdef CONFIG_BLOCK | ||
358 | extern struct seq_operations partitions_op; | 362 | extern struct seq_operations partitions_op; |
359 | static int partitions_open(struct inode *inode, struct file *file) | 363 | static int partitions_open(struct inode *inode, struct file *file) |
360 | { | 364 | { |
@@ -378,6 +382,7 @@ static struct file_operations proc_diskstats_operations = { | |||
378 | .llseek = seq_lseek, | 382 | .llseek = seq_lseek, |
379 | .release = seq_release, | 383 | .release = seq_release, |
380 | }; | 384 | }; |
385 | #endif | ||
381 | 386 | ||
382 | #ifdef CONFIG_MODULES | 387 | #ifdef CONFIG_MODULES |
383 | extern struct seq_operations modules_op; | 388 | extern struct seq_operations modules_op; |
@@ -695,7 +700,9 @@ void __init proc_misc_init(void) | |||
695 | entry->proc_fops = &proc_kmsg_operations; | 700 | entry->proc_fops = &proc_kmsg_operations; |
696 | create_seq_entry("devices", 0, &proc_devinfo_operations); | 701 | create_seq_entry("devices", 0, &proc_devinfo_operations); |
697 | create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations); | 702 | create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations); |
703 | #ifdef CONFIG_BLOCK | ||
698 | create_seq_entry("partitions", 0, &proc_partitions_operations); | 704 | create_seq_entry("partitions", 0, &proc_partitions_operations); |
705 | #endif | ||
699 | create_seq_entry("stat", 0, &proc_stat_operations); | 706 | create_seq_entry("stat", 0, &proc_stat_operations); |
700 | create_seq_entry("interrupts", 0, &proc_interrupts_operations); | 707 | create_seq_entry("interrupts", 0, &proc_interrupts_operations); |
701 | #ifdef CONFIG_SLAB | 708 | #ifdef CONFIG_SLAB |
@@ -707,7 +714,9 @@ void __init proc_misc_init(void) | |||
707 | create_seq_entry("buddyinfo",S_IRUGO, &fragmentation_file_operations); | 714 | create_seq_entry("buddyinfo",S_IRUGO, &fragmentation_file_operations); |
708 | create_seq_entry("vmstat",S_IRUGO, &proc_vmstat_file_operations); | 715 | create_seq_entry("vmstat",S_IRUGO, &proc_vmstat_file_operations); |
709 | create_seq_entry("zoneinfo",S_IRUGO, &proc_zoneinfo_file_operations); | 716 | create_seq_entry("zoneinfo",S_IRUGO, &proc_zoneinfo_file_operations); |
717 | #ifdef CONFIG_BLOCK | ||
710 | create_seq_entry("diskstats", 0, &proc_diskstats_operations); | 718 | create_seq_entry("diskstats", 0, &proc_diskstats_operations); |
719 | #endif | ||
711 | #ifdef CONFIG_MODULES | 720 | #ifdef CONFIG_MODULES |
712 | create_seq_entry("modules", 0, &proc_modules_operations); | 721 | create_seq_entry("modules", 0, &proc_modules_operations); |
713 | #endif | 722 | #endif |
diff --git a/fs/qnx4/file.c b/fs/qnx4/file.c index 62af4b1348bd..467e5ac7280e 100644 --- a/fs/qnx4/file.c +++ b/fs/qnx4/file.c | |||
@@ -22,11 +22,13 @@ | |||
22 | const struct file_operations qnx4_file_operations = | 22 | const struct file_operations qnx4_file_operations = |
23 | { | 23 | { |
24 | .llseek = generic_file_llseek, | 24 | .llseek = generic_file_llseek, |
25 | .read = generic_file_read, | 25 | .read = do_sync_read, |
26 | .aio_read = generic_file_aio_read, | ||
26 | .mmap = generic_file_mmap, | 27 | .mmap = generic_file_mmap, |
27 | .sendfile = generic_file_sendfile, | 28 | .sendfile = generic_file_sendfile, |
28 | #ifdef CONFIG_QNX4FS_RW | 29 | #ifdef CONFIG_QNX4FS_RW |
29 | .write = generic_file_write, | 30 | .write = do_sync_write, |
31 | .aio_write = generic_file_aio_write, | ||
30 | .fsync = qnx4_sync_file, | 32 | .fsync = qnx4_sync_file, |
31 | #endif | 33 | #endif |
32 | }; | 34 | }; |
diff --git a/fs/qnx4/namei.c b/fs/qnx4/namei.c index c3d83f67154a..733cdf01d645 100644 --- a/fs/qnx4/namei.c +++ b/fs/qnx4/namei.c | |||
@@ -186,11 +186,10 @@ int qnx4_rmdir(struct inode *dir, struct dentry *dentry) | |||
186 | memset(de->di_fname, 0, sizeof de->di_fname); | 186 | memset(de->di_fname, 0, sizeof de->di_fname); |
187 | de->di_mode = 0; | 187 | de->di_mode = 0; |
188 | mark_buffer_dirty(bh); | 188 | mark_buffer_dirty(bh); |
189 | inode->i_nlink = 0; | 189 | clear_nlink(inode); |
190 | mark_inode_dirty(inode); | 190 | mark_inode_dirty(inode); |
191 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; | 191 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; |
192 | dir->i_nlink--; | 192 | inode_dec_link_count(dir); |
193 | mark_inode_dirty(dir); | ||
194 | retval = 0; | 193 | retval = 0; |
195 | 194 | ||
196 | end_rmdir: | 195 | end_rmdir: |
@@ -234,9 +233,8 @@ int qnx4_unlink(struct inode *dir, struct dentry *dentry) | |||
234 | mark_buffer_dirty(bh); | 233 | mark_buffer_dirty(bh); |
235 | dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; | 234 | dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; |
236 | mark_inode_dirty(dir); | 235 | mark_inode_dirty(dir); |
237 | inode->i_nlink--; | ||
238 | inode->i_ctime = dir->i_ctime; | 236 | inode->i_ctime = dir->i_ctime; |
239 | mark_inode_dirty(inode); | 237 | inode_dec_link_count(inode); |
240 | retval = 0; | 238 | retval = 0; |
241 | 239 | ||
242 | end_unlink: | 240 | end_unlink: |
diff --git a/fs/quota.c b/fs/quota.c index d6a2be826e29..b9dae76a0b6e 100644 --- a/fs/quota.c +++ b/fs/quota.c | |||
@@ -338,6 +338,34 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void | |||
338 | } | 338 | } |
339 | 339 | ||
340 | /* | 340 | /* |
341 | * look up a superblock on which quota ops will be performed | ||
342 | * - use the name of a block device to find the superblock thereon | ||
343 | */ | ||
344 | static inline struct super_block *quotactl_block(const char __user *special) | ||
345 | { | ||
346 | #ifdef CONFIG_BLOCK | ||
347 | struct block_device *bdev; | ||
348 | struct super_block *sb; | ||
349 | char *tmp = getname(special); | ||
350 | |||
351 | if (IS_ERR(tmp)) | ||
352 | return ERR_PTR(PTR_ERR(tmp)); | ||
353 | bdev = lookup_bdev(tmp); | ||
354 | putname(tmp); | ||
355 | if (IS_ERR(bdev)) | ||
356 | return ERR_PTR(PTR_ERR(bdev)); | ||
357 | sb = get_super(bdev); | ||
358 | bdput(bdev); | ||
359 | if (!sb) | ||
360 | return ERR_PTR(-ENODEV); | ||
361 | |||
362 | return sb; | ||
363 | #else | ||
364 | return ERR_PTR(-ENODEV); | ||
365 | #endif | ||
366 | } | ||
367 | |||
368 | /* | ||
341 | * This is the system call interface. This communicates with | 369 | * This is the system call interface. This communicates with |
342 | * the user-level programs. Currently this only supports diskquota | 370 | * the user-level programs. Currently this only supports diskquota |
343 | * calls. Maybe we need to add the process quotas etc. in the future, | 371 | * calls. Maybe we need to add the process quotas etc. in the future, |
@@ -347,25 +375,15 @@ asmlinkage long sys_quotactl(unsigned int cmd, const char __user *special, qid_t | |||
347 | { | 375 | { |
348 | uint cmds, type; | 376 | uint cmds, type; |
349 | struct super_block *sb = NULL; | 377 | struct super_block *sb = NULL; |
350 | struct block_device *bdev; | ||
351 | char *tmp; | ||
352 | int ret; | 378 | int ret; |
353 | 379 | ||
354 | cmds = cmd >> SUBCMDSHIFT; | 380 | cmds = cmd >> SUBCMDSHIFT; |
355 | type = cmd & SUBCMDMASK; | 381 | type = cmd & SUBCMDMASK; |
356 | 382 | ||
357 | if (cmds != Q_SYNC || special) { | 383 | if (cmds != Q_SYNC || special) { |
358 | tmp = getname(special); | 384 | sb = quotactl_block(special); |
359 | if (IS_ERR(tmp)) | 385 | if (IS_ERR(sb)) |
360 | return PTR_ERR(tmp); | 386 | return PTR_ERR(sb); |
361 | bdev = lookup_bdev(tmp); | ||
362 | putname(tmp); | ||
363 | if (IS_ERR(bdev)) | ||
364 | return PTR_ERR(bdev); | ||
365 | sb = get_super(bdev); | ||
366 | bdput(bdev); | ||
367 | if (!sb) | ||
368 | return -ENODEV; | ||
369 | } | 387 | } |
370 | 388 | ||
371 | ret = check_quotactl_valid(sb, type, cmds, id); | 389 | ret = check_quotactl_valid(sb, type, cmds, id); |
diff --git a/fs/ramfs/file-mmu.c b/fs/ramfs/file-mmu.c index 86f14cacf641..0947fb57dcf3 100644 --- a/fs/ramfs/file-mmu.c +++ b/fs/ramfs/file-mmu.c | |||
@@ -33,8 +33,10 @@ const struct address_space_operations ramfs_aops = { | |||
33 | }; | 33 | }; |
34 | 34 | ||
35 | const struct file_operations ramfs_file_operations = { | 35 | const struct file_operations ramfs_file_operations = { |
36 | .read = generic_file_read, | 36 | .read = do_sync_read, |
37 | .write = generic_file_write, | 37 | .aio_read = generic_file_aio_read, |
38 | .write = do_sync_write, | ||
39 | .aio_write = generic_file_aio_write, | ||
38 | .mmap = generic_file_mmap, | 40 | .mmap = generic_file_mmap, |
39 | .fsync = simple_sync_file, | 41 | .fsync = simple_sync_file, |
40 | .sendfile = generic_file_sendfile, | 42 | .sendfile = generic_file_sendfile, |
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c index 677139b48e00..bfe5dbf1002e 100644 --- a/fs/ramfs/file-nommu.c +++ b/fs/ramfs/file-nommu.c | |||
@@ -36,8 +36,10 @@ const struct address_space_operations ramfs_aops = { | |||
36 | const struct file_operations ramfs_file_operations = { | 36 | const struct file_operations ramfs_file_operations = { |
37 | .mmap = ramfs_nommu_mmap, | 37 | .mmap = ramfs_nommu_mmap, |
38 | .get_unmapped_area = ramfs_nommu_get_unmapped_area, | 38 | .get_unmapped_area = ramfs_nommu_get_unmapped_area, |
39 | .read = generic_file_read, | 39 | .read = do_sync_read, |
40 | .write = generic_file_write, | 40 | .aio_read = generic_file_aio_read, |
41 | .write = do_sync_write, | ||
42 | .aio_write = generic_file_aio_write, | ||
41 | .fsync = simple_sync_file, | 43 | .fsync = simple_sync_file, |
42 | .sendfile = generic_file_sendfile, | 44 | .sendfile = generic_file_sendfile, |
43 | .llseek = generic_file_llseek, | 45 | .llseek = generic_file_llseek, |
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index bc0e51662424..2faf4cdf61b0 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c | |||
@@ -75,7 +75,7 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev) | |||
75 | inode->i_fop = &simple_dir_operations; | 75 | inode->i_fop = &simple_dir_operations; |
76 | 76 | ||
77 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | 77 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ |
78 | inode->i_nlink++; | 78 | inc_nlink(inode); |
79 | break; | 79 | break; |
80 | case S_IFLNK: | 80 | case S_IFLNK: |
81 | inode->i_op = &page_symlink_inode_operations; | 81 | inode->i_op = &page_symlink_inode_operations; |
@@ -113,7 +113,7 @@ static int ramfs_mkdir(struct inode * dir, struct dentry * dentry, int mode) | |||
113 | { | 113 | { |
114 | int retval = ramfs_mknod(dir, dentry, mode | S_IFDIR, 0); | 114 | int retval = ramfs_mknod(dir, dentry, mode | S_IFDIR, 0); |
115 | if (!retval) | 115 | if (!retval) |
116 | dir->i_nlink++; | 116 | inc_nlink(dir); |
117 | return retval; | 117 | return retval; |
118 | } | 118 | } |
119 | 119 | ||
diff --git a/fs/read_write.c b/fs/read_write.c index d4cb3183c99c..f792000a28e6 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
@@ -15,13 +15,15 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/syscalls.h> | 16 | #include <linux/syscalls.h> |
17 | #include <linux/pagemap.h> | 17 | #include <linux/pagemap.h> |
18 | #include "read_write.h" | ||
18 | 19 | ||
19 | #include <asm/uaccess.h> | 20 | #include <asm/uaccess.h> |
20 | #include <asm/unistd.h> | 21 | #include <asm/unistd.h> |
21 | 22 | ||
22 | const struct file_operations generic_ro_fops = { | 23 | const struct file_operations generic_ro_fops = { |
23 | .llseek = generic_file_llseek, | 24 | .llseek = generic_file_llseek, |
24 | .read = generic_file_read, | 25 | .read = do_sync_read, |
26 | .aio_read = generic_file_aio_read, | ||
25 | .mmap = generic_file_readonly_mmap, | 27 | .mmap = generic_file_readonly_mmap, |
26 | .sendfile = generic_file_sendfile, | 28 | .sendfile = generic_file_sendfile, |
27 | }; | 29 | }; |
@@ -227,14 +229,20 @@ static void wait_on_retry_sync_kiocb(struct kiocb *iocb) | |||
227 | 229 | ||
228 | ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos) | 230 | ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos) |
229 | { | 231 | { |
232 | struct iovec iov = { .iov_base = buf, .iov_len = len }; | ||
230 | struct kiocb kiocb; | 233 | struct kiocb kiocb; |
231 | ssize_t ret; | 234 | ssize_t ret; |
232 | 235 | ||
233 | init_sync_kiocb(&kiocb, filp); | 236 | init_sync_kiocb(&kiocb, filp); |
234 | kiocb.ki_pos = *ppos; | 237 | kiocb.ki_pos = *ppos; |
235 | while (-EIOCBRETRY == | 238 | kiocb.ki_left = len; |
236 | (ret = filp->f_op->aio_read(&kiocb, buf, len, kiocb.ki_pos))) | 239 | |
240 | for (;;) { | ||
241 | ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos); | ||
242 | if (ret != -EIOCBRETRY) | ||
243 | break; | ||
237 | wait_on_retry_sync_kiocb(&kiocb); | 244 | wait_on_retry_sync_kiocb(&kiocb); |
245 | } | ||
238 | 246 | ||
239 | if (-EIOCBQUEUED == ret) | 247 | if (-EIOCBQUEUED == ret) |
240 | ret = wait_on_sync_kiocb(&kiocb); | 248 | ret = wait_on_sync_kiocb(&kiocb); |
@@ -279,14 +287,20 @@ EXPORT_SYMBOL(vfs_read); | |||
279 | 287 | ||
280 | ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos) | 288 | ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos) |
281 | { | 289 | { |
290 | struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = len }; | ||
282 | struct kiocb kiocb; | 291 | struct kiocb kiocb; |
283 | ssize_t ret; | 292 | ssize_t ret; |
284 | 293 | ||
285 | init_sync_kiocb(&kiocb, filp); | 294 | init_sync_kiocb(&kiocb, filp); |
286 | kiocb.ki_pos = *ppos; | 295 | kiocb.ki_pos = *ppos; |
287 | while (-EIOCBRETRY == | 296 | kiocb.ki_left = len; |
288 | (ret = filp->f_op->aio_write(&kiocb, buf, len, kiocb.ki_pos))) | 297 | |
298 | for (;;) { | ||
299 | ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos); | ||
300 | if (ret != -EIOCBRETRY) | ||
301 | break; | ||
289 | wait_on_retry_sync_kiocb(&kiocb); | 302 | wait_on_retry_sync_kiocb(&kiocb); |
303 | } | ||
290 | 304 | ||
291 | if (-EIOCBQUEUED == ret) | 305 | if (-EIOCBQUEUED == ret) |
292 | ret = wait_on_sync_kiocb(&kiocb); | 306 | ret = wait_on_sync_kiocb(&kiocb); |
@@ -438,78 +452,155 @@ unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to) | |||
438 | 452 | ||
439 | EXPORT_UNUSED_SYMBOL(iov_shorten); /* June 2006 */ | 453 | EXPORT_UNUSED_SYMBOL(iov_shorten); /* June 2006 */ |
440 | 454 | ||
455 | ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov, | ||
456 | unsigned long nr_segs, size_t len, loff_t *ppos, iov_fn_t fn) | ||
457 | { | ||
458 | struct kiocb kiocb; | ||
459 | ssize_t ret; | ||
460 | |||
461 | init_sync_kiocb(&kiocb, filp); | ||
462 | kiocb.ki_pos = *ppos; | ||
463 | kiocb.ki_left = len; | ||
464 | kiocb.ki_nbytes = len; | ||
465 | |||
466 | for (;;) { | ||
467 | ret = fn(&kiocb, iov, nr_segs, kiocb.ki_pos); | ||
468 | if (ret != -EIOCBRETRY) | ||
469 | break; | ||
470 | wait_on_retry_sync_kiocb(&kiocb); | ||
471 | } | ||
472 | |||
473 | if (ret == -EIOCBQUEUED) | ||
474 | ret = wait_on_sync_kiocb(&kiocb); | ||
475 | *ppos = kiocb.ki_pos; | ||
476 | return ret; | ||
477 | } | ||
478 | |||
479 | /* Do it by hand, with file-ops */ | ||
480 | ssize_t do_loop_readv_writev(struct file *filp, struct iovec *iov, | ||
481 | unsigned long nr_segs, loff_t *ppos, io_fn_t fn) | ||
482 | { | ||
483 | struct iovec *vector = iov; | ||
484 | ssize_t ret = 0; | ||
485 | |||
486 | while (nr_segs > 0) { | ||
487 | void __user *base; | ||
488 | size_t len; | ||
489 | ssize_t nr; | ||
490 | |||
491 | base = vector->iov_base; | ||
492 | len = vector->iov_len; | ||
493 | vector++; | ||
494 | nr_segs--; | ||
495 | |||
496 | nr = fn(filp, base, len, ppos); | ||
497 | |||
498 | if (nr < 0) { | ||
499 | if (!ret) | ||
500 | ret = nr; | ||
501 | break; | ||
502 | } | ||
503 | ret += nr; | ||
504 | if (nr != len) | ||
505 | break; | ||
506 | } | ||
507 | |||
508 | return ret; | ||
509 | } | ||
510 | |||
441 | /* A write operation does a read from user space and vice versa */ | 511 | /* A write operation does a read from user space and vice versa */ |
442 | #define vrfy_dir(type) ((type) == READ ? VERIFY_WRITE : VERIFY_READ) | 512 | #define vrfy_dir(type) ((type) == READ ? VERIFY_WRITE : VERIFY_READ) |
443 | 513 | ||
514 | ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, | ||
515 | unsigned long nr_segs, unsigned long fast_segs, | ||
516 | struct iovec *fast_pointer, | ||
517 | struct iovec **ret_pointer) | ||
518 | { | ||
519 | unsigned long seg; | ||
520 | ssize_t ret; | ||
521 | struct iovec *iov = fast_pointer; | ||
522 | |||
523 | /* | ||
524 | * SuS says "The readv() function *may* fail if the iovcnt argument | ||
525 | * was less than or equal to 0, or greater than {IOV_MAX}. Linux has | ||
526 | * traditionally returned zero for zero segments, so... | ||
527 | */ | ||
528 | if (nr_segs == 0) { | ||
529 | ret = 0; | ||
530 | goto out; | ||
531 | } | ||
532 | |||
533 | /* | ||
534 | * First get the "struct iovec" from user memory and | ||
535 | * verify all the pointers | ||
536 | */ | ||
537 | if (nr_segs > UIO_MAXIOV) { | ||
538 | ret = -EINVAL; | ||
539 | goto out; | ||
540 | } | ||
541 | if (nr_segs > fast_segs) { | ||
542 | iov = kmalloc(nr_segs*sizeof(struct iovec), GFP_KERNEL); | ||
543 | if (iov == NULL) { | ||
544 | ret = -ENOMEM; | ||
545 | goto out; | ||
546 | } | ||
547 | } | ||
548 | if (copy_from_user(iov, uvector, nr_segs*sizeof(*uvector))) { | ||
549 | ret = -EFAULT; | ||
550 | goto out; | ||
551 | } | ||
552 | |||
553 | /* | ||
554 | * According to the Single Unix Specification we should return EINVAL | ||
555 | * if an element length is < 0 when cast to ssize_t or if the | ||
556 | * total length would overflow the ssize_t return value of the | ||
557 | * system call. | ||
558 | */ | ||
559 | ret = 0; | ||
560 | for (seg = 0; seg < nr_segs; seg++) { | ||
561 | void __user *buf = iov[seg].iov_base; | ||
562 | ssize_t len = (ssize_t)iov[seg].iov_len; | ||
563 | |||
564 | /* see if we we're about to use an invalid len or if | ||
565 | * it's about to overflow ssize_t */ | ||
566 | if (len < 0 || (ret + len < ret)) { | ||
567 | ret = -EINVAL; | ||
568 | goto out; | ||
569 | } | ||
570 | if (unlikely(!access_ok(vrfy_dir(type), buf, len))) { | ||
571 | ret = -EFAULT; | ||
572 | goto out; | ||
573 | } | ||
574 | |||
575 | ret += len; | ||
576 | } | ||
577 | out: | ||
578 | *ret_pointer = iov; | ||
579 | return ret; | ||
580 | } | ||
581 | |||
444 | static ssize_t do_readv_writev(int type, struct file *file, | 582 | static ssize_t do_readv_writev(int type, struct file *file, |
445 | const struct iovec __user * uvector, | 583 | const struct iovec __user * uvector, |
446 | unsigned long nr_segs, loff_t *pos) | 584 | unsigned long nr_segs, loff_t *pos) |
447 | { | 585 | { |
448 | typedef ssize_t (*io_fn_t)(struct file *, char __user *, size_t, loff_t *); | ||
449 | typedef ssize_t (*iov_fn_t)(struct file *, const struct iovec *, unsigned long, loff_t *); | ||
450 | |||
451 | size_t tot_len; | 586 | size_t tot_len; |
452 | struct iovec iovstack[UIO_FASTIOV]; | 587 | struct iovec iovstack[UIO_FASTIOV]; |
453 | struct iovec *iov=iovstack, *vector; | 588 | struct iovec *iov = iovstack; |
454 | ssize_t ret; | 589 | ssize_t ret; |
455 | int seg; | ||
456 | io_fn_t fn; | 590 | io_fn_t fn; |
457 | iov_fn_t fnv; | 591 | iov_fn_t fnv; |
458 | 592 | ||
459 | /* | 593 | if (!file->f_op) { |
460 | * SuS says "The readv() function *may* fail if the iovcnt argument | 594 | ret = -EINVAL; |
461 | * was less than or equal to 0, or greater than {IOV_MAX}. Linux has | ||
462 | * traditionally returned zero for zero segments, so... | ||
463 | */ | ||
464 | ret = 0; | ||
465 | if (nr_segs == 0) | ||
466 | goto out; | 595 | goto out; |
596 | } | ||
467 | 597 | ||
468 | /* | 598 | ret = rw_copy_check_uvector(type, uvector, nr_segs, |
469 | * First get the "struct iovec" from user memory and | 599 | ARRAY_SIZE(iovstack), iovstack, &iov); |
470 | * verify all the pointers | 600 | if (ret <= 0) |
471 | */ | ||
472 | ret = -EINVAL; | ||
473 | if (nr_segs > UIO_MAXIOV) | ||
474 | goto out; | ||
475 | if (!file->f_op) | ||
476 | goto out; | ||
477 | if (nr_segs > UIO_FASTIOV) { | ||
478 | ret = -ENOMEM; | ||
479 | iov = kmalloc(nr_segs*sizeof(struct iovec), GFP_KERNEL); | ||
480 | if (!iov) | ||
481 | goto out; | ||
482 | } | ||
483 | ret = -EFAULT; | ||
484 | if (copy_from_user(iov, uvector, nr_segs*sizeof(*uvector))) | ||
485 | goto out; | 601 | goto out; |
486 | 602 | ||
487 | /* | 603 | tot_len = ret; |
488 | * Single unix specification: | ||
489 | * We should -EINVAL if an element length is not >= 0 and fitting an | ||
490 | * ssize_t. The total length is fitting an ssize_t | ||
491 | * | ||
492 | * Be careful here because iov_len is a size_t not an ssize_t | ||
493 | */ | ||
494 | tot_len = 0; | ||
495 | ret = -EINVAL; | ||
496 | for (seg = 0; seg < nr_segs; seg++) { | ||
497 | void __user *buf = iov[seg].iov_base; | ||
498 | ssize_t len = (ssize_t)iov[seg].iov_len; | ||
499 | |||
500 | if (len < 0) /* size_t not fitting an ssize_t .. */ | ||
501 | goto out; | ||
502 | if (unlikely(!access_ok(vrfy_dir(type), buf, len))) | ||
503 | goto Efault; | ||
504 | tot_len += len; | ||
505 | if ((ssize_t)tot_len < 0) /* maths overflow on the ssize_t */ | ||
506 | goto out; | ||
507 | } | ||
508 | if (tot_len == 0) { | ||
509 | ret = 0; | ||
510 | goto out; | ||
511 | } | ||
512 | |||
513 | ret = rw_verify_area(type, file, pos, tot_len); | 604 | ret = rw_verify_area(type, file, pos, tot_len); |
514 | if (ret < 0) | 605 | if (ret < 0) |
515 | goto out; | 606 | goto out; |
@@ -520,39 +611,18 @@ static ssize_t do_readv_writev(int type, struct file *file, | |||
520 | fnv = NULL; | 611 | fnv = NULL; |
521 | if (type == READ) { | 612 | if (type == READ) { |
522 | fn = file->f_op->read; | 613 | fn = file->f_op->read; |
523 | fnv = file->f_op->readv; | 614 | fnv = file->f_op->aio_read; |
524 | } else { | 615 | } else { |
525 | fn = (io_fn_t)file->f_op->write; | 616 | fn = (io_fn_t)file->f_op->write; |
526 | fnv = file->f_op->writev; | 617 | fnv = file->f_op->aio_write; |
527 | } | 618 | } |
528 | if (fnv) { | ||
529 | ret = fnv(file, iov, nr_segs, pos); | ||
530 | goto out; | ||
531 | } | ||
532 | |||
533 | /* Do it by hand, with file-ops */ | ||
534 | ret = 0; | ||
535 | vector = iov; | ||
536 | while (nr_segs > 0) { | ||
537 | void __user * base; | ||
538 | size_t len; | ||
539 | ssize_t nr; | ||
540 | 619 | ||
541 | base = vector->iov_base; | 620 | if (fnv) |
542 | len = vector->iov_len; | 621 | ret = do_sync_readv_writev(file, iov, nr_segs, tot_len, |
543 | vector++; | 622 | pos, fnv); |
544 | nr_segs--; | 623 | else |
545 | 624 | ret = do_loop_readv_writev(file, iov, nr_segs, pos, fn); | |
546 | nr = fn(file, base, len, pos); | ||
547 | 625 | ||
548 | if (nr < 0) { | ||
549 | if (!ret) ret = nr; | ||
550 | break; | ||
551 | } | ||
552 | ret += nr; | ||
553 | if (nr != len) | ||
554 | break; | ||
555 | } | ||
556 | out: | 626 | out: |
557 | if (iov != iovstack) | 627 | if (iov != iovstack) |
558 | kfree(iov); | 628 | kfree(iov); |
@@ -563,9 +633,6 @@ out: | |||
563 | fsnotify_modify(file->f_dentry); | 633 | fsnotify_modify(file->f_dentry); |
564 | } | 634 | } |
565 | return ret; | 635 | return ret; |
566 | Efault: | ||
567 | ret = -EFAULT; | ||
568 | goto out; | ||
569 | } | 636 | } |
570 | 637 | ||
571 | ssize_t vfs_readv(struct file *file, const struct iovec __user *vec, | 638 | ssize_t vfs_readv(struct file *file, const struct iovec __user *vec, |
@@ -573,7 +640,7 @@ ssize_t vfs_readv(struct file *file, const struct iovec __user *vec, | |||
573 | { | 640 | { |
574 | if (!(file->f_mode & FMODE_READ)) | 641 | if (!(file->f_mode & FMODE_READ)) |
575 | return -EBADF; | 642 | return -EBADF; |
576 | if (!file->f_op || (!file->f_op->readv && !file->f_op->read)) | 643 | if (!file->f_op || (!file->f_op->aio_read && !file->f_op->read)) |
577 | return -EINVAL; | 644 | return -EINVAL; |
578 | 645 | ||
579 | return do_readv_writev(READ, file, vec, vlen, pos); | 646 | return do_readv_writev(READ, file, vec, vlen, pos); |
@@ -586,7 +653,7 @@ ssize_t vfs_writev(struct file *file, const struct iovec __user *vec, | |||
586 | { | 653 | { |
587 | if (!(file->f_mode & FMODE_WRITE)) | 654 | if (!(file->f_mode & FMODE_WRITE)) |
588 | return -EBADF; | 655 | return -EBADF; |
589 | if (!file->f_op || (!file->f_op->writev && !file->f_op->write)) | 656 | if (!file->f_op || (!file->f_op->aio_write && !file->f_op->write)) |
590 | return -EINVAL; | 657 | return -EINVAL; |
591 | 658 | ||
592 | return do_readv_writev(WRITE, file, vec, vlen, pos); | 659 | return do_readv_writev(WRITE, file, vec, vlen, pos); |
diff --git a/fs/read_write.h b/fs/read_write.h new file mode 100644 index 000000000000..d07b954c6e0c --- /dev/null +++ b/fs/read_write.h | |||
@@ -0,0 +1,14 @@ | |||
1 | /* | ||
2 | * This file is only for sharing some helpers from read_write.c with compat.c. | ||
3 | * Don't use anywhere else. | ||
4 | */ | ||
5 | |||
6 | |||
7 | typedef ssize_t (*io_fn_t)(struct file *, char __user *, size_t, loff_t *); | ||
8 | typedef ssize_t (*iov_fn_t)(struct kiocb *, const struct iovec *, | ||
9 | unsigned long, loff_t); | ||
10 | |||
11 | ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov, | ||
12 | unsigned long nr_segs, size_t len, loff_t *ppos, iov_fn_t fn); | ||
13 | ssize_t do_loop_readv_writev(struct file *filp, struct iovec *iov, | ||
14 | unsigned long nr_segs, loff_t *ppos, io_fn_t fn); | ||
diff --git a/fs/reiserfs/Makefile b/fs/reiserfs/Makefile index 3a59309f3ca9..0eb7ac080484 100644 --- a/fs/reiserfs/Makefile +++ b/fs/reiserfs/Makefile | |||
@@ -28,7 +28,7 @@ endif | |||
28 | # will work around it. If any other architecture displays this behavior, | 28 | # will work around it. If any other architecture displays this behavior, |
29 | # add it here. | 29 | # add it here. |
30 | ifeq ($(CONFIG_PPC32),y) | 30 | ifeq ($(CONFIG_PPC32),y) |
31 | EXTRA_CFLAGS := -O1 | 31 | EXTRA_CFLAGS := $(call cc-ifversion, -lt, 0400, -O1) |
32 | endif | 32 | endif |
33 | 33 | ||
34 | TAGS: | 34 | TAGS: |
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c index 4a7dbdee1b6d..1bfae42117ca 100644 --- a/fs/reiserfs/bitmap.c +++ b/fs/reiserfs/bitmap.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/buffer_head.h> | 9 | #include <linux/buffer_head.h> |
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/pagemap.h> | 11 | #include <linux/pagemap.h> |
12 | #include <linux/vmalloc.h> | ||
12 | #include <linux/reiserfs_fs_sb.h> | 13 | #include <linux/reiserfs_fs_sb.h> |
13 | #include <linux/reiserfs_fs_i.h> | 14 | #include <linux/reiserfs_fs_i.h> |
14 | #include <linux/quotaops.h> | 15 | #include <linux/quotaops.h> |
@@ -50,16 +51,15 @@ static inline void get_bit_address(struct super_block *s, | |||
50 | { | 51 | { |
51 | /* It is in the bitmap block number equal to the block | 52 | /* It is in the bitmap block number equal to the block |
52 | * number divided by the number of bits in a block. */ | 53 | * number divided by the number of bits in a block. */ |
53 | *bmap_nr = block / (s->s_blocksize << 3); | 54 | *bmap_nr = block >> (s->s_blocksize_bits + 3); |
54 | /* Within that bitmap block it is located at bit offset *offset. */ | 55 | /* Within that bitmap block it is located at bit offset *offset. */ |
55 | *offset = block & ((s->s_blocksize << 3) - 1); | 56 | *offset = block & ((s->s_blocksize << 3) - 1); |
56 | return; | ||
57 | } | 57 | } |
58 | 58 | ||
59 | #ifdef CONFIG_REISERFS_CHECK | 59 | #ifdef CONFIG_REISERFS_CHECK |
60 | int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value) | 60 | int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value) |
61 | { | 61 | { |
62 | int i, j; | 62 | int bmap, offset; |
63 | 63 | ||
64 | if (block == 0 || block >= SB_BLOCK_COUNT(s)) { | 64 | if (block == 0 || block >= SB_BLOCK_COUNT(s)) { |
65 | reiserfs_warning(s, | 65 | reiserfs_warning(s, |
@@ -68,36 +68,32 @@ int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value) | |||
68 | return 0; | 68 | return 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | /* it can't be one of the bitmap blocks */ | 71 | get_bit_address(s, block, &bmap, &offset); |
72 | for (i = 0; i < SB_BMAP_NR(s); i++) | 72 | |
73 | if (block == SB_AP_BITMAP(s)[i].bh->b_blocknr) { | 73 | /* Old format filesystem? Unlikely, but the bitmaps are all up front so |
74 | * we need to account for it. */ | ||
75 | if (unlikely(test_bit(REISERFS_OLD_FORMAT, | ||
76 | &(REISERFS_SB(s)->s_properties)))) { | ||
77 | b_blocknr_t bmap1 = REISERFS_SB(s)->s_sbh->b_blocknr + 1; | ||
78 | if (block >= bmap1 && block <= bmap1 + SB_BMAP_NR(s)) { | ||
79 | reiserfs_warning(s, "vs: 4019: is_reusable: " | ||
80 | "bitmap block %lu(%u) can't be freed or reused", | ||
81 | block, SB_BMAP_NR(s)); | ||
82 | return 0; | ||
83 | } | ||
84 | } else { | ||
85 | if (offset == 0) { | ||
74 | reiserfs_warning(s, "vs: 4020: is_reusable: " | 86 | reiserfs_warning(s, "vs: 4020: is_reusable: " |
75 | "bitmap block %lu(%u) can't be freed or reused", | 87 | "bitmap block %lu(%u) can't be freed or reused", |
76 | block, SB_BMAP_NR(s)); | 88 | block, SB_BMAP_NR(s)); |
77 | return 0; | 89 | return 0; |
78 | } | 90 | } |
79 | |||
80 | get_bit_address(s, block, &i, &j); | ||
81 | |||
82 | if (i >= SB_BMAP_NR(s)) { | ||
83 | reiserfs_warning(s, | ||
84 | "vs-4030: is_reusable: there is no so many bitmap blocks: " | ||
85 | "block=%lu, bitmap_nr=%d", block, i); | ||
86 | return 0; | ||
87 | } | 91 | } |
88 | 92 | ||
89 | if ((bit_value == 0 && | 93 | if (bmap >= SB_BMAP_NR(s)) { |
90 | reiserfs_test_le_bit(j, SB_AP_BITMAP(s)[i].bh->b_data)) || | ||
91 | (bit_value == 1 && | ||
92 | reiserfs_test_le_bit(j, SB_AP_BITMAP(s)[i].bh->b_data) == 0)) { | ||
93 | reiserfs_warning(s, | 94 | reiserfs_warning(s, |
94 | "vs-4040: is_reusable: corresponding bit of block %lu does not " | 95 | "vs-4030: is_reusable: there is no so many bitmap blocks: " |
95 | "match required value (i==%d, j==%d) test_bit==%d", | 96 | "block=%lu, bitmap_nr=%d", block, bmap); |
96 | block, i, j, reiserfs_test_le_bit(j, | ||
97 | SB_AP_BITMAP | ||
98 | (s)[i].bh-> | ||
99 | b_data)); | ||
100 | |||
101 | return 0; | 97 | return 0; |
102 | } | 98 | } |
103 | 99 | ||
@@ -141,6 +137,7 @@ static int scan_bitmap_block(struct reiserfs_transaction_handle *th, | |||
141 | { | 137 | { |
142 | struct super_block *s = th->t_super; | 138 | struct super_block *s = th->t_super; |
143 | struct reiserfs_bitmap_info *bi = &SB_AP_BITMAP(s)[bmap_n]; | 139 | struct reiserfs_bitmap_info *bi = &SB_AP_BITMAP(s)[bmap_n]; |
140 | struct buffer_head *bh; | ||
144 | int end, next; | 141 | int end, next; |
145 | int org = *beg; | 142 | int org = *beg; |
146 | 143 | ||
@@ -159,22 +156,25 @@ static int scan_bitmap_block(struct reiserfs_transaction_handle *th, | |||
159 | bmap_n); | 156 | bmap_n); |
160 | return 0; | 157 | return 0; |
161 | } | 158 | } |
162 | if (buffer_locked(bi->bh)) { | 159 | |
163 | PROC_INFO_INC(s, scan_bitmap.wait); | 160 | bh = reiserfs_read_bitmap_block(s, bmap_n); |
164 | __wait_on_buffer(bi->bh); | 161 | if (bh == NULL) |
165 | } | 162 | return 0; |
166 | 163 | ||
167 | while (1) { | 164 | while (1) { |
168 | cont: | 165 | cont: |
169 | if (bi->free_count < min) | 166 | if (bi->free_count < min) { |
167 | brelse(bh); | ||
170 | return 0; // No free blocks in this bitmap | 168 | return 0; // No free blocks in this bitmap |
169 | } | ||
171 | 170 | ||
172 | /* search for a first zero bit -- beggining of a window */ | 171 | /* search for a first zero bit -- beggining of a window */ |
173 | *beg = reiserfs_find_next_zero_le_bit | 172 | *beg = reiserfs_find_next_zero_le_bit |
174 | ((unsigned long *)(bi->bh->b_data), boundary, *beg); | 173 | ((unsigned long *)(bh->b_data), boundary, *beg); |
175 | 174 | ||
176 | if (*beg + min > boundary) { /* search for a zero bit fails or the rest of bitmap block | 175 | if (*beg + min > boundary) { /* search for a zero bit fails or the rest of bitmap block |
177 | * cannot contain a zero window of minimum size */ | 176 | * cannot contain a zero window of minimum size */ |
177 | brelse(bh); | ||
178 | return 0; | 178 | return 0; |
179 | } | 179 | } |
180 | 180 | ||
@@ -183,7 +183,7 @@ static int scan_bitmap_block(struct reiserfs_transaction_handle *th, | |||
183 | /* first zero bit found; we check next bits */ | 183 | /* first zero bit found; we check next bits */ |
184 | for (end = *beg + 1;; end++) { | 184 | for (end = *beg + 1;; end++) { |
185 | if (end >= *beg + max || end >= boundary | 185 | if (end >= *beg + max || end >= boundary |
186 | || reiserfs_test_le_bit(end, bi->bh->b_data)) { | 186 | || reiserfs_test_le_bit(end, bh->b_data)) { |
187 | next = end; | 187 | next = end; |
188 | break; | 188 | break; |
189 | } | 189 | } |
@@ -197,12 +197,12 @@ static int scan_bitmap_block(struct reiserfs_transaction_handle *th, | |||
197 | * (end) points to one bit after the window end */ | 197 | * (end) points to one bit after the window end */ |
198 | if (end - *beg >= min) { /* it seems we have found window of proper size */ | 198 | if (end - *beg >= min) { /* it seems we have found window of proper size */ |
199 | int i; | 199 | int i; |
200 | reiserfs_prepare_for_journal(s, bi->bh, 1); | 200 | reiserfs_prepare_for_journal(s, bh, 1); |
201 | /* try to set all blocks used checking are they still free */ | 201 | /* try to set all blocks used checking are they still free */ |
202 | for (i = *beg; i < end; i++) { | 202 | for (i = *beg; i < end; i++) { |
203 | /* It seems that we should not check in journal again. */ | 203 | /* It seems that we should not check in journal again. */ |
204 | if (reiserfs_test_and_set_le_bit | 204 | if (reiserfs_test_and_set_le_bit |
205 | (i, bi->bh->b_data)) { | 205 | (i, bh->b_data)) { |
206 | /* bit was set by another process | 206 | /* bit was set by another process |
207 | * while we slept in prepare_for_journal() */ | 207 | * while we slept in prepare_for_journal() */ |
208 | PROC_INFO_INC(s, scan_bitmap.stolen); | 208 | PROC_INFO_INC(s, scan_bitmap.stolen); |
@@ -214,17 +214,16 @@ static int scan_bitmap_block(struct reiserfs_transaction_handle *th, | |||
214 | /* otherwise we clear all bit were set ... */ | 214 | /* otherwise we clear all bit were set ... */ |
215 | while (--i >= *beg) | 215 | while (--i >= *beg) |
216 | reiserfs_test_and_clear_le_bit | 216 | reiserfs_test_and_clear_le_bit |
217 | (i, bi->bh->b_data); | 217 | (i, bh->b_data); |
218 | reiserfs_restore_prepared_buffer(s, | 218 | reiserfs_restore_prepared_buffer(s, bh); |
219 | bi-> | ||
220 | bh); | ||
221 | *beg = org; | 219 | *beg = org; |
222 | /* ... and search again in current block from beginning */ | 220 | /* ... and search again in current block from beginning */ |
223 | goto cont; | 221 | goto cont; |
224 | } | 222 | } |
225 | } | 223 | } |
226 | bi->free_count -= (end - *beg); | 224 | bi->free_count -= (end - *beg); |
227 | journal_mark_dirty(th, s, bi->bh); | 225 | journal_mark_dirty(th, s, bh); |
226 | brelse(bh); | ||
228 | 227 | ||
229 | /* free block count calculation */ | 228 | /* free block count calculation */ |
230 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), | 229 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), |
@@ -266,9 +265,20 @@ static int bmap_hash_id(struct super_block *s, u32 id) | |||
266 | */ | 265 | */ |
267 | static inline int block_group_used(struct super_block *s, u32 id) | 266 | static inline int block_group_used(struct super_block *s, u32 id) |
268 | { | 267 | { |
269 | int bm; | 268 | int bm = bmap_hash_id(s, id); |
270 | bm = bmap_hash_id(s, id); | 269 | struct reiserfs_bitmap_info *info = &SB_AP_BITMAP(s)[bm]; |
271 | if (SB_AP_BITMAP(s)[bm].free_count > ((s->s_blocksize << 3) * 60 / 100)) { | 270 | |
271 | /* If we don't have cached information on this bitmap block, we're | ||
272 | * going to have to load it later anyway. Loading it here allows us | ||
273 | * to make a better decision. This favors long-term performace gain | ||
274 | * with a better on-disk layout vs. a short term gain of skipping the | ||
275 | * read and potentially having a bad placement. */ | ||
276 | if (info->first_zero_hint == 0) { | ||
277 | struct buffer_head *bh = reiserfs_read_bitmap_block(s, bm); | ||
278 | brelse(bh); | ||
279 | } | ||
280 | |||
281 | if (info->free_count > ((s->s_blocksize << 3) * 60 / 100)) { | ||
272 | return 0; | 282 | return 0; |
273 | } | 283 | } |
274 | return 1; | 284 | return 1; |
@@ -373,7 +383,7 @@ static void _reiserfs_free_block(struct reiserfs_transaction_handle *th, | |||
373 | { | 383 | { |
374 | struct super_block *s = th->t_super; | 384 | struct super_block *s = th->t_super; |
375 | struct reiserfs_super_block *rs; | 385 | struct reiserfs_super_block *rs; |
376 | struct buffer_head *sbh; | 386 | struct buffer_head *sbh, *bmbh; |
377 | struct reiserfs_bitmap_info *apbi; | 387 | struct reiserfs_bitmap_info *apbi; |
378 | int nr, offset; | 388 | int nr, offset; |
379 | 389 | ||
@@ -394,16 +404,21 @@ static void _reiserfs_free_block(struct reiserfs_transaction_handle *th, | |||
394 | return; | 404 | return; |
395 | } | 405 | } |
396 | 406 | ||
397 | reiserfs_prepare_for_journal(s, apbi[nr].bh, 1); | 407 | bmbh = reiserfs_read_bitmap_block(s, nr); |
408 | if (!bmbh) | ||
409 | return; | ||
410 | |||
411 | reiserfs_prepare_for_journal(s, bmbh, 1); | ||
398 | 412 | ||
399 | /* clear bit for the given block in bit map */ | 413 | /* clear bit for the given block in bit map */ |
400 | if (!reiserfs_test_and_clear_le_bit(offset, apbi[nr].bh->b_data)) { | 414 | if (!reiserfs_test_and_clear_le_bit(offset, bmbh->b_data)) { |
401 | reiserfs_warning(s, "vs-4080: reiserfs_free_block: " | 415 | reiserfs_warning(s, "vs-4080: reiserfs_free_block: " |
402 | "free_block (%s:%lu)[dev:blocknr]: bit already cleared", | 416 | "free_block (%s:%lu)[dev:blocknr]: bit already cleared", |
403 | reiserfs_bdevname(s), block); | 417 | reiserfs_bdevname(s), block); |
404 | } | 418 | } |
405 | apbi[nr].free_count++; | 419 | apbi[nr].free_count++; |
406 | journal_mark_dirty(th, s, apbi[nr].bh); | 420 | journal_mark_dirty(th, s, bmbh); |
421 | brelse(bmbh); | ||
407 | 422 | ||
408 | reiserfs_prepare_for_journal(s, sbh, 1); | 423 | reiserfs_prepare_for_journal(s, sbh, 1); |
409 | /* update super block */ | 424 | /* update super block */ |
@@ -1019,7 +1034,6 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start | |||
1019 | b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1; | 1034 | b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1; |
1020 | int passno = 0; | 1035 | int passno = 0; |
1021 | int nr_allocated = 0; | 1036 | int nr_allocated = 0; |
1022 | int bigalloc = 0; | ||
1023 | 1037 | ||
1024 | determine_prealloc_size(hint); | 1038 | determine_prealloc_size(hint); |
1025 | if (!hint->formatted_node) { | 1039 | if (!hint->formatted_node) { |
@@ -1046,28 +1060,9 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start | |||
1046 | hint->preallocate = hint->prealloc_size = 0; | 1060 | hint->preallocate = hint->prealloc_size = 0; |
1047 | } | 1061 | } |
1048 | /* for unformatted nodes, force large allocations */ | 1062 | /* for unformatted nodes, force large allocations */ |
1049 | bigalloc = amount_needed; | ||
1050 | } | 1063 | } |
1051 | 1064 | ||
1052 | do { | 1065 | do { |
1053 | /* in bigalloc mode, nr_allocated should stay zero until | ||
1054 | * the entire allocation is filled | ||
1055 | */ | ||
1056 | if (unlikely(bigalloc && nr_allocated)) { | ||
1057 | reiserfs_warning(s, "bigalloc is %d, nr_allocated %d\n", | ||
1058 | bigalloc, nr_allocated); | ||
1059 | /* reset things to a sane value */ | ||
1060 | bigalloc = amount_needed - nr_allocated; | ||
1061 | } | ||
1062 | /* | ||
1063 | * try pass 0 and pass 1 looking for a nice big | ||
1064 | * contiguous allocation. Then reset and look | ||
1065 | * for anything you can find. | ||
1066 | */ | ||
1067 | if (passno == 2 && bigalloc) { | ||
1068 | passno = 0; | ||
1069 | bigalloc = 0; | ||
1070 | } | ||
1071 | switch (passno++) { | 1066 | switch (passno++) { |
1072 | case 0: /* Search from hint->search_start to end of disk */ | 1067 | case 0: /* Search from hint->search_start to end of disk */ |
1073 | start = hint->search_start; | 1068 | start = hint->search_start; |
@@ -1105,8 +1100,7 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start | |||
1105 | new_blocknrs + | 1100 | new_blocknrs + |
1106 | nr_allocated, | 1101 | nr_allocated, |
1107 | start, finish, | 1102 | start, finish, |
1108 | bigalloc ? | 1103 | 1, |
1109 | bigalloc : 1, | ||
1110 | amount_needed - | 1104 | amount_needed - |
1111 | nr_allocated, | 1105 | nr_allocated, |
1112 | hint-> | 1106 | hint-> |
@@ -1263,3 +1257,89 @@ int reiserfs_can_fit_pages(struct super_block *sb /* superblock of filesystem | |||
1263 | 1257 | ||
1264 | return space > 0 ? space : 0; | 1258 | return space > 0 ? space : 0; |
1265 | } | 1259 | } |
1260 | |||
1261 | void reiserfs_cache_bitmap_metadata(struct super_block *sb, | ||
1262 | struct buffer_head *bh, | ||
1263 | struct reiserfs_bitmap_info *info) | ||
1264 | { | ||
1265 | unsigned long *cur = (unsigned long *)(bh->b_data + bh->b_size); | ||
1266 | |||
1267 | info->first_zero_hint = 1 << (sb->s_blocksize_bits + 3); | ||
1268 | |||
1269 | while (--cur >= (unsigned long *)bh->b_data) { | ||
1270 | int base = ((char *)cur - bh->b_data) << 3; | ||
1271 | |||
1272 | /* 0 and ~0 are special, we can optimize for them */ | ||
1273 | if (*cur == 0) { | ||
1274 | info->first_zero_hint = base; | ||
1275 | info->free_count += BITS_PER_LONG; | ||
1276 | } else if (*cur != ~0L) { /* A mix, investigate */ | ||
1277 | int b; | ||
1278 | for (b = BITS_PER_LONG - 1; b >= 0; b--) { | ||
1279 | if (!reiserfs_test_le_bit(b, cur)) { | ||
1280 | info->first_zero_hint = base + b; | ||
1281 | info->free_count++; | ||
1282 | } | ||
1283 | } | ||
1284 | } | ||
1285 | } | ||
1286 | /* The first bit must ALWAYS be 1 */ | ||
1287 | BUG_ON(info->first_zero_hint == 0); | ||
1288 | } | ||
1289 | |||
1290 | struct buffer_head *reiserfs_read_bitmap_block(struct super_block *sb, | ||
1291 | unsigned int bitmap) | ||
1292 | { | ||
1293 | b_blocknr_t block = (sb->s_blocksize << 3) * bitmap; | ||
1294 | struct reiserfs_bitmap_info *info = SB_AP_BITMAP(sb) + bitmap; | ||
1295 | struct buffer_head *bh; | ||
1296 | |||
1297 | /* Way old format filesystems had the bitmaps packed up front. | ||
1298 | * I doubt there are any of these left, but just in case... */ | ||
1299 | if (unlikely(test_bit(REISERFS_OLD_FORMAT, | ||
1300 | &(REISERFS_SB(sb)->s_properties)))) | ||
1301 | block = REISERFS_SB(sb)->s_sbh->b_blocknr + 1 + bitmap; | ||
1302 | else if (bitmap == 0) | ||
1303 | block = (REISERFS_DISK_OFFSET_IN_BYTES >> sb->s_blocksize_bits) + 1; | ||
1304 | |||
1305 | bh = sb_bread(sb, block); | ||
1306 | if (bh == NULL) | ||
1307 | reiserfs_warning(sb, "sh-2029: %s: bitmap block (#%lu) " | ||
1308 | "reading failed", __FUNCTION__, bh->b_blocknr); | ||
1309 | else { | ||
1310 | if (buffer_locked(bh)) { | ||
1311 | PROC_INFO_INC(sb, scan_bitmap.wait); | ||
1312 | __wait_on_buffer(bh); | ||
1313 | } | ||
1314 | BUG_ON(!buffer_uptodate(bh)); | ||
1315 | BUG_ON(atomic_read(&bh->b_count) == 0); | ||
1316 | |||
1317 | if (info->first_zero_hint == 0) | ||
1318 | reiserfs_cache_bitmap_metadata(sb, bh, info); | ||
1319 | } | ||
1320 | |||
1321 | return bh; | ||
1322 | } | ||
1323 | |||
1324 | int reiserfs_init_bitmap_cache(struct super_block *sb) | ||
1325 | { | ||
1326 | struct reiserfs_bitmap_info *bitmap; | ||
1327 | |||
1328 | bitmap = vmalloc(sizeof (*bitmap) * SB_BMAP_NR(sb)); | ||
1329 | if (bitmap == NULL) | ||
1330 | return -ENOMEM; | ||
1331 | |||
1332 | memset(bitmap, 0, sizeof (*bitmap) * SB_BMAP_NR(sb)); | ||
1333 | |||
1334 | SB_AP_BITMAP(sb) = bitmap; | ||
1335 | |||
1336 | return 0; | ||
1337 | } | ||
1338 | |||
1339 | void reiserfs_free_bitmap_cache(struct super_block *sb) | ||
1340 | { | ||
1341 | if (SB_AP_BITMAP(sb)) { | ||
1342 | vfree(SB_AP_BITMAP(sb)); | ||
1343 | SB_AP_BITMAP(sb) = NULL; | ||
1344 | } | ||
1345 | } | ||
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c index 9aabcc0ccd2d..657050ad7430 100644 --- a/fs/reiserfs/dir.c +++ b/fs/reiserfs/dir.c | |||
@@ -22,6 +22,9 @@ const struct file_operations reiserfs_dir_operations = { | |||
22 | .readdir = reiserfs_readdir, | 22 | .readdir = reiserfs_readdir, |
23 | .fsync = reiserfs_dir_fsync, | 23 | .fsync = reiserfs_dir_fsync, |
24 | .ioctl = reiserfs_ioctl, | 24 | .ioctl = reiserfs_ioctl, |
25 | #ifdef CONFIG_COMPAT | ||
26 | .compat_ioctl = reiserfs_compat_ioctl, | ||
27 | #endif | ||
25 | }; | 28 | }; |
26 | 29 | ||
27 | static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, | 30 | static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, |
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c index 1627edd50810..41f24369e47a 100644 --- a/fs/reiserfs/file.c +++ b/fs/reiserfs/file.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README | 2 | * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <linux/config.h> | ||
5 | #include <linux/time.h> | 6 | #include <linux/time.h> |
6 | #include <linux/reiserfs_fs.h> | 7 | #include <linux/reiserfs_fs.h> |
7 | #include <linux/reiserfs_acl.h> | 8 | #include <linux/reiserfs_acl.h> |
@@ -130,7 +131,7 @@ static int reiserfs_sync_file(struct file *p_s_filp, | |||
130 | reiserfs_write_lock(p_s_inode->i_sb); | 131 | reiserfs_write_lock(p_s_inode->i_sb); |
131 | barrier_done = reiserfs_commit_for_inode(p_s_inode); | 132 | barrier_done = reiserfs_commit_for_inode(p_s_inode); |
132 | reiserfs_write_unlock(p_s_inode->i_sb); | 133 | reiserfs_write_unlock(p_s_inode->i_sb); |
133 | if (barrier_done != 1) | 134 | if (barrier_done != 1 && reiserfs_barrier_flush(p_s_inode->i_sb)) |
134 | blkdev_issue_flush(p_s_inode->i_sb->s_bdev, NULL); | 135 | blkdev_issue_flush(p_s_inode->i_sb->s_bdev, NULL); |
135 | if (barrier_done < 0) | 136 | if (barrier_done < 0) |
136 | return barrier_done; | 137 | return barrier_done; |
@@ -1333,7 +1334,7 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t | |||
1333 | if (err) | 1334 | if (err) |
1334 | return err; | 1335 | return err; |
1335 | } | 1336 | } |
1336 | result = generic_file_write(file, buf, count, ppos); | 1337 | result = do_sync_write(file, buf, count, ppos); |
1337 | 1338 | ||
1338 | if (after_file_end) { /* Now update i_size and remove the savelink */ | 1339 | if (after_file_end) { /* Now update i_size and remove the savelink */ |
1339 | struct reiserfs_transaction_handle th; | 1340 | struct reiserfs_transaction_handle th; |
@@ -1565,10 +1566,14 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t | |||
1565 | } | 1566 | } |
1566 | 1567 | ||
1567 | const struct file_operations reiserfs_file_operations = { | 1568 | const struct file_operations reiserfs_file_operations = { |
1568 | .read = generic_file_read, | 1569 | .read = do_sync_read, |
1569 | .write = reiserfs_file_write, | 1570 | .write = reiserfs_file_write, |
1570 | .ioctl = reiserfs_ioctl, | 1571 | .ioctl = reiserfs_ioctl, |
1572 | #ifdef CONFIG_COMPAT | ||
1573 | .compat_ioctl = reiserfs_compat_ioctl, | ||
1574 | #endif | ||
1571 | .mmap = generic_file_mmap, | 1575 | .mmap = generic_file_mmap, |
1576 | .open = generic_file_open, | ||
1572 | .release = reiserfs_file_release, | 1577 | .release = reiserfs_file_release, |
1573 | .fsync = reiserfs_sync_file, | 1578 | .fsync = reiserfs_sync_file, |
1574 | .sendfile = generic_file_sendfile, | 1579 | .sendfile = generic_file_sendfile, |
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index 8810fda0da46..7e5a2f5ebeb0 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
@@ -1127,9 +1127,9 @@ static void init_inode(struct inode *inode, struct path *path) | |||
1127 | REISERFS_I(inode)->i_prealloc_count = 0; | 1127 | REISERFS_I(inode)->i_prealloc_count = 0; |
1128 | REISERFS_I(inode)->i_trans_id = 0; | 1128 | REISERFS_I(inode)->i_trans_id = 0; |
1129 | REISERFS_I(inode)->i_jl = NULL; | 1129 | REISERFS_I(inode)->i_jl = NULL; |
1130 | REISERFS_I(inode)->i_acl_access = NULL; | 1130 | reiserfs_init_acl_access(inode); |
1131 | REISERFS_I(inode)->i_acl_default = NULL; | 1131 | reiserfs_init_acl_default(inode); |
1132 | init_rwsem(&REISERFS_I(inode)->xattr_sem); | 1132 | reiserfs_init_xattr_rwsem(inode); |
1133 | 1133 | ||
1134 | if (stat_data_v1(ih)) { | 1134 | if (stat_data_v1(ih)) { |
1135 | struct stat_data_v1 *sd = | 1135 | struct stat_data_v1 *sd = |
@@ -1834,9 +1834,9 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th, | |||
1834 | REISERFS_I(inode)->i_attrs = | 1834 | REISERFS_I(inode)->i_attrs = |
1835 | REISERFS_I(dir)->i_attrs & REISERFS_INHERIT_MASK; | 1835 | REISERFS_I(dir)->i_attrs & REISERFS_INHERIT_MASK; |
1836 | sd_attrs_to_i_attrs(REISERFS_I(inode)->i_attrs, inode); | 1836 | sd_attrs_to_i_attrs(REISERFS_I(inode)->i_attrs, inode); |
1837 | REISERFS_I(inode)->i_acl_access = NULL; | 1837 | reiserfs_init_acl_access(inode); |
1838 | REISERFS_I(inode)->i_acl_default = NULL; | 1838 | reiserfs_init_acl_default(inode); |
1839 | init_rwsem(&REISERFS_I(inode)->xattr_sem); | 1839 | reiserfs_init_xattr_rwsem(inode); |
1840 | 1840 | ||
1841 | if (old_format_only(sb)) | 1841 | if (old_format_only(sb)) |
1842 | make_le_item_head(&ih, NULL, KEY_FORMAT_3_5, SD_OFFSET, | 1842 | make_le_item_head(&ih, NULL, KEY_FORMAT_3_5, SD_OFFSET, |
@@ -1974,11 +1974,13 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th, | |||
1974 | * iput doesn't deadlock in reiserfs_delete_xattrs. The locking | 1974 | * iput doesn't deadlock in reiserfs_delete_xattrs. The locking |
1975 | * code really needs to be reworked, but this will take care of it | 1975 | * code really needs to be reworked, but this will take care of it |
1976 | * for now. -jeffm */ | 1976 | * for now. -jeffm */ |
1977 | #ifdef CONFIG_REISERFS_FS_POSIX_ACL | ||
1977 | if (REISERFS_I(dir)->i_acl_default && !IS_ERR(REISERFS_I(dir)->i_acl_default)) { | 1978 | if (REISERFS_I(dir)->i_acl_default && !IS_ERR(REISERFS_I(dir)->i_acl_default)) { |
1978 | reiserfs_write_unlock_xattrs(dir->i_sb); | 1979 | reiserfs_write_unlock_xattrs(dir->i_sb); |
1979 | iput(inode); | 1980 | iput(inode); |
1980 | reiserfs_write_lock_xattrs(dir->i_sb); | 1981 | reiserfs_write_lock_xattrs(dir->i_sb); |
1981 | } else | 1982 | } else |
1983 | #endif | ||
1982 | iput(inode); | 1984 | iput(inode); |
1983 | return err; | 1985 | return err; |
1984 | } | 1986 | } |
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c index a986b5e1e288..9c57578cb831 100644 --- a/fs/reiserfs/ioctl.c +++ b/fs/reiserfs/ioctl.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <asm/uaccess.h> | 9 | #include <asm/uaccess.h> |
10 | #include <linux/pagemap.h> | 10 | #include <linux/pagemap.h> |
11 | #include <linux/smp_lock.h> | 11 | #include <linux/smp_lock.h> |
12 | #include <linux/compat.h> | ||
12 | 13 | ||
13 | static int reiserfs_unpack(struct inode *inode, struct file *filp); | 14 | static int reiserfs_unpack(struct inode *inode, struct file *filp); |
14 | 15 | ||
@@ -94,6 +95,40 @@ int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | |||
94 | } | 95 | } |
95 | } | 96 | } |
96 | 97 | ||
98 | #ifdef CONFIG_COMPAT | ||
99 | long reiserfs_compat_ioctl(struct file *file, unsigned int cmd, | ||
100 | unsigned long arg) | ||
101 | { | ||
102 | struct inode *inode = file->f_dentry->d_inode; | ||
103 | int ret; | ||
104 | |||
105 | /* These are just misnamed, they actually get/put from/to user an int */ | ||
106 | switch (cmd) { | ||
107 | case REISERFS_IOC32_UNPACK: | ||
108 | cmd = REISERFS_IOC_UNPACK; | ||
109 | break; | ||
110 | case REISERFS_IOC32_GETFLAGS: | ||
111 | cmd = REISERFS_IOC_GETFLAGS; | ||
112 | break; | ||
113 | case REISERFS_IOC32_SETFLAGS: | ||
114 | cmd = REISERFS_IOC_SETFLAGS; | ||
115 | break; | ||
116 | case REISERFS_IOC32_GETVERSION: | ||
117 | cmd = REISERFS_IOC_GETVERSION; | ||
118 | break; | ||
119 | case REISERFS_IOC32_SETVERSION: | ||
120 | cmd = REISERFS_IOC_SETVERSION; | ||
121 | break; | ||
122 | default: | ||
123 | return -ENOIOCTLCMD; | ||
124 | } | ||
125 | lock_kernel(); | ||
126 | ret = reiserfs_ioctl(inode, file, cmd, (unsigned long) compat_ptr(arg)); | ||
127 | unlock_kernel(); | ||
128 | return ret; | ||
129 | } | ||
130 | #endif | ||
131 | |||
97 | /* | 132 | /* |
98 | ** reiserfs_unpack | 133 | ** reiserfs_unpack |
99 | ** Function try to convert tail from direct item into indirect. | 134 | ** Function try to convert tail from direct item into indirect. |
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index 9b3672d69367..e6b5ccf23f15 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c | |||
@@ -1186,6 +1186,21 @@ static struct reiserfs_journal_list *find_newer_jl_for_cn(struct | |||
1186 | return NULL; | 1186 | return NULL; |
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | static int newer_jl_done(struct reiserfs_journal_cnode *cn) | ||
1190 | { | ||
1191 | struct super_block *sb = cn->sb; | ||
1192 | b_blocknr_t blocknr = cn->blocknr; | ||
1193 | |||
1194 | cn = cn->hprev; | ||
1195 | while (cn) { | ||
1196 | if (cn->sb == sb && cn->blocknr == blocknr && cn->jlist && | ||
1197 | atomic_read(&cn->jlist->j_commit_left) != 0) | ||
1198 | return 0; | ||
1199 | cn = cn->hprev; | ||
1200 | } | ||
1201 | return 1; | ||
1202 | } | ||
1203 | |||
1189 | static void remove_journal_hash(struct super_block *, | 1204 | static void remove_journal_hash(struct super_block *, |
1190 | struct reiserfs_journal_cnode **, | 1205 | struct reiserfs_journal_cnode **, |
1191 | struct reiserfs_journal_list *, unsigned long, | 1206 | struct reiserfs_journal_list *, unsigned long, |
@@ -1604,6 +1619,31 @@ static int flush_journal_list(struct super_block *s, | |||
1604 | return err; | 1619 | return err; |
1605 | } | 1620 | } |
1606 | 1621 | ||
1622 | static int test_transaction(struct super_block *s, | ||
1623 | struct reiserfs_journal_list *jl) | ||
1624 | { | ||
1625 | struct reiserfs_journal_cnode *cn; | ||
1626 | |||
1627 | if (jl->j_len == 0 || atomic_read(&jl->j_nonzerolen) == 0) | ||
1628 | return 1; | ||
1629 | |||
1630 | cn = jl->j_realblock; | ||
1631 | while (cn) { | ||
1632 | /* if the blocknr == 0, this has been cleared from the hash, | ||
1633 | ** skip it | ||
1634 | */ | ||
1635 | if (cn->blocknr == 0) { | ||
1636 | goto next; | ||
1637 | } | ||
1638 | if (cn->bh && !newer_jl_done(cn)) | ||
1639 | return 0; | ||
1640 | next: | ||
1641 | cn = cn->next; | ||
1642 | cond_resched(); | ||
1643 | } | ||
1644 | return 0; | ||
1645 | } | ||
1646 | |||
1607 | static int write_one_transaction(struct super_block *s, | 1647 | static int write_one_transaction(struct super_block *s, |
1608 | struct reiserfs_journal_list *jl, | 1648 | struct reiserfs_journal_list *jl, |
1609 | struct buffer_chunk *chunk) | 1649 | struct buffer_chunk *chunk) |
@@ -3433,16 +3473,6 @@ static void flush_async_commits(void *p) | |||
3433 | flush_commit_list(p_s_sb, jl, 1); | 3473 | flush_commit_list(p_s_sb, jl, 1); |
3434 | } | 3474 | } |
3435 | unlock_kernel(); | 3475 | unlock_kernel(); |
3436 | /* | ||
3437 | * this is a little racey, but there's no harm in missing | ||
3438 | * the filemap_fdata_write | ||
3439 | */ | ||
3440 | if (!atomic_read(&journal->j_async_throttle) | ||
3441 | && !reiserfs_is_journal_aborted(journal)) { | ||
3442 | atomic_inc(&journal->j_async_throttle); | ||
3443 | filemap_fdatawrite(p_s_sb->s_bdev->bd_inode->i_mapping); | ||
3444 | atomic_dec(&journal->j_async_throttle); | ||
3445 | } | ||
3446 | } | 3476 | } |
3447 | 3477 | ||
3448 | /* | 3478 | /* |
@@ -3844,7 +3874,9 @@ static void flush_old_journal_lists(struct super_block *s) | |||
3844 | entry = journal->j_journal_list.next; | 3874 | entry = journal->j_journal_list.next; |
3845 | jl = JOURNAL_LIST_ENTRY(entry); | 3875 | jl = JOURNAL_LIST_ENTRY(entry); |
3846 | /* this check should always be run, to send old lists to disk */ | 3876 | /* this check should always be run, to send old lists to disk */ |
3847 | if (jl->j_timestamp < (now - (JOURNAL_MAX_TRANS_AGE * 4))) { | 3877 | if (jl->j_timestamp < (now - (JOURNAL_MAX_TRANS_AGE * 4)) && |
3878 | atomic_read(&jl->j_commit_left) == 0 && | ||
3879 | test_transaction(s, jl)) { | ||
3848 | flush_used_journal_lists(s, jl); | 3880 | flush_used_journal_lists(s, jl); |
3849 | } else { | 3881 | } else { |
3850 | break; | 3882 | break; |
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index c61710e49c62..16e9cff8f15d 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c | |||
@@ -19,8 +19,8 @@ | |||
19 | #include <linux/smp_lock.h> | 19 | #include <linux/smp_lock.h> |
20 | #include <linux/quotaops.h> | 20 | #include <linux/quotaops.h> |
21 | 21 | ||
22 | #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { i->i_nlink++; if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; } | 22 | #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; } |
23 | #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) i->i_nlink--; | 23 | #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i); |
24 | 24 | ||
25 | // directory item contains array of entry headers. This performs | 25 | // directory item contains array of entry headers. This performs |
26 | // binary search through that array | 26 | // binary search through that array |
@@ -913,7 +913,7 @@ static int reiserfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
913 | reiserfs_warning(inode->i_sb, "%s: empty directory has nlink " | 913 | reiserfs_warning(inode->i_sb, "%s: empty directory has nlink " |
914 | "!= 2 (%d)", __FUNCTION__, inode->i_nlink); | 914 | "!= 2 (%d)", __FUNCTION__, inode->i_nlink); |
915 | 915 | ||
916 | inode->i_nlink = 0; | 916 | clear_nlink(inode); |
917 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; | 917 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; |
918 | reiserfs_update_sd(&th, inode); | 918 | reiserfs_update_sd(&th, inode); |
919 | 919 | ||
@@ -994,7 +994,7 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry) | |||
994 | inode->i_nlink = 1; | 994 | inode->i_nlink = 1; |
995 | } | 995 | } |
996 | 996 | ||
997 | inode->i_nlink--; | 997 | drop_nlink(inode); |
998 | 998 | ||
999 | /* | 999 | /* |
1000 | * we schedule before doing the add_save_link call, save the link | 1000 | * we schedule before doing the add_save_link call, save the link |
@@ -1006,7 +1006,7 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry) | |||
1006 | reiserfs_cut_from_item(&th, &path, &(de.de_entry_key), dir, NULL, | 1006 | reiserfs_cut_from_item(&th, &path, &(de.de_entry_key), dir, NULL, |
1007 | 0); | 1007 | 0); |
1008 | if (retval < 0) { | 1008 | if (retval < 0) { |
1009 | inode->i_nlink++; | 1009 | inc_nlink(inode); |
1010 | goto end_unlink; | 1010 | goto end_unlink; |
1011 | } | 1011 | } |
1012 | inode->i_ctime = CURRENT_TIME_SEC; | 1012 | inode->i_ctime = CURRENT_TIME_SEC; |
@@ -1143,7 +1143,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir, | |||
1143 | } | 1143 | } |
1144 | 1144 | ||
1145 | /* inc before scheduling so reiserfs_unlink knows we are here */ | 1145 | /* inc before scheduling so reiserfs_unlink knows we are here */ |
1146 | inode->i_nlink++; | 1146 | inc_nlink(inode); |
1147 | 1147 | ||
1148 | retval = journal_begin(&th, dir->i_sb, jbegin_count); | 1148 | retval = journal_begin(&th, dir->i_sb, jbegin_count); |
1149 | if (retval) { | 1149 | if (retval) { |
@@ -1473,9 +1473,9 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1473 | if (new_dentry_inode) { | 1473 | if (new_dentry_inode) { |
1474 | // adjust link number of the victim | 1474 | // adjust link number of the victim |
1475 | if (S_ISDIR(new_dentry_inode->i_mode)) { | 1475 | if (S_ISDIR(new_dentry_inode->i_mode)) { |
1476 | new_dentry_inode->i_nlink = 0; | 1476 | clear_nlink(new_dentry_inode); |
1477 | } else { | 1477 | } else { |
1478 | new_dentry_inode->i_nlink--; | 1478 | drop_nlink(new_dentry_inode); |
1479 | } | 1479 | } |
1480 | new_dentry_inode->i_ctime = ctime; | 1480 | new_dentry_inode->i_ctime = ctime; |
1481 | savelink = new_dentry_inode->i_nlink; | 1481 | savelink = new_dentry_inode->i_nlink; |
diff --git a/fs/reiserfs/resize.c b/fs/reiserfs/resize.c index 39cc7f47f5dc..315684793d1d 100644 --- a/fs/reiserfs/resize.c +++ b/fs/reiserfs/resize.c | |||
@@ -22,6 +22,7 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new) | |||
22 | int err = 0; | 22 | int err = 0; |
23 | struct reiserfs_super_block *sb; | 23 | struct reiserfs_super_block *sb; |
24 | struct reiserfs_bitmap_info *bitmap; | 24 | struct reiserfs_bitmap_info *bitmap; |
25 | struct reiserfs_bitmap_info *info; | ||
25 | struct reiserfs_bitmap_info *old_bitmap = SB_AP_BITMAP(s); | 26 | struct reiserfs_bitmap_info *old_bitmap = SB_AP_BITMAP(s); |
26 | struct buffer_head *bh; | 27 | struct buffer_head *bh; |
27 | struct reiserfs_transaction_handle th; | 28 | struct reiserfs_transaction_handle th; |
@@ -127,16 +128,20 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new) | |||
127 | * transaction begins, and the new bitmaps don't matter if the | 128 | * transaction begins, and the new bitmaps don't matter if the |
128 | * transaction fails. */ | 129 | * transaction fails. */ |
129 | for (i = bmap_nr; i < bmap_nr_new; i++) { | 130 | for (i = bmap_nr; i < bmap_nr_new; i++) { |
130 | bitmap[i].bh = sb_getblk(s, i * s->s_blocksize * 8); | 131 | /* don't use read_bitmap_block since it will cache |
131 | memset(bitmap[i].bh->b_data, 0, sb_blocksize(sb)); | 132 | * the uninitialized bitmap */ |
132 | reiserfs_test_and_set_le_bit(0, bitmap[i].bh->b_data); | 133 | bh = sb_bread(s, i * s->s_blocksize * 8); |
133 | 134 | memset(bh->b_data, 0, sb_blocksize(sb)); | |
134 | set_buffer_uptodate(bitmap[i].bh); | 135 | reiserfs_test_and_set_le_bit(0, bh->b_data); |
135 | mark_buffer_dirty(bitmap[i].bh); | 136 | reiserfs_cache_bitmap_metadata(s, bh, bitmap + i); |
136 | sync_dirty_buffer(bitmap[i].bh); | 137 | |
138 | set_buffer_uptodate(bh); | ||
139 | mark_buffer_dirty(bh); | ||
140 | sync_dirty_buffer(bh); | ||
137 | // update bitmap_info stuff | 141 | // update bitmap_info stuff |
138 | bitmap[i].first_zero_hint = 1; | 142 | bitmap[i].first_zero_hint = 1; |
139 | bitmap[i].free_count = sb_blocksize(sb) * 8 - 1; | 143 | bitmap[i].free_count = sb_blocksize(sb) * 8 - 1; |
144 | brelse(bh); | ||
140 | } | 145 | } |
141 | /* free old bitmap blocks array */ | 146 | /* free old bitmap blocks array */ |
142 | SB_AP_BITMAP(s) = bitmap; | 147 | SB_AP_BITMAP(s) = bitmap; |
@@ -150,30 +155,46 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new) | |||
150 | if (err) | 155 | if (err) |
151 | return err; | 156 | return err; |
152 | 157 | ||
153 | /* correct last bitmap blocks in old and new disk layout */ | 158 | /* Extend old last bitmap block - new blocks have been made available */ |
154 | reiserfs_prepare_for_journal(s, SB_AP_BITMAP(s)[bmap_nr - 1].bh, 1); | 159 | info = SB_AP_BITMAP(s) + bmap_nr - 1; |
160 | bh = reiserfs_read_bitmap_block(s, bmap_nr - 1); | ||
161 | if (!bh) { | ||
162 | int jerr = journal_end(&th, s, 10); | ||
163 | if (jerr) | ||
164 | return jerr; | ||
165 | return -EIO; | ||
166 | } | ||
167 | |||
168 | reiserfs_prepare_for_journal(s, bh, 1); | ||
155 | for (i = block_r; i < s->s_blocksize * 8; i++) | 169 | for (i = block_r; i < s->s_blocksize * 8; i++) |
156 | reiserfs_test_and_clear_le_bit(i, | 170 | reiserfs_test_and_clear_le_bit(i, bh->b_data); |
157 | SB_AP_BITMAP(s)[bmap_nr - | 171 | info->free_count += s->s_blocksize * 8 - block_r; |
158 | 1].bh->b_data); | 172 | if (!info->first_zero_hint) |
159 | SB_AP_BITMAP(s)[bmap_nr - 1].free_count += s->s_blocksize * 8 - block_r; | 173 | info->first_zero_hint = block_r; |
160 | if (!SB_AP_BITMAP(s)[bmap_nr - 1].first_zero_hint) | ||
161 | SB_AP_BITMAP(s)[bmap_nr - 1].first_zero_hint = block_r; | ||
162 | 174 | ||
163 | journal_mark_dirty(&th, s, SB_AP_BITMAP(s)[bmap_nr - 1].bh); | 175 | journal_mark_dirty(&th, s, bh); |
176 | brelse(bh); | ||
177 | |||
178 | /* Correct new last bitmap block - It may not be full */ | ||
179 | info = SB_AP_BITMAP(s) + bmap_nr_new - 1; | ||
180 | bh = reiserfs_read_bitmap_block(s, bmap_nr_new - 1); | ||
181 | if (!bh) { | ||
182 | int jerr = journal_end(&th, s, 10); | ||
183 | if (jerr) | ||
184 | return jerr; | ||
185 | return -EIO; | ||
186 | } | ||
164 | 187 | ||
165 | reiserfs_prepare_for_journal(s, SB_AP_BITMAP(s)[bmap_nr_new - 1].bh, 1); | 188 | reiserfs_prepare_for_journal(s, bh, 1); |
166 | for (i = block_r_new; i < s->s_blocksize * 8; i++) | 189 | for (i = block_r_new; i < s->s_blocksize * 8; i++) |
167 | reiserfs_test_and_set_le_bit(i, | 190 | reiserfs_test_and_set_le_bit(i, bh->b_data); |
168 | SB_AP_BITMAP(s)[bmap_nr_new - | 191 | journal_mark_dirty(&th, s, bh); |
169 | 1].bh->b_data); | 192 | brelse(bh); |
170 | journal_mark_dirty(&th, s, SB_AP_BITMAP(s)[bmap_nr_new - 1].bh); | ||
171 | 193 | ||
172 | SB_AP_BITMAP(s)[bmap_nr_new - 1].free_count -= | 194 | info->free_count -= s->s_blocksize * 8 - block_r_new; |
173 | s->s_blocksize * 8 - block_r_new; | ||
174 | /* Extreme case where last bitmap is the only valid block in itself. */ | 195 | /* Extreme case where last bitmap is the only valid block in itself. */ |
175 | if (!SB_AP_BITMAP(s)[bmap_nr_new - 1].free_count) | 196 | if (!info->free_count) |
176 | SB_AP_BITMAP(s)[bmap_nr_new - 1].first_zero_hint = 0; | 197 | info->first_zero_hint = 0; |
177 | /* update super */ | 198 | /* update super */ |
178 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); | 199 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); |
179 | free_blocks = SB_FREE_BLOCKS(s); | 200 | free_blocks = SB_FREE_BLOCKS(s); |
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index b40d4d64d598..c89aa2338191 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
@@ -432,7 +432,6 @@ int remove_save_link(struct inode *inode, int truncate) | |||
432 | 432 | ||
433 | static void reiserfs_put_super(struct super_block *s) | 433 | static void reiserfs_put_super(struct super_block *s) |
434 | { | 434 | { |
435 | int i; | ||
436 | struct reiserfs_transaction_handle th; | 435 | struct reiserfs_transaction_handle th; |
437 | th.t_trans_id = 0; | 436 | th.t_trans_id = 0; |
438 | 437 | ||
@@ -462,10 +461,7 @@ static void reiserfs_put_super(struct super_block *s) | |||
462 | */ | 461 | */ |
463 | journal_release(&th, s); | 462 | journal_release(&th, s); |
464 | 463 | ||
465 | for (i = 0; i < SB_BMAP_NR(s); i++) | 464 | reiserfs_free_bitmap_cache(s); |
466 | brelse(SB_AP_BITMAP(s)[i].bh); | ||
467 | |||
468 | vfree(SB_AP_BITMAP(s)); | ||
469 | 465 | ||
470 | brelse(SB_BUFFER_WITH_SB(s)); | 466 | brelse(SB_BUFFER_WITH_SB(s)); |
471 | 467 | ||
@@ -510,8 +506,10 @@ static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags) | |||
510 | SLAB_CTOR_CONSTRUCTOR) { | 506 | SLAB_CTOR_CONSTRUCTOR) { |
511 | INIT_LIST_HEAD(&ei->i_prealloc_list); | 507 | INIT_LIST_HEAD(&ei->i_prealloc_list); |
512 | inode_init_once(&ei->vfs_inode); | 508 | inode_init_once(&ei->vfs_inode); |
509 | #ifdef CONFIG_REISERFS_FS_POSIX_ACL | ||
513 | ei->i_acl_access = NULL; | 510 | ei->i_acl_access = NULL; |
514 | ei->i_acl_default = NULL; | 511 | ei->i_acl_default = NULL; |
512 | #endif | ||
515 | } | 513 | } |
516 | } | 514 | } |
517 | 515 | ||
@@ -560,6 +558,7 @@ static void reiserfs_dirty_inode(struct inode *inode) | |||
560 | reiserfs_write_unlock(inode->i_sb); | 558 | reiserfs_write_unlock(inode->i_sb); |
561 | } | 559 | } |
562 | 560 | ||
561 | #ifdef CONFIG_REISERFS_FS_POSIX_ACL | ||
563 | static void reiserfs_clear_inode(struct inode *inode) | 562 | static void reiserfs_clear_inode(struct inode *inode) |
564 | { | 563 | { |
565 | struct posix_acl *acl; | 564 | struct posix_acl *acl; |
@@ -574,6 +573,9 @@ static void reiserfs_clear_inode(struct inode *inode) | |||
574 | posix_acl_release(acl); | 573 | posix_acl_release(acl); |
575 | REISERFS_I(inode)->i_acl_default = NULL; | 574 | REISERFS_I(inode)->i_acl_default = NULL; |
576 | } | 575 | } |
576 | #else | ||
577 | #define reiserfs_clear_inode NULL | ||
578 | #endif | ||
577 | 579 | ||
578 | #ifdef CONFIG_QUOTA | 580 | #ifdef CONFIG_QUOTA |
579 | static ssize_t reiserfs_quota_write(struct super_block *, int, const char *, | 581 | static ssize_t reiserfs_quota_write(struct super_block *, int, const char *, |
@@ -1237,118 +1239,6 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | |||
1237 | return 0; | 1239 | return 0; |
1238 | } | 1240 | } |
1239 | 1241 | ||
1240 | /* load_bitmap_info_data - Sets up the reiserfs_bitmap_info structure from disk. | ||
1241 | * @sb - superblock for this filesystem | ||
1242 | * @bi - the bitmap info to be loaded. Requires that bi->bh is valid. | ||
1243 | * | ||
1244 | * This routine counts how many free bits there are, finding the first zero | ||
1245 | * as a side effect. Could also be implemented as a loop of test_bit() calls, or | ||
1246 | * a loop of find_first_zero_bit() calls. This implementation is similar to | ||
1247 | * find_first_zero_bit(), but doesn't return after it finds the first bit. | ||
1248 | * Should only be called on fs mount, but should be fairly efficient anyways. | ||
1249 | * | ||
1250 | * bi->first_zero_hint is considered unset if it == 0, since the bitmap itself | ||
1251 | * will * invariably occupt block 0 represented in the bitmap. The only | ||
1252 | * exception to this is when free_count also == 0, since there will be no | ||
1253 | * free blocks at all. | ||
1254 | */ | ||
1255 | |||
1256 | static void load_bitmap_info_data(struct super_block *sb, | ||
1257 | struct reiserfs_bitmap_info *bi) | ||
1258 | { | ||
1259 | unsigned long *cur = (unsigned long *)bi->bh->b_data; | ||
1260 | |||
1261 | while ((char *)cur < (bi->bh->b_data + sb->s_blocksize)) { | ||
1262 | |||
1263 | /* No need to scan if all 0's or all 1's. | ||
1264 | * Since we're only counting 0's, we can simply ignore all 1's */ | ||
1265 | if (*cur == 0) { | ||
1266 | if (bi->first_zero_hint == 0) { | ||
1267 | bi->first_zero_hint = | ||
1268 | ((char *)cur - bi->bh->b_data) << 3; | ||
1269 | } | ||
1270 | bi->free_count += sizeof(unsigned long) * 8; | ||
1271 | } else if (*cur != ~0L) { | ||
1272 | int b; | ||
1273 | for (b = 0; b < sizeof(unsigned long) * 8; b++) { | ||
1274 | if (!reiserfs_test_le_bit(b, cur)) { | ||
1275 | bi->free_count++; | ||
1276 | if (bi->first_zero_hint == 0) | ||
1277 | bi->first_zero_hint = | ||
1278 | (((char *)cur - | ||
1279 | bi->bh->b_data) << 3) + b; | ||
1280 | } | ||
1281 | } | ||
1282 | } | ||
1283 | cur++; | ||
1284 | } | ||
1285 | |||
1286 | #ifdef CONFIG_REISERFS_CHECK | ||
1287 | // This outputs a lot of unneded info on big FSes | ||
1288 | // reiserfs_warning ("bitmap loaded from block %d: %d free blocks", | ||
1289 | // bi->bh->b_blocknr, bi->free_count); | ||
1290 | #endif | ||
1291 | } | ||
1292 | |||
1293 | static int read_bitmaps(struct super_block *s) | ||
1294 | { | ||
1295 | int i, bmap_nr; | ||
1296 | |||
1297 | SB_AP_BITMAP(s) = | ||
1298 | vmalloc(sizeof(struct reiserfs_bitmap_info) * SB_BMAP_NR(s)); | ||
1299 | if (SB_AP_BITMAP(s) == 0) | ||
1300 | return 1; | ||
1301 | memset(SB_AP_BITMAP(s), 0, | ||
1302 | sizeof(struct reiserfs_bitmap_info) * SB_BMAP_NR(s)); | ||
1303 | for (i = 0, bmap_nr = | ||
1304 | REISERFS_DISK_OFFSET_IN_BYTES / s->s_blocksize + 1; | ||
1305 | i < SB_BMAP_NR(s); i++, bmap_nr = s->s_blocksize * 8 * i) { | ||
1306 | SB_AP_BITMAP(s)[i].bh = sb_getblk(s, bmap_nr); | ||
1307 | if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) | ||
1308 | ll_rw_block(READ, 1, &SB_AP_BITMAP(s)[i].bh); | ||
1309 | } | ||
1310 | for (i = 0; i < SB_BMAP_NR(s); i++) { | ||
1311 | wait_on_buffer(SB_AP_BITMAP(s)[i].bh); | ||
1312 | if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) { | ||
1313 | reiserfs_warning(s, "sh-2029: reiserfs read_bitmaps: " | ||
1314 | "bitmap block (#%lu) reading failed", | ||
1315 | SB_AP_BITMAP(s)[i].bh->b_blocknr); | ||
1316 | for (i = 0; i < SB_BMAP_NR(s); i++) | ||
1317 | brelse(SB_AP_BITMAP(s)[i].bh); | ||
1318 | vfree(SB_AP_BITMAP(s)); | ||
1319 | SB_AP_BITMAP(s) = NULL; | ||
1320 | return 1; | ||
1321 | } | ||
1322 | load_bitmap_info_data(s, SB_AP_BITMAP(s) + i); | ||
1323 | } | ||
1324 | return 0; | ||
1325 | } | ||
1326 | |||
1327 | static int read_old_bitmaps(struct super_block *s) | ||
1328 | { | ||
1329 | int i; | ||
1330 | struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(s); | ||
1331 | int bmp1 = (REISERFS_OLD_DISK_OFFSET_IN_BYTES / s->s_blocksize) + 1; /* first of bitmap blocks */ | ||
1332 | |||
1333 | /* read true bitmap */ | ||
1334 | SB_AP_BITMAP(s) = | ||
1335 | vmalloc(sizeof(struct reiserfs_buffer_info *) * sb_bmap_nr(rs)); | ||
1336 | if (SB_AP_BITMAP(s) == 0) | ||
1337 | return 1; | ||
1338 | |||
1339 | memset(SB_AP_BITMAP(s), 0, | ||
1340 | sizeof(struct reiserfs_buffer_info *) * sb_bmap_nr(rs)); | ||
1341 | |||
1342 | for (i = 0; i < sb_bmap_nr(rs); i++) { | ||
1343 | SB_AP_BITMAP(s)[i].bh = sb_bread(s, bmp1 + i); | ||
1344 | if (!SB_AP_BITMAP(s)[i].bh) | ||
1345 | return 1; | ||
1346 | load_bitmap_info_data(s, SB_AP_BITMAP(s) + i); | ||
1347 | } | ||
1348 | |||
1349 | return 0; | ||
1350 | } | ||
1351 | |||
1352 | static int read_super_block(struct super_block *s, int offset) | 1242 | static int read_super_block(struct super_block *s, int offset) |
1353 | { | 1243 | { |
1354 | struct buffer_head *bh; | 1244 | struct buffer_head *bh; |
@@ -1450,7 +1340,6 @@ static int read_super_block(struct super_block *s, int offset) | |||
1450 | /* after journal replay, reread all bitmap and super blocks */ | 1340 | /* after journal replay, reread all bitmap and super blocks */ |
1451 | static int reread_meta_blocks(struct super_block *s) | 1341 | static int reread_meta_blocks(struct super_block *s) |
1452 | { | 1342 | { |
1453 | int i; | ||
1454 | ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s))); | 1343 | ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s))); |
1455 | wait_on_buffer(SB_BUFFER_WITH_SB(s)); | 1344 | wait_on_buffer(SB_BUFFER_WITH_SB(s)); |
1456 | if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) { | 1345 | if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) { |
@@ -1459,20 +1348,7 @@ static int reread_meta_blocks(struct super_block *s) | |||
1459 | return 1; | 1348 | return 1; |
1460 | } | 1349 | } |
1461 | 1350 | ||
1462 | for (i = 0; i < SB_BMAP_NR(s); i++) { | ||
1463 | ll_rw_block(READ, 1, &(SB_AP_BITMAP(s)[i].bh)); | ||
1464 | wait_on_buffer(SB_AP_BITMAP(s)[i].bh); | ||
1465 | if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) { | ||
1466 | reiserfs_warning(s, | ||
1467 | "reread_meta_blocks, error reading bitmap block number %d at %llu", | ||
1468 | i, | ||
1469 | (unsigned long long)SB_AP_BITMAP(s)[i]. | ||
1470 | bh->b_blocknr); | ||
1471 | return 1; | ||
1472 | } | ||
1473 | } | ||
1474 | return 0; | 1351 | return 0; |
1475 | |||
1476 | } | 1352 | } |
1477 | 1353 | ||
1478 | ///////////////////////////////////////////////////// | 1354 | ///////////////////////////////////////////////////// |
@@ -1653,7 +1529,6 @@ static int function2code(hashf_t func) | |||
1653 | static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | 1529 | static int reiserfs_fill_super(struct super_block *s, void *data, int silent) |
1654 | { | 1530 | { |
1655 | struct inode *root_inode; | 1531 | struct inode *root_inode; |
1656 | int j; | ||
1657 | struct reiserfs_transaction_handle th; | 1532 | struct reiserfs_transaction_handle th; |
1658 | int old_format = 0; | 1533 | int old_format = 0; |
1659 | unsigned long blocks; | 1534 | unsigned long blocks; |
@@ -1730,7 +1605,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
1730 | sbi->s_mount_state = SB_REISERFS_STATE(s); | 1605 | sbi->s_mount_state = SB_REISERFS_STATE(s); |
1731 | sbi->s_mount_state = REISERFS_VALID_FS; | 1606 | sbi->s_mount_state = REISERFS_VALID_FS; |
1732 | 1607 | ||
1733 | if (old_format ? read_old_bitmaps(s) : read_bitmaps(s)) { | 1608 | if ((errval = reiserfs_init_bitmap_cache(s))) { |
1734 | SWARN(silent, s, | 1609 | SWARN(silent, s, |
1735 | "jmacd-8: reiserfs_fill_super: unable to read bitmap"); | 1610 | "jmacd-8: reiserfs_fill_super: unable to read bitmap"); |
1736 | goto error; | 1611 | goto error; |
@@ -1812,6 +1687,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
1812 | if (is_reiserfs_3_5(rs) | 1687 | if (is_reiserfs_3_5(rs) |
1813 | || (is_reiserfs_jr(rs) && SB_VERSION(s) == REISERFS_VERSION_1)) | 1688 | || (is_reiserfs_jr(rs) && SB_VERSION(s) == REISERFS_VERSION_1)) |
1814 | set_bit(REISERFS_3_5, &(sbi->s_properties)); | 1689 | set_bit(REISERFS_3_5, &(sbi->s_properties)); |
1690 | else if (old_format) | ||
1691 | set_bit(REISERFS_OLD_FORMAT, &(sbi->s_properties)); | ||
1815 | else | 1692 | else |
1816 | set_bit(REISERFS_3_6, &(sbi->s_properties)); | 1693 | set_bit(REISERFS_3_6, &(sbi->s_properties)); |
1817 | 1694 | ||
@@ -1897,19 +1774,17 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
1897 | if (jinit_done) { /* kill the commit thread, free journal ram */ | 1774 | if (jinit_done) { /* kill the commit thread, free journal ram */ |
1898 | journal_release_error(NULL, s); | 1775 | journal_release_error(NULL, s); |
1899 | } | 1776 | } |
1900 | if (SB_DISK_SUPER_BLOCK(s)) { | 1777 | |
1901 | for (j = 0; j < SB_BMAP_NR(s); j++) { | 1778 | reiserfs_free_bitmap_cache(s); |
1902 | if (SB_AP_BITMAP(s)) | ||
1903 | brelse(SB_AP_BITMAP(s)[j].bh); | ||
1904 | } | ||
1905 | vfree(SB_AP_BITMAP(s)); | ||
1906 | } | ||
1907 | if (SB_BUFFER_WITH_SB(s)) | 1779 | if (SB_BUFFER_WITH_SB(s)) |
1908 | brelse(SB_BUFFER_WITH_SB(s)); | 1780 | brelse(SB_BUFFER_WITH_SB(s)); |
1909 | #ifdef CONFIG_QUOTA | 1781 | #ifdef CONFIG_QUOTA |
1910 | for (j = 0; j < MAXQUOTAS; j++) { | 1782 | { |
1911 | kfree(sbi->s_qf_names[j]); | 1783 | int j; |
1912 | sbi->s_qf_names[j] = NULL; | 1784 | for (j = 0; j < MAXQUOTAS; j++) { |
1785 | kfree(sbi->s_qf_names[j]); | ||
1786 | sbi->s_qf_names[j] = NULL; | ||
1787 | } | ||
1913 | } | 1788 | } |
1914 | #endif | 1789 | #endif |
1915 | kfree(sbi); | 1790 | kfree(sbi); |
diff --git a/fs/select.c b/fs/select.c index 33b72ba0f86f..dcbc1112b7ec 100644 --- a/fs/select.c +++ b/fs/select.c | |||
@@ -658,8 +658,6 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds, s64 *timeout) | |||
658 | unsigned int i; | 658 | unsigned int i; |
659 | struct poll_list *head; | 659 | struct poll_list *head; |
660 | struct poll_list *walk; | 660 | struct poll_list *walk; |
661 | struct fdtable *fdt; | ||
662 | int max_fdset; | ||
663 | /* Allocate small arguments on the stack to save memory and be | 661 | /* Allocate small arguments on the stack to save memory and be |
664 | faster - use long to make sure the buffer is aligned properly | 662 | faster - use long to make sure the buffer is aligned properly |
665 | on 64 bit archs to avoid unaligned access */ | 663 | on 64 bit archs to avoid unaligned access */ |
@@ -667,11 +665,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds, s64 *timeout) | |||
667 | struct poll_list *stack_pp = NULL; | 665 | struct poll_list *stack_pp = NULL; |
668 | 666 | ||
669 | /* Do a sanity check on nfds ... */ | 667 | /* Do a sanity check on nfds ... */ |
670 | rcu_read_lock(); | 668 | if (nfds > current->signal->rlim[RLIMIT_NOFILE].rlim_cur) |
671 | fdt = files_fdtable(current->files); | ||
672 | max_fdset = fdt->max_fdset; | ||
673 | rcu_read_unlock(); | ||
674 | if (nfds > max_fdset && nfds > OPEN_MAX) | ||
675 | return -EINVAL; | 669 | return -EINVAL; |
676 | 670 | ||
677 | poll_initwait(&table); | 671 | poll_initwait(&table); |
diff --git a/fs/smbfs/file.c b/fs/smbfs/file.c index dae67048baba..50784d13c87b 100644 --- a/fs/smbfs/file.c +++ b/fs/smbfs/file.c | |||
@@ -214,13 +214,15 @@ smb_updatepage(struct file *file, struct page *page, unsigned long offset, | |||
214 | } | 214 | } |
215 | 215 | ||
216 | static ssize_t | 216 | static ssize_t |
217 | smb_file_read(struct file * file, char __user * buf, size_t count, loff_t *ppos) | 217 | smb_file_aio_read(struct kiocb *iocb, const struct iovec *iov, |
218 | unsigned long nr_segs, loff_t pos) | ||
218 | { | 219 | { |
220 | struct file * file = iocb->ki_filp; | ||
219 | struct dentry * dentry = file->f_dentry; | 221 | struct dentry * dentry = file->f_dentry; |
220 | ssize_t status; | 222 | ssize_t status; |
221 | 223 | ||
222 | VERBOSE("file %s/%s, count=%lu@%lu\n", DENTRY_PATH(dentry), | 224 | VERBOSE("file %s/%s, count=%lu@%lu\n", DENTRY_PATH(dentry), |
223 | (unsigned long) count, (unsigned long) *ppos); | 225 | (unsigned long) iocb->ki_left, (unsigned long) pos); |
224 | 226 | ||
225 | status = smb_revalidate_inode(dentry); | 227 | status = smb_revalidate_inode(dentry); |
226 | if (status) { | 228 | if (status) { |
@@ -233,7 +235,7 @@ smb_file_read(struct file * file, char __user * buf, size_t count, loff_t *ppos) | |||
233 | (long)dentry->d_inode->i_size, | 235 | (long)dentry->d_inode->i_size, |
234 | dentry->d_inode->i_flags, dentry->d_inode->i_atime); | 236 | dentry->d_inode->i_flags, dentry->d_inode->i_atime); |
235 | 237 | ||
236 | status = generic_file_read(file, buf, count, ppos); | 238 | status = generic_file_aio_read(iocb, iov, nr_segs, pos); |
237 | out: | 239 | out: |
238 | return status; | 240 | return status; |
239 | } | 241 | } |
@@ -317,14 +319,16 @@ const struct address_space_operations smb_file_aops = { | |||
317 | * Write to a file (through the page cache). | 319 | * Write to a file (through the page cache). |
318 | */ | 320 | */ |
319 | static ssize_t | 321 | static ssize_t |
320 | smb_file_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | 322 | smb_file_aio_write(struct kiocb *iocb, const struct iovec *iov, |
323 | unsigned long nr_segs, loff_t pos) | ||
321 | { | 324 | { |
325 | struct file * file = iocb->ki_filp; | ||
322 | struct dentry * dentry = file->f_dentry; | 326 | struct dentry * dentry = file->f_dentry; |
323 | ssize_t result; | 327 | ssize_t result; |
324 | 328 | ||
325 | VERBOSE("file %s/%s, count=%lu@%lu\n", | 329 | VERBOSE("file %s/%s, count=%lu@%lu\n", |
326 | DENTRY_PATH(dentry), | 330 | DENTRY_PATH(dentry), |
327 | (unsigned long) count, (unsigned long) *ppos); | 331 | (unsigned long) iocb->ki_left, (unsigned long) pos); |
328 | 332 | ||
329 | result = smb_revalidate_inode(dentry); | 333 | result = smb_revalidate_inode(dentry); |
330 | if (result) { | 334 | if (result) { |
@@ -337,8 +341,8 @@ smb_file_write(struct file *file, const char __user *buf, size_t count, loff_t * | |||
337 | if (result) | 341 | if (result) |
338 | goto out; | 342 | goto out; |
339 | 343 | ||
340 | if (count > 0) { | 344 | if (iocb->ki_left > 0) { |
341 | result = generic_file_write(file, buf, count, ppos); | 345 | result = generic_file_aio_write(iocb, iov, nr_segs, pos); |
342 | VERBOSE("pos=%ld, size=%ld, mtime=%ld, atime=%ld\n", | 346 | VERBOSE("pos=%ld, size=%ld, mtime=%ld, atime=%ld\n", |
343 | (long) file->f_pos, (long) dentry->d_inode->i_size, | 347 | (long) file->f_pos, (long) dentry->d_inode->i_size, |
344 | dentry->d_inode->i_mtime, dentry->d_inode->i_atime); | 348 | dentry->d_inode->i_mtime, dentry->d_inode->i_atime); |
@@ -402,8 +406,10 @@ smb_file_permission(struct inode *inode, int mask, struct nameidata *nd) | |||
402 | const struct file_operations smb_file_operations = | 406 | const struct file_operations smb_file_operations = |
403 | { | 407 | { |
404 | .llseek = remote_llseek, | 408 | .llseek = remote_llseek, |
405 | .read = smb_file_read, | 409 | .read = do_sync_read, |
406 | .write = smb_file_write, | 410 | .aio_read = smb_file_aio_read, |
411 | .write = do_sync_write, | ||
412 | .aio_write = smb_file_aio_write, | ||
407 | .ioctl = smb_ioctl, | 413 | .ioctl = smb_ioctl, |
408 | .mmap = smb_file_mmap, | 414 | .mmap = smb_file_mmap, |
409 | .open = smb_file_open, | 415 | .open = smb_file_open, |
diff --git a/fs/splice.c b/fs/splice.c index 684bca3d3a10..13e92dd19fbb 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
@@ -12,7 +12,7 @@ | |||
12 | * Jens to support splicing to files, network, direct splicing, etc and | 12 | * Jens to support splicing to files, network, direct splicing, etc and |
13 | * fixing lots of bugs. | 13 | * fixing lots of bugs. |
14 | * | 14 | * |
15 | * Copyright (C) 2005-2006 Jens Axboe <axboe@suse.de> | 15 | * Copyright (C) 2005-2006 Jens Axboe <axboe@kernel.dk> |
16 | * Copyright (C) 2005-2006 Linus Torvalds <torvalds@osdl.org> | 16 | * Copyright (C) 2005-2006 Linus Torvalds <torvalds@osdl.org> |
17 | * Copyright (C) 2006 Ingo Molnar <mingo@elte.hu> | 17 | * Copyright (C) 2006 Ingo Molnar <mingo@elte.hu> |
18 | * | 18 | * |
diff --git a/fs/super.c b/fs/super.c index 5c4c94d5495e..aec99ddbe53f 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -199,7 +199,7 @@ EXPORT_SYMBOL(deactivate_super); | |||
199 | * success, 0 if we had failed (superblock contents was already dead or | 199 | * success, 0 if we had failed (superblock contents was already dead or |
200 | * dying when grab_super() had been called). | 200 | * dying when grab_super() had been called). |
201 | */ | 201 | */ |
202 | static int grab_super(struct super_block *s) | 202 | static int grab_super(struct super_block *s) __releases(sb_lock) |
203 | { | 203 | { |
204 | s->s_count++; | 204 | s->s_count++; |
205 | spin_unlock(&sb_lock); | 205 | spin_unlock(&sb_lock); |
@@ -220,6 +220,37 @@ static int grab_super(struct super_block *s) | |||
220 | return 0; | 220 | return 0; |
221 | } | 221 | } |
222 | 222 | ||
223 | /* | ||
224 | * Write out and wait upon all dirty data associated with this | ||
225 | * superblock. Filesystem data as well as the underlying block | ||
226 | * device. Takes the superblock lock. Requires a second blkdev | ||
227 | * flush by the caller to complete the operation. | ||
228 | */ | ||
229 | void __fsync_super(struct super_block *sb) | ||
230 | { | ||
231 | sync_inodes_sb(sb, 0); | ||
232 | DQUOT_SYNC(sb); | ||
233 | lock_super(sb); | ||
234 | if (sb->s_dirt && sb->s_op->write_super) | ||
235 | sb->s_op->write_super(sb); | ||
236 | unlock_super(sb); | ||
237 | if (sb->s_op->sync_fs) | ||
238 | sb->s_op->sync_fs(sb, 1); | ||
239 | sync_blockdev(sb->s_bdev); | ||
240 | sync_inodes_sb(sb, 1); | ||
241 | } | ||
242 | |||
243 | /* | ||
244 | * Write out and wait upon all dirty data associated with this | ||
245 | * superblock. Filesystem data as well as the underlying block | ||
246 | * device. Takes the superblock lock. | ||
247 | */ | ||
248 | int fsync_super(struct super_block *sb) | ||
249 | { | ||
250 | __fsync_super(sb); | ||
251 | return sync_blockdev(sb->s_bdev); | ||
252 | } | ||
253 | |||
223 | /** | 254 | /** |
224 | * generic_shutdown_super - common helper for ->kill_sb() | 255 | * generic_shutdown_super - common helper for ->kill_sb() |
225 | * @sb: superblock to kill | 256 | * @sb: superblock to kill |
@@ -540,8 +571,10 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force) | |||
540 | { | 571 | { |
541 | int retval; | 572 | int retval; |
542 | 573 | ||
574 | #ifdef CONFIG_BLOCK | ||
543 | if (!(flags & MS_RDONLY) && bdev_read_only(sb->s_bdev)) | 575 | if (!(flags & MS_RDONLY) && bdev_read_only(sb->s_bdev)) |
544 | return -EACCES; | 576 | return -EACCES; |
577 | #endif | ||
545 | if (flags & MS_RDONLY) | 578 | if (flags & MS_RDONLY) |
546 | acct_auto_close(sb); | 579 | acct_auto_close(sb); |
547 | shrink_dcache_sb(sb); | 580 | shrink_dcache_sb(sb); |
@@ -661,6 +694,7 @@ void kill_litter_super(struct super_block *sb) | |||
661 | 694 | ||
662 | EXPORT_SYMBOL(kill_litter_super); | 695 | EXPORT_SYMBOL(kill_litter_super); |
663 | 696 | ||
697 | #ifdef CONFIG_BLOCK | ||
664 | static int set_bdev_super(struct super_block *s, void *data) | 698 | static int set_bdev_super(struct super_block *s, void *data) |
665 | { | 699 | { |
666 | s->s_bdev = data; | 700 | s->s_bdev = data; |
@@ -756,6 +790,7 @@ void kill_block_super(struct super_block *sb) | |||
756 | } | 790 | } |
757 | 791 | ||
758 | EXPORT_SYMBOL(kill_block_super); | 792 | EXPORT_SYMBOL(kill_block_super); |
793 | #endif | ||
759 | 794 | ||
760 | int get_sb_nodev(struct file_system_type *fs_type, | 795 | int get_sb_nodev(struct file_system_type *fs_type, |
761 | int flags, void *data, | 796 | int flags, void *data, |
@@ -10,11 +10,124 @@ | |||
10 | #include <linux/syscalls.h> | 10 | #include <linux/syscalls.h> |
11 | #include <linux/linkage.h> | 11 | #include <linux/linkage.h> |
12 | #include <linux/pagemap.h> | 12 | #include <linux/pagemap.h> |
13 | #include <linux/quotaops.h> | ||
14 | #include <linux/buffer_head.h> | ||
13 | 15 | ||
14 | #define VALID_FLAGS (SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| \ | 16 | #define VALID_FLAGS (SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| \ |
15 | SYNC_FILE_RANGE_WAIT_AFTER) | 17 | SYNC_FILE_RANGE_WAIT_AFTER) |
16 | 18 | ||
17 | /* | 19 | /* |
20 | * sync everything. Start out by waking pdflush, because that writes back | ||
21 | * all queues in parallel. | ||
22 | */ | ||
23 | static void do_sync(unsigned long wait) | ||
24 | { | ||
25 | wakeup_pdflush(0); | ||
26 | sync_inodes(0); /* All mappings, inodes and their blockdevs */ | ||
27 | DQUOT_SYNC(NULL); | ||
28 | sync_supers(); /* Write the superblocks */ | ||
29 | sync_filesystems(0); /* Start syncing the filesystems */ | ||
30 | sync_filesystems(wait); /* Waitingly sync the filesystems */ | ||
31 | sync_inodes(wait); /* Mappings, inodes and blockdevs, again. */ | ||
32 | if (!wait) | ||
33 | printk("Emergency Sync complete\n"); | ||
34 | if (unlikely(laptop_mode)) | ||
35 | laptop_sync_completion(); | ||
36 | } | ||
37 | |||
38 | asmlinkage long sys_sync(void) | ||
39 | { | ||
40 | do_sync(1); | ||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | void emergency_sync(void) | ||
45 | { | ||
46 | pdflush_operation(do_sync, 0); | ||
47 | } | ||
48 | |||
49 | /* | ||
50 | * Generic function to fsync a file. | ||
51 | * | ||
52 | * filp may be NULL if called via the msync of a vma. | ||
53 | */ | ||
54 | int file_fsync(struct file *filp, struct dentry *dentry, int datasync) | ||
55 | { | ||
56 | struct inode * inode = dentry->d_inode; | ||
57 | struct super_block * sb; | ||
58 | int ret, err; | ||
59 | |||
60 | /* sync the inode to buffers */ | ||
61 | ret = write_inode_now(inode, 0); | ||
62 | |||
63 | /* sync the superblock to buffers */ | ||
64 | sb = inode->i_sb; | ||
65 | lock_super(sb); | ||
66 | if (sb->s_op->write_super) | ||
67 | sb->s_op->write_super(sb); | ||
68 | unlock_super(sb); | ||
69 | |||
70 | /* .. finally sync the buffers to disk */ | ||
71 | err = sync_blockdev(sb->s_bdev); | ||
72 | if (!ret) | ||
73 | ret = err; | ||
74 | return ret; | ||
75 | } | ||
76 | |||
77 | long do_fsync(struct file *file, int datasync) | ||
78 | { | ||
79 | int ret; | ||
80 | int err; | ||
81 | struct address_space *mapping = file->f_mapping; | ||
82 | |||
83 | if (!file->f_op || !file->f_op->fsync) { | ||
84 | /* Why? We can still call filemap_fdatawrite */ | ||
85 | ret = -EINVAL; | ||
86 | goto out; | ||
87 | } | ||
88 | |||
89 | ret = filemap_fdatawrite(mapping); | ||
90 | |||
91 | /* | ||
92 | * We need to protect against concurrent writers, which could cause | ||
93 | * livelocks in fsync_buffers_list(). | ||
94 | */ | ||
95 | mutex_lock(&mapping->host->i_mutex); | ||
96 | err = file->f_op->fsync(file, file->f_dentry, datasync); | ||
97 | if (!ret) | ||
98 | ret = err; | ||
99 | mutex_unlock(&mapping->host->i_mutex); | ||
100 | err = filemap_fdatawait(mapping); | ||
101 | if (!ret) | ||
102 | ret = err; | ||
103 | out: | ||
104 | return ret; | ||
105 | } | ||
106 | |||
107 | static long __do_fsync(unsigned int fd, int datasync) | ||
108 | { | ||
109 | struct file *file; | ||
110 | int ret = -EBADF; | ||
111 | |||
112 | file = fget(fd); | ||
113 | if (file) { | ||
114 | ret = do_fsync(file, datasync); | ||
115 | fput(file); | ||
116 | } | ||
117 | return ret; | ||
118 | } | ||
119 | |||
120 | asmlinkage long sys_fsync(unsigned int fd) | ||
121 | { | ||
122 | return __do_fsync(fd, 0); | ||
123 | } | ||
124 | |||
125 | asmlinkage long sys_fdatasync(unsigned int fd) | ||
126 | { | ||
127 | return __do_fsync(fd, 1); | ||
128 | } | ||
129 | |||
130 | /* | ||
18 | * sys_sync_file_range() permits finely controlled syncing over a segment of | 131 | * sys_sync_file_range() permits finely controlled syncing over a segment of |
19 | * a file in the range offset .. (offset+nbytes-1) inclusive. If nbytes is | 132 | * a file in the range offset .. (offset+nbytes-1) inclusive. If nbytes is |
20 | * zero then sys_sync_file_range() will operate from offset out to EOF. | 133 | * zero then sys_sync_file_range() will operate from offset out to EOF. |
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 5f3d725d1125..3aa3434621ca 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -103,7 +103,7 @@ static int init_dir(struct inode * inode) | |||
103 | inode->i_fop = &sysfs_dir_operations; | 103 | inode->i_fop = &sysfs_dir_operations; |
104 | 104 | ||
105 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | 105 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ |
106 | inode->i_nlink++; | 106 | inc_nlink(inode); |
107 | return 0; | 107 | return 0; |
108 | } | 108 | } |
109 | 109 | ||
@@ -137,7 +137,7 @@ static int create_dir(struct kobject * k, struct dentry * p, | |||
137 | if (!error) { | 137 | if (!error) { |
138 | error = sysfs_create(*d, mode, init_dir); | 138 | error = sysfs_create(*d, mode, init_dir); |
139 | if (!error) { | 139 | if (!error) { |
140 | p->d_inode->i_nlink++; | 140 | inc_nlink(p->d_inode); |
141 | (*d)->d_op = &sysfs_dentry_ops; | 141 | (*d)->d_op = &sysfs_dentry_ops; |
142 | d_rehash(*d); | 142 | d_rehash(*d); |
143 | } | 143 | } |
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c index 40190c489271..20551a1b8a56 100644 --- a/fs/sysfs/mount.c +++ b/fs/sysfs/mount.c | |||
@@ -49,7 +49,7 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent) | |||
49 | inode->i_op = &sysfs_dir_inode_operations; | 49 | inode->i_op = &sysfs_dir_inode_operations; |
50 | inode->i_fop = &sysfs_dir_operations; | 50 | inode->i_fop = &sysfs_dir_operations; |
51 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | 51 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ |
52 | inode->i_nlink++; | 52 | inc_nlink(inode); |
53 | } else { | 53 | } else { |
54 | pr_debug("sysfs: could not get root inode\n"); | 54 | pr_debug("sysfs: could not get root inode\n"); |
55 | return -ENOMEM; | 55 | return -ENOMEM; |
diff --git a/fs/sysv/file.c b/fs/sysv/file.c index a59e303135fa..47a4b728f15b 100644 --- a/fs/sysv/file.c +++ b/fs/sysv/file.c | |||
@@ -21,8 +21,10 @@ | |||
21 | */ | 21 | */ |
22 | const struct file_operations sysv_file_operations = { | 22 | const struct file_operations sysv_file_operations = { |
23 | .llseek = generic_file_llseek, | 23 | .llseek = generic_file_llseek, |
24 | .read = generic_file_read, | 24 | .read = do_sync_read, |
25 | .write = generic_file_write, | 25 | .aio_read = generic_file_aio_read, |
26 | .write = do_sync_write, | ||
27 | .aio_write = generic_file_aio_write, | ||
26 | .mmap = generic_file_mmap, | 28 | .mmap = generic_file_mmap, |
27 | .fsync = sysv_sync_file, | 29 | .fsync = sysv_sync_file, |
28 | .sendfile = generic_file_sendfile, | 30 | .sendfile = generic_file_sendfile, |
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c index b8a73f716fbe..f7c08db8e34c 100644 --- a/fs/sysv/namei.c +++ b/fs/sysv/namei.c | |||
@@ -250,7 +250,7 @@ static int sysv_rename(struct inode * old_dir, struct dentry * old_dentry, | |||
250 | sysv_set_link(new_de, new_page, old_inode); | 250 | sysv_set_link(new_de, new_page, old_inode); |
251 | new_inode->i_ctime = CURRENT_TIME_SEC; | 251 | new_inode->i_ctime = CURRENT_TIME_SEC; |
252 | if (dir_de) | 252 | if (dir_de) |
253 | new_inode->i_nlink--; | 253 | drop_nlink(new_inode); |
254 | inode_dec_link_count(new_inode); | 254 | inode_dec_link_count(new_inode); |
255 | } else { | 255 | } else { |
256 | if (dir_de) { | 256 | if (dir_de) { |
diff --git a/fs/udf/file.c b/fs/udf/file.c index a59e5f33daf6..7aedd552cba1 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c | |||
@@ -103,19 +103,21 @@ const struct address_space_operations udf_adinicb_aops = { | |||
103 | .commit_write = udf_adinicb_commit_write, | 103 | .commit_write = udf_adinicb_commit_write, |
104 | }; | 104 | }; |
105 | 105 | ||
106 | static ssize_t udf_file_write(struct file * file, const char __user * buf, | 106 | static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, |
107 | size_t count, loff_t *ppos) | 107 | unsigned long nr_segs, loff_t ppos) |
108 | { | 108 | { |
109 | ssize_t retval; | 109 | ssize_t retval; |
110 | struct file *file = iocb->ki_filp; | ||
110 | struct inode *inode = file->f_dentry->d_inode; | 111 | struct inode *inode = file->f_dentry->d_inode; |
111 | int err, pos; | 112 | int err, pos; |
113 | size_t count = iocb->ki_left; | ||
112 | 114 | ||
113 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) | 115 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) |
114 | { | 116 | { |
115 | if (file->f_flags & O_APPEND) | 117 | if (file->f_flags & O_APPEND) |
116 | pos = inode->i_size; | 118 | pos = inode->i_size; |
117 | else | 119 | else |
118 | pos = *ppos; | 120 | pos = ppos; |
119 | 121 | ||
120 | if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) + | 122 | if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) + |
121 | pos + count)) | 123 | pos + count)) |
@@ -136,7 +138,7 @@ static ssize_t udf_file_write(struct file * file, const char __user * buf, | |||
136 | } | 138 | } |
137 | } | 139 | } |
138 | 140 | ||
139 | retval = generic_file_write(file, buf, count, ppos); | 141 | retval = generic_file_aio_write(iocb, iov, nr_segs, ppos); |
140 | 142 | ||
141 | if (retval > 0) | 143 | if (retval > 0) |
142 | mark_inode_dirty(inode); | 144 | mark_inode_dirty(inode); |
@@ -249,11 +251,13 @@ static int udf_release_file(struct inode * inode, struct file * filp) | |||
249 | } | 251 | } |
250 | 252 | ||
251 | const struct file_operations udf_file_operations = { | 253 | const struct file_operations udf_file_operations = { |
252 | .read = generic_file_read, | 254 | .read = do_sync_read, |
255 | .aio_read = generic_file_aio_read, | ||
253 | .ioctl = udf_ioctl, | 256 | .ioctl = udf_ioctl, |
254 | .open = generic_file_open, | 257 | .open = generic_file_open, |
255 | .mmap = generic_file_mmap, | 258 | .mmap = generic_file_mmap, |
256 | .write = udf_file_write, | 259 | .write = do_sync_write, |
260 | .aio_write = udf_file_aio_write, | ||
257 | .release = udf_release_file, | 261 | .release = udf_release_file, |
258 | .fsync = udf_fsync_file, | 262 | .fsync = udf_fsync_file, |
259 | .sendfile = generic_file_sendfile, | 263 | .sendfile = generic_file_sendfile, |
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index b223b32db991..ae21a0e59e95 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c | |||
@@ -1165,7 +1165,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1165 | inode->i_op = &udf_dir_inode_operations; | 1165 | inode->i_op = &udf_dir_inode_operations; |
1166 | inode->i_fop = &udf_dir_operations; | 1166 | inode->i_fop = &udf_dir_operations; |
1167 | inode->i_mode |= S_IFDIR; | 1167 | inode->i_mode |= S_IFDIR; |
1168 | inode->i_nlink ++; | 1168 | inc_nlink(inode); |
1169 | break; | 1169 | break; |
1170 | } | 1170 | } |
1171 | case ICBTAG_FILE_TYPE_REALTIME: | 1171 | case ICBTAG_FILE_TYPE_REALTIME: |
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index ab9a7629d23e..73163325e5ec 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
@@ -762,7 +762,7 @@ static int udf_mkdir(struct inode * dir, struct dentry * dentry, int mode) | |||
762 | cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); | 762 | cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); |
763 | cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY; | 763 | cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY; |
764 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 764 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
765 | dir->i_nlink++; | 765 | inc_nlink(dir); |
766 | mark_inode_dirty(dir); | 766 | mark_inode_dirty(dir); |
767 | d_instantiate(dentry, inode); | 767 | d_instantiate(dentry, inode); |
768 | if (fibh.sbh != fibh.ebh) | 768 | if (fibh.sbh != fibh.ebh) |
@@ -876,10 +876,9 @@ static int udf_rmdir(struct inode * dir, struct dentry * dentry) | |||
876 | udf_warning(inode->i_sb, "udf_rmdir", | 876 | udf_warning(inode->i_sb, "udf_rmdir", |
877 | "empty directory has nlink != 2 (%d)", | 877 | "empty directory has nlink != 2 (%d)", |
878 | inode->i_nlink); | 878 | inode->i_nlink); |
879 | inode->i_nlink = 0; | 879 | clear_nlink(inode); |
880 | inode->i_size = 0; | 880 | inode->i_size = 0; |
881 | mark_inode_dirty(inode); | 881 | inode_dec_link_count(inode); |
882 | dir->i_nlink --; | ||
883 | inode->i_ctime = dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb); | 882 | inode->i_ctime = dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb); |
884 | mark_inode_dirty(dir); | 883 | mark_inode_dirty(dir); |
885 | 884 | ||
@@ -923,8 +922,7 @@ static int udf_unlink(struct inode * dir, struct dentry * dentry) | |||
923 | goto end_unlink; | 922 | goto end_unlink; |
924 | dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb); | 923 | dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb); |
925 | mark_inode_dirty(dir); | 924 | mark_inode_dirty(dir); |
926 | inode->i_nlink--; | 925 | inode_dec_link_count(inode); |
927 | mark_inode_dirty(inode); | ||
928 | inode->i_ctime = dir->i_ctime; | 926 | inode->i_ctime = dir->i_ctime; |
929 | retval = 0; | 927 | retval = 0; |
930 | 928 | ||
@@ -1101,8 +1099,7 @@ out: | |||
1101 | return err; | 1099 | return err; |
1102 | 1100 | ||
1103 | out_no_entry: | 1101 | out_no_entry: |
1104 | inode->i_nlink--; | 1102 | inode_dec_link_count(inode); |
1105 | mark_inode_dirty(inode); | ||
1106 | iput(inode); | 1103 | iput(inode); |
1107 | goto out; | 1104 | goto out; |
1108 | } | 1105 | } |
@@ -1150,7 +1147,7 @@ static int udf_link(struct dentry * old_dentry, struct inode * dir, | |||
1150 | if (fibh.sbh != fibh.ebh) | 1147 | if (fibh.sbh != fibh.ebh) |
1151 | udf_release_data(fibh.ebh); | 1148 | udf_release_data(fibh.ebh); |
1152 | udf_release_data(fibh.sbh); | 1149 | udf_release_data(fibh.sbh); |
1153 | inode->i_nlink ++; | 1150 | inc_nlink(inode); |
1154 | inode->i_ctime = current_fs_time(inode->i_sb); | 1151 | inode->i_ctime = current_fs_time(inode->i_sb); |
1155 | mark_inode_dirty(inode); | 1152 | mark_inode_dirty(inode); |
1156 | atomic_inc(&inode->i_count); | 1153 | atomic_inc(&inode->i_count); |
@@ -1261,9 +1258,8 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry, | |||
1261 | 1258 | ||
1262 | if (new_inode) | 1259 | if (new_inode) |
1263 | { | 1260 | { |
1264 | new_inode->i_nlink--; | ||
1265 | new_inode->i_ctime = current_fs_time(new_inode->i_sb); | 1261 | new_inode->i_ctime = current_fs_time(new_inode->i_sb); |
1266 | mark_inode_dirty(new_inode); | 1262 | inode_dec_link_count(new_inode); |
1267 | } | 1263 | } |
1268 | old_dir->i_ctime = old_dir->i_mtime = current_fs_time(old_dir->i_sb); | 1264 | old_dir->i_ctime = old_dir->i_mtime = current_fs_time(old_dir->i_sb); |
1269 | mark_inode_dirty(old_dir); | 1265 | mark_inode_dirty(old_dir); |
@@ -1279,16 +1275,14 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry, | |||
1279 | } | 1275 | } |
1280 | else | 1276 | else |
1281 | mark_buffer_dirty_inode(dir_bh, old_inode); | 1277 | mark_buffer_dirty_inode(dir_bh, old_inode); |
1282 | old_dir->i_nlink --; | 1278 | inode_dec_link_count(old_dir); |
1283 | mark_inode_dirty(old_dir); | ||
1284 | if (new_inode) | 1279 | if (new_inode) |
1285 | { | 1280 | { |
1286 | new_inode->i_nlink --; | 1281 | inode_dec_link_count(new_inode); |
1287 | mark_inode_dirty(new_inode); | ||
1288 | } | 1282 | } |
1289 | else | 1283 | else |
1290 | { | 1284 | { |
1291 | new_dir->i_nlink ++; | 1285 | inc_nlink(new_dir); |
1292 | mark_inode_dirty(new_dir); | 1286 | mark_inode_dirty(new_dir); |
1293 | } | 1287 | } |
1294 | } | 1288 | } |
diff --git a/fs/udf/super.c b/fs/udf/super.c index 5dd356cbbda6..1d3b5d2070e5 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -1621,6 +1621,10 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1621 | goto error_out; | 1621 | goto error_out; |
1622 | } | 1622 | } |
1623 | 1623 | ||
1624 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_READ_ONLY) | ||
1625 | printk("UDF-fs: Partition marked readonly; forcing readonly mount\n"); | ||
1626 | sb->s_flags |= MS_RDONLY; | ||
1627 | |||
1624 | if ( udf_find_fileset(sb, &fileset, &rootdir) ) | 1628 | if ( udf_find_fileset(sb, &fileset, &rootdir) ) |
1625 | { | 1629 | { |
1626 | printk("UDF-fs: No fileset found\n"); | 1630 | printk("UDF-fs: No fileset found\n"); |
diff --git a/fs/ufs/file.c b/fs/ufs/file.c index a9c6e5f04fae..1e096323bad4 100644 --- a/fs/ufs/file.c +++ b/fs/ufs/file.c | |||
@@ -53,8 +53,10 @@ static int ufs_sync_file(struct file *file, struct dentry *dentry, int datasync) | |||
53 | 53 | ||
54 | const struct file_operations ufs_file_operations = { | 54 | const struct file_operations ufs_file_operations = { |
55 | .llseek = generic_file_llseek, | 55 | .llseek = generic_file_llseek, |
56 | .read = generic_file_read, | 56 | .read = do_sync_read, |
57 | .write = generic_file_write, | 57 | .aio_read = generic_file_aio_read, |
58 | .write = do_sync_write, | ||
59 | .aio_write = generic_file_aio_write, | ||
58 | .mmap = generic_file_mmap, | 60 | .mmap = generic_file_mmap, |
59 | .open = generic_file_open, | 61 | .open = generic_file_open, |
60 | .fsync = ufs_sync_file, | 62 | .fsync = ufs_sync_file, |
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index d344b411e261..e84c0ecf0730 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c | |||
@@ -308,7 +308,7 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
308 | ufs_set_link(new_dir, new_de, new_page, old_inode); | 308 | ufs_set_link(new_dir, new_de, new_page, old_inode); |
309 | new_inode->i_ctime = CURRENT_TIME_SEC; | 309 | new_inode->i_ctime = CURRENT_TIME_SEC; |
310 | if (dir_de) | 310 | if (dir_de) |
311 | new_inode->i_nlink--; | 311 | drop_nlink(new_inode); |
312 | inode_dec_link_count(new_inode); | 312 | inode_dec_link_count(new_inode); |
313 | } else { | 313 | } else { |
314 | if (dir_de) { | 314 | if (dir_de) { |
diff --git a/fs/utimes.c b/fs/utimes.c new file mode 100644 index 000000000000..1bcd852fc4a9 --- /dev/null +++ b/fs/utimes.c | |||
@@ -0,0 +1,137 @@ | |||
1 | #include <linux/compiler.h> | ||
2 | #include <linux/fs.h> | ||
3 | #include <linux/linkage.h> | ||
4 | #include <linux/namei.h> | ||
5 | #include <linux/utime.h> | ||
6 | #include <asm/uaccess.h> | ||
7 | #include <asm/unistd.h> | ||
8 | |||
9 | #ifdef __ARCH_WANT_SYS_UTIME | ||
10 | |||
11 | /* | ||
12 | * sys_utime() can be implemented in user-level using sys_utimes(). | ||
13 | * Is this for backwards compatibility? If so, why not move it | ||
14 | * into the appropriate arch directory (for those architectures that | ||
15 | * need it). | ||
16 | */ | ||
17 | |||
18 | /* If times==NULL, set access and modification to current time, | ||
19 | * must be owner or have write permission. | ||
20 | * Else, update from *times, must be owner or super user. | ||
21 | */ | ||
22 | asmlinkage long sys_utime(char __user * filename, struct utimbuf __user * times) | ||
23 | { | ||
24 | int error; | ||
25 | struct nameidata nd; | ||
26 | struct inode * inode; | ||
27 | struct iattr newattrs; | ||
28 | |||
29 | error = user_path_walk(filename, &nd); | ||
30 | if (error) | ||
31 | goto out; | ||
32 | inode = nd.dentry->d_inode; | ||
33 | |||
34 | error = -EROFS; | ||
35 | if (IS_RDONLY(inode)) | ||
36 | goto dput_and_out; | ||
37 | |||
38 | /* Don't worry, the checks are done in inode_change_ok() */ | ||
39 | newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; | ||
40 | if (times) { | ||
41 | error = -EPERM; | ||
42 | if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) | ||
43 | goto dput_and_out; | ||
44 | |||
45 | error = get_user(newattrs.ia_atime.tv_sec, ×->actime); | ||
46 | newattrs.ia_atime.tv_nsec = 0; | ||
47 | if (!error) | ||
48 | error = get_user(newattrs.ia_mtime.tv_sec, ×->modtime); | ||
49 | newattrs.ia_mtime.tv_nsec = 0; | ||
50 | if (error) | ||
51 | goto dput_and_out; | ||
52 | |||
53 | newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET; | ||
54 | } else { | ||
55 | error = -EACCES; | ||
56 | if (IS_IMMUTABLE(inode)) | ||
57 | goto dput_and_out; | ||
58 | |||
59 | if (current->fsuid != inode->i_uid && | ||
60 | (error = vfs_permission(&nd, MAY_WRITE)) != 0) | ||
61 | goto dput_and_out; | ||
62 | } | ||
63 | mutex_lock(&inode->i_mutex); | ||
64 | error = notify_change(nd.dentry, &newattrs); | ||
65 | mutex_unlock(&inode->i_mutex); | ||
66 | dput_and_out: | ||
67 | path_release(&nd); | ||
68 | out: | ||
69 | return error; | ||
70 | } | ||
71 | |||
72 | #endif | ||
73 | |||
74 | /* If times==NULL, set access and modification to current time, | ||
75 | * must be owner or have write permission. | ||
76 | * Else, update from *times, must be owner or super user. | ||
77 | */ | ||
78 | long do_utimes(int dfd, char __user *filename, struct timeval *times) | ||
79 | { | ||
80 | int error; | ||
81 | struct nameidata nd; | ||
82 | struct inode * inode; | ||
83 | struct iattr newattrs; | ||
84 | |||
85 | error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd); | ||
86 | |||
87 | if (error) | ||
88 | goto out; | ||
89 | inode = nd.dentry->d_inode; | ||
90 | |||
91 | error = -EROFS; | ||
92 | if (IS_RDONLY(inode)) | ||
93 | goto dput_and_out; | ||
94 | |||
95 | /* Don't worry, the checks are done in inode_change_ok() */ | ||
96 | newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; | ||
97 | if (times) { | ||
98 | error = -EPERM; | ||
99 | if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) | ||
100 | goto dput_and_out; | ||
101 | |||
102 | newattrs.ia_atime.tv_sec = times[0].tv_sec; | ||
103 | newattrs.ia_atime.tv_nsec = times[0].tv_usec * 1000; | ||
104 | newattrs.ia_mtime.tv_sec = times[1].tv_sec; | ||
105 | newattrs.ia_mtime.tv_nsec = times[1].tv_usec * 1000; | ||
106 | newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET; | ||
107 | } else { | ||
108 | error = -EACCES; | ||
109 | if (IS_IMMUTABLE(inode)) | ||
110 | goto dput_and_out; | ||
111 | |||
112 | if (current->fsuid != inode->i_uid && | ||
113 | (error = vfs_permission(&nd, MAY_WRITE)) != 0) | ||
114 | goto dput_and_out; | ||
115 | } | ||
116 | mutex_lock(&inode->i_mutex); | ||
117 | error = notify_change(nd.dentry, &newattrs); | ||
118 | mutex_unlock(&inode->i_mutex); | ||
119 | dput_and_out: | ||
120 | path_release(&nd); | ||
121 | out: | ||
122 | return error; | ||
123 | } | ||
124 | |||
125 | asmlinkage long sys_futimesat(int dfd, char __user *filename, struct timeval __user *utimes) | ||
126 | { | ||
127 | struct timeval times[2]; | ||
128 | |||
129 | if (utimes && copy_from_user(×, utimes, sizeof(times))) | ||
130 | return -EFAULT; | ||
131 | return do_utimes(dfd, filename, utimes ? times : NULL); | ||
132 | } | ||
133 | |||
134 | asmlinkage long sys_utimes(char __user *filename, struct timeval __user *utimes) | ||
135 | { | ||
136 | return sys_futimesat(AT_FDCWD, filename, utimes); | ||
137 | } | ||
diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c index 9a8f48bae956..edb711ff7b05 100644 --- a/fs/vfat/namei.c +++ b/fs/vfat/namei.c | |||
@@ -782,9 +782,9 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry) | |||
782 | err = fat_remove_entries(dir, &sinfo); /* and releases bh */ | 782 | err = fat_remove_entries(dir, &sinfo); /* and releases bh */ |
783 | if (err) | 783 | if (err) |
784 | goto out; | 784 | goto out; |
785 | dir->i_nlink--; | 785 | drop_nlink(dir); |
786 | 786 | ||
787 | inode->i_nlink = 0; | 787 | clear_nlink(inode); |
788 | inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; | 788 | inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; |
789 | fat_detach(inode); | 789 | fat_detach(inode); |
790 | out: | 790 | out: |
@@ -808,7 +808,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry) | |||
808 | err = fat_remove_entries(dir, &sinfo); /* and releases bh */ | 808 | err = fat_remove_entries(dir, &sinfo); /* and releases bh */ |
809 | if (err) | 809 | if (err) |
810 | goto out; | 810 | goto out; |
811 | inode->i_nlink = 0; | 811 | clear_nlink(inode); |
812 | inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; | 812 | inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; |
813 | fat_detach(inode); | 813 | fat_detach(inode); |
814 | out: | 814 | out: |
@@ -837,7 +837,7 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
837 | if (err) | 837 | if (err) |
838 | goto out_free; | 838 | goto out_free; |
839 | dir->i_version++; | 839 | dir->i_version++; |
840 | dir->i_nlink++; | 840 | inc_nlink(dir); |
841 | 841 | ||
842 | inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); | 842 | inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); |
843 | brelse(sinfo.bh); | 843 | brelse(sinfo.bh); |
@@ -930,9 +930,9 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
930 | if (err) | 930 | if (err) |
931 | goto error_dotdot; | 931 | goto error_dotdot; |
932 | } | 932 | } |
933 | old_dir->i_nlink--; | 933 | drop_nlink(old_dir); |
934 | if (!new_inode) | 934 | if (!new_inode) |
935 | new_dir->i_nlink++; | 935 | inc_nlink(new_dir); |
936 | } | 936 | } |
937 | 937 | ||
938 | err = fat_remove_entries(old_dir, &old_sinfo); /* and releases bh */ | 938 | err = fat_remove_entries(old_dir, &old_sinfo); /* and releases bh */ |
@@ -947,10 +947,9 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
947 | mark_inode_dirty(old_dir); | 947 | mark_inode_dirty(old_dir); |
948 | 948 | ||
949 | if (new_inode) { | 949 | if (new_inode) { |
950 | drop_nlink(new_inode); | ||
950 | if (is_dir) | 951 | if (is_dir) |
951 | new_inode->i_nlink -= 2; | 952 | drop_nlink(new_inode); |
952 | else | ||
953 | new_inode->i_nlink--; | ||
954 | new_inode->i_ctime = ts; | 953 | new_inode->i_ctime = ts; |
955 | } | 954 | } |
956 | out: | 955 | out: |
diff --git a/fs/xfs/Kconfig b/fs/xfs/Kconfig index 26b364c9d62c..35115bca036e 100644 --- a/fs/xfs/Kconfig +++ b/fs/xfs/Kconfig | |||
@@ -1,5 +1,6 @@ | |||
1 | config XFS_FS | 1 | config XFS_FS |
2 | tristate "XFS filesystem support" | 2 | tristate "XFS filesystem support" |
3 | depends on BLOCK | ||
3 | help | 4 | help |
4 | XFS is a high performance journaling filesystem which originated | 5 | XFS is a high performance journaling filesystem which originated |
5 | on the SGI IRIX platform. It is completely multi-threaded, can | 6 | on the SGI IRIX platform. It is completely multi-threaded, can |
diff --git a/fs/xfs/Makefile-linux-2.6 b/fs/xfs/Makefile-linux-2.6 index 9e7f85986d0d..291948d5085a 100644 --- a/fs/xfs/Makefile-linux-2.6 +++ b/fs/xfs/Makefile-linux-2.6 | |||
@@ -30,7 +30,6 @@ ifeq ($(CONFIG_XFS_TRACE),y) | |||
30 | EXTRA_CFLAGS += -DXFS_BLI_TRACE | 30 | EXTRA_CFLAGS += -DXFS_BLI_TRACE |
31 | EXTRA_CFLAGS += -DXFS_BMAP_TRACE | 31 | EXTRA_CFLAGS += -DXFS_BMAP_TRACE |
32 | EXTRA_CFLAGS += -DXFS_BMBT_TRACE | 32 | EXTRA_CFLAGS += -DXFS_BMBT_TRACE |
33 | EXTRA_CFLAGS += -DXFS_DIR_TRACE | ||
34 | EXTRA_CFLAGS += -DXFS_DIR2_TRACE | 33 | EXTRA_CFLAGS += -DXFS_DIR2_TRACE |
35 | EXTRA_CFLAGS += -DXFS_DQUOT_TRACE | 34 | EXTRA_CFLAGS += -DXFS_DQUOT_TRACE |
36 | EXTRA_CFLAGS += -DXFS_ILOCK_TRACE | 35 | EXTRA_CFLAGS += -DXFS_ILOCK_TRACE |
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c index aba7fcf881a2..d59737589815 100644 --- a/fs/xfs/linux-2.6/kmem.c +++ b/fs/xfs/linux-2.6/kmem.c | |||
@@ -34,6 +34,14 @@ kmem_alloc(size_t size, unsigned int __nocast flags) | |||
34 | gfp_t lflags = kmem_flags_convert(flags); | 34 | gfp_t lflags = kmem_flags_convert(flags); |
35 | void *ptr; | 35 | void *ptr; |
36 | 36 | ||
37 | #ifdef DEBUG | ||
38 | if (unlikely(!(flags & KM_LARGE) && (size > PAGE_SIZE))) { | ||
39 | printk(KERN_WARNING "Large %s attempt, size=%ld\n", | ||
40 | __FUNCTION__, (long)size); | ||
41 | dump_stack(); | ||
42 | } | ||
43 | #endif | ||
44 | |||
37 | do { | 45 | do { |
38 | if (size < MAX_SLAB_SIZE || retries > MAX_VMALLOCS) | 46 | if (size < MAX_SLAB_SIZE || retries > MAX_VMALLOCS) |
39 | ptr = kmalloc(size, lflags); | 47 | ptr = kmalloc(size, lflags); |
@@ -60,6 +68,27 @@ kmem_zalloc(size_t size, unsigned int __nocast flags) | |||
60 | return ptr; | 68 | return ptr; |
61 | } | 69 | } |
62 | 70 | ||
71 | void * | ||
72 | kmem_zalloc_greedy(size_t *size, size_t minsize, size_t maxsize, | ||
73 | unsigned int __nocast flags) | ||
74 | { | ||
75 | void *ptr; | ||
76 | size_t kmsize = maxsize; | ||
77 | unsigned int kmflags = (flags & ~KM_SLEEP) | KM_NOSLEEP; | ||
78 | |||
79 | while (!(ptr = kmem_zalloc(kmsize, kmflags))) { | ||
80 | if ((kmsize <= minsize) && (flags & KM_NOSLEEP)) | ||
81 | break; | ||
82 | if ((kmsize >>= 1) <= minsize) { | ||
83 | kmsize = minsize; | ||
84 | kmflags = flags; | ||
85 | } | ||
86 | } | ||
87 | if (ptr) | ||
88 | *size = kmsize; | ||
89 | return ptr; | ||
90 | } | ||
91 | |||
63 | void | 92 | void |
64 | kmem_free(void *ptr, size_t size) | 93 | kmem_free(void *ptr, size_t size) |
65 | { | 94 | { |
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h index 0e8293c5a32f..9ebabdf7829c 100644 --- a/fs/xfs/linux-2.6/kmem.h +++ b/fs/xfs/linux-2.6/kmem.h | |||
@@ -30,6 +30,7 @@ | |||
30 | #define KM_NOSLEEP 0x0002u | 30 | #define KM_NOSLEEP 0x0002u |
31 | #define KM_NOFS 0x0004u | 31 | #define KM_NOFS 0x0004u |
32 | #define KM_MAYFAIL 0x0008u | 32 | #define KM_MAYFAIL 0x0008u |
33 | #define KM_LARGE 0x0010u | ||
33 | 34 | ||
34 | /* | 35 | /* |
35 | * We use a special process flag to avoid recursive callbacks into | 36 | * We use a special process flag to avoid recursive callbacks into |
@@ -41,7 +42,7 @@ kmem_flags_convert(unsigned int __nocast flags) | |||
41 | { | 42 | { |
42 | gfp_t lflags; | 43 | gfp_t lflags; |
43 | 44 | ||
44 | BUG_ON(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL)); | 45 | BUG_ON(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL|KM_LARGE)); |
45 | 46 | ||
46 | if (flags & KM_NOSLEEP) { | 47 | if (flags & KM_NOSLEEP) { |
47 | lflags = GFP_ATOMIC | __GFP_NOWARN; | 48 | lflags = GFP_ATOMIC | __GFP_NOWARN; |
@@ -54,8 +55,9 @@ kmem_flags_convert(unsigned int __nocast flags) | |||
54 | } | 55 | } |
55 | 56 | ||
56 | extern void *kmem_alloc(size_t, unsigned int __nocast); | 57 | extern void *kmem_alloc(size_t, unsigned int __nocast); |
57 | extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast); | ||
58 | extern void *kmem_zalloc(size_t, unsigned int __nocast); | 58 | extern void *kmem_zalloc(size_t, unsigned int __nocast); |
59 | extern void *kmem_zalloc_greedy(size_t *, size_t, size_t, unsigned int __nocast); | ||
60 | extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast); | ||
59 | extern void kmem_free(void *, size_t); | 61 | extern void kmem_free(void *, size_t); |
60 | 62 | ||
61 | /* | 63 | /* |
diff --git a/fs/xfs/linux-2.6/sema.h b/fs/xfs/linux-2.6/sema.h index b25090094cca..2009e6d922ce 100644 --- a/fs/xfs/linux-2.6/sema.h +++ b/fs/xfs/linux-2.6/sema.h | |||
@@ -29,8 +29,6 @@ | |||
29 | 29 | ||
30 | typedef struct semaphore sema_t; | 30 | typedef struct semaphore sema_t; |
31 | 31 | ||
32 | #define init_sema(sp, val, c, d) sema_init(sp, val) | ||
33 | #define initsema(sp, val) sema_init(sp, val) | ||
34 | #define initnsema(sp, val, name) sema_init(sp, val) | 32 | #define initnsema(sp, val, name) sema_init(sp, val) |
35 | #define psema(sp, b) down(sp) | 33 | #define psema(sp, b) down(sp) |
36 | #define vsema(sp) up(sp) | 34 | #define vsema(sp) up(sp) |
diff --git a/fs/xfs/linux-2.6/sv.h b/fs/xfs/linux-2.6/sv.h index 9a8ad481b008..351a8f454bd1 100644 --- a/fs/xfs/linux-2.6/sv.h +++ b/fs/xfs/linux-2.6/sv.h | |||
@@ -53,8 +53,6 @@ static inline void _sv_wait(sv_t *sv, spinlock_t *lock, int state, | |||
53 | remove_wait_queue(&sv->waiters, &wait); | 53 | remove_wait_queue(&sv->waiters, &wait); |
54 | } | 54 | } |
55 | 55 | ||
56 | #define init_sv(sv,type,name,flag) \ | ||
57 | init_waitqueue_head(&(sv)->waiters) | ||
58 | #define sv_init(sv,flag,name) \ | 56 | #define sv_init(sv,flag,name) \ |
59 | init_waitqueue_head(&(sv)->waiters) | 57 | init_waitqueue_head(&(sv)->waiters) |
60 | #define sv_destroy(sv) \ | 58 | #define sv_destroy(sv) \ |
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c index 34dcb43a7837..09360cf1e1f2 100644 --- a/fs/xfs/linux-2.6/xfs_aops.c +++ b/fs/xfs/linux-2.6/xfs_aops.c | |||
@@ -71,7 +71,7 @@ xfs_page_trace( | |||
71 | int tag, | 71 | int tag, |
72 | struct inode *inode, | 72 | struct inode *inode, |
73 | struct page *page, | 73 | struct page *page, |
74 | int mask) | 74 | unsigned long pgoff) |
75 | { | 75 | { |
76 | xfs_inode_t *ip; | 76 | xfs_inode_t *ip; |
77 | bhv_vnode_t *vp = vn_from_inode(inode); | 77 | bhv_vnode_t *vp = vn_from_inode(inode); |
@@ -91,7 +91,7 @@ xfs_page_trace( | |||
91 | (void *)ip, | 91 | (void *)ip, |
92 | (void *)inode, | 92 | (void *)inode, |
93 | (void *)page, | 93 | (void *)page, |
94 | (void *)((unsigned long)mask), | 94 | (void *)pgoff, |
95 | (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)), | 95 | (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)), |
96 | (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)), | 96 | (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)), |
97 | (void *)((unsigned long)((isize >> 32) & 0xffffffff)), | 97 | (void *)((unsigned long)((isize >> 32) & 0xffffffff)), |
@@ -105,7 +105,7 @@ xfs_page_trace( | |||
105 | (void *)NULL); | 105 | (void *)NULL); |
106 | } | 106 | } |
107 | #else | 107 | #else |
108 | #define xfs_page_trace(tag, inode, page, mask) | 108 | #define xfs_page_trace(tag, inode, page, pgoff) |
109 | #endif | 109 | #endif |
110 | 110 | ||
111 | /* | 111 | /* |
@@ -1197,7 +1197,7 @@ xfs_vm_releasepage( | |||
1197 | .nr_to_write = 1, | 1197 | .nr_to_write = 1, |
1198 | }; | 1198 | }; |
1199 | 1199 | ||
1200 | xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, gfp_mask); | 1200 | xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, 0); |
1201 | 1201 | ||
1202 | if (!page_has_buffers(page)) | 1202 | if (!page_has_buffers(page)) |
1203 | return 0; | 1203 | return 0; |
@@ -1356,7 +1356,6 @@ xfs_end_io_direct( | |||
1356 | ioend->io_size = size; | 1356 | ioend->io_size = size; |
1357 | xfs_finish_ioend(ioend); | 1357 | xfs_finish_ioend(ioend); |
1358 | } else { | 1358 | } else { |
1359 | ASSERT(size >= 0); | ||
1360 | xfs_destroy_ioend(ioend); | 1359 | xfs_destroy_ioend(ioend); |
1361 | } | 1360 | } |
1362 | 1361 | ||
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index 2af528dcfb04..9bbadafdcb00 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. | 2 | * Copyright (c) 2000-2006 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | 3 | * All Rights Reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
@@ -318,8 +318,12 @@ xfs_buf_free( | |||
318 | if ((bp->b_flags & XBF_MAPPED) && (bp->b_page_count > 1)) | 318 | if ((bp->b_flags & XBF_MAPPED) && (bp->b_page_count > 1)) |
319 | free_address(bp->b_addr - bp->b_offset); | 319 | free_address(bp->b_addr - bp->b_offset); |
320 | 320 | ||
321 | for (i = 0; i < bp->b_page_count; i++) | 321 | for (i = 0; i < bp->b_page_count; i++) { |
322 | page_cache_release(bp->b_pages[i]); | 322 | struct page *page = bp->b_pages[i]; |
323 | |||
324 | ASSERT(!PagePrivate(page)); | ||
325 | page_cache_release(page); | ||
326 | } | ||
323 | _xfs_buf_free_pages(bp); | 327 | _xfs_buf_free_pages(bp); |
324 | } else if (bp->b_flags & _XBF_KMEM_ALLOC) { | 328 | } else if (bp->b_flags & _XBF_KMEM_ALLOC) { |
325 | /* | 329 | /* |
@@ -400,6 +404,7 @@ _xfs_buf_lookup_pages( | |||
400 | nbytes = min_t(size_t, size, PAGE_CACHE_SIZE - offset); | 404 | nbytes = min_t(size_t, size, PAGE_CACHE_SIZE - offset); |
401 | size -= nbytes; | 405 | size -= nbytes; |
402 | 406 | ||
407 | ASSERT(!PagePrivate(page)); | ||
403 | if (!PageUptodate(page)) { | 408 | if (!PageUptodate(page)) { |
404 | page_count--; | 409 | page_count--; |
405 | if (blocksize >= PAGE_CACHE_SIZE) { | 410 | if (blocksize >= PAGE_CACHE_SIZE) { |
@@ -768,7 +773,7 @@ xfs_buf_get_noaddr( | |||
768 | _xfs_buf_initialize(bp, target, 0, len, 0); | 773 | _xfs_buf_initialize(bp, target, 0, len, 0); |
769 | 774 | ||
770 | try_again: | 775 | try_again: |
771 | data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL); | 776 | data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL | KM_LARGE); |
772 | if (unlikely(data == NULL)) | 777 | if (unlikely(data == NULL)) |
773 | goto fail_free_buf; | 778 | goto fail_free_buf; |
774 | 779 | ||
@@ -1117,10 +1122,10 @@ xfs_buf_bio_end_io( | |||
1117 | do { | 1122 | do { |
1118 | struct page *page = bvec->bv_page; | 1123 | struct page *page = bvec->bv_page; |
1119 | 1124 | ||
1125 | ASSERT(!PagePrivate(page)); | ||
1120 | if (unlikely(bp->b_error)) { | 1126 | if (unlikely(bp->b_error)) { |
1121 | if (bp->b_flags & XBF_READ) | 1127 | if (bp->b_flags & XBF_READ) |
1122 | ClearPageUptodate(page); | 1128 | ClearPageUptodate(page); |
1123 | SetPageError(page); | ||
1124 | } else if (blocksize >= PAGE_CACHE_SIZE) { | 1129 | } else if (blocksize >= PAGE_CACHE_SIZE) { |
1125 | SetPageUptodate(page); | 1130 | SetPageUptodate(page); |
1126 | } else if (!PagePrivate(page) && | 1131 | } else if (!PagePrivate(page) && |
@@ -1156,16 +1161,16 @@ _xfs_buf_ioapply( | |||
1156 | total_nr_pages = bp->b_page_count; | 1161 | total_nr_pages = bp->b_page_count; |
1157 | map_i = 0; | 1162 | map_i = 0; |
1158 | 1163 | ||
1159 | if (bp->b_flags & _XBF_RUN_QUEUES) { | ||
1160 | bp->b_flags &= ~_XBF_RUN_QUEUES; | ||
1161 | rw = (bp->b_flags & XBF_READ) ? READ_SYNC : WRITE_SYNC; | ||
1162 | } else { | ||
1163 | rw = (bp->b_flags & XBF_READ) ? READ : WRITE; | ||
1164 | } | ||
1165 | |||
1166 | if (bp->b_flags & XBF_ORDERED) { | 1164 | if (bp->b_flags & XBF_ORDERED) { |
1167 | ASSERT(!(bp->b_flags & XBF_READ)); | 1165 | ASSERT(!(bp->b_flags & XBF_READ)); |
1168 | rw = WRITE_BARRIER; | 1166 | rw = WRITE_BARRIER; |
1167 | } else if (bp->b_flags & _XBF_RUN_QUEUES) { | ||
1168 | ASSERT(!(bp->b_flags & XBF_READ_AHEAD)); | ||
1169 | bp->b_flags &= ~_XBF_RUN_QUEUES; | ||
1170 | rw = (bp->b_flags & XBF_WRITE) ? WRITE_SYNC : READ_SYNC; | ||
1171 | } else { | ||
1172 | rw = (bp->b_flags & XBF_WRITE) ? WRITE : | ||
1173 | (bp->b_flags & XBF_READ_AHEAD) ? READA : READ; | ||
1169 | } | 1174 | } |
1170 | 1175 | ||
1171 | /* Special code path for reading a sub page size buffer in -- | 1176 | /* Special code path for reading a sub page size buffer in -- |
@@ -1681,6 +1686,7 @@ xfsbufd( | |||
1681 | xfs_buf_t *bp, *n; | 1686 | xfs_buf_t *bp, *n; |
1682 | struct list_head *dwq = &target->bt_delwrite_queue; | 1687 | struct list_head *dwq = &target->bt_delwrite_queue; |
1683 | spinlock_t *dwlk = &target->bt_delwrite_lock; | 1688 | spinlock_t *dwlk = &target->bt_delwrite_lock; |
1689 | int count; | ||
1684 | 1690 | ||
1685 | current->flags |= PF_MEMALLOC; | 1691 | current->flags |= PF_MEMALLOC; |
1686 | 1692 | ||
@@ -1696,6 +1702,7 @@ xfsbufd( | |||
1696 | schedule_timeout_interruptible( | 1702 | schedule_timeout_interruptible( |
1697 | xfs_buf_timer_centisecs * msecs_to_jiffies(10)); | 1703 | xfs_buf_timer_centisecs * msecs_to_jiffies(10)); |
1698 | 1704 | ||
1705 | count = 0; | ||
1699 | age = xfs_buf_age_centisecs * msecs_to_jiffies(10); | 1706 | age = xfs_buf_age_centisecs * msecs_to_jiffies(10); |
1700 | spin_lock(dwlk); | 1707 | spin_lock(dwlk); |
1701 | list_for_each_entry_safe(bp, n, dwq, b_list) { | 1708 | list_for_each_entry_safe(bp, n, dwq, b_list) { |
@@ -1711,9 +1718,11 @@ xfsbufd( | |||
1711 | break; | 1718 | break; |
1712 | } | 1719 | } |
1713 | 1720 | ||
1714 | bp->b_flags &= ~(XBF_DELWRI|_XBF_DELWRI_Q); | 1721 | bp->b_flags &= ~(XBF_DELWRI|_XBF_DELWRI_Q| |
1722 | _XBF_RUN_QUEUES); | ||
1715 | bp->b_flags |= XBF_WRITE; | 1723 | bp->b_flags |= XBF_WRITE; |
1716 | list_move(&bp->b_list, &tmp); | 1724 | list_move_tail(&bp->b_list, &tmp); |
1725 | count++; | ||
1717 | } | 1726 | } |
1718 | } | 1727 | } |
1719 | spin_unlock(dwlk); | 1728 | spin_unlock(dwlk); |
@@ -1724,12 +1733,12 @@ xfsbufd( | |||
1724 | 1733 | ||
1725 | list_del_init(&bp->b_list); | 1734 | list_del_init(&bp->b_list); |
1726 | xfs_buf_iostrategy(bp); | 1735 | xfs_buf_iostrategy(bp); |
1727 | |||
1728 | blk_run_address_space(target->bt_mapping); | ||
1729 | } | 1736 | } |
1730 | 1737 | ||
1731 | if (as_list_len > 0) | 1738 | if (as_list_len > 0) |
1732 | purge_addresses(); | 1739 | purge_addresses(); |
1740 | if (count) | ||
1741 | blk_run_address_space(target->bt_mapping); | ||
1733 | 1742 | ||
1734 | clear_bit(XBT_FORCE_FLUSH, &target->bt_flags); | 1743 | clear_bit(XBT_FORCE_FLUSH, &target->bt_flags); |
1735 | } while (!kthread_should_stop()); | 1744 | } while (!kthread_should_stop()); |
@@ -1767,7 +1776,7 @@ xfs_flush_buftarg( | |||
1767 | continue; | 1776 | continue; |
1768 | } | 1777 | } |
1769 | 1778 | ||
1770 | list_move(&bp->b_list, &tmp); | 1779 | list_move_tail(&bp->b_list, &tmp); |
1771 | } | 1780 | } |
1772 | spin_unlock(dwlk); | 1781 | spin_unlock(dwlk); |
1773 | 1782 | ||
@@ -1776,7 +1785,7 @@ xfs_flush_buftarg( | |||
1776 | */ | 1785 | */ |
1777 | list_for_each_entry_safe(bp, n, &tmp, b_list) { | 1786 | list_for_each_entry_safe(bp, n, &tmp, b_list) { |
1778 | xfs_buf_lock(bp); | 1787 | xfs_buf_lock(bp); |
1779 | bp->b_flags &= ~(XBF_DELWRI|_XBF_DELWRI_Q); | 1788 | bp->b_flags &= ~(XBF_DELWRI|_XBF_DELWRI_Q|_XBF_RUN_QUEUES); |
1780 | bp->b_flags |= XBF_WRITE; | 1789 | bp->b_flags |= XBF_WRITE; |
1781 | if (wait) | 1790 | if (wait) |
1782 | bp->b_flags &= ~XBF_ASYNC; | 1791 | bp->b_flags &= ~XBF_ASYNC; |
@@ -1786,6 +1795,9 @@ xfs_flush_buftarg( | |||
1786 | xfs_buf_iostrategy(bp); | 1795 | xfs_buf_iostrategy(bp); |
1787 | } | 1796 | } |
1788 | 1797 | ||
1798 | if (wait) | ||
1799 | blk_run_address_space(target->bt_mapping); | ||
1800 | |||
1789 | /* | 1801 | /* |
1790 | * Remaining list items must be flushed before returning | 1802 | * Remaining list items must be flushed before returning |
1791 | */ | 1803 | */ |
@@ -1797,9 +1809,6 @@ xfs_flush_buftarg( | |||
1797 | xfs_buf_relse(bp); | 1809 | xfs_buf_relse(bp); |
1798 | } | 1810 | } |
1799 | 1811 | ||
1800 | if (wait) | ||
1801 | blk_run_address_space(target->bt_mapping); | ||
1802 | |||
1803 | return pincount; | 1812 | return pincount; |
1804 | } | 1813 | } |
1805 | 1814 | ||
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h index 7858703ed84c..9dd235cb0107 100644 --- a/fs/xfs/linux-2.6/xfs_buf.h +++ b/fs/xfs/linux-2.6/xfs_buf.h | |||
@@ -298,11 +298,6 @@ extern void xfs_buf_trace(xfs_buf_t *, char *, void *, void *); | |||
298 | #define XFS_BUF_UNWRITE(bp) ((bp)->b_flags &= ~XBF_WRITE) | 298 | #define XFS_BUF_UNWRITE(bp) ((bp)->b_flags &= ~XBF_WRITE) |
299 | #define XFS_BUF_ISWRITE(bp) ((bp)->b_flags & XBF_WRITE) | 299 | #define XFS_BUF_ISWRITE(bp) ((bp)->b_flags & XBF_WRITE) |
300 | 300 | ||
301 | #define XFS_BUF_ISUNINITIAL(bp) (0) | ||
302 | #define XFS_BUF_UNUNINITIAL(bp) (0) | ||
303 | |||
304 | #define XFS_BUF_BP_ISMAPPED(bp) (1) | ||
305 | |||
306 | #define XFS_BUF_IODONE_FUNC(bp) ((bp)->b_iodone) | 301 | #define XFS_BUF_IODONE_FUNC(bp) ((bp)->b_iodone) |
307 | #define XFS_BUF_SET_IODONE_FUNC(bp, func) ((bp)->b_iodone = (func)) | 302 | #define XFS_BUF_SET_IODONE_FUNC(bp, func) ((bp)->b_iodone = (func)) |
308 | #define XFS_BUF_CLR_IODONE_FUNC(bp) ((bp)->b_iodone = NULL) | 303 | #define XFS_BUF_CLR_IODONE_FUNC(bp) ((bp)->b_iodone = NULL) |
@@ -393,8 +388,6 @@ static inline int XFS_bwrite(xfs_buf_t *bp) | |||
393 | return error; | 388 | return error; |
394 | } | 389 | } |
395 | 390 | ||
396 | #define XFS_bdwrite(bp) xfs_buf_iostart(bp, XBF_DELWRI | XBF_ASYNC) | ||
397 | |||
398 | static inline int xfs_bdwrite(void *mp, xfs_buf_t *bp) | 391 | static inline int xfs_bdwrite(void *mp, xfs_buf_t *bp) |
399 | { | 392 | { |
400 | bp->b_strat = xfs_bdstrat_cb; | 393 | bp->b_strat = xfs_bdstrat_cb; |
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c index 41cfcba7ce49..d93d8dd1958d 100644 --- a/fs/xfs/linux-2.6/xfs_file.c +++ b/fs/xfs/linux-2.6/xfs_file.c | |||
@@ -49,50 +49,49 @@ static struct vm_operations_struct xfs_dmapi_file_vm_ops; | |||
49 | STATIC inline ssize_t | 49 | STATIC inline ssize_t |
50 | __xfs_file_read( | 50 | __xfs_file_read( |
51 | struct kiocb *iocb, | 51 | struct kiocb *iocb, |
52 | char __user *buf, | 52 | const struct iovec *iov, |
53 | unsigned long nr_segs, | ||
53 | int ioflags, | 54 | int ioflags, |
54 | size_t count, | ||
55 | loff_t pos) | 55 | loff_t pos) |
56 | { | 56 | { |
57 | struct iovec iov = {buf, count}; | ||
58 | struct file *file = iocb->ki_filp; | 57 | struct file *file = iocb->ki_filp; |
59 | bhv_vnode_t *vp = vn_from_inode(file->f_dentry->d_inode); | 58 | bhv_vnode_t *vp = vn_from_inode(file->f_dentry->d_inode); |
60 | 59 | ||
61 | BUG_ON(iocb->ki_pos != pos); | 60 | BUG_ON(iocb->ki_pos != pos); |
62 | if (unlikely(file->f_flags & O_DIRECT)) | 61 | if (unlikely(file->f_flags & O_DIRECT)) |
63 | ioflags |= IO_ISDIRECT; | 62 | ioflags |= IO_ISDIRECT; |
64 | return bhv_vop_read(vp, iocb, &iov, 1, &iocb->ki_pos, ioflags, NULL); | 63 | return bhv_vop_read(vp, iocb, iov, nr_segs, &iocb->ki_pos, |
64 | ioflags, NULL); | ||
65 | } | 65 | } |
66 | 66 | ||
67 | STATIC ssize_t | 67 | STATIC ssize_t |
68 | xfs_file_aio_read( | 68 | xfs_file_aio_read( |
69 | struct kiocb *iocb, | 69 | struct kiocb *iocb, |
70 | char __user *buf, | 70 | const struct iovec *iov, |
71 | size_t count, | 71 | unsigned long nr_segs, |
72 | loff_t pos) | 72 | loff_t pos) |
73 | { | 73 | { |
74 | return __xfs_file_read(iocb, buf, IO_ISAIO, count, pos); | 74 | return __xfs_file_read(iocb, iov, nr_segs, IO_ISAIO, pos); |
75 | } | 75 | } |
76 | 76 | ||
77 | STATIC ssize_t | 77 | STATIC ssize_t |
78 | xfs_file_aio_read_invis( | 78 | xfs_file_aio_read_invis( |
79 | struct kiocb *iocb, | 79 | struct kiocb *iocb, |
80 | char __user *buf, | 80 | const struct iovec *iov, |
81 | size_t count, | 81 | unsigned long nr_segs, |
82 | loff_t pos) | 82 | loff_t pos) |
83 | { | 83 | { |
84 | return __xfs_file_read(iocb, buf, IO_ISAIO|IO_INVIS, count, pos); | 84 | return __xfs_file_read(iocb, iov, nr_segs, IO_ISAIO|IO_INVIS, pos); |
85 | } | 85 | } |
86 | 86 | ||
87 | STATIC inline ssize_t | 87 | STATIC inline ssize_t |
88 | __xfs_file_write( | 88 | __xfs_file_write( |
89 | struct kiocb *iocb, | 89 | struct kiocb *iocb, |
90 | const char __user *buf, | 90 | const struct iovec *iov, |
91 | int ioflags, | 91 | unsigned long nr_segs, |
92 | size_t count, | 92 | int ioflags, |
93 | loff_t pos) | 93 | loff_t pos) |
94 | { | 94 | { |
95 | struct iovec iov = {(void __user *)buf, count}; | ||
96 | struct file *file = iocb->ki_filp; | 95 | struct file *file = iocb->ki_filp; |
97 | struct inode *inode = file->f_mapping->host; | 96 | struct inode *inode = file->f_mapping->host; |
98 | bhv_vnode_t *vp = vn_from_inode(inode); | 97 | bhv_vnode_t *vp = vn_from_inode(inode); |
@@ -100,117 +99,28 @@ __xfs_file_write( | |||
100 | BUG_ON(iocb->ki_pos != pos); | 99 | BUG_ON(iocb->ki_pos != pos); |
101 | if (unlikely(file->f_flags & O_DIRECT)) | 100 | if (unlikely(file->f_flags & O_DIRECT)) |
102 | ioflags |= IO_ISDIRECT; | 101 | ioflags |= IO_ISDIRECT; |
103 | return bhv_vop_write(vp, iocb, &iov, 1, &iocb->ki_pos, ioflags, NULL); | 102 | return bhv_vop_write(vp, iocb, iov, nr_segs, &iocb->ki_pos, |
103 | ioflags, NULL); | ||
104 | } | 104 | } |
105 | 105 | ||
106 | STATIC ssize_t | 106 | STATIC ssize_t |
107 | xfs_file_aio_write( | 107 | xfs_file_aio_write( |
108 | struct kiocb *iocb, | 108 | struct kiocb *iocb, |
109 | const char __user *buf, | 109 | const struct iovec *iov, |
110 | size_t count, | 110 | unsigned long nr_segs, |
111 | loff_t pos) | 111 | loff_t pos) |
112 | { | 112 | { |
113 | return __xfs_file_write(iocb, buf, IO_ISAIO, count, pos); | 113 | return __xfs_file_write(iocb, iov, nr_segs, IO_ISAIO, pos); |
114 | } | 114 | } |
115 | 115 | ||
116 | STATIC ssize_t | 116 | STATIC ssize_t |
117 | xfs_file_aio_write_invis( | 117 | xfs_file_aio_write_invis( |
118 | struct kiocb *iocb, | 118 | struct kiocb *iocb, |
119 | const char __user *buf, | 119 | const struct iovec *iov, |
120 | size_t count, | ||
121 | loff_t pos) | ||
122 | { | ||
123 | return __xfs_file_write(iocb, buf, IO_ISAIO|IO_INVIS, count, pos); | ||
124 | } | ||
125 | |||
126 | STATIC inline ssize_t | ||
127 | __xfs_file_readv( | ||
128 | struct file *file, | ||
129 | const struct iovec *iov, | ||
130 | int ioflags, | ||
131 | unsigned long nr_segs, | ||
132 | loff_t *ppos) | ||
133 | { | ||
134 | struct inode *inode = file->f_mapping->host; | ||
135 | bhv_vnode_t *vp = vn_from_inode(inode); | ||
136 | struct kiocb kiocb; | ||
137 | ssize_t rval; | ||
138 | |||
139 | init_sync_kiocb(&kiocb, file); | ||
140 | kiocb.ki_pos = *ppos; | ||
141 | |||
142 | if (unlikely(file->f_flags & O_DIRECT)) | ||
143 | ioflags |= IO_ISDIRECT; | ||
144 | rval = bhv_vop_read(vp, &kiocb, iov, nr_segs, | ||
145 | &kiocb.ki_pos, ioflags, NULL); | ||
146 | |||
147 | *ppos = kiocb.ki_pos; | ||
148 | return rval; | ||
149 | } | ||
150 | |||
151 | STATIC ssize_t | ||
152 | xfs_file_readv( | ||
153 | struct file *file, | ||
154 | const struct iovec *iov, | ||
155 | unsigned long nr_segs, | ||
156 | loff_t *ppos) | ||
157 | { | ||
158 | return __xfs_file_readv(file, iov, 0, nr_segs, ppos); | ||
159 | } | ||
160 | |||
161 | STATIC ssize_t | ||
162 | xfs_file_readv_invis( | ||
163 | struct file *file, | ||
164 | const struct iovec *iov, | ||
165 | unsigned long nr_segs, | ||
166 | loff_t *ppos) | ||
167 | { | ||
168 | return __xfs_file_readv(file, iov, IO_INVIS, nr_segs, ppos); | ||
169 | } | ||
170 | |||
171 | STATIC inline ssize_t | ||
172 | __xfs_file_writev( | ||
173 | struct file *file, | ||
174 | const struct iovec *iov, | ||
175 | int ioflags, | ||
176 | unsigned long nr_segs, | ||
177 | loff_t *ppos) | ||
178 | { | ||
179 | struct inode *inode = file->f_mapping->host; | ||
180 | bhv_vnode_t *vp = vn_from_inode(inode); | ||
181 | struct kiocb kiocb; | ||
182 | ssize_t rval; | ||
183 | |||
184 | init_sync_kiocb(&kiocb, file); | ||
185 | kiocb.ki_pos = *ppos; | ||
186 | if (unlikely(file->f_flags & O_DIRECT)) | ||
187 | ioflags |= IO_ISDIRECT; | ||
188 | |||
189 | rval = bhv_vop_write(vp, &kiocb, iov, nr_segs, | ||
190 | &kiocb.ki_pos, ioflags, NULL); | ||
191 | |||
192 | *ppos = kiocb.ki_pos; | ||
193 | return rval; | ||
194 | } | ||
195 | |||
196 | STATIC ssize_t | ||
197 | xfs_file_writev( | ||
198 | struct file *file, | ||
199 | const struct iovec *iov, | ||
200 | unsigned long nr_segs, | 120 | unsigned long nr_segs, |
201 | loff_t *ppos) | 121 | loff_t pos) |
202 | { | ||
203 | return __xfs_file_writev(file, iov, 0, nr_segs, ppos); | ||
204 | } | ||
205 | |||
206 | STATIC ssize_t | ||
207 | xfs_file_writev_invis( | ||
208 | struct file *file, | ||
209 | const struct iovec *iov, | ||
210 | unsigned long nr_segs, | ||
211 | loff_t *ppos) | ||
212 | { | 122 | { |
213 | return __xfs_file_writev(file, iov, IO_INVIS, nr_segs, ppos); | 123 | return __xfs_file_write(iocb, iov, nr_segs, IO_ISAIO|IO_INVIS, pos); |
214 | } | 124 | } |
215 | 125 | ||
216 | STATIC ssize_t | 126 | STATIC ssize_t |
@@ -540,8 +450,6 @@ const struct file_operations xfs_file_operations = { | |||
540 | .llseek = generic_file_llseek, | 450 | .llseek = generic_file_llseek, |
541 | .read = do_sync_read, | 451 | .read = do_sync_read, |
542 | .write = do_sync_write, | 452 | .write = do_sync_write, |
543 | .readv = xfs_file_readv, | ||
544 | .writev = xfs_file_writev, | ||
545 | .aio_read = xfs_file_aio_read, | 453 | .aio_read = xfs_file_aio_read, |
546 | .aio_write = xfs_file_aio_write, | 454 | .aio_write = xfs_file_aio_write, |
547 | .sendfile = xfs_file_sendfile, | 455 | .sendfile = xfs_file_sendfile, |
@@ -565,8 +473,6 @@ const struct file_operations xfs_invis_file_operations = { | |||
565 | .llseek = generic_file_llseek, | 473 | .llseek = generic_file_llseek, |
566 | .read = do_sync_read, | 474 | .read = do_sync_read, |
567 | .write = do_sync_write, | 475 | .write = do_sync_write, |
568 | .readv = xfs_file_readv_invis, | ||
569 | .writev = xfs_file_writev_invis, | ||
570 | .aio_read = xfs_file_aio_read_invis, | 476 | .aio_read = xfs_file_aio_read_invis, |
571 | .aio_write = xfs_file_aio_write_invis, | 477 | .aio_write = xfs_file_aio_write_invis, |
572 | .sendfile = xfs_file_sendfile_invis, | 478 | .sendfile = xfs_file_sendfile_invis, |
diff --git a/fs/xfs/linux-2.6/xfs_globals.c b/fs/xfs/linux-2.6/xfs_globals.c index 6c162c3dde7e..ed3a5e1b4b67 100644 --- a/fs/xfs/linux-2.6/xfs_globals.c +++ b/fs/xfs/linux-2.6/xfs_globals.c | |||
@@ -34,7 +34,7 @@ xfs_param_t xfs_params = { | |||
34 | .restrict_chown = { 0, 1, 1 }, | 34 | .restrict_chown = { 0, 1, 1 }, |
35 | .sgid_inherit = { 0, 0, 1 }, | 35 | .sgid_inherit = { 0, 0, 1 }, |
36 | .symlink_mode = { 0, 0, 1 }, | 36 | .symlink_mode = { 0, 0, 1 }, |
37 | .panic_mask = { 0, 0, 127 }, | 37 | .panic_mask = { 0, 0, 255 }, |
38 | .error_level = { 0, 3, 11 }, | 38 | .error_level = { 0, 3, 11 }, |
39 | .syncd_timer = { 1*100, 30*100, 7200*100}, | 39 | .syncd_timer = { 1*100, 30*100, 7200*100}, |
40 | .stats_clear = { 0, 0, 1 }, | 40 | .stats_clear = { 0, 0, 1 }, |
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c index 6e52a5dd38d8..a74f854d91e6 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl.c +++ b/fs/xfs/linux-2.6/xfs_ioctl.c | |||
@@ -653,7 +653,7 @@ xfs_attrmulti_by_handle( | |||
653 | STATIC int | 653 | STATIC int |
654 | xfs_ioc_space( | 654 | xfs_ioc_space( |
655 | bhv_desc_t *bdp, | 655 | bhv_desc_t *bdp, |
656 | bhv_vnode_t *vp, | 656 | struct inode *inode, |
657 | struct file *filp, | 657 | struct file *filp, |
658 | int flags, | 658 | int flags, |
659 | unsigned int cmd, | 659 | unsigned int cmd, |
@@ -735,7 +735,7 @@ xfs_ioctl( | |||
735 | !capable(CAP_SYS_ADMIN)) | 735 | !capable(CAP_SYS_ADMIN)) |
736 | return -EPERM; | 736 | return -EPERM; |
737 | 737 | ||
738 | return xfs_ioc_space(bdp, vp, filp, ioflags, cmd, arg); | 738 | return xfs_ioc_space(bdp, inode, filp, ioflags, cmd, arg); |
739 | 739 | ||
740 | case XFS_IOC_DIOINFO: { | 740 | case XFS_IOC_DIOINFO: { |
741 | struct dioattr da; | 741 | struct dioattr da; |
@@ -763,6 +763,8 @@ xfs_ioctl( | |||
763 | return xfs_ioc_fsgeometry(mp, arg); | 763 | return xfs_ioc_fsgeometry(mp, arg); |
764 | 764 | ||
765 | case XFS_IOC_GETVERSION: | 765 | case XFS_IOC_GETVERSION: |
766 | return put_user(inode->i_generation, (int __user *)arg); | ||
767 | |||
766 | case XFS_IOC_GETXFLAGS: | 768 | case XFS_IOC_GETXFLAGS: |
767 | case XFS_IOC_SETXFLAGS: | 769 | case XFS_IOC_SETXFLAGS: |
768 | case XFS_IOC_FSGETXATTR: | 770 | case XFS_IOC_FSGETXATTR: |
@@ -957,7 +959,7 @@ xfs_ioctl( | |||
957 | STATIC int | 959 | STATIC int |
958 | xfs_ioc_space( | 960 | xfs_ioc_space( |
959 | bhv_desc_t *bdp, | 961 | bhv_desc_t *bdp, |
960 | bhv_vnode_t *vp, | 962 | struct inode *inode, |
961 | struct file *filp, | 963 | struct file *filp, |
962 | int ioflags, | 964 | int ioflags, |
963 | unsigned int cmd, | 965 | unsigned int cmd, |
@@ -967,13 +969,13 @@ xfs_ioc_space( | |||
967 | int attr_flags = 0; | 969 | int attr_flags = 0; |
968 | int error; | 970 | int error; |
969 | 971 | ||
970 | if (vp->v_inode.i_flags & (S_IMMUTABLE|S_APPEND)) | 972 | if (inode->i_flags & (S_IMMUTABLE|S_APPEND)) |
971 | return -XFS_ERROR(EPERM); | 973 | return -XFS_ERROR(EPERM); |
972 | 974 | ||
973 | if (!(filp->f_mode & FMODE_WRITE)) | 975 | if (!(filp->f_mode & FMODE_WRITE)) |
974 | return -XFS_ERROR(EBADF); | 976 | return -XFS_ERROR(EBADF); |
975 | 977 | ||
976 | if (!VN_ISREG(vp)) | 978 | if (!S_ISREG(inode->i_mode)) |
977 | return -XFS_ERROR(EINVAL); | 979 | return -XFS_ERROR(EINVAL); |
978 | 980 | ||
979 | if (copy_from_user(&bf, arg, sizeof(bf))) | 981 | if (copy_from_user(&bf, arg, sizeof(bf))) |
@@ -1264,13 +1266,6 @@ xfs_ioc_xattr( | |||
1264 | break; | 1266 | break; |
1265 | } | 1267 | } |
1266 | 1268 | ||
1267 | case XFS_IOC_GETVERSION: { | ||
1268 | flags = vn_to_inode(vp)->i_generation; | ||
1269 | if (copy_to_user(arg, &flags, sizeof(flags))) | ||
1270 | error = -EFAULT; | ||
1271 | break; | ||
1272 | } | ||
1273 | |||
1274 | default: | 1269 | default: |
1275 | error = -ENOTTY; | 1270 | error = -ENOTTY; |
1276 | break; | 1271 | break; |
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index 22e3b714f629..3ba814ae3bba 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c | |||
@@ -623,12 +623,27 @@ xfs_vn_getattr( | |||
623 | { | 623 | { |
624 | struct inode *inode = dentry->d_inode; | 624 | struct inode *inode = dentry->d_inode; |
625 | bhv_vnode_t *vp = vn_from_inode(inode); | 625 | bhv_vnode_t *vp = vn_from_inode(inode); |
626 | int error = 0; | 626 | bhv_vattr_t vattr = { .va_mask = XFS_AT_STAT }; |
627 | int error; | ||
627 | 628 | ||
628 | if (unlikely(vp->v_flag & VMODIFIED)) | 629 | error = bhv_vop_getattr(vp, &vattr, ATTR_LAZY, NULL); |
629 | error = vn_revalidate(vp); | 630 | if (likely(!error)) { |
630 | if (!error) | 631 | stat->size = i_size_read(inode); |
631 | generic_fillattr(inode, stat); | 632 | stat->dev = inode->i_sb->s_dev; |
633 | stat->rdev = (vattr.va_rdev == 0) ? 0 : | ||
634 | MKDEV(sysv_major(vattr.va_rdev) & 0x1ff, | ||
635 | sysv_minor(vattr.va_rdev)); | ||
636 | stat->mode = vattr.va_mode; | ||
637 | stat->nlink = vattr.va_nlink; | ||
638 | stat->uid = vattr.va_uid; | ||
639 | stat->gid = vattr.va_gid; | ||
640 | stat->ino = vattr.va_nodeid; | ||
641 | stat->atime = vattr.va_atime; | ||
642 | stat->mtime = vattr.va_mtime; | ||
643 | stat->ctime = vattr.va_ctime; | ||
644 | stat->blocks = vattr.va_nblocks; | ||
645 | stat->blksize = vattr.va_blocksize; | ||
646 | } | ||
632 | return -error; | 647 | return -error; |
633 | } | 648 | } |
634 | 649 | ||
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h index a13f75c1a936..2b0e0018738a 100644 --- a/fs/xfs/linux-2.6/xfs_linux.h +++ b/fs/xfs/linux-2.6/xfs_linux.h | |||
@@ -148,11 +148,7 @@ BUFFER_FNS(PrivateStart, unwritten); | |||
148 | (current->flags = ((current->flags & ~(f)) | (*(sp) & (f)))) | 148 | (current->flags = ((current->flags & ~(f)) | (*(sp) & (f)))) |
149 | 149 | ||
150 | #define NBPP PAGE_SIZE | 150 | #define NBPP PAGE_SIZE |
151 | #define DPPSHFT (PAGE_SHIFT - 9) | ||
152 | #define NDPP (1 << (PAGE_SHIFT - 9)) | 151 | #define NDPP (1 << (PAGE_SHIFT - 9)) |
153 | #define dtop(DD) (((DD) + NDPP - 1) >> DPPSHFT) | ||
154 | #define dtopt(DD) ((DD) >> DPPSHFT) | ||
155 | #define dpoff(DD) ((DD) & (NDPP-1)) | ||
156 | 152 | ||
157 | #define NBBY 8 /* number of bits per byte */ | 153 | #define NBBY 8 /* number of bits per byte */ |
158 | #define NBPC PAGE_SIZE /* Number of bytes per click */ | 154 | #define NBPC PAGE_SIZE /* Number of bytes per click */ |
@@ -172,8 +168,6 @@ BUFFER_FNS(PrivateStart, unwritten); | |||
172 | #define btoct(x) ((__psunsigned_t)(x)>>BPCSHIFT) | 168 | #define btoct(x) ((__psunsigned_t)(x)>>BPCSHIFT) |
173 | #define btoc64(x) (((__uint64_t)(x)+(NBPC-1))>>BPCSHIFT) | 169 | #define btoc64(x) (((__uint64_t)(x)+(NBPC-1))>>BPCSHIFT) |
174 | #define btoct64(x) ((__uint64_t)(x)>>BPCSHIFT) | 170 | #define btoct64(x) ((__uint64_t)(x)>>BPCSHIFT) |
175 | #define io_btoc(x) (((__psunsigned_t)(x)+(IO_NBPC-1))>>IO_BPCSHIFT) | ||
176 | #define io_btoct(x) ((__psunsigned_t)(x)>>IO_BPCSHIFT) | ||
177 | 171 | ||
178 | /* off_t bytes to clicks */ | 172 | /* off_t bytes to clicks */ |
179 | #define offtoc(x) (((__uint64_t)(x)+(NBPC-1))>>BPCSHIFT) | 173 | #define offtoc(x) (((__uint64_t)(x)+(NBPC-1))>>BPCSHIFT) |
@@ -186,7 +180,6 @@ BUFFER_FNS(PrivateStart, unwritten); | |||
186 | #define ctob(x) ((__psunsigned_t)(x)<<BPCSHIFT) | 180 | #define ctob(x) ((__psunsigned_t)(x)<<BPCSHIFT) |
187 | #define btoct(x) ((__psunsigned_t)(x)>>BPCSHIFT) | 181 | #define btoct(x) ((__psunsigned_t)(x)>>BPCSHIFT) |
188 | #define ctob64(x) ((__uint64_t)(x)<<BPCSHIFT) | 182 | #define ctob64(x) ((__uint64_t)(x)<<BPCSHIFT) |
189 | #define io_ctob(x) ((__psunsigned_t)(x)<<IO_BPCSHIFT) | ||
190 | 183 | ||
191 | /* bytes to clicks */ | 184 | /* bytes to clicks */ |
192 | #define btoc(x) (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT) | 185 | #define btoc(x) (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT) |
@@ -339,4 +332,11 @@ static inline __uint64_t roundup_64(__uint64_t x, __uint32_t y) | |||
339 | return(x * y); | 332 | return(x * y); |
340 | } | 333 | } |
341 | 334 | ||
335 | static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y) | ||
336 | { | ||
337 | x += y - 1; | ||
338 | do_div(x, y); | ||
339 | return x; | ||
340 | } | ||
341 | |||
342 | #endif /* __XFS_LINUX__ */ | 342 | #endif /* __XFS_LINUX__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c index ee788b1cb364..fa842f1c9fa2 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.c +++ b/fs/xfs/linux-2.6/xfs_lrw.c | |||
@@ -270,16 +270,18 @@ xfs_read( | |||
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | if (unlikely((ioflags & IO_ISDIRECT) && VN_CACHED(vp))) | 273 | if (unlikely(ioflags & IO_ISDIRECT)) { |
274 | bhv_vop_flushinval_pages(vp, ctooff(offtoct(*offset)), | 274 | if (VN_CACHED(vp)) |
275 | -1, FI_REMAPF_LOCKED); | 275 | bhv_vop_flushinval_pages(vp, ctooff(offtoct(*offset)), |
276 | 276 | -1, FI_REMAPF_LOCKED); | |
277 | if (unlikely(ioflags & IO_ISDIRECT)) | ||
278 | mutex_unlock(&inode->i_mutex); | 277 | mutex_unlock(&inode->i_mutex); |
278 | } | ||
279 | 279 | ||
280 | xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore, | 280 | xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore, |
281 | (void *)iovp, segs, *offset, ioflags); | 281 | (void *)iovp, segs, *offset, ioflags); |
282 | ret = __generic_file_aio_read(iocb, iovp, segs, offset); | 282 | |
283 | iocb->ki_pos = *offset; | ||
284 | ret = generic_file_aio_read(iocb, iovp, segs, *offset); | ||
283 | if (ret == -EIOCBQUEUED && !(ioflags & IO_ISAIO)) | 285 | if (ret == -EIOCBQUEUED && !(ioflags & IO_ISAIO)) |
284 | ret = wait_on_sync_kiocb(iocb); | 286 | ret = wait_on_sync_kiocb(iocb); |
285 | if (ret > 0) | 287 | if (ret > 0) |
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index 9df9ed37d219..38c4d128a8c0 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
@@ -227,7 +227,9 @@ xfs_initialize_vnode( | |||
227 | xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip); | 227 | xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip); |
228 | xfs_set_inodeops(inode); | 228 | xfs_set_inodeops(inode); |
229 | 229 | ||
230 | spin_lock(&ip->i_flags_lock); | ||
230 | ip->i_flags &= ~XFS_INEW; | 231 | ip->i_flags &= ~XFS_INEW; |
232 | spin_unlock(&ip->i_flags_lock); | ||
231 | barrier(); | 233 | barrier(); |
232 | 234 | ||
233 | unlock_new_inode(inode); | 235 | unlock_new_inode(inode); |
diff --git a/fs/xfs/linux-2.6/xfs_vfs.h b/fs/xfs/linux-2.6/xfs_vfs.h index 91fc2c4b3353..da255bdf5260 100644 --- a/fs/xfs/linux-2.6/xfs_vfs.h +++ b/fs/xfs/linux-2.6/xfs_vfs.h | |||
@@ -79,7 +79,7 @@ typedef enum { | |||
79 | #define VFS_RDONLY 0x0001 /* read-only vfs */ | 79 | #define VFS_RDONLY 0x0001 /* read-only vfs */ |
80 | #define VFS_GRPID 0x0002 /* group-ID assigned from directory */ | 80 | #define VFS_GRPID 0x0002 /* group-ID assigned from directory */ |
81 | #define VFS_DMI 0x0004 /* filesystem has the DMI enabled */ | 81 | #define VFS_DMI 0x0004 /* filesystem has the DMI enabled */ |
82 | #define VFS_UMOUNT 0x0008 /* unmount in progress */ | 82 | /* ---- VFS_UMOUNT ---- 0x0008 -- unneeded, fixed via kthread APIs */ |
83 | #define VFS_32BITINODES 0x0010 /* do not use inums above 32 bits */ | 83 | #define VFS_32BITINODES 0x0010 /* do not use inums above 32 bits */ |
84 | #define VFS_END 0x0010 /* max flag */ | 84 | #define VFS_END 0x0010 /* max flag */ |
85 | 85 | ||
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h index c42b3221b20c..515f5fdea57a 100644 --- a/fs/xfs/linux-2.6/xfs_vnode.h +++ b/fs/xfs/linux-2.6/xfs_vnode.h | |||
@@ -85,8 +85,6 @@ typedef enum { | |||
85 | #define VN_BHV_HEAD(vp) ((bhv_head_t *)(&((vp)->v_bh))) | 85 | #define VN_BHV_HEAD(vp) ((bhv_head_t *)(&((vp)->v_bh))) |
86 | #define vn_bhv_head_init(bhp,name) bhv_head_init(bhp,name) | 86 | #define vn_bhv_head_init(bhp,name) bhv_head_init(bhp,name) |
87 | #define vn_bhv_remove(bhp,bdp) bhv_remove(bhp,bdp) | 87 | #define vn_bhv_remove(bhp,bdp) bhv_remove(bhp,bdp) |
88 | #define vn_bhv_lookup(bhp,ops) bhv_lookup(bhp,ops) | ||
89 | #define vn_bhv_lookup_unlocked(bhp,ops) bhv_lookup_unlocked(bhp,ops) | ||
90 | 88 | ||
91 | /* | 89 | /* |
92 | * Vnode to Linux inode mapping. | 90 | * Vnode to Linux inode mapping. |
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/quota/xfs_dquot_item.c index 5b2dcc58b244..33ad5af386e0 100644 --- a/fs/xfs/quota/xfs_dquot_item.c +++ b/fs/xfs/quota/xfs_dquot_item.c | |||
@@ -382,18 +382,6 @@ xfs_qm_dquot_logitem_unlock( | |||
382 | 382 | ||
383 | 383 | ||
384 | /* | 384 | /* |
385 | * The transaction with the dquot locked has aborted. The dquot | ||
386 | * must not be dirty within the transaction. We simply unlock just | ||
387 | * as if the transaction had been cancelled. | ||
388 | */ | ||
389 | STATIC void | ||
390 | xfs_qm_dquot_logitem_abort( | ||
391 | xfs_dq_logitem_t *ql) | ||
392 | { | ||
393 | xfs_qm_dquot_logitem_unlock(ql); | ||
394 | } | ||
395 | |||
396 | /* | ||
397 | * this needs to stamp an lsn into the dquot, I think. | 385 | * this needs to stamp an lsn into the dquot, I think. |
398 | * rpc's that look at user dquot's would then have to | 386 | * rpc's that look at user dquot's would then have to |
399 | * push on the dependency recorded in the dquot | 387 | * push on the dependency recorded in the dquot |
@@ -426,7 +414,6 @@ STATIC struct xfs_item_ops xfs_dquot_item_ops = { | |||
426 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) | 414 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) |
427 | xfs_qm_dquot_logitem_committed, | 415 | xfs_qm_dquot_logitem_committed, |
428 | .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_push, | 416 | .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_push, |
429 | .iop_abort = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_abort, | ||
430 | .iop_pushbuf = (void(*)(xfs_log_item_t*)) | 417 | .iop_pushbuf = (void(*)(xfs_log_item_t*)) |
431 | xfs_qm_dquot_logitem_pushbuf, | 418 | xfs_qm_dquot_logitem_pushbuf, |
432 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) | 419 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) |
@@ -559,17 +546,6 @@ xfs_qm_qoff_logitem_committed(xfs_qoff_logitem_t *qf, xfs_lsn_t lsn) | |||
559 | } | 546 | } |
560 | 547 | ||
561 | /* | 548 | /* |
562 | * The transaction of which this QUOTAOFF is a part has been aborted. | ||
563 | * Just clean up after ourselves. | ||
564 | * Shouldn't this never happen in the case of qoffend logitems? XXX | ||
565 | */ | ||
566 | STATIC void | ||
567 | xfs_qm_qoff_logitem_abort(xfs_qoff_logitem_t *qf) | ||
568 | { | ||
569 | kmem_free(qf, sizeof(xfs_qoff_logitem_t)); | ||
570 | } | ||
571 | |||
572 | /* | ||
573 | * There isn't much you can do to push on an quotaoff item. It is simply | 549 | * There isn't much you can do to push on an quotaoff item. It is simply |
574 | * stuck waiting for the log to be flushed to disk. | 550 | * stuck waiting for the log to be flushed to disk. |
575 | */ | 551 | */ |
@@ -644,7 +620,6 @@ STATIC struct xfs_item_ops xfs_qm_qoffend_logitem_ops = { | |||
644 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) | 620 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) |
645 | xfs_qm_qoffend_logitem_committed, | 621 | xfs_qm_qoffend_logitem_committed, |
646 | .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push, | 622 | .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push, |
647 | .iop_abort = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_abort, | ||
648 | .iop_pushbuf = NULL, | 623 | .iop_pushbuf = NULL, |
649 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) | 624 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) |
650 | xfs_qm_qoffend_logitem_committing | 625 | xfs_qm_qoffend_logitem_committing |
@@ -667,7 +642,6 @@ STATIC struct xfs_item_ops xfs_qm_qoff_logitem_ops = { | |||
667 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) | 642 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) |
668 | xfs_qm_qoff_logitem_committed, | 643 | xfs_qm_qoff_logitem_committed, |
669 | .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push, | 644 | .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push, |
670 | .iop_abort = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_abort, | ||
671 | .iop_pushbuf = NULL, | 645 | .iop_pushbuf = NULL, |
672 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) | 646 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) |
673 | xfs_qm_qoff_logitem_committing | 647 | xfs_qm_qoff_logitem_committing |
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c index e23e45535c48..7c6a3a50379e 100644 --- a/fs/xfs/quota/xfs_qm.c +++ b/fs/xfs/quota/xfs_qm.c | |||
@@ -112,17 +112,17 @@ xfs_Gqm_init(void) | |||
112 | { | 112 | { |
113 | xfs_dqhash_t *udqhash, *gdqhash; | 113 | xfs_dqhash_t *udqhash, *gdqhash; |
114 | xfs_qm_t *xqm; | 114 | xfs_qm_t *xqm; |
115 | uint i, hsize, flags = KM_SLEEP | KM_MAYFAIL; | 115 | size_t hsize; |
116 | uint i; | ||
116 | 117 | ||
117 | /* | 118 | /* |
118 | * Initialize the dquot hash tables. | 119 | * Initialize the dquot hash tables. |
119 | */ | 120 | */ |
120 | hsize = XFS_QM_HASHSIZE_HIGH; | 121 | udqhash = kmem_zalloc_greedy(&hsize, |
121 | while (!(udqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), flags))) { | 122 | XFS_QM_HASHSIZE_LOW, XFS_QM_HASHSIZE_HIGH, |
122 | if ((hsize >>= 1) <= XFS_QM_HASHSIZE_LOW) | 123 | KM_SLEEP | KM_MAYFAIL | KM_LARGE); |
123 | flags = KM_SLEEP; | 124 | gdqhash = kmem_zalloc(hsize, KM_SLEEP | KM_LARGE); |
124 | } | 125 | hsize /= sizeof(xfs_dqhash_t); |
125 | gdqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), KM_SLEEP); | ||
126 | ndquot = hsize << 8; | 126 | ndquot = hsize << 8; |
127 | 127 | ||
128 | xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP); | 128 | xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP); |
diff --git a/fs/xfs/quota/xfs_qm.h b/fs/xfs/quota/xfs_qm.h index 4568deb6da86..689407de0a20 100644 --- a/fs/xfs/quota/xfs_qm.h +++ b/fs/xfs/quota/xfs_qm.h | |||
@@ -56,12 +56,6 @@ extern kmem_zone_t *qm_dqtrxzone; | |||
56 | #define XFS_QM_HASHSIZE_HIGH ((NBPP * 4) / sizeof(xfs_dqhash_t)) | 56 | #define XFS_QM_HASHSIZE_HIGH ((NBPP * 4) / sizeof(xfs_dqhash_t)) |
57 | 57 | ||
58 | /* | 58 | /* |
59 | * We output a cmn_err when quotachecking a quota file with more than | ||
60 | * this many fsbs. | ||
61 | */ | ||
62 | #define XFS_QM_BIG_QCHECK_NBLKS 500 | ||
63 | |||
64 | /* | ||
65 | * This defines the unit of allocation of dquots. | 59 | * This defines the unit of allocation of dquots. |
66 | * Currently, it is just one file system block, and a 4K blk contains 30 | 60 | * Currently, it is just one file system block, and a 4K blk contains 30 |
67 | * (136 * 30 = 4080) dquots. It's probably not worth trying to make | 61 | * (136 * 30 = 4080) dquots. It's probably not worth trying to make |
diff --git a/fs/xfs/quota/xfs_quota_priv.h b/fs/xfs/quota/xfs_quota_priv.h index b7ddd04aae32..a8b85e2be9d5 100644 --- a/fs/xfs/quota/xfs_quota_priv.h +++ b/fs/xfs/quota/xfs_quota_priv.h | |||
@@ -75,7 +75,6 @@ static inline int XQMISLCKD(struct xfs_dqhash *h) | |||
75 | 75 | ||
76 | #define xfs_qm_freelist_lock(qm) XQMLCK(&((qm)->qm_dqfreelist)) | 76 | #define xfs_qm_freelist_lock(qm) XQMLCK(&((qm)->qm_dqfreelist)) |
77 | #define xfs_qm_freelist_unlock(qm) XQMUNLCK(&((qm)->qm_dqfreelist)) | 77 | #define xfs_qm_freelist_unlock(qm) XQMUNLCK(&((qm)->qm_dqfreelist)) |
78 | #define XFS_QM_IS_FREELIST_LOCKED(qm) XQMISLCKD(&((qm)->qm_dqfreelist)) | ||
79 | 78 | ||
80 | /* | 79 | /* |
81 | * Hash into a bucket in the dquot hash table, based on <mp, id>. | 80 | * Hash into a bucket in the dquot hash table, based on <mp, id>. |
@@ -170,6 +169,5 @@ for ((dqp) = (qlist)->qh_next; (dqp) != (xfs_dquot_t *)(qlist); \ | |||
170 | #define DQFLAGTO_TYPESTR(d) (((d)->dq_flags & XFS_DQ_USER) ? "USR" : \ | 169 | #define DQFLAGTO_TYPESTR(d) (((d)->dq_flags & XFS_DQ_USER) ? "USR" : \ |
171 | (((d)->dq_flags & XFS_DQ_GROUP) ? "GRP" : \ | 170 | (((d)->dq_flags & XFS_DQ_GROUP) ? "GRP" : \ |
172 | (((d)->dq_flags & XFS_DQ_PROJ) ? "PRJ":"???"))) | 171 | (((d)->dq_flags & XFS_DQ_PROJ) ? "PRJ":"???"))) |
173 | #define DQFLAGTO_DIRTYSTR(d) (XFS_DQ_IS_DIRTY(d) ? "DIRTY" : "NOTDIRTY") | ||
174 | 172 | ||
175 | #endif /* __XFS_QUOTA_PRIV_H__ */ | 173 | #endif /* __XFS_QUOTA_PRIV_H__ */ |
diff --git a/fs/xfs/support/ktrace.c b/fs/xfs/support/ktrace.c index addf5a7ea06c..5cf2e86caa71 100644 --- a/fs/xfs/support/ktrace.c +++ b/fs/xfs/support/ktrace.c | |||
@@ -75,7 +75,7 @@ ktrace_alloc(int nentries, unsigned int __nocast sleep) | |||
75 | sleep); | 75 | sleep); |
76 | } else { | 76 | } else { |
77 | ktep = (ktrace_entry_t*)kmem_zalloc((nentries * sizeof(*ktep)), | 77 | ktep = (ktrace_entry_t*)kmem_zalloc((nentries * sizeof(*ktep)), |
78 | sleep); | 78 | sleep | KM_LARGE); |
79 | } | 79 | } |
80 | 80 | ||
81 | if (ktep == NULL) { | 81 | if (ktep == NULL) { |
diff --git a/fs/xfs/xfs_ag.h b/fs/xfs/xfs_ag.h index dc2361dd740a..9ece7f87ec5b 100644 --- a/fs/xfs/xfs_ag.h +++ b/fs/xfs/xfs_ag.h | |||
@@ -150,7 +150,7 @@ typedef struct xfs_agi { | |||
150 | #define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)XFS_BUF_PTR(bp)) | 150 | #define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)XFS_BUF_PTR(bp)) |
151 | 151 | ||
152 | typedef struct xfs_agfl { | 152 | typedef struct xfs_agfl { |
153 | xfs_agblock_t agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */ | 153 | __be32 agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */ |
154 | } xfs_agfl_t; | 154 | } xfs_agfl_t; |
155 | 155 | ||
156 | /* | 156 | /* |
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index d2bbcd882a69..e80dda3437d1 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c | |||
@@ -1477,8 +1477,10 @@ xfs_alloc_ag_vextent_small( | |||
1477 | /* | 1477 | /* |
1478 | * Can't allocate from the freelist for some reason. | 1478 | * Can't allocate from the freelist for some reason. |
1479 | */ | 1479 | */ |
1480 | else | 1480 | else { |
1481 | fbno = NULLAGBLOCK; | ||
1481 | flen = 0; | 1482 | flen = 0; |
1483 | } | ||
1482 | /* | 1484 | /* |
1483 | * Can't do the allocation, give up. | 1485 | * Can't do the allocation, give up. |
1484 | */ | 1486 | */ |
@@ -2021,7 +2023,7 @@ xfs_alloc_get_freelist( | |||
2021 | /* | 2023 | /* |
2022 | * Get the block number and update the data structures. | 2024 | * Get the block number and update the data structures. |
2023 | */ | 2025 | */ |
2024 | bno = INT_GET(agfl->agfl_bno[be32_to_cpu(agf->agf_flfirst)], ARCH_CONVERT); | 2026 | bno = be32_to_cpu(agfl->agfl_bno[be32_to_cpu(agf->agf_flfirst)]); |
2025 | be32_add(&agf->agf_flfirst, 1); | 2027 | be32_add(&agf->agf_flfirst, 1); |
2026 | xfs_trans_brelse(tp, agflbp); | 2028 | xfs_trans_brelse(tp, agflbp); |
2027 | if (be32_to_cpu(agf->agf_flfirst) == XFS_AGFL_SIZE(mp)) | 2029 | if (be32_to_cpu(agf->agf_flfirst) == XFS_AGFL_SIZE(mp)) |
@@ -2108,7 +2110,7 @@ xfs_alloc_put_freelist( | |||
2108 | { | 2110 | { |
2109 | xfs_agf_t *agf; /* a.g. freespace structure */ | 2111 | xfs_agf_t *agf; /* a.g. freespace structure */ |
2110 | xfs_agfl_t *agfl; /* a.g. free block array */ | 2112 | xfs_agfl_t *agfl; /* a.g. free block array */ |
2111 | xfs_agblock_t *blockp;/* pointer to array entry */ | 2113 | __be32 *blockp;/* pointer to array entry */ |
2112 | int error; | 2114 | int error; |
2113 | #ifdef XFS_ALLOC_TRACE | 2115 | #ifdef XFS_ALLOC_TRACE |
2114 | static char fname[] = "xfs_alloc_put_freelist"; | 2116 | static char fname[] = "xfs_alloc_put_freelist"; |
@@ -2132,7 +2134,7 @@ xfs_alloc_put_freelist( | |||
2132 | pag->pagf_flcount++; | 2134 | pag->pagf_flcount++; |
2133 | ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp)); | 2135 | ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp)); |
2134 | blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)]; | 2136 | blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)]; |
2135 | INT_SET(*blockp, ARCH_CONVERT, bno); | 2137 | *blockp = cpu_to_be32(bno); |
2136 | TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); | 2138 | TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); |
2137 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); | 2139 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); |
2138 | xfs_trans_log_buf(tp, agflbp, | 2140 | xfs_trans_log_buf(tp, agflbp, |
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c index 7446556e8021..74cadf95d4e8 100644 --- a/fs/xfs/xfs_alloc_btree.c +++ b/fs/xfs/xfs_alloc_btree.c | |||
@@ -92,6 +92,7 @@ xfs_alloc_delrec( | |||
92 | xfs_alloc_key_t *rkp; /* right block key pointer */ | 92 | xfs_alloc_key_t *rkp; /* right block key pointer */ |
93 | xfs_alloc_ptr_t *rpp; /* right block address pointer */ | 93 | xfs_alloc_ptr_t *rpp; /* right block address pointer */ |
94 | int rrecs=0; /* number of records in right block */ | 94 | int rrecs=0; /* number of records in right block */ |
95 | int numrecs; | ||
95 | xfs_alloc_rec_t *rrp; /* right block record pointer */ | 96 | xfs_alloc_rec_t *rrp; /* right block record pointer */ |
96 | xfs_btree_cur_t *tcur; /* temporary btree cursor */ | 97 | xfs_btree_cur_t *tcur; /* temporary btree cursor */ |
97 | 98 | ||
@@ -115,7 +116,8 @@ xfs_alloc_delrec( | |||
115 | /* | 116 | /* |
116 | * Fail if we're off the end of the block. | 117 | * Fail if we're off the end of the block. |
117 | */ | 118 | */ |
118 | if (ptr > be16_to_cpu(block->bb_numrecs)) { | 119 | numrecs = be16_to_cpu(block->bb_numrecs); |
120 | if (ptr > numrecs) { | ||
119 | *stat = 0; | 121 | *stat = 0; |
120 | return 0; | 122 | return 0; |
121 | } | 123 | } |
@@ -129,18 +131,18 @@ xfs_alloc_delrec( | |||
129 | lkp = XFS_ALLOC_KEY_ADDR(block, 1, cur); | 131 | lkp = XFS_ALLOC_KEY_ADDR(block, 1, cur); |
130 | lpp = XFS_ALLOC_PTR_ADDR(block, 1, cur); | 132 | lpp = XFS_ALLOC_PTR_ADDR(block, 1, cur); |
131 | #ifdef DEBUG | 133 | #ifdef DEBUG |
132 | for (i = ptr; i < be16_to_cpu(block->bb_numrecs); i++) { | 134 | for (i = ptr; i < numrecs; i++) { |
133 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(lpp[i]), level))) | 135 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(lpp[i]), level))) |
134 | return error; | 136 | return error; |
135 | } | 137 | } |
136 | #endif | 138 | #endif |
137 | if (ptr < be16_to_cpu(block->bb_numrecs)) { | 139 | if (ptr < numrecs) { |
138 | memmove(&lkp[ptr - 1], &lkp[ptr], | 140 | memmove(&lkp[ptr - 1], &lkp[ptr], |
139 | (be16_to_cpu(block->bb_numrecs) - ptr) * sizeof(*lkp)); | 141 | (numrecs - ptr) * sizeof(*lkp)); |
140 | memmove(&lpp[ptr - 1], &lpp[ptr], | 142 | memmove(&lpp[ptr - 1], &lpp[ptr], |
141 | (be16_to_cpu(block->bb_numrecs) - ptr) * sizeof(*lpp)); | 143 | (numrecs - ptr) * sizeof(*lpp)); |
142 | xfs_alloc_log_ptrs(cur, bp, ptr, be16_to_cpu(block->bb_numrecs) - 1); | 144 | xfs_alloc_log_ptrs(cur, bp, ptr, numrecs - 1); |
143 | xfs_alloc_log_keys(cur, bp, ptr, be16_to_cpu(block->bb_numrecs) - 1); | 145 | xfs_alloc_log_keys(cur, bp, ptr, numrecs - 1); |
144 | } | 146 | } |
145 | } | 147 | } |
146 | /* | 148 | /* |
@@ -149,10 +151,10 @@ xfs_alloc_delrec( | |||
149 | */ | 151 | */ |
150 | else { | 152 | else { |
151 | lrp = XFS_ALLOC_REC_ADDR(block, 1, cur); | 153 | lrp = XFS_ALLOC_REC_ADDR(block, 1, cur); |
152 | if (ptr < be16_to_cpu(block->bb_numrecs)) { | 154 | if (ptr < numrecs) { |
153 | memmove(&lrp[ptr - 1], &lrp[ptr], | 155 | memmove(&lrp[ptr - 1], &lrp[ptr], |
154 | (be16_to_cpu(block->bb_numrecs) - ptr) * sizeof(*lrp)); | 156 | (numrecs - ptr) * sizeof(*lrp)); |
155 | xfs_alloc_log_recs(cur, bp, ptr, be16_to_cpu(block->bb_numrecs) - 1); | 157 | xfs_alloc_log_recs(cur, bp, ptr, numrecs - 1); |
156 | } | 158 | } |
157 | /* | 159 | /* |
158 | * If it's the first record in the block, we'll need a key | 160 | * If it's the first record in the block, we'll need a key |
@@ -167,7 +169,8 @@ xfs_alloc_delrec( | |||
167 | /* | 169 | /* |
168 | * Decrement and log the number of entries in the block. | 170 | * Decrement and log the number of entries in the block. |
169 | */ | 171 | */ |
170 | be16_add(&block->bb_numrecs, -1); | 172 | numrecs--; |
173 | block->bb_numrecs = cpu_to_be16(numrecs); | ||
171 | xfs_alloc_log_block(cur->bc_tp, bp, XFS_BB_NUMRECS); | 174 | xfs_alloc_log_block(cur->bc_tp, bp, XFS_BB_NUMRECS); |
172 | /* | 175 | /* |
173 | * See if the longest free extent in the allocation group was | 176 | * See if the longest free extent in the allocation group was |
@@ -181,14 +184,14 @@ xfs_alloc_delrec( | |||
181 | if (level == 0 && | 184 | if (level == 0 && |
182 | cur->bc_btnum == XFS_BTNUM_CNT && | 185 | cur->bc_btnum == XFS_BTNUM_CNT && |
183 | be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK && | 186 | be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK && |
184 | ptr > be16_to_cpu(block->bb_numrecs)) { | 187 | ptr > numrecs) { |
185 | ASSERT(ptr == be16_to_cpu(block->bb_numrecs) + 1); | 188 | ASSERT(ptr == numrecs + 1); |
186 | /* | 189 | /* |
187 | * There are still records in the block. Grab the size | 190 | * There are still records in the block. Grab the size |
188 | * from the last one. | 191 | * from the last one. |
189 | */ | 192 | */ |
190 | if (be16_to_cpu(block->bb_numrecs)) { | 193 | if (numrecs) { |
191 | rrp = XFS_ALLOC_REC_ADDR(block, be16_to_cpu(block->bb_numrecs), cur); | 194 | rrp = XFS_ALLOC_REC_ADDR(block, numrecs, cur); |
192 | agf->agf_longest = rrp->ar_blockcount; | 195 | agf->agf_longest = rrp->ar_blockcount; |
193 | } | 196 | } |
194 | /* | 197 | /* |
@@ -211,7 +214,7 @@ xfs_alloc_delrec( | |||
211 | * and it's NOT the leaf level, | 214 | * and it's NOT the leaf level, |
212 | * then we can get rid of this level. | 215 | * then we can get rid of this level. |
213 | */ | 216 | */ |
214 | if (be16_to_cpu(block->bb_numrecs) == 1 && level > 0) { | 217 | if (numrecs == 1 && level > 0) { |
215 | /* | 218 | /* |
216 | * lpp is still set to the first pointer in the block. | 219 | * lpp is still set to the first pointer in the block. |
217 | * Make it the new root of the btree. | 220 | * Make it the new root of the btree. |
@@ -267,7 +270,7 @@ xfs_alloc_delrec( | |||
267 | * If the number of records remaining in the block is at least | 270 | * If the number of records remaining in the block is at least |
268 | * the minimum, we're done. | 271 | * the minimum, we're done. |
269 | */ | 272 | */ |
270 | if (be16_to_cpu(block->bb_numrecs) >= XFS_ALLOC_BLOCK_MINRECS(level, cur)) { | 273 | if (numrecs >= XFS_ALLOC_BLOCK_MINRECS(level, cur)) { |
271 | if (level > 0 && (error = xfs_alloc_decrement(cur, level, &i))) | 274 | if (level > 0 && (error = xfs_alloc_decrement(cur, level, &i))) |
272 | return error; | 275 | return error; |
273 | *stat = 1; | 276 | *stat = 1; |
@@ -419,19 +422,21 @@ xfs_alloc_delrec( | |||
419 | * See if we can join with the left neighbor block. | 422 | * See if we can join with the left neighbor block. |
420 | */ | 423 | */ |
421 | if (lbno != NULLAGBLOCK && | 424 | if (lbno != NULLAGBLOCK && |
422 | lrecs + be16_to_cpu(block->bb_numrecs) <= XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { | 425 | lrecs + numrecs <= XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { |
423 | /* | 426 | /* |
424 | * Set "right" to be the starting block, | 427 | * Set "right" to be the starting block, |
425 | * "left" to be the left neighbor. | 428 | * "left" to be the left neighbor. |
426 | */ | 429 | */ |
427 | rbno = bno; | 430 | rbno = bno; |
428 | right = block; | 431 | right = block; |
432 | rrecs = be16_to_cpu(right->bb_numrecs); | ||
429 | rbp = bp; | 433 | rbp = bp; |
430 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, | 434 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, |
431 | cur->bc_private.a.agno, lbno, 0, &lbp, | 435 | cur->bc_private.a.agno, lbno, 0, &lbp, |
432 | XFS_ALLOC_BTREE_REF))) | 436 | XFS_ALLOC_BTREE_REF))) |
433 | return error; | 437 | return error; |
434 | left = XFS_BUF_TO_ALLOC_BLOCK(lbp); | 438 | left = XFS_BUF_TO_ALLOC_BLOCK(lbp); |
439 | lrecs = be16_to_cpu(left->bb_numrecs); | ||
435 | if ((error = xfs_btree_check_sblock(cur, left, level, lbp))) | 440 | if ((error = xfs_btree_check_sblock(cur, left, level, lbp))) |
436 | return error; | 441 | return error; |
437 | } | 442 | } |
@@ -439,20 +444,21 @@ xfs_alloc_delrec( | |||
439 | * If that won't work, see if we can join with the right neighbor block. | 444 | * If that won't work, see if we can join with the right neighbor block. |
440 | */ | 445 | */ |
441 | else if (rbno != NULLAGBLOCK && | 446 | else if (rbno != NULLAGBLOCK && |
442 | rrecs + be16_to_cpu(block->bb_numrecs) <= | 447 | rrecs + numrecs <= XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { |
443 | XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { | ||
444 | /* | 448 | /* |
445 | * Set "left" to be the starting block, | 449 | * Set "left" to be the starting block, |
446 | * "right" to be the right neighbor. | 450 | * "right" to be the right neighbor. |
447 | */ | 451 | */ |
448 | lbno = bno; | 452 | lbno = bno; |
449 | left = block; | 453 | left = block; |
454 | lrecs = be16_to_cpu(left->bb_numrecs); | ||
450 | lbp = bp; | 455 | lbp = bp; |
451 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, | 456 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, |
452 | cur->bc_private.a.agno, rbno, 0, &rbp, | 457 | cur->bc_private.a.agno, rbno, 0, &rbp, |
453 | XFS_ALLOC_BTREE_REF))) | 458 | XFS_ALLOC_BTREE_REF))) |
454 | return error; | 459 | return error; |
455 | right = XFS_BUF_TO_ALLOC_BLOCK(rbp); | 460 | right = XFS_BUF_TO_ALLOC_BLOCK(rbp); |
461 | rrecs = be16_to_cpu(right->bb_numrecs); | ||
456 | if ((error = xfs_btree_check_sblock(cur, right, level, rbp))) | 462 | if ((error = xfs_btree_check_sblock(cur, right, level, rbp))) |
457 | return error; | 463 | return error; |
458 | } | 464 | } |
@@ -474,34 +480,28 @@ xfs_alloc_delrec( | |||
474 | /* | 480 | /* |
475 | * It's a non-leaf. Move keys and pointers. | 481 | * It's a non-leaf. Move keys and pointers. |
476 | */ | 482 | */ |
477 | lkp = XFS_ALLOC_KEY_ADDR(left, be16_to_cpu(left->bb_numrecs) + 1, cur); | 483 | lkp = XFS_ALLOC_KEY_ADDR(left, lrecs + 1, cur); |
478 | lpp = XFS_ALLOC_PTR_ADDR(left, be16_to_cpu(left->bb_numrecs) + 1, cur); | 484 | lpp = XFS_ALLOC_PTR_ADDR(left, lrecs + 1, cur); |
479 | rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur); | 485 | rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur); |
480 | rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); | 486 | rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); |
481 | #ifdef DEBUG | 487 | #ifdef DEBUG |
482 | for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) { | 488 | for (i = 0; i < rrecs; i++) { |
483 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i]), level))) | 489 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i]), level))) |
484 | return error; | 490 | return error; |
485 | } | 491 | } |
486 | #endif | 492 | #endif |
487 | memcpy(lkp, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*lkp)); | 493 | memcpy(lkp, rkp, rrecs * sizeof(*lkp)); |
488 | memcpy(lpp, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*lpp)); | 494 | memcpy(lpp, rpp, rrecs * sizeof(*lpp)); |
489 | xfs_alloc_log_keys(cur, lbp, be16_to_cpu(left->bb_numrecs) + 1, | 495 | xfs_alloc_log_keys(cur, lbp, lrecs + 1, lrecs + rrecs); |
490 | be16_to_cpu(left->bb_numrecs) + | 496 | xfs_alloc_log_ptrs(cur, lbp, lrecs + 1, lrecs + rrecs); |
491 | be16_to_cpu(right->bb_numrecs)); | ||
492 | xfs_alloc_log_ptrs(cur, lbp, be16_to_cpu(left->bb_numrecs) + 1, | ||
493 | be16_to_cpu(left->bb_numrecs) + | ||
494 | be16_to_cpu(right->bb_numrecs)); | ||
495 | } else { | 497 | } else { |
496 | /* | 498 | /* |
497 | * It's a leaf. Move records. | 499 | * It's a leaf. Move records. |
498 | */ | 500 | */ |
499 | lrp = XFS_ALLOC_REC_ADDR(left, be16_to_cpu(left->bb_numrecs) + 1, cur); | 501 | lrp = XFS_ALLOC_REC_ADDR(left, lrecs + 1, cur); |
500 | rrp = XFS_ALLOC_REC_ADDR(right, 1, cur); | 502 | rrp = XFS_ALLOC_REC_ADDR(right, 1, cur); |
501 | memcpy(lrp, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*lrp)); | 503 | memcpy(lrp, rrp, rrecs * sizeof(*lrp)); |
502 | xfs_alloc_log_recs(cur, lbp, be16_to_cpu(left->bb_numrecs) + 1, | 504 | xfs_alloc_log_recs(cur, lbp, lrecs + 1, lrecs + rrecs); |
503 | be16_to_cpu(left->bb_numrecs) + | ||
504 | be16_to_cpu(right->bb_numrecs)); | ||
505 | } | 505 | } |
506 | /* | 506 | /* |
507 | * If we joined with the left neighbor, set the buffer in the | 507 | * If we joined with the left neighbor, set the buffer in the |
@@ -509,7 +509,7 @@ xfs_alloc_delrec( | |||
509 | */ | 509 | */ |
510 | if (bp != lbp) { | 510 | if (bp != lbp) { |
511 | xfs_btree_setbuf(cur, level, lbp); | 511 | xfs_btree_setbuf(cur, level, lbp); |
512 | cur->bc_ptrs[level] += be16_to_cpu(left->bb_numrecs); | 512 | cur->bc_ptrs[level] += lrecs; |
513 | } | 513 | } |
514 | /* | 514 | /* |
515 | * If we joined with the right neighbor and there's a level above | 515 | * If we joined with the right neighbor and there's a level above |
@@ -521,7 +521,8 @@ xfs_alloc_delrec( | |||
521 | /* | 521 | /* |
522 | * Fix up the number of records in the surviving block. | 522 | * Fix up the number of records in the surviving block. |
523 | */ | 523 | */ |
524 | be16_add(&left->bb_numrecs, be16_to_cpu(right->bb_numrecs)); | 524 | lrecs += rrecs; |
525 | left->bb_numrecs = cpu_to_be16(lrecs); | ||
525 | /* | 526 | /* |
526 | * Fix up the right block pointer in the surviving block, and log it. | 527 | * Fix up the right block pointer in the surviving block, and log it. |
527 | */ | 528 | */ |
@@ -608,6 +609,7 @@ xfs_alloc_insrec( | |||
608 | xfs_btree_cur_t *ncur; /* new cursor to be used at next lvl */ | 609 | xfs_btree_cur_t *ncur; /* new cursor to be used at next lvl */ |
609 | xfs_alloc_key_t nkey; /* new key value, from split */ | 610 | xfs_alloc_key_t nkey; /* new key value, from split */ |
610 | xfs_alloc_rec_t nrec; /* new record value, for caller */ | 611 | xfs_alloc_rec_t nrec; /* new record value, for caller */ |
612 | int numrecs; | ||
611 | int optr; /* old ptr value */ | 613 | int optr; /* old ptr value */ |
612 | xfs_alloc_ptr_t *pp; /* pointer to btree addresses */ | 614 | xfs_alloc_ptr_t *pp; /* pointer to btree addresses */ |
613 | int ptr; /* index in btree block for this rec */ | 615 | int ptr; /* index in btree block for this rec */ |
@@ -653,13 +655,14 @@ xfs_alloc_insrec( | |||
653 | */ | 655 | */ |
654 | bp = cur->bc_bufs[level]; | 656 | bp = cur->bc_bufs[level]; |
655 | block = XFS_BUF_TO_ALLOC_BLOCK(bp); | 657 | block = XFS_BUF_TO_ALLOC_BLOCK(bp); |
658 | numrecs = be16_to_cpu(block->bb_numrecs); | ||
656 | #ifdef DEBUG | 659 | #ifdef DEBUG |
657 | if ((error = xfs_btree_check_sblock(cur, block, level, bp))) | 660 | if ((error = xfs_btree_check_sblock(cur, block, level, bp))) |
658 | return error; | 661 | return error; |
659 | /* | 662 | /* |
660 | * Check that the new entry is being inserted in the right place. | 663 | * Check that the new entry is being inserted in the right place. |
661 | */ | 664 | */ |
662 | if (ptr <= be16_to_cpu(block->bb_numrecs)) { | 665 | if (ptr <= numrecs) { |
663 | if (level == 0) { | 666 | if (level == 0) { |
664 | rp = XFS_ALLOC_REC_ADDR(block, ptr, cur); | 667 | rp = XFS_ALLOC_REC_ADDR(block, ptr, cur); |
665 | xfs_btree_check_rec(cur->bc_btnum, recp, rp); | 668 | xfs_btree_check_rec(cur->bc_btnum, recp, rp); |
@@ -670,12 +673,12 @@ xfs_alloc_insrec( | |||
670 | } | 673 | } |
671 | #endif | 674 | #endif |
672 | nbno = NULLAGBLOCK; | 675 | nbno = NULLAGBLOCK; |
673 | ncur = (xfs_btree_cur_t *)0; | 676 | ncur = NULL; |
674 | /* | 677 | /* |
675 | * If the block is full, we can't insert the new entry until we | 678 | * If the block is full, we can't insert the new entry until we |
676 | * make the block un-full. | 679 | * make the block un-full. |
677 | */ | 680 | */ |
678 | if (be16_to_cpu(block->bb_numrecs) == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { | 681 | if (numrecs == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { |
679 | /* | 682 | /* |
680 | * First, try shifting an entry to the right neighbor. | 683 | * First, try shifting an entry to the right neighbor. |
681 | */ | 684 | */ |
@@ -729,6 +732,7 @@ xfs_alloc_insrec( | |||
729 | * At this point we know there's room for our new entry in the block | 732 | * At this point we know there's room for our new entry in the block |
730 | * we're pointing at. | 733 | * we're pointing at. |
731 | */ | 734 | */ |
735 | numrecs = be16_to_cpu(block->bb_numrecs); | ||
732 | if (level > 0) { | 736 | if (level > 0) { |
733 | /* | 737 | /* |
734 | * It's a non-leaf entry. Make a hole for the new data | 738 | * It's a non-leaf entry. Make a hole for the new data |
@@ -737,15 +741,15 @@ xfs_alloc_insrec( | |||
737 | kp = XFS_ALLOC_KEY_ADDR(block, 1, cur); | 741 | kp = XFS_ALLOC_KEY_ADDR(block, 1, cur); |
738 | pp = XFS_ALLOC_PTR_ADDR(block, 1, cur); | 742 | pp = XFS_ALLOC_PTR_ADDR(block, 1, cur); |
739 | #ifdef DEBUG | 743 | #ifdef DEBUG |
740 | for (i = be16_to_cpu(block->bb_numrecs); i >= ptr; i--) { | 744 | for (i = numrecs; i >= ptr; i--) { |
741 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(pp[i - 1]), level))) | 745 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(pp[i - 1]), level))) |
742 | return error; | 746 | return error; |
743 | } | 747 | } |
744 | #endif | 748 | #endif |
745 | memmove(&kp[ptr], &kp[ptr - 1], | 749 | memmove(&kp[ptr], &kp[ptr - 1], |
746 | (be16_to_cpu(block->bb_numrecs) - ptr + 1) * sizeof(*kp)); | 750 | (numrecs - ptr + 1) * sizeof(*kp)); |
747 | memmove(&pp[ptr], &pp[ptr - 1], | 751 | memmove(&pp[ptr], &pp[ptr - 1], |
748 | (be16_to_cpu(block->bb_numrecs) - ptr + 1) * sizeof(*pp)); | 752 | (numrecs - ptr + 1) * sizeof(*pp)); |
749 | #ifdef DEBUG | 753 | #ifdef DEBUG |
750 | if ((error = xfs_btree_check_sptr(cur, *bnop, level))) | 754 | if ((error = xfs_btree_check_sptr(cur, *bnop, level))) |
751 | return error; | 755 | return error; |
@@ -755,11 +759,12 @@ xfs_alloc_insrec( | |||
755 | */ | 759 | */ |
756 | kp[ptr - 1] = key; | 760 | kp[ptr - 1] = key; |
757 | pp[ptr - 1] = cpu_to_be32(*bnop); | 761 | pp[ptr - 1] = cpu_to_be32(*bnop); |
758 | be16_add(&block->bb_numrecs, 1); | 762 | numrecs++; |
759 | xfs_alloc_log_keys(cur, bp, ptr, be16_to_cpu(block->bb_numrecs)); | 763 | block->bb_numrecs = cpu_to_be16(numrecs); |
760 | xfs_alloc_log_ptrs(cur, bp, ptr, be16_to_cpu(block->bb_numrecs)); | 764 | xfs_alloc_log_keys(cur, bp, ptr, numrecs); |
765 | xfs_alloc_log_ptrs(cur, bp, ptr, numrecs); | ||
761 | #ifdef DEBUG | 766 | #ifdef DEBUG |
762 | if (ptr < be16_to_cpu(block->bb_numrecs)) | 767 | if (ptr < numrecs) |
763 | xfs_btree_check_key(cur->bc_btnum, kp + ptr - 1, | 768 | xfs_btree_check_key(cur->bc_btnum, kp + ptr - 1, |
764 | kp + ptr); | 769 | kp + ptr); |
765 | #endif | 770 | #endif |
@@ -769,16 +774,17 @@ xfs_alloc_insrec( | |||
769 | */ | 774 | */ |
770 | rp = XFS_ALLOC_REC_ADDR(block, 1, cur); | 775 | rp = XFS_ALLOC_REC_ADDR(block, 1, cur); |
771 | memmove(&rp[ptr], &rp[ptr - 1], | 776 | memmove(&rp[ptr], &rp[ptr - 1], |
772 | (be16_to_cpu(block->bb_numrecs) - ptr + 1) * sizeof(*rp)); | 777 | (numrecs - ptr + 1) * sizeof(*rp)); |
773 | /* | 778 | /* |
774 | * Now stuff the new record in, bump numrecs | 779 | * Now stuff the new record in, bump numrecs |
775 | * and log the new data. | 780 | * and log the new data. |
776 | */ | 781 | */ |
777 | rp[ptr - 1] = *recp; /* INT_: struct copy */ | 782 | rp[ptr - 1] = *recp; |
778 | be16_add(&block->bb_numrecs, 1); | 783 | numrecs++; |
779 | xfs_alloc_log_recs(cur, bp, ptr, be16_to_cpu(block->bb_numrecs)); | 784 | block->bb_numrecs = cpu_to_be16(numrecs); |
785 | xfs_alloc_log_recs(cur, bp, ptr, numrecs); | ||
780 | #ifdef DEBUG | 786 | #ifdef DEBUG |
781 | if (ptr < be16_to_cpu(block->bb_numrecs)) | 787 | if (ptr < numrecs) |
782 | xfs_btree_check_rec(cur->bc_btnum, rp + ptr - 1, | 788 | xfs_btree_check_rec(cur->bc_btnum, rp + ptr - 1, |
783 | rp + ptr); | 789 | rp + ptr); |
784 | #endif | 790 | #endif |
@@ -819,8 +825,8 @@ xfs_alloc_insrec( | |||
819 | */ | 825 | */ |
820 | *bnop = nbno; | 826 | *bnop = nbno; |
821 | if (nbno != NULLAGBLOCK) { | 827 | if (nbno != NULLAGBLOCK) { |
822 | *recp = nrec; /* INT_: struct copy */ | 828 | *recp = nrec; |
823 | *curp = ncur; /* INT_: struct copy */ | 829 | *curp = ncur; |
824 | } | 830 | } |
825 | *stat = 1; | 831 | *stat = 1; |
826 | return 0; | 832 | return 0; |
@@ -981,7 +987,7 @@ xfs_alloc_lookup( | |||
981 | */ | 987 | */ |
982 | bp = cur->bc_bufs[level]; | 988 | bp = cur->bc_bufs[level]; |
983 | if (bp && XFS_BUF_ADDR(bp) != d) | 989 | if (bp && XFS_BUF_ADDR(bp) != d) |
984 | bp = (xfs_buf_t *)0; | 990 | bp = NULL; |
985 | if (!bp) { | 991 | if (!bp) { |
986 | /* | 992 | /* |
987 | * Need to get a new buffer. Read it, then | 993 | * Need to get a new buffer. Read it, then |
@@ -1229,7 +1235,7 @@ xfs_alloc_lshift( | |||
1229 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*rpp), level))) | 1235 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*rpp), level))) |
1230 | return error; | 1236 | return error; |
1231 | #endif | 1237 | #endif |
1232 | *lpp = *rpp; /* INT_: copy */ | 1238 | *lpp = *rpp; |
1233 | xfs_alloc_log_ptrs(cur, lbp, nrec, nrec); | 1239 | xfs_alloc_log_ptrs(cur, lbp, nrec, nrec); |
1234 | xfs_btree_check_key(cur->bc_btnum, lkp - 1, lkp); | 1240 | xfs_btree_check_key(cur->bc_btnum, lkp - 1, lkp); |
1235 | } | 1241 | } |
@@ -1406,8 +1412,8 @@ xfs_alloc_newroot( | |||
1406 | 1412 | ||
1407 | kp = XFS_ALLOC_KEY_ADDR(new, 1, cur); | 1413 | kp = XFS_ALLOC_KEY_ADDR(new, 1, cur); |
1408 | if (be16_to_cpu(left->bb_level) > 0) { | 1414 | if (be16_to_cpu(left->bb_level) > 0) { |
1409 | kp[0] = *XFS_ALLOC_KEY_ADDR(left, 1, cur); /* INT_: structure copy */ | 1415 | kp[0] = *XFS_ALLOC_KEY_ADDR(left, 1, cur); |
1410 | kp[1] = *XFS_ALLOC_KEY_ADDR(right, 1, cur);/* INT_: structure copy */ | 1416 | kp[1] = *XFS_ALLOC_KEY_ADDR(right, 1, cur); |
1411 | } else { | 1417 | } else { |
1412 | xfs_alloc_rec_t *rp; /* btree record pointer */ | 1418 | xfs_alloc_rec_t *rp; /* btree record pointer */ |
1413 | 1419 | ||
@@ -1527,8 +1533,8 @@ xfs_alloc_rshift( | |||
1527 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*lpp), level))) | 1533 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*lpp), level))) |
1528 | return error; | 1534 | return error; |
1529 | #endif | 1535 | #endif |
1530 | *rkp = *lkp; /* INT_: copy */ | 1536 | *rkp = *lkp; |
1531 | *rpp = *lpp; /* INT_: copy */ | 1537 | *rpp = *lpp; |
1532 | xfs_alloc_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); | 1538 | xfs_alloc_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1533 | xfs_alloc_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); | 1539 | xfs_alloc_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1534 | xfs_btree_check_key(cur->bc_btnum, rkp, rkp + 1); | 1540 | xfs_btree_check_key(cur->bc_btnum, rkp, rkp + 1); |
@@ -2044,7 +2050,7 @@ xfs_alloc_insert( | |||
2044 | nbno = NULLAGBLOCK; | 2050 | nbno = NULLAGBLOCK; |
2045 | nrec.ar_startblock = cpu_to_be32(cur->bc_rec.a.ar_startblock); | 2051 | nrec.ar_startblock = cpu_to_be32(cur->bc_rec.a.ar_startblock); |
2046 | nrec.ar_blockcount = cpu_to_be32(cur->bc_rec.a.ar_blockcount); | 2052 | nrec.ar_blockcount = cpu_to_be32(cur->bc_rec.a.ar_blockcount); |
2047 | ncur = (xfs_btree_cur_t *)0; | 2053 | ncur = NULL; |
2048 | pcur = cur; | 2054 | pcur = cur; |
2049 | /* | 2055 | /* |
2050 | * Loop going up the tree, starting at the leaf level. | 2056 | * Loop going up the tree, starting at the leaf level. |
@@ -2076,7 +2082,7 @@ xfs_alloc_insert( | |||
2076 | */ | 2082 | */ |
2077 | if (ncur) { | 2083 | if (ncur) { |
2078 | pcur = ncur; | 2084 | pcur = ncur; |
2079 | ncur = (xfs_btree_cur_t *)0; | 2085 | ncur = NULL; |
2080 | } | 2086 | } |
2081 | } while (nbno != NULLAGBLOCK); | 2087 | } while (nbno != NULLAGBLOCK); |
2082 | *stat = i; | 2088 | *stat = i; |
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c index 1a2101043275..9ada7bdbae52 100644 --- a/fs/xfs/xfs_attr.c +++ b/fs/xfs/xfs_attr.c | |||
@@ -91,7 +91,6 @@ STATIC int xfs_attr_refillstate(xfs_da_state_t *state); | |||
91 | /* | 91 | /* |
92 | * Routines to manipulate out-of-line attribute values. | 92 | * Routines to manipulate out-of-line attribute values. |
93 | */ | 93 | */ |
94 | STATIC int xfs_attr_rmtval_get(xfs_da_args_t *args); | ||
95 | STATIC int xfs_attr_rmtval_set(xfs_da_args_t *args); | 94 | STATIC int xfs_attr_rmtval_set(xfs_da_args_t *args); |
96 | STATIC int xfs_attr_rmtval_remove(xfs_da_args_t *args); | 95 | STATIC int xfs_attr_rmtval_remove(xfs_da_args_t *args); |
97 | 96 | ||
@@ -180,7 +179,7 @@ xfs_attr_get(bhv_desc_t *bdp, const char *name, char *value, int *valuelenp, | |||
180 | return(error); | 179 | return(error); |
181 | } | 180 | } |
182 | 181 | ||
183 | STATIC int | 182 | int |
184 | xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen, | 183 | xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen, |
185 | char *value, int valuelen, int flags) | 184 | char *value, int valuelen, int flags) |
186 | { | 185 | { |
@@ -440,7 +439,7 @@ xfs_attr_set(bhv_desc_t *bdp, const char *name, char *value, int valuelen, int f | |||
440 | * Generic handler routine to remove a name from an attribute list. | 439 | * Generic handler routine to remove a name from an attribute list. |
441 | * Transitions attribute list from Btree to shortform as necessary. | 440 | * Transitions attribute list from Btree to shortform as necessary. |
442 | */ | 441 | */ |
443 | STATIC int | 442 | int |
444 | xfs_attr_remove_int(xfs_inode_t *dp, const char *name, int namelen, int flags) | 443 | xfs_attr_remove_int(xfs_inode_t *dp, const char *name, int namelen, int flags) |
445 | { | 444 | { |
446 | xfs_da_args_t args; | 445 | xfs_da_args_t args; |
@@ -591,6 +590,110 @@ xfs_attr_remove(bhv_desc_t *bdp, const char *name, int flags, struct cred *cred) | |||
591 | return xfs_attr_remove_int(dp, name, namelen, flags); | 590 | return xfs_attr_remove_int(dp, name, namelen, flags); |
592 | } | 591 | } |
593 | 592 | ||
593 | int /* error */ | ||
594 | xfs_attr_list_int(xfs_attr_list_context_t *context) | ||
595 | { | ||
596 | int error; | ||
597 | xfs_inode_t *dp = context->dp; | ||
598 | |||
599 | /* | ||
600 | * Decide on what work routines to call based on the inode size. | ||
601 | */ | ||
602 | if (XFS_IFORK_Q(dp) == 0 || | ||
603 | (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && | ||
604 | dp->i_d.di_anextents == 0)) { | ||
605 | error = 0; | ||
606 | } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { | ||
607 | error = xfs_attr_shortform_list(context); | ||
608 | } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { | ||
609 | error = xfs_attr_leaf_list(context); | ||
610 | } else { | ||
611 | error = xfs_attr_node_list(context); | ||
612 | } | ||
613 | return error; | ||
614 | } | ||
615 | |||
616 | #define ATTR_ENTBASESIZE /* minimum bytes used by an attr */ \ | ||
617 | (((struct attrlist_ent *) 0)->a_name - (char *) 0) | ||
618 | #define ATTR_ENTSIZE(namelen) /* actual bytes used by an attr */ \ | ||
619 | ((ATTR_ENTBASESIZE + (namelen) + 1 + sizeof(u_int32_t)-1) \ | ||
620 | & ~(sizeof(u_int32_t)-1)) | ||
621 | |||
622 | /* | ||
623 | * Format an attribute and copy it out to the user's buffer. | ||
624 | * Take care to check values and protect against them changing later, | ||
625 | * we may be reading them directly out of a user buffer. | ||
626 | */ | ||
627 | /*ARGSUSED*/ | ||
628 | STATIC int | ||
629 | xfs_attr_put_listent(xfs_attr_list_context_t *context, attrnames_t *namesp, | ||
630 | char *name, int namelen, | ||
631 | int valuelen, char *value) | ||
632 | { | ||
633 | attrlist_ent_t *aep; | ||
634 | int arraytop; | ||
635 | |||
636 | ASSERT(!(context->flags & ATTR_KERNOVAL)); | ||
637 | ASSERT(context->count >= 0); | ||
638 | ASSERT(context->count < (ATTR_MAX_VALUELEN/8)); | ||
639 | ASSERT(context->firstu >= sizeof(*context->alist)); | ||
640 | ASSERT(context->firstu <= context->bufsize); | ||
641 | |||
642 | arraytop = sizeof(*context->alist) + | ||
643 | context->count * sizeof(context->alist->al_offset[0]); | ||
644 | context->firstu -= ATTR_ENTSIZE(namelen); | ||
645 | if (context->firstu < arraytop) { | ||
646 | xfs_attr_trace_l_c("buffer full", context); | ||
647 | context->alist->al_more = 1; | ||
648 | context->seen_enough = 1; | ||
649 | return 1; | ||
650 | } | ||
651 | |||
652 | aep = (attrlist_ent_t *)&(((char *)context->alist)[ context->firstu ]); | ||
653 | aep->a_valuelen = valuelen; | ||
654 | memcpy(aep->a_name, name, namelen); | ||
655 | aep->a_name[ namelen ] = 0; | ||
656 | context->alist->al_offset[ context->count++ ] = context->firstu; | ||
657 | context->alist->al_count = context->count; | ||
658 | xfs_attr_trace_l_c("add", context); | ||
659 | return 0; | ||
660 | } | ||
661 | |||
662 | STATIC int | ||
663 | xfs_attr_kern_list(xfs_attr_list_context_t *context, attrnames_t *namesp, | ||
664 | char *name, int namelen, | ||
665 | int valuelen, char *value) | ||
666 | { | ||
667 | char *offset; | ||
668 | int arraytop; | ||
669 | |||
670 | ASSERT(context->count >= 0); | ||
671 | |||
672 | arraytop = context->count + namesp->attr_namelen + namelen + 1; | ||
673 | if (arraytop > context->firstu) { | ||
674 | context->count = -1; /* insufficient space */ | ||
675 | return 1; | ||
676 | } | ||
677 | offset = (char *)context->alist + context->count; | ||
678 | strncpy(offset, namesp->attr_name, namesp->attr_namelen); | ||
679 | offset += namesp->attr_namelen; | ||
680 | strncpy(offset, name, namelen); /* real name */ | ||
681 | offset += namelen; | ||
682 | *offset = '\0'; | ||
683 | context->count += namesp->attr_namelen + namelen + 1; | ||
684 | return 0; | ||
685 | } | ||
686 | |||
687 | /*ARGSUSED*/ | ||
688 | STATIC int | ||
689 | xfs_attr_kern_list_sizes(xfs_attr_list_context_t *context, attrnames_t *namesp, | ||
690 | char *name, int namelen, | ||
691 | int valuelen, char *value) | ||
692 | { | ||
693 | context->count += namesp->attr_namelen + namelen + 1; | ||
694 | return 0; | ||
695 | } | ||
696 | |||
594 | /* | 697 | /* |
595 | * Generate a list of extended attribute names and optionally | 698 | * Generate a list of extended attribute names and optionally |
596 | * also value lengths. Positive return value follows the XFS | 699 | * also value lengths. Positive return value follows the XFS |
@@ -615,13 +718,13 @@ xfs_attr_list(bhv_desc_t *bdp, char *buffer, int bufsize, int flags, | |||
615 | return(XFS_ERROR(EINVAL)); | 718 | return(XFS_ERROR(EINVAL)); |
616 | if ((cursor->initted == 0) && | 719 | if ((cursor->initted == 0) && |
617 | (cursor->hashval || cursor->blkno || cursor->offset)) | 720 | (cursor->hashval || cursor->blkno || cursor->offset)) |
618 | return(XFS_ERROR(EINVAL)); | 721 | return XFS_ERROR(EINVAL); |
619 | 722 | ||
620 | /* | 723 | /* |
621 | * Check for a properly aligned buffer. | 724 | * Check for a properly aligned buffer. |
622 | */ | 725 | */ |
623 | if (((long)buffer) & (sizeof(int)-1)) | 726 | if (((long)buffer) & (sizeof(int)-1)) |
624 | return(XFS_ERROR(EFAULT)); | 727 | return XFS_ERROR(EFAULT); |
625 | if (flags & ATTR_KERNOVAL) | 728 | if (flags & ATTR_KERNOVAL) |
626 | bufsize = 0; | 729 | bufsize = 0; |
627 | 730 | ||
@@ -634,53 +737,47 @@ xfs_attr_list(bhv_desc_t *bdp, char *buffer, int bufsize, int flags, | |||
634 | context.dupcnt = 0; | 737 | context.dupcnt = 0; |
635 | context.resynch = 1; | 738 | context.resynch = 1; |
636 | context.flags = flags; | 739 | context.flags = flags; |
637 | if (!(flags & ATTR_KERNAMELS)) { | 740 | context.seen_enough = 0; |
741 | context.alist = (attrlist_t *)buffer; | ||
742 | context.put_value = 0; | ||
743 | |||
744 | if (flags & ATTR_KERNAMELS) { | ||
745 | context.bufsize = bufsize; | ||
746 | context.firstu = context.bufsize; | ||
747 | if (flags & ATTR_KERNOVAL) | ||
748 | context.put_listent = xfs_attr_kern_list_sizes; | ||
749 | else | ||
750 | context.put_listent = xfs_attr_kern_list; | ||
751 | } else { | ||
638 | context.bufsize = (bufsize & ~(sizeof(int)-1)); /* align */ | 752 | context.bufsize = (bufsize & ~(sizeof(int)-1)); /* align */ |
639 | context.firstu = context.bufsize; | 753 | context.firstu = context.bufsize; |
640 | context.alist = (attrlist_t *)buffer; | ||
641 | context.alist->al_count = 0; | 754 | context.alist->al_count = 0; |
642 | context.alist->al_more = 0; | 755 | context.alist->al_more = 0; |
643 | context.alist->al_offset[0] = context.bufsize; | 756 | context.alist->al_offset[0] = context.bufsize; |
644 | } | 757 | context.put_listent = xfs_attr_put_listent; |
645 | else { | ||
646 | context.bufsize = bufsize; | ||
647 | context.firstu = context.bufsize; | ||
648 | context.alist = (attrlist_t *)buffer; | ||
649 | } | 758 | } |
650 | 759 | ||
651 | if (XFS_FORCED_SHUTDOWN(dp->i_mount)) | 760 | if (XFS_FORCED_SHUTDOWN(dp->i_mount)) |
652 | return (EIO); | 761 | return EIO; |
653 | 762 | ||
654 | xfs_ilock(dp, XFS_ILOCK_SHARED); | 763 | xfs_ilock(dp, XFS_ILOCK_SHARED); |
655 | /* | ||
656 | * Decide on what work routines to call based on the inode size. | ||
657 | */ | ||
658 | xfs_attr_trace_l_c("syscall start", &context); | 764 | xfs_attr_trace_l_c("syscall start", &context); |
659 | if (XFS_IFORK_Q(dp) == 0 || | 765 | |
660 | (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && | 766 | error = xfs_attr_list_int(&context); |
661 | dp->i_d.di_anextents == 0)) { | 767 | |
662 | error = 0; | ||
663 | } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { | ||
664 | error = xfs_attr_shortform_list(&context); | ||
665 | } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { | ||
666 | error = xfs_attr_leaf_list(&context); | ||
667 | } else { | ||
668 | error = xfs_attr_node_list(&context); | ||
669 | } | ||
670 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | 768 | xfs_iunlock(dp, XFS_ILOCK_SHARED); |
671 | xfs_attr_trace_l_c("syscall end", &context); | 769 | xfs_attr_trace_l_c("syscall end", &context); |
672 | 770 | ||
673 | if (!(context.flags & (ATTR_KERNOVAL|ATTR_KERNAMELS))) { | 771 | if (context.flags & (ATTR_KERNOVAL|ATTR_KERNAMELS)) { |
674 | ASSERT(error >= 0); | 772 | /* must return negated buffer size or the error */ |
675 | } | ||
676 | else { /* must return negated buffer size or the error */ | ||
677 | if (context.count < 0) | 773 | if (context.count < 0) |
678 | error = XFS_ERROR(ERANGE); | 774 | error = XFS_ERROR(ERANGE); |
679 | else | 775 | else |
680 | error = -context.count; | 776 | error = -context.count; |
681 | } | 777 | } else |
778 | ASSERT(error >= 0); | ||
682 | 779 | ||
683 | return(error); | 780 | return error; |
684 | } | 781 | } |
685 | 782 | ||
686 | int /* error */ | 783 | int /* error */ |
@@ -1122,19 +1219,19 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context) | |||
1122 | context->cursor->blkno = 0; | 1219 | context->cursor->blkno = 0; |
1123 | error = xfs_da_read_buf(NULL, context->dp, 0, -1, &bp, XFS_ATTR_FORK); | 1220 | error = xfs_da_read_buf(NULL, context->dp, 0, -1, &bp, XFS_ATTR_FORK); |
1124 | if (error) | 1221 | if (error) |
1125 | return(error); | 1222 | return XFS_ERROR(error); |
1126 | ASSERT(bp != NULL); | 1223 | ASSERT(bp != NULL); |
1127 | leaf = bp->data; | 1224 | leaf = bp->data; |
1128 | if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC)) { | 1225 | if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC)) { |
1129 | XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW, | 1226 | XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW, |
1130 | context->dp->i_mount, leaf); | 1227 | context->dp->i_mount, leaf); |
1131 | xfs_da_brelse(NULL, bp); | 1228 | xfs_da_brelse(NULL, bp); |
1132 | return(XFS_ERROR(EFSCORRUPTED)); | 1229 | return XFS_ERROR(EFSCORRUPTED); |
1133 | } | 1230 | } |
1134 | 1231 | ||
1135 | (void)xfs_attr_leaf_list_int(bp, context); | 1232 | error = xfs_attr_leaf_list_int(bp, context); |
1136 | xfs_da_brelse(NULL, bp); | 1233 | xfs_da_brelse(NULL, bp); |
1137 | return(0); | 1234 | return XFS_ERROR(error); |
1138 | } | 1235 | } |
1139 | 1236 | ||
1140 | 1237 | ||
@@ -1858,8 +1955,12 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1858 | return(XFS_ERROR(EFSCORRUPTED)); | 1955 | return(XFS_ERROR(EFSCORRUPTED)); |
1859 | } | 1956 | } |
1860 | error = xfs_attr_leaf_list_int(bp, context); | 1957 | error = xfs_attr_leaf_list_int(bp, context); |
1861 | if (error || !leaf->hdr.info.forw) | 1958 | if (error) { |
1862 | break; /* not really an error, buffer full or EOF */ | 1959 | xfs_da_brelse(NULL, bp); |
1960 | return error; | ||
1961 | } | ||
1962 | if (context->seen_enough || leaf->hdr.info.forw == 0) | ||
1963 | break; | ||
1863 | cursor->blkno = be32_to_cpu(leaf->hdr.info.forw); | 1964 | cursor->blkno = be32_to_cpu(leaf->hdr.info.forw); |
1864 | xfs_da_brelse(NULL, bp); | 1965 | xfs_da_brelse(NULL, bp); |
1865 | error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1, | 1966 | error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1, |
@@ -1886,7 +1987,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1886 | * Read the value associated with an attribute from the out-of-line buffer | 1987 | * Read the value associated with an attribute from the out-of-line buffer |
1887 | * that we stored it in. | 1988 | * that we stored it in. |
1888 | */ | 1989 | */ |
1889 | STATIC int | 1990 | int |
1890 | xfs_attr_rmtval_get(xfs_da_args_t *args) | 1991 | xfs_attr_rmtval_get(xfs_da_args_t *args) |
1891 | { | 1992 | { |
1892 | xfs_bmbt_irec_t map[ATTR_RMTVALUE_MAPSIZE]; | 1993 | xfs_bmbt_irec_t map[ATTR_RMTVALUE_MAPSIZE]; |
diff --git a/fs/xfs/xfs_attr.h b/fs/xfs/xfs_attr.h index 981633f6c077..783977d3ea71 100644 --- a/fs/xfs/xfs_attr.h +++ b/fs/xfs/xfs_attr.h | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | struct cred; | 38 | struct cred; |
39 | struct bhv_vnode; | 39 | struct bhv_vnode; |
40 | struct xfs_attr_list_context; | ||
40 | 41 | ||
41 | typedef int (*attrset_t)(struct bhv_vnode *, char *, void *, size_t, int); | 42 | typedef int (*attrset_t)(struct bhv_vnode *, char *, void *, size_t, int); |
42 | typedef int (*attrget_t)(struct bhv_vnode *, char *, void *, size_t, int); | 43 | typedef int (*attrget_t)(struct bhv_vnode *, char *, void *, size_t, int); |
@@ -160,13 +161,16 @@ struct xfs_da_args; | |||
160 | */ | 161 | */ |
161 | int xfs_attr_get(bhv_desc_t *, const char *, char *, int *, int, struct cred *); | 162 | int xfs_attr_get(bhv_desc_t *, const char *, char *, int *, int, struct cred *); |
162 | int xfs_attr_set(bhv_desc_t *, const char *, char *, int, int, struct cred *); | 163 | int xfs_attr_set(bhv_desc_t *, const char *, char *, int, int, struct cred *); |
164 | int xfs_attr_set_int(struct xfs_inode *, const char *, int, char *, int, int); | ||
163 | int xfs_attr_remove(bhv_desc_t *, const char *, int, struct cred *); | 165 | int xfs_attr_remove(bhv_desc_t *, const char *, int, struct cred *); |
164 | int xfs_attr_list(bhv_desc_t *, char *, int, int, | 166 | int xfs_attr_remove_int(struct xfs_inode *, const char *, int, int); |
165 | struct attrlist_cursor_kern *, struct cred *); | 167 | int xfs_attr_list(bhv_desc_t *, char *, int, int, struct attrlist_cursor_kern *, struct cred *); |
168 | int xfs_attr_list_int(struct xfs_attr_list_context *); | ||
166 | int xfs_attr_inactive(struct xfs_inode *dp); | 169 | int xfs_attr_inactive(struct xfs_inode *dp); |
167 | 170 | ||
168 | int xfs_attr_shortform_getvalue(struct xfs_da_args *); | 171 | int xfs_attr_shortform_getvalue(struct xfs_da_args *); |
169 | int xfs_attr_fetch(struct xfs_inode *, const char *, int, | 172 | int xfs_attr_fetch(struct xfs_inode *, const char *, int, |
170 | char *, int *, int, struct cred *); | 173 | char *, int *, int, struct cred *); |
174 | int xfs_attr_rmtval_get(struct xfs_da_args *args); | ||
171 | 175 | ||
172 | #endif /* __XFS_ATTR_H__ */ | 176 | #endif /* __XFS_ATTR_H__ */ |
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index 9455051f0120..9719bbef122c 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c | |||
@@ -89,9 +89,46 @@ STATIC void xfs_attr_leaf_moveents(xfs_attr_leafblock_t *src_leaf, | |||
89 | int dst_start, int move_count, | 89 | int dst_start, int move_count, |
90 | xfs_mount_t *mp); | 90 | xfs_mount_t *mp); |
91 | STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index); | 91 | STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index); |
92 | STATIC int xfs_attr_put_listent(xfs_attr_list_context_t *context, | 92 | |
93 | attrnames_t *, char *name, int namelen, | 93 | /*======================================================================== |
94 | int valuelen); | 94 | * Namespace helper routines |
95 | *========================================================================*/ | ||
96 | |||
97 | STATIC inline attrnames_t * | ||
98 | xfs_attr_flags_namesp(int flags) | ||
99 | { | ||
100 | return ((flags & XFS_ATTR_SECURE) ? &attr_secure: | ||
101 | ((flags & XFS_ATTR_ROOT) ? &attr_trusted : &attr_user)); | ||
102 | } | ||
103 | |||
104 | /* | ||
105 | * If namespace bits don't match return 0. | ||
106 | * If all match then return 1. | ||
107 | */ | ||
108 | STATIC inline int | ||
109 | xfs_attr_namesp_match(int arg_flags, int ondisk_flags) | ||
110 | { | ||
111 | return XFS_ATTR_NSP_ONDISK(ondisk_flags) == XFS_ATTR_NSP_ARGS_TO_ONDISK(arg_flags); | ||
112 | } | ||
113 | |||
114 | /* | ||
115 | * If namespace bits don't match and we don't have an override for it | ||
116 | * then return 0. | ||
117 | * If all match or are overridable then return 1. | ||
118 | */ | ||
119 | STATIC inline int | ||
120 | xfs_attr_namesp_match_overrides(int arg_flags, int ondisk_flags) | ||
121 | { | ||
122 | if (((arg_flags & ATTR_SECURE) == 0) != | ||
123 | ((ondisk_flags & XFS_ATTR_SECURE) == 0) && | ||
124 | !(arg_flags & ATTR_KERNORMALS)) | ||
125 | return 0; | ||
126 | if (((arg_flags & ATTR_ROOT) == 0) != | ||
127 | ((ondisk_flags & XFS_ATTR_ROOT) == 0) && | ||
128 | !(arg_flags & ATTR_KERNROOTLS)) | ||
129 | return 0; | ||
130 | return 1; | ||
131 | } | ||
95 | 132 | ||
96 | 133 | ||
97 | /*======================================================================== | 134 | /*======================================================================== |
@@ -228,11 +265,7 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) | |||
228 | continue; | 265 | continue; |
229 | if (memcmp(args->name, sfe->nameval, args->namelen) != 0) | 266 | if (memcmp(args->name, sfe->nameval, args->namelen) != 0) |
230 | continue; | 267 | continue; |
231 | if (((args->flags & ATTR_SECURE) != 0) != | 268 | if (!xfs_attr_namesp_match(args->flags, sfe->flags)) |
232 | ((sfe->flags & XFS_ATTR_SECURE) != 0)) | ||
233 | continue; | ||
234 | if (((args->flags & ATTR_ROOT) != 0) != | ||
235 | ((sfe->flags & XFS_ATTR_ROOT) != 0)) | ||
236 | continue; | 269 | continue; |
237 | ASSERT(0); | 270 | ASSERT(0); |
238 | #endif | 271 | #endif |
@@ -246,8 +279,7 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) | |||
246 | 279 | ||
247 | sfe->namelen = args->namelen; | 280 | sfe->namelen = args->namelen; |
248 | sfe->valuelen = args->valuelen; | 281 | sfe->valuelen = args->valuelen; |
249 | sfe->flags = (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE : | 282 | sfe->flags = XFS_ATTR_NSP_ARGS_TO_ONDISK(args->flags); |
250 | ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0); | ||
251 | memcpy(sfe->nameval, args->name, args->namelen); | 283 | memcpy(sfe->nameval, args->name, args->namelen); |
252 | memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen); | 284 | memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen); |
253 | sf->hdr.count++; | 285 | sf->hdr.count++; |
@@ -282,11 +314,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) | |||
282 | continue; | 314 | continue; |
283 | if (memcmp(sfe->nameval, args->name, args->namelen) != 0) | 315 | if (memcmp(sfe->nameval, args->name, args->namelen) != 0) |
284 | continue; | 316 | continue; |
285 | if (((args->flags & ATTR_SECURE) != 0) != | 317 | if (!xfs_attr_namesp_match(args->flags, sfe->flags)) |
286 | ((sfe->flags & XFS_ATTR_SECURE) != 0)) | ||
287 | continue; | ||
288 | if (((args->flags & ATTR_ROOT) != 0) != | ||
289 | ((sfe->flags & XFS_ATTR_ROOT) != 0)) | ||
290 | continue; | 318 | continue; |
291 | break; | 319 | break; |
292 | } | 320 | } |
@@ -363,11 +391,7 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args) | |||
363 | continue; | 391 | continue; |
364 | if (memcmp(args->name, sfe->nameval, args->namelen) != 0) | 392 | if (memcmp(args->name, sfe->nameval, args->namelen) != 0) |
365 | continue; | 393 | continue; |
366 | if (((args->flags & ATTR_SECURE) != 0) != | 394 | if (!xfs_attr_namesp_match(args->flags, sfe->flags)) |
367 | ((sfe->flags & XFS_ATTR_SECURE) != 0)) | ||
368 | continue; | ||
369 | if (((args->flags & ATTR_ROOT) != 0) != | ||
370 | ((sfe->flags & XFS_ATTR_ROOT) != 0)) | ||
371 | continue; | 395 | continue; |
372 | return(XFS_ERROR(EEXIST)); | 396 | return(XFS_ERROR(EEXIST)); |
373 | } | 397 | } |
@@ -394,11 +418,7 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args) | |||
394 | continue; | 418 | continue; |
395 | if (memcmp(args->name, sfe->nameval, args->namelen) != 0) | 419 | if (memcmp(args->name, sfe->nameval, args->namelen) != 0) |
396 | continue; | 420 | continue; |
397 | if (((args->flags & ATTR_SECURE) != 0) != | 421 | if (!xfs_attr_namesp_match(args->flags, sfe->flags)) |
398 | ((sfe->flags & XFS_ATTR_SECURE) != 0)) | ||
399 | continue; | ||
400 | if (((args->flags & ATTR_ROOT) != 0) != | ||
401 | ((sfe->flags & XFS_ATTR_ROOT) != 0)) | ||
402 | continue; | 422 | continue; |
403 | if (args->flags & ATTR_KERNOVAL) { | 423 | if (args->flags & ATTR_KERNOVAL) { |
404 | args->valuelen = sfe->valuelen; | 424 | args->valuelen = sfe->valuelen; |
@@ -485,8 +505,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) | |||
485 | nargs.valuelen = sfe->valuelen; | 505 | nargs.valuelen = sfe->valuelen; |
486 | nargs.hashval = xfs_da_hashname((char *)sfe->nameval, | 506 | nargs.hashval = xfs_da_hashname((char *)sfe->nameval, |
487 | sfe->namelen); | 507 | sfe->namelen); |
488 | nargs.flags = (sfe->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : | 508 | nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags); |
489 | ((sfe->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0); | ||
490 | error = xfs_attr_leaf_lookup_int(bp, &nargs); /* set a->index */ | 509 | error = xfs_attr_leaf_lookup_int(bp, &nargs); /* set a->index */ |
491 | ASSERT(error == ENOATTR); | 510 | ASSERT(error == ENOATTR); |
492 | error = xfs_attr_leaf_add(bp, &nargs); | 511 | error = xfs_attr_leaf_add(bp, &nargs); |
@@ -520,6 +539,10 @@ xfs_attr_shortform_compare(const void *a, const void *b) | |||
520 | } | 539 | } |
521 | } | 540 | } |
522 | 541 | ||
542 | |||
543 | #define XFS_ISRESET_CURSOR(cursor) \ | ||
544 | (!((cursor)->initted) && !((cursor)->hashval) && \ | ||
545 | !((cursor)->blkno) && !((cursor)->offset)) | ||
523 | /* | 546 | /* |
524 | * Copy out entries of shortform attribute lists for attr_list(). | 547 | * Copy out entries of shortform attribute lists for attr_list(). |
525 | * Shortform attribute lists are not stored in hashval sorted order. | 548 | * Shortform attribute lists are not stored in hashval sorted order. |
@@ -537,6 +560,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
537 | xfs_attr_sf_entry_t *sfe; | 560 | xfs_attr_sf_entry_t *sfe; |
538 | xfs_inode_t *dp; | 561 | xfs_inode_t *dp; |
539 | int sbsize, nsbuf, count, i; | 562 | int sbsize, nsbuf, count, i; |
563 | int error; | ||
540 | 564 | ||
541 | ASSERT(context != NULL); | 565 | ASSERT(context != NULL); |
542 | dp = context->dp; | 566 | dp = context->dp; |
@@ -552,46 +576,51 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
552 | xfs_attr_trace_l_c("sf start", context); | 576 | xfs_attr_trace_l_c("sf start", context); |
553 | 577 | ||
554 | /* | 578 | /* |
555 | * If the buffer is large enough, do not bother with sorting. | 579 | * If the buffer is large enough and the cursor is at the start, |
580 | * do not bother with sorting since we will return everything in | ||
581 | * one buffer and another call using the cursor won't need to be | ||
582 | * made. | ||
556 | * Note the generous fudge factor of 16 overhead bytes per entry. | 583 | * Note the generous fudge factor of 16 overhead bytes per entry. |
584 | * If bufsize is zero then put_listent must be a search function | ||
585 | * and can just scan through what we have. | ||
557 | */ | 586 | */ |
558 | if ((dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize) { | 587 | if (context->bufsize == 0 || |
588 | (XFS_ISRESET_CURSOR(cursor) && | ||
589 | (dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize)) { | ||
559 | for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { | 590 | for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { |
560 | attrnames_t *namesp; | 591 | attrnames_t *namesp; |
561 | 592 | ||
562 | if (((context->flags & ATTR_SECURE) != 0) != | 593 | if (!xfs_attr_namesp_match_overrides(context->flags, sfe->flags)) { |
563 | ((sfe->flags & XFS_ATTR_SECURE) != 0) && | ||
564 | !(context->flags & ATTR_KERNORMALS)) { | ||
565 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); | ||
566 | continue; | ||
567 | } | ||
568 | if (((context->flags & ATTR_ROOT) != 0) != | ||
569 | ((sfe->flags & XFS_ATTR_ROOT) != 0) && | ||
570 | !(context->flags & ATTR_KERNROOTLS)) { | ||
571 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); | 594 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); |
572 | continue; | 595 | continue; |
573 | } | 596 | } |
574 | namesp = (sfe->flags & XFS_ATTR_SECURE) ? &attr_secure: | 597 | namesp = xfs_attr_flags_namesp(sfe->flags); |
575 | ((sfe->flags & XFS_ATTR_ROOT) ? &attr_trusted : | 598 | error = context->put_listent(context, |
576 | &attr_user); | 599 | namesp, |
577 | if (context->flags & ATTR_KERNOVAL) { | 600 | (char *)sfe->nameval, |
578 | ASSERT(context->flags & ATTR_KERNAMELS); | 601 | (int)sfe->namelen, |
579 | context->count += namesp->attr_namelen + | 602 | (int)sfe->valuelen, |
580 | sfe->namelen + 1; | 603 | (char*)&sfe->nameval[sfe->namelen]); |
581 | } | 604 | |
582 | else { | 605 | /* |
583 | if (xfs_attr_put_listent(context, namesp, | 606 | * Either search callback finished early or |
584 | (char *)sfe->nameval, | 607 | * didn't fit it all in the buffer after all. |
585 | (int)sfe->namelen, | 608 | */ |
586 | (int)sfe->valuelen)) | 609 | if (context->seen_enough) |
587 | break; | 610 | break; |
588 | } | 611 | |
612 | if (error) | ||
613 | return error; | ||
589 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); | 614 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); |
590 | } | 615 | } |
591 | xfs_attr_trace_l_c("sf big-gulp", context); | 616 | xfs_attr_trace_l_c("sf big-gulp", context); |
592 | return(0); | 617 | return(0); |
593 | } | 618 | } |
594 | 619 | ||
620 | /* do no more for a search callback */ | ||
621 | if (context->bufsize == 0) | ||
622 | return 0; | ||
623 | |||
595 | /* | 624 | /* |
596 | * It didn't all fit, so we have to sort everything on hashval. | 625 | * It didn't all fit, so we have to sort everything on hashval. |
597 | */ | 626 | */ |
@@ -614,15 +643,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
614 | kmem_free(sbuf, sbsize); | 643 | kmem_free(sbuf, sbsize); |
615 | return XFS_ERROR(EFSCORRUPTED); | 644 | return XFS_ERROR(EFSCORRUPTED); |
616 | } | 645 | } |
617 | if (((context->flags & ATTR_SECURE) != 0) != | 646 | if (!xfs_attr_namesp_match_overrides(context->flags, sfe->flags)) { |
618 | ((sfe->flags & XFS_ATTR_SECURE) != 0) && | ||
619 | !(context->flags & ATTR_KERNORMALS)) { | ||
620 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); | ||
621 | continue; | ||
622 | } | ||
623 | if (((context->flags & ATTR_ROOT) != 0) != | ||
624 | ((sfe->flags & XFS_ATTR_ROOT) != 0) && | ||
625 | !(context->flags & ATTR_KERNROOTLS)) { | ||
626 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); | 647 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); |
627 | continue; | 648 | continue; |
628 | } | 649 | } |
@@ -671,24 +692,22 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
671 | for ( ; i < nsbuf; i++, sbp++) { | 692 | for ( ; i < nsbuf; i++, sbp++) { |
672 | attrnames_t *namesp; | 693 | attrnames_t *namesp; |
673 | 694 | ||
674 | namesp = (sbp->flags & XFS_ATTR_SECURE) ? &attr_secure : | 695 | namesp = xfs_attr_flags_namesp(sbp->flags); |
675 | ((sbp->flags & XFS_ATTR_ROOT) ? &attr_trusted : | ||
676 | &attr_user); | ||
677 | 696 | ||
678 | if (cursor->hashval != sbp->hash) { | 697 | if (cursor->hashval != sbp->hash) { |
679 | cursor->hashval = sbp->hash; | 698 | cursor->hashval = sbp->hash; |
680 | cursor->offset = 0; | 699 | cursor->offset = 0; |
681 | } | 700 | } |
682 | if (context->flags & ATTR_KERNOVAL) { | 701 | error = context->put_listent(context, |
683 | ASSERT(context->flags & ATTR_KERNAMELS); | 702 | namesp, |
684 | context->count += namesp->attr_namelen + | 703 | sbp->name, |
685 | sbp->namelen + 1; | 704 | sbp->namelen, |
686 | } else { | 705 | sbp->valuelen, |
687 | if (xfs_attr_put_listent(context, namesp, | 706 | &sbp->name[sbp->namelen]); |
688 | sbp->name, sbp->namelen, | 707 | if (error) |
689 | sbp->valuelen)) | 708 | return error; |
690 | break; | 709 | if (context->seen_enough) |
691 | } | 710 | break; |
692 | cursor->offset++; | 711 | cursor->offset++; |
693 | } | 712 | } |
694 | 713 | ||
@@ -810,8 +829,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) | |||
810 | nargs.value = (char *)&name_loc->nameval[nargs.namelen]; | 829 | nargs.value = (char *)&name_loc->nameval[nargs.namelen]; |
811 | nargs.valuelen = be16_to_cpu(name_loc->valuelen); | 830 | nargs.valuelen = be16_to_cpu(name_loc->valuelen); |
812 | nargs.hashval = be32_to_cpu(entry->hashval); | 831 | nargs.hashval = be32_to_cpu(entry->hashval); |
813 | nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : | 832 | nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(entry->flags); |
814 | ((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0); | ||
815 | xfs_attr_shortform_add(&nargs, forkoff); | 833 | xfs_attr_shortform_add(&nargs, forkoff); |
816 | } | 834 | } |
817 | error = 0; | 835 | error = 0; |
@@ -1098,8 +1116,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) | |||
1098 | be16_to_cpu(map->size)); | 1116 | be16_to_cpu(map->size)); |
1099 | entry->hashval = cpu_to_be32(args->hashval); | 1117 | entry->hashval = cpu_to_be32(args->hashval); |
1100 | entry->flags = tmp ? XFS_ATTR_LOCAL : 0; | 1118 | entry->flags = tmp ? XFS_ATTR_LOCAL : 0; |
1101 | entry->flags |= (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE : | 1119 | entry->flags |= XFS_ATTR_NSP_ARGS_TO_ONDISK(args->flags); |
1102 | ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0); | ||
1103 | if (args->rename) { | 1120 | if (args->rename) { |
1104 | entry->flags |= XFS_ATTR_INCOMPLETE; | 1121 | entry->flags |= XFS_ATTR_INCOMPLETE; |
1105 | if ((args->blkno2 == args->blkno) && | 1122 | if ((args->blkno2 == args->blkno) && |
@@ -1926,7 +1943,7 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1926 | else | 1943 | else |
1927 | break; | 1944 | break; |
1928 | } | 1945 | } |
1929 | ASSERT((probe >= 0) && | 1946 | ASSERT((probe >= 0) && |
1930 | (!leaf->hdr.count | 1947 | (!leaf->hdr.count |
1931 | || (probe < be16_to_cpu(leaf->hdr.count)))); | 1948 | || (probe < be16_to_cpu(leaf->hdr.count)))); |
1932 | ASSERT((span <= 4) || (be32_to_cpu(entry->hashval) == hashval)); | 1949 | ASSERT((span <= 4) || (be32_to_cpu(entry->hashval) == hashval)); |
@@ -1971,14 +1988,9 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1971 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, probe); | 1988 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, probe); |
1972 | if (name_loc->namelen != args->namelen) | 1989 | if (name_loc->namelen != args->namelen) |
1973 | continue; | 1990 | continue; |
1974 | if (memcmp(args->name, (char *)name_loc->nameval, | 1991 | if (memcmp(args->name, (char *)name_loc->nameval, args->namelen) != 0) |
1975 | args->namelen) != 0) | ||
1976 | continue; | 1992 | continue; |
1977 | if (((args->flags & ATTR_SECURE) != 0) != | 1993 | if (!xfs_attr_namesp_match(args->flags, entry->flags)) |
1978 | ((entry->flags & XFS_ATTR_SECURE) != 0)) | ||
1979 | continue; | ||
1980 | if (((args->flags & ATTR_ROOT) != 0) != | ||
1981 | ((entry->flags & XFS_ATTR_ROOT) != 0)) | ||
1982 | continue; | 1994 | continue; |
1983 | args->index = probe; | 1995 | args->index = probe; |
1984 | return(XFS_ERROR(EEXIST)); | 1996 | return(XFS_ERROR(EEXIST)); |
@@ -1989,11 +2001,7 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1989 | if (memcmp(args->name, (char *)name_rmt->name, | 2001 | if (memcmp(args->name, (char *)name_rmt->name, |
1990 | args->namelen) != 0) | 2002 | args->namelen) != 0) |
1991 | continue; | 2003 | continue; |
1992 | if (((args->flags & ATTR_SECURE) != 0) != | 2004 | if (!xfs_attr_namesp_match(args->flags, entry->flags)) |
1993 | ((entry->flags & XFS_ATTR_SECURE) != 0)) | ||
1994 | continue; | ||
1995 | if (((args->flags & ATTR_ROOT) != 0) != | ||
1996 | ((entry->flags & XFS_ATTR_ROOT) != 0)) | ||
1997 | continue; | 2005 | continue; |
1998 | args->index = probe; | 2006 | args->index = probe; |
1999 | args->rmtblkno = be32_to_cpu(name_rmt->valueblk); | 2007 | args->rmtblkno = be32_to_cpu(name_rmt->valueblk); |
@@ -2312,8 +2320,6 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2312 | attrlist_cursor_kern_t *cursor; | 2320 | attrlist_cursor_kern_t *cursor; |
2313 | xfs_attr_leafblock_t *leaf; | 2321 | xfs_attr_leafblock_t *leaf; |
2314 | xfs_attr_leaf_entry_t *entry; | 2322 | xfs_attr_leaf_entry_t *entry; |
2315 | xfs_attr_leaf_name_local_t *name_loc; | ||
2316 | xfs_attr_leaf_name_remote_t *name_rmt; | ||
2317 | int retval, i; | 2323 | int retval, i; |
2318 | 2324 | ||
2319 | ASSERT(bp != NULL); | 2325 | ASSERT(bp != NULL); |
@@ -2355,9 +2361,8 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2355 | * We have found our place, start copying out the new attributes. | 2361 | * We have found our place, start copying out the new attributes. |
2356 | */ | 2362 | */ |
2357 | retval = 0; | 2363 | retval = 0; |
2358 | for ( ; (i < be16_to_cpu(leaf->hdr.count)) | 2364 | for ( ; (i < be16_to_cpu(leaf->hdr.count)); entry++, i++) { |
2359 | && (retval == 0); entry++, i++) { | 2365 | attrnames_t *namesp; |
2360 | attrnames_t *namesp; | ||
2361 | 2366 | ||
2362 | if (be32_to_cpu(entry->hashval) != cursor->hashval) { | 2367 | if (be32_to_cpu(entry->hashval) != cursor->hashval) { |
2363 | cursor->hashval = be32_to_cpu(entry->hashval); | 2368 | cursor->hashval = be32_to_cpu(entry->hashval); |
@@ -2366,115 +2371,69 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2366 | 2371 | ||
2367 | if (entry->flags & XFS_ATTR_INCOMPLETE) | 2372 | if (entry->flags & XFS_ATTR_INCOMPLETE) |
2368 | continue; /* skip incomplete entries */ | 2373 | continue; /* skip incomplete entries */ |
2369 | if (((context->flags & ATTR_SECURE) != 0) != | 2374 | if (!xfs_attr_namesp_match_overrides(context->flags, entry->flags)) |
2370 | ((entry->flags & XFS_ATTR_SECURE) != 0) && | 2375 | continue; |
2371 | !(context->flags & ATTR_KERNORMALS)) | 2376 | |
2372 | continue; /* skip non-matching entries */ | 2377 | namesp = xfs_attr_flags_namesp(entry->flags); |
2373 | if (((context->flags & ATTR_ROOT) != 0) != | ||
2374 | ((entry->flags & XFS_ATTR_ROOT) != 0) && | ||
2375 | !(context->flags & ATTR_KERNROOTLS)) | ||
2376 | continue; /* skip non-matching entries */ | ||
2377 | |||
2378 | namesp = (entry->flags & XFS_ATTR_SECURE) ? &attr_secure : | ||
2379 | ((entry->flags & XFS_ATTR_ROOT) ? &attr_trusted : | ||
2380 | &attr_user); | ||
2381 | 2378 | ||
2382 | if (entry->flags & XFS_ATTR_LOCAL) { | 2379 | if (entry->flags & XFS_ATTR_LOCAL) { |
2383 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i); | 2380 | xfs_attr_leaf_name_local_t *name_loc = |
2384 | if (context->flags & ATTR_KERNOVAL) { | 2381 | XFS_ATTR_LEAF_NAME_LOCAL(leaf, i); |
2385 | ASSERT(context->flags & ATTR_KERNAMELS); | 2382 | |
2386 | context->count += namesp->attr_namelen + | 2383 | retval = context->put_listent(context, |
2387 | (int)name_loc->namelen + 1; | 2384 | namesp, |
2388 | } else { | 2385 | (char *)name_loc->nameval, |
2389 | retval = xfs_attr_put_listent(context, namesp, | 2386 | (int)name_loc->namelen, |
2390 | (char *)name_loc->nameval, | 2387 | be16_to_cpu(name_loc->valuelen), |
2391 | (int)name_loc->namelen, | 2388 | (char *)&name_loc->nameval[name_loc->namelen]); |
2392 | be16_to_cpu(name_loc->valuelen)); | 2389 | if (retval) |
2393 | } | 2390 | return retval; |
2394 | } else { | 2391 | } else { |
2395 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); | 2392 | xfs_attr_leaf_name_remote_t *name_rmt = |
2396 | if (context->flags & ATTR_KERNOVAL) { | 2393 | XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); |
2397 | ASSERT(context->flags & ATTR_KERNAMELS); | 2394 | |
2398 | context->count += namesp->attr_namelen + | 2395 | int valuelen = be32_to_cpu(name_rmt->valuelen); |
2399 | (int)name_rmt->namelen + 1; | 2396 | |
2400 | } else { | 2397 | if (context->put_value) { |
2401 | retval = xfs_attr_put_listent(context, namesp, | 2398 | xfs_da_args_t args; |
2402 | (char *)name_rmt->name, | 2399 | |
2403 | (int)name_rmt->namelen, | 2400 | memset((char *)&args, 0, sizeof(args)); |
2404 | be32_to_cpu(name_rmt->valuelen)); | 2401 | args.dp = context->dp; |
2402 | args.whichfork = XFS_ATTR_FORK; | ||
2403 | args.valuelen = valuelen; | ||
2404 | args.value = kmem_alloc(valuelen, KM_SLEEP); | ||
2405 | args.rmtblkno = be32_to_cpu(name_rmt->valueblk); | ||
2406 | args.rmtblkcnt = XFS_B_TO_FSB(args.dp->i_mount, valuelen); | ||
2407 | retval = xfs_attr_rmtval_get(&args); | ||
2408 | if (retval) | ||
2409 | return retval; | ||
2410 | retval = context->put_listent(context, | ||
2411 | namesp, | ||
2412 | (char *)name_rmt->name, | ||
2413 | (int)name_rmt->namelen, | ||
2414 | valuelen, | ||
2415 | (char*)args.value); | ||
2416 | kmem_free(args.value, valuelen); | ||
2405 | } | 2417 | } |
2418 | else { | ||
2419 | retval = context->put_listent(context, | ||
2420 | namesp, | ||
2421 | (char *)name_rmt->name, | ||
2422 | (int)name_rmt->namelen, | ||
2423 | valuelen, | ||
2424 | NULL); | ||
2425 | } | ||
2426 | if (retval) | ||
2427 | return retval; | ||
2406 | } | 2428 | } |
2407 | if (retval == 0) { | 2429 | if (context->seen_enough) |
2408 | cursor->offset++; | 2430 | break; |
2409 | } | 2431 | cursor->offset++; |
2410 | } | 2432 | } |
2411 | xfs_attr_trace_l_cl("blk end", context, leaf); | 2433 | xfs_attr_trace_l_cl("blk end", context, leaf); |
2412 | return(retval); | 2434 | return(retval); |
2413 | } | 2435 | } |
2414 | 2436 | ||
2415 | #define ATTR_ENTBASESIZE /* minimum bytes used by an attr */ \ | ||
2416 | (((struct attrlist_ent *) 0)->a_name - (char *) 0) | ||
2417 | #define ATTR_ENTSIZE(namelen) /* actual bytes used by an attr */ \ | ||
2418 | ((ATTR_ENTBASESIZE + (namelen) + 1 + sizeof(u_int32_t)-1) \ | ||
2419 | & ~(sizeof(u_int32_t)-1)) | ||
2420 | |||
2421 | /* | ||
2422 | * Format an attribute and copy it out to the user's buffer. | ||
2423 | * Take care to check values and protect against them changing later, | ||
2424 | * we may be reading them directly out of a user buffer. | ||
2425 | */ | ||
2426 | /*ARGSUSED*/ | ||
2427 | STATIC int | ||
2428 | xfs_attr_put_listent(xfs_attr_list_context_t *context, | ||
2429 | attrnames_t *namesp, char *name, int namelen, int valuelen) | ||
2430 | { | ||
2431 | attrlist_ent_t *aep; | ||
2432 | int arraytop; | ||
2433 | |||
2434 | ASSERT(!(context->flags & ATTR_KERNOVAL)); | ||
2435 | if (context->flags & ATTR_KERNAMELS) { | ||
2436 | char *offset; | ||
2437 | |||
2438 | ASSERT(context->count >= 0); | ||
2439 | |||
2440 | arraytop = context->count + namesp->attr_namelen + namelen + 1; | ||
2441 | if (arraytop > context->firstu) { | ||
2442 | context->count = -1; /* insufficient space */ | ||
2443 | return(1); | ||
2444 | } | ||
2445 | offset = (char *)context->alist + context->count; | ||
2446 | strncpy(offset, namesp->attr_name, namesp->attr_namelen); | ||
2447 | offset += namesp->attr_namelen; | ||
2448 | strncpy(offset, name, namelen); /* real name */ | ||
2449 | offset += namelen; | ||
2450 | *offset = '\0'; | ||
2451 | context->count += namesp->attr_namelen + namelen + 1; | ||
2452 | return(0); | ||
2453 | } | ||
2454 | |||
2455 | ASSERT(context->count >= 0); | ||
2456 | ASSERT(context->count < (ATTR_MAX_VALUELEN/8)); | ||
2457 | ASSERT(context->firstu >= sizeof(*context->alist)); | ||
2458 | ASSERT(context->firstu <= context->bufsize); | ||
2459 | |||
2460 | arraytop = sizeof(*context->alist) + | ||
2461 | context->count * sizeof(context->alist->al_offset[0]); | ||
2462 | context->firstu -= ATTR_ENTSIZE(namelen); | ||
2463 | if (context->firstu < arraytop) { | ||
2464 | xfs_attr_trace_l_c("buffer full", context); | ||
2465 | context->alist->al_more = 1; | ||
2466 | return(1); | ||
2467 | } | ||
2468 | |||
2469 | aep = (attrlist_ent_t *)&(((char *)context->alist)[ context->firstu ]); | ||
2470 | aep->a_valuelen = valuelen; | ||
2471 | memcpy(aep->a_name, name, namelen); | ||
2472 | aep->a_name[ namelen ] = 0; | ||
2473 | context->alist->al_offset[ context->count++ ] = context->firstu; | ||
2474 | context->alist->al_count = context->count; | ||
2475 | xfs_attr_trace_l_c("add", context); | ||
2476 | return(0); | ||
2477 | } | ||
2478 | 2437 | ||
2479 | /*======================================================================== | 2438 | /*======================================================================== |
2480 | * Manage the INCOMPLETE flag in a leaf entry | 2439 | * Manage the INCOMPLETE flag in a leaf entry |
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h index 51c3ee156b2f..040f732ce1e2 100644 --- a/fs/xfs/xfs_attr_leaf.h +++ b/fs/xfs/xfs_attr_leaf.h | |||
@@ -130,6 +130,19 @@ typedef struct xfs_attr_leafblock { | |||
130 | #define XFS_ATTR_INCOMPLETE (1 << XFS_ATTR_INCOMPLETE_BIT) | 130 | #define XFS_ATTR_INCOMPLETE (1 << XFS_ATTR_INCOMPLETE_BIT) |
131 | 131 | ||
132 | /* | 132 | /* |
133 | * Conversion macros for converting namespace bits from argument flags | ||
134 | * to ondisk flags. | ||
135 | */ | ||
136 | #define XFS_ATTR_NSP_ARGS_MASK (ATTR_ROOT | ATTR_SECURE) | ||
137 | #define XFS_ATTR_NSP_ONDISK_MASK (XFS_ATTR_ROOT | XFS_ATTR_SECURE) | ||
138 | #define XFS_ATTR_NSP_ONDISK(flags) ((flags) & XFS_ATTR_NSP_ONDISK_MASK) | ||
139 | #define XFS_ATTR_NSP_ARGS(flags) ((flags) & XFS_ATTR_NSP_ARGS_MASK) | ||
140 | #define XFS_ATTR_NSP_ARGS_TO_ONDISK(x) (((x) & ATTR_ROOT ? XFS_ATTR_ROOT : 0) |\ | ||
141 | ((x) & ATTR_SECURE ? XFS_ATTR_SECURE : 0)) | ||
142 | #define XFS_ATTR_NSP_ONDISK_TO_ARGS(x) (((x) & XFS_ATTR_ROOT ? ATTR_ROOT : 0) |\ | ||
143 | ((x) & XFS_ATTR_SECURE ? ATTR_SECURE : 0)) | ||
144 | |||
145 | /* | ||
133 | * Alignment for namelist and valuelist entries (since they are mixed | 146 | * Alignment for namelist and valuelist entries (since they are mixed |
134 | * there can be only one alignment value) | 147 | * there can be only one alignment value) |
135 | */ | 148 | */ |
@@ -196,16 +209,26 @@ static inline int xfs_attr_leaf_entsize_local_max(int bsize) | |||
196 | * Structure used to pass context around among the routines. | 209 | * Structure used to pass context around among the routines. |
197 | *========================================================================*/ | 210 | *========================================================================*/ |
198 | 211 | ||
212 | |||
213 | struct xfs_attr_list_context; | ||
214 | |||
215 | typedef int (*put_listent_func_t)(struct xfs_attr_list_context *, struct attrnames *, | ||
216 | char *, int, int, char *); | ||
217 | |||
199 | typedef struct xfs_attr_list_context { | 218 | typedef struct xfs_attr_list_context { |
200 | struct xfs_inode *dp; /* inode */ | 219 | struct xfs_inode *dp; /* inode */ |
201 | struct attrlist_cursor_kern *cursor;/* position in list */ | 220 | struct attrlist_cursor_kern *cursor; /* position in list */ |
202 | struct attrlist *alist; /* output buffer */ | 221 | struct attrlist *alist; /* output buffer */ |
203 | int count; /* num used entries */ | 222 | int seen_enough; /* T/F: seen enough of list? */ |
204 | int dupcnt; /* count dup hashvals seen */ | 223 | int count; /* num used entries */ |
205 | int bufsize;/* total buffer size */ | 224 | int dupcnt; /* count dup hashvals seen */ |
206 | int firstu; /* first used byte in buffer */ | 225 | int bufsize; /* total buffer size */ |
207 | int flags; /* from VOP call */ | 226 | int firstu; /* first used byte in buffer */ |
208 | int resynch;/* T/F: resynch with cursor */ | 227 | int flags; /* from VOP call */ |
228 | int resynch; /* T/F: resynch with cursor */ | ||
229 | int put_value; /* T/F: need value for listent */ | ||
230 | put_listent_func_t put_listent; /* list output fmt function */ | ||
231 | int index; /* index into output buffer */ | ||
209 | } xfs_attr_list_context_t; | 232 | } xfs_attr_list_context_t; |
210 | 233 | ||
211 | /* | 234 | /* |
diff --git a/fs/xfs/xfs_behavior.c b/fs/xfs/xfs_behavior.c index f4fe3715a803..0dc17219d412 100644 --- a/fs/xfs/xfs_behavior.c +++ b/fs/xfs/xfs_behavior.c | |||
@@ -110,26 +110,6 @@ bhv_remove_not_first(bhv_head_t *bhp, bhv_desc_t *bdp) | |||
110 | } | 110 | } |
111 | 111 | ||
112 | /* | 112 | /* |
113 | * Look for a specific ops vector on the specified behavior chain. | ||
114 | * Return the associated behavior descriptor. Or NULL, if not found. | ||
115 | */ | ||
116 | bhv_desc_t * | ||
117 | bhv_lookup(bhv_head_t *bhp, void *ops) | ||
118 | { | ||
119 | bhv_desc_t *curdesc; | ||
120 | |||
121 | for (curdesc = bhp->bh_first; | ||
122 | curdesc != NULL; | ||
123 | curdesc = curdesc->bd_next) { | ||
124 | |||
125 | if (curdesc->bd_ops == ops) | ||
126 | return curdesc; | ||
127 | } | ||
128 | |||
129 | return NULL; | ||
130 | } | ||
131 | |||
132 | /* | ||
133 | * Looks for the first behavior within a specified range of positions. | 113 | * Looks for the first behavior within a specified range of positions. |
134 | * Return the associated behavior descriptor. Or NULL, if none found. | 114 | * Return the associated behavior descriptor. Or NULL, if none found. |
135 | */ | 115 | */ |
diff --git a/fs/xfs/xfs_behavior.h b/fs/xfs/xfs_behavior.h index 6e6e56fb352d..e7ca1fed955a 100644 --- a/fs/xfs/xfs_behavior.h +++ b/fs/xfs/xfs_behavior.h | |||
@@ -176,12 +176,10 @@ extern void bhv_insert_initial(bhv_head_t *, bhv_desc_t *); | |||
176 | * Behavior module prototypes. | 176 | * Behavior module prototypes. |
177 | */ | 177 | */ |
178 | extern void bhv_remove_not_first(bhv_head_t *bhp, bhv_desc_t *bdp); | 178 | extern void bhv_remove_not_first(bhv_head_t *bhp, bhv_desc_t *bdp); |
179 | extern bhv_desc_t * bhv_lookup(bhv_head_t *bhp, void *ops); | ||
180 | extern bhv_desc_t * bhv_lookup_range(bhv_head_t *bhp, int low, int high); | 179 | extern bhv_desc_t * bhv_lookup_range(bhv_head_t *bhp, int low, int high); |
181 | extern bhv_desc_t * bhv_base(bhv_head_t *bhp); | 180 | extern bhv_desc_t * bhv_base(bhv_head_t *bhp); |
182 | 181 | ||
183 | /* No bhv locking on Linux */ | 182 | /* No bhv locking on Linux */ |
184 | #define bhv_lookup_unlocked bhv_lookup | ||
185 | #define bhv_base_unlocked bhv_base | 183 | #define bhv_base_unlocked bhv_base |
186 | 184 | ||
187 | #endif /* __XFS_BEHAVIOR_H__ */ | 185 | #endif /* __XFS_BEHAVIOR_H__ */ |
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index bf46fae303af..5b050c06795f 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -2999,7 +2999,7 @@ xfs_bmap_btree_to_extents( | |||
2999 | int error; /* error return value */ | 2999 | int error; /* error return value */ |
3000 | xfs_ifork_t *ifp; /* inode fork data */ | 3000 | xfs_ifork_t *ifp; /* inode fork data */ |
3001 | xfs_mount_t *mp; /* mount point structure */ | 3001 | xfs_mount_t *mp; /* mount point structure */ |
3002 | xfs_bmbt_ptr_t *pp; /* ptr to block address */ | 3002 | __be64 *pp; /* ptr to block address */ |
3003 | xfs_bmbt_block_t *rblock;/* root btree block */ | 3003 | xfs_bmbt_block_t *rblock;/* root btree block */ |
3004 | 3004 | ||
3005 | ifp = XFS_IFORK_PTR(ip, whichfork); | 3005 | ifp = XFS_IFORK_PTR(ip, whichfork); |
@@ -3011,12 +3011,12 @@ xfs_bmap_btree_to_extents( | |||
3011 | ASSERT(XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes) == 1); | 3011 | ASSERT(XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes) == 1); |
3012 | mp = ip->i_mount; | 3012 | mp = ip->i_mount; |
3013 | pp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, ifp->if_broot_bytes); | 3013 | pp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, ifp->if_broot_bytes); |
3014 | cbno = be64_to_cpu(*pp); | ||
3014 | *logflagsp = 0; | 3015 | *logflagsp = 0; |
3015 | #ifdef DEBUG | 3016 | #ifdef DEBUG |
3016 | if ((error = xfs_btree_check_lptr(cur, INT_GET(*pp, ARCH_CONVERT), 1))) | 3017 | if ((error = xfs_btree_check_lptr(cur, cbno, 1))) |
3017 | return error; | 3018 | return error; |
3018 | #endif | 3019 | #endif |
3019 | cbno = INT_GET(*pp, ARCH_CONVERT); | ||
3020 | if ((error = xfs_btree_read_bufl(mp, tp, cbno, 0, &cbp, | 3020 | if ((error = xfs_btree_read_bufl(mp, tp, cbno, 0, &cbp, |
3021 | XFS_BMAP_BTREE_REF))) | 3021 | XFS_BMAP_BTREE_REF))) |
3022 | return error; | 3022 | return error; |
@@ -3512,9 +3512,9 @@ xfs_bmap_extents_to_btree( | |||
3512 | */ | 3512 | */ |
3513 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); | 3513 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); |
3514 | arp = XFS_BMAP_REC_IADDR(ablock, 1, cur); | 3514 | arp = XFS_BMAP_REC_IADDR(ablock, 1, cur); |
3515 | INT_SET(kp->br_startoff, ARCH_CONVERT, xfs_bmbt_disk_get_startoff(arp)); | 3515 | kp->br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(arp)); |
3516 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); | 3516 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); |
3517 | INT_SET(*pp, ARCH_CONVERT, args.fsbno); | 3517 | *pp = cpu_to_be64(args.fsbno); |
3518 | /* | 3518 | /* |
3519 | * Do all this logging at the end so that | 3519 | * Do all this logging at the end so that |
3520 | * the root is at the right level. | 3520 | * the root is at the right level. |
@@ -3705,7 +3705,7 @@ STATIC xfs_bmbt_rec_t * /* pointer to found extent entry */ | |||
3705 | xfs_bmap_search_extents( | 3705 | xfs_bmap_search_extents( |
3706 | xfs_inode_t *ip, /* incore inode pointer */ | 3706 | xfs_inode_t *ip, /* incore inode pointer */ |
3707 | xfs_fileoff_t bno, /* block number searched for */ | 3707 | xfs_fileoff_t bno, /* block number searched for */ |
3708 | int whichfork, /* data or attr fork */ | 3708 | int fork, /* data or attr fork */ |
3709 | int *eofp, /* out: end of file found */ | 3709 | int *eofp, /* out: end of file found */ |
3710 | xfs_extnum_t *lastxp, /* out: last extent index */ | 3710 | xfs_extnum_t *lastxp, /* out: last extent index */ |
3711 | xfs_bmbt_irec_t *gotp, /* out: extent entry found */ | 3711 | xfs_bmbt_irec_t *gotp, /* out: extent entry found */ |
@@ -3713,25 +3713,28 @@ xfs_bmap_search_extents( | |||
3713 | { | 3713 | { |
3714 | xfs_ifork_t *ifp; /* inode fork pointer */ | 3714 | xfs_ifork_t *ifp; /* inode fork pointer */ |
3715 | xfs_bmbt_rec_t *ep; /* extent record pointer */ | 3715 | xfs_bmbt_rec_t *ep; /* extent record pointer */ |
3716 | int rt; /* realtime flag */ | ||
3717 | 3716 | ||
3718 | XFS_STATS_INC(xs_look_exlist); | 3717 | XFS_STATS_INC(xs_look_exlist); |
3719 | ifp = XFS_IFORK_PTR(ip, whichfork); | 3718 | ifp = XFS_IFORK_PTR(ip, fork); |
3720 | 3719 | ||
3721 | ep = xfs_bmap_search_multi_extents(ifp, bno, eofp, lastxp, gotp, prevp); | 3720 | ep = xfs_bmap_search_multi_extents(ifp, bno, eofp, lastxp, gotp, prevp); |
3722 | 3721 | ||
3723 | rt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip); | 3722 | if (unlikely(!(gotp->br_startblock) && (*lastxp != NULLEXTNUM) && |
3724 | if (unlikely(!rt && !gotp->br_startblock && (*lastxp != NULLEXTNUM))) { | 3723 | !(XFS_IS_REALTIME_INODE(ip) && fork == XFS_DATA_FORK))) { |
3725 | cmn_err(CE_PANIC,"Access to block zero: fs: <%s> inode: %lld " | 3724 | xfs_cmn_err(XFS_PTAG_FSBLOCK_ZERO, CE_ALERT, ip->i_mount, |
3726 | "start_block : %llx start_off : %llx blkcnt : %llx " | 3725 | "Access to block zero in inode %llu " |
3727 | "extent-state : %x \n", | 3726 | "start_block: %llx start_off: %llx " |
3728 | (ip->i_mount)->m_fsname, (long long)ip->i_ino, | 3727 | "blkcnt: %llx extent-state: %x lastx: %x\n", |
3728 | (unsigned long long)ip->i_ino, | ||
3729 | (unsigned long long)gotp->br_startblock, | 3729 | (unsigned long long)gotp->br_startblock, |
3730 | (unsigned long long)gotp->br_startoff, | 3730 | (unsigned long long)gotp->br_startoff, |
3731 | (unsigned long long)gotp->br_blockcount, | 3731 | (unsigned long long)gotp->br_blockcount, |
3732 | gotp->br_state); | 3732 | gotp->br_state, *lastxp); |
3733 | } | 3733 | *lastxp = NULLEXTNUM; |
3734 | return ep; | 3734 | *eofp = 1; |
3735 | return NULL; | ||
3736 | } | ||
3737 | return ep; | ||
3735 | } | 3738 | } |
3736 | 3739 | ||
3737 | 3740 | ||
@@ -4494,7 +4497,7 @@ xfs_bmap_read_extents( | |||
4494 | xfs_ifork_t *ifp; /* fork structure */ | 4497 | xfs_ifork_t *ifp; /* fork structure */ |
4495 | int level; /* btree level, for checking */ | 4498 | int level; /* btree level, for checking */ |
4496 | xfs_mount_t *mp; /* file system mount structure */ | 4499 | xfs_mount_t *mp; /* file system mount structure */ |
4497 | xfs_bmbt_ptr_t *pp; /* pointer to block address */ | 4500 | __be64 *pp; /* pointer to block address */ |
4498 | /* REFERENCED */ | 4501 | /* REFERENCED */ |
4499 | xfs_extnum_t room; /* number of entries there's room for */ | 4502 | xfs_extnum_t room; /* number of entries there's room for */ |
4500 | 4503 | ||
@@ -4510,10 +4513,10 @@ xfs_bmap_read_extents( | |||
4510 | level = be16_to_cpu(block->bb_level); | 4513 | level = be16_to_cpu(block->bb_level); |
4511 | ASSERT(level > 0); | 4514 | ASSERT(level > 0); |
4512 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); | 4515 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); |
4513 | ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); | 4516 | bno = be64_to_cpu(*pp); |
4514 | ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); | 4517 | ASSERT(bno != NULLDFSBNO); |
4515 | ASSERT(XFS_FSB_TO_AGBNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agblocks); | 4518 | ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); |
4516 | bno = INT_GET(*pp, ARCH_CONVERT); | 4519 | ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); |
4517 | /* | 4520 | /* |
4518 | * Go down the tree until leaf level is reached, following the first | 4521 | * Go down the tree until leaf level is reached, following the first |
4519 | * pointer (leftmost) at each level. | 4522 | * pointer (leftmost) at each level. |
@@ -4530,10 +4533,8 @@ xfs_bmap_read_extents( | |||
4530 | break; | 4533 | break; |
4531 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, | 4534 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, |
4532 | 1, mp->m_bmap_dmxr[1]); | 4535 | 1, mp->m_bmap_dmxr[1]); |
4533 | XFS_WANT_CORRUPTED_GOTO( | 4536 | bno = be64_to_cpu(*pp); |
4534 | XFS_FSB_SANITY_CHECK(mp, INT_GET(*pp, ARCH_CONVERT)), | 4537 | XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0); |
4535 | error0); | ||
4536 | bno = INT_GET(*pp, ARCH_CONVERT); | ||
4537 | xfs_trans_brelse(tp, bp); | 4538 | xfs_trans_brelse(tp, bp); |
4538 | } | 4539 | } |
4539 | /* | 4540 | /* |
@@ -6141,7 +6142,7 @@ xfs_check_block( | |||
6141 | short sz) | 6142 | short sz) |
6142 | { | 6143 | { |
6143 | int i, j, dmxr; | 6144 | int i, j, dmxr; |
6144 | xfs_bmbt_ptr_t *pp, *thispa; /* pointer to block address */ | 6145 | __be64 *pp, *thispa; /* pointer to block address */ |
6145 | xfs_bmbt_key_t *prevp, *keyp; | 6146 | xfs_bmbt_key_t *prevp, *keyp; |
6146 | 6147 | ||
6147 | ASSERT(be16_to_cpu(block->bb_level) > 0); | 6148 | ASSERT(be16_to_cpu(block->bb_level) > 0); |
@@ -6179,11 +6180,10 @@ xfs_check_block( | |||
6179 | thispa = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, | 6180 | thispa = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, |
6180 | xfs_bmbt, block, j, dmxr); | 6181 | xfs_bmbt, block, j, dmxr); |
6181 | } | 6182 | } |
6182 | if (INT_GET(*thispa, ARCH_CONVERT) == | 6183 | if (*thispa == *pp) { |
6183 | INT_GET(*pp, ARCH_CONVERT)) { | ||
6184 | cmn_err(CE_WARN, "%s: thispa(%d) == pp(%d) %Ld", | 6184 | cmn_err(CE_WARN, "%s: thispa(%d) == pp(%d) %Ld", |
6185 | __FUNCTION__, j, i, | 6185 | __FUNCTION__, j, i, |
6186 | INT_GET(*thispa, ARCH_CONVERT)); | 6186 | (unsigned long long)be64_to_cpu(*thispa)); |
6187 | panic("%s: ptrs are equal in node\n", | 6187 | panic("%s: ptrs are equal in node\n", |
6188 | __FUNCTION__); | 6188 | __FUNCTION__); |
6189 | } | 6189 | } |
@@ -6210,7 +6210,7 @@ xfs_bmap_check_leaf_extents( | |||
6210 | xfs_ifork_t *ifp; /* fork structure */ | 6210 | xfs_ifork_t *ifp; /* fork structure */ |
6211 | int level; /* btree level, for checking */ | 6211 | int level; /* btree level, for checking */ |
6212 | xfs_mount_t *mp; /* file system mount structure */ | 6212 | xfs_mount_t *mp; /* file system mount structure */ |
6213 | xfs_bmbt_ptr_t *pp; /* pointer to block address */ | 6213 | __be64 *pp; /* pointer to block address */ |
6214 | xfs_bmbt_rec_t *ep; /* pointer to current extent */ | 6214 | xfs_bmbt_rec_t *ep; /* pointer to current extent */ |
6215 | xfs_bmbt_rec_t *lastp; /* pointer to previous extent */ | 6215 | xfs_bmbt_rec_t *lastp; /* pointer to previous extent */ |
6216 | xfs_bmbt_rec_t *nextp; /* pointer to next extent */ | 6216 | xfs_bmbt_rec_t *nextp; /* pointer to next extent */ |
@@ -6231,10 +6231,12 @@ xfs_bmap_check_leaf_extents( | |||
6231 | ASSERT(level > 0); | 6231 | ASSERT(level > 0); |
6232 | xfs_check_block(block, mp, 1, ifp->if_broot_bytes); | 6232 | xfs_check_block(block, mp, 1, ifp->if_broot_bytes); |
6233 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); | 6233 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); |
6234 | ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); | 6234 | bno = be64_to_cpu(*pp); |
6235 | ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); | 6235 | |
6236 | ASSERT(XFS_FSB_TO_AGBNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agblocks); | 6236 | ASSERT(bno != NULLDFSBNO); |
6237 | bno = INT_GET(*pp, ARCH_CONVERT); | 6237 | ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); |
6238 | ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); | ||
6239 | |||
6238 | /* | 6240 | /* |
6239 | * Go down the tree until leaf level is reached, following the first | 6241 | * Go down the tree until leaf level is reached, following the first |
6240 | * pointer (leftmost) at each level. | 6242 | * pointer (leftmost) at each level. |
@@ -6265,8 +6267,8 @@ xfs_bmap_check_leaf_extents( | |||
6265 | xfs_check_block(block, mp, 0, 0); | 6267 | xfs_check_block(block, mp, 0, 0); |
6266 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, | 6268 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, |
6267 | 1, mp->m_bmap_dmxr[1]); | 6269 | 1, mp->m_bmap_dmxr[1]); |
6268 | XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, INT_GET(*pp, ARCH_CONVERT)), error0); | 6270 | bno = be64_to_cpu(*pp); |
6269 | bno = INT_GET(*pp, ARCH_CONVERT); | 6271 | XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0); |
6270 | if (bp_release) { | 6272 | if (bp_release) { |
6271 | bp_release = 0; | 6273 | bp_release = 0; |
6272 | xfs_trans_brelse(NULL, bp); | 6274 | xfs_trans_brelse(NULL, bp); |
@@ -6372,7 +6374,7 @@ xfs_bmap_count_blocks( | |||
6372 | xfs_ifork_t *ifp; /* fork structure */ | 6374 | xfs_ifork_t *ifp; /* fork structure */ |
6373 | int level; /* btree level, for checking */ | 6375 | int level; /* btree level, for checking */ |
6374 | xfs_mount_t *mp; /* file system mount structure */ | 6376 | xfs_mount_t *mp; /* file system mount structure */ |
6375 | xfs_bmbt_ptr_t *pp; /* pointer to block address */ | 6377 | __be64 *pp; /* pointer to block address */ |
6376 | 6378 | ||
6377 | bno = NULLFSBLOCK; | 6379 | bno = NULLFSBLOCK; |
6378 | mp = ip->i_mount; | 6380 | mp = ip->i_mount; |
@@ -6395,10 +6397,10 @@ xfs_bmap_count_blocks( | |||
6395 | level = be16_to_cpu(block->bb_level); | 6397 | level = be16_to_cpu(block->bb_level); |
6396 | ASSERT(level > 0); | 6398 | ASSERT(level > 0); |
6397 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); | 6399 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); |
6398 | ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); | 6400 | bno = be64_to_cpu(*pp); |
6399 | ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); | 6401 | ASSERT(bno != NULLDFSBNO); |
6400 | ASSERT(XFS_FSB_TO_AGBNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agblocks); | 6402 | ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); |
6401 | bno = INT_GET(*pp, ARCH_CONVERT); | 6403 | ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); |
6402 | 6404 | ||
6403 | if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) { | 6405 | if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) { |
6404 | XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW, | 6406 | XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW, |
@@ -6425,7 +6427,7 @@ xfs_bmap_count_tree( | |||
6425 | int error; | 6427 | int error; |
6426 | xfs_buf_t *bp, *nbp; | 6428 | xfs_buf_t *bp, *nbp; |
6427 | int level = levelin; | 6429 | int level = levelin; |
6428 | xfs_bmbt_ptr_t *pp; | 6430 | __be64 *pp; |
6429 | xfs_fsblock_t bno = blockno; | 6431 | xfs_fsblock_t bno = blockno; |
6430 | xfs_fsblock_t nextbno; | 6432 | xfs_fsblock_t nextbno; |
6431 | xfs_bmbt_block_t *block, *nextblock; | 6433 | xfs_bmbt_block_t *block, *nextblock; |
@@ -6452,7 +6454,7 @@ xfs_bmap_count_tree( | |||
6452 | /* Dive to the next level */ | 6454 | /* Dive to the next level */ |
6453 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, | 6455 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, |
6454 | xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]); | 6456 | xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]); |
6455 | bno = INT_GET(*pp, ARCH_CONVERT); | 6457 | bno = be64_to_cpu(*pp); |
6456 | if (unlikely((error = | 6458 | if (unlikely((error = |
6457 | xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) { | 6459 | xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) { |
6458 | xfs_trans_brelse(tp, bp); | 6460 | xfs_trans_brelse(tp, bp); |
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c index 18fb7385d719..a7b835bf870a 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/xfs_bmap_btree.c | |||
@@ -58,7 +58,7 @@ STATIC void xfs_bmbt_log_ptrs(xfs_btree_cur_t *, xfs_buf_t *, int, int); | |||
58 | STATIC int xfs_bmbt_lshift(xfs_btree_cur_t *, int, int *); | 58 | STATIC int xfs_bmbt_lshift(xfs_btree_cur_t *, int, int *); |
59 | STATIC int xfs_bmbt_rshift(xfs_btree_cur_t *, int, int *); | 59 | STATIC int xfs_bmbt_rshift(xfs_btree_cur_t *, int, int *); |
60 | STATIC int xfs_bmbt_split(xfs_btree_cur_t *, int, xfs_fsblock_t *, | 60 | STATIC int xfs_bmbt_split(xfs_btree_cur_t *, int, xfs_fsblock_t *, |
61 | xfs_bmbt_key_t *, xfs_btree_cur_t **, int *); | 61 | __uint64_t *, xfs_btree_cur_t **, int *); |
62 | STATIC int xfs_bmbt_updkey(xfs_btree_cur_t *, xfs_bmbt_key_t *, int); | 62 | STATIC int xfs_bmbt_updkey(xfs_btree_cur_t *, xfs_bmbt_key_t *, int); |
63 | 63 | ||
64 | 64 | ||
@@ -192,16 +192,11 @@ xfs_bmbt_trace_argifk( | |||
192 | xfs_btree_cur_t *cur, | 192 | xfs_btree_cur_t *cur, |
193 | int i, | 193 | int i, |
194 | xfs_fsblock_t f, | 194 | xfs_fsblock_t f, |
195 | xfs_bmbt_key_t *k, | 195 | xfs_dfiloff_t o, |
196 | int line) | 196 | int line) |
197 | { | 197 | { |
198 | xfs_dfsbno_t d; | ||
199 | xfs_dfiloff_t o; | ||
200 | |||
201 | d = (xfs_dfsbno_t)f; | ||
202 | o = INT_GET(k->br_startoff, ARCH_CONVERT); | ||
203 | xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGIFK, line, | 198 | xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGIFK, line, |
204 | i, d >> 32, (int)d, o >> 32, | 199 | i, (xfs_dfsbno_t)f >> 32, (int)f, o >> 32, |
205 | (int)o, 0, 0, 0, | 200 | (int)o, 0, 0, 0, |
206 | 0, 0, 0); | 201 | 0, 0, 0); |
207 | } | 202 | } |
@@ -248,7 +243,7 @@ xfs_bmbt_trace_argik( | |||
248 | { | 243 | { |
249 | xfs_dfiloff_t o; | 244 | xfs_dfiloff_t o; |
250 | 245 | ||
251 | o = INT_GET(k->br_startoff, ARCH_CONVERT); | 246 | o = be64_to_cpu(k->br_startoff); |
252 | xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGIFK, line, | 247 | xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGIFK, line, |
253 | i, o >> 32, (int)o, 0, | 248 | i, o >> 32, (int)o, 0, |
254 | 0, 0, 0, 0, | 249 | 0, 0, 0, 0, |
@@ -286,8 +281,8 @@ xfs_bmbt_trace_cursor( | |||
286 | xfs_bmbt_trace_argfffi(fname, c, o, b, i, j, __LINE__) | 281 | xfs_bmbt_trace_argfffi(fname, c, o, b, i, j, __LINE__) |
287 | #define XFS_BMBT_TRACE_ARGI(c,i) \ | 282 | #define XFS_BMBT_TRACE_ARGI(c,i) \ |
288 | xfs_bmbt_trace_argi(fname, c, i, __LINE__) | 283 | xfs_bmbt_trace_argi(fname, c, i, __LINE__) |
289 | #define XFS_BMBT_TRACE_ARGIFK(c,i,f,k) \ | 284 | #define XFS_BMBT_TRACE_ARGIFK(c,i,f,s) \ |
290 | xfs_bmbt_trace_argifk(fname, c, i, f, k, __LINE__) | 285 | xfs_bmbt_trace_argifk(fname, c, i, f, s, __LINE__) |
291 | #define XFS_BMBT_TRACE_ARGIFR(c,i,f,r) \ | 286 | #define XFS_BMBT_TRACE_ARGIFR(c,i,f,r) \ |
292 | xfs_bmbt_trace_argifr(fname, c, i, f, r, __LINE__) | 287 | xfs_bmbt_trace_argifr(fname, c, i, f, r, __LINE__) |
293 | #define XFS_BMBT_TRACE_ARGIK(c,i,k) \ | 288 | #define XFS_BMBT_TRACE_ARGIK(c,i,k) \ |
@@ -299,7 +294,7 @@ xfs_bmbt_trace_cursor( | |||
299 | #define XFS_BMBT_TRACE_ARGBII(c,b,i,j) | 294 | #define XFS_BMBT_TRACE_ARGBII(c,b,i,j) |
300 | #define XFS_BMBT_TRACE_ARGFFFI(c,o,b,i,j) | 295 | #define XFS_BMBT_TRACE_ARGFFFI(c,o,b,i,j) |
301 | #define XFS_BMBT_TRACE_ARGI(c,i) | 296 | #define XFS_BMBT_TRACE_ARGI(c,i) |
302 | #define XFS_BMBT_TRACE_ARGIFK(c,i,f,k) | 297 | #define XFS_BMBT_TRACE_ARGIFK(c,i,f,s) |
303 | #define XFS_BMBT_TRACE_ARGIFR(c,i,f,r) | 298 | #define XFS_BMBT_TRACE_ARGIFR(c,i,f,r) |
304 | #define XFS_BMBT_TRACE_ARGIK(c,i,k) | 299 | #define XFS_BMBT_TRACE_ARGIK(c,i,k) |
305 | #define XFS_BMBT_TRACE_CURSOR(c,s) | 300 | #define XFS_BMBT_TRACE_CURSOR(c,s) |
@@ -357,7 +352,7 @@ xfs_bmbt_delrec( | |||
357 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); | 352 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); |
358 | XFS_BMBT_TRACE_ARGI(cur, level); | 353 | XFS_BMBT_TRACE_ARGI(cur, level); |
359 | ptr = cur->bc_ptrs[level]; | 354 | ptr = cur->bc_ptrs[level]; |
360 | tcur = (xfs_btree_cur_t *)0; | 355 | tcur = NULL; |
361 | if (ptr == 0) { | 356 | if (ptr == 0) { |
362 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 357 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
363 | *stat = 0; | 358 | *stat = 0; |
@@ -382,7 +377,7 @@ xfs_bmbt_delrec( | |||
382 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); | 377 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); |
383 | #ifdef DEBUG | 378 | #ifdef DEBUG |
384 | for (i = ptr; i < numrecs; i++) { | 379 | for (i = ptr; i < numrecs; i++) { |
385 | if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) { | 380 | if ((error = xfs_btree_check_lptr_disk(cur, pp[i], level))) { |
386 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 381 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
387 | goto error0; | 382 | goto error0; |
388 | } | 383 | } |
@@ -404,7 +399,8 @@ xfs_bmbt_delrec( | |||
404 | xfs_bmbt_log_recs(cur, bp, ptr, numrecs - 1); | 399 | xfs_bmbt_log_recs(cur, bp, ptr, numrecs - 1); |
405 | } | 400 | } |
406 | if (ptr == 1) { | 401 | if (ptr == 1) { |
407 | INT_SET(key.br_startoff, ARCH_CONVERT, xfs_bmbt_disk_get_startoff(rp)); | 402 | key.br_startoff = |
403 | cpu_to_be64(xfs_bmbt_disk_get_startoff(rp)); | ||
408 | kp = &key; | 404 | kp = &key; |
409 | } | 405 | } |
410 | } | 406 | } |
@@ -621,7 +617,7 @@ xfs_bmbt_delrec( | |||
621 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); | 617 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); |
622 | #ifdef DEBUG | 618 | #ifdef DEBUG |
623 | for (i = 0; i < numrrecs; i++) { | 619 | for (i = 0; i < numrrecs; i++) { |
624 | if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) { | 620 | if ((error = xfs_btree_check_lptr_disk(cur, rpp[i], level))) { |
625 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 621 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
626 | goto error0; | 622 | goto error0; |
627 | } | 623 | } |
@@ -748,7 +744,7 @@ xfs_bmbt_insrec( | |||
748 | int logflags; /* inode logging flags */ | 744 | int logflags; /* inode logging flags */ |
749 | xfs_fsblock_t nbno; /* new block number */ | 745 | xfs_fsblock_t nbno; /* new block number */ |
750 | struct xfs_btree_cur *ncur; /* new btree cursor */ | 746 | struct xfs_btree_cur *ncur; /* new btree cursor */ |
751 | xfs_bmbt_key_t nkey; /* new btree key value */ | 747 | __uint64_t startoff; /* new btree key value */ |
752 | xfs_bmbt_rec_t nrec; /* new record count */ | 748 | xfs_bmbt_rec_t nrec; /* new record count */ |
753 | int optr; /* old key/record index */ | 749 | int optr; /* old key/record index */ |
754 | xfs_bmbt_ptr_t *pp; /* pointer to bmap block addr */ | 750 | xfs_bmbt_ptr_t *pp; /* pointer to bmap block addr */ |
@@ -759,9 +755,8 @@ xfs_bmbt_insrec( | |||
759 | ASSERT(level < cur->bc_nlevels); | 755 | ASSERT(level < cur->bc_nlevels); |
760 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); | 756 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); |
761 | XFS_BMBT_TRACE_ARGIFR(cur, level, *bnop, recp); | 757 | XFS_BMBT_TRACE_ARGIFR(cur, level, *bnop, recp); |
762 | ncur = (xfs_btree_cur_t *)0; | 758 | ncur = NULL; |
763 | INT_SET(key.br_startoff, ARCH_CONVERT, | 759 | key.br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(recp)); |
764 | xfs_bmbt_disk_get_startoff(recp)); | ||
765 | optr = ptr = cur->bc_ptrs[level]; | 760 | optr = ptr = cur->bc_ptrs[level]; |
766 | if (ptr == 0) { | 761 | if (ptr == 0) { |
767 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 762 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
@@ -820,7 +815,7 @@ xfs_bmbt_insrec( | |||
820 | optr = ptr = cur->bc_ptrs[level]; | 815 | optr = ptr = cur->bc_ptrs[level]; |
821 | } else { | 816 | } else { |
822 | if ((error = xfs_bmbt_split(cur, level, | 817 | if ((error = xfs_bmbt_split(cur, level, |
823 | &nbno, &nkey, &ncur, | 818 | &nbno, &startoff, &ncur, |
824 | &i))) { | 819 | &i))) { |
825 | XFS_BMBT_TRACE_CURSOR(cur, | 820 | XFS_BMBT_TRACE_CURSOR(cur, |
826 | ERROR); | 821 | ERROR); |
@@ -840,7 +835,7 @@ xfs_bmbt_insrec( | |||
840 | #endif | 835 | #endif |
841 | ptr = cur->bc_ptrs[level]; | 836 | ptr = cur->bc_ptrs[level]; |
842 | xfs_bmbt_disk_set_allf(&nrec, | 837 | xfs_bmbt_disk_set_allf(&nrec, |
843 | nkey.br_startoff, 0, 0, | 838 | startoff, 0, 0, |
844 | XFS_EXT_NORM); | 839 | XFS_EXT_NORM); |
845 | } else { | 840 | } else { |
846 | XFS_BMBT_TRACE_CURSOR(cur, | 841 | XFS_BMBT_TRACE_CURSOR(cur, |
@@ -858,7 +853,7 @@ xfs_bmbt_insrec( | |||
858 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); | 853 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); |
859 | #ifdef DEBUG | 854 | #ifdef DEBUG |
860 | for (i = numrecs; i >= ptr; i--) { | 855 | for (i = numrecs; i >= ptr; i--) { |
861 | if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i - 1], ARCH_CONVERT), | 856 | if ((error = xfs_btree_check_lptr_disk(cur, pp[i - 1], |
862 | level))) { | 857 | level))) { |
863 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 858 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
864 | return error; | 859 | return error; |
@@ -870,14 +865,13 @@ xfs_bmbt_insrec( | |||
870 | memmove(&pp[ptr], &pp[ptr - 1], /* INT_: direct copy */ | 865 | memmove(&pp[ptr], &pp[ptr - 1], /* INT_: direct copy */ |
871 | (numrecs - ptr + 1) * sizeof(*pp)); | 866 | (numrecs - ptr + 1) * sizeof(*pp)); |
872 | #ifdef DEBUG | 867 | #ifdef DEBUG |
873 | if ((error = xfs_btree_check_lptr(cur, (xfs_bmbt_ptr_t)*bnop, | 868 | if ((error = xfs_btree_check_lptr(cur, *bnop, level))) { |
874 | level))) { | ||
875 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 869 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
876 | return error; | 870 | return error; |
877 | } | 871 | } |
878 | #endif | 872 | #endif |
879 | kp[ptr - 1] = key; | 873 | kp[ptr - 1] = key; |
880 | INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop); | 874 | pp[ptr - 1] = cpu_to_be64(*bnop); |
881 | numrecs++; | 875 | numrecs++; |
882 | block->bb_numrecs = cpu_to_be16(numrecs); | 876 | block->bb_numrecs = cpu_to_be16(numrecs); |
883 | xfs_bmbt_log_keys(cur, bp, ptr, numrecs); | 877 | xfs_bmbt_log_keys(cur, bp, ptr, numrecs); |
@@ -988,7 +982,7 @@ xfs_bmbt_killroot( | |||
988 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); | 982 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); |
989 | #ifdef DEBUG | 983 | #ifdef DEBUG |
990 | for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) { | 984 | for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) { |
991 | if ((error = xfs_btree_check_lptr(cur, INT_GET(cpp[i], ARCH_CONVERT), level - 1))) { | 985 | if ((error = xfs_btree_check_lptr_disk(cur, cpp[i], level - 1))) { |
992 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 986 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
993 | return error; | 987 | return error; |
994 | } | 988 | } |
@@ -1132,7 +1126,7 @@ xfs_bmbt_lookup( | |||
1132 | d = XFS_FSB_TO_DADDR(mp, fsbno); | 1126 | d = XFS_FSB_TO_DADDR(mp, fsbno); |
1133 | bp = cur->bc_bufs[level]; | 1127 | bp = cur->bc_bufs[level]; |
1134 | if (bp && XFS_BUF_ADDR(bp) != d) | 1128 | if (bp && XFS_BUF_ADDR(bp) != d) |
1135 | bp = (xfs_buf_t *)0; | 1129 | bp = NULL; |
1136 | if (!bp) { | 1130 | if (!bp) { |
1137 | if ((error = xfs_btree_read_bufl(mp, tp, fsbno, | 1131 | if ((error = xfs_btree_read_bufl(mp, tp, fsbno, |
1138 | 0, &bp, XFS_BMAP_BTREE_REF))) { | 1132 | 0, &bp, XFS_BMAP_BTREE_REF))) { |
@@ -1170,7 +1164,7 @@ xfs_bmbt_lookup( | |||
1170 | keyno = (low + high) >> 1; | 1164 | keyno = (low + high) >> 1; |
1171 | if (level > 0) { | 1165 | if (level > 0) { |
1172 | kkp = kkbase + keyno - 1; | 1166 | kkp = kkbase + keyno - 1; |
1173 | startoff = INT_GET(kkp->br_startoff, ARCH_CONVERT); | 1167 | startoff = be64_to_cpu(kkp->br_startoff); |
1174 | } else { | 1168 | } else { |
1175 | krp = krbase + keyno - 1; | 1169 | krp = krbase + keyno - 1; |
1176 | startoff = xfs_bmbt_disk_get_startoff(krp); | 1170 | startoff = xfs_bmbt_disk_get_startoff(krp); |
@@ -1189,13 +1183,13 @@ xfs_bmbt_lookup( | |||
1189 | if (diff > 0 && --keyno < 1) | 1183 | if (diff > 0 && --keyno < 1) |
1190 | keyno = 1; | 1184 | keyno = 1; |
1191 | pp = XFS_BMAP_PTR_IADDR(block, keyno, cur); | 1185 | pp = XFS_BMAP_PTR_IADDR(block, keyno, cur); |
1186 | fsbno = be64_to_cpu(*pp); | ||
1192 | #ifdef DEBUG | 1187 | #ifdef DEBUG |
1193 | if ((error = xfs_btree_check_lptr(cur, INT_GET(*pp, ARCH_CONVERT), level))) { | 1188 | if ((error = xfs_btree_check_lptr(cur, fsbno, level))) { |
1194 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1189 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1195 | return error; | 1190 | return error; |
1196 | } | 1191 | } |
1197 | #endif | 1192 | #endif |
1198 | fsbno = INT_GET(*pp, ARCH_CONVERT); | ||
1199 | cur->bc_ptrs[level] = keyno; | 1193 | cur->bc_ptrs[level] = keyno; |
1200 | } | 1194 | } |
1201 | } | 1195 | } |
@@ -1313,7 +1307,7 @@ xfs_bmbt_lshift( | |||
1313 | lpp = XFS_BMAP_PTR_IADDR(left, lrecs, cur); | 1307 | lpp = XFS_BMAP_PTR_IADDR(left, lrecs, cur); |
1314 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); | 1308 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); |
1315 | #ifdef DEBUG | 1309 | #ifdef DEBUG |
1316 | if ((error = xfs_btree_check_lptr(cur, INT_GET(*rpp, ARCH_CONVERT), level))) { | 1310 | if ((error = xfs_btree_check_lptr_disk(cur, *rpp, level))) { |
1317 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1311 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1318 | return error; | 1312 | return error; |
1319 | } | 1313 | } |
@@ -1340,7 +1334,7 @@ xfs_bmbt_lshift( | |||
1340 | if (level > 0) { | 1334 | if (level > 0) { |
1341 | #ifdef DEBUG | 1335 | #ifdef DEBUG |
1342 | for (i = 0; i < rrecs; i++) { | 1336 | for (i = 0; i < rrecs; i++) { |
1343 | if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i + 1], ARCH_CONVERT), | 1337 | if ((error = xfs_btree_check_lptr_disk(cur, rpp[i + 1], |
1344 | level))) { | 1338 | level))) { |
1345 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1339 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1346 | return error; | 1340 | return error; |
@@ -1354,8 +1348,7 @@ xfs_bmbt_lshift( | |||
1354 | } else { | 1348 | } else { |
1355 | memmove(rrp, rrp + 1, rrecs * sizeof(*rrp)); | 1349 | memmove(rrp, rrp + 1, rrecs * sizeof(*rrp)); |
1356 | xfs_bmbt_log_recs(cur, rbp, 1, rrecs); | 1350 | xfs_bmbt_log_recs(cur, rbp, 1, rrecs); |
1357 | INT_SET(key.br_startoff, ARCH_CONVERT, | 1351 | key.br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(rrp)); |
1358 | xfs_bmbt_disk_get_startoff(rrp)); | ||
1359 | rkp = &key; | 1352 | rkp = &key; |
1360 | } | 1353 | } |
1361 | if ((error = xfs_bmbt_updkey(cur, rkp, level + 1))) { | 1354 | if ((error = xfs_bmbt_updkey(cur, rkp, level + 1))) { |
@@ -1445,7 +1438,7 @@ xfs_bmbt_rshift( | |||
1445 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); | 1438 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); |
1446 | #ifdef DEBUG | 1439 | #ifdef DEBUG |
1447 | for (i = be16_to_cpu(right->bb_numrecs) - 1; i >= 0; i--) { | 1440 | for (i = be16_to_cpu(right->bb_numrecs) - 1; i >= 0; i--) { |
1448 | if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) { | 1441 | if ((error = xfs_btree_check_lptr_disk(cur, rpp[i], level))) { |
1449 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1442 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1450 | return error; | 1443 | return error; |
1451 | } | 1444 | } |
@@ -1454,7 +1447,7 @@ xfs_bmbt_rshift( | |||
1454 | memmove(rkp + 1, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); | 1447 | memmove(rkp + 1, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); |
1455 | memmove(rpp + 1, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); | 1448 | memmove(rpp + 1, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1456 | #ifdef DEBUG | 1449 | #ifdef DEBUG |
1457 | if ((error = xfs_btree_check_lptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) { | 1450 | if ((error = xfs_btree_check_lptr_disk(cur, *lpp, level))) { |
1458 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1451 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1459 | return error; | 1452 | return error; |
1460 | } | 1453 | } |
@@ -1469,8 +1462,7 @@ xfs_bmbt_rshift( | |||
1469 | memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); | 1462 | memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1470 | *rrp = *lrp; | 1463 | *rrp = *lrp; |
1471 | xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); | 1464 | xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1472 | INT_SET(key.br_startoff, ARCH_CONVERT, | 1465 | key.br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(rrp)); |
1473 | xfs_bmbt_disk_get_startoff(rrp)); | ||
1474 | rkp = &key; | 1466 | rkp = &key; |
1475 | } | 1467 | } |
1476 | be16_add(&left->bb_numrecs, -1); | 1468 | be16_add(&left->bb_numrecs, -1); |
@@ -1535,7 +1527,7 @@ xfs_bmbt_split( | |||
1535 | xfs_btree_cur_t *cur, | 1527 | xfs_btree_cur_t *cur, |
1536 | int level, | 1528 | int level, |
1537 | xfs_fsblock_t *bnop, | 1529 | xfs_fsblock_t *bnop, |
1538 | xfs_bmbt_key_t *keyp, | 1530 | __uint64_t *startoff, |
1539 | xfs_btree_cur_t **curp, | 1531 | xfs_btree_cur_t **curp, |
1540 | int *stat) /* success/failure */ | 1532 | int *stat) /* success/failure */ |
1541 | { | 1533 | { |
@@ -1560,7 +1552,7 @@ xfs_bmbt_split( | |||
1560 | xfs_bmbt_rec_t *rrp; /* right record pointer */ | 1552 | xfs_bmbt_rec_t *rrp; /* right record pointer */ |
1561 | 1553 | ||
1562 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); | 1554 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); |
1563 | XFS_BMBT_TRACE_ARGIFK(cur, level, *bnop, keyp); | 1555 | XFS_BMBT_TRACE_ARGIFK(cur, level, *bnop, *startoff); |
1564 | args.tp = cur->bc_tp; | 1556 | args.tp = cur->bc_tp; |
1565 | args.mp = cur->bc_mp; | 1557 | args.mp = cur->bc_mp; |
1566 | lbp = cur->bc_bufs[level]; | 1558 | lbp = cur->bc_bufs[level]; |
@@ -1619,7 +1611,7 @@ xfs_bmbt_split( | |||
1619 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); | 1611 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); |
1620 | #ifdef DEBUG | 1612 | #ifdef DEBUG |
1621 | for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) { | 1613 | for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) { |
1622 | if ((error = xfs_btree_check_lptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) { | 1614 | if ((error = xfs_btree_check_lptr_disk(cur, lpp[i], level))) { |
1623 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1615 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1624 | return error; | 1616 | return error; |
1625 | } | 1617 | } |
@@ -1629,13 +1621,13 @@ xfs_bmbt_split( | |||
1629 | memcpy(rpp, lpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); | 1621 | memcpy(rpp, lpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1630 | xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); | 1622 | xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1631 | xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); | 1623 | xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1632 | keyp->br_startoff = INT_GET(rkp->br_startoff, ARCH_CONVERT); | 1624 | *startoff = be64_to_cpu(rkp->br_startoff); |
1633 | } else { | 1625 | } else { |
1634 | lrp = XFS_BMAP_REC_IADDR(left, i, cur); | 1626 | lrp = XFS_BMAP_REC_IADDR(left, i, cur); |
1635 | rrp = XFS_BMAP_REC_IADDR(right, 1, cur); | 1627 | rrp = XFS_BMAP_REC_IADDR(right, 1, cur); |
1636 | memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); | 1628 | memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1637 | xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); | 1629 | xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1638 | keyp->br_startoff = xfs_bmbt_disk_get_startoff(rrp); | 1630 | *startoff = xfs_bmbt_disk_get_startoff(rrp); |
1639 | } | 1631 | } |
1640 | be16_add(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs))); | 1632 | be16_add(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs))); |
1641 | right->bb_rightsib = left->bb_rightsib; | 1633 | right->bb_rightsib = left->bb_rightsib; |
@@ -1728,9 +1720,9 @@ xfs_bmdr_to_bmbt( | |||
1728 | { | 1720 | { |
1729 | int dmxr; | 1721 | int dmxr; |
1730 | xfs_bmbt_key_t *fkp; | 1722 | xfs_bmbt_key_t *fkp; |
1731 | xfs_bmbt_ptr_t *fpp; | 1723 | __be64 *fpp; |
1732 | xfs_bmbt_key_t *tkp; | 1724 | xfs_bmbt_key_t *tkp; |
1733 | xfs_bmbt_ptr_t *tpp; | 1725 | __be64 *tpp; |
1734 | 1726 | ||
1735 | rblock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); | 1727 | rblock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); |
1736 | rblock->bb_level = dblock->bb_level; | 1728 | rblock->bb_level = dblock->bb_level; |
@@ -1745,7 +1737,7 @@ xfs_bmdr_to_bmbt( | |||
1745 | tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); | 1737 | tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); |
1746 | dmxr = be16_to_cpu(dblock->bb_numrecs); | 1738 | dmxr = be16_to_cpu(dblock->bb_numrecs); |
1747 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); | 1739 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); |
1748 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ | 1740 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); |
1749 | } | 1741 | } |
1750 | 1742 | ||
1751 | /* | 1743 | /* |
@@ -1805,7 +1797,7 @@ xfs_bmbt_decrement( | |||
1805 | tp = cur->bc_tp; | 1797 | tp = cur->bc_tp; |
1806 | mp = cur->bc_mp; | 1798 | mp = cur->bc_mp; |
1807 | for (block = xfs_bmbt_get_block(cur, lev, &bp); lev > level; ) { | 1799 | for (block = xfs_bmbt_get_block(cur, lev, &bp); lev > level; ) { |
1808 | fsbno = INT_GET(*XFS_BMAP_PTR_IADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT); | 1800 | fsbno = be64_to_cpu(*XFS_BMAP_PTR_IADDR(block, cur->bc_ptrs[lev], cur)); |
1809 | if ((error = xfs_btree_read_bufl(mp, tp, fsbno, 0, &bp, | 1801 | if ((error = xfs_btree_read_bufl(mp, tp, fsbno, 0, &bp, |
1810 | XFS_BMAP_BTREE_REF))) { | 1802 | XFS_BMAP_BTREE_REF))) { |
1811 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1803 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -2135,7 +2127,7 @@ xfs_bmbt_increment( | |||
2135 | tp = cur->bc_tp; | 2127 | tp = cur->bc_tp; |
2136 | mp = cur->bc_mp; | 2128 | mp = cur->bc_mp; |
2137 | for (block = xfs_bmbt_get_block(cur, lev, &bp); lev > level; ) { | 2129 | for (block = xfs_bmbt_get_block(cur, lev, &bp); lev > level; ) { |
2138 | fsbno = INT_GET(*XFS_BMAP_PTR_IADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT); | 2130 | fsbno = be64_to_cpu(*XFS_BMAP_PTR_IADDR(block, cur->bc_ptrs[lev], cur)); |
2139 | if ((error = xfs_btree_read_bufl(mp, tp, fsbno, 0, &bp, | 2131 | if ((error = xfs_btree_read_bufl(mp, tp, fsbno, 0, &bp, |
2140 | XFS_BMAP_BTREE_REF))) { | 2132 | XFS_BMAP_BTREE_REF))) { |
2141 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 2133 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -2178,7 +2170,7 @@ xfs_bmbt_insert( | |||
2178 | level = 0; | 2170 | level = 0; |
2179 | nbno = NULLFSBLOCK; | 2171 | nbno = NULLFSBLOCK; |
2180 | xfs_bmbt_disk_set_all(&nrec, &cur->bc_rec.b); | 2172 | xfs_bmbt_disk_set_all(&nrec, &cur->bc_rec.b); |
2181 | ncur = (xfs_btree_cur_t *)0; | 2173 | ncur = NULL; |
2182 | pcur = cur; | 2174 | pcur = cur; |
2183 | do { | 2175 | do { |
2184 | if ((error = xfs_bmbt_insrec(pcur, level++, &nbno, &nrec, &ncur, | 2176 | if ((error = xfs_bmbt_insrec(pcur, level++, &nbno, &nrec, &ncur, |
@@ -2205,7 +2197,7 @@ xfs_bmbt_insert( | |||
2205 | } | 2197 | } |
2206 | if (ncur) { | 2198 | if (ncur) { |
2207 | pcur = ncur; | 2199 | pcur = ncur; |
2208 | ncur = (xfs_btree_cur_t *)0; | 2200 | ncur = NULL; |
2209 | } | 2201 | } |
2210 | } while (nbno != NULLFSBLOCK); | 2202 | } while (nbno != NULLFSBLOCK); |
2211 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 2203 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
@@ -2356,12 +2348,12 @@ xfs_bmbt_newroot( | |||
2356 | args.firstblock = args.fsbno; | 2348 | args.firstblock = args.fsbno; |
2357 | if (args.fsbno == NULLFSBLOCK) { | 2349 | if (args.fsbno == NULLFSBLOCK) { |
2358 | #ifdef DEBUG | 2350 | #ifdef DEBUG |
2359 | if ((error = xfs_btree_check_lptr(cur, INT_GET(*pp, ARCH_CONVERT), level))) { | 2351 | if ((error = xfs_btree_check_lptr_disk(cur, *pp, level))) { |
2360 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 2352 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
2361 | return error; | 2353 | return error; |
2362 | } | 2354 | } |
2363 | #endif | 2355 | #endif |
2364 | args.fsbno = INT_GET(*pp, ARCH_CONVERT); | 2356 | args.fsbno = be64_to_cpu(*pp); |
2365 | args.type = XFS_ALLOCTYPE_START_BNO; | 2357 | args.type = XFS_ALLOCTYPE_START_BNO; |
2366 | } else | 2358 | } else |
2367 | args.type = XFS_ALLOCTYPE_NEAR_BNO; | 2359 | args.type = XFS_ALLOCTYPE_NEAR_BNO; |
@@ -2393,7 +2385,7 @@ xfs_bmbt_newroot( | |||
2393 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); | 2385 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); |
2394 | #ifdef DEBUG | 2386 | #ifdef DEBUG |
2395 | for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) { | 2387 | for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) { |
2396 | if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) { | 2388 | if ((error = xfs_btree_check_lptr_disk(cur, pp[i], level))) { |
2397 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 2389 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
2398 | return error; | 2390 | return error; |
2399 | } | 2391 | } |
@@ -2401,13 +2393,12 @@ xfs_bmbt_newroot( | |||
2401 | #endif | 2393 | #endif |
2402 | memcpy(cpp, pp, be16_to_cpu(cblock->bb_numrecs) * sizeof(*pp)); | 2394 | memcpy(cpp, pp, be16_to_cpu(cblock->bb_numrecs) * sizeof(*pp)); |
2403 | #ifdef DEBUG | 2395 | #ifdef DEBUG |
2404 | if ((error = xfs_btree_check_lptr(cur, (xfs_bmbt_ptr_t)args.fsbno, | 2396 | if ((error = xfs_btree_check_lptr(cur, args.fsbno, level))) { |
2405 | level))) { | ||
2406 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 2397 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
2407 | return error; | 2398 | return error; |
2408 | } | 2399 | } |
2409 | #endif | 2400 | #endif |
2410 | INT_SET(*pp, ARCH_CONVERT, args.fsbno); | 2401 | *pp = cpu_to_be64(args.fsbno); |
2411 | xfs_iroot_realloc(cur->bc_private.b.ip, 1 - be16_to_cpu(cblock->bb_numrecs), | 2402 | xfs_iroot_realloc(cur->bc_private.b.ip, 1 - be16_to_cpu(cblock->bb_numrecs), |
2412 | cur->bc_private.b.whichfork); | 2403 | cur->bc_private.b.whichfork); |
2413 | xfs_btree_setbuf(cur, level, bp); | 2404 | xfs_btree_setbuf(cur, level, bp); |
@@ -2681,9 +2672,9 @@ xfs_bmbt_to_bmdr( | |||
2681 | { | 2672 | { |
2682 | int dmxr; | 2673 | int dmxr; |
2683 | xfs_bmbt_key_t *fkp; | 2674 | xfs_bmbt_key_t *fkp; |
2684 | xfs_bmbt_ptr_t *fpp; | 2675 | __be64 *fpp; |
2685 | xfs_bmbt_key_t *tkp; | 2676 | xfs_bmbt_key_t *tkp; |
2686 | xfs_bmbt_ptr_t *tpp; | 2677 | __be64 *tpp; |
2687 | 2678 | ||
2688 | ASSERT(be32_to_cpu(rblock->bb_magic) == XFS_BMAP_MAGIC); | 2679 | ASSERT(be32_to_cpu(rblock->bb_magic) == XFS_BMAP_MAGIC); |
2689 | ASSERT(be64_to_cpu(rblock->bb_leftsib) == NULLDFSBNO); | 2680 | ASSERT(be64_to_cpu(rblock->bb_leftsib) == NULLDFSBNO); |
@@ -2698,7 +2689,7 @@ xfs_bmbt_to_bmdr( | |||
2698 | tpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); | 2689 | tpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); |
2699 | dmxr = be16_to_cpu(dblock->bb_numrecs); | 2690 | dmxr = be16_to_cpu(dblock->bb_numrecs); |
2700 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); | 2691 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); |
2701 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ | 2692 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); |
2702 | } | 2693 | } |
2703 | 2694 | ||
2704 | /* | 2695 | /* |
@@ -2740,7 +2731,7 @@ xfs_bmbt_update( | |||
2740 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 2731 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
2741 | return 0; | 2732 | return 0; |
2742 | } | 2733 | } |
2743 | INT_SET(key.br_startoff, ARCH_CONVERT, off); | 2734 | key.br_startoff = cpu_to_be64(off); |
2744 | if ((error = xfs_bmbt_updkey(cur, &key, 1))) { | 2735 | if ((error = xfs_bmbt_updkey(cur, &key, 1))) { |
2745 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 2736 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
2746 | return error; | 2737 | return error; |
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h index 6478cfa0e539..49539de9525b 100644 --- a/fs/xfs/xfs_bmap_btree.h +++ b/fs/xfs/xfs_bmap_btree.h | |||
@@ -163,13 +163,14 @@ typedef struct xfs_bmbt_irec | |||
163 | /* | 163 | /* |
164 | * Key structure for non-leaf levels of the tree. | 164 | * Key structure for non-leaf levels of the tree. |
165 | */ | 165 | */ |
166 | typedef struct xfs_bmbt_key | 166 | typedef struct xfs_bmbt_key { |
167 | { | 167 | __be64 br_startoff; /* starting file offset */ |
168 | xfs_dfiloff_t br_startoff; /* starting file offset */ | ||
169 | } xfs_bmbt_key_t, xfs_bmdr_key_t; | 168 | } xfs_bmbt_key_t, xfs_bmdr_key_t; |
170 | 169 | ||
171 | typedef xfs_dfsbno_t xfs_bmbt_ptr_t, xfs_bmdr_ptr_t; /* btree pointer type */ | 170 | /* btree pointer type */ |
172 | /* btree block header type */ | 171 | typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t; |
172 | |||
173 | /* btree block header type */ | ||
173 | typedef struct xfs_btree_lblock xfs_bmbt_block_t; | 174 | typedef struct xfs_btree_lblock xfs_bmbt_block_t; |
174 | 175 | ||
175 | #define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp)) | 176 | #define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp)) |
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c index ee2255bd6562..aeb87ca69fcc 100644 --- a/fs/xfs/xfs_btree.c +++ b/fs/xfs/xfs_btree.c | |||
@@ -161,7 +161,7 @@ xfs_btree_check_key( | |||
161 | 161 | ||
162 | k1 = ak1; | 162 | k1 = ak1; |
163 | k2 = ak2; | 163 | k2 = ak2; |
164 | ASSERT(INT_GET(k1->br_startoff, ARCH_CONVERT) < INT_GET(k2->br_startoff, ARCH_CONVERT)); | 164 | ASSERT(be64_to_cpu(k1->br_startoff) < be64_to_cpu(k2->br_startoff)); |
165 | break; | 165 | break; |
166 | } | 166 | } |
167 | case XFS_BTNUM_INO: { | 167 | case XFS_BTNUM_INO: { |
@@ -170,7 +170,7 @@ xfs_btree_check_key( | |||
170 | 170 | ||
171 | k1 = ak1; | 171 | k1 = ak1; |
172 | k2 = ak2; | 172 | k2 = ak2; |
173 | ASSERT(INT_GET(k1->ir_startino, ARCH_CONVERT) < INT_GET(k2->ir_startino, ARCH_CONVERT)); | 173 | ASSERT(be32_to_cpu(k1->ir_startino) < be32_to_cpu(k2->ir_startino)); |
174 | break; | 174 | break; |
175 | } | 175 | } |
176 | default: | 176 | default: |
@@ -285,8 +285,8 @@ xfs_btree_check_rec( | |||
285 | 285 | ||
286 | r1 = ar1; | 286 | r1 = ar1; |
287 | r2 = ar2; | 287 | r2 = ar2; |
288 | ASSERT(INT_GET(r1->ir_startino, ARCH_CONVERT) + XFS_INODES_PER_CHUNK <= | 288 | ASSERT(be32_to_cpu(r1->ir_startino) + XFS_INODES_PER_CHUNK <= |
289 | INT_GET(r2->ir_startino, ARCH_CONVERT)); | 289 | be32_to_cpu(r2->ir_startino)); |
290 | break; | 290 | break; |
291 | } | 291 | } |
292 | default: | 292 | default: |
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h index 44f1bd98064a..892b06c54263 100644 --- a/fs/xfs/xfs_btree.h +++ b/fs/xfs/xfs_btree.h | |||
@@ -145,7 +145,7 @@ typedef struct xfs_btree_cur | |||
145 | union { | 145 | union { |
146 | xfs_alloc_rec_incore_t a; | 146 | xfs_alloc_rec_incore_t a; |
147 | xfs_bmbt_irec_t b; | 147 | xfs_bmbt_irec_t b; |
148 | xfs_inobt_rec_t i; | 148 | xfs_inobt_rec_incore_t i; |
149 | } bc_rec; /* current insert/search record value */ | 149 | } bc_rec; /* current insert/search record value */ |
150 | struct xfs_buf *bc_bufs[XFS_BTREE_MAXLEVELS]; /* buf ptr per level */ | 150 | struct xfs_buf *bc_bufs[XFS_BTREE_MAXLEVELS]; /* buf ptr per level */ |
151 | int bc_ptrs[XFS_BTREE_MAXLEVELS]; /* key/record # */ | 151 | int bc_ptrs[XFS_BTREE_MAXLEVELS]; /* key/record # */ |
@@ -243,6 +243,9 @@ xfs_btree_check_lptr( | |||
243 | xfs_dfsbno_t ptr, /* btree block disk address */ | 243 | xfs_dfsbno_t ptr, /* btree block disk address */ |
244 | int level); /* btree block level */ | 244 | int level); /* btree block level */ |
245 | 245 | ||
246 | #define xfs_btree_check_lptr_disk(cur, ptr, level) \ | ||
247 | xfs_btree_check_lptr(cur, be64_to_cpu(ptr), level) | ||
248 | |||
246 | /* | 249 | /* |
247 | * Checking routine: check that short form block header is ok. | 250 | * Checking routine: check that short form block header is ok. |
248 | */ | 251 | */ |
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index a4aa53974f76..7a55c248ea70 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c | |||
@@ -234,7 +234,6 @@ xfs_buf_item_format( | |||
234 | ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || | 234 | ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || |
235 | (bip->bli_flags & XFS_BLI_STALE)); | 235 | (bip->bli_flags & XFS_BLI_STALE)); |
236 | bp = bip->bli_buf; | 236 | bp = bip->bli_buf; |
237 | ASSERT(XFS_BUF_BP_ISMAPPED(bp)); | ||
238 | vecp = log_vector; | 237 | vecp = log_vector; |
239 | 238 | ||
240 | /* | 239 | /* |
@@ -628,25 +627,6 @@ xfs_buf_item_committed( | |||
628 | } | 627 | } |
629 | 628 | ||
630 | /* | 629 | /* |
631 | * This is called when the transaction holding the buffer is aborted. | ||
632 | * Just behave as if the transaction had been cancelled. If we're shutting down | ||
633 | * and have aborted this transaction, we'll trap this buffer when it tries to | ||
634 | * get written out. | ||
635 | */ | ||
636 | STATIC void | ||
637 | xfs_buf_item_abort( | ||
638 | xfs_buf_log_item_t *bip) | ||
639 | { | ||
640 | xfs_buf_t *bp; | ||
641 | |||
642 | bp = bip->bli_buf; | ||
643 | xfs_buftrace("XFS_ABORT", bp); | ||
644 | XFS_BUF_SUPER_STALE(bp); | ||
645 | xfs_buf_item_unlock(bip); | ||
646 | return; | ||
647 | } | ||
648 | |||
649 | /* | ||
650 | * This is called to asynchronously write the buffer associated with this | 630 | * This is called to asynchronously write the buffer associated with this |
651 | * buf log item out to disk. The buffer will already have been locked by | 631 | * buf log item out to disk. The buffer will already have been locked by |
652 | * a successful call to xfs_buf_item_trylock(). If the buffer still has | 632 | * a successful call to xfs_buf_item_trylock(). If the buffer still has |
@@ -693,7 +673,6 @@ STATIC struct xfs_item_ops xfs_buf_item_ops = { | |||
693 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) | 673 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) |
694 | xfs_buf_item_committed, | 674 | xfs_buf_item_committed, |
695 | .iop_push = (void(*)(xfs_log_item_t*))xfs_buf_item_push, | 675 | .iop_push = (void(*)(xfs_log_item_t*))xfs_buf_item_push, |
696 | .iop_abort = (void(*)(xfs_log_item_t*))xfs_buf_item_abort, | ||
697 | .iop_pushbuf = NULL, | 676 | .iop_pushbuf = NULL, |
698 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) | 677 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) |
699 | xfs_buf_item_committing | 678 | xfs_buf_item_committing |
@@ -901,7 +880,6 @@ xfs_buf_item_relse( | |||
901 | XFS_BUF_SET_FSPRIVATE(bp, bip->bli_item.li_bio_list); | 880 | XFS_BUF_SET_FSPRIVATE(bp, bip->bli_item.li_bio_list); |
902 | if ((XFS_BUF_FSPRIVATE(bp, void *) == NULL) && | 881 | if ((XFS_BUF_FSPRIVATE(bp, void *) == NULL) && |
903 | (XFS_BUF_IODONE_FUNC(bp) != NULL)) { | 882 | (XFS_BUF_IODONE_FUNC(bp) != NULL)) { |
904 | ASSERT((XFS_BUF_ISUNINITIAL(bp)) == 0); | ||
905 | XFS_BUF_CLR_IODONE_FUNC(bp); | 883 | XFS_BUF_CLR_IODONE_FUNC(bp); |
906 | } | 884 | } |
907 | 885 | ||
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 32ab61d17ace..a68bc1f1a313 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -1054,7 +1054,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1054 | xfs_da_node_entry_t *btree; | 1054 | xfs_da_node_entry_t *btree; |
1055 | xfs_dablk_t blkno; | 1055 | xfs_dablk_t blkno; |
1056 | int probe, span, max, error, retval; | 1056 | int probe, span, max, error, retval; |
1057 | xfs_dahash_t hashval; | 1057 | xfs_dahash_t hashval, btreehashval; |
1058 | xfs_da_args_t *args; | 1058 | xfs_da_args_t *args; |
1059 | 1059 | ||
1060 | args = state->args; | 1060 | args = state->args; |
@@ -1079,30 +1079,32 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1079 | return(error); | 1079 | return(error); |
1080 | } | 1080 | } |
1081 | curr = blk->bp->data; | 1081 | curr = blk->bp->data; |
1082 | ASSERT(be16_to_cpu(curr->magic) == XFS_DA_NODE_MAGIC || | 1082 | blk->magic = be16_to_cpu(curr->magic); |
1083 | be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC || | 1083 | ASSERT(blk->magic == XFS_DA_NODE_MAGIC || |
1084 | be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC); | 1084 | blk->magic == XFS_DIR2_LEAFN_MAGIC || |
1085 | blk->magic == XFS_ATTR_LEAF_MAGIC); | ||
1085 | 1086 | ||
1086 | /* | 1087 | /* |
1087 | * Search an intermediate node for a match. | 1088 | * Search an intermediate node for a match. |
1088 | */ | 1089 | */ |
1089 | blk->magic = be16_to_cpu(curr->magic); | ||
1090 | if (blk->magic == XFS_DA_NODE_MAGIC) { | 1090 | if (blk->magic == XFS_DA_NODE_MAGIC) { |
1091 | node = blk->bp->data; | 1091 | node = blk->bp->data; |
1092 | blk->hashval = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval); | 1092 | max = be16_to_cpu(node->hdr.count); |
1093 | btreehashval = node->btree[max-1].hashval; | ||
1094 | blk->hashval = be32_to_cpu(btreehashval); | ||
1093 | 1095 | ||
1094 | /* | 1096 | /* |
1095 | * Binary search. (note: small blocks will skip loop) | 1097 | * Binary search. (note: small blocks will skip loop) |
1096 | */ | 1098 | */ |
1097 | max = be16_to_cpu(node->hdr.count); | ||
1098 | probe = span = max / 2; | 1099 | probe = span = max / 2; |
1099 | hashval = args->hashval; | 1100 | hashval = args->hashval; |
1100 | for (btree = &node->btree[probe]; span > 4; | 1101 | for (btree = &node->btree[probe]; span > 4; |
1101 | btree = &node->btree[probe]) { | 1102 | btree = &node->btree[probe]) { |
1102 | span /= 2; | 1103 | span /= 2; |
1103 | if (be32_to_cpu(btree->hashval) < hashval) | 1104 | btreehashval = be32_to_cpu(btree->hashval); |
1105 | if (btreehashval < hashval) | ||
1104 | probe += span; | 1106 | probe += span; |
1105 | else if (be32_to_cpu(btree->hashval) > hashval) | 1107 | else if (btreehashval > hashval) |
1106 | probe -= span; | 1108 | probe -= span; |
1107 | else | 1109 | else |
1108 | break; | 1110 | break; |
@@ -1133,10 +1135,10 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1133 | blk->index = probe; | 1135 | blk->index = probe; |
1134 | blkno = be32_to_cpu(btree->before); | 1136 | blkno = be32_to_cpu(btree->before); |
1135 | } | 1137 | } |
1136 | } else if (be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC) { | 1138 | } else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { |
1137 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); | 1139 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); |
1138 | break; | 1140 | break; |
1139 | } else if (be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC) { | 1141 | } else if (blk->magic == XFS_DIR2_LEAFN_MAGIC) { |
1140 | blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL); | 1142 | blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL); |
1141 | break; | 1143 | break; |
1142 | } | 1144 | } |
@@ -1152,11 +1154,13 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1152 | if (blk->magic == XFS_DIR2_LEAFN_MAGIC) { | 1154 | if (blk->magic == XFS_DIR2_LEAFN_MAGIC) { |
1153 | retval = xfs_dir2_leafn_lookup_int(blk->bp, args, | 1155 | retval = xfs_dir2_leafn_lookup_int(blk->bp, args, |
1154 | &blk->index, state); | 1156 | &blk->index, state); |
1155 | } | 1157 | } else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { |
1156 | else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { | ||
1157 | retval = xfs_attr_leaf_lookup_int(blk->bp, args); | 1158 | retval = xfs_attr_leaf_lookup_int(blk->bp, args); |
1158 | blk->index = args->index; | 1159 | blk->index = args->index; |
1159 | args->blkno = blk->blkno; | 1160 | args->blkno = blk->blkno; |
1161 | } else { | ||
1162 | ASSERT(0); | ||
1163 | return XFS_ERROR(EFSCORRUPTED); | ||
1160 | } | 1164 | } |
1161 | if (((retval == ENOENT) || (retval == ENOATTR)) && | 1165 | if (((retval == ENOENT) || (retval == ENOATTR)) && |
1162 | (blk->hashval == args->hashval)) { | 1166 | (blk->hashval == args->hashval)) { |
@@ -1166,8 +1170,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1166 | return(error); | 1170 | return(error); |
1167 | if (retval == 0) { | 1171 | if (retval == 0) { |
1168 | continue; | 1172 | continue; |
1169 | } | 1173 | } else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { |
1170 | else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { | ||
1171 | /* path_shift() gives ENOENT */ | 1174 | /* path_shift() gives ENOENT */ |
1172 | retval = XFS_ERROR(ENOATTR); | 1175 | retval = XFS_ERROR(ENOATTR); |
1173 | } | 1176 | } |
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h index bc43163456ef..0893e16b7d83 100644 --- a/fs/xfs/xfs_error.h +++ b/fs/xfs/xfs_error.h | |||
@@ -18,14 +18,6 @@ | |||
18 | #ifndef __XFS_ERROR_H__ | 18 | #ifndef __XFS_ERROR_H__ |
19 | #define __XFS_ERROR_H__ | 19 | #define __XFS_ERROR_H__ |
20 | 20 | ||
21 | #define XFS_ERECOVER 1 /* Failure to recover log */ | ||
22 | #define XFS_ELOGSTAT 2 /* Failure to stat log in user space */ | ||
23 | #define XFS_ENOLOGSPACE 3 /* Reservation too large */ | ||
24 | #define XFS_ENOTSUP 4 /* Operation not supported */ | ||
25 | #define XFS_ENOLSN 5 /* Can't find the lsn you asked for */ | ||
26 | #define XFS_ENOTFOUND 6 | ||
27 | #define XFS_ENOTXFS 7 /* Not XFS filesystem */ | ||
28 | |||
29 | #ifdef DEBUG | 21 | #ifdef DEBUG |
30 | #define XFS_ERROR_NTRAP 10 | 22 | #define XFS_ERROR_NTRAP 10 |
31 | extern int xfs_etrap[XFS_ERROR_NTRAP]; | 23 | extern int xfs_etrap[XFS_ERROR_NTRAP]; |
@@ -175,6 +167,7 @@ extern int xfs_errortag_clearall_umount(int64_t fsid, char *fsname, int loud); | |||
175 | #define XFS_PTAG_SHUTDOWN_CORRUPT 0x00000010 | 167 | #define XFS_PTAG_SHUTDOWN_CORRUPT 0x00000010 |
176 | #define XFS_PTAG_SHUTDOWN_IOERROR 0x00000020 | 168 | #define XFS_PTAG_SHUTDOWN_IOERROR 0x00000020 |
177 | #define XFS_PTAG_SHUTDOWN_LOGERROR 0x00000040 | 169 | #define XFS_PTAG_SHUTDOWN_LOGERROR 0x00000040 |
170 | #define XFS_PTAG_FSBLOCK_ZERO 0x00000080 | ||
178 | 171 | ||
179 | struct xfs_mount; | 172 | struct xfs_mount; |
180 | /* PRINTFLIKE4 */ | 173 | /* PRINTFLIKE4 */ |
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index 6cf6d8769b97..6dba78199faf 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c | |||
@@ -33,9 +33,6 @@ kmem_zone_t *xfs_efi_zone; | |||
33 | kmem_zone_t *xfs_efd_zone; | 33 | kmem_zone_t *xfs_efd_zone; |
34 | 34 | ||
35 | STATIC void xfs_efi_item_unlock(xfs_efi_log_item_t *); | 35 | STATIC void xfs_efi_item_unlock(xfs_efi_log_item_t *); |
36 | STATIC void xfs_efi_item_abort(xfs_efi_log_item_t *); | ||
37 | STATIC void xfs_efd_item_abort(xfs_efd_log_item_t *); | ||
38 | |||
39 | 36 | ||
40 | void | 37 | void |
41 | xfs_efi_item_free(xfs_efi_log_item_t *efip) | 38 | xfs_efi_item_free(xfs_efi_log_item_t *efip) |
@@ -184,7 +181,7 @@ STATIC void | |||
184 | xfs_efi_item_unlock(xfs_efi_log_item_t *efip) | 181 | xfs_efi_item_unlock(xfs_efi_log_item_t *efip) |
185 | { | 182 | { |
186 | if (efip->efi_item.li_flags & XFS_LI_ABORTED) | 183 | if (efip->efi_item.li_flags & XFS_LI_ABORTED) |
187 | xfs_efi_item_abort(efip); | 184 | xfs_efi_item_free(efip); |
188 | return; | 185 | return; |
189 | } | 186 | } |
190 | 187 | ||
@@ -202,18 +199,6 @@ xfs_efi_item_committed(xfs_efi_log_item_t *efip, xfs_lsn_t lsn) | |||
202 | } | 199 | } |
203 | 200 | ||
204 | /* | 201 | /* |
205 | * This is called when the transaction logging the EFI is aborted. | ||
206 | * Free up the EFI and return. No need to clean up the slot for | ||
207 | * the item in the transaction. That was done by the unpin code | ||
208 | * which is called prior to this routine in the abort/fs-shutdown path. | ||
209 | */ | ||
210 | STATIC void | ||
211 | xfs_efi_item_abort(xfs_efi_log_item_t *efip) | ||
212 | { | ||
213 | xfs_efi_item_free(efip); | ||
214 | } | ||
215 | |||
216 | /* | ||
217 | * There isn't much you can do to push on an efi item. It is simply | 202 | * There isn't much you can do to push on an efi item. It is simply |
218 | * stuck waiting for all of its corresponding efd items to be | 203 | * stuck waiting for all of its corresponding efd items to be |
219 | * committed to disk. | 204 | * committed to disk. |
@@ -255,7 +240,6 @@ STATIC struct xfs_item_ops xfs_efi_item_ops = { | |||
255 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) | 240 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) |
256 | xfs_efi_item_committed, | 241 | xfs_efi_item_committed, |
257 | .iop_push = (void(*)(xfs_log_item_t*))xfs_efi_item_push, | 242 | .iop_push = (void(*)(xfs_log_item_t*))xfs_efi_item_push, |
258 | .iop_abort = (void(*)(xfs_log_item_t*))xfs_efi_item_abort, | ||
259 | .iop_pushbuf = NULL, | 243 | .iop_pushbuf = NULL, |
260 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) | 244 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) |
261 | xfs_efi_item_committing | 245 | xfs_efi_item_committing |
@@ -386,33 +370,6 @@ xfs_efi_release(xfs_efi_log_item_t *efip, | |||
386 | } | 370 | } |
387 | } | 371 | } |
388 | 372 | ||
389 | /* | ||
390 | * This is called when the transaction that should be committing the | ||
391 | * EFD corresponding to the given EFI is aborted. The committed and | ||
392 | * canceled flags are used to coordinate the freeing of the EFI and | ||
393 | * the references by the transaction that committed it. | ||
394 | */ | ||
395 | STATIC void | ||
396 | xfs_efi_cancel( | ||
397 | xfs_efi_log_item_t *efip) | ||
398 | { | ||
399 | xfs_mount_t *mp; | ||
400 | SPLDECL(s); | ||
401 | |||
402 | mp = efip->efi_item.li_mountp; | ||
403 | AIL_LOCK(mp, s); | ||
404 | if (efip->efi_flags & XFS_EFI_COMMITTED) { | ||
405 | /* | ||
406 | * xfs_trans_delete_ail() drops the AIL lock. | ||
407 | */ | ||
408 | xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s); | ||
409 | xfs_efi_item_free(efip); | ||
410 | } else { | ||
411 | efip->efi_flags |= XFS_EFI_CANCELED; | ||
412 | AIL_UNLOCK(mp, s); | ||
413 | } | ||
414 | } | ||
415 | |||
416 | STATIC void | 373 | STATIC void |
417 | xfs_efd_item_free(xfs_efd_log_item_t *efdp) | 374 | xfs_efd_item_free(xfs_efd_log_item_t *efdp) |
418 | { | 375 | { |
@@ -514,7 +471,7 @@ STATIC void | |||
514 | xfs_efd_item_unlock(xfs_efd_log_item_t *efdp) | 471 | xfs_efd_item_unlock(xfs_efd_log_item_t *efdp) |
515 | { | 472 | { |
516 | if (efdp->efd_item.li_flags & XFS_LI_ABORTED) | 473 | if (efdp->efd_item.li_flags & XFS_LI_ABORTED) |
517 | xfs_efd_item_abort(efdp); | 474 | xfs_efd_item_free(efdp); |
518 | return; | 475 | return; |
519 | } | 476 | } |
520 | 477 | ||
@@ -541,27 +498,6 @@ xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn) | |||
541 | } | 498 | } |
542 | 499 | ||
543 | /* | 500 | /* |
544 | * The transaction of which this EFD is a part has been aborted. | ||
545 | * Inform its companion EFI of this fact and then clean up after | ||
546 | * ourselves. No need to clean up the slot for the item in the | ||
547 | * transaction. That was done by the unpin code which is called | ||
548 | * prior to this routine in the abort/fs-shutdown path. | ||
549 | */ | ||
550 | STATIC void | ||
551 | xfs_efd_item_abort(xfs_efd_log_item_t *efdp) | ||
552 | { | ||
553 | /* | ||
554 | * If we got a log I/O error, it's always the case that the LR with the | ||
555 | * EFI got unpinned and freed before the EFD got aborted. So don't | ||
556 | * reference the EFI at all in that case. | ||
557 | */ | ||
558 | if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0) | ||
559 | xfs_efi_cancel(efdp->efd_efip); | ||
560 | |||
561 | xfs_efd_item_free(efdp); | ||
562 | } | ||
563 | |||
564 | /* | ||
565 | * There isn't much you can do to push on an efd item. It is simply | 501 | * There isn't much you can do to push on an efd item. It is simply |
566 | * stuck waiting for the log to be flushed to disk. | 502 | * stuck waiting for the log to be flushed to disk. |
567 | */ | 503 | */ |
@@ -602,7 +538,6 @@ STATIC struct xfs_item_ops xfs_efd_item_ops = { | |||
602 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) | 538 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) |
603 | xfs_efd_item_committed, | 539 | xfs_efd_item_committed, |
604 | .iop_push = (void(*)(xfs_log_item_t*))xfs_efd_item_push, | 540 | .iop_push = (void(*)(xfs_log_item_t*))xfs_efd_item_push, |
605 | .iop_abort = (void(*)(xfs_log_item_t*))xfs_efd_item_abort, | ||
606 | .iop_pushbuf = NULL, | 541 | .iop_pushbuf = NULL, |
607 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) | 542 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) |
608 | xfs_efd_item_committing | 543 | xfs_efd_item_committing |
diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h index 0ea45edaab03..2f049f63e85f 100644 --- a/fs/xfs/xfs_extfree_item.h +++ b/fs/xfs/xfs_extfree_item.h | |||
@@ -33,14 +33,16 @@ typedef struct xfs_extent { | |||
33 | * conversion routine. | 33 | * conversion routine. |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #ifndef HAVE_FORMAT32 | ||
36 | typedef struct xfs_extent_32 { | 37 | typedef struct xfs_extent_32 { |
37 | xfs_dfsbno_t ext_start; | 38 | __uint64_t ext_start; |
38 | xfs_extlen_t ext_len; | 39 | __uint32_t ext_len; |
39 | } __attribute__((packed)) xfs_extent_32_t; | 40 | } __attribute__((packed)) xfs_extent_32_t; |
41 | #endif | ||
40 | 42 | ||
41 | typedef struct xfs_extent_64 { | 43 | typedef struct xfs_extent_64 { |
42 | xfs_dfsbno_t ext_start; | 44 | __uint64_t ext_start; |
43 | xfs_extlen_t ext_len; | 45 | __uint32_t ext_len; |
44 | __uint32_t ext_pad; | 46 | __uint32_t ext_pad; |
45 | } xfs_extent_64_t; | 47 | } xfs_extent_64_t; |
46 | 48 | ||
@@ -50,25 +52,27 @@ typedef struct xfs_extent_64 { | |||
50 | * size is given by efi_nextents. | 52 | * size is given by efi_nextents. |
51 | */ | 53 | */ |
52 | typedef struct xfs_efi_log_format { | 54 | typedef struct xfs_efi_log_format { |
53 | unsigned short efi_type; /* efi log item type */ | 55 | __uint16_t efi_type; /* efi log item type */ |
54 | unsigned short efi_size; /* size of this item */ | 56 | __uint16_t efi_size; /* size of this item */ |
55 | uint efi_nextents; /* # extents to free */ | 57 | __uint32_t efi_nextents; /* # extents to free */ |
56 | __uint64_t efi_id; /* efi identifier */ | 58 | __uint64_t efi_id; /* efi identifier */ |
57 | xfs_extent_t efi_extents[1]; /* array of extents to free */ | 59 | xfs_extent_t efi_extents[1]; /* array of extents to free */ |
58 | } xfs_efi_log_format_t; | 60 | } xfs_efi_log_format_t; |
59 | 61 | ||
62 | #ifndef HAVE_FORMAT32 | ||
60 | typedef struct xfs_efi_log_format_32 { | 63 | typedef struct xfs_efi_log_format_32 { |
61 | unsigned short efi_type; /* efi log item type */ | 64 | __uint16_t efi_type; /* efi log item type */ |
62 | unsigned short efi_size; /* size of this item */ | 65 | __uint16_t efi_size; /* size of this item */ |
63 | uint efi_nextents; /* # extents to free */ | 66 | __uint32_t efi_nextents; /* # extents to free */ |
64 | __uint64_t efi_id; /* efi identifier */ | 67 | __uint64_t efi_id; /* efi identifier */ |
65 | xfs_extent_32_t efi_extents[1]; /* array of extents to free */ | 68 | xfs_extent_32_t efi_extents[1]; /* array of extents to free */ |
66 | } __attribute__((packed)) xfs_efi_log_format_32_t; | 69 | } __attribute__((packed)) xfs_efi_log_format_32_t; |
70 | #endif | ||
67 | 71 | ||
68 | typedef struct xfs_efi_log_format_64 { | 72 | typedef struct xfs_efi_log_format_64 { |
69 | unsigned short efi_type; /* efi log item type */ | 73 | __uint16_t efi_type; /* efi log item type */ |
70 | unsigned short efi_size; /* size of this item */ | 74 | __uint16_t efi_size; /* size of this item */ |
71 | uint efi_nextents; /* # extents to free */ | 75 | __uint32_t efi_nextents; /* # extents to free */ |
72 | __uint64_t efi_id; /* efi identifier */ | 76 | __uint64_t efi_id; /* efi identifier */ |
73 | xfs_extent_64_t efi_extents[1]; /* array of extents to free */ | 77 | xfs_extent_64_t efi_extents[1]; /* array of extents to free */ |
74 | } xfs_efi_log_format_64_t; | 78 | } xfs_efi_log_format_64_t; |
@@ -79,25 +83,27 @@ typedef struct xfs_efi_log_format_64 { | |||
79 | * size is given by efd_nextents; | 83 | * size is given by efd_nextents; |
80 | */ | 84 | */ |
81 | typedef struct xfs_efd_log_format { | 85 | typedef struct xfs_efd_log_format { |
82 | unsigned short efd_type; /* efd log item type */ | 86 | __uint16_t efd_type; /* efd log item type */ |
83 | unsigned short efd_size; /* size of this item */ | 87 | __uint16_t efd_size; /* size of this item */ |
84 | uint efd_nextents; /* # of extents freed */ | 88 | __uint32_t efd_nextents; /* # of extents freed */ |
85 | __uint64_t efd_efi_id; /* id of corresponding efi */ | 89 | __uint64_t efd_efi_id; /* id of corresponding efi */ |
86 | xfs_extent_t efd_extents[1]; /* array of extents freed */ | 90 | xfs_extent_t efd_extents[1]; /* array of extents freed */ |
87 | } xfs_efd_log_format_t; | 91 | } xfs_efd_log_format_t; |
88 | 92 | ||
93 | #ifndef HAVE_FORMAT32 | ||
89 | typedef struct xfs_efd_log_format_32 { | 94 | typedef struct xfs_efd_log_format_32 { |
90 | unsigned short efd_type; /* efd log item type */ | 95 | __uint16_t efd_type; /* efd log item type */ |
91 | unsigned short efd_size; /* size of this item */ | 96 | __uint16_t efd_size; /* size of this item */ |
92 | uint efd_nextents; /* # of extents freed */ | 97 | __uint32_t efd_nextents; /* # of extents freed */ |
93 | __uint64_t efd_efi_id; /* id of corresponding efi */ | 98 | __uint64_t efd_efi_id; /* id of corresponding efi */ |
94 | xfs_extent_32_t efd_extents[1]; /* array of extents freed */ | 99 | xfs_extent_32_t efd_extents[1]; /* array of extents freed */ |
95 | } __attribute__((packed)) xfs_efd_log_format_32_t; | 100 | } __attribute__((packed)) xfs_efd_log_format_32_t; |
101 | #endif | ||
96 | 102 | ||
97 | typedef struct xfs_efd_log_format_64 { | 103 | typedef struct xfs_efd_log_format_64 { |
98 | unsigned short efd_type; /* efd log item type */ | 104 | __uint16_t efd_type; /* efd log item type */ |
99 | unsigned short efd_size; /* size of this item */ | 105 | __uint16_t efd_size; /* size of this item */ |
100 | uint efd_nextents; /* # of extents freed */ | 106 | __uint32_t efd_nextents; /* # of extents freed */ |
101 | __uint64_t efd_efi_id; /* id of corresponding efi */ | 107 | __uint64_t efd_efi_id; /* id of corresponding efi */ |
102 | xfs_extent_64_t efd_extents[1]; /* array of extents freed */ | 108 | xfs_extent_64_t efd_extents[1]; /* array of extents freed */ |
103 | } xfs_efd_log_format_64_t; | 109 | } xfs_efd_log_format_64_t; |
diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h index 0f0ad1535951..1335449841cd 100644 --- a/fs/xfs/xfs_fs.h +++ b/fs/xfs/xfs_fs.h | |||
@@ -22,8 +22,6 @@ | |||
22 | * SGI's XFS filesystem's major stuff (constants, structures) | 22 | * SGI's XFS filesystem's major stuff (constants, structures) |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #define XFS_NAME "xfs" | ||
26 | |||
27 | /* | 25 | /* |
28 | * Direct I/O attribute record used with XFS_IOC_DIOINFO | 26 | * Direct I/O attribute record used with XFS_IOC_DIOINFO |
29 | * d_miniosz is the min xfer size, xfer size multiple and file seek offset | 27 | * d_miniosz is the min xfer size, xfer size multiple and file seek offset |
@@ -426,11 +424,7 @@ typedef struct xfs_handle { | |||
426 | - (char *) &(handle)) \ | 424 | - (char *) &(handle)) \ |
427 | + (handle).ha_fid.xfs_fid_len) | 425 | + (handle).ha_fid.xfs_fid_len) |
428 | 426 | ||
429 | #define XFS_HANDLE_CMP(h1, h2) memcmp(h1, h2, sizeof(xfs_handle_t)) | 427 | /* |
430 | |||
431 | #define FSHSIZE sizeof(fsid_t) | ||
432 | |||
433 | /* | ||
434 | * Flags for going down operation | 428 | * Flags for going down operation |
435 | */ | 429 | */ |
436 | #define XFS_FSOP_GOING_FLAGS_DEFAULT 0x0 /* going down */ | 430 | #define XFS_FSOP_GOING_FLAGS_DEFAULT 0x0 /* going down */ |
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index 33164a85aa9d..a446e5a115c6 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
@@ -458,7 +458,7 @@ nextag: | |||
458 | */ | 458 | */ |
459 | if (XFS_FORCED_SHUTDOWN(mp)) { | 459 | if (XFS_FORCED_SHUTDOWN(mp)) { |
460 | up_read(&mp->m_peraglock); | 460 | up_read(&mp->m_peraglock); |
461 | return (xfs_buf_t *)0; | 461 | return NULL; |
462 | } | 462 | } |
463 | agno++; | 463 | agno++; |
464 | if (agno >= agcount) | 464 | if (agno >= agcount) |
@@ -466,7 +466,7 @@ nextag: | |||
466 | if (agno == pagno) { | 466 | if (agno == pagno) { |
467 | if (flags == 0) { | 467 | if (flags == 0) { |
468 | up_read(&mp->m_peraglock); | 468 | up_read(&mp->m_peraglock); |
469 | return (xfs_buf_t *)0; | 469 | return NULL; |
470 | } | 470 | } |
471 | flags = 0; | 471 | flags = 0; |
472 | } | 472 | } |
@@ -529,10 +529,10 @@ xfs_dialloc( | |||
529 | int offset; /* index of inode in chunk */ | 529 | int offset; /* index of inode in chunk */ |
530 | xfs_agino_t pagino; /* parent's a.g. relative inode # */ | 530 | xfs_agino_t pagino; /* parent's a.g. relative inode # */ |
531 | xfs_agnumber_t pagno; /* parent's allocation group number */ | 531 | xfs_agnumber_t pagno; /* parent's allocation group number */ |
532 | xfs_inobt_rec_t rec; /* inode allocation record */ | 532 | xfs_inobt_rec_incore_t rec; /* inode allocation record */ |
533 | xfs_agnumber_t tagno; /* testing allocation group number */ | 533 | xfs_agnumber_t tagno; /* testing allocation group number */ |
534 | xfs_btree_cur_t *tcur; /* temp cursor */ | 534 | xfs_btree_cur_t *tcur; /* temp cursor */ |
535 | xfs_inobt_rec_t trec; /* temp inode allocation record */ | 535 | xfs_inobt_rec_incore_t trec; /* temp inode allocation record */ |
536 | 536 | ||
537 | 537 | ||
538 | if (*IO_agbp == NULL) { | 538 | if (*IO_agbp == NULL) { |
@@ -945,7 +945,7 @@ xfs_difree( | |||
945 | int ilen; /* inodes in an inode cluster */ | 945 | int ilen; /* inodes in an inode cluster */ |
946 | xfs_mount_t *mp; /* mount structure for filesystem */ | 946 | xfs_mount_t *mp; /* mount structure for filesystem */ |
947 | int off; /* offset of inode in inode chunk */ | 947 | int off; /* offset of inode in inode chunk */ |
948 | xfs_inobt_rec_t rec; /* btree record */ | 948 | xfs_inobt_rec_incore_t rec; /* btree record */ |
949 | 949 | ||
950 | mp = tp->t_mountp; | 950 | mp = tp->t_mountp; |
951 | 951 | ||
@@ -1195,6 +1195,7 @@ xfs_dilocate( | |||
1195 | "(0x%llx)", | 1195 | "(0x%llx)", |
1196 | ino, XFS_AGINO_TO_INO(mp, agno, agino)); | 1196 | ino, XFS_AGINO_TO_INO(mp, agno, agino)); |
1197 | } | 1197 | } |
1198 | xfs_stack_trace(); | ||
1198 | #endif /* DEBUG */ | 1199 | #endif /* DEBUG */ |
1199 | return XFS_ERROR(EINVAL); | 1200 | return XFS_ERROR(EINVAL); |
1200 | } | 1201 | } |
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c index 616eeeb6953e..8cdeeaf8632b 100644 --- a/fs/xfs/xfs_ialloc_btree.c +++ b/fs/xfs/xfs_ialloc_btree.c | |||
@@ -568,7 +568,7 @@ xfs_inobt_insrec( | |||
568 | /* | 568 | /* |
569 | * Make a key out of the record data to be inserted, and save it. | 569 | * Make a key out of the record data to be inserted, and save it. |
570 | */ | 570 | */ |
571 | key.ir_startino = recp->ir_startino; /* INT_: direct copy */ | 571 | key.ir_startino = recp->ir_startino; |
572 | optr = ptr = cur->bc_ptrs[level]; | 572 | optr = ptr = cur->bc_ptrs[level]; |
573 | /* | 573 | /* |
574 | * If we're off the left edge, return failure. | 574 | * If we're off the left edge, return failure. |
@@ -600,7 +600,7 @@ xfs_inobt_insrec( | |||
600 | } | 600 | } |
601 | #endif | 601 | #endif |
602 | nbno = NULLAGBLOCK; | 602 | nbno = NULLAGBLOCK; |
603 | ncur = (xfs_btree_cur_t *)0; | 603 | ncur = NULL; |
604 | /* | 604 | /* |
605 | * If the block is full, we can't insert the new entry until we | 605 | * If the block is full, we can't insert the new entry until we |
606 | * make the block un-full. | 606 | * make the block un-full. |
@@ -641,7 +641,7 @@ xfs_inobt_insrec( | |||
641 | return error; | 641 | return error; |
642 | #endif | 642 | #endif |
643 | ptr = cur->bc_ptrs[level]; | 643 | ptr = cur->bc_ptrs[level]; |
644 | nrec.ir_startino = nkey.ir_startino; /* INT_: direct copy */ | 644 | nrec.ir_startino = nkey.ir_startino; |
645 | } else { | 645 | } else { |
646 | /* | 646 | /* |
647 | * Otherwise the insert fails. | 647 | * Otherwise the insert fails. |
@@ -681,7 +681,7 @@ xfs_inobt_insrec( | |||
681 | if ((error = xfs_btree_check_sptr(cur, *bnop, level))) | 681 | if ((error = xfs_btree_check_sptr(cur, *bnop, level))) |
682 | return error; | 682 | return error; |
683 | #endif | 683 | #endif |
684 | kp[ptr - 1] = key; /* INT_: struct copy */ | 684 | kp[ptr - 1] = key; |
685 | pp[ptr - 1] = cpu_to_be32(*bnop); | 685 | pp[ptr - 1] = cpu_to_be32(*bnop); |
686 | numrecs++; | 686 | numrecs++; |
687 | block->bb_numrecs = cpu_to_be16(numrecs); | 687 | block->bb_numrecs = cpu_to_be16(numrecs); |
@@ -698,7 +698,7 @@ xfs_inobt_insrec( | |||
698 | * Now stuff the new record in, bump numrecs | 698 | * Now stuff the new record in, bump numrecs |
699 | * and log the new data. | 699 | * and log the new data. |
700 | */ | 700 | */ |
701 | rp[ptr - 1] = *recp; /* INT_: struct copy */ | 701 | rp[ptr - 1] = *recp; |
702 | numrecs++; | 702 | numrecs++; |
703 | block->bb_numrecs = cpu_to_be16(numrecs); | 703 | block->bb_numrecs = cpu_to_be16(numrecs); |
704 | xfs_inobt_log_recs(cur, bp, ptr, numrecs); | 704 | xfs_inobt_log_recs(cur, bp, ptr, numrecs); |
@@ -731,7 +731,7 @@ xfs_inobt_insrec( | |||
731 | */ | 731 | */ |
732 | *bnop = nbno; | 732 | *bnop = nbno; |
733 | if (nbno != NULLAGBLOCK) { | 733 | if (nbno != NULLAGBLOCK) { |
734 | *recp = nrec; /* INT_: struct copy */ | 734 | *recp = nrec; |
735 | *curp = ncur; | 735 | *curp = ncur; |
736 | } | 736 | } |
737 | *stat = 1; | 737 | *stat = 1; |
@@ -878,7 +878,7 @@ xfs_inobt_lookup( | |||
878 | */ | 878 | */ |
879 | bp = cur->bc_bufs[level]; | 879 | bp = cur->bc_bufs[level]; |
880 | if (bp && XFS_BUF_ADDR(bp) != d) | 880 | if (bp && XFS_BUF_ADDR(bp) != d) |
881 | bp = (xfs_buf_t *)0; | 881 | bp = NULL; |
882 | if (!bp) { | 882 | if (!bp) { |
883 | /* | 883 | /* |
884 | * Need to get a new buffer. Read it, then | 884 | * Need to get a new buffer. Read it, then |
@@ -950,12 +950,12 @@ xfs_inobt_lookup( | |||
950 | xfs_inobt_key_t *kkp; | 950 | xfs_inobt_key_t *kkp; |
951 | 951 | ||
952 | kkp = kkbase + keyno - 1; | 952 | kkp = kkbase + keyno - 1; |
953 | startino = INT_GET(kkp->ir_startino, ARCH_CONVERT); | 953 | startino = be32_to_cpu(kkp->ir_startino); |
954 | } else { | 954 | } else { |
955 | xfs_inobt_rec_t *krp; | 955 | xfs_inobt_rec_t *krp; |
956 | 956 | ||
957 | krp = krbase + keyno - 1; | 957 | krp = krbase + keyno - 1; |
958 | startino = INT_GET(krp->ir_startino, ARCH_CONVERT); | 958 | startino = be32_to_cpu(krp->ir_startino); |
959 | } | 959 | } |
960 | /* | 960 | /* |
961 | * Compute difference to get next direction. | 961 | * Compute difference to get next direction. |
@@ -1117,7 +1117,7 @@ xfs_inobt_lshift( | |||
1117 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*rpp), level))) | 1117 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*rpp), level))) |
1118 | return error; | 1118 | return error; |
1119 | #endif | 1119 | #endif |
1120 | *lpp = *rpp; /* INT_: no-change copy */ | 1120 | *lpp = *rpp; |
1121 | xfs_inobt_log_ptrs(cur, lbp, nrec, nrec); | 1121 | xfs_inobt_log_ptrs(cur, lbp, nrec, nrec); |
1122 | } | 1122 | } |
1123 | /* | 1123 | /* |
@@ -1160,7 +1160,7 @@ xfs_inobt_lshift( | |||
1160 | } else { | 1160 | } else { |
1161 | memmove(rrp, rrp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); | 1161 | memmove(rrp, rrp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1162 | xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); | 1162 | xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1163 | key.ir_startino = rrp->ir_startino; /* INT_: direct copy */ | 1163 | key.ir_startino = rrp->ir_startino; |
1164 | rkp = &key; | 1164 | rkp = &key; |
1165 | } | 1165 | } |
1166 | /* | 1166 | /* |
@@ -1297,13 +1297,13 @@ xfs_inobt_newroot( | |||
1297 | */ | 1297 | */ |
1298 | kp = XFS_INOBT_KEY_ADDR(new, 1, cur); | 1298 | kp = XFS_INOBT_KEY_ADDR(new, 1, cur); |
1299 | if (be16_to_cpu(left->bb_level) > 0) { | 1299 | if (be16_to_cpu(left->bb_level) > 0) { |
1300 | kp[0] = *XFS_INOBT_KEY_ADDR(left, 1, cur); /* INT_: struct copy */ | 1300 | kp[0] = *XFS_INOBT_KEY_ADDR(left, 1, cur); |
1301 | kp[1] = *XFS_INOBT_KEY_ADDR(right, 1, cur); /* INT_: struct copy */ | 1301 | kp[1] = *XFS_INOBT_KEY_ADDR(right, 1, cur); |
1302 | } else { | 1302 | } else { |
1303 | rp = XFS_INOBT_REC_ADDR(left, 1, cur); | 1303 | rp = XFS_INOBT_REC_ADDR(left, 1, cur); |
1304 | INT_COPY(kp[0].ir_startino, rp->ir_startino, ARCH_CONVERT); | 1304 | kp[0].ir_startino = rp->ir_startino; |
1305 | rp = XFS_INOBT_REC_ADDR(right, 1, cur); | 1305 | rp = XFS_INOBT_REC_ADDR(right, 1, cur); |
1306 | INT_COPY(kp[1].ir_startino, rp->ir_startino, ARCH_CONVERT); | 1306 | kp[1].ir_startino = rp->ir_startino; |
1307 | } | 1307 | } |
1308 | xfs_inobt_log_keys(cur, nbp, 1, 2); | 1308 | xfs_inobt_log_keys(cur, nbp, 1, 2); |
1309 | /* | 1309 | /* |
@@ -1410,8 +1410,8 @@ xfs_inobt_rshift( | |||
1410 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*lpp), level))) | 1410 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*lpp), level))) |
1411 | return error; | 1411 | return error; |
1412 | #endif | 1412 | #endif |
1413 | *rkp = *lkp; /* INT_: no change copy */ | 1413 | *rkp = *lkp; |
1414 | *rpp = *lpp; /* INT_: no change copy */ | 1414 | *rpp = *lpp; |
1415 | xfs_inobt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); | 1415 | xfs_inobt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1416 | xfs_inobt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); | 1416 | xfs_inobt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1417 | } else { | 1417 | } else { |
@@ -1420,7 +1420,7 @@ xfs_inobt_rshift( | |||
1420 | memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); | 1420 | memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1421 | *rrp = *lrp; | 1421 | *rrp = *lrp; |
1422 | xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); | 1422 | xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1423 | key.ir_startino = rrp->ir_startino; /* INT_: direct copy */ | 1423 | key.ir_startino = rrp->ir_startino; |
1424 | rkp = &key; | 1424 | rkp = &key; |
1425 | } | 1425 | } |
1426 | /* | 1426 | /* |
@@ -1559,7 +1559,7 @@ xfs_inobt_split( | |||
1559 | rrp = XFS_INOBT_REC_ADDR(right, 1, cur); | 1559 | rrp = XFS_INOBT_REC_ADDR(right, 1, cur); |
1560 | memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); | 1560 | memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1561 | xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); | 1561 | xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1562 | keyp->ir_startino = rrp->ir_startino; /* INT_: direct copy */ | 1562 | keyp->ir_startino = rrp->ir_startino; |
1563 | } | 1563 | } |
1564 | /* | 1564 | /* |
1565 | * Find the left block number by looking in the buffer. | 1565 | * Find the left block number by looking in the buffer. |
@@ -1813,9 +1813,9 @@ xfs_inobt_get_rec( | |||
1813 | * Point to the record and extract its data. | 1813 | * Point to the record and extract its data. |
1814 | */ | 1814 | */ |
1815 | rec = XFS_INOBT_REC_ADDR(block, ptr, cur); | 1815 | rec = XFS_INOBT_REC_ADDR(block, ptr, cur); |
1816 | *ino = INT_GET(rec->ir_startino, ARCH_CONVERT); | 1816 | *ino = be32_to_cpu(rec->ir_startino); |
1817 | *fcnt = INT_GET(rec->ir_freecount, ARCH_CONVERT); | 1817 | *fcnt = be32_to_cpu(rec->ir_freecount); |
1818 | *free = INT_GET(rec->ir_free, ARCH_CONVERT); | 1818 | *free = be64_to_cpu(rec->ir_free); |
1819 | *stat = 1; | 1819 | *stat = 1; |
1820 | return 0; | 1820 | return 0; |
1821 | } | 1821 | } |
@@ -1930,10 +1930,10 @@ xfs_inobt_insert( | |||
1930 | 1930 | ||
1931 | level = 0; | 1931 | level = 0; |
1932 | nbno = NULLAGBLOCK; | 1932 | nbno = NULLAGBLOCK; |
1933 | INT_SET(nrec.ir_startino, ARCH_CONVERT, cur->bc_rec.i.ir_startino); | 1933 | nrec.ir_startino = cpu_to_be32(cur->bc_rec.i.ir_startino); |
1934 | INT_SET(nrec.ir_freecount, ARCH_CONVERT, cur->bc_rec.i.ir_freecount); | 1934 | nrec.ir_freecount = cpu_to_be32(cur->bc_rec.i.ir_freecount); |
1935 | INT_SET(nrec.ir_free, ARCH_CONVERT, cur->bc_rec.i.ir_free); | 1935 | nrec.ir_free = cpu_to_be64(cur->bc_rec.i.ir_free); |
1936 | ncur = (xfs_btree_cur_t *)0; | 1936 | ncur = NULL; |
1937 | pcur = cur; | 1937 | pcur = cur; |
1938 | /* | 1938 | /* |
1939 | * Loop going up the tree, starting at the leaf level. | 1939 | * Loop going up the tree, starting at the leaf level. |
@@ -1965,7 +1965,7 @@ xfs_inobt_insert( | |||
1965 | */ | 1965 | */ |
1966 | if (ncur) { | 1966 | if (ncur) { |
1967 | pcur = ncur; | 1967 | pcur = ncur; |
1968 | ncur = (xfs_btree_cur_t *)0; | 1968 | ncur = NULL; |
1969 | } | 1969 | } |
1970 | } while (nbno != NULLAGBLOCK); | 1970 | } while (nbno != NULLAGBLOCK); |
1971 | *stat = i; | 1971 | *stat = i; |
@@ -2060,9 +2060,9 @@ xfs_inobt_update( | |||
2060 | /* | 2060 | /* |
2061 | * Fill in the new contents and log them. | 2061 | * Fill in the new contents and log them. |
2062 | */ | 2062 | */ |
2063 | INT_SET(rp->ir_startino, ARCH_CONVERT, ino); | 2063 | rp->ir_startino = cpu_to_be32(ino); |
2064 | INT_SET(rp->ir_freecount, ARCH_CONVERT, fcnt); | 2064 | rp->ir_freecount = cpu_to_be32(fcnt); |
2065 | INT_SET(rp->ir_free, ARCH_CONVERT, free); | 2065 | rp->ir_free = cpu_to_be64(free); |
2066 | xfs_inobt_log_recs(cur, bp, ptr, ptr); | 2066 | xfs_inobt_log_recs(cur, bp, ptr, ptr); |
2067 | /* | 2067 | /* |
2068 | * Updating first record in leaf. Pass new key value up to our parent. | 2068 | * Updating first record in leaf. Pass new key value up to our parent. |
@@ -2070,7 +2070,7 @@ xfs_inobt_update( | |||
2070 | if (ptr == 1) { | 2070 | if (ptr == 1) { |
2071 | xfs_inobt_key_t key; /* key containing [ino] */ | 2071 | xfs_inobt_key_t key; /* key containing [ino] */ |
2072 | 2072 | ||
2073 | INT_SET(key.ir_startino, ARCH_CONVERT, ino); | 2073 | key.ir_startino = cpu_to_be32(ino); |
2074 | if ((error = xfs_inobt_updkey(cur, &key, 1))) | 2074 | if ((error = xfs_inobt_updkey(cur, &key, 1))) |
2075 | return error; | 2075 | return error; |
2076 | } | 2076 | } |
diff --git a/fs/xfs/xfs_ialloc_btree.h b/fs/xfs/xfs_ialloc_btree.h index ae3904cb1ee8..2c0e49893ff7 100644 --- a/fs/xfs/xfs_ialloc_btree.h +++ b/fs/xfs/xfs_ialloc_btree.h | |||
@@ -47,19 +47,24 @@ static inline xfs_inofree_t xfs_inobt_maskn(int i, int n) | |||
47 | /* | 47 | /* |
48 | * Data record structure | 48 | * Data record structure |
49 | */ | 49 | */ |
50 | typedef struct xfs_inobt_rec | 50 | typedef struct xfs_inobt_rec { |
51 | { | 51 | __be32 ir_startino; /* starting inode number */ |
52 | __be32 ir_freecount; /* count of free inodes (set bits) */ | ||
53 | __be64 ir_free; /* free inode mask */ | ||
54 | } xfs_inobt_rec_t; | ||
55 | |||
56 | typedef struct xfs_inobt_rec_incore { | ||
52 | xfs_agino_t ir_startino; /* starting inode number */ | 57 | xfs_agino_t ir_startino; /* starting inode number */ |
53 | __int32_t ir_freecount; /* count of free inodes (set bits) */ | 58 | __int32_t ir_freecount; /* count of free inodes (set bits) */ |
54 | xfs_inofree_t ir_free; /* free inode mask */ | 59 | xfs_inofree_t ir_free; /* free inode mask */ |
55 | } xfs_inobt_rec_t; | 60 | } xfs_inobt_rec_incore_t; |
61 | |||
56 | 62 | ||
57 | /* | 63 | /* |
58 | * Key structure | 64 | * Key structure |
59 | */ | 65 | */ |
60 | typedef struct xfs_inobt_key | 66 | typedef struct xfs_inobt_key { |
61 | { | 67 | __be32 ir_startino; /* starting inode number */ |
62 | xfs_agino_t ir_startino; /* starting inode number */ | ||
63 | } xfs_inobt_key_t; | 68 | } xfs_inobt_key_t; |
64 | 69 | ||
65 | /* btree pointer type */ | 70 | /* btree pointer type */ |
@@ -77,7 +82,7 @@ typedef struct xfs_btree_sblock xfs_inobt_block_t; | |||
77 | #define XFS_INOBT_IS_FREE(rp,i) \ | 82 | #define XFS_INOBT_IS_FREE(rp,i) \ |
78 | (((rp)->ir_free & XFS_INOBT_MASK(i)) != 0) | 83 | (((rp)->ir_free & XFS_INOBT_MASK(i)) != 0) |
79 | #define XFS_INOBT_IS_FREE_DISK(rp,i) \ | 84 | #define XFS_INOBT_IS_FREE_DISK(rp,i) \ |
80 | ((INT_GET((rp)->ir_free,ARCH_CONVERT) & XFS_INOBT_MASK(i)) != 0) | 85 | ((be64_to_cpu((rp)->ir_free) & XFS_INOBT_MASK(i)) != 0) |
81 | #define XFS_INOBT_SET_FREE(rp,i) ((rp)->ir_free |= XFS_INOBT_MASK(i)) | 86 | #define XFS_INOBT_SET_FREE(rp,i) ((rp)->ir_free |= XFS_INOBT_MASK(i)) |
82 | #define XFS_INOBT_CLR_FREE(rp,i) ((rp)->ir_free &= ~XFS_INOBT_MASK(i)) | 87 | #define XFS_INOBT_CLR_FREE(rp,i) ((rp)->ir_free &= ~XFS_INOBT_MASK(i)) |
83 | 88 | ||
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c index 0724df7fabb7..b73d216ecaf9 100644 --- a/fs/xfs/xfs_iget.c +++ b/fs/xfs/xfs_iget.c | |||
@@ -50,7 +50,7 @@ void | |||
50 | xfs_ihash_init(xfs_mount_t *mp) | 50 | xfs_ihash_init(xfs_mount_t *mp) |
51 | { | 51 | { |
52 | __uint64_t icount; | 52 | __uint64_t icount; |
53 | uint i, flags = KM_SLEEP | KM_MAYFAIL; | 53 | uint i; |
54 | 54 | ||
55 | if (!mp->m_ihsize) { | 55 | if (!mp->m_ihsize) { |
56 | icount = mp->m_maxicount ? mp->m_maxicount : | 56 | icount = mp->m_maxicount ? mp->m_maxicount : |
@@ -61,14 +61,13 @@ xfs_ihash_init(xfs_mount_t *mp) | |||
61 | (64 * NBPP) / sizeof(xfs_ihash_t)); | 61 | (64 * NBPP) / sizeof(xfs_ihash_t)); |
62 | } | 62 | } |
63 | 63 | ||
64 | while (!(mp->m_ihash = (xfs_ihash_t *)kmem_zalloc(mp->m_ihsize * | 64 | mp->m_ihash = kmem_zalloc_greedy(&mp->m_ihsize, |
65 | sizeof(xfs_ihash_t), flags))) { | 65 | NBPC * sizeof(xfs_ihash_t), |
66 | if ((mp->m_ihsize >>= 1) <= NBPP) | 66 | mp->m_ihsize * sizeof(xfs_ihash_t), |
67 | flags = KM_SLEEP; | 67 | KM_SLEEP | KM_MAYFAIL | KM_LARGE); |
68 | } | 68 | mp->m_ihsize /= sizeof(xfs_ihash_t); |
69 | for (i = 0; i < mp->m_ihsize; i++) { | 69 | for (i = 0; i < mp->m_ihsize; i++) |
70 | rwlock_init(&(mp->m_ihash[i].ih_lock)); | 70 | rwlock_init(&(mp->m_ihash[i].ih_lock)); |
71 | } | ||
72 | } | 71 | } |
73 | 72 | ||
74 | /* | 73 | /* |
@@ -77,7 +76,7 @@ xfs_ihash_init(xfs_mount_t *mp) | |||
77 | void | 76 | void |
78 | xfs_ihash_free(xfs_mount_t *mp) | 77 | xfs_ihash_free(xfs_mount_t *mp) |
79 | { | 78 | { |
80 | kmem_free(mp->m_ihash, mp->m_ihsize*sizeof(xfs_ihash_t)); | 79 | kmem_free(mp->m_ihash, mp->m_ihsize * sizeof(xfs_ihash_t)); |
81 | mp->m_ihash = NULL; | 80 | mp->m_ihash = NULL; |
82 | } | 81 | } |
83 | 82 | ||
@@ -95,7 +94,7 @@ xfs_chash_init(xfs_mount_t *mp) | |||
95 | mp->m_chsize = min_t(uint, mp->m_chsize, mp->m_ihsize); | 94 | mp->m_chsize = min_t(uint, mp->m_chsize, mp->m_ihsize); |
96 | mp->m_chash = (xfs_chash_t *)kmem_zalloc(mp->m_chsize | 95 | mp->m_chash = (xfs_chash_t *)kmem_zalloc(mp->m_chsize |
97 | * sizeof(xfs_chash_t), | 96 | * sizeof(xfs_chash_t), |
98 | KM_SLEEP); | 97 | KM_SLEEP | KM_LARGE); |
99 | for (i = 0; i < mp->m_chsize; i++) { | 98 | for (i = 0; i < mp->m_chsize; i++) { |
100 | spinlock_init(&mp->m_chash[i].ch_lock,"xfshash"); | 99 | spinlock_init(&mp->m_chash[i].ch_lock,"xfshash"); |
101 | } | 100 | } |
@@ -244,7 +243,9 @@ again: | |||
244 | 243 | ||
245 | XFS_STATS_INC(xs_ig_found); | 244 | XFS_STATS_INC(xs_ig_found); |
246 | 245 | ||
246 | spin_lock(&ip->i_flags_lock); | ||
247 | ip->i_flags &= ~XFS_IRECLAIMABLE; | 247 | ip->i_flags &= ~XFS_IRECLAIMABLE; |
248 | spin_unlock(&ip->i_flags_lock); | ||
248 | version = ih->ih_version; | 249 | version = ih->ih_version; |
249 | read_unlock(&ih->ih_lock); | 250 | read_unlock(&ih->ih_lock); |
250 | xfs_ihash_promote(ih, ip, version); | 251 | xfs_ihash_promote(ih, ip, version); |
@@ -290,15 +291,17 @@ again: | |||
290 | 291 | ||
291 | finish_inode: | 292 | finish_inode: |
292 | if (ip->i_d.di_mode == 0) { | 293 | if (ip->i_d.di_mode == 0) { |
293 | if (!(flags & IGET_CREATE)) | 294 | if (!(flags & XFS_IGET_CREATE)) |
294 | return ENOENT; | 295 | return ENOENT; |
295 | xfs_iocore_inode_reinit(ip); | 296 | xfs_iocore_inode_reinit(ip); |
296 | } | 297 | } |
297 | 298 | ||
298 | if (lock_flags != 0) | 299 | if (lock_flags != 0) |
299 | xfs_ilock(ip, lock_flags); | 300 | xfs_ilock(ip, lock_flags); |
300 | 301 | ||
302 | spin_lock(&ip->i_flags_lock); | ||
301 | ip->i_flags &= ~XFS_ISTALE; | 303 | ip->i_flags &= ~XFS_ISTALE; |
304 | spin_unlock(&ip->i_flags_lock); | ||
302 | 305 | ||
303 | vn_trace_exit(vp, "xfs_iget.found", | 306 | vn_trace_exit(vp, "xfs_iget.found", |
304 | (inst_t *)__return_address); | 307 | (inst_t *)__return_address); |
@@ -320,21 +323,20 @@ finish_inode: | |||
320 | * Read the disk inode attributes into a new inode structure and get | 323 | * Read the disk inode attributes into a new inode structure and get |
321 | * a new vnode for it. This should also initialize i_ino and i_mount. | 324 | * a new vnode for it. This should also initialize i_ino and i_mount. |
322 | */ | 325 | */ |
323 | error = xfs_iread(mp, tp, ino, &ip, bno); | 326 | error = xfs_iread(mp, tp, ino, &ip, bno, |
324 | if (error) { | 327 | (flags & XFS_IGET_BULKSTAT) ? XFS_IMAP_BULKSTAT : 0); |
328 | if (error) | ||
325 | return error; | 329 | return error; |
326 | } | ||
327 | 330 | ||
328 | vn_trace_exit(vp, "xfs_iget.alloc", (inst_t *)__return_address); | 331 | vn_trace_exit(vp, "xfs_iget.alloc", (inst_t *)__return_address); |
329 | 332 | ||
330 | xfs_inode_lock_init(ip, vp); | 333 | xfs_inode_lock_init(ip, vp); |
331 | xfs_iocore_inode_init(ip); | 334 | xfs_iocore_inode_init(ip); |
332 | 335 | ||
333 | if (lock_flags != 0) { | 336 | if (lock_flags) |
334 | xfs_ilock(ip, lock_flags); | 337 | xfs_ilock(ip, lock_flags); |
335 | } | 338 | |
336 | 339 | if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) { | |
337 | if ((ip->i_d.di_mode == 0) && !(flags & IGET_CREATE)) { | ||
338 | xfs_idestroy(ip); | 340 | xfs_idestroy(ip); |
339 | return ENOENT; | 341 | return ENOENT; |
340 | } | 342 | } |
@@ -369,7 +371,9 @@ finish_inode: | |||
369 | ih->ih_next = ip; | 371 | ih->ih_next = ip; |
370 | ip->i_udquot = ip->i_gdquot = NULL; | 372 | ip->i_udquot = ip->i_gdquot = NULL; |
371 | ih->ih_version++; | 373 | ih->ih_version++; |
374 | spin_lock(&ip->i_flags_lock); | ||
372 | ip->i_flags |= XFS_INEW; | 375 | ip->i_flags |= XFS_INEW; |
376 | spin_unlock(&ip->i_flags_lock); | ||
373 | 377 | ||
374 | write_unlock(&ih->ih_lock); | 378 | write_unlock(&ih->ih_lock); |
375 | 379 | ||
@@ -548,7 +552,7 @@ xfs_inode_lock_init( | |||
548 | mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", vp->v_number); | 552 | mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", vp->v_number); |
549 | init_waitqueue_head(&ip->i_ipin_wait); | 553 | init_waitqueue_head(&ip->i_ipin_wait); |
550 | atomic_set(&ip->i_pincount, 0); | 554 | atomic_set(&ip->i_pincount, 0); |
551 | init_sema(&ip->i_flock, 1, "xfsfino", vp->v_number); | 555 | initnsema(&ip->i_flock, 1, "xfsfino"); |
552 | } | 556 | } |
553 | 557 | ||
554 | /* | 558 | /* |
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 1f8ecff8553a..c27d7d495aa0 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -854,7 +854,8 @@ xfs_iread( | |||
854 | xfs_trans_t *tp, | 854 | xfs_trans_t *tp, |
855 | xfs_ino_t ino, | 855 | xfs_ino_t ino, |
856 | xfs_inode_t **ipp, | 856 | xfs_inode_t **ipp, |
857 | xfs_daddr_t bno) | 857 | xfs_daddr_t bno, |
858 | uint imap_flags) | ||
858 | { | 859 | { |
859 | xfs_buf_t *bp; | 860 | xfs_buf_t *bp; |
860 | xfs_dinode_t *dip; | 861 | xfs_dinode_t *dip; |
@@ -866,6 +867,7 @@ xfs_iread( | |||
866 | ip = kmem_zone_zalloc(xfs_inode_zone, KM_SLEEP); | 867 | ip = kmem_zone_zalloc(xfs_inode_zone, KM_SLEEP); |
867 | ip->i_ino = ino; | 868 | ip->i_ino = ino; |
868 | ip->i_mount = mp; | 869 | ip->i_mount = mp; |
870 | spin_lock_init(&ip->i_flags_lock); | ||
869 | 871 | ||
870 | /* | 872 | /* |
871 | * Get pointer's to the on-disk inode and the buffer containing it. | 873 | * Get pointer's to the on-disk inode and the buffer containing it. |
@@ -874,7 +876,7 @@ xfs_iread( | |||
874 | * return NULL as well. Set i_blkno to 0 so that xfs_itobp() will | 876 | * return NULL as well. Set i_blkno to 0 so that xfs_itobp() will |
875 | * know that this is a new incore inode. | 877 | * know that this is a new incore inode. |
876 | */ | 878 | */ |
877 | error = xfs_itobp(mp, tp, ip, &dip, &bp, bno, 0); | 879 | error = xfs_itobp(mp, tp, ip, &dip, &bp, bno, imap_flags); |
878 | if (error) { | 880 | if (error) { |
879 | kmem_zone_free(xfs_inode_zone, ip); | 881 | kmem_zone_free(xfs_inode_zone, ip); |
880 | return error; | 882 | return error; |
@@ -1113,7 +1115,7 @@ xfs_ialloc( | |||
1113 | * to prevent others from looking at until we're done. | 1115 | * to prevent others from looking at until we're done. |
1114 | */ | 1116 | */ |
1115 | error = xfs_trans_iget(tp->t_mountp, tp, ino, | 1117 | error = xfs_trans_iget(tp->t_mountp, tp, ino, |
1116 | IGET_CREATE, XFS_ILOCK_EXCL, &ip); | 1118 | XFS_IGET_CREATE, XFS_ILOCK_EXCL, &ip); |
1117 | if (error != 0) { | 1119 | if (error != 0) { |
1118 | return error; | 1120 | return error; |
1119 | } | 1121 | } |
@@ -2213,7 +2215,9 @@ xfs_ifree_cluster( | |||
2213 | 2215 | ||
2214 | if (ip == free_ip) { | 2216 | if (ip == free_ip) { |
2215 | if (xfs_iflock_nowait(ip)) { | 2217 | if (xfs_iflock_nowait(ip)) { |
2218 | spin_lock(&ip->i_flags_lock); | ||
2216 | ip->i_flags |= XFS_ISTALE; | 2219 | ip->i_flags |= XFS_ISTALE; |
2220 | spin_unlock(&ip->i_flags_lock); | ||
2217 | 2221 | ||
2218 | if (xfs_inode_clean(ip)) { | 2222 | if (xfs_inode_clean(ip)) { |
2219 | xfs_ifunlock(ip); | 2223 | xfs_ifunlock(ip); |
@@ -2227,7 +2231,9 @@ xfs_ifree_cluster( | |||
2227 | 2231 | ||
2228 | if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) { | 2232 | if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) { |
2229 | if (xfs_iflock_nowait(ip)) { | 2233 | if (xfs_iflock_nowait(ip)) { |
2234 | spin_lock(&ip->i_flags_lock); | ||
2230 | ip->i_flags |= XFS_ISTALE; | 2235 | ip->i_flags |= XFS_ISTALE; |
2236 | spin_unlock(&ip->i_flags_lock); | ||
2231 | 2237 | ||
2232 | if (xfs_inode_clean(ip)) { | 2238 | if (xfs_inode_clean(ip)) { |
2233 | xfs_ifunlock(ip); | 2239 | xfs_ifunlock(ip); |
@@ -2257,7 +2263,9 @@ xfs_ifree_cluster( | |||
2257 | AIL_LOCK(mp,s); | 2263 | AIL_LOCK(mp,s); |
2258 | iip->ili_flush_lsn = iip->ili_item.li_lsn; | 2264 | iip->ili_flush_lsn = iip->ili_item.li_lsn; |
2259 | AIL_UNLOCK(mp, s); | 2265 | AIL_UNLOCK(mp, s); |
2266 | spin_lock(&iip->ili_inode->i_flags_lock); | ||
2260 | iip->ili_inode->i_flags |= XFS_ISTALE; | 2267 | iip->ili_inode->i_flags |= XFS_ISTALE; |
2268 | spin_unlock(&iip->ili_inode->i_flags_lock); | ||
2261 | pre_flushed++; | 2269 | pre_flushed++; |
2262 | } | 2270 | } |
2263 | lip = lip->li_bio_list; | 2271 | lip = lip->li_bio_list; |
@@ -2753,19 +2761,29 @@ xfs_iunpin( | |||
2753 | * call as the inode reclaim may be blocked waiting for | 2761 | * call as the inode reclaim may be blocked waiting for |
2754 | * the inode to become unpinned. | 2762 | * the inode to become unpinned. |
2755 | */ | 2763 | */ |
2764 | struct inode *inode = NULL; | ||
2765 | |||
2766 | spin_lock(&ip->i_flags_lock); | ||
2756 | if (!(ip->i_flags & (XFS_IRECLAIM|XFS_IRECLAIMABLE))) { | 2767 | if (!(ip->i_flags & (XFS_IRECLAIM|XFS_IRECLAIMABLE))) { |
2757 | bhv_vnode_t *vp = XFS_ITOV_NULL(ip); | 2768 | bhv_vnode_t *vp = XFS_ITOV_NULL(ip); |
2758 | 2769 | ||
2759 | /* make sync come back and flush this inode */ | 2770 | /* make sync come back and flush this inode */ |
2760 | if (vp) { | 2771 | if (vp) { |
2761 | struct inode *inode = vn_to_inode(vp); | 2772 | inode = vn_to_inode(vp); |
2762 | 2773 | ||
2763 | if (!(inode->i_state & | 2774 | if (!(inode->i_state & |
2764 | (I_NEW|I_FREEING|I_CLEAR))) | 2775 | (I_NEW|I_FREEING|I_CLEAR))) { |
2765 | mark_inode_dirty_sync(inode); | 2776 | inode = igrab(inode); |
2777 | if (inode) | ||
2778 | mark_inode_dirty_sync(inode); | ||
2779 | } else | ||
2780 | inode = NULL; | ||
2766 | } | 2781 | } |
2767 | } | 2782 | } |
2783 | spin_unlock(&ip->i_flags_lock); | ||
2768 | wake_up(&ip->i_ipin_wait); | 2784 | wake_up(&ip->i_ipin_wait); |
2785 | if (inode) | ||
2786 | iput(inode); | ||
2769 | } | 2787 | } |
2770 | } | 2788 | } |
2771 | 2789 | ||
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index d10b76ed1e5b..e96eb0835fe6 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
@@ -267,6 +267,7 @@ typedef struct xfs_inode { | |||
267 | sema_t i_flock; /* inode flush lock */ | 267 | sema_t i_flock; /* inode flush lock */ |
268 | atomic_t i_pincount; /* inode pin count */ | 268 | atomic_t i_pincount; /* inode pin count */ |
269 | wait_queue_head_t i_ipin_wait; /* inode pinning wait queue */ | 269 | wait_queue_head_t i_ipin_wait; /* inode pinning wait queue */ |
270 | spinlock_t i_flags_lock; /* inode i_flags lock */ | ||
270 | #ifdef HAVE_REFCACHE | 271 | #ifdef HAVE_REFCACHE |
271 | struct xfs_inode **i_refcache; /* ptr to entry in ref cache */ | 272 | struct xfs_inode **i_refcache; /* ptr to entry in ref cache */ |
272 | struct xfs_inode *i_release; /* inode to unref */ | 273 | struct xfs_inode *i_release; /* inode to unref */ |
@@ -389,11 +390,14 @@ typedef struct xfs_inode { | |||
389 | (((vfsp)->vfs_flag & VFS_GRPID) || ((pip)->i_d.di_mode & S_ISGID)) | 390 | (((vfsp)->vfs_flag & VFS_GRPID) || ((pip)->i_d.di_mode & S_ISGID)) |
390 | 391 | ||
391 | /* | 392 | /* |
392 | * xfs_iget.c prototypes. | 393 | * Flags for xfs_iget() |
393 | */ | 394 | */ |
395 | #define XFS_IGET_CREATE 0x1 | ||
396 | #define XFS_IGET_BULKSTAT 0x2 | ||
394 | 397 | ||
395 | #define IGET_CREATE 1 | 398 | /* |
396 | 399 | * xfs_iget.c prototypes. | |
400 | */ | ||
397 | void xfs_ihash_init(struct xfs_mount *); | 401 | void xfs_ihash_init(struct xfs_mount *); |
398 | void xfs_ihash_free(struct xfs_mount *); | 402 | void xfs_ihash_free(struct xfs_mount *); |
399 | void xfs_chash_init(struct xfs_mount *); | 403 | void xfs_chash_init(struct xfs_mount *); |
@@ -425,7 +429,7 @@ int xfs_itobp(struct xfs_mount *, struct xfs_trans *, | |||
425 | xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **, | 429 | xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **, |
426 | xfs_daddr_t, uint); | 430 | xfs_daddr_t, uint); |
427 | int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, | 431 | int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, |
428 | xfs_inode_t **, xfs_daddr_t); | 432 | xfs_inode_t **, xfs_daddr_t, uint); |
429 | int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int); | 433 | int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int); |
430 | int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, | 434 | int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, |
431 | xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t, | 435 | xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t, |
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index f8e80d8e7237..a7a92251eb56 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c | |||
@@ -743,21 +743,6 @@ xfs_inode_item_committed( | |||
743 | } | 743 | } |
744 | 744 | ||
745 | /* | 745 | /* |
746 | * The transaction with the inode locked has aborted. The inode | ||
747 | * must not be dirty within the transaction (unless we're forcibly | ||
748 | * shutting down). We simply unlock just as if the transaction | ||
749 | * had been cancelled. | ||
750 | */ | ||
751 | STATIC void | ||
752 | xfs_inode_item_abort( | ||
753 | xfs_inode_log_item_t *iip) | ||
754 | { | ||
755 | xfs_inode_item_unlock(iip); | ||
756 | return; | ||
757 | } | ||
758 | |||
759 | |||
760 | /* | ||
761 | * This gets called by xfs_trans_push_ail(), when IOP_TRYLOCK | 746 | * This gets called by xfs_trans_push_ail(), when IOP_TRYLOCK |
762 | * failed to get the inode flush lock but did get the inode locked SHARED. | 747 | * failed to get the inode flush lock but did get the inode locked SHARED. |
763 | * Here we're trying to see if the inode buffer is incore, and if so whether it's | 748 | * Here we're trying to see if the inode buffer is incore, and if so whether it's |
@@ -915,7 +900,6 @@ STATIC struct xfs_item_ops xfs_inode_item_ops = { | |||
915 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) | 900 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) |
916 | xfs_inode_item_committed, | 901 | xfs_inode_item_committed, |
917 | .iop_push = (void(*)(xfs_log_item_t*))xfs_inode_item_push, | 902 | .iop_push = (void(*)(xfs_log_item_t*))xfs_inode_item_push, |
918 | .iop_abort = (void(*)(xfs_log_item_t*))xfs_inode_item_abort, | ||
919 | .iop_pushbuf = (void(*)(xfs_log_item_t*))xfs_inode_item_pushbuf, | 903 | .iop_pushbuf = (void(*)(xfs_log_item_t*))xfs_inode_item_pushbuf, |
920 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) | 904 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) |
921 | xfs_inode_item_committing | 905 | xfs_inode_item_committing |
diff --git a/fs/xfs/xfs_inode_item.h b/fs/xfs/xfs_inode_item.h index 5db6cd1b4cf3..bfe92ea17952 100644 --- a/fs/xfs/xfs_inode_item.h +++ b/fs/xfs/xfs_inode_item.h | |||
@@ -25,52 +25,54 @@ | |||
25 | * must be added on to the end. | 25 | * must be added on to the end. |
26 | */ | 26 | */ |
27 | typedef struct xfs_inode_log_format { | 27 | typedef struct xfs_inode_log_format { |
28 | unsigned short ilf_type; /* inode log item type */ | 28 | __uint16_t ilf_type; /* inode log item type */ |
29 | unsigned short ilf_size; /* size of this item */ | 29 | __uint16_t ilf_size; /* size of this item */ |
30 | uint ilf_fields; /* flags for fields logged */ | 30 | __uint32_t ilf_fields; /* flags for fields logged */ |
31 | ushort ilf_asize; /* size of attr d/ext/root */ | 31 | __uint16_t ilf_asize; /* size of attr d/ext/root */ |
32 | ushort ilf_dsize; /* size of data/ext/root */ | 32 | __uint16_t ilf_dsize; /* size of data/ext/root */ |
33 | xfs_ino_t ilf_ino; /* inode number */ | 33 | __uint64_t ilf_ino; /* inode number */ |
34 | union { | 34 | union { |
35 | xfs_dev_t ilfu_rdev; /* rdev value for dev inode*/ | 35 | __uint32_t ilfu_rdev; /* rdev value for dev inode*/ |
36 | uuid_t ilfu_uuid; /* mount point value */ | 36 | uuid_t ilfu_uuid; /* mount point value */ |
37 | } ilf_u; | 37 | } ilf_u; |
38 | __int64_t ilf_blkno; /* blkno of inode buffer */ | 38 | __int64_t ilf_blkno; /* blkno of inode buffer */ |
39 | int ilf_len; /* len of inode buffer */ | 39 | __int32_t ilf_len; /* len of inode buffer */ |
40 | int ilf_boffset; /* off of inode in buffer */ | 40 | __int32_t ilf_boffset; /* off of inode in buffer */ |
41 | } xfs_inode_log_format_t; | 41 | } xfs_inode_log_format_t; |
42 | 42 | ||
43 | #ifndef HAVE_FORMAT32 | ||
43 | typedef struct xfs_inode_log_format_32 { | 44 | typedef struct xfs_inode_log_format_32 { |
44 | unsigned short ilf_type; /* 16: inode log item type */ | 45 | __uint16_t ilf_type; /* inode log item type */ |
45 | unsigned short ilf_size; /* 16: size of this item */ | 46 | __uint16_t ilf_size; /* size of this item */ |
46 | uint ilf_fields; /* 32: flags for fields logged */ | 47 | __uint32_t ilf_fields; /* flags for fields logged */ |
47 | ushort ilf_asize; /* 32: size of attr d/ext/root */ | 48 | __uint16_t ilf_asize; /* size of attr d/ext/root */ |
48 | ushort ilf_dsize; /* 32: size of data/ext/root */ | 49 | __uint16_t ilf_dsize; /* size of data/ext/root */ |
49 | xfs_ino_t ilf_ino; /* 64: inode number */ | 50 | __uint64_t ilf_ino; /* inode number */ |
50 | union { | 51 | union { |
51 | xfs_dev_t ilfu_rdev; /* 32: rdev value for dev inode*/ | 52 | __uint32_t ilfu_rdev; /* rdev value for dev inode*/ |
52 | uuid_t ilfu_uuid; /* 128: mount point value */ | 53 | uuid_t ilfu_uuid; /* mount point value */ |
53 | } ilf_u; | 54 | } ilf_u; |
54 | __int64_t ilf_blkno; /* 64: blkno of inode buffer */ | 55 | __int64_t ilf_blkno; /* blkno of inode buffer */ |
55 | int ilf_len; /* 32: len of inode buffer */ | 56 | __int32_t ilf_len; /* len of inode buffer */ |
56 | int ilf_boffset; /* 32: off of inode in buffer */ | 57 | __int32_t ilf_boffset; /* off of inode in buffer */ |
57 | } __attribute__((packed)) xfs_inode_log_format_32_t; | 58 | } __attribute__((packed)) xfs_inode_log_format_32_t; |
59 | #endif | ||
58 | 60 | ||
59 | typedef struct xfs_inode_log_format_64 { | 61 | typedef struct xfs_inode_log_format_64 { |
60 | unsigned short ilf_type; /* 16: inode log item type */ | 62 | __uint16_t ilf_type; /* inode log item type */ |
61 | unsigned short ilf_size; /* 16: size of this item */ | 63 | __uint16_t ilf_size; /* size of this item */ |
62 | uint ilf_fields; /* 32: flags for fields logged */ | 64 | __uint32_t ilf_fields; /* flags for fields logged */ |
63 | ushort ilf_asize; /* 32: size of attr d/ext/root */ | 65 | __uint16_t ilf_asize; /* size of attr d/ext/root */ |
64 | ushort ilf_dsize; /* 32: size of data/ext/root */ | 66 | __uint16_t ilf_dsize; /* size of data/ext/root */ |
65 | __uint32_t ilf_pad; /* 32: pad for 64 bit boundary */ | 67 | __uint32_t ilf_pad; /* pad for 64 bit boundary */ |
66 | xfs_ino_t ilf_ino; /* 64: inode number */ | 68 | __uint64_t ilf_ino; /* inode number */ |
67 | union { | 69 | union { |
68 | xfs_dev_t ilfu_rdev; /* 32: rdev value for dev inode*/ | 70 | __uint32_t ilfu_rdev; /* rdev value for dev inode*/ |
69 | uuid_t ilfu_uuid; /* 128: mount point value */ | 71 | uuid_t ilfu_uuid; /* mount point value */ |
70 | } ilf_u; | 72 | } ilf_u; |
71 | __int64_t ilf_blkno; /* 64: blkno of inode buffer */ | 73 | __int64_t ilf_blkno; /* blkno of inode buffer */ |
72 | int ilf_len; /* 32: len of inode buffer */ | 74 | __int32_t ilf_len; /* len of inode buffer */ |
73 | int ilf_boffset; /* 32: off of inode in buffer */ | 75 | __int32_t ilf_boffset; /* off of inode in buffer */ |
74 | } xfs_inode_log_format_64_t; | 76 | } xfs_inode_log_format_64_t; |
75 | 77 | ||
76 | /* | 78 | /* |
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index f1949c16df15..19655124da78 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
@@ -398,6 +398,23 @@ xfs_flush_space( | |||
398 | return 1; | 398 | return 1; |
399 | } | 399 | } |
400 | 400 | ||
401 | STATIC int | ||
402 | xfs_cmn_err_fsblock_zero( | ||
403 | xfs_inode_t *ip, | ||
404 | xfs_bmbt_irec_t *imap) | ||
405 | { | ||
406 | xfs_cmn_err(XFS_PTAG_FSBLOCK_ZERO, CE_ALERT, ip->i_mount, | ||
407 | "Access to block zero in inode %llu " | ||
408 | "start_block: %llx start_off: %llx " | ||
409 | "blkcnt: %llx extent-state: %x\n", | ||
410 | (unsigned long long)ip->i_ino, | ||
411 | (unsigned long long)imap->br_startblock, | ||
412 | (unsigned long long)imap->br_startoff, | ||
413 | (unsigned long long)imap->br_blockcount, | ||
414 | imap->br_state); | ||
415 | return EFSCORRUPTED; | ||
416 | } | ||
417 | |||
401 | int | 418 | int |
402 | xfs_iomap_write_direct( | 419 | xfs_iomap_write_direct( |
403 | xfs_inode_t *ip, | 420 | xfs_inode_t *ip, |
@@ -536,23 +553,17 @@ xfs_iomap_write_direct( | |||
536 | * Copy any maps to caller's array and return any error. | 553 | * Copy any maps to caller's array and return any error. |
537 | */ | 554 | */ |
538 | if (nimaps == 0) { | 555 | if (nimaps == 0) { |
539 | error = (ENOSPC); | 556 | error = ENOSPC; |
557 | goto error_out; | ||
558 | } | ||
559 | |||
560 | if (unlikely(!imap.br_startblock && !(io->io_flags & XFS_IOCORE_RT))) { | ||
561 | error = xfs_cmn_err_fsblock_zero(ip, &imap); | ||
540 | goto error_out; | 562 | goto error_out; |
541 | } | 563 | } |
542 | 564 | ||
543 | *ret_imap = imap; | 565 | *ret_imap = imap; |
544 | *nmaps = 1; | 566 | *nmaps = 1; |
545 | if ( !(io->io_flags & XFS_IOCORE_RT) && !ret_imap->br_startblock) { | ||
546 | cmn_err(CE_PANIC,"Access to block zero: fs <%s> inode: %lld " | ||
547 | "start_block : %llx start_off : %llx blkcnt : %llx " | ||
548 | "extent-state : %x \n", | ||
549 | (ip->i_mount)->m_fsname, | ||
550 | (long long)ip->i_ino, | ||
551 | (unsigned long long)ret_imap->br_startblock, | ||
552 | (unsigned long long)ret_imap->br_startoff, | ||
553 | (unsigned long long)ret_imap->br_blockcount, | ||
554 | ret_imap->br_state); | ||
555 | } | ||
556 | return 0; | 567 | return 0; |
557 | 568 | ||
558 | error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ | 569 | error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ |
@@ -715,17 +726,8 @@ retry: | |||
715 | goto retry; | 726 | goto retry; |
716 | } | 727 | } |
717 | 728 | ||
718 | if (!(io->io_flags & XFS_IOCORE_RT) && !ret_imap->br_startblock) { | 729 | if (unlikely(!imap[0].br_startblock && !(io->io_flags & XFS_IOCORE_RT))) |
719 | cmn_err(CE_PANIC,"Access to block zero: fs <%s> inode: %lld " | 730 | return xfs_cmn_err_fsblock_zero(ip, &imap[0]); |
720 | "start_block : %llx start_off : %llx blkcnt : %llx " | ||
721 | "extent-state : %x \n", | ||
722 | (ip->i_mount)->m_fsname, | ||
723 | (long long)ip->i_ino, | ||
724 | (unsigned long long)ret_imap->br_startblock, | ||
725 | (unsigned long long)ret_imap->br_startoff, | ||
726 | (unsigned long long)ret_imap->br_blockcount, | ||
727 | ret_imap->br_state); | ||
728 | } | ||
729 | 731 | ||
730 | *ret_imap = imap[0]; | 732 | *ret_imap = imap[0]; |
731 | *nmaps = 1; | 733 | *nmaps = 1; |
@@ -853,24 +855,10 @@ xfs_iomap_write_allocate( | |||
853 | * See if we were able to allocate an extent that | 855 | * See if we were able to allocate an extent that |
854 | * covers at least part of the callers request | 856 | * covers at least part of the callers request |
855 | */ | 857 | */ |
856 | |||
857 | for (i = 0; i < nimaps; i++) { | 858 | for (i = 0; i < nimaps; i++) { |
858 | if (!(io->io_flags & XFS_IOCORE_RT) && | 859 | if (unlikely(!imap[i].br_startblock && |
859 | !imap[i].br_startblock) { | 860 | !(io->io_flags & XFS_IOCORE_RT))) |
860 | cmn_err(CE_PANIC,"Access to block zero: " | 861 | return xfs_cmn_err_fsblock_zero(ip, &imap[i]); |
861 | "fs <%s> inode: %lld " | ||
862 | "start_block : %llx start_off : %llx " | ||
863 | "blkcnt : %llx extent-state : %x \n", | ||
864 | (ip->i_mount)->m_fsname, | ||
865 | (long long)ip->i_ino, | ||
866 | (unsigned long long) | ||
867 | imap[i].br_startblock, | ||
868 | (unsigned long long) | ||
869 | imap[i].br_startoff, | ||
870 | (unsigned long long) | ||
871 | imap[i].br_blockcount, | ||
872 | imap[i].br_state); | ||
873 | } | ||
874 | if ((offset_fsb >= imap[i].br_startoff) && | 862 | if ((offset_fsb >= imap[i].br_startoff) && |
875 | (offset_fsb < (imap[i].br_startoff + | 863 | (offset_fsb < (imap[i].br_startoff + |
876 | imap[i].br_blockcount))) { | 864 | imap[i].br_blockcount))) { |
@@ -941,7 +929,7 @@ xfs_iomap_write_unwritten( | |||
941 | XFS_WRITE_LOG_COUNT); | 929 | XFS_WRITE_LOG_COUNT); |
942 | if (error) { | 930 | if (error) { |
943 | xfs_trans_cancel(tp, 0); | 931 | xfs_trans_cancel(tp, 0); |
944 | goto error0; | 932 | return XFS_ERROR(error); |
945 | } | 933 | } |
946 | 934 | ||
947 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 935 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
@@ -967,19 +955,11 @@ xfs_iomap_write_unwritten( | |||
967 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL); | 955 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL); |
968 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 956 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
969 | if (error) | 957 | if (error) |
970 | goto error0; | 958 | return XFS_ERROR(error); |
971 | 959 | ||
972 | if ( !(io->io_flags & XFS_IOCORE_RT) && !imap.br_startblock) { | 960 | if (unlikely(!imap.br_startblock && |
973 | cmn_err(CE_PANIC,"Access to block zero: fs <%s> " | 961 | !(io->io_flags & XFS_IOCORE_RT))) |
974 | "inode: %lld start_block : %llx start_off : " | 962 | return xfs_cmn_err_fsblock_zero(ip, &imap); |
975 | "%llx blkcnt : %llx extent-state : %x \n", | ||
976 | (ip->i_mount)->m_fsname, | ||
977 | (long long)ip->i_ino, | ||
978 | (unsigned long long)imap.br_startblock, | ||
979 | (unsigned long long)imap.br_startoff, | ||
980 | (unsigned long long)imap.br_blockcount, | ||
981 | imap.br_state); | ||
982 | } | ||
983 | 963 | ||
984 | if ((numblks_fsb = imap.br_blockcount) == 0) { | 964 | if ((numblks_fsb = imap.br_blockcount) == 0) { |
985 | /* | 965 | /* |
@@ -999,6 +979,5 @@ error_on_bmapi_transaction: | |||
999 | xfs_bmap_cancel(&free_list); | 979 | xfs_bmap_cancel(&free_list); |
1000 | xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT)); | 980 | xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT)); |
1001 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 981 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
1002 | error0: | ||
1003 | return XFS_ERROR(error); | 982 | return XFS_ERROR(error); |
1004 | } | 983 | } |
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index 46249e4d1fea..7775ddc0b3c6 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c | |||
@@ -39,6 +39,16 @@ | |||
39 | #include "xfs_error.h" | 39 | #include "xfs_error.h" |
40 | #include "xfs_btree.h" | 40 | #include "xfs_btree.h" |
41 | 41 | ||
42 | int | ||
43 | xfs_internal_inum( | ||
44 | xfs_mount_t *mp, | ||
45 | xfs_ino_t ino) | ||
46 | { | ||
47 | return (ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || | ||
48 | (XFS_SB_VERSION_HASQUOTA(&mp->m_sb) && | ||
49 | (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino))); | ||
50 | } | ||
51 | |||
42 | STATIC int | 52 | STATIC int |
43 | xfs_bulkstat_one_iget( | 53 | xfs_bulkstat_one_iget( |
44 | xfs_mount_t *mp, /* mount point for filesystem */ | 54 | xfs_mount_t *mp, /* mount point for filesystem */ |
@@ -52,7 +62,8 @@ xfs_bulkstat_one_iget( | |||
52 | bhv_vnode_t *vp; | 62 | bhv_vnode_t *vp; |
53 | int error; | 63 | int error; |
54 | 64 | ||
55 | error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, bno); | 65 | error = xfs_iget(mp, NULL, ino, |
66 | XFS_IGET_BULKSTAT, XFS_ILOCK_SHARED, &ip, bno); | ||
56 | if (error) { | 67 | if (error) { |
57 | *stat = BULKSTAT_RV_NOTHING; | 68 | *stat = BULKSTAT_RV_NOTHING; |
58 | return error; | 69 | return error; |
@@ -212,17 +223,12 @@ xfs_bulkstat_one( | |||
212 | xfs_dinode_t *dip; /* dinode inode pointer */ | 223 | xfs_dinode_t *dip; /* dinode inode pointer */ |
213 | 224 | ||
214 | dip = (xfs_dinode_t *)dibuff; | 225 | dip = (xfs_dinode_t *)dibuff; |
226 | *stat = BULKSTAT_RV_NOTHING; | ||
215 | 227 | ||
216 | if (!buffer || ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || | 228 | if (!buffer || xfs_internal_inum(mp, ino)) |
217 | (XFS_SB_VERSION_HASQUOTA(&mp->m_sb) && | ||
218 | (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino))) { | ||
219 | *stat = BULKSTAT_RV_NOTHING; | ||
220 | return XFS_ERROR(EINVAL); | 229 | return XFS_ERROR(EINVAL); |
221 | } | 230 | if (ubsize < sizeof(*buf)) |
222 | if (ubsize < sizeof(*buf)) { | ||
223 | *stat = BULKSTAT_RV_NOTHING; | ||
224 | return XFS_ERROR(ENOMEM); | 231 | return XFS_ERROR(ENOMEM); |
225 | } | ||
226 | 232 | ||
227 | buf = kmem_alloc(sizeof(*buf), KM_SLEEP); | 233 | buf = kmem_alloc(sizeof(*buf), KM_SLEEP); |
228 | 234 | ||
@@ -238,8 +244,7 @@ xfs_bulkstat_one( | |||
238 | } | 244 | } |
239 | 245 | ||
240 | if (copy_to_user(buffer, buf, sizeof(*buf))) { | 246 | if (copy_to_user(buffer, buf, sizeof(*buf))) { |
241 | *stat = BULKSTAT_RV_NOTHING; | 247 | error = EFAULT; |
242 | error = EFAULT; | ||
243 | goto out_free; | 248 | goto out_free; |
244 | } | 249 | } |
245 | 250 | ||
@@ -253,6 +258,46 @@ xfs_bulkstat_one( | |||
253 | } | 258 | } |
254 | 259 | ||
255 | /* | 260 | /* |
261 | * Test to see whether we can use the ondisk inode directly, based | ||
262 | * on the given bulkstat flags, filling in dipp accordingly. | ||
263 | * Returns zero if the inode is dodgey. | ||
264 | */ | ||
265 | STATIC int | ||
266 | xfs_bulkstat_use_dinode( | ||
267 | xfs_mount_t *mp, | ||
268 | int flags, | ||
269 | xfs_buf_t *bp, | ||
270 | int clustidx, | ||
271 | xfs_dinode_t **dipp) | ||
272 | { | ||
273 | xfs_dinode_t *dip; | ||
274 | unsigned int aformat; | ||
275 | |||
276 | *dipp = NULL; | ||
277 | if (!bp || (flags & BULKSTAT_FG_IGET)) | ||
278 | return 1; | ||
279 | dip = (xfs_dinode_t *) | ||
280 | xfs_buf_offset(bp, clustidx << mp->m_sb.sb_inodelog); | ||
281 | if (INT_GET(dip->di_core.di_magic, ARCH_CONVERT) != XFS_DINODE_MAGIC || | ||
282 | !XFS_DINODE_GOOD_VERSION( | ||
283 | INT_GET(dip->di_core.di_version, ARCH_CONVERT))) | ||
284 | return 0; | ||
285 | if (flags & BULKSTAT_FG_QUICK) { | ||
286 | *dipp = dip; | ||
287 | return 1; | ||
288 | } | ||
289 | /* BULKSTAT_FG_INLINE: if attr fork is local, or not there, use it */ | ||
290 | aformat = INT_GET(dip->di_core.di_aformat, ARCH_CONVERT); | ||
291 | if ((XFS_CFORK_Q(&dip->di_core) == 0) || | ||
292 | (aformat == XFS_DINODE_FMT_LOCAL) || | ||
293 | (aformat == XFS_DINODE_FMT_EXTENTS && !dip->di_core.di_anextents)) { | ||
294 | *dipp = dip; | ||
295 | return 1; | ||
296 | } | ||
297 | return 1; | ||
298 | } | ||
299 | |||
300 | /* | ||
256 | * Return stat information in bulk (by-inode) for the filesystem. | 301 | * Return stat information in bulk (by-inode) for the filesystem. |
257 | */ | 302 | */ |
258 | int /* error status */ | 303 | int /* error status */ |
@@ -284,10 +329,11 @@ xfs_bulkstat( | |||
284 | xfs_agino_t gino; /* current btree rec's start inode */ | 329 | xfs_agino_t gino; /* current btree rec's start inode */ |
285 | int i; /* loop index */ | 330 | int i; /* loop index */ |
286 | int icount; /* count of inodes good in irbuf */ | 331 | int icount; /* count of inodes good in irbuf */ |
332 | size_t irbsize; /* size of irec buffer in bytes */ | ||
287 | xfs_ino_t ino; /* inode number (filesystem) */ | 333 | xfs_ino_t ino; /* inode number (filesystem) */ |
288 | xfs_inobt_rec_t *irbp; /* current irec buffer pointer */ | 334 | xfs_inobt_rec_incore_t *irbp; /* current irec buffer pointer */ |
289 | xfs_inobt_rec_t *irbuf; /* start of irec buffer */ | 335 | xfs_inobt_rec_incore_t *irbuf; /* start of irec buffer */ |
290 | xfs_inobt_rec_t *irbufend; /* end of good irec buffer entries */ | 336 | xfs_inobt_rec_incore_t *irbufend; /* end of good irec buffer entries */ |
291 | xfs_ino_t lastino=0; /* last inode number returned */ | 337 | xfs_ino_t lastino=0; /* last inode number returned */ |
292 | int nbcluster; /* # of blocks in a cluster */ | 338 | int nbcluster; /* # of blocks in a cluster */ |
293 | int nicluster; /* # of inodes in a cluster */ | 339 | int nicluster; /* # of inodes in a cluster */ |
@@ -328,13 +374,10 @@ xfs_bulkstat( | |||
328 | (XFS_INODE_CLUSTER_SIZE(mp) >> mp->m_sb.sb_inodelog); | 374 | (XFS_INODE_CLUSTER_SIZE(mp) >> mp->m_sb.sb_inodelog); |
329 | nimask = ~(nicluster - 1); | 375 | nimask = ~(nicluster - 1); |
330 | nbcluster = nicluster >> mp->m_sb.sb_inopblog; | 376 | nbcluster = nicluster >> mp->m_sb.sb_inopblog; |
331 | /* | 377 | irbuf = kmem_zalloc_greedy(&irbsize, NBPC, NBPC * 4, |
332 | * Allocate a page-sized buffer for inode btree records. | 378 | KM_SLEEP | KM_MAYFAIL | KM_LARGE); |
333 | * We could try allocating something smaller, but for normal | 379 | nirbuf = irbsize / sizeof(*irbuf); |
334 | * calls we'll always (potentially) need the whole page. | 380 | |
335 | */ | ||
336 | irbuf = kmem_alloc(NBPC, KM_SLEEP); | ||
337 | nirbuf = NBPC / sizeof(*irbuf); | ||
338 | /* | 381 | /* |
339 | * Loop over the allocation groups, starting from the last | 382 | * Loop over the allocation groups, starting from the last |
340 | * inode returned; 0 means start of the allocation group. | 383 | * inode returned; 0 means start of the allocation group. |
@@ -358,7 +401,7 @@ xfs_bulkstat( | |||
358 | * Allocate and initialize a btree cursor for ialloc btree. | 401 | * Allocate and initialize a btree cursor for ialloc btree. |
359 | */ | 402 | */ |
360 | cur = xfs_btree_init_cursor(mp, NULL, agbp, agno, XFS_BTNUM_INO, | 403 | cur = xfs_btree_init_cursor(mp, NULL, agbp, agno, XFS_BTNUM_INO, |
361 | (xfs_inode_t *)0, 0); | 404 | (xfs_inode_t *)0, 0); |
362 | irbp = irbuf; | 405 | irbp = irbuf; |
363 | irbufend = irbuf + nirbuf; | 406 | irbufend = irbuf + nirbuf; |
364 | end_of_ag = 0; | 407 | end_of_ag = 0; |
@@ -395,9 +438,9 @@ xfs_bulkstat( | |||
395 | gcnt++; | 438 | gcnt++; |
396 | } | 439 | } |
397 | gfree |= XFS_INOBT_MASKN(0, chunkidx); | 440 | gfree |= XFS_INOBT_MASKN(0, chunkidx); |
398 | INT_SET(irbp->ir_startino, ARCH_CONVERT, gino); | 441 | irbp->ir_startino = gino; |
399 | INT_SET(irbp->ir_freecount, ARCH_CONVERT, gcnt); | 442 | irbp->ir_freecount = gcnt; |
400 | INT_SET(irbp->ir_free, ARCH_CONVERT, gfree); | 443 | irbp->ir_free = gfree; |
401 | irbp++; | 444 | irbp++; |
402 | agino = gino + XFS_INODES_PER_CHUNK; | 445 | agino = gino + XFS_INODES_PER_CHUNK; |
403 | icount = XFS_INODES_PER_CHUNK - gcnt; | 446 | icount = XFS_INODES_PER_CHUNK - gcnt; |
@@ -451,11 +494,27 @@ xfs_bulkstat( | |||
451 | } | 494 | } |
452 | /* | 495 | /* |
453 | * If this chunk has any allocated inodes, save it. | 496 | * If this chunk has any allocated inodes, save it. |
497 | * Also start read-ahead now for this chunk. | ||
454 | */ | 498 | */ |
455 | if (gcnt < XFS_INODES_PER_CHUNK) { | 499 | if (gcnt < XFS_INODES_PER_CHUNK) { |
456 | INT_SET(irbp->ir_startino, ARCH_CONVERT, gino); | 500 | /* |
457 | INT_SET(irbp->ir_freecount, ARCH_CONVERT, gcnt); | 501 | * Loop over all clusters in the next chunk. |
458 | INT_SET(irbp->ir_free, ARCH_CONVERT, gfree); | 502 | * Do a readahead if there are any allocated |
503 | * inodes in that cluster. | ||
504 | */ | ||
505 | for (agbno = XFS_AGINO_TO_AGBNO(mp, gino), | ||
506 | chunkidx = 0; | ||
507 | chunkidx < XFS_INODES_PER_CHUNK; | ||
508 | chunkidx += nicluster, | ||
509 | agbno += nbcluster) { | ||
510 | if (XFS_INOBT_MASKN(chunkidx, | ||
511 | nicluster) & ~gfree) | ||
512 | xfs_btree_reada_bufs(mp, agno, | ||
513 | agbno, nbcluster); | ||
514 | } | ||
515 | irbp->ir_startino = gino; | ||
516 | irbp->ir_freecount = gcnt; | ||
517 | irbp->ir_free = gfree; | ||
459 | irbp++; | 518 | irbp++; |
460 | icount += XFS_INODES_PER_CHUNK - gcnt; | 519 | icount += XFS_INODES_PER_CHUNK - gcnt; |
461 | } | 520 | } |
@@ -479,33 +538,11 @@ xfs_bulkstat( | |||
479 | for (irbp = irbuf; | 538 | for (irbp = irbuf; |
480 | irbp < irbufend && ubleft >= statstruct_size; irbp++) { | 539 | irbp < irbufend && ubleft >= statstruct_size; irbp++) { |
481 | /* | 540 | /* |
482 | * Read-ahead the next chunk's worth of inodes. | ||
483 | */ | ||
484 | if (&irbp[1] < irbufend) { | ||
485 | /* | ||
486 | * Loop over all clusters in the next chunk. | ||
487 | * Do a readahead if there are any allocated | ||
488 | * inodes in that cluster. | ||
489 | */ | ||
490 | for (agbno = XFS_AGINO_TO_AGBNO(mp, | ||
491 | INT_GET(irbp[1].ir_startino, ARCH_CONVERT)), | ||
492 | chunkidx = 0; | ||
493 | chunkidx < XFS_INODES_PER_CHUNK; | ||
494 | chunkidx += nicluster, | ||
495 | agbno += nbcluster) { | ||
496 | if (XFS_INOBT_MASKN(chunkidx, | ||
497 | nicluster) & | ||
498 | ~(INT_GET(irbp[1].ir_free, ARCH_CONVERT))) | ||
499 | xfs_btree_reada_bufs(mp, agno, | ||
500 | agbno, nbcluster); | ||
501 | } | ||
502 | } | ||
503 | /* | ||
504 | * Now process this chunk of inodes. | 541 | * Now process this chunk of inodes. |
505 | */ | 542 | */ |
506 | for (agino = INT_GET(irbp->ir_startino, ARCH_CONVERT), chunkidx = 0, clustidx = 0; | 543 | for (agino = irbp->ir_startino, chunkidx = clustidx = 0; |
507 | ubleft > 0 && | 544 | ubleft > 0 && |
508 | INT_GET(irbp->ir_freecount, ARCH_CONVERT) < XFS_INODES_PER_CHUNK; | 545 | irbp->ir_freecount < XFS_INODES_PER_CHUNK; |
509 | chunkidx++, clustidx++, agino++) { | 546 | chunkidx++, clustidx++, agino++) { |
510 | ASSERT(chunkidx < XFS_INODES_PER_CHUNK); | 547 | ASSERT(chunkidx < XFS_INODES_PER_CHUNK); |
511 | /* | 548 | /* |
@@ -525,11 +562,12 @@ xfs_bulkstat( | |||
525 | */ | 562 | */ |
526 | if ((chunkidx & (nicluster - 1)) == 0) { | 563 | if ((chunkidx & (nicluster - 1)) == 0) { |
527 | agbno = XFS_AGINO_TO_AGBNO(mp, | 564 | agbno = XFS_AGINO_TO_AGBNO(mp, |
528 | INT_GET(irbp->ir_startino, ARCH_CONVERT)) + | 565 | irbp->ir_startino) + |
529 | ((chunkidx & nimask) >> | 566 | ((chunkidx & nimask) >> |
530 | mp->m_sb.sb_inopblog); | 567 | mp->m_sb.sb_inopblog); |
531 | 568 | ||
532 | if (flags & BULKSTAT_FG_QUICK) { | 569 | if (flags & (BULKSTAT_FG_QUICK | |
570 | BULKSTAT_FG_INLINE)) { | ||
533 | ino = XFS_AGINO_TO_INO(mp, agno, | 571 | ino = XFS_AGINO_TO_INO(mp, agno, |
534 | agino); | 572 | agino); |
535 | bno = XFS_AGB_TO_DADDR(mp, agno, | 573 | bno = XFS_AGB_TO_DADDR(mp, agno, |
@@ -543,6 +581,7 @@ xfs_bulkstat( | |||
543 | KM_SLEEP); | 581 | KM_SLEEP); |
544 | ip->i_ino = ino; | 582 | ip->i_ino = ino; |
545 | ip->i_mount = mp; | 583 | ip->i_mount = mp; |
584 | spin_lock_init(&ip->i_flags_lock); | ||
546 | if (bp) | 585 | if (bp) |
547 | xfs_buf_relse(bp); | 586 | xfs_buf_relse(bp); |
548 | error = xfs_itobp(mp, NULL, ip, | 587 | error = xfs_itobp(mp, NULL, ip, |
@@ -564,30 +603,34 @@ xfs_bulkstat( | |||
564 | /* | 603 | /* |
565 | * Skip if this inode is free. | 604 | * Skip if this inode is free. |
566 | */ | 605 | */ |
567 | if (XFS_INOBT_MASK(chunkidx) & INT_GET(irbp->ir_free, ARCH_CONVERT)) | 606 | if (XFS_INOBT_MASK(chunkidx) & irbp->ir_free) |
568 | continue; | 607 | continue; |
569 | /* | 608 | /* |
570 | * Count used inodes as free so we can tell | 609 | * Count used inodes as free so we can tell |
571 | * when the chunk is used up. | 610 | * when the chunk is used up. |
572 | */ | 611 | */ |
573 | INT_MOD(irbp->ir_freecount, ARCH_CONVERT, +1); | 612 | irbp->ir_freecount++; |
574 | ino = XFS_AGINO_TO_INO(mp, agno, agino); | 613 | ino = XFS_AGINO_TO_INO(mp, agno, agino); |
575 | bno = XFS_AGB_TO_DADDR(mp, agno, agbno); | 614 | bno = XFS_AGB_TO_DADDR(mp, agno, agbno); |
576 | if (flags & BULKSTAT_FG_QUICK) { | 615 | if (!xfs_bulkstat_use_dinode(mp, flags, bp, |
577 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, | 616 | clustidx, &dip)) |
578 | (clustidx << mp->m_sb.sb_inodelog)); | 617 | continue; |
579 | 618 | /* | |
580 | if (INT_GET(dip->di_core.di_magic, ARCH_CONVERT) | 619 | * If we need to do an iget, cannot hold bp. |
581 | != XFS_DINODE_MAGIC | 620 | * Drop it, until starting the next cluster. |
582 | || !XFS_DINODE_GOOD_VERSION( | 621 | */ |
583 | INT_GET(dip->di_core.di_version, ARCH_CONVERT))) | 622 | if ((flags & BULKSTAT_FG_INLINE) && !dip) { |
584 | continue; | 623 | if (bp) |
624 | xfs_buf_relse(bp); | ||
625 | bp = NULL; | ||
585 | } | 626 | } |
586 | 627 | ||
587 | /* | 628 | /* |
588 | * Get the inode and fill in a single buffer. | 629 | * Get the inode and fill in a single buffer. |
589 | * BULKSTAT_FG_QUICK uses dip to fill it in. | 630 | * BULKSTAT_FG_QUICK uses dip to fill it in. |
590 | * BULKSTAT_FG_IGET uses igets. | 631 | * BULKSTAT_FG_IGET uses igets. |
632 | * BULKSTAT_FG_INLINE uses dip if we have an | ||
633 | * inline attr fork, else igets. | ||
591 | * See: xfs_bulkstat_one & xfs_dm_bulkstat_one. | 634 | * See: xfs_bulkstat_one & xfs_dm_bulkstat_one. |
592 | * This is also used to count inodes/blks, etc | 635 | * This is also used to count inodes/blks, etc |
593 | * in xfs_qm_quotacheck. | 636 | * in xfs_qm_quotacheck. |
@@ -597,8 +640,15 @@ xfs_bulkstat( | |||
597 | ubleft, private_data, | 640 | ubleft, private_data, |
598 | bno, &ubused, dip, &fmterror); | 641 | bno, &ubused, dip, &fmterror); |
599 | if (fmterror == BULKSTAT_RV_NOTHING) { | 642 | if (fmterror == BULKSTAT_RV_NOTHING) { |
600 | if (error == ENOMEM) | 643 | if (error == EFAULT) { |
644 | ubleft = 0; | ||
645 | rval = error; | ||
646 | break; | ||
647 | } | ||
648 | else if (error == ENOMEM) | ||
601 | ubleft = 0; | 649 | ubleft = 0; |
650 | else | ||
651 | lastino = ino; | ||
602 | continue; | 652 | continue; |
603 | } | 653 | } |
604 | if (fmterror == BULKSTAT_RV_GIVEUP) { | 654 | if (fmterror == BULKSTAT_RV_GIVEUP) { |
@@ -633,7 +683,7 @@ xfs_bulkstat( | |||
633 | /* | 683 | /* |
634 | * Done, we're either out of filesystem or space to put the data. | 684 | * Done, we're either out of filesystem or space to put the data. |
635 | */ | 685 | */ |
636 | kmem_free(irbuf, NBPC); | 686 | kmem_free(irbuf, irbsize); |
637 | *ubcountp = ubelem; | 687 | *ubcountp = ubelem; |
638 | if (agno >= mp->m_sb.sb_agcount) { | 688 | if (agno >= mp->m_sb.sb_agcount) { |
639 | /* | 689 | /* |
diff --git a/fs/xfs/xfs_itable.h b/fs/xfs/xfs_itable.h index be5f12e07d22..f25a28862a17 100644 --- a/fs/xfs/xfs_itable.h +++ b/fs/xfs/xfs_itable.h | |||
@@ -36,15 +36,16 @@ typedef int (*bulkstat_one_pf)(struct xfs_mount *mp, | |||
36 | /* | 36 | /* |
37 | * Values for stat return value. | 37 | * Values for stat return value. |
38 | */ | 38 | */ |
39 | #define BULKSTAT_RV_NOTHING 0 | 39 | #define BULKSTAT_RV_NOTHING 0 |
40 | #define BULKSTAT_RV_DIDONE 1 | 40 | #define BULKSTAT_RV_DIDONE 1 |
41 | #define BULKSTAT_RV_GIVEUP 2 | 41 | #define BULKSTAT_RV_GIVEUP 2 |
42 | 42 | ||
43 | /* | 43 | /* |
44 | * Values for bulkstat flag argument. | 44 | * Values for bulkstat flag argument. |
45 | */ | 45 | */ |
46 | #define BULKSTAT_FG_IGET 0x1 /* Go through the buffer cache */ | 46 | #define BULKSTAT_FG_IGET 0x1 /* Go through the buffer cache */ |
47 | #define BULKSTAT_FG_QUICK 0x2 /* No iget, walk the dinode cluster */ | 47 | #define BULKSTAT_FG_QUICK 0x2 /* No iget, walk the dinode cluster */ |
48 | #define BULKSTAT_FG_INLINE 0x4 /* No iget if inline attrs */ | ||
48 | 49 | ||
49 | /* | 50 | /* |
50 | * Return stat information in bulk (by-inode) for the filesystem. | 51 | * Return stat information in bulk (by-inode) for the filesystem. |
@@ -80,6 +81,11 @@ xfs_bulkstat_one( | |||
80 | void *dibuff, | 81 | void *dibuff, |
81 | int *stat); | 82 | int *stat); |
82 | 83 | ||
84 | int | ||
85 | xfs_internal_inum( | ||
86 | xfs_mount_t *mp, | ||
87 | xfs_ino_t ino); | ||
88 | |||
83 | int /* error status */ | 89 | int /* error status */ |
84 | xfs_inumbers( | 90 | xfs_inumbers( |
85 | xfs_mount_t *mp, /* mount point for filesystem */ | 91 | xfs_mount_t *mp, /* mount point for filesystem */ |
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 21ac1a67e3e0..c48bf61f17bd 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -617,7 +617,8 @@ xfs_log_unmount_write(xfs_mount_t *mp) | |||
617 | reg[0].i_len = sizeof(magic); | 617 | reg[0].i_len = sizeof(magic); |
618 | XLOG_VEC_SET_TYPE(®[0], XLOG_REG_TYPE_UNMOUNT); | 618 | XLOG_VEC_SET_TYPE(®[0], XLOG_REG_TYPE_UNMOUNT); |
619 | 619 | ||
620 | error = xfs_log_reserve(mp, 600, 1, &tic, XFS_LOG, 0, 0); | 620 | error = xfs_log_reserve(mp, 600, 1, &tic, |
621 | XFS_LOG, 0, XLOG_UNMOUNT_REC_TYPE); | ||
621 | if (!error) { | 622 | if (!error) { |
622 | /* remove inited flag */ | 623 | /* remove inited flag */ |
623 | ((xlog_ticket_t *)tic)->t_flags = 0; | 624 | ((xlog_ticket_t *)tic)->t_flags = 0; |
@@ -655,8 +656,11 @@ xfs_log_unmount_write(xfs_mount_t *mp) | |||
655 | } else { | 656 | } else { |
656 | LOG_UNLOCK(log, s); | 657 | LOG_UNLOCK(log, s); |
657 | } | 658 | } |
658 | if (tic) | 659 | if (tic) { |
660 | xlog_trace_loggrant(log, tic, "unmount rec"); | ||
661 | xlog_ungrant_log_space(log, tic); | ||
659 | xlog_state_put_ticket(log, tic); | 662 | xlog_state_put_ticket(log, tic); |
663 | } | ||
660 | } else { | 664 | } else { |
661 | /* | 665 | /* |
662 | * We're already in forced_shutdown mode, couldn't | 666 | * We're already in forced_shutdown mode, couldn't |
@@ -1196,7 +1200,7 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1196 | kmem_zalloc(sizeof(xlog_in_core_t), KM_SLEEP); | 1200 | kmem_zalloc(sizeof(xlog_in_core_t), KM_SLEEP); |
1197 | iclog = *iclogp; | 1201 | iclog = *iclogp; |
1198 | iclog->hic_data = (xlog_in_core_2_t *) | 1202 | iclog->hic_data = (xlog_in_core_2_t *) |
1199 | kmem_zalloc(iclogsize, KM_SLEEP); | 1203 | kmem_zalloc(iclogsize, KM_SLEEP | KM_LARGE); |
1200 | 1204 | ||
1201 | iclog->ic_prev = prev_iclog; | 1205 | iclog->ic_prev = prev_iclog; |
1202 | prev_iclog = iclog; | 1206 | prev_iclog = iclog; |
@@ -2212,9 +2216,13 @@ xlog_state_do_callback( | |||
2212 | 2216 | ||
2213 | iclog = iclog->ic_next; | 2217 | iclog = iclog->ic_next; |
2214 | } while (first_iclog != iclog); | 2218 | } while (first_iclog != iclog); |
2215 | if (repeats && (repeats % 10) == 0) { | 2219 | |
2220 | if (repeats > 5000) { | ||
2221 | flushcnt += repeats; | ||
2222 | repeats = 0; | ||
2216 | xfs_fs_cmn_err(CE_WARN, log->l_mp, | 2223 | xfs_fs_cmn_err(CE_WARN, log->l_mp, |
2217 | "xlog_state_do_callback: looping %d", repeats); | 2224 | "%s: possible infinite loop (%d iterations)", |
2225 | __FUNCTION__, flushcnt); | ||
2218 | } | 2226 | } |
2219 | } while (!ioerrors && loopdidcallbacks); | 2227 | } while (!ioerrors && loopdidcallbacks); |
2220 | 2228 | ||
@@ -2246,6 +2254,7 @@ xlog_state_do_callback( | |||
2246 | } | 2254 | } |
2247 | #endif | 2255 | #endif |
2248 | 2256 | ||
2257 | flushcnt = 0; | ||
2249 | if (log->l_iclog->ic_state & (XLOG_STATE_ACTIVE|XLOG_STATE_IOERROR)) { | 2258 | if (log->l_iclog->ic_state & (XLOG_STATE_ACTIVE|XLOG_STATE_IOERROR)) { |
2250 | flushcnt = log->l_flushcnt; | 2259 | flushcnt = log->l_flushcnt; |
2251 | log->l_flushcnt = 0; | 2260 | log->l_flushcnt = 0; |
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h index eacb3d4987f2..ebbe93f4f97b 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h | |||
@@ -48,16 +48,10 @@ static inline xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2) | |||
48 | */ | 48 | */ |
49 | 49 | ||
50 | /* | 50 | /* |
51 | * Flags to xfs_log_mount | ||
52 | */ | ||
53 | #define XFS_LOG_RECOVER 0x1 | ||
54 | |||
55 | /* | ||
56 | * Flags to xfs_log_done() | 51 | * Flags to xfs_log_done() |
57 | */ | 52 | */ |
58 | #define XFS_LOG_REL_PERM_RESERV 0x1 | 53 | #define XFS_LOG_REL_PERM_RESERV 0x1 |
59 | 54 | ||
60 | |||
61 | /* | 55 | /* |
62 | * Flags to xfs_log_reserve() | 56 | * Flags to xfs_log_reserve() |
63 | * | 57 | * |
@@ -70,8 +64,6 @@ static inline xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2) | |||
70 | #define XFS_LOG_SLEEP 0x0 | 64 | #define XFS_LOG_SLEEP 0x0 |
71 | #define XFS_LOG_NOSLEEP 0x1 | 65 | #define XFS_LOG_NOSLEEP 0x1 |
72 | #define XFS_LOG_PERM_RESERV 0x2 | 66 | #define XFS_LOG_PERM_RESERV 0x2 |
73 | #define XFS_LOG_RESV_ALL (XFS_LOG_NOSLEEP|XFS_LOG_PERM_RESERV) | ||
74 | |||
75 | 67 | ||
76 | /* | 68 | /* |
77 | * Flags to xfs_log_force() | 69 | * Flags to xfs_log_force() |
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index 34bcbf50789c..9bd3cdf11a87 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h | |||
@@ -32,7 +32,6 @@ struct xfs_mount; | |||
32 | #define XLOG_MIN_ICLOGS 2 | 32 | #define XLOG_MIN_ICLOGS 2 |
33 | #define XLOG_MED_ICLOGS 4 | 33 | #define XLOG_MED_ICLOGS 4 |
34 | #define XLOG_MAX_ICLOGS 8 | 34 | #define XLOG_MAX_ICLOGS 8 |
35 | #define XLOG_CALLBACK_SIZE 10 | ||
36 | #define XLOG_HEADER_MAGIC_NUM 0xFEEDbabe /* Invalid cycle number */ | 35 | #define XLOG_HEADER_MAGIC_NUM 0xFEEDbabe /* Invalid cycle number */ |
37 | #define XLOG_VERSION_1 1 | 36 | #define XLOG_VERSION_1 1 |
38 | #define XLOG_VERSION_2 2 /* Large IClogs, Log sunit */ | 37 | #define XLOG_VERSION_2 2 /* Large IClogs, Log sunit */ |
@@ -149,9 +148,6 @@ struct xfs_mount; | |||
149 | #define XLOG_WAS_CONT_TRANS 0x08 /* Cont this trans into new region */ | 148 | #define XLOG_WAS_CONT_TRANS 0x08 /* Cont this trans into new region */ |
150 | #define XLOG_END_TRANS 0x10 /* End a continued transaction */ | 149 | #define XLOG_END_TRANS 0x10 /* End a continued transaction */ |
151 | #define XLOG_UNMOUNT_TRANS 0x20 /* Unmount a filesystem transaction */ | 150 | #define XLOG_UNMOUNT_TRANS 0x20 /* Unmount a filesystem transaction */ |
152 | #define XLOG_SKIP_TRANS (XLOG_COMMIT_TRANS | XLOG_CONTINUE_TRANS | \ | ||
153 | XLOG_WAS_CONT_TRANS | XLOG_END_TRANS | \ | ||
154 | XLOG_UNMOUNT_TRANS) | ||
155 | 151 | ||
156 | #ifdef __KERNEL__ | 152 | #ifdef __KERNEL__ |
157 | /* | 153 | /* |
@@ -506,6 +502,12 @@ extern int xlog_bread(xlog_t *, xfs_daddr_t, int, struct xfs_buf *); | |||
506 | #define XLOG_TRACE_SLEEP_FLUSH 3 | 502 | #define XLOG_TRACE_SLEEP_FLUSH 3 |
507 | #define XLOG_TRACE_WAKE_FLUSH 4 | 503 | #define XLOG_TRACE_WAKE_FLUSH 4 |
508 | 504 | ||
505 | /* | ||
506 | * Unmount record type is used as a pseudo transaction type for the ticket. | ||
507 | * It's value must be outside the range of XFS_TRANS_* values. | ||
508 | */ | ||
509 | #define XLOG_UNMOUNT_REC_TYPE (-1U) | ||
510 | |||
509 | #endif /* __KERNEL__ */ | 511 | #endif /* __KERNEL__ */ |
510 | 512 | ||
511 | #endif /* __XFS_LOG_PRIV_H__ */ | 513 | #endif /* __XFS_LOG_PRIV_H__ */ |
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index b2bd4be4200a..e5f396ff9a3d 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h | |||
@@ -331,7 +331,7 @@ typedef struct xfs_mount { | |||
331 | xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */ | 331 | xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */ |
332 | lock_t m_agirotor_lock;/* .. and lock protecting it */ | 332 | lock_t m_agirotor_lock;/* .. and lock protecting it */ |
333 | xfs_agnumber_t m_maxagi; /* highest inode alloc group */ | 333 | xfs_agnumber_t m_maxagi; /* highest inode alloc group */ |
334 | uint m_ihsize; /* size of next field */ | 334 | size_t m_ihsize; /* size of next field */ |
335 | struct xfs_ihash *m_ihash; /* fs private inode hash table*/ | 335 | struct xfs_ihash *m_ihash; /* fs private inode hash table*/ |
336 | struct xfs_inode *m_inodes; /* active inode list */ | 336 | struct xfs_inode *m_inodes; /* active inode list */ |
337 | struct list_head m_del_inodes; /* inodes to reclaim */ | 337 | struct list_head m_del_inodes; /* inodes to reclaim */ |
@@ -541,7 +541,8 @@ static inline xfs_mount_t *xfs_bhvtom(bhv_desc_t *bdp) | |||
541 | #define XFS_VFSTOM(vfs) xfs_vfstom(vfs) | 541 | #define XFS_VFSTOM(vfs) xfs_vfstom(vfs) |
542 | static inline xfs_mount_t *xfs_vfstom(bhv_vfs_t *vfs) | 542 | static inline xfs_mount_t *xfs_vfstom(bhv_vfs_t *vfs) |
543 | { | 543 | { |
544 | return XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfs), &xfs_vfsops)); | 544 | return XFS_BHVTOM(bhv_lookup_range(VFS_BHVHEAD(vfs), |
545 | VFS_POSITION_XFS, VFS_POSITION_XFS)); | ||
545 | } | 546 | } |
546 | 547 | ||
547 | #define XFS_DADDR_TO_AGNO(mp,d) xfs_daddr_to_agno(mp,d) | 548 | #define XFS_DADDR_TO_AGNO(mp,d) xfs_daddr_to_agno(mp,d) |
diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h index acb853b33ebb..9dcb32aa4e2e 100644 --- a/fs/xfs/xfs_quota.h +++ b/fs/xfs/xfs_quota.h | |||
@@ -281,8 +281,6 @@ typedef struct xfs_qoff_logformat { | |||
281 | XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ | 281 | XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ |
282 | XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\ | 282 | XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\ |
283 | XFS_GQUOTA_ACCT) | 283 | XFS_GQUOTA_ACCT) |
284 | #define XFS_MOUNT_QUOTA_MASK (XFS_MOUNT_QUOTA_ALL | XFS_UQUOTA_ACTIVE | \ | ||
285 | XFS_GQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE) | ||
286 | 284 | ||
287 | 285 | ||
288 | /* | 286 | /* |
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 5a0b678956e0..880c73271c05 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c | |||
@@ -1948,7 +1948,7 @@ xfs_growfs_rt( | |||
1948 | */ | 1948 | */ |
1949 | nrextents = nrblocks; | 1949 | nrextents = nrblocks; |
1950 | do_div(nrextents, in->extsize); | 1950 | do_div(nrextents, in->extsize); |
1951 | nrbmblocks = roundup_64(nrextents, NBBY * sbp->sb_blocksize); | 1951 | nrbmblocks = howmany_64(nrextents, NBBY * sbp->sb_blocksize); |
1952 | nrextslog = xfs_highbit32(nrextents); | 1952 | nrextslog = xfs_highbit32(nrextents); |
1953 | nrsumlevels = nrextslog + 1; | 1953 | nrsumlevels = nrextslog + 1; |
1954 | nrsumsize = (uint)sizeof(xfs_suminfo_t) * nrsumlevels * nrbmblocks; | 1954 | nrsumsize = (uint)sizeof(xfs_suminfo_t) * nrsumlevels * nrbmblocks; |
@@ -1976,7 +1976,10 @@ xfs_growfs_rt( | |||
1976 | if ((error = xfs_growfs_rt_alloc(mp, rsumblocks, nrsumblocks, | 1976 | if ((error = xfs_growfs_rt_alloc(mp, rsumblocks, nrsumblocks, |
1977 | mp->m_sb.sb_rsumino))) | 1977 | mp->m_sb.sb_rsumino))) |
1978 | return error; | 1978 | return error; |
1979 | nmp = NULL; | 1979 | /* |
1980 | * Allocate a new (fake) mount/sb. | ||
1981 | */ | ||
1982 | nmp = kmem_alloc(sizeof(*nmp), KM_SLEEP); | ||
1980 | /* | 1983 | /* |
1981 | * Loop over the bitmap blocks. | 1984 | * Loop over the bitmap blocks. |
1982 | * We will do everything one bitmap block at a time. | 1985 | * We will do everything one bitmap block at a time. |
@@ -1987,10 +1990,6 @@ xfs_growfs_rt( | |||
1987 | ((sbp->sb_rextents & ((1 << mp->m_blkbit_log) - 1)) != 0); | 1990 | ((sbp->sb_rextents & ((1 << mp->m_blkbit_log) - 1)) != 0); |
1988 | bmbno < nrbmblocks; | 1991 | bmbno < nrbmblocks; |
1989 | bmbno++) { | 1992 | bmbno++) { |
1990 | /* | ||
1991 | * Allocate a new (fake) mount/sb. | ||
1992 | */ | ||
1993 | nmp = kmem_alloc(sizeof(*nmp), KM_SLEEP); | ||
1994 | *nmp = *mp; | 1993 | *nmp = *mp; |
1995 | nsbp = &nmp->m_sb; | 1994 | nsbp = &nmp->m_sb; |
1996 | /* | 1995 | /* |
@@ -2018,13 +2017,13 @@ xfs_growfs_rt( | |||
2018 | cancelflags = 0; | 2017 | cancelflags = 0; |
2019 | if ((error = xfs_trans_reserve(tp, 0, | 2018 | if ((error = xfs_trans_reserve(tp, 0, |
2020 | XFS_GROWRTFREE_LOG_RES(nmp), 0, 0, 0))) | 2019 | XFS_GROWRTFREE_LOG_RES(nmp), 0, 0, 0))) |
2021 | goto error_exit; | 2020 | break; |
2022 | /* | 2021 | /* |
2023 | * Lock out other callers by grabbing the bitmap inode lock. | 2022 | * Lock out other callers by grabbing the bitmap inode lock. |
2024 | */ | 2023 | */ |
2025 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, | 2024 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, |
2026 | XFS_ILOCK_EXCL, &ip))) | 2025 | XFS_ILOCK_EXCL, &ip))) |
2027 | goto error_exit; | 2026 | break; |
2028 | ASSERT(ip == mp->m_rbmip); | 2027 | ASSERT(ip == mp->m_rbmip); |
2029 | /* | 2028 | /* |
2030 | * Update the bitmap inode's size. | 2029 | * Update the bitmap inode's size. |
@@ -2038,7 +2037,7 @@ xfs_growfs_rt( | |||
2038 | */ | 2037 | */ |
2039 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, | 2038 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, |
2040 | XFS_ILOCK_EXCL, &ip))) | 2039 | XFS_ILOCK_EXCL, &ip))) |
2041 | goto error_exit; | 2040 | break; |
2042 | ASSERT(ip == mp->m_rsumip); | 2041 | ASSERT(ip == mp->m_rsumip); |
2043 | /* | 2042 | /* |
2044 | * Update the summary inode's size. | 2043 | * Update the summary inode's size. |
@@ -2053,7 +2052,7 @@ xfs_growfs_rt( | |||
2053 | mp->m_rsumlevels != nmp->m_rsumlevels) { | 2052 | mp->m_rsumlevels != nmp->m_rsumlevels) { |
2054 | error = xfs_rtcopy_summary(mp, nmp, tp); | 2053 | error = xfs_rtcopy_summary(mp, nmp, tp); |
2055 | if (error) | 2054 | if (error) |
2056 | goto error_exit; | 2055 | break; |
2057 | } | 2056 | } |
2058 | /* | 2057 | /* |
2059 | * Update superblock fields. | 2058 | * Update superblock fields. |
@@ -2080,18 +2079,13 @@ xfs_growfs_rt( | |||
2080 | error = xfs_rtfree_range(nmp, tp, sbp->sb_rextents, | 2079 | error = xfs_rtfree_range(nmp, tp, sbp->sb_rextents, |
2081 | nsbp->sb_rextents - sbp->sb_rextents, &bp, &sumbno); | 2080 | nsbp->sb_rextents - sbp->sb_rextents, &bp, &sumbno); |
2082 | if (error) | 2081 | if (error) |
2083 | goto error_exit; | 2082 | break; |
2084 | /* | 2083 | /* |
2085 | * Mark more blocks free in the superblock. | 2084 | * Mark more blocks free in the superblock. |
2086 | */ | 2085 | */ |
2087 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_FREXTENTS, | 2086 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_FREXTENTS, |
2088 | nsbp->sb_rextents - sbp->sb_rextents); | 2087 | nsbp->sb_rextents - sbp->sb_rextents); |
2089 | /* | 2088 | /* |
2090 | * Free the fake mp structure. | ||
2091 | */ | ||
2092 | kmem_free(nmp, sizeof(*nmp)); | ||
2093 | nmp = NULL; | ||
2094 | /* | ||
2095 | * Update mp values into the real mp structure. | 2089 | * Update mp values into the real mp structure. |
2096 | */ | 2090 | */ |
2097 | mp->m_rsumlevels = nrsumlevels; | 2091 | mp->m_rsumlevels = nrsumlevels; |
@@ -2101,15 +2095,15 @@ xfs_growfs_rt( | |||
2101 | */ | 2095 | */ |
2102 | xfs_trans_commit(tp, 0, NULL); | 2096 | xfs_trans_commit(tp, 0, NULL); |
2103 | } | 2097 | } |
2104 | return 0; | 2098 | |
2099 | if (error) | ||
2100 | xfs_trans_cancel(tp, cancelflags); | ||
2105 | 2101 | ||
2106 | /* | 2102 | /* |
2107 | * Error paths come here. | 2103 | * Free the fake mp structure. |
2108 | */ | 2104 | */ |
2109 | error_exit: | 2105 | kmem_free(nmp, sizeof(*nmp)); |
2110 | if (nmp) | 2106 | |
2111 | kmem_free(nmp, sizeof(*nmp)); | ||
2112 | xfs_trans_cancel(tp, cancelflags); | ||
2113 | return error; | 2107 | return error; |
2114 | } | 2108 | } |
2115 | 2109 | ||
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h index bf168a91ddb8..467854b45c8f 100644 --- a/fs/xfs/xfs_sb.h +++ b/fs/xfs/xfs_sb.h | |||
@@ -60,10 +60,6 @@ struct xfs_mount; | |||
60 | XFS_SB_VERSION_LOGV2BIT | \ | 60 | XFS_SB_VERSION_LOGV2BIT | \ |
61 | XFS_SB_VERSION_SECTORBIT | \ | 61 | XFS_SB_VERSION_SECTORBIT | \ |
62 | XFS_SB_VERSION_MOREBITSBIT) | 62 | XFS_SB_VERSION_MOREBITSBIT) |
63 | #define XFS_SB_VERSION_OKSASHBITS \ | ||
64 | (XFS_SB_VERSION_NUMBITS | \ | ||
65 | XFS_SB_VERSION_REALFBITS | \ | ||
66 | XFS_SB_VERSION_OKSASHFBITS) | ||
67 | #define XFS_SB_VERSION_OKREALBITS \ | 63 | #define XFS_SB_VERSION_OKREALBITS \ |
68 | (XFS_SB_VERSION_NUMBITS | \ | 64 | (XFS_SB_VERSION_NUMBITS | \ |
69 | XFS_SB_VERSION_OKREALFBITS | \ | 65 | XFS_SB_VERSION_OKREALFBITS | \ |
@@ -81,9 +77,6 @@ struct xfs_mount; | |||
81 | #define XFS_SB_VERSION2_RESERVED2BIT 0x00000002 | 77 | #define XFS_SB_VERSION2_RESERVED2BIT 0x00000002 |
82 | #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004 | 78 | #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004 |
83 | #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */ | 79 | #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */ |
84 | #define XFS_SB_VERSION2_SASHFBITS 0xff000000 /* Mask: features that | ||
85 | require changing | ||
86 | PROM and SASH */ | ||
87 | 80 | ||
88 | #define XFS_SB_VERSION2_OKREALFBITS \ | 81 | #define XFS_SB_VERSION2_OKREALFBITS \ |
89 | (XFS_SB_VERSION2_ATTR2BIT) | 82 | (XFS_SB_VERSION2_ATTR2BIT) |
@@ -238,12 +231,6 @@ static inline int xfs_sb_good_version(xfs_sb_t *sbp) | |||
238 | } | 231 | } |
239 | #endif /* __KERNEL__ */ | 232 | #endif /* __KERNEL__ */ |
240 | 233 | ||
241 | #define XFS_SB_GOOD_SASH_VERSION(sbp) \ | ||
242 | ((((sbp)->sb_versionnum >= XFS_SB_VERSION_1) && \ | ||
243 | ((sbp)->sb_versionnum <= XFS_SB_VERSION_3)) || \ | ||
244 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | ||
245 | !((sbp)->sb_versionnum & ~XFS_SB_VERSION_OKSASHBITS))) | ||
246 | |||
247 | #define XFS_SB_VERSION_TONEW(v) xfs_sb_version_tonew(v) | 234 | #define XFS_SB_VERSION_TONEW(v) xfs_sb_version_tonew(v) |
248 | static inline unsigned xfs_sb_version_tonew(unsigned v) | 235 | static inline unsigned xfs_sb_version_tonew(unsigned v) |
249 | { | 236 | { |
@@ -461,15 +448,6 @@ static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp) | |||
461 | * File system sector to basic block conversions. | 448 | * File system sector to basic block conversions. |
462 | */ | 449 | */ |
463 | #define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log) | 450 | #define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log) |
464 | #define XFS_BB_TO_FSS(mp,bb) \ | ||
465 | (((bb) + (XFS_FSS_TO_BB(mp,1) - 1)) >> (mp)->m_sectbb_log) | ||
466 | #define XFS_BB_TO_FSST(mp,bb) ((bb) >> (mp)->m_sectbb_log) | ||
467 | |||
468 | /* | ||
469 | * File system sector to byte conversions. | ||
470 | */ | ||
471 | #define XFS_FSS_TO_B(mp,sectno) ((xfs_fsize_t)(sectno) << (mp)->m_sb.sb_sectlog) | ||
472 | #define XFS_B_TO_FSST(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_sectlog) | ||
473 | 451 | ||
474 | /* | 452 | /* |
475 | * File system block to basic block conversions. | 453 | * File system block to basic block conversions. |
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index 9dc88b380608..c68e00105d23 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h | |||
@@ -149,7 +149,6 @@ typedef struct xfs_item_ops { | |||
149 | void (*iop_unlock)(xfs_log_item_t *); | 149 | void (*iop_unlock)(xfs_log_item_t *); |
150 | xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t); | 150 | xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t); |
151 | void (*iop_push)(xfs_log_item_t *); | 151 | void (*iop_push)(xfs_log_item_t *); |
152 | void (*iop_abort)(xfs_log_item_t *); | ||
153 | void (*iop_pushbuf)(xfs_log_item_t *); | 152 | void (*iop_pushbuf)(xfs_log_item_t *); |
154 | void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t); | 153 | void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t); |
155 | } xfs_item_ops_t; | 154 | } xfs_item_ops_t; |
@@ -163,7 +162,6 @@ typedef struct xfs_item_ops { | |||
163 | #define IOP_UNLOCK(ip) (*(ip)->li_ops->iop_unlock)(ip) | 162 | #define IOP_UNLOCK(ip) (*(ip)->li_ops->iop_unlock)(ip) |
164 | #define IOP_COMMITTED(ip, lsn) (*(ip)->li_ops->iop_committed)(ip, lsn) | 163 | #define IOP_COMMITTED(ip, lsn) (*(ip)->li_ops->iop_committed)(ip, lsn) |
165 | #define IOP_PUSH(ip) (*(ip)->li_ops->iop_push)(ip) | 164 | #define IOP_PUSH(ip) (*(ip)->li_ops->iop_push)(ip) |
166 | #define IOP_ABORT(ip) (*(ip)->li_ops->iop_abort)(ip) | ||
167 | #define IOP_PUSHBUF(ip) (*(ip)->li_ops->iop_pushbuf)(ip) | 165 | #define IOP_PUSHBUF(ip) (*(ip)->li_ops->iop_pushbuf)(ip) |
168 | #define IOP_COMMITTING(ip, lsn) (*(ip)->li_ops->iop_committing)(ip, lsn) | 166 | #define IOP_COMMITTING(ip, lsn) (*(ip)->li_ops->iop_committing)(ip, lsn) |
169 | 167 | ||
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c index 558c87ff0c41..fc39b166d403 100644 --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c | |||
@@ -276,7 +276,7 @@ xfs_trans_update_ail( | |||
276 | xfs_mount_t *mp, | 276 | xfs_mount_t *mp, |
277 | xfs_log_item_t *lip, | 277 | xfs_log_item_t *lip, |
278 | xfs_lsn_t lsn, | 278 | xfs_lsn_t lsn, |
279 | unsigned long s) | 279 | unsigned long s) __releases(mp->m_ail_lock) |
280 | { | 280 | { |
281 | xfs_ail_entry_t *ailp; | 281 | xfs_ail_entry_t *ailp; |
282 | xfs_log_item_t *dlip=NULL; | 282 | xfs_log_item_t *dlip=NULL; |
@@ -328,7 +328,7 @@ void | |||
328 | xfs_trans_delete_ail( | 328 | xfs_trans_delete_ail( |
329 | xfs_mount_t *mp, | 329 | xfs_mount_t *mp, |
330 | xfs_log_item_t *lip, | 330 | xfs_log_item_t *lip, |
331 | unsigned long s) | 331 | unsigned long s) __releases(mp->m_ail_lock) |
332 | { | 332 | { |
333 | xfs_ail_entry_t *ailp; | 333 | xfs_ail_entry_t *ailp; |
334 | xfs_log_item_t *dlip; | 334 | xfs_log_item_t *dlip; |
diff --git a/fs/xfs/xfs_trans_priv.h b/fs/xfs/xfs_trans_priv.h index 13edab8a9e94..447ac4308c91 100644 --- a/fs/xfs/xfs_trans_priv.h +++ b/fs/xfs/xfs_trans_priv.h | |||
@@ -46,11 +46,13 @@ xfs_log_busy_slot_t *xfs_trans_add_busy(xfs_trans_t *tp, | |||
46 | /* | 46 | /* |
47 | * From xfs_trans_ail.c | 47 | * From xfs_trans_ail.c |
48 | */ | 48 | */ |
49 | void xfs_trans_update_ail(struct xfs_mount *, | 49 | void xfs_trans_update_ail(struct xfs_mount *mp, |
50 | struct xfs_log_item *, xfs_lsn_t, | 50 | struct xfs_log_item *lip, xfs_lsn_t lsn, |
51 | unsigned long); | 51 | unsigned long s) |
52 | void xfs_trans_delete_ail(struct xfs_mount *, | 52 | __releases(mp->m_ail_lock); |
53 | struct xfs_log_item *, unsigned long); | 53 | void xfs_trans_delete_ail(struct xfs_mount *mp, |
54 | struct xfs_log_item *lip, unsigned long s) | ||
55 | __releases(mp->m_ail_lock); | ||
54 | struct xfs_log_item *xfs_trans_first_ail(struct xfs_mount *, int *); | 56 | struct xfs_log_item *xfs_trans_first_ail(struct xfs_mount *, int *); |
55 | struct xfs_log_item *xfs_trans_next_ail(struct xfs_mount *, | 57 | struct xfs_log_item *xfs_trans_next_ail(struct xfs_mount *, |
56 | struct xfs_log_item *, int *, int *); | 58 | struct xfs_log_item *, int *, int *); |
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c index a34796e57afb..62336a4cc5a4 100644 --- a/fs/xfs/xfs_vfsops.c +++ b/fs/xfs/xfs_vfsops.c | |||
@@ -1922,7 +1922,7 @@ xfs_showargs( | |||
1922 | } | 1922 | } |
1923 | 1923 | ||
1924 | if (mp->m_flags & XFS_MOUNT_IHASHSIZE) | 1924 | if (mp->m_flags & XFS_MOUNT_IHASHSIZE) |
1925 | seq_printf(m, "," MNTOPT_IHASHSIZE "=%d", mp->m_ihsize); | 1925 | seq_printf(m, "," MNTOPT_IHASHSIZE "=%d", (int)mp->m_ihsize); |
1926 | 1926 | ||
1927 | if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) | 1927 | if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) |
1928 | seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk", | 1928 | seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk", |
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index 23cfa5837728..061e2ffdd1de 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -2366,10 +2366,15 @@ xfs_remove( | |||
2366 | 2366 | ||
2367 | namelen = VNAMELEN(dentry); | 2367 | namelen = VNAMELEN(dentry); |
2368 | 2368 | ||
2369 | if (!xfs_get_dir_entry(dentry, &ip)) { | ||
2370 | dm_di_mode = ip->i_d.di_mode; | ||
2371 | IRELE(ip); | ||
2372 | } | ||
2373 | |||
2369 | if (DM_EVENT_ENABLED(dir_vp->v_vfsp, dp, DM_EVENT_REMOVE)) { | 2374 | if (DM_EVENT_ENABLED(dir_vp->v_vfsp, dp, DM_EVENT_REMOVE)) { |
2370 | error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, dir_vp, | 2375 | error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, dir_vp, |
2371 | DM_RIGHT_NULL, NULL, DM_RIGHT_NULL, | 2376 | DM_RIGHT_NULL, NULL, DM_RIGHT_NULL, |
2372 | name, NULL, 0, 0, 0); | 2377 | name, NULL, dm_di_mode, 0, 0); |
2373 | if (error) | 2378 | if (error) |
2374 | return error; | 2379 | return error; |
2375 | } | 2380 | } |
@@ -2995,7 +3000,7 @@ xfs_rmdir( | |||
2995 | int cancel_flags; | 3000 | int cancel_flags; |
2996 | int committed; | 3001 | int committed; |
2997 | bhv_vnode_t *dir_vp; | 3002 | bhv_vnode_t *dir_vp; |
2998 | int dm_di_mode = 0; | 3003 | int dm_di_mode = S_IFDIR; |
2999 | int last_cdp_link; | 3004 | int last_cdp_link; |
3000 | int namelen; | 3005 | int namelen; |
3001 | uint resblks; | 3006 | uint resblks; |
@@ -3010,11 +3015,16 @@ xfs_rmdir( | |||
3010 | return XFS_ERROR(EIO); | 3015 | return XFS_ERROR(EIO); |
3011 | namelen = VNAMELEN(dentry); | 3016 | namelen = VNAMELEN(dentry); |
3012 | 3017 | ||
3018 | if (!xfs_get_dir_entry(dentry, &cdp)) { | ||
3019 | dm_di_mode = cdp->i_d.di_mode; | ||
3020 | IRELE(cdp); | ||
3021 | } | ||
3022 | |||
3013 | if (DM_EVENT_ENABLED(dir_vp->v_vfsp, dp, DM_EVENT_REMOVE)) { | 3023 | if (DM_EVENT_ENABLED(dir_vp->v_vfsp, dp, DM_EVENT_REMOVE)) { |
3014 | error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, | 3024 | error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, |
3015 | dir_vp, DM_RIGHT_NULL, | 3025 | dir_vp, DM_RIGHT_NULL, |
3016 | NULL, DM_RIGHT_NULL, | 3026 | NULL, DM_RIGHT_NULL, |
3017 | name, NULL, 0, 0, 0); | 3027 | name, NULL, dm_di_mode, 0, 0); |
3018 | if (error) | 3028 | if (error) |
3019 | return XFS_ERROR(error); | 3029 | return XFS_ERROR(error); |
3020 | } | 3030 | } |
@@ -3834,7 +3844,9 @@ xfs_reclaim( | |||
3834 | XFS_MOUNT_ILOCK(mp); | 3844 | XFS_MOUNT_ILOCK(mp); |
3835 | vn_bhv_remove(VN_BHV_HEAD(vp), XFS_ITOBHV(ip)); | 3845 | vn_bhv_remove(VN_BHV_HEAD(vp), XFS_ITOBHV(ip)); |
3836 | list_add_tail(&ip->i_reclaim, &mp->m_del_inodes); | 3846 | list_add_tail(&ip->i_reclaim, &mp->m_del_inodes); |
3847 | spin_lock(&ip->i_flags_lock); | ||
3837 | ip->i_flags |= XFS_IRECLAIMABLE; | 3848 | ip->i_flags |= XFS_IRECLAIMABLE; |
3849 | spin_unlock(&ip->i_flags_lock); | ||
3838 | XFS_MOUNT_IUNLOCK(mp); | 3850 | XFS_MOUNT_IUNLOCK(mp); |
3839 | } | 3851 | } |
3840 | return 0; | 3852 | return 0; |
@@ -3859,8 +3871,10 @@ xfs_finish_reclaim( | |||
3859 | * us. | 3871 | * us. |
3860 | */ | 3872 | */ |
3861 | write_lock(&ih->ih_lock); | 3873 | write_lock(&ih->ih_lock); |
3874 | spin_lock(&ip->i_flags_lock); | ||
3862 | if ((ip->i_flags & XFS_IRECLAIM) || | 3875 | if ((ip->i_flags & XFS_IRECLAIM) || |
3863 | (!(ip->i_flags & XFS_IRECLAIMABLE) && vp == NULL)) { | 3876 | (!(ip->i_flags & XFS_IRECLAIMABLE) && vp == NULL)) { |
3877 | spin_unlock(&ip->i_flags_lock); | ||
3864 | write_unlock(&ih->ih_lock); | 3878 | write_unlock(&ih->ih_lock); |
3865 | if (locked) { | 3879 | if (locked) { |
3866 | xfs_ifunlock(ip); | 3880 | xfs_ifunlock(ip); |
@@ -3869,6 +3883,7 @@ xfs_finish_reclaim( | |||
3869 | return 1; | 3883 | return 1; |
3870 | } | 3884 | } |
3871 | ip->i_flags |= XFS_IRECLAIM; | 3885 | ip->i_flags |= XFS_IRECLAIM; |
3886 | spin_unlock(&ip->i_flags_lock); | ||
3872 | write_unlock(&ih->ih_lock); | 3887 | write_unlock(&ih->ih_lock); |
3873 | 3888 | ||
3874 | /* | 3889 | /* |
@@ -4272,7 +4287,7 @@ xfs_free_file_space( | |||
4272 | xfs_mount_t *mp; | 4287 | xfs_mount_t *mp; |
4273 | int nimap; | 4288 | int nimap; |
4274 | uint resblks; | 4289 | uint resblks; |
4275 | int rounding; | 4290 | uint rounding; |
4276 | int rt; | 4291 | int rt; |
4277 | xfs_fileoff_t startoffset_fsb; | 4292 | xfs_fileoff_t startoffset_fsb; |
4278 | xfs_trans_t *tp; | 4293 | xfs_trans_t *tp; |
@@ -4313,8 +4328,7 @@ xfs_free_file_space( | |||
4313 | vn_iowait(vp); /* wait for the completion of any pending DIOs */ | 4328 | vn_iowait(vp); /* wait for the completion of any pending DIOs */ |
4314 | } | 4329 | } |
4315 | 4330 | ||
4316 | rounding = MAX((__uint8_t)(1 << mp->m_sb.sb_blocklog), | 4331 | rounding = max_t(uint, 1 << mp->m_sb.sb_blocklog, NBPP); |
4317 | (__uint8_t)NBPP); | ||
4318 | ilen = len + (offset & (rounding - 1)); | 4332 | ilen = len + (offset & (rounding - 1)); |
4319 | ioffset = offset & ~(rounding - 1); | 4333 | ioffset = offset & ~(rounding - 1); |
4320 | if (ilen & (rounding - 1)) | 4334 | if (ilen & (rounding - 1)) |