diff options
| author | Ingo Molnar <mingo@elte.hu> | 2008-09-04 07:02:35 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2008-09-04 07:02:35 -0400 |
| commit | 42390cdec5f6e6e2ee54f308474a6ef7dd16aa5c (patch) | |
| tree | e9684c84f53272319a5acd4b9c86503f30274a51 /fs | |
| parent | 11c231a962c740b3216eb6565149ae5a7944cba7 (diff) | |
| parent | d210baf53b699fc61aa891c177b71d7082d3b957 (diff) | |
Merge branch 'linus' into x86/x2apic
Conflicts:
arch/x86/kernel/cpu/cyrix.c
include/asm-x86/cpufeature.h
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'fs')
83 files changed, 1156 insertions, 805 deletions
diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c index 88e3787c6ea9..e298fe194093 100644 --- a/fs/9p/vfs_dir.c +++ b/fs/9p/vfs_dir.c | |||
| @@ -119,6 +119,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp) | |||
| 119 | 119 | ||
| 120 | const struct file_operations v9fs_dir_operations = { | 120 | const struct file_operations v9fs_dir_operations = { |
| 121 | .read = generic_read_dir, | 121 | .read = generic_read_dir, |
| 122 | .llseek = generic_file_llseek, | ||
| 122 | .readdir = v9fs_dir_readdir, | 123 | .readdir = v9fs_dir_readdir, |
| 123 | .open = v9fs_file_open, | 124 | .open = v9fs_file_open, |
| 124 | .release = v9fs_dir_release, | 125 | .release = v9fs_dir_release, |
diff --git a/fs/Kconfig b/fs/Kconfig index d3873583360b..abccb5dab9a8 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
| @@ -1930,6 +1930,16 @@ config CIFS_WEAK_PW_HASH | |||
| 1930 | 1930 | ||
| 1931 | If unsure, say N. | 1931 | If unsure, say N. |
| 1932 | 1932 | ||
| 1933 | config CIFS_UPCALL | ||
| 1934 | bool "Kerberos/SPNEGO advanced session setup" | ||
| 1935 | depends on CIFS && KEYS | ||
| 1936 | help | ||
| 1937 | Enables an upcall mechanism for CIFS which accesses | ||
| 1938 | userspace helper utilities to provide SPNEGO packaged (RFC 4178) | ||
| 1939 | Kerberos tickets which are needed to mount to certain secure servers | ||
| 1940 | (for which more secure Kerberos authentication is required). If | ||
| 1941 | unsure, say N. | ||
| 1942 | |||
| 1933 | config CIFS_XATTR | 1943 | config CIFS_XATTR |
| 1934 | bool "CIFS extended attributes" | 1944 | bool "CIFS extended attributes" |
| 1935 | depends on CIFS | 1945 | depends on CIFS |
| @@ -1982,17 +1992,6 @@ config CIFS_EXPERIMENTAL | |||
| 1982 | (which is disabled by default). See the file fs/cifs/README | 1992 | (which is disabled by default). See the file fs/cifs/README |
| 1983 | for more details. If unsure, say N. | 1993 | for more details. If unsure, say N. |
| 1984 | 1994 | ||
| 1985 | config CIFS_UPCALL | ||
| 1986 | bool "Kerberos/SPNEGO advanced session setup (EXPERIMENTAL)" | ||
| 1987 | depends on CIFS_EXPERIMENTAL | ||
| 1988 | depends on KEYS | ||
| 1989 | help | ||
| 1990 | Enables an upcall mechanism for CIFS which accesses | ||
| 1991 | userspace helper utilities to provide SPNEGO packaged (RFC 4178) | ||
| 1992 | Kerberos tickets which are needed to mount to certain secure servers | ||
| 1993 | (for which more secure Kerberos authentication is required). If | ||
| 1994 | unsure, say N. | ||
| 1995 | |||
| 1996 | config CIFS_DFS_UPCALL | 1995 | config CIFS_DFS_UPCALL |
| 1997 | bool "DFS feature support (EXPERIMENTAL)" | 1996 | bool "DFS feature support (EXPERIMENTAL)" |
| 1998 | depends on CIFS_EXPERIMENTAL | 1997 | depends on CIFS_EXPERIMENTAL |
diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c index fc1a8dc64d78..85a30e929800 100644 --- a/fs/adfs/dir.c +++ b/fs/adfs/dir.c | |||
| @@ -197,6 +197,7 @@ out: | |||
| 197 | 197 | ||
| 198 | const struct file_operations adfs_dir_operations = { | 198 | const struct file_operations adfs_dir_operations = { |
| 199 | .read = generic_read_dir, | 199 | .read = generic_read_dir, |
| 200 | .llseek = generic_file_llseek, | ||
| 200 | .readdir = adfs_readdir, | 201 | .readdir = adfs_readdir, |
| 201 | .fsync = file_fsync, | 202 | .fsync = file_fsync, |
| 202 | }; | 203 | }; |
diff --git a/fs/affs/dir.c b/fs/affs/dir.c index 6e3f282424b0..7b36904dbeac 100644 --- a/fs/affs/dir.c +++ b/fs/affs/dir.c | |||
| @@ -19,6 +19,7 @@ static int affs_readdir(struct file *, void *, filldir_t); | |||
| 19 | 19 | ||
| 20 | const struct file_operations affs_dir_operations = { | 20 | const struct file_operations affs_dir_operations = { |
| 21 | .read = generic_read_dir, | 21 | .read = generic_read_dir, |
| 22 | .llseek = generic_file_llseek, | ||
| 22 | .readdir = affs_readdir, | 23 | .readdir = affs_readdir, |
| 23 | .fsync = file_fsync, | 24 | .fsync = file_fsync, |
| 24 | }; | 25 | }; |
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index bcfb2dc0a61b..2a41c2a7fc52 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c | |||
| @@ -36,6 +36,7 @@ const struct file_operations autofs4_root_operations = { | |||
| 36 | .release = dcache_dir_close, | 36 | .release = dcache_dir_close, |
| 37 | .read = generic_read_dir, | 37 | .read = generic_read_dir, |
| 38 | .readdir = dcache_readdir, | 38 | .readdir = dcache_readdir, |
| 39 | .llseek = dcache_dir_lseek, | ||
| 39 | .ioctl = autofs4_root_ioctl, | 40 | .ioctl = autofs4_root_ioctl, |
| 40 | }; | 41 | }; |
| 41 | 42 | ||
| @@ -44,6 +45,7 @@ const struct file_operations autofs4_dir_operations = { | |||
| 44 | .release = dcache_dir_close, | 45 | .release = dcache_dir_close, |
| 45 | .read = generic_read_dir, | 46 | .read = generic_read_dir, |
| 46 | .readdir = dcache_readdir, | 47 | .readdir = dcache_readdir, |
| 48 | .llseek = dcache_dir_lseek, | ||
| 47 | }; | 49 | }; |
| 48 | 50 | ||
| 49 | const struct inode_operations autofs4_indirect_root_inode_operations = { | 51 | const struct inode_operations autofs4_indirect_root_inode_operations = { |
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 02c6e62b72f8..740f53672a8a 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c | |||
| @@ -66,6 +66,7 @@ static struct kmem_cache *befs_inode_cachep; | |||
| 66 | static const struct file_operations befs_dir_operations = { | 66 | static const struct file_operations befs_dir_operations = { |
| 67 | .read = generic_read_dir, | 67 | .read = generic_read_dir, |
| 68 | .readdir = befs_readdir, | 68 | .readdir = befs_readdir, |
| 69 | .llseek = generic_file_llseek, | ||
| 69 | }; | 70 | }; |
| 70 | 71 | ||
| 71 | static const struct inode_operations befs_dir_inode_operations = { | 72 | static const struct inode_operations befs_dir_inode_operations = { |
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 56372ecf1690..dfc0197905ca 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c | |||
| @@ -914,7 +914,9 @@ static int load_flat_binary(struct linux_binprm * bprm, struct pt_regs * regs) | |||
| 914 | /* Stash our initial stack pointer into the mm structure */ | 914 | /* Stash our initial stack pointer into the mm structure */ |
| 915 | current->mm->start_stack = (unsigned long )sp; | 915 | current->mm->start_stack = (unsigned long )sp; |
| 916 | 916 | ||
| 917 | 917 | #ifdef FLAT_PLAT_INIT | |
| 918 | FLAT_PLAT_INIT(regs); | ||
| 919 | #endif | ||
| 918 | DBG_FLT("start_thread(regs=0x%x, entry=0x%x, start_stack=0x%x)\n", | 920 | DBG_FLT("start_thread(regs=0x%x, entry=0x%x, start_stack=0x%x)\n", |
| 919 | (int)regs, (int)start_addr, (int)current->mm->start_stack); | 921 | (int)regs, (int)start_addr, (int)current->mm->start_stack); |
| 920 | 922 | ||
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 756205314c24..8d7e88e02e0f 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c | |||
| @@ -120,8 +120,6 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
| 120 | if (bprm->misc_bang) | 120 | if (bprm->misc_bang) |
| 121 | goto _ret; | 121 | goto _ret; |
| 122 | 122 | ||
| 123 | bprm->misc_bang = 1; | ||
| 124 | |||
| 125 | /* to keep locking time low, we copy the interpreter string */ | 123 | /* to keep locking time low, we copy the interpreter string */ |
| 126 | read_lock(&entries_lock); | 124 | read_lock(&entries_lock); |
| 127 | fmt = check_file(bprm); | 125 | fmt = check_file(bprm); |
| @@ -199,6 +197,8 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
| 199 | if (retval < 0) | 197 | if (retval < 0) |
| 200 | goto _error; | 198 | goto _error; |
| 201 | 199 | ||
| 200 | bprm->misc_bang = 1; | ||
| 201 | |||
| 202 | retval = search_binary_handler (bprm, regs); | 202 | retval = search_binary_handler (bprm, regs); |
| 203 | if (retval < 0) | 203 | if (retval < 0) |
| 204 | goto _error; | 204 | goto _error; |
| @@ -469,20 +469,21 @@ static void bio_free_map_data(struct bio_map_data *bmd) | |||
| 469 | kfree(bmd); | 469 | kfree(bmd); |
| 470 | } | 470 | } |
| 471 | 471 | ||
| 472 | static struct bio_map_data *bio_alloc_map_data(int nr_segs, int iov_count) | 472 | static struct bio_map_data *bio_alloc_map_data(int nr_segs, int iov_count, |
| 473 | gfp_t gfp_mask) | ||
| 473 | { | 474 | { |
| 474 | struct bio_map_data *bmd = kmalloc(sizeof(*bmd), GFP_KERNEL); | 475 | struct bio_map_data *bmd = kmalloc(sizeof(*bmd), gfp_mask); |
| 475 | 476 | ||
| 476 | if (!bmd) | 477 | if (!bmd) |
| 477 | return NULL; | 478 | return NULL; |
| 478 | 479 | ||
| 479 | bmd->iovecs = kmalloc(sizeof(struct bio_vec) * nr_segs, GFP_KERNEL); | 480 | bmd->iovecs = kmalloc(sizeof(struct bio_vec) * nr_segs, gfp_mask); |
| 480 | if (!bmd->iovecs) { | 481 | if (!bmd->iovecs) { |
| 481 | kfree(bmd); | 482 | kfree(bmd); |
| 482 | return NULL; | 483 | return NULL; |
| 483 | } | 484 | } |
| 484 | 485 | ||
| 485 | bmd->sgvecs = kmalloc(sizeof(struct sg_iovec) * iov_count, GFP_KERNEL); | 486 | bmd->sgvecs = kmalloc(sizeof(struct sg_iovec) * iov_count, gfp_mask); |
| 486 | if (bmd->sgvecs) | 487 | if (bmd->sgvecs) |
| 487 | return bmd; | 488 | return bmd; |
| 488 | 489 | ||
| @@ -491,8 +492,8 @@ static struct bio_map_data *bio_alloc_map_data(int nr_segs, int iov_count) | |||
| 491 | return NULL; | 492 | return NULL; |
| 492 | } | 493 | } |
| 493 | 494 | ||
| 494 | static int __bio_copy_iov(struct bio *bio, struct sg_iovec *iov, int iov_count, | 495 | static int __bio_copy_iov(struct bio *bio, struct bio_vec *iovecs, |
| 495 | int uncopy) | 496 | struct sg_iovec *iov, int iov_count, int uncopy) |
| 496 | { | 497 | { |
| 497 | int ret = 0, i; | 498 | int ret = 0, i; |
| 498 | struct bio_vec *bvec; | 499 | struct bio_vec *bvec; |
| @@ -502,7 +503,7 @@ static int __bio_copy_iov(struct bio *bio, struct sg_iovec *iov, int iov_count, | |||
| 502 | 503 | ||
| 503 | __bio_for_each_segment(bvec, bio, i, 0) { | 504 | __bio_for_each_segment(bvec, bio, i, 0) { |
| 504 | char *bv_addr = page_address(bvec->bv_page); | 505 | char *bv_addr = page_address(bvec->bv_page); |
| 505 | unsigned int bv_len = bvec->bv_len; | 506 | unsigned int bv_len = iovecs[i].bv_len; |
| 506 | 507 | ||
| 507 | while (bv_len && iov_idx < iov_count) { | 508 | while (bv_len && iov_idx < iov_count) { |
| 508 | unsigned int bytes; | 509 | unsigned int bytes; |
| @@ -554,7 +555,7 @@ int bio_uncopy_user(struct bio *bio) | |||
| 554 | struct bio_map_data *bmd = bio->bi_private; | 555 | struct bio_map_data *bmd = bio->bi_private; |
| 555 | int ret; | 556 | int ret; |
| 556 | 557 | ||
| 557 | ret = __bio_copy_iov(bio, bmd->sgvecs, bmd->nr_sgvecs, 1); | 558 | ret = __bio_copy_iov(bio, bmd->iovecs, bmd->sgvecs, bmd->nr_sgvecs, 1); |
| 558 | 559 | ||
| 559 | bio_free_map_data(bmd); | 560 | bio_free_map_data(bmd); |
| 560 | bio_put(bio); | 561 | bio_put(bio); |
| @@ -596,7 +597,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q, struct sg_iovec *iov, | |||
| 596 | len += iov[i].iov_len; | 597 | len += iov[i].iov_len; |
| 597 | } | 598 | } |
| 598 | 599 | ||
| 599 | bmd = bio_alloc_map_data(nr_pages, iov_count); | 600 | bmd = bio_alloc_map_data(nr_pages, iov_count, GFP_KERNEL); |
| 600 | if (!bmd) | 601 | if (!bmd) |
| 601 | return ERR_PTR(-ENOMEM); | 602 | return ERR_PTR(-ENOMEM); |
| 602 | 603 | ||
| @@ -633,7 +634,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q, struct sg_iovec *iov, | |||
| 633 | * success | 634 | * success |
| 634 | */ | 635 | */ |
| 635 | if (!write_to_vm) { | 636 | if (!write_to_vm) { |
| 636 | ret = __bio_copy_iov(bio, iov, iov_count, 0); | 637 | ret = __bio_copy_iov(bio, bio->bi_io_vec, iov, iov_count, 0); |
| 637 | if (ret) | 638 | if (ret) |
| 638 | goto cleanup; | 639 | goto cleanup; |
| 639 | } | 640 | } |
| @@ -942,19 +943,22 @@ static void bio_copy_kern_endio(struct bio *bio, int err) | |||
| 942 | { | 943 | { |
| 943 | struct bio_vec *bvec; | 944 | struct bio_vec *bvec; |
| 944 | const int read = bio_data_dir(bio) == READ; | 945 | const int read = bio_data_dir(bio) == READ; |
| 945 | char *p = bio->bi_private; | 946 | struct bio_map_data *bmd = bio->bi_private; |
| 946 | int i; | 947 | int i; |
| 948 | char *p = bmd->sgvecs[0].iov_base; | ||
| 947 | 949 | ||
| 948 | __bio_for_each_segment(bvec, bio, i, 0) { | 950 | __bio_for_each_segment(bvec, bio, i, 0) { |
| 949 | char *addr = page_address(bvec->bv_page); | 951 | char *addr = page_address(bvec->bv_page); |
| 952 | int len = bmd->iovecs[i].bv_len; | ||
| 950 | 953 | ||
| 951 | if (read && !err) | 954 | if (read && !err) |
| 952 | memcpy(p, addr, bvec->bv_len); | 955 | memcpy(p, addr, len); |
| 953 | 956 | ||
| 954 | __free_page(bvec->bv_page); | 957 | __free_page(bvec->bv_page); |
| 955 | p += bvec->bv_len; | 958 | p += len; |
| 956 | } | 959 | } |
| 957 | 960 | ||
| 961 | bio_free_map_data(bmd); | ||
| 958 | bio_put(bio); | 962 | bio_put(bio); |
| 959 | } | 963 | } |
| 960 | 964 | ||
| @@ -978,11 +982,21 @@ struct bio *bio_copy_kern(struct request_queue *q, void *data, unsigned int len, | |||
| 978 | const int nr_pages = end - start; | 982 | const int nr_pages = end - start; |
| 979 | struct bio *bio; | 983 | struct bio *bio; |
| 980 | struct bio_vec *bvec; | 984 | struct bio_vec *bvec; |
| 985 | struct bio_map_data *bmd; | ||
| 981 | int i, ret; | 986 | int i, ret; |
| 987 | struct sg_iovec iov; | ||
| 988 | |||
| 989 | iov.iov_base = data; | ||
| 990 | iov.iov_len = len; | ||
| 991 | |||
| 992 | bmd = bio_alloc_map_data(nr_pages, 1, gfp_mask); | ||
| 993 | if (!bmd) | ||
| 994 | return ERR_PTR(-ENOMEM); | ||
| 982 | 995 | ||
| 996 | ret = -ENOMEM; | ||
| 983 | bio = bio_alloc(gfp_mask, nr_pages); | 997 | bio = bio_alloc(gfp_mask, nr_pages); |
| 984 | if (!bio) | 998 | if (!bio) |
| 985 | return ERR_PTR(-ENOMEM); | 999 | goto out_bmd; |
| 986 | 1000 | ||
| 987 | while (len) { | 1001 | while (len) { |
| 988 | struct page *page; | 1002 | struct page *page; |
| @@ -1016,14 +1030,18 @@ struct bio *bio_copy_kern(struct request_queue *q, void *data, unsigned int len, | |||
| 1016 | } | 1030 | } |
| 1017 | } | 1031 | } |
| 1018 | 1032 | ||
| 1019 | bio->bi_private = data; | 1033 | bio->bi_private = bmd; |
| 1020 | bio->bi_end_io = bio_copy_kern_endio; | 1034 | bio->bi_end_io = bio_copy_kern_endio; |
| 1035 | |||
| 1036 | bio_set_map_data(bmd, bio, &iov, 1); | ||
| 1021 | return bio; | 1037 | return bio; |
| 1022 | cleanup: | 1038 | cleanup: |
| 1023 | bio_for_each_segment(bvec, bio, i) | 1039 | bio_for_each_segment(bvec, bio, i) |
| 1024 | __free_page(bvec->bv_page); | 1040 | __free_page(bvec->bv_page); |
| 1025 | 1041 | ||
| 1026 | bio_put(bio); | 1042 | bio_put(bio); |
| 1043 | out_bmd: | ||
| 1044 | bio_free_map_data(bmd); | ||
| 1027 | 1045 | ||
| 1028 | return ERR_PTR(ret); | 1046 | return ERR_PTR(ret); |
| 1029 | } | 1047 | } |
diff --git a/fs/buffer.c b/fs/buffer.c index 38653e36e225..ac78d4c19b3b 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
| @@ -2926,14 +2926,17 @@ int submit_bh(int rw, struct buffer_head * bh) | |||
| 2926 | BUG_ON(!buffer_mapped(bh)); | 2926 | BUG_ON(!buffer_mapped(bh)); |
| 2927 | BUG_ON(!bh->b_end_io); | 2927 | BUG_ON(!bh->b_end_io); |
| 2928 | 2928 | ||
| 2929 | if (buffer_ordered(bh) && (rw == WRITE)) | 2929 | /* |
| 2930 | rw = WRITE_BARRIER; | 2930 | * Mask in barrier bit for a write (could be either a WRITE or a |
| 2931 | * WRITE_SYNC | ||
| 2932 | */ | ||
| 2933 | if (buffer_ordered(bh) && (rw & WRITE)) | ||
| 2934 | rw |= WRITE_BARRIER; | ||
| 2931 | 2935 | ||
| 2932 | /* | 2936 | /* |
| 2933 | * Only clear out a write error when rewriting, should this | 2937 | * Only clear out a write error when rewriting |
| 2934 | * include WRITE_SYNC as well? | ||
| 2935 | */ | 2938 | */ |
| 2936 | if (test_set_buffer_req(bh) && (rw == WRITE || rw == WRITE_BARRIER)) | 2939 | if (test_set_buffer_req(bh) && (rw & WRITE)) |
| 2937 | clear_buffer_write_io_error(bh); | 2940 | clear_buffer_write_io_error(bh); |
| 2938 | 2941 | ||
| 2939 | /* | 2942 | /* |
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES index f5d0083e09fa..06e521a945c3 100644 --- a/fs/cifs/CHANGES +++ b/fs/cifs/CHANGES | |||
| @@ -4,7 +4,15 @@ Fix premature write failure on congested networks (we would give up | |||
| 4 | on EAGAIN from the socket too quickly on large writes). | 4 | on EAGAIN from the socket too quickly on large writes). |
| 5 | Cifs_mkdir and cifs_create now respect the setgid bit on parent dir. | 5 | Cifs_mkdir and cifs_create now respect the setgid bit on parent dir. |
| 6 | Fix endian problems in acl (mode from/to cifs acl) on bigendian | 6 | Fix endian problems in acl (mode from/to cifs acl) on bigendian |
| 7 | architectures. | 7 | architectures. Fix problems with preserving timestamps on copying open |
| 8 | files (e.g. "cp -a") to Windows servers. For mkdir and create honor setgid bit | ||
| 9 | on parent directory when server supports Unix Extensions but not POSIX | ||
| 10 | create. Update cifs.upcall version to handle new Kerberos sec flags | ||
| 11 | (this requires update of cifs.upcall program from Samba). Fix memory leak | ||
| 12 | on dns_upcall (resolving DFS referralls). Fix plain text password | ||
| 13 | authentication (requires setting SecurityFlags to 0x30030 to enable | ||
| 14 | lanman and plain text though). Fix writes to be at correct offset when | ||
| 15 | file is open with O_APPEND and file is on a directio (forcediretio) mount. | ||
| 8 | 16 | ||
| 9 | Version 1.53 | 17 | Version 1.53 |
| 10 | ------------ | 18 | ------------ |
diff --git a/fs/cifs/README b/fs/cifs/README index 2bd6fe556f88..bd2343d4c6a6 100644 --- a/fs/cifs/README +++ b/fs/cifs/README | |||
| @@ -542,10 +542,20 @@ SecurityFlags Flags which control security negotiation and | |||
| 542 | hashing mechanisms (as "must use") on the other hand | 542 | hashing mechanisms (as "must use") on the other hand |
| 543 | does not make much sense. Default flags are | 543 | does not make much sense. Default flags are |
| 544 | 0x07007 | 544 | 0x07007 |
| 545 | (NTLM, NTLMv2 and packet signing allowed). Maximum | 545 | (NTLM, NTLMv2 and packet signing allowed). The maximum |
| 546 | allowable flags if you want to allow mounts to servers | 546 | allowable flags if you want to allow mounts to servers |
| 547 | using weaker password hashes is 0x37037 (lanman, | 547 | using weaker password hashes is 0x37037 (lanman, |
| 548 | plaintext, ntlm, ntlmv2, signing allowed): | 548 | plaintext, ntlm, ntlmv2, signing allowed). Some |
| 549 | SecurityFlags require the corresponding menuconfig | ||
| 550 | options to be enabled (lanman and plaintext require | ||
| 551 | CONFIG_CIFS_WEAK_PW_HASH for example). Enabling | ||
| 552 | plaintext authentication currently requires also | ||
| 553 | enabling lanman authentication in the security flags | ||
| 554 | because the cifs module only supports sending | ||
| 555 | laintext passwords using the older lanman dialect | ||
| 556 | form of the session setup SMB. (e.g. for authentication | ||
| 557 | using plain text passwords, set the SecurityFlags | ||
| 558 | to 0x30030): | ||
| 549 | 559 | ||
| 550 | may use packet signing 0x00001 | 560 | may use packet signing 0x00001 |
| 551 | must use packet signing 0x01001 | 561 | must use packet signing 0x01001 |
| @@ -642,8 +652,30 @@ The statistics for the number of total SMBs and oplock breaks are different in | |||
| 642 | that they represent all for that share, not just those for which the server | 652 | that they represent all for that share, not just those for which the server |
| 643 | returned success. | 653 | returned success. |
| 644 | 654 | ||
| 645 | Also note that "cat /proc/fs/cifs/DebugData" will display information about | 655 | Also note that "cat /proc/fs/cifs/DebugData" will display information about |
| 646 | the active sessions and the shares that are mounted. | 656 | the active sessions and the shares that are mounted. |
| 647 | Enabling Kerberos (extended security) works when CONFIG_CIFS_EXPERIMENTAL is | 657 | |
| 648 | on but requires a user space helper (from the Samba project). NTLM and NTLMv2 and | 658 | Enabling Kerberos (extended security) works but requires version 1.2 or later |
| 649 | LANMAN support do not require this helper. | 659 | of the helper program cifs.upcall to be present and to be configured in the |
| 660 | /etc/request-key.conf file. The cifs.upcall helper program is from the Samba | ||
| 661 | project(http://www.samba.org). NTLM and NTLMv2 and LANMAN support do not | ||
| 662 | require this helper. Note that NTLMv2 security (which does not require the | ||
| 663 | cifs.upcall helper program), instead of using Kerberos, is sufficient for | ||
| 664 | some use cases. | ||
| 665 | |||
| 666 | Enabling DFS support (used to access shares transparently in an MS-DFS | ||
| 667 | global name space) requires that CONFIG_CIFS_EXPERIMENTAL be enabled. In | ||
| 668 | addition, DFS support for target shares which are specified as UNC | ||
| 669 | names which begin with host names (rather than IP addresses) requires | ||
| 670 | a user space helper (such as cifs.upcall) to be present in order to | ||
| 671 | translate host names to ip address, and the user space helper must also | ||
| 672 | be configured in the file /etc/request-key.conf | ||
| 673 | |||
| 674 | To use cifs Kerberos and DFS support, the Linux keyutils package should be | ||
| 675 | installed and something like the following lines should be added to the | ||
| 676 | /etc/request-key.conf file: | ||
| 677 | |||
| 678 | create cifs.spnego * * /usr/local/sbin/cifs.upcall %k | ||
| 679 | create dns_resolver * * /usr/local/sbin/cifs.upcall %k | ||
| 680 | |||
| 681 | |||
diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c index 5fabd2caf93c..1b09f1670061 100644 --- a/fs/cifs/asn1.c +++ b/fs/cifs/asn1.c | |||
| @@ -476,6 +476,7 @@ decode_negTokenInit(unsigned char *security_blob, int length, | |||
| 476 | unsigned int cls, con, tag, oidlen, rc; | 476 | unsigned int cls, con, tag, oidlen, rc; |
| 477 | bool use_ntlmssp = false; | 477 | bool use_ntlmssp = false; |
| 478 | bool use_kerberos = false; | 478 | bool use_kerberos = false; |
| 479 | bool use_mskerberos = false; | ||
| 479 | 480 | ||
| 480 | *secType = NTLM; /* BB eventually make Kerberos or NLTMSSP the default*/ | 481 | *secType = NTLM; /* BB eventually make Kerberos or NLTMSSP the default*/ |
| 481 | 482 | ||
| @@ -574,10 +575,12 @@ decode_negTokenInit(unsigned char *security_blob, int length, | |||
| 574 | *(oid + 1), *(oid + 2), *(oid + 3))); | 575 | *(oid + 1), *(oid + 2), *(oid + 3))); |
| 575 | 576 | ||
| 576 | if (compare_oid(oid, oidlen, MSKRB5_OID, | 577 | if (compare_oid(oid, oidlen, MSKRB5_OID, |
| 577 | MSKRB5_OID_LEN)) | 578 | MSKRB5_OID_LEN) && |
| 578 | use_kerberos = true; | 579 | !use_kerberos) |
| 580 | use_mskerberos = true; | ||
| 579 | else if (compare_oid(oid, oidlen, KRB5_OID, | 581 | else if (compare_oid(oid, oidlen, KRB5_OID, |
| 580 | KRB5_OID_LEN)) | 582 | KRB5_OID_LEN) && |
| 583 | !use_mskerberos) | ||
| 581 | use_kerberos = true; | 584 | use_kerberos = true; |
| 582 | else if (compare_oid(oid, oidlen, NTLMSSP_OID, | 585 | else if (compare_oid(oid, oidlen, NTLMSSP_OID, |
| 583 | NTLMSSP_OID_LEN)) | 586 | NTLMSSP_OID_LEN)) |
| @@ -630,6 +633,8 @@ decode_negTokenInit(unsigned char *security_blob, int length, | |||
| 630 | 633 | ||
| 631 | if (use_kerberos) | 634 | if (use_kerberos) |
| 632 | *secType = Kerberos; | 635 | *secType = Kerberos; |
| 636 | else if (use_mskerberos) | ||
| 637 | *secType = MSKerberos; | ||
| 633 | else if (use_ntlmssp) | 638 | else if (use_ntlmssp) |
| 634 | *secType = NTLMSSP; | 639 | *secType = NTLMSSP; |
| 635 | 640 | ||
diff --git a/fs/cifs/cifs_spnego.c b/fs/cifs/cifs_spnego.c index 2434ab0e8791..117ef4bba68e 100644 --- a/fs/cifs/cifs_spnego.c +++ b/fs/cifs/cifs_spnego.c | |||
| @@ -114,9 +114,11 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo) | |||
| 114 | 114 | ||
| 115 | dp = description + strlen(description); | 115 | dp = description + strlen(description); |
| 116 | 116 | ||
| 117 | /* for now, only sec=krb5 is valid */ | 117 | /* for now, only sec=krb5 and sec=mskrb5 are valid */ |
| 118 | if (server->secType == Kerberos) | 118 | if (server->secType == Kerberos) |
| 119 | sprintf(dp, ";sec=krb5"); | 119 | sprintf(dp, ";sec=krb5"); |
| 120 | else if (server->secType == MSKerberos) | ||
| 121 | sprintf(dp, ";sec=mskrb5"); | ||
| 120 | else | 122 | else |
| 121 | goto out; | 123 | goto out; |
| 122 | 124 | ||
diff --git a/fs/cifs/cifs_spnego.h b/fs/cifs/cifs_spnego.h index 05a34b17a1ab..e4041ec4d712 100644 --- a/fs/cifs/cifs_spnego.h +++ b/fs/cifs/cifs_spnego.h | |||
| @@ -23,7 +23,7 @@ | |||
| 23 | #ifndef _CIFS_SPNEGO_H | 23 | #ifndef _CIFS_SPNEGO_H |
| 24 | #define _CIFS_SPNEGO_H | 24 | #define _CIFS_SPNEGO_H |
| 25 | 25 | ||
| 26 | #define CIFS_SPNEGO_UPCALL_VERSION 1 | 26 | #define CIFS_SPNEGO_UPCALL_VERSION 2 |
| 27 | 27 | ||
| 28 | /* | 28 | /* |
| 29 | * The version field should always be set to CIFS_SPNEGO_UPCALL_VERSION. | 29 | * The version field should always be set to CIFS_SPNEGO_UPCALL_VERSION. |
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index 83fd40dc1ef0..bd5f13d38450 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c | |||
| @@ -294,6 +294,7 @@ void calc_lanman_hash(struct cifsSesInfo *ses, char *lnm_session_key) | |||
| 294 | 294 | ||
| 295 | if ((ses->server->secMode & SECMODE_PW_ENCRYPT) == 0) | 295 | if ((ses->server->secMode & SECMODE_PW_ENCRYPT) == 0) |
| 296 | if (extended_security & CIFSSEC_MAY_PLNTXT) { | 296 | if (extended_security & CIFSSEC_MAY_PLNTXT) { |
| 297 | memset(lnm_session_key, 0, CIFS_SESS_KEY_SIZE); | ||
| 297 | memcpy(lnm_session_key, password_with_pad, | 298 | memcpy(lnm_session_key, password_with_pad, |
| 298 | CIFS_ENCPWD_SIZE); | 299 | CIFS_ENCPWD_SIZE); |
| 299 | return; | 300 | return; |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index e8da4ee761b5..25ecbd5b0404 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
| @@ -175,6 +175,8 @@ out_no_root: | |||
| 175 | if (inode) | 175 | if (inode) |
| 176 | iput(inode); | 176 | iput(inode); |
| 177 | 177 | ||
| 178 | cifs_umount(sb, cifs_sb); | ||
| 179 | |||
| 178 | out_mount_failed: | 180 | out_mount_failed: |
| 179 | if (cifs_sb) { | 181 | if (cifs_sb) { |
| 180 | #ifdef CONFIG_CIFS_DFS_UPCALL | 182 | #ifdef CONFIG_CIFS_DFS_UPCALL |
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 7e1cf262effe..8dfd6f24d488 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
| @@ -80,7 +80,8 @@ enum securityEnum { | |||
| 80 | NTLMv2, /* Legacy NTLM auth with NTLMv2 hash */ | 80 | NTLMv2, /* Legacy NTLM auth with NTLMv2 hash */ |
| 81 | RawNTLMSSP, /* NTLMSSP without SPNEGO */ | 81 | RawNTLMSSP, /* NTLMSSP without SPNEGO */ |
| 82 | NTLMSSP, /* NTLMSSP via SPNEGO */ | 82 | NTLMSSP, /* NTLMSSP via SPNEGO */ |
| 83 | Kerberos /* Kerberos via SPNEGO */ | 83 | Kerberos, /* Kerberos via SPNEGO */ |
| 84 | MSKerberos, /* MS Kerberos via SPNEGO */ | ||
| 84 | }; | 85 | }; |
| 85 | 86 | ||
| 86 | enum protocolEnum { | 87 | enum protocolEnum { |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 0711db65afe8..4c13bcdb92a5 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
| @@ -3598,19 +3598,21 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
| 3598 | char ntlm_session_key[CIFS_SESS_KEY_SIZE]; | 3598 | char ntlm_session_key[CIFS_SESS_KEY_SIZE]; |
| 3599 | bool ntlmv2_flag = false; | 3599 | bool ntlmv2_flag = false; |
| 3600 | int first_time = 0; | 3600 | int first_time = 0; |
| 3601 | struct TCP_Server_Info *server = pSesInfo->server; | ||
| 3601 | 3602 | ||
| 3602 | /* what if server changes its buffer size after dropping the session? */ | 3603 | /* what if server changes its buffer size after dropping the session? */ |
| 3603 | if (pSesInfo->server->maxBuf == 0) /* no need to send on reconnect */ { | 3604 | if (server->maxBuf == 0) /* no need to send on reconnect */ { |
| 3604 | rc = CIFSSMBNegotiate(xid, pSesInfo); | 3605 | rc = CIFSSMBNegotiate(xid, pSesInfo); |
| 3605 | if (rc == -EAGAIN) /* retry only once on 1st time connection */ { | 3606 | if (rc == -EAGAIN) { |
| 3607 | /* retry only once on 1st time connection */ | ||
| 3606 | rc = CIFSSMBNegotiate(xid, pSesInfo); | 3608 | rc = CIFSSMBNegotiate(xid, pSesInfo); |
| 3607 | if (rc == -EAGAIN) | 3609 | if (rc == -EAGAIN) |
| 3608 | rc = -EHOSTDOWN; | 3610 | rc = -EHOSTDOWN; |
| 3609 | } | 3611 | } |
| 3610 | if (rc == 0) { | 3612 | if (rc == 0) { |
| 3611 | spin_lock(&GlobalMid_Lock); | 3613 | spin_lock(&GlobalMid_Lock); |
| 3612 | if (pSesInfo->server->tcpStatus != CifsExiting) | 3614 | if (server->tcpStatus != CifsExiting) |
| 3613 | pSesInfo->server->tcpStatus = CifsGood; | 3615 | server->tcpStatus = CifsGood; |
| 3614 | else | 3616 | else |
| 3615 | rc = -EHOSTDOWN; | 3617 | rc = -EHOSTDOWN; |
| 3616 | spin_unlock(&GlobalMid_Lock); | 3618 | spin_unlock(&GlobalMid_Lock); |
| @@ -3623,23 +3625,22 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
| 3623 | goto ss_err_exit; | 3625 | goto ss_err_exit; |
| 3624 | 3626 | ||
| 3625 | pSesInfo->flags = 0; | 3627 | pSesInfo->flags = 0; |
| 3626 | pSesInfo->capabilities = pSesInfo->server->capabilities; | 3628 | pSesInfo->capabilities = server->capabilities; |
| 3627 | if (linuxExtEnabled == 0) | 3629 | if (linuxExtEnabled == 0) |
| 3628 | pSesInfo->capabilities &= (~CAP_UNIX); | 3630 | pSesInfo->capabilities &= (~CAP_UNIX); |
| 3629 | /* pSesInfo->sequence_number = 0;*/ | 3631 | /* pSesInfo->sequence_number = 0;*/ |
| 3630 | cFYI(1, ("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d", | 3632 | cFYI(1, ("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d", |
| 3631 | pSesInfo->server->secMode, | 3633 | server->secMode, server->capabilities, server->timeAdj)); |
| 3632 | pSesInfo->server->capabilities, | 3634 | |
| 3633 | pSesInfo->server->timeAdj)); | ||
| 3634 | if (experimEnabled < 2) | 3635 | if (experimEnabled < 2) |
| 3635 | rc = CIFS_SessSetup(xid, pSesInfo, first_time, nls_info); | 3636 | rc = CIFS_SessSetup(xid, pSesInfo, first_time, nls_info); |
| 3636 | else if (extended_security | 3637 | else if (extended_security |
| 3637 | && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) | 3638 | && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) |
| 3638 | && (pSesInfo->server->secType == NTLMSSP)) { | 3639 | && (server->secType == NTLMSSP)) { |
| 3639 | rc = -EOPNOTSUPP; | 3640 | rc = -EOPNOTSUPP; |
| 3640 | } else if (extended_security | 3641 | } else if (extended_security |
| 3641 | && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) | 3642 | && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) |
| 3642 | && (pSesInfo->server->secType == RawNTLMSSP)) { | 3643 | && (server->secType == RawNTLMSSP)) { |
| 3643 | cFYI(1, ("NTLMSSP sesssetup")); | 3644 | cFYI(1, ("NTLMSSP sesssetup")); |
| 3644 | rc = CIFSNTLMSSPNegotiateSessSetup(xid, pSesInfo, &ntlmv2_flag, | 3645 | rc = CIFSNTLMSSPNegotiateSessSetup(xid, pSesInfo, &ntlmv2_flag, |
| 3645 | nls_info); | 3646 | nls_info); |
| @@ -3668,12 +3669,12 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
| 3668 | 3669 | ||
| 3669 | } else { | 3670 | } else { |
| 3670 | SMBNTencrypt(pSesInfo->password, | 3671 | SMBNTencrypt(pSesInfo->password, |
| 3671 | pSesInfo->server->cryptKey, | 3672 | server->cryptKey, |
| 3672 | ntlm_session_key); | 3673 | ntlm_session_key); |
| 3673 | 3674 | ||
| 3674 | if (first_time) | 3675 | if (first_time) |
| 3675 | cifs_calculate_mac_key( | 3676 | cifs_calculate_mac_key( |
| 3676 | &pSesInfo->server->mac_signing_key, | 3677 | &server->mac_signing_key, |
| 3677 | ntlm_session_key, | 3678 | ntlm_session_key, |
| 3678 | pSesInfo->password); | 3679 | pSesInfo->password); |
| 3679 | } | 3680 | } |
| @@ -3686,13 +3687,13 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
| 3686 | nls_info); | 3687 | nls_info); |
| 3687 | } | 3688 | } |
| 3688 | } else { /* old style NTLM 0.12 session setup */ | 3689 | } else { /* old style NTLM 0.12 session setup */ |
| 3689 | SMBNTencrypt(pSesInfo->password, pSesInfo->server->cryptKey, | 3690 | SMBNTencrypt(pSesInfo->password, server->cryptKey, |
| 3690 | ntlm_session_key); | 3691 | ntlm_session_key); |
| 3691 | 3692 | ||
| 3692 | if (first_time) | 3693 | if (first_time) |
| 3693 | cifs_calculate_mac_key( | 3694 | cifs_calculate_mac_key(&server->mac_signing_key, |
| 3694 | &pSesInfo->server->mac_signing_key, | 3695 | ntlm_session_key, |
| 3695 | ntlm_session_key, pSesInfo->password); | 3696 | pSesInfo->password); |
| 3696 | 3697 | ||
| 3697 | rc = CIFSSessSetup(xid, pSesInfo, ntlm_session_key, nls_info); | 3698 | rc = CIFSSessSetup(xid, pSesInfo, ntlm_session_key, nls_info); |
| 3698 | } | 3699 | } |
diff --git a/fs/cifs/dns_resolve.c b/fs/cifs/dns_resolve.c index f730ef35499e..a2e0673e1b08 100644 --- a/fs/cifs/dns_resolve.c +++ b/fs/cifs/dns_resolve.c | |||
| @@ -47,11 +47,18 @@ static int dns_resolver_instantiate(struct key *key, const void *data, | |||
| 47 | return rc; | 47 | return rc; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | static void | ||
| 51 | dns_resolver_destroy(struct key *key) | ||
| 52 | { | ||
| 53 | kfree(key->payload.data); | ||
| 54 | } | ||
| 55 | |||
| 50 | struct key_type key_type_dns_resolver = { | 56 | struct key_type key_type_dns_resolver = { |
| 51 | .name = "dns_resolver", | 57 | .name = "dns_resolver", |
| 52 | .def_datalen = sizeof(struct in_addr), | 58 | .def_datalen = sizeof(struct in_addr), |
| 53 | .describe = user_describe, | 59 | .describe = user_describe, |
| 54 | .instantiate = dns_resolver_instantiate, | 60 | .instantiate = dns_resolver_instantiate, |
| 61 | .destroy = dns_resolver_destroy, | ||
| 55 | .match = user_match, | 62 | .match = user_match, |
| 56 | }; | 63 | }; |
| 57 | 64 | ||
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index ff14d14903a0..cbefe1f1f9fe 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
| @@ -833,6 +833,10 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, | |||
| 833 | return -EBADF; | 833 | return -EBADF; |
| 834 | open_file = (struct cifsFileInfo *) file->private_data; | 834 | open_file = (struct cifsFileInfo *) file->private_data; |
| 835 | 835 | ||
| 836 | rc = generic_write_checks(file, poffset, &write_size, 0); | ||
| 837 | if (rc) | ||
| 838 | return rc; | ||
| 839 | |||
| 836 | xid = GetXid(); | 840 | xid = GetXid(); |
| 837 | 841 | ||
| 838 | if (*poffset > file->f_path.dentry->d_inode->i_size) | 842 | if (*poffset > file->f_path.dentry->d_inode->i_size) |
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 28a22092d450..9c548f110102 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
| @@ -546,7 +546,8 @@ int cifs_get_inode_info(struct inode **pinode, | |||
| 546 | if ((inode->i_mode & S_IWUGO) == 0 && | 546 | if ((inode->i_mode & S_IWUGO) == 0 && |
| 547 | (attr & ATTR_READONLY) == 0) | 547 | (attr & ATTR_READONLY) == 0) |
| 548 | inode->i_mode |= (S_IWUGO & default_mode); | 548 | inode->i_mode |= (S_IWUGO & default_mode); |
| 549 | inode->i_mode &= ~S_IFMT; | 549 | |
| 550 | inode->i_mode &= ~S_IFMT; | ||
| 550 | } | 551 | } |
| 551 | /* clear write bits if ATTR_READONLY is set */ | 552 | /* clear write bits if ATTR_READONLY is set */ |
| 552 | if (attr & ATTR_READONLY) | 553 | if (attr & ATTR_READONLY) |
| @@ -649,6 +650,7 @@ struct inode *cifs_iget(struct super_block *sb, unsigned long ino) | |||
| 649 | inode->i_fop = &simple_dir_operations; | 650 | inode->i_fop = &simple_dir_operations; |
| 650 | inode->i_uid = cifs_sb->mnt_uid; | 651 | inode->i_uid = cifs_sb->mnt_uid; |
| 651 | inode->i_gid = cifs_sb->mnt_gid; | 652 | inode->i_gid = cifs_sb->mnt_gid; |
| 653 | } else if (rc) { | ||
| 652 | _FreeXid(xid); | 654 | _FreeXid(xid); |
| 653 | iget_failed(inode); | 655 | iget_failed(inode); |
| 654 | return ERR_PTR(rc); | 656 | return ERR_PTR(rc); |
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index ed150efbe27c..252fdc0567f1 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c | |||
| @@ -409,6 +409,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
| 409 | #ifdef CONFIG_CIFS_WEAK_PW_HASH | 409 | #ifdef CONFIG_CIFS_WEAK_PW_HASH |
| 410 | char lnm_session_key[CIFS_SESS_KEY_SIZE]; | 410 | char lnm_session_key[CIFS_SESS_KEY_SIZE]; |
| 411 | 411 | ||
| 412 | pSMB->req.hdr.Flags2 &= ~SMBFLG2_UNICODE; | ||
| 413 | |||
| 412 | /* no capabilities flags in old lanman negotiation */ | 414 | /* no capabilities flags in old lanman negotiation */ |
| 413 | 415 | ||
| 414 | pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE); | 416 | pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE); |
| @@ -505,7 +507,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
| 505 | unicode_ssetup_strings(&bcc_ptr, ses, nls_cp); | 507 | unicode_ssetup_strings(&bcc_ptr, ses, nls_cp); |
| 506 | } else | 508 | } else |
| 507 | ascii_ssetup_strings(&bcc_ptr, ses, nls_cp); | 509 | ascii_ssetup_strings(&bcc_ptr, ses, nls_cp); |
| 508 | } else if (type == Kerberos) { | 510 | } else if (type == Kerberos || type == MSKerberos) { |
| 509 | #ifdef CONFIG_CIFS_UPCALL | 511 | #ifdef CONFIG_CIFS_UPCALL |
| 510 | struct cifs_spnego_msg *msg; | 512 | struct cifs_spnego_msg *msg; |
| 511 | spnego_key = cifs_get_spnego_key(ses); | 513 | spnego_key = cifs_get_spnego_key(ses); |
| @@ -516,6 +518,15 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
| 516 | } | 518 | } |
| 517 | 519 | ||
| 518 | msg = spnego_key->payload.data; | 520 | msg = spnego_key->payload.data; |
| 521 | /* check version field to make sure that cifs.upcall is | ||
| 522 | sending us a response in an expected form */ | ||
| 523 | if (msg->version != CIFS_SPNEGO_UPCALL_VERSION) { | ||
| 524 | cERROR(1, ("incorrect version of cifs.upcall (expected" | ||
| 525 | " %d but got %d)", | ||
| 526 | CIFS_SPNEGO_UPCALL_VERSION, msg->version)); | ||
| 527 | rc = -EKEYREJECTED; | ||
| 528 | goto ssetup_exit; | ||
| 529 | } | ||
| 519 | /* bail out if key is too long */ | 530 | /* bail out if key is too long */ |
| 520 | if (msg->sesskey_len > | 531 | if (msg->sesskey_len > |
| 521 | sizeof(ses->server->mac_signing_key.data.krb5)) { | 532 | sizeof(ses->server->mac_signing_key.data.krb5)) { |
diff --git a/fs/compat.c b/fs/compat.c index c9d1472e65c5..075d0509970d 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
| @@ -792,8 +792,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen, | |||
| 792 | if (buf->result) | 792 | if (buf->result) |
| 793 | return -EINVAL; | 793 | return -EINVAL; |
| 794 | d_ino = ino; | 794 | d_ino = ino; |
| 795 | if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) | 795 | if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) { |
| 796 | buf->result = -EOVERFLOW; | ||
| 796 | return -EOVERFLOW; | 797 | return -EOVERFLOW; |
| 798 | } | ||
| 797 | buf->result++; | 799 | buf->result++; |
| 798 | dirent = buf->dirent; | 800 | dirent = buf->dirent; |
| 799 | if (!access_ok(VERIFY_WRITE, dirent, | 801 | if (!access_ok(VERIFY_WRITE, dirent, |
| @@ -862,8 +864,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen, | |||
| 862 | if (reclen > buf->count) | 864 | if (reclen > buf->count) |
| 863 | return -EINVAL; | 865 | return -EINVAL; |
| 864 | d_ino = ino; | 866 | d_ino = ino; |
| 865 | if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) | 867 | if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) { |
| 868 | buf->error = -EOVERFLOW; | ||
| 866 | return -EOVERFLOW; | 869 | return -EOVERFLOW; |
| 870 | } | ||
| 867 | dirent = buf->previous; | 871 | dirent = buf->previous; |
| 868 | if (dirent) { | 872 | if (dirent) { |
| 869 | if (__put_user(offset, &dirent->d_off)) | 873 | if (__put_user(offset, &dirent->d_off)) |
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 7a8db78a91d2..8e93341f3e82 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
| @@ -1311,16 +1311,18 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
| 1311 | * Ensure that no racing symlink() will make detach_prep() fail while | 1311 | * Ensure that no racing symlink() will make detach_prep() fail while |
| 1312 | * the new link is temporarily attached | 1312 | * the new link is temporarily attached |
| 1313 | */ | 1313 | */ |
| 1314 | mutex_lock(&configfs_symlink_mutex); | ||
| 1315 | spin_lock(&configfs_dirent_lock); | ||
| 1316 | do { | 1314 | do { |
| 1317 | struct mutex *wait_mutex; | 1315 | struct mutex *wait_mutex; |
| 1318 | 1316 | ||
| 1317 | mutex_lock(&configfs_symlink_mutex); | ||
| 1318 | spin_lock(&configfs_dirent_lock); | ||
| 1319 | ret = configfs_detach_prep(dentry, &wait_mutex); | 1319 | ret = configfs_detach_prep(dentry, &wait_mutex); |
| 1320 | if (ret) { | 1320 | if (ret) |
| 1321 | configfs_detach_rollback(dentry); | 1321 | configfs_detach_rollback(dentry); |
| 1322 | spin_unlock(&configfs_dirent_lock); | 1322 | spin_unlock(&configfs_dirent_lock); |
| 1323 | mutex_unlock(&configfs_symlink_mutex); | 1323 | mutex_unlock(&configfs_symlink_mutex); |
| 1324 | |||
| 1325 | if (ret) { | ||
| 1324 | if (ret != -EAGAIN) { | 1326 | if (ret != -EAGAIN) { |
| 1325 | config_item_put(parent_item); | 1327 | config_item_put(parent_item); |
| 1326 | return ret; | 1328 | return ret; |
| @@ -1329,13 +1331,8 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
| 1329 | /* Wait until the racing operation terminates */ | 1331 | /* Wait until the racing operation terminates */ |
| 1330 | mutex_lock(wait_mutex); | 1332 | mutex_lock(wait_mutex); |
| 1331 | mutex_unlock(wait_mutex); | 1333 | mutex_unlock(wait_mutex); |
| 1332 | |||
| 1333 | mutex_lock(&configfs_symlink_mutex); | ||
| 1334 | spin_lock(&configfs_dirent_lock); | ||
| 1335 | } | 1334 | } |
| 1336 | } while (ret == -EAGAIN); | 1335 | } while (ret == -EAGAIN); |
| 1337 | spin_unlock(&configfs_dirent_lock); | ||
| 1338 | mutex_unlock(&configfs_symlink_mutex); | ||
| 1339 | 1336 | ||
| 1340 | /* Get a working ref for the duration of this function */ | 1337 | /* Get a working ref for the duration of this function */ |
| 1341 | item = configfs_get_config_item(dentry); | 1338 | item = configfs_get_config_item(dentry); |
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index 0c3b618c15b3..f40423eb1a14 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c | |||
| @@ -43,58 +43,13 @@ static DEFINE_MUTEX(read_mutex); | |||
| 43 | static int cramfs_iget5_test(struct inode *inode, void *opaque) | 43 | static int cramfs_iget5_test(struct inode *inode, void *opaque) |
| 44 | { | 44 | { |
| 45 | struct cramfs_inode *cramfs_inode = opaque; | 45 | struct cramfs_inode *cramfs_inode = opaque; |
| 46 | 46 | return inode->i_ino == CRAMINO(cramfs_inode) && inode->i_ino != 1; | |
| 47 | if (inode->i_ino != CRAMINO(cramfs_inode)) | ||
| 48 | return 0; /* does not match */ | ||
| 49 | |||
| 50 | if (inode->i_ino != 1) | ||
| 51 | return 1; | ||
| 52 | |||
| 53 | /* all empty directories, char, block, pipe, and sock, share inode #1 */ | ||
| 54 | |||
| 55 | if ((inode->i_mode != cramfs_inode->mode) || | ||
| 56 | (inode->i_gid != cramfs_inode->gid) || | ||
| 57 | (inode->i_uid != cramfs_inode->uid)) | ||
| 58 | return 0; /* does not match */ | ||
| 59 | |||
| 60 | if ((S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) && | ||
| 61 | (inode->i_rdev != old_decode_dev(cramfs_inode->size))) | ||
| 62 | return 0; /* does not match */ | ||
| 63 | |||
| 64 | return 1; /* matches */ | ||
| 65 | } | 47 | } |
| 66 | 48 | ||
| 67 | static int cramfs_iget5_set(struct inode *inode, void *opaque) | 49 | static int cramfs_iget5_set(struct inode *inode, void *opaque) |
| 68 | { | 50 | { |
| 69 | static struct timespec zerotime; | ||
| 70 | struct cramfs_inode *cramfs_inode = opaque; | 51 | struct cramfs_inode *cramfs_inode = opaque; |
| 71 | inode->i_mode = cramfs_inode->mode; | ||
| 72 | inode->i_uid = cramfs_inode->uid; | ||
| 73 | inode->i_size = cramfs_inode->size; | ||
| 74 | inode->i_blocks = (cramfs_inode->size - 1) / 512 + 1; | ||
| 75 | inode->i_gid = cramfs_inode->gid; | ||
| 76 | /* Struct copy intentional */ | ||
| 77 | inode->i_mtime = inode->i_atime = inode->i_ctime = zerotime; | ||
| 78 | inode->i_ino = CRAMINO(cramfs_inode); | 52 | inode->i_ino = CRAMINO(cramfs_inode); |
| 79 | /* inode->i_nlink is left 1 - arguably wrong for directories, | ||
| 80 | but it's the best we can do without reading the directory | ||
| 81 | contents. 1 yields the right result in GNU find, even | ||
| 82 | without -noleaf option. */ | ||
| 83 | if (S_ISREG(inode->i_mode)) { | ||
| 84 | inode->i_fop = &generic_ro_fops; | ||
| 85 | inode->i_data.a_ops = &cramfs_aops; | ||
| 86 | } else if (S_ISDIR(inode->i_mode)) { | ||
| 87 | inode->i_op = &cramfs_dir_inode_operations; | ||
| 88 | inode->i_fop = &cramfs_directory_operations; | ||
| 89 | } else if (S_ISLNK(inode->i_mode)) { | ||
| 90 | inode->i_op = &page_symlink_inode_operations; | ||
| 91 | inode->i_data.a_ops = &cramfs_aops; | ||
| 92 | } else { | ||
| 93 | inode->i_size = 0; | ||
| 94 | inode->i_blocks = 0; | ||
| 95 | init_special_inode(inode, inode->i_mode, | ||
| 96 | old_decode_dev(cramfs_inode->size)); | ||
| 97 | } | ||
| 98 | return 0; | 53 | return 0; |
| 99 | } | 54 | } |
| 100 | 55 | ||
| @@ -104,12 +59,48 @@ static struct inode *get_cramfs_inode(struct super_block *sb, | |||
| 104 | struct inode *inode = iget5_locked(sb, CRAMINO(cramfs_inode), | 59 | struct inode *inode = iget5_locked(sb, CRAMINO(cramfs_inode), |
| 105 | cramfs_iget5_test, cramfs_iget5_set, | 60 | cramfs_iget5_test, cramfs_iget5_set, |
| 106 | cramfs_inode); | 61 | cramfs_inode); |
| 62 | static struct timespec zerotime; | ||
| 63 | |||
| 107 | if (inode && (inode->i_state & I_NEW)) { | 64 | if (inode && (inode->i_state & I_NEW)) { |
| 65 | inode->i_mode = cramfs_inode->mode; | ||
| 66 | inode->i_uid = cramfs_inode->uid; | ||
| 67 | inode->i_size = cramfs_inode->size; | ||
| 68 | inode->i_blocks = (cramfs_inode->size - 1) / 512 + 1; | ||
| 69 | inode->i_gid = cramfs_inode->gid; | ||
| 70 | /* Struct copy intentional */ | ||
| 71 | inode->i_mtime = inode->i_atime = inode->i_ctime = zerotime; | ||
| 72 | /* inode->i_nlink is left 1 - arguably wrong for directories, | ||
| 73 | but it's the best we can do without reading the directory | ||
| 74 | contents. 1 yields the right result in GNU find, even | ||
| 75 | without -noleaf option. */ | ||
| 76 | if (S_ISREG(inode->i_mode)) { | ||
| 77 | inode->i_fop = &generic_ro_fops; | ||
| 78 | inode->i_data.a_ops = &cramfs_aops; | ||
| 79 | } else if (S_ISDIR(inode->i_mode)) { | ||
| 80 | inode->i_op = &cramfs_dir_inode_operations; | ||
| 81 | inode->i_fop = &cramfs_directory_operations; | ||
| 82 | } else if (S_ISLNK(inode->i_mode)) { | ||
| 83 | inode->i_op = &page_symlink_inode_operations; | ||
| 84 | inode->i_data.a_ops = &cramfs_aops; | ||
| 85 | } else { | ||
| 86 | inode->i_size = 0; | ||
| 87 | inode->i_blocks = 0; | ||
| 88 | init_special_inode(inode, inode->i_mode, | ||
| 89 | old_decode_dev(cramfs_inode->size)); | ||
| 90 | } | ||
| 108 | unlock_new_inode(inode); | 91 | unlock_new_inode(inode); |
| 109 | } | 92 | } |
| 110 | return inode; | 93 | return inode; |
| 111 | } | 94 | } |
| 112 | 95 | ||
| 96 | static void cramfs_drop_inode(struct inode *inode) | ||
| 97 | { | ||
| 98 | if (inode->i_ino == 1) | ||
| 99 | generic_delete_inode(inode); | ||
| 100 | else | ||
| 101 | generic_drop_inode(inode); | ||
| 102 | } | ||
| 103 | |||
| 113 | /* | 104 | /* |
| 114 | * We have our own block cache: don't fill up the buffer cache | 105 | * We have our own block cache: don't fill up the buffer cache |
| 115 | * with the rom-image, because the way the filesystem is set | 106 | * with the rom-image, because the way the filesystem is set |
| @@ -534,6 +525,7 @@ static const struct super_operations cramfs_ops = { | |||
| 534 | .put_super = cramfs_put_super, | 525 | .put_super = cramfs_put_super, |
| 535 | .remount_fs = cramfs_remount, | 526 | .remount_fs = cramfs_remount, |
| 536 | .statfs = cramfs_statfs, | 527 | .statfs = cramfs_statfs, |
| 528 | .drop_inode = cramfs_drop_inode, | ||
| 537 | }; | 529 | }; |
| 538 | 530 | ||
| 539 | static int cramfs_get_sb(struct file_system_type *fs_type, | 531 | static int cramfs_get_sb(struct file_system_type *fs_type, |
diff --git a/fs/dcache.c b/fs/dcache.c index 101663d15e9f..80e93956aced 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
| @@ -1236,7 +1236,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) | |||
| 1236 | * If no entry exists with the exact case name, allocate new dentry with | 1236 | * If no entry exists with the exact case name, allocate new dentry with |
| 1237 | * the exact case, and return the spliced entry. | 1237 | * the exact case, and return the spliced entry. |
| 1238 | */ | 1238 | */ |
| 1239 | struct dentry *d_add_ci(struct inode *inode, struct dentry *dentry, | 1239 | struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, |
| 1240 | struct qstr *name) | 1240 | struct qstr *name) |
| 1241 | { | 1241 | { |
| 1242 | int error; | 1242 | int error; |
diff --git a/fs/efs/namei.c b/fs/efs/namei.c index 3a404e7fad53..291abb11e20e 100644 --- a/fs/efs/namei.c +++ b/fs/efs/namei.c | |||
| @@ -74,8 +74,7 @@ struct dentry *efs_lookup(struct inode *dir, struct dentry *dentry, struct namei | |||
| 74 | } | 74 | } |
| 75 | unlock_kernel(); | 75 | unlock_kernel(); |
| 76 | 76 | ||
| 77 | d_add(dentry, inode); | 77 | return d_splice_alias(inode, dentry); |
| 78 | return NULL; | ||
| 79 | } | 78 | } |
| 80 | 79 | ||
| 81 | static struct inode *efs_nfs_get_inode(struct super_block *sb, u64 ino, | 80 | static struct inode *efs_nfs_get_inode(struct super_block *sb, u64 ino, |
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 1ae5004e93fc..e9fa960ba6da 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
| @@ -1626,6 +1626,9 @@ ext4_fsblk_t ext4_has_free_blocks(struct ext4_sb_info *sbi, | |||
| 1626 | free_blocks = | 1626 | free_blocks = |
| 1627 | percpu_counter_sum_and_set(&sbi->s_freeblocks_counter); | 1627 | percpu_counter_sum_and_set(&sbi->s_freeblocks_counter); |
| 1628 | #endif | 1628 | #endif |
| 1629 | if (free_blocks <= root_blocks) | ||
| 1630 | /* we don't have free space */ | ||
| 1631 | return 0; | ||
| 1629 | if (free_blocks - root_blocks < nblocks) | 1632 | if (free_blocks - root_blocks < nblocks) |
| 1630 | return free_blocks - root_blocks; | 1633 | return free_blocks - root_blocks; |
| 1631 | return nblocks; | 1634 | return nblocks; |
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c index d3d23d73c08b..ec8e33b45219 100644 --- a/fs/ext4/dir.c +++ b/fs/ext4/dir.c | |||
| @@ -411,7 +411,7 @@ static int call_filldir(struct file * filp, void * dirent, | |||
| 411 | get_dtype(sb, fname->file_type)); | 411 | get_dtype(sb, fname->file_type)); |
| 412 | if (error) { | 412 | if (error) { |
| 413 | filp->f_pos = curr_pos; | 413 | filp->f_pos = curr_pos; |
| 414 | info->extra_fname = fname->next; | 414 | info->extra_fname = fname; |
| 415 | return error; | 415 | return error; |
| 416 | } | 416 | } |
| 417 | fname = fname->next; | 417 | fname = fname->next; |
| @@ -450,11 +450,21 @@ static int ext4_dx_readdir(struct file * filp, | |||
| 450 | * If there are any leftover names on the hash collision | 450 | * If there are any leftover names on the hash collision |
| 451 | * chain, return them first. | 451 | * chain, return them first. |
| 452 | */ | 452 | */ |
| 453 | if (info->extra_fname && | 453 | if (info->extra_fname) { |
| 454 | call_filldir(filp, dirent, filldir, info->extra_fname)) | 454 | if (call_filldir(filp, dirent, filldir, info->extra_fname)) |
| 455 | goto finished; | 455 | goto finished; |
| 456 | 456 | ||
| 457 | if (!info->curr_node) | 457 | info->extra_fname = NULL; |
| 458 | info->curr_node = rb_next(info->curr_node); | ||
| 459 | if (!info->curr_node) { | ||
| 460 | if (info->next_hash == ~0) { | ||
| 461 | filp->f_pos = EXT4_HTREE_EOF; | ||
| 462 | goto finished; | ||
| 463 | } | ||
| 464 | info->curr_hash = info->next_hash; | ||
| 465 | info->curr_minor_hash = 0; | ||
| 466 | } | ||
| 467 | } else if (!info->curr_node) | ||
| 458 | info->curr_node = rb_first(&info->root); | 468 | info->curr_node = rb_first(&info->root); |
| 459 | 469 | ||
| 460 | while (1) { | 470 | while (1) { |
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 6c7924d9e358..295003241d3d 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
| @@ -1072,6 +1072,8 @@ extern void ext4_set_inode_flags(struct inode *); | |||
| 1072 | extern void ext4_get_inode_flags(struct ext4_inode_info *); | 1072 | extern void ext4_get_inode_flags(struct ext4_inode_info *); |
| 1073 | extern void ext4_set_aops(struct inode *inode); | 1073 | extern void ext4_set_aops(struct inode *inode); |
| 1074 | extern int ext4_writepage_trans_blocks(struct inode *); | 1074 | extern int ext4_writepage_trans_blocks(struct inode *); |
| 1075 | extern int ext4_meta_trans_blocks(struct inode *, int nrblocks, int idxblocks); | ||
| 1076 | extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks); | ||
| 1075 | extern int ext4_block_truncate_page(handle_t *handle, | 1077 | extern int ext4_block_truncate_page(handle_t *handle, |
| 1076 | struct address_space *mapping, loff_t from); | 1078 | struct address_space *mapping, loff_t from); |
| 1077 | extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct page *page); | 1079 | extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct page *page); |
| @@ -1227,6 +1229,8 @@ extern const struct inode_operations ext4_fast_symlink_inode_operations; | |||
| 1227 | /* extents.c */ | 1229 | /* extents.c */ |
| 1228 | extern int ext4_ext_tree_init(handle_t *handle, struct inode *); | 1230 | extern int ext4_ext_tree_init(handle_t *handle, struct inode *); |
| 1229 | extern int ext4_ext_writepage_trans_blocks(struct inode *, int); | 1231 | extern int ext4_ext_writepage_trans_blocks(struct inode *, int); |
| 1232 | extern int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks, | ||
| 1233 | int chunk); | ||
| 1230 | extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, | 1234 | extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, |
| 1231 | ext4_lblk_t iblock, | 1235 | ext4_lblk_t iblock, |
| 1232 | unsigned long max_blocks, struct buffer_head *bh_result, | 1236 | unsigned long max_blocks, struct buffer_head *bh_result, |
diff --git a/fs/ext4/ext4_extents.h b/fs/ext4/ext4_extents.h index 6c166c0a54b7..d33dc56d6986 100644 --- a/fs/ext4/ext4_extents.h +++ b/fs/ext4/ext4_extents.h | |||
| @@ -216,7 +216,9 @@ extern int ext4_ext_calc_metadata_amount(struct inode *inode, int blocks); | |||
| 216 | extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *); | 216 | extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *); |
| 217 | extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t); | 217 | extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t); |
| 218 | extern int ext4_extent_tree_init(handle_t *, struct inode *); | 218 | extern int ext4_extent_tree_init(handle_t *, struct inode *); |
| 219 | extern int ext4_ext_calc_credits_for_insert(struct inode *, struct ext4_ext_path *); | 219 | extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode, |
| 220 | int num, | ||
| 221 | struct ext4_ext_path *path); | ||
| 220 | extern int ext4_ext_try_to_merge(struct inode *inode, | 222 | extern int ext4_ext_try_to_merge(struct inode *inode, |
| 221 | struct ext4_ext_path *path, | 223 | struct ext4_ext_path *path, |
| 222 | struct ext4_extent *); | 224 | struct ext4_extent *); |
diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h index eb8bc3afe6e9..b455c685a98b 100644 --- a/fs/ext4/ext4_jbd2.h +++ b/fs/ext4/ext4_jbd2.h | |||
| @@ -51,6 +51,14 @@ | |||
| 51 | EXT4_XATTR_TRANS_BLOCKS - 2 + \ | 51 | EXT4_XATTR_TRANS_BLOCKS - 2 + \ |
| 52 | 2*EXT4_QUOTA_TRANS_BLOCKS(sb)) | 52 | 2*EXT4_QUOTA_TRANS_BLOCKS(sb)) |
| 53 | 53 | ||
| 54 | /* | ||
| 55 | * Define the number of metadata blocks we need to account to modify data. | ||
| 56 | * | ||
| 57 | * This include super block, inode block, quota blocks and xattr blocks | ||
| 58 | */ | ||
| 59 | #define EXT4_META_TRANS_BLOCKS(sb) (EXT4_XATTR_TRANS_BLOCKS + \ | ||
| 60 | 2*EXT4_QUOTA_TRANS_BLOCKS(sb)) | ||
| 61 | |||
| 54 | /* Delete operations potentially hit one directory's namespace plus an | 62 | /* Delete operations potentially hit one directory's namespace plus an |
| 55 | * entire inode, plus arbitrary amounts of bitmap/indirection data. Be | 63 | * entire inode, plus arbitrary amounts of bitmap/indirection data. Be |
| 56 | * generous. We can grow the delete transaction later if necessary. */ | 64 | * generous. We can grow the delete transaction later if necessary. */ |
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 612c3d2c3824..b24d3c53f20c 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
| @@ -1747,54 +1747,61 @@ static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode, | |||
| 1747 | } | 1747 | } |
| 1748 | 1748 | ||
| 1749 | /* | 1749 | /* |
| 1750 | * ext4_ext_calc_credits_for_insert: | 1750 | * ext4_ext_calc_credits_for_single_extent: |
| 1751 | * This routine returns max. credits that the extent tree can consume. | 1751 | * This routine returns max. credits that needed to insert an extent |
| 1752 | * It should be OK for low-performance paths like ->writepage() | 1752 | * to the extent tree. |
| 1753 | * To allow many writing processes to fit into a single transaction, | 1753 | * When pass the actual path, the caller should calculate credits |
| 1754 | * the caller should calculate credits under i_data_sem and | 1754 | * under i_data_sem. |
| 1755 | * pass the actual path. | ||
| 1756 | */ | 1755 | */ |
| 1757 | int ext4_ext_calc_credits_for_insert(struct inode *inode, | 1756 | int ext4_ext_calc_credits_for_single_extent(struct inode *inode, int nrblocks, |
| 1758 | struct ext4_ext_path *path) | 1757 | struct ext4_ext_path *path) |
| 1759 | { | 1758 | { |
| 1760 | int depth, needed; | ||
| 1761 | |||
| 1762 | if (path) { | 1759 | if (path) { |
| 1760 | int depth = ext_depth(inode); | ||
| 1761 | int ret = 0; | ||
| 1762 | |||
| 1763 | /* probably there is space in leaf? */ | 1763 | /* probably there is space in leaf? */ |
| 1764 | depth = ext_depth(inode); | ||
| 1765 | if (le16_to_cpu(path[depth].p_hdr->eh_entries) | 1764 | if (le16_to_cpu(path[depth].p_hdr->eh_entries) |
| 1766 | < le16_to_cpu(path[depth].p_hdr->eh_max)) | 1765 | < le16_to_cpu(path[depth].p_hdr->eh_max)) { |
| 1767 | return 1; | ||
| 1768 | } | ||
| 1769 | 1766 | ||
| 1770 | /* | 1767 | /* |
| 1771 | * given 32-bit logical block (4294967296 blocks), max. tree | 1768 | * There are some space in the leaf tree, no |
| 1772 | * can be 4 levels in depth -- 4 * 340^4 == 53453440000. | 1769 | * need to account for leaf block credit |
| 1773 | * Let's also add one more level for imbalance. | 1770 | * |
| 1774 | */ | 1771 | * bitmaps and block group descriptor blocks |
| 1775 | depth = 5; | 1772 | * and other metadat blocks still need to be |
| 1776 | 1773 | * accounted. | |
| 1777 | /* allocation of new data block(s) */ | 1774 | */ |
| 1778 | needed = 2; | 1775 | /* 1 bitmap, 1 block group descriptor */ |
| 1776 | ret = 2 + EXT4_META_TRANS_BLOCKS(inode->i_sb); | ||
| 1777 | } | ||
| 1778 | } | ||
| 1779 | 1779 | ||
| 1780 | /* | 1780 | return ext4_chunk_trans_blocks(inode, nrblocks); |
| 1781 | * tree can be full, so it would need to grow in depth: | 1781 | } |
| 1782 | * we need one credit to modify old root, credits for | ||
| 1783 | * new root will be added in split accounting | ||
| 1784 | */ | ||
| 1785 | needed += 1; | ||
| 1786 | 1782 | ||
| 1787 | /* | 1783 | /* |
| 1788 | * Index split can happen, we would need: | 1784 | * How many index/leaf blocks need to change/allocate to modify nrblocks? |
| 1789 | * allocate intermediate indexes (bitmap + group) | 1785 | * |
| 1790 | * + change two blocks at each level, but root (already included) | 1786 | * if nrblocks are fit in a single extent (chunk flag is 1), then |
| 1791 | */ | 1787 | * in the worse case, each tree level index/leaf need to be changed |
| 1792 | needed += (depth * 2) + (depth * 2); | 1788 | * if the tree split due to insert a new extent, then the old tree |
| 1789 | * index/leaf need to be updated too | ||
| 1790 | * | ||
| 1791 | * If the nrblocks are discontiguous, they could cause | ||
| 1792 | * the whole tree split more than once, but this is really rare. | ||
| 1793 | */ | ||
| 1794 | int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks, int chunk) | ||
| 1795 | { | ||
| 1796 | int index; | ||
| 1797 | int depth = ext_depth(inode); | ||
| 1793 | 1798 | ||
| 1794 | /* any allocation modifies superblock */ | 1799 | if (chunk) |
| 1795 | needed += 1; | 1800 | index = depth * 2; |
| 1801 | else | ||
| 1802 | index = depth * 3; | ||
| 1796 | 1803 | ||
| 1797 | return needed; | 1804 | return index; |
| 1798 | } | 1805 | } |
| 1799 | 1806 | ||
| 1800 | static int ext4_remove_blocks(handle_t *handle, struct inode *inode, | 1807 | static int ext4_remove_blocks(handle_t *handle, struct inode *inode, |
| @@ -1921,9 +1928,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode, | |||
| 1921 | correct_index = 1; | 1928 | correct_index = 1; |
| 1922 | credits += (ext_depth(inode)) + 1; | 1929 | credits += (ext_depth(inode)) + 1; |
| 1923 | } | 1930 | } |
| 1924 | #ifdef CONFIG_QUOTA | ||
| 1925 | credits += 2 * EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb); | 1931 | credits += 2 * EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb); |
| 1926 | #endif | ||
| 1927 | 1932 | ||
| 1928 | err = ext4_ext_journal_restart(handle, credits); | 1933 | err = ext4_ext_journal_restart(handle, credits); |
| 1929 | if (err) | 1934 | if (err) |
| @@ -2805,7 +2810,7 @@ void ext4_ext_truncate(struct inode *inode) | |||
| 2805 | /* | 2810 | /* |
| 2806 | * probably first extent we're gonna free will be last in block | 2811 | * probably first extent we're gonna free will be last in block |
| 2807 | */ | 2812 | */ |
| 2808 | err = ext4_writepage_trans_blocks(inode) + 3; | 2813 | err = ext4_writepage_trans_blocks(inode); |
| 2809 | handle = ext4_journal_start(inode, err); | 2814 | handle = ext4_journal_start(inode, err); |
| 2810 | if (IS_ERR(handle)) | 2815 | if (IS_ERR(handle)) |
| 2811 | return; | 2816 | return; |
| @@ -2819,7 +2824,7 @@ void ext4_ext_truncate(struct inode *inode) | |||
| 2819 | down_write(&EXT4_I(inode)->i_data_sem); | 2824 | down_write(&EXT4_I(inode)->i_data_sem); |
| 2820 | ext4_ext_invalidate_cache(inode); | 2825 | ext4_ext_invalidate_cache(inode); |
| 2821 | 2826 | ||
| 2822 | ext4_mb_discard_inode_preallocations(inode); | 2827 | ext4_discard_reservation(inode); |
| 2823 | 2828 | ||
| 2824 | /* | 2829 | /* |
| 2825 | * TODO: optimization is possible here. | 2830 | * TODO: optimization is possible here. |
| @@ -2858,27 +2863,6 @@ out_stop: | |||
| 2858 | ext4_journal_stop(handle); | 2863 | ext4_journal_stop(handle); |
| 2859 | } | 2864 | } |
| 2860 | 2865 | ||
| 2861 | /* | ||
| 2862 | * ext4_ext_writepage_trans_blocks: | ||
| 2863 | * calculate max number of blocks we could modify | ||
| 2864 | * in order to allocate new block for an inode | ||
| 2865 | */ | ||
| 2866 | int ext4_ext_writepage_trans_blocks(struct inode *inode, int num) | ||
| 2867 | { | ||
| 2868 | int needed; | ||
| 2869 | |||
| 2870 | needed = ext4_ext_calc_credits_for_insert(inode, NULL); | ||
| 2871 | |||
| 2872 | /* caller wants to allocate num blocks, but note it includes sb */ | ||
| 2873 | needed = needed * num - (num - 1); | ||
| 2874 | |||
| 2875 | #ifdef CONFIG_QUOTA | ||
| 2876 | needed += 2 * EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb); | ||
| 2877 | #endif | ||
| 2878 | |||
| 2879 | return needed; | ||
| 2880 | } | ||
| 2881 | |||
| 2882 | static void ext4_falloc_update_inode(struct inode *inode, | 2866 | static void ext4_falloc_update_inode(struct inode *inode, |
| 2883 | int mode, loff_t new_size, int update_ctime) | 2867 | int mode, loff_t new_size, int update_ctime) |
| 2884 | { | 2868 | { |
| @@ -2939,10 +2923,9 @@ long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len) | |||
| 2939 | max_blocks = (EXT4_BLOCK_ALIGN(len + offset, blkbits) >> blkbits) | 2923 | max_blocks = (EXT4_BLOCK_ALIGN(len + offset, blkbits) >> blkbits) |
| 2940 | - block; | 2924 | - block; |
| 2941 | /* | 2925 | /* |
| 2942 | * credits to insert 1 extent into extent tree + buffers to be able to | 2926 | * credits to insert 1 extent into extent tree |
| 2943 | * modify 1 super block, 1 block bitmap and 1 group descriptor. | ||
| 2944 | */ | 2927 | */ |
| 2945 | credits = EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + 3; | 2928 | credits = ext4_chunk_trans_blocks(inode, max_blocks); |
| 2946 | mutex_lock(&inode->i_mutex); | 2929 | mutex_lock(&inode->i_mutex); |
| 2947 | retry: | 2930 | retry: |
| 2948 | while (ret >= 0 && ret < max_blocks) { | 2931 | while (ret >= 0 && ret < max_blocks) { |
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 655e760212b8..f344834bbf58 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
| @@ -351,7 +351,7 @@ find_close_to_parent: | |||
| 351 | goto found_flexbg; | 351 | goto found_flexbg; |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | if (best_flex < 0 || | 354 | if (flex_group[best_flex].free_inodes == 0 || |
| 355 | (flex_group[i].free_blocks > | 355 | (flex_group[i].free_blocks > |
| 356 | flex_group[best_flex].free_blocks && | 356 | flex_group[best_flex].free_blocks && |
| 357 | flex_group[i].free_inodes)) | 357 | flex_group[i].free_inodes)) |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 59fbbe899acc..7e91913e325b 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
| @@ -41,6 +41,8 @@ | |||
| 41 | #include "acl.h" | 41 | #include "acl.h" |
| 42 | #include "ext4_extents.h" | 42 | #include "ext4_extents.h" |
| 43 | 43 | ||
| 44 | #define MPAGE_DA_EXTENT_TAIL 0x01 | ||
| 45 | |||
| 44 | static inline int ext4_begin_ordered_truncate(struct inode *inode, | 46 | static inline int ext4_begin_ordered_truncate(struct inode *inode, |
| 45 | loff_t new_size) | 47 | loff_t new_size) |
| 46 | { | 48 | { |
| @@ -1005,6 +1007,9 @@ static int ext4_indirect_calc_metadata_amount(struct inode *inode, int blocks) | |||
| 1005 | */ | 1007 | */ |
| 1006 | static int ext4_calc_metadata_amount(struct inode *inode, int blocks) | 1008 | static int ext4_calc_metadata_amount(struct inode *inode, int blocks) |
| 1007 | { | 1009 | { |
| 1010 | if (!blocks) | ||
| 1011 | return 0; | ||
| 1012 | |||
| 1008 | if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) | 1013 | if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) |
| 1009 | return ext4_ext_calc_metadata_amount(inode, blocks); | 1014 | return ext4_ext_calc_metadata_amount(inode, blocks); |
| 1010 | 1015 | ||
| @@ -1041,18 +1046,6 @@ static void ext4_da_update_reserve_space(struct inode *inode, int used) | |||
| 1041 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); | 1046 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); |
| 1042 | } | 1047 | } |
| 1043 | 1048 | ||
| 1044 | /* Maximum number of blocks we map for direct IO at once. */ | ||
| 1045 | #define DIO_MAX_BLOCKS 4096 | ||
| 1046 | /* | ||
| 1047 | * Number of credits we need for writing DIO_MAX_BLOCKS: | ||
| 1048 | * We need sb + group descriptor + bitmap + inode -> 4 | ||
| 1049 | * For B blocks with A block pointers per block we need: | ||
| 1050 | * 1 (triple ind.) + (B/A/A + 2) (doubly ind.) + (B/A + 2) (indirect). | ||
| 1051 | * If we plug in 4096 for B and 256 for A (for 1KB block size), we get 25. | ||
| 1052 | */ | ||
| 1053 | #define DIO_CREDITS 25 | ||
| 1054 | |||
| 1055 | |||
| 1056 | /* | 1049 | /* |
| 1057 | * The ext4_get_blocks_wrap() function try to look up the requested blocks, | 1050 | * The ext4_get_blocks_wrap() function try to look up the requested blocks, |
| 1058 | * and returns if the blocks are already mapped. | 1051 | * and returns if the blocks are already mapped. |
| @@ -1164,19 +1157,23 @@ int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block, | |||
| 1164 | return retval; | 1157 | return retval; |
| 1165 | } | 1158 | } |
| 1166 | 1159 | ||
| 1160 | /* Maximum number of blocks we map for direct IO at once. */ | ||
| 1161 | #define DIO_MAX_BLOCKS 4096 | ||
| 1162 | |||
| 1167 | static int ext4_get_block(struct inode *inode, sector_t iblock, | 1163 | static int ext4_get_block(struct inode *inode, sector_t iblock, |
| 1168 | struct buffer_head *bh_result, int create) | 1164 | struct buffer_head *bh_result, int create) |
| 1169 | { | 1165 | { |
| 1170 | handle_t *handle = ext4_journal_current_handle(); | 1166 | handle_t *handle = ext4_journal_current_handle(); |
| 1171 | int ret = 0, started = 0; | 1167 | int ret = 0, started = 0; |
| 1172 | unsigned max_blocks = bh_result->b_size >> inode->i_blkbits; | 1168 | unsigned max_blocks = bh_result->b_size >> inode->i_blkbits; |
| 1169 | int dio_credits; | ||
| 1173 | 1170 | ||
| 1174 | if (create && !handle) { | 1171 | if (create && !handle) { |
| 1175 | /* Direct IO write... */ | 1172 | /* Direct IO write... */ |
| 1176 | if (max_blocks > DIO_MAX_BLOCKS) | 1173 | if (max_blocks > DIO_MAX_BLOCKS) |
| 1177 | max_blocks = DIO_MAX_BLOCKS; | 1174 | max_blocks = DIO_MAX_BLOCKS; |
| 1178 | handle = ext4_journal_start(inode, DIO_CREDITS + | 1175 | dio_credits = ext4_chunk_trans_blocks(inode, max_blocks); |
| 1179 | 2 * EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb)); | 1176 | handle = ext4_journal_start(inode, dio_credits); |
| 1180 | if (IS_ERR(handle)) { | 1177 | if (IS_ERR(handle)) { |
| 1181 | ret = PTR_ERR(handle); | 1178 | ret = PTR_ERR(handle); |
| 1182 | goto out; | 1179 | goto out; |
| @@ -1559,7 +1556,25 @@ static void ext4_da_release_space(struct inode *inode, int to_free) | |||
| 1559 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | 1556 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
| 1560 | int total, mdb, mdb_free, release; | 1557 | int total, mdb, mdb_free, release; |
| 1561 | 1558 | ||
| 1559 | if (!to_free) | ||
| 1560 | return; /* Nothing to release, exit */ | ||
| 1561 | |||
| 1562 | spin_lock(&EXT4_I(inode)->i_block_reservation_lock); | 1562 | spin_lock(&EXT4_I(inode)->i_block_reservation_lock); |
| 1563 | |||
| 1564 | if (!EXT4_I(inode)->i_reserved_data_blocks) { | ||
| 1565 | /* | ||
| 1566 | * if there is no reserved blocks, but we try to free some | ||
| 1567 | * then the counter is messed up somewhere. | ||
| 1568 | * but since this function is called from invalidate | ||
| 1569 | * page, it's harmless to return without any action | ||
| 1570 | */ | ||
| 1571 | printk(KERN_INFO "ext4 delalloc try to release %d reserved " | ||
| 1572 | "blocks for inode %lu, but there is no reserved " | ||
| 1573 | "data blocks\n", to_free, inode->i_ino); | ||
| 1574 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); | ||
| 1575 | return; | ||
| 1576 | } | ||
| 1577 | |||
| 1563 | /* recalculate the number of metablocks still need to be reserved */ | 1578 | /* recalculate the number of metablocks still need to be reserved */ |
| 1564 | total = EXT4_I(inode)->i_reserved_data_blocks - to_free; | 1579 | total = EXT4_I(inode)->i_reserved_data_blocks - to_free; |
| 1565 | mdb = ext4_calc_metadata_amount(inode, total); | 1580 | mdb = ext4_calc_metadata_amount(inode, total); |
| @@ -1613,11 +1628,13 @@ struct mpage_da_data { | |||
| 1613 | unsigned long first_page, next_page; /* extent of pages */ | 1628 | unsigned long first_page, next_page; /* extent of pages */ |
| 1614 | get_block_t *get_block; | 1629 | get_block_t *get_block; |
| 1615 | struct writeback_control *wbc; | 1630 | struct writeback_control *wbc; |
| 1631 | int io_done; | ||
| 1632 | long pages_written; | ||
| 1616 | }; | 1633 | }; |
| 1617 | 1634 | ||
| 1618 | /* | 1635 | /* |
| 1619 | * mpage_da_submit_io - walks through extent of pages and try to write | 1636 | * mpage_da_submit_io - walks through extent of pages and try to write |
| 1620 | * them with __mpage_writepage() | 1637 | * them with writepage() call back |
| 1621 | * | 1638 | * |
| 1622 | * @mpd->inode: inode | 1639 | * @mpd->inode: inode |
| 1623 | * @mpd->first_page: first page of the extent | 1640 | * @mpd->first_page: first page of the extent |
| @@ -1632,18 +1649,11 @@ struct mpage_da_data { | |||
| 1632 | static int mpage_da_submit_io(struct mpage_da_data *mpd) | 1649 | static int mpage_da_submit_io(struct mpage_da_data *mpd) |
| 1633 | { | 1650 | { |
| 1634 | struct address_space *mapping = mpd->inode->i_mapping; | 1651 | struct address_space *mapping = mpd->inode->i_mapping; |
| 1635 | struct mpage_data mpd_pp = { | ||
| 1636 | .bio = NULL, | ||
| 1637 | .last_block_in_bio = 0, | ||
| 1638 | .get_block = mpd->get_block, | ||
| 1639 | .use_writepage = 1, | ||
| 1640 | }; | ||
| 1641 | int ret = 0, err, nr_pages, i; | 1652 | int ret = 0, err, nr_pages, i; |
| 1642 | unsigned long index, end; | 1653 | unsigned long index, end; |
| 1643 | struct pagevec pvec; | 1654 | struct pagevec pvec; |
| 1644 | 1655 | ||
| 1645 | BUG_ON(mpd->next_page <= mpd->first_page); | 1656 | BUG_ON(mpd->next_page <= mpd->first_page); |
| 1646 | |||
| 1647 | pagevec_init(&pvec, 0); | 1657 | pagevec_init(&pvec, 0); |
| 1648 | index = mpd->first_page; | 1658 | index = mpd->first_page; |
| 1649 | end = mpd->next_page - 1; | 1659 | end = mpd->next_page - 1; |
| @@ -1661,8 +1671,9 @@ static int mpage_da_submit_io(struct mpage_da_data *mpd) | |||
| 1661 | break; | 1671 | break; |
| 1662 | index++; | 1672 | index++; |
| 1663 | 1673 | ||
| 1664 | err = __mpage_writepage(page, mpd->wbc, &mpd_pp); | 1674 | err = mapping->a_ops->writepage(page, mpd->wbc); |
| 1665 | 1675 | if (!err) | |
| 1676 | mpd->pages_written++; | ||
| 1666 | /* | 1677 | /* |
| 1667 | * In error case, we have to continue because | 1678 | * In error case, we have to continue because |
| 1668 | * remaining pages are still locked | 1679 | * remaining pages are still locked |
| @@ -1673,9 +1684,6 @@ static int mpage_da_submit_io(struct mpage_da_data *mpd) | |||
| 1673 | } | 1684 | } |
| 1674 | pagevec_release(&pvec); | 1685 | pagevec_release(&pvec); |
| 1675 | } | 1686 | } |
| 1676 | if (mpd_pp.bio) | ||
| 1677 | mpage_bio_submit(WRITE, mpd_pp.bio); | ||
| 1678 | |||
| 1679 | return ret; | 1687 | return ret; |
| 1680 | } | 1688 | } |
| 1681 | 1689 | ||
| @@ -1698,7 +1706,7 @@ static void mpage_put_bnr_to_bhs(struct mpage_da_data *mpd, sector_t logical, | |||
| 1698 | int blocks = exbh->b_size >> inode->i_blkbits; | 1706 | int blocks = exbh->b_size >> inode->i_blkbits; |
| 1699 | sector_t pblock = exbh->b_blocknr, cur_logical; | 1707 | sector_t pblock = exbh->b_blocknr, cur_logical; |
| 1700 | struct buffer_head *head, *bh; | 1708 | struct buffer_head *head, *bh; |
| 1701 | unsigned long index, end; | 1709 | pgoff_t index, end; |
| 1702 | struct pagevec pvec; | 1710 | struct pagevec pvec; |
| 1703 | int nr_pages, i; | 1711 | int nr_pages, i; |
| 1704 | 1712 | ||
| @@ -1741,6 +1749,13 @@ static void mpage_put_bnr_to_bhs(struct mpage_da_data *mpd, sector_t logical, | |||
| 1741 | if (buffer_delay(bh)) { | 1749 | if (buffer_delay(bh)) { |
| 1742 | bh->b_blocknr = pblock; | 1750 | bh->b_blocknr = pblock; |
| 1743 | clear_buffer_delay(bh); | 1751 | clear_buffer_delay(bh); |
| 1752 | bh->b_bdev = inode->i_sb->s_bdev; | ||
| 1753 | } else if (buffer_unwritten(bh)) { | ||
| 1754 | bh->b_blocknr = pblock; | ||
| 1755 | clear_buffer_unwritten(bh); | ||
| 1756 | set_buffer_mapped(bh); | ||
| 1757 | set_buffer_new(bh); | ||
| 1758 | bh->b_bdev = inode->i_sb->s_bdev; | ||
| 1744 | } else if (buffer_mapped(bh)) | 1759 | } else if (buffer_mapped(bh)) |
| 1745 | BUG_ON(bh->b_blocknr != pblock); | 1760 | BUG_ON(bh->b_blocknr != pblock); |
| 1746 | 1761 | ||
| @@ -1776,13 +1791,11 @@ static inline void __unmap_underlying_blocks(struct inode *inode, | |||
| 1776 | * | 1791 | * |
| 1777 | * The function skips space we know is already mapped to disk blocks. | 1792 | * The function skips space we know is already mapped to disk blocks. |
| 1778 | * | 1793 | * |
| 1779 | * The function ignores errors ->get_block() returns, thus real | ||
| 1780 | * error handling is postponed to __mpage_writepage() | ||
| 1781 | */ | 1794 | */ |
| 1782 | static void mpage_da_map_blocks(struct mpage_da_data *mpd) | 1795 | static void mpage_da_map_blocks(struct mpage_da_data *mpd) |
| 1783 | { | 1796 | { |
| 1797 | int err = 0; | ||
| 1784 | struct buffer_head *lbh = &mpd->lbh; | 1798 | struct buffer_head *lbh = &mpd->lbh; |
| 1785 | int err = 0, remain = lbh->b_size; | ||
| 1786 | sector_t next = lbh->b_blocknr; | 1799 | sector_t next = lbh->b_blocknr; |
| 1787 | struct buffer_head new; | 1800 | struct buffer_head new; |
| 1788 | 1801 | ||
| @@ -1792,38 +1805,36 @@ static void mpage_da_map_blocks(struct mpage_da_data *mpd) | |||
| 1792 | if (buffer_mapped(lbh) && !buffer_delay(lbh)) | 1805 | if (buffer_mapped(lbh) && !buffer_delay(lbh)) |
| 1793 | return; | 1806 | return; |
| 1794 | 1807 | ||
| 1795 | while (remain) { | 1808 | new.b_state = lbh->b_state; |
| 1796 | new.b_state = lbh->b_state; | 1809 | new.b_blocknr = 0; |
| 1797 | new.b_blocknr = 0; | 1810 | new.b_size = lbh->b_size; |
| 1798 | new.b_size = remain; | ||
| 1799 | err = mpd->get_block(mpd->inode, next, &new, 1); | ||
| 1800 | if (err) { | ||
| 1801 | /* | ||
| 1802 | * Rather than implement own error handling | ||
| 1803 | * here, we just leave remaining blocks | ||
| 1804 | * unallocated and try again with ->writepage() | ||
| 1805 | */ | ||
| 1806 | break; | ||
| 1807 | } | ||
| 1808 | BUG_ON(new.b_size == 0); | ||
| 1809 | 1811 | ||
| 1810 | if (buffer_new(&new)) | 1812 | /* |
| 1811 | __unmap_underlying_blocks(mpd->inode, &new); | 1813 | * If we didn't accumulate anything |
| 1814 | * to write simply return | ||
| 1815 | */ | ||
| 1816 | if (!new.b_size) | ||
| 1817 | return; | ||
| 1818 | err = mpd->get_block(mpd->inode, next, &new, 1); | ||
| 1819 | if (err) | ||
| 1820 | return; | ||
| 1821 | BUG_ON(new.b_size == 0); | ||
| 1812 | 1822 | ||
| 1813 | /* | 1823 | if (buffer_new(&new)) |
| 1814 | * If blocks are delayed marked, we need to | 1824 | __unmap_underlying_blocks(mpd->inode, &new); |
| 1815 | * put actual blocknr and drop delayed bit | ||
| 1816 | */ | ||
| 1817 | if (buffer_delay(lbh)) | ||
| 1818 | mpage_put_bnr_to_bhs(mpd, next, &new); | ||
| 1819 | 1825 | ||
| 1820 | /* go for the remaining blocks */ | 1826 | /* |
| 1821 | next += new.b_size >> mpd->inode->i_blkbits; | 1827 | * If blocks are delayed marked, we need to |
| 1822 | remain -= new.b_size; | 1828 | * put actual blocknr and drop delayed bit |
| 1823 | } | 1829 | */ |
| 1830 | if (buffer_delay(lbh) || buffer_unwritten(lbh)) | ||
| 1831 | mpage_put_bnr_to_bhs(mpd, next, &new); | ||
| 1832 | |||
| 1833 | return; | ||
| 1824 | } | 1834 | } |
| 1825 | 1835 | ||
| 1826 | #define BH_FLAGS ((1 << BH_Uptodate) | (1 << BH_Mapped) | (1 << BH_Delay)) | 1836 | #define BH_FLAGS ((1 << BH_Uptodate) | (1 << BH_Mapped) | \ |
| 1837 | (1 << BH_Delay) | (1 << BH_Unwritten)) | ||
| 1827 | 1838 | ||
| 1828 | /* | 1839 | /* |
| 1829 | * mpage_add_bh_to_extent - try to add one more block to extent of blocks | 1840 | * mpage_add_bh_to_extent - try to add one more block to extent of blocks |
| @@ -1837,41 +1848,61 @@ static void mpage_da_map_blocks(struct mpage_da_data *mpd) | |||
| 1837 | static void mpage_add_bh_to_extent(struct mpage_da_data *mpd, | 1848 | static void mpage_add_bh_to_extent(struct mpage_da_data *mpd, |
| 1838 | sector_t logical, struct buffer_head *bh) | 1849 | sector_t logical, struct buffer_head *bh) |
| 1839 | { | 1850 | { |
| 1840 | struct buffer_head *lbh = &mpd->lbh; | ||
| 1841 | sector_t next; | 1851 | sector_t next; |
| 1852 | size_t b_size = bh->b_size; | ||
| 1853 | struct buffer_head *lbh = &mpd->lbh; | ||
| 1854 | int nrblocks = lbh->b_size >> mpd->inode->i_blkbits; | ||
| 1842 | 1855 | ||
| 1843 | next = lbh->b_blocknr + (lbh->b_size >> mpd->inode->i_blkbits); | 1856 | /* check if thereserved journal credits might overflow */ |
| 1844 | 1857 | if (!(EXT4_I(mpd->inode)->i_flags & EXT4_EXTENTS_FL)) { | |
| 1858 | if (nrblocks >= EXT4_MAX_TRANS_DATA) { | ||
| 1859 | /* | ||
| 1860 | * With non-extent format we are limited by the journal | ||
| 1861 | * credit available. Total credit needed to insert | ||
| 1862 | * nrblocks contiguous blocks is dependent on the | ||
| 1863 | * nrblocks. So limit nrblocks. | ||
| 1864 | */ | ||
| 1865 | goto flush_it; | ||
| 1866 | } else if ((nrblocks + (b_size >> mpd->inode->i_blkbits)) > | ||
| 1867 | EXT4_MAX_TRANS_DATA) { | ||
| 1868 | /* | ||
| 1869 | * Adding the new buffer_head would make it cross the | ||
| 1870 | * allowed limit for which we have journal credit | ||
| 1871 | * reserved. So limit the new bh->b_size | ||
| 1872 | */ | ||
| 1873 | b_size = (EXT4_MAX_TRANS_DATA - nrblocks) << | ||
| 1874 | mpd->inode->i_blkbits; | ||
| 1875 | /* we will do mpage_da_submit_io in the next loop */ | ||
| 1876 | } | ||
| 1877 | } | ||
| 1845 | /* | 1878 | /* |
| 1846 | * First block in the extent | 1879 | * First block in the extent |
| 1847 | */ | 1880 | */ |
| 1848 | if (lbh->b_size == 0) { | 1881 | if (lbh->b_size == 0) { |
| 1849 | lbh->b_blocknr = logical; | 1882 | lbh->b_blocknr = logical; |
| 1850 | lbh->b_size = bh->b_size; | 1883 | lbh->b_size = b_size; |
| 1851 | lbh->b_state = bh->b_state & BH_FLAGS; | 1884 | lbh->b_state = bh->b_state & BH_FLAGS; |
| 1852 | return; | 1885 | return; |
| 1853 | } | 1886 | } |
| 1854 | 1887 | ||
| 1888 | next = lbh->b_blocknr + nrblocks; | ||
| 1855 | /* | 1889 | /* |
| 1856 | * Can we merge the block to our big extent? | 1890 | * Can we merge the block to our big extent? |
| 1857 | */ | 1891 | */ |
| 1858 | if (logical == next && (bh->b_state & BH_FLAGS) == lbh->b_state) { | 1892 | if (logical == next && (bh->b_state & BH_FLAGS) == lbh->b_state) { |
| 1859 | lbh->b_size += bh->b_size; | 1893 | lbh->b_size += b_size; |
| 1860 | return; | 1894 | return; |
| 1861 | } | 1895 | } |
| 1862 | 1896 | ||
| 1897 | flush_it: | ||
| 1863 | /* | 1898 | /* |
| 1864 | * We couldn't merge the block to our extent, so we | 1899 | * We couldn't merge the block to our extent, so we |
| 1865 | * need to flush current extent and start new one | 1900 | * need to flush current extent and start new one |
| 1866 | */ | 1901 | */ |
| 1867 | mpage_da_map_blocks(mpd); | 1902 | mpage_da_map_blocks(mpd); |
| 1868 | 1903 | mpage_da_submit_io(mpd); | |
| 1869 | /* | 1904 | mpd->io_done = 1; |
| 1870 | * Now start a new extent | 1905 | return; |
| 1871 | */ | ||
| 1872 | lbh->b_size = bh->b_size; | ||
| 1873 | lbh->b_state = bh->b_state & BH_FLAGS; | ||
| 1874 | lbh->b_blocknr = logical; | ||
| 1875 | } | 1906 | } |
| 1876 | 1907 | ||
| 1877 | /* | 1908 | /* |
| @@ -1891,17 +1922,35 @@ static int __mpage_da_writepage(struct page *page, | |||
| 1891 | struct buffer_head *bh, *head, fake; | 1922 | struct buffer_head *bh, *head, fake; |
| 1892 | sector_t logical; | 1923 | sector_t logical; |
| 1893 | 1924 | ||
| 1925 | if (mpd->io_done) { | ||
| 1926 | /* | ||
| 1927 | * Rest of the page in the page_vec | ||
| 1928 | * redirty then and skip then. We will | ||
| 1929 | * try to to write them again after | ||
| 1930 | * starting a new transaction | ||
| 1931 | */ | ||
| 1932 | redirty_page_for_writepage(wbc, page); | ||
| 1933 | unlock_page(page); | ||
| 1934 | return MPAGE_DA_EXTENT_TAIL; | ||
| 1935 | } | ||
| 1894 | /* | 1936 | /* |
| 1895 | * Can we merge this page to current extent? | 1937 | * Can we merge this page to current extent? |
| 1896 | */ | 1938 | */ |
| 1897 | if (mpd->next_page != page->index) { | 1939 | if (mpd->next_page != page->index) { |
| 1898 | /* | 1940 | /* |
| 1899 | * Nope, we can't. So, we map non-allocated blocks | 1941 | * Nope, we can't. So, we map non-allocated blocks |
| 1900 | * and start IO on them using __mpage_writepage() | 1942 | * and start IO on them using writepage() |
| 1901 | */ | 1943 | */ |
| 1902 | if (mpd->next_page != mpd->first_page) { | 1944 | if (mpd->next_page != mpd->first_page) { |
| 1903 | mpage_da_map_blocks(mpd); | 1945 | mpage_da_map_blocks(mpd); |
| 1904 | mpage_da_submit_io(mpd); | 1946 | mpage_da_submit_io(mpd); |
| 1947 | /* | ||
| 1948 | * skip rest of the page in the page_vec | ||
| 1949 | */ | ||
| 1950 | mpd->io_done = 1; | ||
| 1951 | redirty_page_for_writepage(wbc, page); | ||
| 1952 | unlock_page(page); | ||
| 1953 | return MPAGE_DA_EXTENT_TAIL; | ||
| 1905 | } | 1954 | } |
| 1906 | 1955 | ||
| 1907 | /* | 1956 | /* |
| @@ -1932,6 +1981,8 @@ static int __mpage_da_writepage(struct page *page, | |||
| 1932 | set_buffer_dirty(bh); | 1981 | set_buffer_dirty(bh); |
| 1933 | set_buffer_uptodate(bh); | 1982 | set_buffer_uptodate(bh); |
| 1934 | mpage_add_bh_to_extent(mpd, logical, bh); | 1983 | mpage_add_bh_to_extent(mpd, logical, bh); |
| 1984 | if (mpd->io_done) | ||
| 1985 | return MPAGE_DA_EXTENT_TAIL; | ||
| 1935 | } else { | 1986 | } else { |
| 1936 | /* | 1987 | /* |
| 1937 | * Page with regular buffer heads, just add all dirty ones | 1988 | * Page with regular buffer heads, just add all dirty ones |
| @@ -1940,8 +1991,12 @@ static int __mpage_da_writepage(struct page *page, | |||
| 1940 | bh = head; | 1991 | bh = head; |
| 1941 | do { | 1992 | do { |
| 1942 | BUG_ON(buffer_locked(bh)); | 1993 | BUG_ON(buffer_locked(bh)); |
| 1943 | if (buffer_dirty(bh)) | 1994 | if (buffer_dirty(bh) && |
| 1995 | (!buffer_mapped(bh) || buffer_delay(bh))) { | ||
| 1944 | mpage_add_bh_to_extent(mpd, logical, bh); | 1996 | mpage_add_bh_to_extent(mpd, logical, bh); |
| 1997 | if (mpd->io_done) | ||
| 1998 | return MPAGE_DA_EXTENT_TAIL; | ||
| 1999 | } | ||
| 1945 | logical++; | 2000 | logical++; |
| 1946 | } while ((bh = bh->b_this_page) != head); | 2001 | } while ((bh = bh->b_this_page) != head); |
| 1947 | } | 2002 | } |
| @@ -1960,22 +2015,13 @@ static int __mpage_da_writepage(struct page *page, | |||
| 1960 | * | 2015 | * |
| 1961 | * This is a library function, which implements the writepages() | 2016 | * This is a library function, which implements the writepages() |
| 1962 | * address_space_operation. | 2017 | * address_space_operation. |
| 1963 | * | ||
| 1964 | * In order to avoid duplication of logic that deals with partial pages, | ||
| 1965 | * multiple bio per page, etc, we find non-allocated blocks, allocate | ||
| 1966 | * them with minimal calls to ->get_block() and re-use __mpage_writepage() | ||
| 1967 | * | ||
| 1968 | * It's important that we call __mpage_writepage() only once for each | ||
| 1969 | * involved page, otherwise we'd have to implement more complicated logic | ||
| 1970 | * to deal with pages w/o PG_lock or w/ PG_writeback and so on. | ||
| 1971 | * | ||
| 1972 | * See comments to mpage_writepages() | ||
| 1973 | */ | 2018 | */ |
| 1974 | static int mpage_da_writepages(struct address_space *mapping, | 2019 | static int mpage_da_writepages(struct address_space *mapping, |
| 1975 | struct writeback_control *wbc, | 2020 | struct writeback_control *wbc, |
| 1976 | get_block_t get_block) | 2021 | get_block_t get_block) |
| 1977 | { | 2022 | { |
| 1978 | struct mpage_da_data mpd; | 2023 | struct mpage_da_data mpd; |
| 2024 | long to_write; | ||
| 1979 | int ret; | 2025 | int ret; |
| 1980 | 2026 | ||
| 1981 | if (!get_block) | 2027 | if (!get_block) |
| @@ -1989,17 +2035,22 @@ static int mpage_da_writepages(struct address_space *mapping, | |||
| 1989 | mpd.first_page = 0; | 2035 | mpd.first_page = 0; |
| 1990 | mpd.next_page = 0; | 2036 | mpd.next_page = 0; |
| 1991 | mpd.get_block = get_block; | 2037 | mpd.get_block = get_block; |
| 2038 | mpd.io_done = 0; | ||
| 2039 | mpd.pages_written = 0; | ||
| 2040 | |||
| 2041 | to_write = wbc->nr_to_write; | ||
| 1992 | 2042 | ||
| 1993 | ret = write_cache_pages(mapping, wbc, __mpage_da_writepage, &mpd); | 2043 | ret = write_cache_pages(mapping, wbc, __mpage_da_writepage, &mpd); |
| 1994 | 2044 | ||
| 1995 | /* | 2045 | /* |
| 1996 | * Handle last extent of pages | 2046 | * Handle last extent of pages |
| 1997 | */ | 2047 | */ |
| 1998 | if (mpd.next_page != mpd.first_page) { | 2048 | if (!mpd.io_done && mpd.next_page != mpd.first_page) { |
| 1999 | mpage_da_map_blocks(&mpd); | 2049 | mpage_da_map_blocks(&mpd); |
| 2000 | mpage_da_submit_io(&mpd); | 2050 | mpage_da_submit_io(&mpd); |
| 2001 | } | 2051 | } |
| 2002 | 2052 | ||
| 2053 | wbc->nr_to_write = to_write - mpd.pages_written; | ||
| 2003 | return ret; | 2054 | return ret; |
| 2004 | } | 2055 | } |
| 2005 | 2056 | ||
| @@ -2204,63 +2255,95 @@ static int ext4_da_writepage(struct page *page, | |||
| 2204 | } | 2255 | } |
| 2205 | 2256 | ||
| 2206 | /* | 2257 | /* |
| 2207 | * For now just follow the DIO way to estimate the max credits | 2258 | * This is called via ext4_da_writepages() to |
| 2208 | * needed to write out EXT4_MAX_WRITEBACK_PAGES. | 2259 | * calulate the total number of credits to reserve to fit |
| 2209 | * todo: need to calculate the max credits need for | 2260 | * a single extent allocation into a single transaction, |
| 2210 | * extent based files, currently the DIO credits is based on | 2261 | * ext4_da_writpeages() will loop calling this before |
| 2211 | * indirect-blocks mapping way. | 2262 | * the block allocation. |
| 2212 | * | ||
| 2213 | * Probably should have a generic way to calculate credits | ||
| 2214 | * for DIO, writepages, and truncate | ||
| 2215 | */ | 2263 | */ |
| 2216 | #define EXT4_MAX_WRITEBACK_PAGES DIO_MAX_BLOCKS | 2264 | |
| 2217 | #define EXT4_MAX_WRITEBACK_CREDITS DIO_CREDITS | 2265 | static int ext4_da_writepages_trans_blocks(struct inode *inode) |
| 2266 | { | ||
| 2267 | int max_blocks = EXT4_I(inode)->i_reserved_data_blocks; | ||
| 2268 | |||
| 2269 | /* | ||
| 2270 | * With non-extent format the journal credit needed to | ||
| 2271 | * insert nrblocks contiguous block is dependent on | ||
| 2272 | * number of contiguous block. So we will limit | ||
| 2273 | * number of contiguous block to a sane value | ||
| 2274 | */ | ||
| 2275 | if (!(inode->i_flags & EXT4_EXTENTS_FL) && | ||
| 2276 | (max_blocks > EXT4_MAX_TRANS_DATA)) | ||
| 2277 | max_blocks = EXT4_MAX_TRANS_DATA; | ||
| 2278 | |||
| 2279 | return ext4_chunk_trans_blocks(inode, max_blocks); | ||
| 2280 | } | ||
| 2218 | 2281 | ||
| 2219 | static int ext4_da_writepages(struct address_space *mapping, | 2282 | static int ext4_da_writepages(struct address_space *mapping, |
| 2220 | struct writeback_control *wbc) | 2283 | struct writeback_control *wbc) |
| 2221 | { | 2284 | { |
| 2222 | struct inode *inode = mapping->host; | ||
| 2223 | handle_t *handle = NULL; | 2285 | handle_t *handle = NULL; |
| 2224 | int needed_blocks; | ||
| 2225 | int ret = 0; | ||
| 2226 | long to_write; | ||
| 2227 | loff_t range_start = 0; | 2286 | loff_t range_start = 0; |
| 2287 | struct inode *inode = mapping->host; | ||
| 2288 | int needed_blocks, ret = 0, nr_to_writebump = 0; | ||
| 2289 | long to_write, pages_skipped = 0; | ||
| 2290 | struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb); | ||
| 2228 | 2291 | ||
| 2229 | /* | 2292 | /* |
| 2230 | * No pages to write? This is mainly a kludge to avoid starting | 2293 | * No pages to write? This is mainly a kludge to avoid starting |
| 2231 | * a transaction for special inodes like journal inode on last iput() | 2294 | * a transaction for special inodes like journal inode on last iput() |
| 2232 | * because that could violate lock ordering on umount | 2295 | * because that could violate lock ordering on umount |
| 2233 | */ | 2296 | */ |
| 2234 | if (!mapping->nrpages) | 2297 | if (!mapping->nrpages || !mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) |
| 2235 | return 0; | 2298 | return 0; |
| 2236 | |||
| 2237 | /* | 2299 | /* |
| 2238 | * Estimate the worse case needed credits to write out | 2300 | * Make sure nr_to_write is >= sbi->s_mb_stream_request |
| 2239 | * EXT4_MAX_BUF_BLOCKS pages | 2301 | * This make sure small files blocks are allocated in |
| 2302 | * single attempt. This ensure that small files | ||
| 2303 | * get less fragmented. | ||
| 2240 | */ | 2304 | */ |
| 2241 | needed_blocks = EXT4_MAX_WRITEBACK_CREDITS; | 2305 | if (wbc->nr_to_write < sbi->s_mb_stream_request) { |
| 2306 | nr_to_writebump = sbi->s_mb_stream_request - wbc->nr_to_write; | ||
| 2307 | wbc->nr_to_write = sbi->s_mb_stream_request; | ||
| 2308 | } | ||
| 2242 | 2309 | ||
| 2243 | to_write = wbc->nr_to_write; | 2310 | if (!wbc->range_cyclic) |
| 2244 | if (!wbc->range_cyclic) { | ||
| 2245 | /* | 2311 | /* |
| 2246 | * If range_cyclic is not set force range_cont | 2312 | * If range_cyclic is not set force range_cont |
| 2247 | * and save the old writeback_index | 2313 | * and save the old writeback_index |
| 2248 | */ | 2314 | */ |
| 2249 | wbc->range_cont = 1; | 2315 | wbc->range_cont = 1; |
| 2250 | range_start = wbc->range_start; | ||
| 2251 | } | ||
| 2252 | 2316 | ||
| 2253 | while (!ret && to_write) { | 2317 | range_start = wbc->range_start; |
| 2318 | pages_skipped = wbc->pages_skipped; | ||
| 2319 | |||
| 2320 | restart_loop: | ||
| 2321 | to_write = wbc->nr_to_write; | ||
| 2322 | while (!ret && to_write > 0) { | ||
| 2323 | |||
| 2324 | /* | ||
| 2325 | * we insert one extent at a time. So we need | ||
| 2326 | * credit needed for single extent allocation. | ||
| 2327 | * journalled mode is currently not supported | ||
| 2328 | * by delalloc | ||
| 2329 | */ | ||
| 2330 | BUG_ON(ext4_should_journal_data(inode)); | ||
| 2331 | needed_blocks = ext4_da_writepages_trans_blocks(inode); | ||
| 2332 | |||
| 2254 | /* start a new transaction*/ | 2333 | /* start a new transaction*/ |
| 2255 | handle = ext4_journal_start(inode, needed_blocks); | 2334 | handle = ext4_journal_start(inode, needed_blocks); |
| 2256 | if (IS_ERR(handle)) { | 2335 | if (IS_ERR(handle)) { |
| 2257 | ret = PTR_ERR(handle); | 2336 | ret = PTR_ERR(handle); |
| 2337 | printk(KERN_EMERG "%s: jbd2_start: " | ||
| 2338 | "%ld pages, ino %lu; err %d\n", __func__, | ||
| 2339 | wbc->nr_to_write, inode->i_ino, ret); | ||
| 2340 | dump_stack(); | ||
| 2258 | goto out_writepages; | 2341 | goto out_writepages; |
| 2259 | } | 2342 | } |
| 2260 | if (ext4_should_order_data(inode)) { | 2343 | if (ext4_should_order_data(inode)) { |
| 2261 | /* | 2344 | /* |
| 2262 | * With ordered mode we need to add | 2345 | * With ordered mode we need to add |
| 2263 | * the inode to the journal handle | 2346 | * the inode to the journal handl |
| 2264 | * when we do block allocation. | 2347 | * when we do block allocation. |
| 2265 | */ | 2348 | */ |
| 2266 | ret = ext4_jbd2_file_inode(handle, inode); | 2349 | ret = ext4_jbd2_file_inode(handle, inode); |
| @@ -2268,20 +2351,20 @@ static int ext4_da_writepages(struct address_space *mapping, | |||
| 2268 | ext4_journal_stop(handle); | 2351 | ext4_journal_stop(handle); |
| 2269 | goto out_writepages; | 2352 | goto out_writepages; |
| 2270 | } | 2353 | } |
| 2271 | |||
| 2272 | } | 2354 | } |
| 2273 | /* | ||
| 2274 | * set the max dirty pages could be write at a time | ||
| 2275 | * to fit into the reserved transaction credits | ||
| 2276 | */ | ||
| 2277 | if (wbc->nr_to_write > EXT4_MAX_WRITEBACK_PAGES) | ||
| 2278 | wbc->nr_to_write = EXT4_MAX_WRITEBACK_PAGES; | ||
| 2279 | 2355 | ||
| 2280 | to_write -= wbc->nr_to_write; | 2356 | to_write -= wbc->nr_to_write; |
| 2281 | ret = mpage_da_writepages(mapping, wbc, | 2357 | ret = mpage_da_writepages(mapping, wbc, |
| 2282 | ext4_da_get_block_write); | 2358 | ext4_da_get_block_write); |
| 2283 | ext4_journal_stop(handle); | 2359 | ext4_journal_stop(handle); |
| 2284 | if (wbc->nr_to_write) { | 2360 | if (ret == MPAGE_DA_EXTENT_TAIL) { |
| 2361 | /* | ||
| 2362 | * got one extent now try with | ||
| 2363 | * rest of the pages | ||
| 2364 | */ | ||
| 2365 | to_write += wbc->nr_to_write; | ||
| 2366 | ret = 0; | ||
| 2367 | } else if (wbc->nr_to_write) { | ||
| 2285 | /* | 2368 | /* |
| 2286 | * There is no more writeout needed | 2369 | * There is no more writeout needed |
| 2287 | * or we requested for a noblocking writeout | 2370 | * or we requested for a noblocking writeout |
| @@ -2293,10 +2376,18 @@ static int ext4_da_writepages(struct address_space *mapping, | |||
| 2293 | wbc->nr_to_write = to_write; | 2376 | wbc->nr_to_write = to_write; |
| 2294 | } | 2377 | } |
| 2295 | 2378 | ||
| 2296 | out_writepages: | 2379 | if (wbc->range_cont && (pages_skipped != wbc->pages_skipped)) { |
| 2297 | wbc->nr_to_write = to_write; | 2380 | /* We skipped pages in this loop */ |
| 2298 | if (range_start) | ||
| 2299 | wbc->range_start = range_start; | 2381 | wbc->range_start = range_start; |
| 2382 | wbc->nr_to_write = to_write + | ||
| 2383 | wbc->pages_skipped - pages_skipped; | ||
| 2384 | wbc->pages_skipped = pages_skipped; | ||
| 2385 | goto restart_loop; | ||
| 2386 | } | ||
| 2387 | |||
| 2388 | out_writepages: | ||
| 2389 | wbc->nr_to_write = to_write - nr_to_writebump; | ||
| 2390 | wbc->range_start = range_start; | ||
| 2300 | return ret; | 2391 | return ret; |
| 2301 | } | 2392 | } |
| 2302 | 2393 | ||
| @@ -3486,6 +3577,9 @@ void ext4_truncate(struct inode *inode) | |||
| 3486 | * modify the block allocation tree. | 3577 | * modify the block allocation tree. |
| 3487 | */ | 3578 | */ |
| 3488 | down_write(&ei->i_data_sem); | 3579 | down_write(&ei->i_data_sem); |
| 3580 | |||
| 3581 | ext4_discard_reservation(inode); | ||
| 3582 | |||
| 3489 | /* | 3583 | /* |
| 3490 | * The orphan list entry will now protect us from any crash which | 3584 | * The orphan list entry will now protect us from any crash which |
| 3491 | * occurs before the truncate completes, so it is now safe to propagate | 3585 | * occurs before the truncate completes, so it is now safe to propagate |
| @@ -3555,8 +3649,6 @@ do_indirects: | |||
| 3555 | ; | 3649 | ; |
| 3556 | } | 3650 | } |
| 3557 | 3651 | ||
| 3558 | ext4_discard_reservation(inode); | ||
| 3559 | |||
| 3560 | up_write(&ei->i_data_sem); | 3652 | up_write(&ei->i_data_sem); |
| 3561 | inode->i_mtime = inode->i_ctime = ext4_current_time(inode); | 3653 | inode->i_mtime = inode->i_ctime = ext4_current_time(inode); |
| 3562 | ext4_mark_inode_dirty(handle, inode); | 3654 | ext4_mark_inode_dirty(handle, inode); |
| @@ -4324,57 +4416,129 @@ int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
| 4324 | return 0; | 4416 | return 0; |
| 4325 | } | 4417 | } |
| 4326 | 4418 | ||
| 4419 | static int ext4_indirect_trans_blocks(struct inode *inode, int nrblocks, | ||
| 4420 | int chunk) | ||
| 4421 | { | ||
| 4422 | int indirects; | ||
| 4423 | |||
| 4424 | /* if nrblocks are contiguous */ | ||
| 4425 | if (chunk) { | ||
| 4426 | /* | ||
| 4427 | * With N contiguous data blocks, it need at most | ||
| 4428 | * N/EXT4_ADDR_PER_BLOCK(inode->i_sb) indirect blocks | ||
| 4429 | * 2 dindirect blocks | ||
| 4430 | * 1 tindirect block | ||
| 4431 | */ | ||
| 4432 | indirects = nrblocks / EXT4_ADDR_PER_BLOCK(inode->i_sb); | ||
| 4433 | return indirects + 3; | ||
| 4434 | } | ||
| 4435 | /* | ||
| 4436 | * if nrblocks are not contiguous, worse case, each block touch | ||
| 4437 | * a indirect block, and each indirect block touch a double indirect | ||
| 4438 | * block, plus a triple indirect block | ||
| 4439 | */ | ||
| 4440 | indirects = nrblocks * 2 + 1; | ||
| 4441 | return indirects; | ||
| 4442 | } | ||
| 4443 | |||
| 4444 | static int ext4_index_trans_blocks(struct inode *inode, int nrblocks, int chunk) | ||
| 4445 | { | ||
| 4446 | if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) | ||
| 4447 | return ext4_indirect_trans_blocks(inode, nrblocks, 0); | ||
| 4448 | return ext4_ext_index_trans_blocks(inode, nrblocks, 0); | ||
| 4449 | } | ||
| 4327 | /* | 4450 | /* |
| 4328 | * How many blocks doth make a writepage()? | 4451 | * Account for index blocks, block groups bitmaps and block group |
| 4329 | * | 4452 | * descriptor blocks if modify datablocks and index blocks |
| 4330 | * With N blocks per page, it may be: | 4453 | * worse case, the indexs blocks spread over different block groups |
| 4331 | * N data blocks | ||
| 4332 | * 2 indirect block | ||
| 4333 | * 2 dindirect | ||
| 4334 | * 1 tindirect | ||
| 4335 | * N+5 bitmap blocks (from the above) | ||
| 4336 | * N+5 group descriptor summary blocks | ||
| 4337 | * 1 inode block | ||
| 4338 | * 1 superblock. | ||
| 4339 | * 2 * EXT4_SINGLEDATA_TRANS_BLOCKS for the quote files | ||
| 4340 | * | 4454 | * |
| 4341 | * 3 * (N + 5) + 2 + 2 * EXT4_SINGLEDATA_TRANS_BLOCKS | 4455 | * If datablocks are discontiguous, they are possible to spread over |
| 4456 | * different block groups too. If they are contiugous, with flexbg, | ||
| 4457 | * they could still across block group boundary. | ||
| 4342 | * | 4458 | * |
| 4343 | * With ordered or writeback data it's the same, less the N data blocks. | 4459 | * Also account for superblock, inode, quota and xattr blocks |
| 4460 | */ | ||
| 4461 | int ext4_meta_trans_blocks(struct inode *inode, int nrblocks, int chunk) | ||
| 4462 | { | ||
| 4463 | int groups, gdpblocks; | ||
| 4464 | int idxblocks; | ||
| 4465 | int ret = 0; | ||
| 4466 | |||
| 4467 | /* | ||
| 4468 | * How many index blocks need to touch to modify nrblocks? | ||
| 4469 | * The "Chunk" flag indicating whether the nrblocks is | ||
| 4470 | * physically contiguous on disk | ||
| 4471 | * | ||
| 4472 | * For Direct IO and fallocate, they calls get_block to allocate | ||
| 4473 | * one single extent at a time, so they could set the "Chunk" flag | ||
| 4474 | */ | ||
| 4475 | idxblocks = ext4_index_trans_blocks(inode, nrblocks, chunk); | ||
| 4476 | |||
| 4477 | ret = idxblocks; | ||
| 4478 | |||
| 4479 | /* | ||
| 4480 | * Now let's see how many group bitmaps and group descriptors need | ||
| 4481 | * to account | ||
| 4482 | */ | ||
| 4483 | groups = idxblocks; | ||
| 4484 | if (chunk) | ||
| 4485 | groups += 1; | ||
| 4486 | else | ||
| 4487 | groups += nrblocks; | ||
| 4488 | |||
| 4489 | gdpblocks = groups; | ||
| 4490 | if (groups > EXT4_SB(inode->i_sb)->s_groups_count) | ||
| 4491 | groups = EXT4_SB(inode->i_sb)->s_groups_count; | ||
| 4492 | if (groups > EXT4_SB(inode->i_sb)->s_gdb_count) | ||
| 4493 | gdpblocks = EXT4_SB(inode->i_sb)->s_gdb_count; | ||
| 4494 | |||
| 4495 | /* bitmaps and block group descriptor blocks */ | ||
| 4496 | ret += groups + gdpblocks; | ||
| 4497 | |||
| 4498 | /* Blocks for super block, inode, quota and xattr blocks */ | ||
| 4499 | ret += EXT4_META_TRANS_BLOCKS(inode->i_sb); | ||
| 4500 | |||
| 4501 | return ret; | ||
| 4502 | } | ||
| 4503 | |||
| 4504 | /* | ||
| 4505 | * Calulate the total number of credits to reserve to fit | ||
| 4506 | * the modification of a single pages into a single transaction, | ||
| 4507 | * which may include multiple chunks of block allocations. | ||
| 4344 | * | 4508 | * |
| 4345 | * If the inode's direct blocks can hold an integral number of pages then a | 4509 | * This could be called via ext4_write_begin() |
| 4346 | * page cannot straddle two indirect blocks, and we can only touch one indirect | ||
| 4347 | * and dindirect block, and the "5" above becomes "3". | ||
| 4348 | * | 4510 | * |
| 4349 | * This still overestimates under most circumstances. If we were to pass the | 4511 | * We need to consider the worse case, when |
| 4350 | * start and end offsets in here as well we could do block_to_path() on each | 4512 | * one new block per extent. |
| 4351 | * block and work out the exact number of indirects which are touched. Pah. | ||
| 4352 | */ | 4513 | */ |
| 4353 | |||
| 4354 | int ext4_writepage_trans_blocks(struct inode *inode) | 4514 | int ext4_writepage_trans_blocks(struct inode *inode) |
| 4355 | { | 4515 | { |
| 4356 | int bpp = ext4_journal_blocks_per_page(inode); | 4516 | int bpp = ext4_journal_blocks_per_page(inode); |
| 4357 | int indirects = (EXT4_NDIR_BLOCKS % bpp) ? 5 : 3; | ||
| 4358 | int ret; | 4517 | int ret; |
| 4359 | 4518 | ||
| 4360 | if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) | 4519 | ret = ext4_meta_trans_blocks(inode, bpp, 0); |
| 4361 | return ext4_ext_writepage_trans_blocks(inode, bpp); | ||
| 4362 | 4520 | ||
| 4521 | /* Account for data blocks for journalled mode */ | ||
| 4363 | if (ext4_should_journal_data(inode)) | 4522 | if (ext4_should_journal_data(inode)) |
| 4364 | ret = 3 * (bpp + indirects) + 2; | 4523 | ret += bpp; |
| 4365 | else | ||
| 4366 | ret = 2 * (bpp + indirects) + 2; | ||
| 4367 | |||
| 4368 | #ifdef CONFIG_QUOTA | ||
| 4369 | /* We know that structure was already allocated during DQUOT_INIT so | ||
| 4370 | * we will be updating only the data blocks + inodes */ | ||
| 4371 | ret += 2*EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb); | ||
| 4372 | #endif | ||
| 4373 | |||
| 4374 | return ret; | 4524 | return ret; |
| 4375 | } | 4525 | } |
| 4376 | 4526 | ||
| 4377 | /* | 4527 | /* |
| 4528 | * Calculate the journal credits for a chunk of data modification. | ||
| 4529 | * | ||
| 4530 | * This is called from DIO, fallocate or whoever calling | ||
| 4531 | * ext4_get_blocks_wrap() to map/allocate a chunk of contigous disk blocks. | ||
| 4532 | * | ||
| 4533 | * journal buffers for data blocks are not included here, as DIO | ||
| 4534 | * and fallocate do no need to journal data buffers. | ||
| 4535 | */ | ||
| 4536 | int ext4_chunk_trans_blocks(struct inode *inode, int nrblocks) | ||
| 4537 | { | ||
| 4538 | return ext4_meta_trans_blocks(inode, nrblocks, 1); | ||
| 4539 | } | ||
| 4540 | |||
| 4541 | /* | ||
| 4378 | * The caller must have previously called ext4_reserve_inode_write(). | 4542 | * The caller must have previously called ext4_reserve_inode_write(). |
| 4379 | * Give this, we know that the caller already has write access to iloc->bh. | 4543 | * Give this, we know that the caller already has write access to iloc->bh. |
| 4380 | */ | 4544 | */ |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 865e9ddb44d4..e0e3a5eb1ddb 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
| @@ -3282,6 +3282,35 @@ static void ext4_mb_use_group_pa(struct ext4_allocation_context *ac, | |||
| 3282 | } | 3282 | } |
| 3283 | 3283 | ||
| 3284 | /* | 3284 | /* |
| 3285 | * Return the prealloc space that have minimal distance | ||
| 3286 | * from the goal block. @cpa is the prealloc | ||
| 3287 | * space that is having currently known minimal distance | ||
| 3288 | * from the goal block. | ||
| 3289 | */ | ||
| 3290 | static struct ext4_prealloc_space * | ||
| 3291 | ext4_mb_check_group_pa(ext4_fsblk_t goal_block, | ||
| 3292 | struct ext4_prealloc_space *pa, | ||
| 3293 | struct ext4_prealloc_space *cpa) | ||
| 3294 | { | ||
| 3295 | ext4_fsblk_t cur_distance, new_distance; | ||
| 3296 | |||
| 3297 | if (cpa == NULL) { | ||
| 3298 | atomic_inc(&pa->pa_count); | ||
| 3299 | return pa; | ||
| 3300 | } | ||
| 3301 | cur_distance = abs(goal_block - cpa->pa_pstart); | ||
| 3302 | new_distance = abs(goal_block - pa->pa_pstart); | ||
| 3303 | |||
| 3304 | if (cur_distance < new_distance) | ||
| 3305 | return cpa; | ||
| 3306 | |||
| 3307 | /* drop the previous reference */ | ||
| 3308 | atomic_dec(&cpa->pa_count); | ||
| 3309 | atomic_inc(&pa->pa_count); | ||
| 3310 | return pa; | ||
| 3311 | } | ||
| 3312 | |||
| 3313 | /* | ||
| 3285 | * search goal blocks in preallocated space | 3314 | * search goal blocks in preallocated space |
| 3286 | */ | 3315 | */ |
| 3287 | static noinline_for_stack int | 3316 | static noinline_for_stack int |
| @@ -3290,7 +3319,8 @@ ext4_mb_use_preallocated(struct ext4_allocation_context *ac) | |||
| 3290 | int order, i; | 3319 | int order, i; |
| 3291 | struct ext4_inode_info *ei = EXT4_I(ac->ac_inode); | 3320 | struct ext4_inode_info *ei = EXT4_I(ac->ac_inode); |
| 3292 | struct ext4_locality_group *lg; | 3321 | struct ext4_locality_group *lg; |
| 3293 | struct ext4_prealloc_space *pa; | 3322 | struct ext4_prealloc_space *pa, *cpa = NULL; |
| 3323 | ext4_fsblk_t goal_block; | ||
| 3294 | 3324 | ||
| 3295 | /* only data can be preallocated */ | 3325 | /* only data can be preallocated */ |
| 3296 | if (!(ac->ac_flags & EXT4_MB_HINT_DATA)) | 3326 | if (!(ac->ac_flags & EXT4_MB_HINT_DATA)) |
| @@ -3333,6 +3363,13 @@ ext4_mb_use_preallocated(struct ext4_allocation_context *ac) | |||
| 3333 | /* The max size of hash table is PREALLOC_TB_SIZE */ | 3363 | /* The max size of hash table is PREALLOC_TB_SIZE */ |
| 3334 | order = PREALLOC_TB_SIZE - 1; | 3364 | order = PREALLOC_TB_SIZE - 1; |
| 3335 | 3365 | ||
| 3366 | goal_block = ac->ac_g_ex.fe_group * EXT4_BLOCKS_PER_GROUP(ac->ac_sb) + | ||
| 3367 | ac->ac_g_ex.fe_start + | ||
| 3368 | le32_to_cpu(EXT4_SB(ac->ac_sb)->s_es->s_first_data_block); | ||
| 3369 | /* | ||
| 3370 | * search for the prealloc space that is having | ||
| 3371 | * minimal distance from the goal block. | ||
| 3372 | */ | ||
| 3336 | for (i = order; i < PREALLOC_TB_SIZE; i++) { | 3373 | for (i = order; i < PREALLOC_TB_SIZE; i++) { |
| 3337 | rcu_read_lock(); | 3374 | rcu_read_lock(); |
| 3338 | list_for_each_entry_rcu(pa, &lg->lg_prealloc_list[i], | 3375 | list_for_each_entry_rcu(pa, &lg->lg_prealloc_list[i], |
| @@ -3340,17 +3377,19 @@ ext4_mb_use_preallocated(struct ext4_allocation_context *ac) | |||
| 3340 | spin_lock(&pa->pa_lock); | 3377 | spin_lock(&pa->pa_lock); |
| 3341 | if (pa->pa_deleted == 0 && | 3378 | if (pa->pa_deleted == 0 && |
| 3342 | pa->pa_free >= ac->ac_o_ex.fe_len) { | 3379 | pa->pa_free >= ac->ac_o_ex.fe_len) { |
| 3343 | atomic_inc(&pa->pa_count); | 3380 | |
| 3344 | ext4_mb_use_group_pa(ac, pa); | 3381 | cpa = ext4_mb_check_group_pa(goal_block, |
| 3345 | spin_unlock(&pa->pa_lock); | 3382 | pa, cpa); |
| 3346 | ac->ac_criteria = 20; | ||
| 3347 | rcu_read_unlock(); | ||
| 3348 | return 1; | ||
| 3349 | } | 3383 | } |
| 3350 | spin_unlock(&pa->pa_lock); | 3384 | spin_unlock(&pa->pa_lock); |
| 3351 | } | 3385 | } |
| 3352 | rcu_read_unlock(); | 3386 | rcu_read_unlock(); |
| 3353 | } | 3387 | } |
| 3388 | if (cpa) { | ||
| 3389 | ext4_mb_use_group_pa(ac, cpa); | ||
| 3390 | ac->ac_criteria = 20; | ||
| 3391 | return 1; | ||
| 3392 | } | ||
| 3354 | return 0; | 3393 | return 0; |
| 3355 | } | 3394 | } |
| 3356 | 3395 | ||
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c index b9e077ba07e9..46fc0b5b12ba 100644 --- a/fs/ext4/migrate.c +++ b/fs/ext4/migrate.c | |||
| @@ -53,7 +53,8 @@ static int finish_range(handle_t *handle, struct inode *inode, | |||
| 53 | * credit. But below we try to not accumalate too much | 53 | * credit. But below we try to not accumalate too much |
| 54 | * of them by restarting the journal. | 54 | * of them by restarting the journal. |
| 55 | */ | 55 | */ |
| 56 | needed = ext4_ext_calc_credits_for_insert(inode, path); | 56 | needed = ext4_ext_calc_credits_for_single_extent(inode, |
| 57 | lb->last_block - lb->first_block + 1, path); | ||
| 57 | 58 | ||
| 58 | /* | 59 | /* |
| 59 | * Make sure the credit we accumalated is not really high | 60 | * Make sure the credit we accumalated is not really high |
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 0a9265164265..b3d35604ea18 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
| @@ -773,7 +773,8 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input) | |||
| 773 | 773 | ||
| 774 | if (reserved_gdb || gdb_off == 0) { | 774 | if (reserved_gdb || gdb_off == 0) { |
| 775 | if (!EXT4_HAS_COMPAT_FEATURE(sb, | 775 | if (!EXT4_HAS_COMPAT_FEATURE(sb, |
| 776 | EXT4_FEATURE_COMPAT_RESIZE_INODE)){ | 776 | EXT4_FEATURE_COMPAT_RESIZE_INODE) |
| 777 | || !le16_to_cpu(es->s_reserved_gdt_blocks)) { | ||
| 777 | ext4_warning(sb, __func__, | 778 | ext4_warning(sb, __func__, |
| 778 | "No reserved GDT blocks, can't resize"); | 779 | "No reserved GDT blocks, can't resize"); |
| 779 | return -EPERM; | 780 | return -EPERM; |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index d5d77958b861..566344b926b7 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
| @@ -568,6 +568,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) | |||
| 568 | #endif | 568 | #endif |
| 569 | ei->i_block_alloc_info = NULL; | 569 | ei->i_block_alloc_info = NULL; |
| 570 | ei->vfs_inode.i_version = 1; | 570 | ei->vfs_inode.i_version = 1; |
| 571 | ei->vfs_inode.i_data.writeback_index = 0; | ||
| 571 | memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache)); | 572 | memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache)); |
| 572 | INIT_LIST_HEAD(&ei->i_prealloc_list); | 573 | INIT_LIST_HEAD(&ei->i_prealloc_list); |
| 573 | spin_lock_init(&ei->i_prealloc_lock); | 574 | spin_lock_init(&ei->i_prealloc_lock); |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 6d266d793e2c..80ff3381fa21 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
| @@ -562,26 +562,23 @@ static int fat_write_inode(struct inode *inode, int wait) | |||
| 562 | struct buffer_head *bh; | 562 | struct buffer_head *bh; |
| 563 | struct msdos_dir_entry *raw_entry; | 563 | struct msdos_dir_entry *raw_entry; |
| 564 | loff_t i_pos; | 564 | loff_t i_pos; |
| 565 | int err = 0; | 565 | int err; |
| 566 | 566 | ||
| 567 | retry: | 567 | retry: |
| 568 | i_pos = MSDOS_I(inode)->i_pos; | 568 | i_pos = MSDOS_I(inode)->i_pos; |
| 569 | if (inode->i_ino == MSDOS_ROOT_INO || !i_pos) | 569 | if (inode->i_ino == MSDOS_ROOT_INO || !i_pos) |
| 570 | return 0; | 570 | return 0; |
| 571 | 571 | ||
| 572 | lock_super(sb); | ||
| 573 | bh = sb_bread(sb, i_pos >> sbi->dir_per_block_bits); | 572 | bh = sb_bread(sb, i_pos >> sbi->dir_per_block_bits); |
| 574 | if (!bh) { | 573 | if (!bh) { |
| 575 | printk(KERN_ERR "FAT: unable to read inode block " | 574 | printk(KERN_ERR "FAT: unable to read inode block " |
| 576 | "for updating (i_pos %lld)\n", i_pos); | 575 | "for updating (i_pos %lld)\n", i_pos); |
| 577 | err = -EIO; | 576 | return -EIO; |
| 578 | goto out; | ||
| 579 | } | 577 | } |
| 580 | spin_lock(&sbi->inode_hash_lock); | 578 | spin_lock(&sbi->inode_hash_lock); |
| 581 | if (i_pos != MSDOS_I(inode)->i_pos) { | 579 | if (i_pos != MSDOS_I(inode)->i_pos) { |
| 582 | spin_unlock(&sbi->inode_hash_lock); | 580 | spin_unlock(&sbi->inode_hash_lock); |
| 583 | brelse(bh); | 581 | brelse(bh); |
| 584 | unlock_super(sb); | ||
| 585 | goto retry; | 582 | goto retry; |
| 586 | } | 583 | } |
| 587 | 584 | ||
| @@ -607,11 +604,10 @@ retry: | |||
| 607 | } | 604 | } |
| 608 | spin_unlock(&sbi->inode_hash_lock); | 605 | spin_unlock(&sbi->inode_hash_lock); |
| 609 | mark_buffer_dirty(bh); | 606 | mark_buffer_dirty(bh); |
| 607 | err = 0; | ||
| 610 | if (wait) | 608 | if (wait) |
| 611 | err = sync_dirty_buffer(bh); | 609 | err = sync_dirty_buffer(bh); |
| 612 | brelse(bh); | 610 | brelse(bh); |
| 613 | out: | ||
| 614 | unlock_super(sb); | ||
| 615 | return err; | 611 | return err; |
| 616 | } | 612 | } |
| 617 | 613 | ||
diff --git a/fs/inode.c b/fs/inode.c index b6726f644530..0487ddba1397 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
| @@ -166,6 +166,7 @@ static struct inode *alloc_inode(struct super_block *sb) | |||
| 166 | mapping_set_gfp_mask(mapping, GFP_HIGHUSER_PAGECACHE); | 166 | mapping_set_gfp_mask(mapping, GFP_HIGHUSER_PAGECACHE); |
| 167 | mapping->assoc_mapping = NULL; | 167 | mapping->assoc_mapping = NULL; |
| 168 | mapping->backing_dev_info = &default_backing_dev_info; | 168 | mapping->backing_dev_info = &default_backing_dev_info; |
| 169 | mapping->writeback_index = 0; | ||
| 169 | 170 | ||
| 170 | /* | 171 | /* |
| 171 | * If the block_device provides a backing_dev_info for client | 172 | * If the block_device provides a backing_dev_info for client |
diff --git a/fs/ioprio.c b/fs/ioprio.c index c4a1c3c65aac..da3cc460d4df 100644 --- a/fs/ioprio.c +++ b/fs/ioprio.c | |||
| @@ -115,11 +115,11 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio) | |||
| 115 | pgrp = task_pgrp(current); | 115 | pgrp = task_pgrp(current); |
| 116 | else | 116 | else |
| 117 | pgrp = find_vpid(who); | 117 | pgrp = find_vpid(who); |
| 118 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { | 118 | do_each_pid_thread(pgrp, PIDTYPE_PGID, p) { |
| 119 | ret = set_task_ioprio(p, ioprio); | 119 | ret = set_task_ioprio(p, ioprio); |
| 120 | if (ret) | 120 | if (ret) |
| 121 | break; | 121 | break; |
| 122 | } while_each_pid_task(pgrp, PIDTYPE_PGID, p); | 122 | } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); |
| 123 | break; | 123 | break; |
| 124 | case IOPRIO_WHO_USER: | 124 | case IOPRIO_WHO_USER: |
| 125 | if (!who) | 125 | if (!who) |
| @@ -204,7 +204,7 @@ asmlinkage long sys_ioprio_get(int which, int who) | |||
| 204 | pgrp = task_pgrp(current); | 204 | pgrp = task_pgrp(current); |
| 205 | else | 205 | else |
| 206 | pgrp = find_vpid(who); | 206 | pgrp = find_vpid(who); |
| 207 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { | 207 | do_each_pid_thread(pgrp, PIDTYPE_PGID, p) { |
| 208 | tmpio = get_task_ioprio(p); | 208 | tmpio = get_task_ioprio(p); |
| 209 | if (tmpio < 0) | 209 | if (tmpio < 0) |
| 210 | continue; | 210 | continue; |
| @@ -212,7 +212,7 @@ asmlinkage long sys_ioprio_get(int which, int who) | |||
| 212 | ret = tmpio; | 212 | ret = tmpio; |
| 213 | else | 213 | else |
| 214 | ret = ioprio_best(ret, tmpio); | 214 | ret = ioprio_best(ret, tmpio); |
| 215 | } while_each_pid_task(pgrp, PIDTYPE_PGID, p); | 215 | } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); |
| 216 | break; | 216 | break; |
| 217 | case IOPRIO_WHO_USER: | 217 | case IOPRIO_WHO_USER: |
| 218 | if (!who) | 218 | if (!who) |
diff --git a/fs/jffs2/jffs2_fs_i.h b/fs/jffs2/jffs2_fs_i.h index 31559f45fdde..4c41db91eaa4 100644 --- a/fs/jffs2/jffs2_fs_i.h +++ b/fs/jffs2/jffs2_fs_i.h | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #ifndef _JFFS2_FS_I | 12 | #ifndef _JFFS2_FS_I |
| 13 | #define _JFFS2_FS_I | 13 | #define _JFFS2_FS_I |
| 14 | 14 | ||
| 15 | #include <linux/version.h> | ||
| 16 | #include <linux/rbtree.h> | 15 | #include <linux/rbtree.h> |
| 17 | #include <linux/posix_acl.h> | 16 | #include <linux/posix_acl.h> |
| 18 | #include <linux/mutex.h> | 17 | #include <linux/mutex.h> |
diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c index b6ed38380ab8..54b8b4140c8f 100644 --- a/fs/nfsd/nfs4acl.c +++ b/fs/nfsd/nfs4acl.c | |||
| @@ -443,7 +443,7 @@ init_state(struct posix_acl_state *state, int cnt) | |||
| 443 | * enough space for either: | 443 | * enough space for either: |
| 444 | */ | 444 | */ |
| 445 | alloc = sizeof(struct posix_ace_state_array) | 445 | alloc = sizeof(struct posix_ace_state_array) |
| 446 | + cnt*sizeof(struct posix_ace_state); | 446 | + cnt*sizeof(struct posix_user_ace_state); |
| 447 | state->users = kzalloc(alloc, GFP_KERNEL); | 447 | state->users = kzalloc(alloc, GFP_KERNEL); |
| 448 | if (!state->users) | 448 | if (!state->users) |
| 449 | return -ENOMEM; | 449 | return -ENOMEM; |
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 2e51adac65de..e5b51ffafc6c 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
| @@ -867,11 +867,6 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
| 867 | int slack_bytes; | 867 | int slack_bytes; |
| 868 | __be32 status; | 868 | __be32 status; |
| 869 | 869 | ||
| 870 | status = nfserr_resource; | ||
| 871 | cstate = cstate_alloc(); | ||
| 872 | if (cstate == NULL) | ||
| 873 | goto out; | ||
| 874 | |||
| 875 | resp->xbuf = &rqstp->rq_res; | 870 | resp->xbuf = &rqstp->rq_res; |
| 876 | resp->p = rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len; | 871 | resp->p = rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len; |
| 877 | resp->tagp = resp->p; | 872 | resp->tagp = resp->p; |
| @@ -890,6 +885,11 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
| 890 | if (args->minorversion > NFSD_SUPPORTED_MINOR_VERSION) | 885 | if (args->minorversion > NFSD_SUPPORTED_MINOR_VERSION) |
| 891 | goto out; | 886 | goto out; |
| 892 | 887 | ||
| 888 | status = nfserr_resource; | ||
| 889 | cstate = cstate_alloc(); | ||
| 890 | if (cstate == NULL) | ||
| 891 | goto out; | ||
| 892 | |||
| 893 | status = nfs_ok; | 893 | status = nfs_ok; |
| 894 | while (!status && resp->opcnt < args->opcnt) { | 894 | while (!status && resp->opcnt < args->opcnt) { |
| 895 | op = &args->ops[resp->opcnt++]; | 895 | op = &args->ops[resp->opcnt++]; |
| @@ -957,9 +957,9 @@ encode_op: | |||
| 957 | nfsd4_increment_op_stats(op->opnum); | 957 | nfsd4_increment_op_stats(op->opnum); |
| 958 | } | 958 | } |
| 959 | 959 | ||
| 960 | cstate_free(cstate); | ||
| 960 | out: | 961 | out: |
| 961 | nfsd4_release_compoundargs(args); | 962 | nfsd4_release_compoundargs(args); |
| 962 | cstate_free(cstate); | ||
| 963 | dprintk("nfsv4 compound returned %d\n", ntohl(status)); | 963 | dprintk("nfsv4 compound returned %d\n", ntohl(status)); |
| 964 | return status; | 964 | return status; |
| 965 | } | 965 | } |
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c index e1781c8b1650..9e8a95be7a1e 100644 --- a/fs/ntfs/namei.c +++ b/fs/ntfs/namei.c | |||
| @@ -174,7 +174,6 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent, | |||
| 174 | // TODO: Consider moving this lot to a separate function! (AIA) | 174 | // TODO: Consider moving this lot to a separate function! (AIA) |
| 175 | handle_name: | 175 | handle_name: |
| 176 | { | 176 | { |
| 177 | struct dentry *real_dent, *new_dent; | ||
| 178 | MFT_RECORD *m; | 177 | MFT_RECORD *m; |
| 179 | ntfs_attr_search_ctx *ctx; | 178 | ntfs_attr_search_ctx *ctx; |
| 180 | ntfs_inode *ni = NTFS_I(dent_inode); | 179 | ntfs_inode *ni = NTFS_I(dent_inode); |
| @@ -255,93 +254,9 @@ handle_name: | |||
| 255 | } | 254 | } |
| 256 | nls_name.hash = full_name_hash(nls_name.name, nls_name.len); | 255 | nls_name.hash = full_name_hash(nls_name.name, nls_name.len); |
| 257 | 256 | ||
| 258 | /* | 257 | dent = d_add_ci(dent, dent_inode, &nls_name); |
| 259 | * Note: No need for dent->d_lock lock as i_mutex is held on the | ||
| 260 | * parent inode. | ||
| 261 | */ | ||
| 262 | |||
| 263 | /* Does a dentry matching the nls_name exist already? */ | ||
| 264 | real_dent = d_lookup(dent->d_parent, &nls_name); | ||
| 265 | /* If not, create it now. */ | ||
| 266 | if (!real_dent) { | ||
| 267 | real_dent = d_alloc(dent->d_parent, &nls_name); | ||
| 268 | kfree(nls_name.name); | ||
| 269 | if (!real_dent) { | ||
| 270 | err = -ENOMEM; | ||
| 271 | goto err_out; | ||
| 272 | } | ||
| 273 | new_dent = d_splice_alias(dent_inode, real_dent); | ||
| 274 | if (new_dent) | ||
| 275 | dput(real_dent); | ||
| 276 | else | ||
| 277 | new_dent = real_dent; | ||
| 278 | ntfs_debug("Done. (Created new dentry.)"); | ||
| 279 | return new_dent; | ||
| 280 | } | ||
| 281 | kfree(nls_name.name); | 258 | kfree(nls_name.name); |
| 282 | /* Matching dentry exists, check if it is negative. */ | 259 | return dent; |
| 283 | if (real_dent->d_inode) { | ||
| 284 | if (unlikely(real_dent->d_inode != dent_inode)) { | ||
| 285 | /* This can happen because bad inodes are unhashed. */ | ||
| 286 | BUG_ON(!is_bad_inode(dent_inode)); | ||
| 287 | BUG_ON(!is_bad_inode(real_dent->d_inode)); | ||
| 288 | } | ||
| 289 | /* | ||
| 290 | * Already have the inode and the dentry attached, decrement | ||
| 291 | * the reference count to balance the ntfs_iget() we did | ||
| 292 | * earlier on. We found the dentry using d_lookup() so it | ||
| 293 | * cannot be disconnected and thus we do not need to worry | ||
| 294 | * about any NFS/disconnectedness issues here. | ||
| 295 | */ | ||
| 296 | iput(dent_inode); | ||
| 297 | ntfs_debug("Done. (Already had inode and dentry.)"); | ||
| 298 | return real_dent; | ||
| 299 | } | ||
| 300 | /* | ||
| 301 | * Negative dentry: instantiate it unless the inode is a directory and | ||
| 302 | * has a 'disconnected' dentry (i.e. IS_ROOT and DCACHE_DISCONNECTED), | ||
| 303 | * in which case d_move() that in place of the found dentry. | ||
| 304 | */ | ||
| 305 | if (!S_ISDIR(dent_inode->i_mode)) { | ||
| 306 | /* Not a directory; everything is easy. */ | ||
| 307 | d_instantiate(real_dent, dent_inode); | ||
| 308 | ntfs_debug("Done. (Already had negative file dentry.)"); | ||
| 309 | return real_dent; | ||
| 310 | } | ||
| 311 | spin_lock(&dcache_lock); | ||
| 312 | if (list_empty(&dent_inode->i_dentry)) { | ||
| 313 | /* | ||
| 314 | * Directory without a 'disconnected' dentry; we need to do | ||
| 315 | * d_instantiate() by hand because it takes dcache_lock which | ||
| 316 | * we already hold. | ||
| 317 | */ | ||
| 318 | list_add(&real_dent->d_alias, &dent_inode->i_dentry); | ||
| 319 | real_dent->d_inode = dent_inode; | ||
| 320 | spin_unlock(&dcache_lock); | ||
| 321 | security_d_instantiate(real_dent, dent_inode); | ||
| 322 | ntfs_debug("Done. (Already had negative directory dentry.)"); | ||
| 323 | return real_dent; | ||
| 324 | } | ||
| 325 | /* | ||
| 326 | * Directory with a 'disconnected' dentry; get a reference to the | ||
| 327 | * 'disconnected' dentry. | ||
| 328 | */ | ||
| 329 | new_dent = list_entry(dent_inode->i_dentry.next, struct dentry, | ||
| 330 | d_alias); | ||
| 331 | dget_locked(new_dent); | ||
| 332 | spin_unlock(&dcache_lock); | ||
| 333 | /* Do security vodoo. */ | ||
| 334 | security_d_instantiate(real_dent, dent_inode); | ||
| 335 | /* Move new_dent in place of real_dent. */ | ||
| 336 | d_move(new_dent, real_dent); | ||
| 337 | /* Balance the ntfs_iget() we did above. */ | ||
| 338 | iput(dent_inode); | ||
| 339 | /* Throw away real_dent. */ | ||
| 340 | dput(real_dent); | ||
| 341 | /* Use new_dent as the actual dentry. */ | ||
| 342 | ntfs_debug("Done. (Already had negative, disconnected directory " | ||
| 343 | "dentry.)"); | ||
| 344 | return new_dent; | ||
| 345 | 260 | ||
| 346 | eio_err_out: | 261 | eio_err_out: |
| 347 | ntfs_error(vol->sb, "Illegal file name attribute. Run chkdsk."); | 262 | ntfs_error(vol->sb, "Illegal file name attribute. Run chkdsk."); |
diff --git a/fs/ntfs/usnjrnl.h b/fs/ntfs/usnjrnl.h index 3a8af75351e8..4087fbdac327 100644 --- a/fs/ntfs/usnjrnl.h +++ b/fs/ntfs/usnjrnl.h | |||
| @@ -113,7 +113,7 @@ typedef struct { | |||
| 113 | * Reason flags (32-bit). Cumulative flags describing the change(s) to the | 113 | * Reason flags (32-bit). Cumulative flags describing the change(s) to the |
| 114 | * file since it was last opened. I think the names speak for themselves but | 114 | * file since it was last opened. I think the names speak for themselves but |
| 115 | * if you disagree check out the descriptions in the Linux NTFS project NTFS | 115 | * if you disagree check out the descriptions in the Linux NTFS project NTFS |
| 116 | * documentation: http://linux-ntfs.sourceforge.net/ntfs/files/usnjrnl.html | 116 | * documentation: http://www.linux-ntfs.org/ |
| 117 | */ | 117 | */ |
| 118 | enum { | 118 | enum { |
| 119 | USN_REASON_DATA_OVERWRITE = const_cpu_to_le32(0x00000001), | 119 | USN_REASON_DATA_OVERWRITE = const_cpu_to_le32(0x00000001), |
| @@ -145,7 +145,7 @@ typedef le32 USN_REASON_FLAGS; | |||
| 145 | * Source info flags (32-bit). Information about the source of the change(s) | 145 | * Source info flags (32-bit). Information about the source of the change(s) |
| 146 | * to the file. For detailed descriptions of what these mean, see the Linux | 146 | * to the file. For detailed descriptions of what these mean, see the Linux |
| 147 | * NTFS project NTFS documentation: | 147 | * NTFS project NTFS documentation: |
| 148 | * http://linux-ntfs.sourceforge.net/ntfs/files/usnjrnl.html | 148 | * http://www.linux-ntfs.org/ |
| 149 | */ | 149 | */ |
| 150 | enum { | 150 | enum { |
| 151 | USN_SOURCE_DATA_MANAGEMENT = const_cpu_to_le32(0x00000001), | 151 | USN_SOURCE_DATA_MANAGEMENT = const_cpu_to_le32(0x00000001), |
diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c index d8bfa0eb41b2..52276c02f710 100644 --- a/fs/ocfs2/cluster/netdebug.c +++ b/fs/ocfs2/cluster/netdebug.c | |||
| @@ -138,20 +138,20 @@ static int nst_seq_show(struct seq_file *seq, void *v) | |||
| 138 | " message id: %d\n" | 138 | " message id: %d\n" |
| 139 | " message type: %u\n" | 139 | " message type: %u\n" |
| 140 | " message key: 0x%08x\n" | 140 | " message key: 0x%08x\n" |
| 141 | " sock acquiry: %lu.%lu\n" | 141 | " sock acquiry: %lu.%ld\n" |
| 142 | " send start: %lu.%lu\n" | 142 | " send start: %lu.%ld\n" |
| 143 | " wait start: %lu.%lu\n", | 143 | " wait start: %lu.%ld\n", |
| 144 | nst, (unsigned long)nst->st_task->pid, | 144 | nst, (unsigned long)nst->st_task->pid, |
| 145 | (unsigned long)nst->st_task->tgid, | 145 | (unsigned long)nst->st_task->tgid, |
| 146 | nst->st_task->comm, nst->st_node, | 146 | nst->st_task->comm, nst->st_node, |
| 147 | nst->st_sc, nst->st_id, nst->st_msg_type, | 147 | nst->st_sc, nst->st_id, nst->st_msg_type, |
| 148 | nst->st_msg_key, | 148 | nst->st_msg_key, |
| 149 | nst->st_sock_time.tv_sec, | 149 | nst->st_sock_time.tv_sec, |
| 150 | (unsigned long)nst->st_sock_time.tv_usec, | 150 | (long)nst->st_sock_time.tv_usec, |
| 151 | nst->st_send_time.tv_sec, | 151 | nst->st_send_time.tv_sec, |
| 152 | (unsigned long)nst->st_send_time.tv_usec, | 152 | (long)nst->st_send_time.tv_usec, |
| 153 | nst->st_status_time.tv_sec, | 153 | nst->st_status_time.tv_sec, |
| 154 | nst->st_status_time.tv_usec); | 154 | (long)nst->st_status_time.tv_usec); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | spin_unlock(&o2net_debug_lock); | 157 | spin_unlock(&o2net_debug_lock); |
| @@ -276,7 +276,7 @@ static void *sc_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
| 276 | return sc; /* unused, just needs to be null when done */ | 276 | return sc; /* unused, just needs to be null when done */ |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | #define TV_SEC_USEC(TV) TV.tv_sec, (unsigned long)TV.tv_usec | 279 | #define TV_SEC_USEC(TV) TV.tv_sec, (long)TV.tv_usec |
| 280 | 280 | ||
| 281 | static int sc_seq_show(struct seq_file *seq, void *v) | 281 | static int sc_seq_show(struct seq_file *seq, void *v) |
| 282 | { | 282 | { |
| @@ -309,12 +309,12 @@ static int sc_seq_show(struct seq_file *seq, void *v) | |||
| 309 | " remote node: %s\n" | 309 | " remote node: %s\n" |
| 310 | " page off: %zu\n" | 310 | " page off: %zu\n" |
| 311 | " handshake ok: %u\n" | 311 | " handshake ok: %u\n" |
| 312 | " timer: %lu.%lu\n" | 312 | " timer: %lu.%ld\n" |
| 313 | " data ready: %lu.%lu\n" | 313 | " data ready: %lu.%ld\n" |
| 314 | " advance start: %lu.%lu\n" | 314 | " advance start: %lu.%ld\n" |
| 315 | " advance stop: %lu.%lu\n" | 315 | " advance stop: %lu.%ld\n" |
| 316 | " func start: %lu.%lu\n" | 316 | " func start: %lu.%ld\n" |
| 317 | " func stop: %lu.%lu\n" | 317 | " func stop: %lu.%ld\n" |
| 318 | " func key: %u\n" | 318 | " func key: %u\n" |
| 319 | " func type: %u\n", | 319 | " func type: %u\n", |
| 320 | sc, | 320 | sc, |
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index a27d61581bd6..2bcf706d9dd3 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c | |||
| @@ -143,8 +143,8 @@ static void o2net_sc_postpone_idle(struct o2net_sock_container *sc); | |||
| 143 | static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc); | 143 | static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc); |
| 144 | 144 | ||
| 145 | #ifdef CONFIG_DEBUG_FS | 145 | #ifdef CONFIG_DEBUG_FS |
| 146 | void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype, | 146 | static void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype, |
| 147 | u32 msgkey, struct task_struct *task, u8 node) | 147 | u32 msgkey, struct task_struct *task, u8 node) |
| 148 | { | 148 | { |
| 149 | INIT_LIST_HEAD(&nst->st_net_debug_item); | 149 | INIT_LIST_HEAD(&nst->st_net_debug_item); |
| 150 | nst->st_task = task; | 150 | nst->st_task = task; |
| @@ -153,31 +153,61 @@ void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype, | |||
| 153 | nst->st_node = node; | 153 | nst->st_node = node; |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | void o2net_set_nst_sock_time(struct o2net_send_tracking *nst) | 156 | static void o2net_set_nst_sock_time(struct o2net_send_tracking *nst) |
| 157 | { | 157 | { |
| 158 | do_gettimeofday(&nst->st_sock_time); | 158 | do_gettimeofday(&nst->st_sock_time); |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | void o2net_set_nst_send_time(struct o2net_send_tracking *nst) | 161 | static void o2net_set_nst_send_time(struct o2net_send_tracking *nst) |
| 162 | { | 162 | { |
| 163 | do_gettimeofday(&nst->st_send_time); | 163 | do_gettimeofday(&nst->st_send_time); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | void o2net_set_nst_status_time(struct o2net_send_tracking *nst) | 166 | static void o2net_set_nst_status_time(struct o2net_send_tracking *nst) |
| 167 | { | 167 | { |
| 168 | do_gettimeofday(&nst->st_status_time); | 168 | do_gettimeofday(&nst->st_status_time); |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | void o2net_set_nst_sock_container(struct o2net_send_tracking *nst, | 171 | static void o2net_set_nst_sock_container(struct o2net_send_tracking *nst, |
| 172 | struct o2net_sock_container *sc) | 172 | struct o2net_sock_container *sc) |
| 173 | { | 173 | { |
| 174 | nst->st_sc = sc; | 174 | nst->st_sc = sc; |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | void o2net_set_nst_msg_id(struct o2net_send_tracking *nst, u32 msg_id) | 177 | static void o2net_set_nst_msg_id(struct o2net_send_tracking *nst, u32 msg_id) |
| 178 | { | 178 | { |
| 179 | nst->st_id = msg_id; | 179 | nst->st_id = msg_id; |
| 180 | } | 180 | } |
| 181 | |||
| 182 | #else /* CONFIG_DEBUG_FS */ | ||
| 183 | |||
| 184 | static inline void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype, | ||
| 185 | u32 msgkey, struct task_struct *task, u8 node) | ||
| 186 | { | ||
| 187 | } | ||
| 188 | |||
| 189 | static inline void o2net_set_nst_sock_time(struct o2net_send_tracking *nst) | ||
| 190 | { | ||
| 191 | } | ||
| 192 | |||
| 193 | static inline void o2net_set_nst_send_time(struct o2net_send_tracking *nst) | ||
| 194 | { | ||
| 195 | } | ||
| 196 | |||
| 197 | static inline void o2net_set_nst_status_time(struct o2net_send_tracking *nst) | ||
| 198 | { | ||
| 199 | } | ||
| 200 | |||
| 201 | static inline void o2net_set_nst_sock_container(struct o2net_send_tracking *nst, | ||
| 202 | struct o2net_sock_container *sc) | ||
| 203 | { | ||
| 204 | } | ||
| 205 | |||
| 206 | static inline void o2net_set_nst_msg_id(struct o2net_send_tracking *nst, | ||
| 207 | u32 msg_id) | ||
| 208 | { | ||
| 209 | } | ||
| 210 | |||
| 181 | #endif /* CONFIG_DEBUG_FS */ | 211 | #endif /* CONFIG_DEBUG_FS */ |
| 182 | 212 | ||
| 183 | static inline int o2net_reconnect_delay(void) | 213 | static inline int o2net_reconnect_delay(void) |
diff --git a/fs/ocfs2/cluster/tcp_internal.h b/fs/ocfs2/cluster/tcp_internal.h index 18307ff81b77..8d58cfe410b1 100644 --- a/fs/ocfs2/cluster/tcp_internal.h +++ b/fs/ocfs2/cluster/tcp_internal.h | |||
| @@ -224,42 +224,10 @@ struct o2net_send_tracking { | |||
| 224 | struct timeval st_send_time; | 224 | struct timeval st_send_time; |
| 225 | struct timeval st_status_time; | 225 | struct timeval st_status_time; |
| 226 | }; | 226 | }; |
| 227 | |||
| 228 | void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype, | ||
| 229 | u32 msgkey, struct task_struct *task, u8 node); | ||
| 230 | void o2net_set_nst_sock_time(struct o2net_send_tracking *nst); | ||
| 231 | void o2net_set_nst_send_time(struct o2net_send_tracking *nst); | ||
| 232 | void o2net_set_nst_status_time(struct o2net_send_tracking *nst); | ||
| 233 | void o2net_set_nst_sock_container(struct o2net_send_tracking *nst, | ||
| 234 | struct o2net_sock_container *sc); | ||
| 235 | void o2net_set_nst_msg_id(struct o2net_send_tracking *nst, u32 msg_id); | ||
| 236 | |||
| 237 | #else | 227 | #else |
| 238 | struct o2net_send_tracking { | 228 | struct o2net_send_tracking { |
| 239 | u32 dummy; | 229 | u32 dummy; |
| 240 | }; | 230 | }; |
| 241 | |||
| 242 | static inline void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype, | ||
| 243 | u32 msgkey, struct task_struct *task, u8 node) | ||
| 244 | { | ||
| 245 | } | ||
| 246 | static inline void o2net_set_nst_sock_time(struct o2net_send_tracking *nst) | ||
| 247 | { | ||
| 248 | } | ||
| 249 | static inline void o2net_set_nst_send_time(struct o2net_send_tracking *nst) | ||
| 250 | { | ||
| 251 | } | ||
| 252 | static inline void o2net_set_nst_status_time(struct o2net_send_tracking *nst) | ||
| 253 | { | ||
| 254 | } | ||
| 255 | static inline void o2net_set_nst_sock_container(struct o2net_send_tracking *nst, | ||
| 256 | struct o2net_sock_container *sc) | ||
| 257 | { | ||
| 258 | } | ||
| 259 | static inline void o2net_set_nst_msg_id(struct o2net_send_tracking *nst, | ||
| 260 | u32 msg_id) | ||
| 261 | { | ||
| 262 | } | ||
| 263 | #endif /* CONFIG_DEBUG_FS */ | 231 | #endif /* CONFIG_DEBUG_FS */ |
| 264 | 232 | ||
| 265 | #endif /* O2CLUSTER_TCP_INTERNAL_H */ | 233 | #endif /* O2CLUSTER_TCP_INTERNAL_H */ |
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index 8a1875848080..9cce563fd627 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c | |||
| @@ -1300,7 +1300,6 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh, | |||
| 1300 | di->i_size = cpu_to_le64(sb->s_blocksize); | 1300 | di->i_size = cpu_to_le64(sb->s_blocksize); |
| 1301 | di->i_ctime = di->i_mtime = cpu_to_le64(dir->i_ctime.tv_sec); | 1301 | di->i_ctime = di->i_mtime = cpu_to_le64(dir->i_ctime.tv_sec); |
| 1302 | di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(dir->i_ctime.tv_nsec); | 1302 | di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(dir->i_ctime.tv_nsec); |
| 1303 | dir->i_blocks = ocfs2_inode_sector_count(dir); | ||
| 1304 | 1303 | ||
| 1305 | /* | 1304 | /* |
| 1306 | * This should never fail as our extent list is empty and all | 1305 | * This should never fail as our extent list is empty and all |
| @@ -1310,9 +1309,15 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh, | |||
| 1310 | NULL); | 1309 | NULL); |
| 1311 | if (ret) { | 1310 | if (ret) { |
| 1312 | mlog_errno(ret); | 1311 | mlog_errno(ret); |
| 1313 | goto out; | 1312 | goto out_commit; |
| 1314 | } | 1313 | } |
| 1315 | 1314 | ||
| 1315 | /* | ||
| 1316 | * Set i_blocks after the extent insert for the most up to | ||
| 1317 | * date ip_clusters value. | ||
| 1318 | */ | ||
| 1319 | dir->i_blocks = ocfs2_inode_sector_count(dir); | ||
| 1320 | |||
| 1316 | ret = ocfs2_journal_dirty(handle, di_bh); | 1321 | ret = ocfs2_journal_dirty(handle, di_bh); |
| 1317 | if (ret) { | 1322 | if (ret) { |
| 1318 | mlog_errno(ret); | 1323 | mlog_errno(ret); |
| @@ -1336,7 +1341,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh, | |||
| 1336 | len, 0, NULL); | 1341 | len, 0, NULL); |
| 1337 | if (ret) { | 1342 | if (ret) { |
| 1338 | mlog_errno(ret); | 1343 | mlog_errno(ret); |
| 1339 | goto out; | 1344 | goto out_commit; |
| 1340 | } | 1345 | } |
| 1341 | } | 1346 | } |
| 1342 | 1347 | ||
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 7a37240f7a31..c47bc2a809c2 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c | |||
| @@ -1418,13 +1418,13 @@ int ocfs2_mark_dead_nodes(struct ocfs2_super *osb) | |||
| 1418 | { | 1418 | { |
| 1419 | unsigned int node_num; | 1419 | unsigned int node_num; |
| 1420 | int status, i; | 1420 | int status, i; |
| 1421 | u32 gen; | ||
| 1421 | struct buffer_head *bh = NULL; | 1422 | struct buffer_head *bh = NULL; |
| 1422 | struct ocfs2_dinode *di; | 1423 | struct ocfs2_dinode *di; |
| 1423 | 1424 | ||
| 1424 | /* This is called with the super block cluster lock, so we | 1425 | /* This is called with the super block cluster lock, so we |
| 1425 | * know that the slot map can't change underneath us. */ | 1426 | * know that the slot map can't change underneath us. */ |
| 1426 | 1427 | ||
| 1427 | spin_lock(&osb->osb_lock); | ||
| 1428 | for (i = 0; i < osb->max_slots; i++) { | 1428 | for (i = 0; i < osb->max_slots; i++) { |
| 1429 | /* Read journal inode to get the recovery generation */ | 1429 | /* Read journal inode to get the recovery generation */ |
| 1430 | status = ocfs2_read_journal_inode(osb, i, &bh, NULL); | 1430 | status = ocfs2_read_journal_inode(osb, i, &bh, NULL); |
| @@ -1433,23 +1433,31 @@ int ocfs2_mark_dead_nodes(struct ocfs2_super *osb) | |||
| 1433 | goto bail; | 1433 | goto bail; |
| 1434 | } | 1434 | } |
| 1435 | di = (struct ocfs2_dinode *)bh->b_data; | 1435 | di = (struct ocfs2_dinode *)bh->b_data; |
| 1436 | osb->slot_recovery_generations[i] = | 1436 | gen = ocfs2_get_recovery_generation(di); |
| 1437 | ocfs2_get_recovery_generation(di); | ||
| 1438 | brelse(bh); | 1437 | brelse(bh); |
| 1439 | bh = NULL; | 1438 | bh = NULL; |
| 1440 | 1439 | ||
| 1440 | spin_lock(&osb->osb_lock); | ||
| 1441 | osb->slot_recovery_generations[i] = gen; | ||
| 1442 | |||
| 1441 | mlog(0, "Slot %u recovery generation is %u\n", i, | 1443 | mlog(0, "Slot %u recovery generation is %u\n", i, |
| 1442 | osb->slot_recovery_generations[i]); | 1444 | osb->slot_recovery_generations[i]); |
| 1443 | 1445 | ||
| 1444 | if (i == osb->slot_num) | 1446 | if (i == osb->slot_num) { |
| 1447 | spin_unlock(&osb->osb_lock); | ||
| 1445 | continue; | 1448 | continue; |
| 1449 | } | ||
| 1446 | 1450 | ||
| 1447 | status = ocfs2_slot_to_node_num_locked(osb, i, &node_num); | 1451 | status = ocfs2_slot_to_node_num_locked(osb, i, &node_num); |
| 1448 | if (status == -ENOENT) | 1452 | if (status == -ENOENT) { |
| 1453 | spin_unlock(&osb->osb_lock); | ||
| 1449 | continue; | 1454 | continue; |
| 1455 | } | ||
| 1450 | 1456 | ||
| 1451 | if (__ocfs2_recovery_map_test(osb, node_num)) | 1457 | if (__ocfs2_recovery_map_test(osb, node_num)) { |
| 1458 | spin_unlock(&osb->osb_lock); | ||
| 1452 | continue; | 1459 | continue; |
| 1460 | } | ||
| 1453 | spin_unlock(&osb->osb_lock); | 1461 | spin_unlock(&osb->osb_lock); |
| 1454 | 1462 | ||
| 1455 | /* Ok, we have a slot occupied by another node which | 1463 | /* Ok, we have a slot occupied by another node which |
| @@ -1465,10 +1473,7 @@ int ocfs2_mark_dead_nodes(struct ocfs2_super *osb) | |||
| 1465 | mlog_errno(status); | 1473 | mlog_errno(status); |
| 1466 | goto bail; | 1474 | goto bail; |
| 1467 | } | 1475 | } |
| 1468 | |||
| 1469 | spin_lock(&osb->osb_lock); | ||
| 1470 | } | 1476 | } |
| 1471 | spin_unlock(&osb->osb_lock); | ||
| 1472 | 1477 | ||
| 1473 | status = 0; | 1478 | status = 0; |
| 1474 | bail: | 1479 | bail: |
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c index 10e149ae5e3a..07f348b8d721 100644 --- a/fs/ocfs2/stackglue.c +++ b/fs/ocfs2/stackglue.c | |||
| @@ -97,13 +97,14 @@ static int ocfs2_stack_driver_request(const char *stack_name, | |||
| 97 | goto out; | 97 | goto out; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | /* Ok, the stack is pinned */ | ||
| 101 | p->sp_count++; | ||
| 102 | active_stack = p; | 100 | active_stack = p; |
| 103 | |||
| 104 | rc = 0; | 101 | rc = 0; |
| 105 | 102 | ||
| 106 | out: | 103 | out: |
| 104 | /* If we found it, pin it */ | ||
| 105 | if (!rc) | ||
| 106 | active_stack->sp_count++; | ||
| 107 | |||
| 107 | spin_unlock(&ocfs2_stack_lock); | 108 | spin_unlock(&ocfs2_stack_lock); |
| 108 | return rc; | 109 | return rc; |
| 109 | } | 110 | } |
diff --git a/fs/omfs/bitmap.c b/fs/omfs/bitmap.c index 697663b01bae..e1c0ec0ae989 100644 --- a/fs/omfs/bitmap.c +++ b/fs/omfs/bitmap.c | |||
| @@ -92,7 +92,7 @@ int omfs_allocate_block(struct super_block *sb, u64 block) | |||
| 92 | struct buffer_head *bh; | 92 | struct buffer_head *bh; |
| 93 | struct omfs_sb_info *sbi = OMFS_SB(sb); | 93 | struct omfs_sb_info *sbi = OMFS_SB(sb); |
| 94 | int bits_per_entry = 8 * sb->s_blocksize; | 94 | int bits_per_entry = 8 * sb->s_blocksize; |
| 95 | int map, bit; | 95 | unsigned int map, bit; |
| 96 | int ret = 0; | 96 | int ret = 0; |
| 97 | u64 tmp; | 97 | u64 tmp; |
| 98 | 98 | ||
| @@ -176,7 +176,8 @@ int omfs_clear_range(struct super_block *sb, u64 block, int count) | |||
| 176 | struct omfs_sb_info *sbi = OMFS_SB(sb); | 176 | struct omfs_sb_info *sbi = OMFS_SB(sb); |
| 177 | int bits_per_entry = 8 * sb->s_blocksize; | 177 | int bits_per_entry = 8 * sb->s_blocksize; |
| 178 | u64 tmp; | 178 | u64 tmp; |
| 179 | int map, bit, ret; | 179 | unsigned int map, bit; |
| 180 | int ret; | ||
| 180 | 181 | ||
| 181 | tmp = block; | 182 | tmp = block; |
| 182 | bit = do_div(tmp, bits_per_entry); | 183 | bit = do_div(tmp, bits_per_entry); |
diff --git a/fs/omfs/file.c b/fs/omfs/file.c index 7e2499053e4d..834b2331f6b3 100644 --- a/fs/omfs/file.c +++ b/fs/omfs/file.c | |||
| @@ -26,6 +26,13 @@ static int omfs_sync_file(struct file *file, struct dentry *dentry, | |||
| 26 | return err ? -EIO : 0; | 26 | return err ? -EIO : 0; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | static u32 omfs_max_extents(struct omfs_sb_info *sbi, int offset) | ||
| 30 | { | ||
| 31 | return (sbi->s_sys_blocksize - offset - | ||
| 32 | sizeof(struct omfs_extent)) / | ||
| 33 | sizeof(struct omfs_extent_entry) + 1; | ||
| 34 | } | ||
| 35 | |||
| 29 | void omfs_make_empty_table(struct buffer_head *bh, int offset) | 36 | void omfs_make_empty_table(struct buffer_head *bh, int offset) |
| 30 | { | 37 | { |
| 31 | struct omfs_extent *oe = (struct omfs_extent *) &bh->b_data[offset]; | 38 | struct omfs_extent *oe = (struct omfs_extent *) &bh->b_data[offset]; |
| @@ -45,6 +52,7 @@ int omfs_shrink_inode(struct inode *inode) | |||
| 45 | struct buffer_head *bh; | 52 | struct buffer_head *bh; |
| 46 | u64 next, last; | 53 | u64 next, last; |
| 47 | u32 extent_count; | 54 | u32 extent_count; |
| 55 | u32 max_extents; | ||
| 48 | int ret; | 56 | int ret; |
| 49 | 57 | ||
| 50 | /* traverse extent table, freeing each entry that is greater | 58 | /* traverse extent table, freeing each entry that is greater |
| @@ -62,15 +70,18 @@ int omfs_shrink_inode(struct inode *inode) | |||
| 62 | goto out; | 70 | goto out; |
| 63 | 71 | ||
| 64 | oe = (struct omfs_extent *)(&bh->b_data[OMFS_EXTENT_START]); | 72 | oe = (struct omfs_extent *)(&bh->b_data[OMFS_EXTENT_START]); |
| 73 | max_extents = omfs_max_extents(sbi, OMFS_EXTENT_START); | ||
| 65 | 74 | ||
| 66 | for (;;) { | 75 | for (;;) { |
| 67 | 76 | ||
| 68 | if (omfs_is_bad(sbi, (struct omfs_header *) bh->b_data, next)) { | 77 | if (omfs_is_bad(sbi, (struct omfs_header *) bh->b_data, next)) |
| 69 | brelse(bh); | 78 | goto out_brelse; |
| 70 | goto out; | ||
| 71 | } | ||
| 72 | 79 | ||
| 73 | extent_count = be32_to_cpu(oe->e_extent_count); | 80 | extent_count = be32_to_cpu(oe->e_extent_count); |
| 81 | |||
| 82 | if (extent_count > max_extents) | ||
| 83 | goto out_brelse; | ||
| 84 | |||
| 74 | last = next; | 85 | last = next; |
| 75 | next = be64_to_cpu(oe->e_next); | 86 | next = be64_to_cpu(oe->e_next); |
| 76 | entry = &oe->e_entry; | 87 | entry = &oe->e_entry; |
| @@ -98,10 +109,14 @@ int omfs_shrink_inode(struct inode *inode) | |||
| 98 | if (!bh) | 109 | if (!bh) |
| 99 | goto out; | 110 | goto out; |
| 100 | oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]); | 111 | oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]); |
| 112 | max_extents = omfs_max_extents(sbi, OMFS_EXTENT_CONT); | ||
| 101 | } | 113 | } |
| 102 | ret = 0; | 114 | ret = 0; |
| 103 | out: | 115 | out: |
| 104 | return ret; | 116 | return ret; |
| 117 | out_brelse: | ||
| 118 | brelse(bh); | ||
| 119 | return ret; | ||
| 105 | } | 120 | } |
| 106 | 121 | ||
| 107 | static void omfs_truncate(struct inode *inode) | 122 | static void omfs_truncate(struct inode *inode) |
| @@ -154,9 +169,7 @@ static int omfs_grow_extent(struct inode *inode, struct omfs_extent *oe, | |||
| 154 | goto out; | 169 | goto out; |
| 155 | } | 170 | } |
| 156 | } | 171 | } |
| 157 | max_count = (sbi->s_sys_blocksize - OMFS_EXTENT_START - | 172 | max_count = omfs_max_extents(sbi, OMFS_EXTENT_START); |
| 158 | sizeof(struct omfs_extent)) / | ||
| 159 | sizeof(struct omfs_extent_entry) + 1; | ||
| 160 | 173 | ||
| 161 | /* TODO: add a continuation block here */ | 174 | /* TODO: add a continuation block here */ |
| 162 | if (be32_to_cpu(oe->e_extent_count) > max_count-1) | 175 | if (be32_to_cpu(oe->e_extent_count) > max_count-1) |
| @@ -225,6 +238,7 @@ static int omfs_get_block(struct inode *inode, sector_t block, | |||
| 225 | sector_t next, offset; | 238 | sector_t next, offset; |
| 226 | int ret; | 239 | int ret; |
| 227 | u64 new_block; | 240 | u64 new_block; |
| 241 | u32 max_extents; | ||
| 228 | int extent_count; | 242 | int extent_count; |
| 229 | struct omfs_extent *oe; | 243 | struct omfs_extent *oe; |
| 230 | struct omfs_extent_entry *entry; | 244 | struct omfs_extent_entry *entry; |
| @@ -238,6 +252,7 @@ static int omfs_get_block(struct inode *inode, sector_t block, | |||
| 238 | goto out; | 252 | goto out; |
| 239 | 253 | ||
| 240 | oe = (struct omfs_extent *)(&bh->b_data[OMFS_EXTENT_START]); | 254 | oe = (struct omfs_extent *)(&bh->b_data[OMFS_EXTENT_START]); |
| 255 | max_extents = omfs_max_extents(sbi, OMFS_EXTENT_START); | ||
| 241 | next = inode->i_ino; | 256 | next = inode->i_ino; |
| 242 | 257 | ||
| 243 | for (;;) { | 258 | for (;;) { |
| @@ -249,6 +264,9 @@ static int omfs_get_block(struct inode *inode, sector_t block, | |||
| 249 | next = be64_to_cpu(oe->e_next); | 264 | next = be64_to_cpu(oe->e_next); |
| 250 | entry = &oe->e_entry; | 265 | entry = &oe->e_entry; |
| 251 | 266 | ||
| 267 | if (extent_count > max_extents) | ||
| 268 | goto out_brelse; | ||
| 269 | |||
| 252 | offset = find_block(inode, entry, block, extent_count, &remain); | 270 | offset = find_block(inode, entry, block, extent_count, &remain); |
| 253 | if (offset > 0) { | 271 | if (offset > 0) { |
| 254 | ret = 0; | 272 | ret = 0; |
| @@ -266,6 +284,7 @@ static int omfs_get_block(struct inode *inode, sector_t block, | |||
| 266 | if (!bh) | 284 | if (!bh) |
| 267 | goto out; | 285 | goto out; |
| 268 | oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]); | 286 | oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]); |
| 287 | max_extents = omfs_max_extents(sbi, OMFS_EXTENT_CONT); | ||
| 269 | } | 288 | } |
| 270 | if (create) { | 289 | if (create) { |
| 271 | ret = omfs_grow_extent(inode, oe, &new_block); | 290 | ret = omfs_grow_extent(inode, oe, &new_block); |
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c index a95fe5984f4b..d29047b1b9b0 100644 --- a/fs/omfs/inode.c +++ b/fs/omfs/inode.c | |||
| @@ -232,8 +232,7 @@ struct inode *omfs_iget(struct super_block *sb, ino_t ino) | |||
| 232 | inode->i_mode = S_IFDIR | (S_IRWXUGO & ~sbi->s_dmask); | 232 | inode->i_mode = S_IFDIR | (S_IRWXUGO & ~sbi->s_dmask); |
| 233 | inode->i_op = &omfs_dir_inops; | 233 | inode->i_op = &omfs_dir_inops; |
| 234 | inode->i_fop = &omfs_dir_operations; | 234 | inode->i_fop = &omfs_dir_operations; |
| 235 | inode->i_size = be32_to_cpu(oi->i_head.h_body_size) + | 235 | inode->i_size = sbi->s_sys_blocksize; |
| 236 | sizeof(struct omfs_header); | ||
| 237 | inc_nlink(inode); | 236 | inc_nlink(inode); |
| 238 | break; | 237 | break; |
| 239 | case OMFS_FILE: | 238 | case OMFS_FILE: |
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 4fb81e9c94e3..bca0f81eb687 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
| @@ -330,6 +330,7 @@ retry: | |||
| 330 | spin_lock(&proc_inum_lock); | 330 | spin_lock(&proc_inum_lock); |
| 331 | ida_remove(&proc_inum_ida, i); | 331 | ida_remove(&proc_inum_ida, i); |
| 332 | spin_unlock(&proc_inum_lock); | 332 | spin_unlock(&proc_inum_lock); |
| 333 | return 0; | ||
| 333 | } | 334 | } |
| 334 | return PROC_DYNAMIC_FIRST + i; | 335 | return PROC_DYNAMIC_FIRST + i; |
| 335 | } | 336 | } |
diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c index 79ecd281d2cb..3f87d2632947 100644 --- a/fs/proc/nommu.c +++ b/fs/proc/nommu.c | |||
| @@ -52,14 +52,14 @@ int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma) | |||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | seq_printf(m, | 54 | seq_printf(m, |
| 55 | "%08lx-%08lx %c%c%c%c %08lx %02x:%02x %lu %n", | 55 | "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n", |
| 56 | vma->vm_start, | 56 | vma->vm_start, |
| 57 | vma->vm_end, | 57 | vma->vm_end, |
| 58 | flags & VM_READ ? 'r' : '-', | 58 | flags & VM_READ ? 'r' : '-', |
| 59 | flags & VM_WRITE ? 'w' : '-', | 59 | flags & VM_WRITE ? 'w' : '-', |
| 60 | flags & VM_EXEC ? 'x' : '-', | 60 | flags & VM_EXEC ? 'x' : '-', |
| 61 | flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p', | 61 | flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p', |
| 62 | vma->vm_pgoff << PAGE_SHIFT, | 62 | ((loff_t)vma->vm_pgoff) << PAGE_SHIFT, |
| 63 | MAJOR(dev), MINOR(dev), ino, &len); | 63 | MAJOR(dev), MINOR(dev), ino, &len); |
| 64 | 64 | ||
| 65 | if (file) { | 65 | if (file) { |
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index ded969862960..00f10a2dcf12 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/tty.h> | 24 | #include <linux/tty.h> |
| 25 | #include <linux/string.h> | 25 | #include <linux/string.h> |
| 26 | #include <linux/mman.h> | 26 | #include <linux/mman.h> |
| 27 | #include <linux/quicklist.h> | ||
| 27 | #include <linux/proc_fs.h> | 28 | #include <linux/proc_fs.h> |
| 28 | #include <linux/ioport.h> | 29 | #include <linux/ioport.h> |
| 29 | #include <linux/mm.h> | 30 | #include <linux/mm.h> |
| @@ -189,7 +190,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off, | |||
| 189 | "Committed_AS: %8lu kB\n" | 190 | "Committed_AS: %8lu kB\n" |
| 190 | "VmallocTotal: %8lu kB\n" | 191 | "VmallocTotal: %8lu kB\n" |
| 191 | "VmallocUsed: %8lu kB\n" | 192 | "VmallocUsed: %8lu kB\n" |
| 192 | "VmallocChunk: %8lu kB\n", | 193 | "VmallocChunk: %8lu kB\n" |
| 194 | "Quicklists: %8lu kB\n", | ||
| 193 | K(i.totalram), | 195 | K(i.totalram), |
| 194 | K(i.freeram), | 196 | K(i.freeram), |
| 195 | K(i.bufferram), | 197 | K(i.bufferram), |
| @@ -221,7 +223,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off, | |||
| 221 | K(committed), | 223 | K(committed), |
| 222 | (unsigned long)VMALLOC_TOTAL >> 10, | 224 | (unsigned long)VMALLOC_TOTAL >> 10, |
| 223 | vmi.used >> 10, | 225 | vmi.used >> 10, |
| 224 | vmi.largest_chunk >> 10 | 226 | vmi.largest_chunk >> 10, |
| 227 | K(quicklist_total_size()) | ||
| 225 | ); | 228 | ); |
| 226 | 229 | ||
| 227 | len += hugetlb_report_meminfo(page + len); | 230 | len += hugetlb_report_meminfo(page + len); |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 7546a918f790..73d1891ee625 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
| @@ -219,14 +219,14 @@ static int show_map(struct seq_file *m, void *v) | |||
| 219 | ino = inode->i_ino; | 219 | ino = inode->i_ino; |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | seq_printf(m, "%08lx-%08lx %c%c%c%c %08lx %02x:%02x %lu %n", | 222 | seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n", |
| 223 | vma->vm_start, | 223 | vma->vm_start, |
| 224 | vma->vm_end, | 224 | vma->vm_end, |
| 225 | flags & VM_READ ? 'r' : '-', | 225 | flags & VM_READ ? 'r' : '-', |
| 226 | flags & VM_WRITE ? 'w' : '-', | 226 | flags & VM_WRITE ? 'w' : '-', |
| 227 | flags & VM_EXEC ? 'x' : '-', | 227 | flags & VM_EXEC ? 'x' : '-', |
| 228 | flags & VM_MAYSHARE ? 's' : 'p', | 228 | flags & VM_MAYSHARE ? 's' : 'p', |
| 229 | vma->vm_pgoff << PAGE_SHIFT, | 229 | ((loff_t)vma->vm_pgoff) << PAGE_SHIFT, |
| 230 | MAJOR(dev), MINOR(dev), ino, &len); | 230 | MAJOR(dev), MINOR(dev), ino, &len); |
| 231 | 231 | ||
| 232 | /* | 232 | /* |
diff --git a/fs/readdir.c b/fs/readdir.c index 4e026e5407fb..93a7559bbfd8 100644 --- a/fs/readdir.c +++ b/fs/readdir.c | |||
| @@ -80,8 +80,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset | |||
| 80 | if (buf->result) | 80 | if (buf->result) |
| 81 | return -EINVAL; | 81 | return -EINVAL; |
| 82 | d_ino = ino; | 82 | d_ino = ino; |
| 83 | if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) | 83 | if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) { |
| 84 | buf->result = -EOVERFLOW; | ||
| 84 | return -EOVERFLOW; | 85 | return -EOVERFLOW; |
| 86 | } | ||
| 85 | buf->result++; | 87 | buf->result++; |
| 86 | dirent = buf->dirent; | 88 | dirent = buf->dirent; |
| 87 | if (!access_ok(VERIFY_WRITE, dirent, | 89 | if (!access_ok(VERIFY_WRITE, dirent, |
| @@ -155,8 +157,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset, | |||
| 155 | if (reclen > buf->count) | 157 | if (reclen > buf->count) |
| 156 | return -EINVAL; | 158 | return -EINVAL; |
| 157 | d_ino = ino; | 159 | d_ino = ino; |
| 158 | if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) | 160 | if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) { |
| 161 | buf->error = -EOVERFLOW; | ||
| 159 | return -EOVERFLOW; | 162 | return -EOVERFLOW; |
| 163 | } | ||
| 160 | dirent = buf->previous; | 164 | dirent = buf->previous; |
| 161 | if (dirent) { | 165 | if (dirent) { |
| 162 | if (__put_user(offset, &dirent->d_off)) | 166 | if (__put_user(offset, &dirent->d_off)) |
diff --git a/fs/seq_file.c b/fs/seq_file.c index 5d54205e486b..bd20f7f5a933 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
| @@ -108,9 +108,9 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) | |||
| 108 | goto Done; | 108 | goto Done; |
| 109 | } | 109 | } |
| 110 | /* we need at least one record in buffer */ | 110 | /* we need at least one record in buffer */ |
| 111 | pos = m->index; | ||
| 112 | p = m->op->start(m, &pos); | ||
| 111 | while (1) { | 113 | while (1) { |
| 112 | pos = m->index; | ||
| 113 | p = m->op->start(m, &pos); | ||
| 114 | err = PTR_ERR(p); | 114 | err = PTR_ERR(p); |
| 115 | if (!p || IS_ERR(p)) | 115 | if (!p || IS_ERR(p)) |
| 116 | break; | 116 | break; |
| @@ -119,6 +119,11 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) | |||
| 119 | break; | 119 | break; |
| 120 | if (unlikely(err)) | 120 | if (unlikely(err)) |
| 121 | m->count = 0; | 121 | m->count = 0; |
| 122 | if (unlikely(!m->count)) { | ||
| 123 | p = m->op->next(m, p, &pos); | ||
| 124 | m->index = pos; | ||
| 125 | continue; | ||
| 126 | } | ||
| 122 | if (m->count < m->size) | 127 | if (m->count < m->size) |
| 123 | goto Fill; | 128 | goto Fill; |
| 124 | m->op->stop(m, p); | 129 | m->op->stop(m, p); |
| @@ -128,6 +133,8 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) | |||
| 128 | goto Enomem; | 133 | goto Enomem; |
| 129 | m->count = 0; | 134 | m->count = 0; |
| 130 | m->version = 0; | 135 | m->version = 0; |
| 136 | pos = m->index; | ||
| 137 | p = m->op->start(m, &pos); | ||
| 131 | } | 138 | } |
| 132 | m->op->stop(m, p); | 139 | m->op->stop(m, p); |
| 133 | m->count = 0; | 140 | m->count = 0; |
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c index d81fb9ed2b8e..154098157473 100644 --- a/fs/ubifs/budget.c +++ b/fs/ubifs/budget.c | |||
| @@ -263,8 +263,8 @@ int ubifs_calc_min_idx_lebs(struct ubifs_info *c) | |||
| 263 | 263 | ||
| 264 | idx_size = c->old_idx_sz + c->budg_idx_growth + c->budg_uncommitted_idx; | 264 | idx_size = c->old_idx_sz + c->budg_idx_growth + c->budg_uncommitted_idx; |
| 265 | 265 | ||
| 266 | /* And make sure we have twice the index size of space reserved */ | 266 | /* And make sure we have thrice the index size of space reserved */ |
| 267 | idx_size <<= 1; | 267 | idx_size = idx_size + (idx_size << 1); |
| 268 | 268 | ||
| 269 | /* | 269 | /* |
| 270 | * We do not maintain 'old_idx_size' as 'old_idx_lebs'/'old_idx_bytes' | 270 | * We do not maintain 'old_idx_size' as 'old_idx_lebs'/'old_idx_bytes' |
| @@ -388,11 +388,11 @@ static int can_use_rp(struct ubifs_info *c) | |||
| 388 | * This function makes sure UBIFS has enough free eraseblocks for index growth | 388 | * This function makes sure UBIFS has enough free eraseblocks for index growth |
| 389 | * and data. | 389 | * and data. |
| 390 | * | 390 | * |
| 391 | * When budgeting index space, UBIFS reserves twice as more LEBs as the index | 391 | * When budgeting index space, UBIFS reserves thrice as many LEBs as the index |
| 392 | * would take if it was consolidated and written to the flash. This guarantees | 392 | * would take if it was consolidated and written to the flash. This guarantees |
| 393 | * that the "in-the-gaps" commit method always succeeds and UBIFS will always | 393 | * that the "in-the-gaps" commit method always succeeds and UBIFS will always |
| 394 | * be able to commit dirty index. So this function basically adds amount of | 394 | * be able to commit dirty index. So this function basically adds amount of |
| 395 | * budgeted index space to the size of the current index, multiplies this by 2, | 395 | * budgeted index space to the size of the current index, multiplies this by 3, |
| 396 | * and makes sure this does not exceed the amount of free eraseblocks. | 396 | * and makes sure this does not exceed the amount of free eraseblocks. |
| 397 | * | 397 | * |
| 398 | * Notes about @c->min_idx_lebs and @c->lst.idx_lebs variables: | 398 | * Notes about @c->min_idx_lebs and @c->lst.idx_lebs variables: |
| @@ -543,8 +543,16 @@ int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req) | |||
| 543 | int err, idx_growth, data_growth, dd_growth; | 543 | int err, idx_growth, data_growth, dd_growth; |
| 544 | struct retries_info ri; | 544 | struct retries_info ri; |
| 545 | 545 | ||
| 546 | ubifs_assert(req->new_page <= 1); | ||
| 547 | ubifs_assert(req->dirtied_page <= 1); | ||
| 548 | ubifs_assert(req->new_dent <= 1); | ||
| 549 | ubifs_assert(req->mod_dent <= 1); | ||
| 550 | ubifs_assert(req->new_ino <= 1); | ||
| 551 | ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA); | ||
| 546 | ubifs_assert(req->dirtied_ino <= 4); | 552 | ubifs_assert(req->dirtied_ino <= 4); |
| 547 | ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4); | 553 | ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4); |
| 554 | ubifs_assert(!(req->new_ino_d & 7)); | ||
| 555 | ubifs_assert(!(req->dirtied_ino_d & 7)); | ||
| 548 | 556 | ||
| 549 | data_growth = calc_data_growth(c, req); | 557 | data_growth = calc_data_growth(c, req); |
| 550 | dd_growth = calc_dd_growth(c, req); | 558 | dd_growth = calc_dd_growth(c, req); |
| @@ -618,8 +626,16 @@ again: | |||
| 618 | */ | 626 | */ |
| 619 | void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req) | 627 | void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req) |
| 620 | { | 628 | { |
| 629 | ubifs_assert(req->new_page <= 1); | ||
| 630 | ubifs_assert(req->dirtied_page <= 1); | ||
| 631 | ubifs_assert(req->new_dent <= 1); | ||
| 632 | ubifs_assert(req->mod_dent <= 1); | ||
| 633 | ubifs_assert(req->new_ino <= 1); | ||
| 634 | ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA); | ||
| 621 | ubifs_assert(req->dirtied_ino <= 4); | 635 | ubifs_assert(req->dirtied_ino <= 4); |
| 622 | ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4); | 636 | ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4); |
| 637 | ubifs_assert(!(req->new_ino_d & 7)); | ||
| 638 | ubifs_assert(!(req->dirtied_ino_d & 7)); | ||
| 623 | if (!req->recalculate) { | 639 | if (!req->recalculate) { |
| 624 | ubifs_assert(req->idx_growth >= 0); | 640 | ubifs_assert(req->idx_growth >= 0); |
| 625 | ubifs_assert(req->data_growth >= 0); | 641 | ubifs_assert(req->data_growth >= 0); |
| @@ -647,7 +663,11 @@ void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req) | |||
| 647 | 663 | ||
| 648 | ubifs_assert(c->budg_idx_growth >= 0); | 664 | ubifs_assert(c->budg_idx_growth >= 0); |
| 649 | ubifs_assert(c->budg_data_growth >= 0); | 665 | ubifs_assert(c->budg_data_growth >= 0); |
| 666 | ubifs_assert(c->budg_dd_growth >= 0); | ||
| 650 | ubifs_assert(c->min_idx_lebs < c->main_lebs); | 667 | ubifs_assert(c->min_idx_lebs < c->main_lebs); |
| 668 | ubifs_assert(!(c->budg_idx_growth & 7)); | ||
| 669 | ubifs_assert(!(c->budg_data_growth & 7)); | ||
| 670 | ubifs_assert(!(c->budg_dd_growth & 7)); | ||
| 651 | spin_unlock(&c->space_lock); | 671 | spin_unlock(&c->space_lock); |
| 652 | } | 672 | } |
| 653 | 673 | ||
| @@ -686,9 +706,10 @@ void ubifs_convert_page_budget(struct ubifs_info *c) | |||
| 686 | void ubifs_release_dirty_inode_budget(struct ubifs_info *c, | 706 | void ubifs_release_dirty_inode_budget(struct ubifs_info *c, |
| 687 | struct ubifs_inode *ui) | 707 | struct ubifs_inode *ui) |
| 688 | { | 708 | { |
| 689 | struct ubifs_budget_req req = {.dd_growth = c->inode_budget, | 709 | struct ubifs_budget_req req; |
| 690 | .dirtied_ino_d = ui->data_len}; | ||
| 691 | 710 | ||
| 711 | memset(&req, 0, sizeof(struct ubifs_budget_req)); | ||
| 712 | req.dd_growth = c->inode_budget + ALIGN(ui->data_len, 8); | ||
| 692 | ubifs_release_budget(c, &req); | 713 | ubifs_release_budget(c, &req); |
| 693 | } | 714 | } |
| 694 | 715 | ||
diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c index 3b516316c9b3..0a6aa2cc78f0 100644 --- a/fs/ubifs/commit.c +++ b/fs/ubifs/commit.c | |||
| @@ -74,6 +74,7 @@ static int do_commit(struct ubifs_info *c) | |||
| 74 | goto out_up; | 74 | goto out_up; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | c->cmt_no += 1; | ||
| 77 | err = ubifs_gc_start_commit(c); | 78 | err = ubifs_gc_start_commit(c); |
| 78 | if (err) | 79 | if (err) |
| 79 | goto out_up; | 80 | goto out_up; |
| @@ -115,7 +116,7 @@ static int do_commit(struct ubifs_info *c) | |||
| 115 | goto out; | 116 | goto out; |
| 116 | 117 | ||
| 117 | mutex_lock(&c->mst_mutex); | 118 | mutex_lock(&c->mst_mutex); |
| 118 | c->mst_node->cmt_no = cpu_to_le64(++c->cmt_no); | 119 | c->mst_node->cmt_no = cpu_to_le64(c->cmt_no); |
| 119 | c->mst_node->log_lnum = cpu_to_le32(new_ltail_lnum); | 120 | c->mst_node->log_lnum = cpu_to_le32(new_ltail_lnum); |
| 120 | c->mst_node->root_lnum = cpu_to_le32(zroot.lnum); | 121 | c->mst_node->root_lnum = cpu_to_le32(zroot.lnum); |
| 121 | c->mst_node->root_offs = cpu_to_le32(zroot.offs); | 122 | c->mst_node->root_offs = cpu_to_le32(zroot.offs); |
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 4e3aaeba4eca..b9cb77473758 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
| @@ -568,8 +568,8 @@ void dbg_dump_budget_req(const struct ubifs_budget_req *req) | |||
| 568 | void dbg_dump_lstats(const struct ubifs_lp_stats *lst) | 568 | void dbg_dump_lstats(const struct ubifs_lp_stats *lst) |
| 569 | { | 569 | { |
| 570 | spin_lock(&dbg_lock); | 570 | spin_lock(&dbg_lock); |
| 571 | printk(KERN_DEBUG "Lprops statistics: empty_lebs %d, idx_lebs %d\n", | 571 | printk(KERN_DEBUG "(pid %d) Lprops statistics: empty_lebs %d, " |
| 572 | lst->empty_lebs, lst->idx_lebs); | 572 | "idx_lebs %d\n", current->pid, lst->empty_lebs, lst->idx_lebs); |
| 573 | printk(KERN_DEBUG "\ttaken_empty_lebs %d, total_free %lld, " | 573 | printk(KERN_DEBUG "\ttaken_empty_lebs %d, total_free %lld, " |
| 574 | "total_dirty %lld\n", lst->taken_empty_lebs, lst->total_free, | 574 | "total_dirty %lld\n", lst->taken_empty_lebs, lst->total_free, |
| 575 | lst->total_dirty); | 575 | lst->total_dirty); |
| @@ -587,8 +587,8 @@ void dbg_dump_budg(struct ubifs_info *c) | |||
| 587 | struct ubifs_gced_idx_leb *idx_gc; | 587 | struct ubifs_gced_idx_leb *idx_gc; |
| 588 | 588 | ||
| 589 | spin_lock(&dbg_lock); | 589 | spin_lock(&dbg_lock); |
| 590 | printk(KERN_DEBUG "Budgeting info: budg_data_growth %lld, " | 590 | printk(KERN_DEBUG "(pid %d) Budgeting info: budg_data_growth %lld, " |
| 591 | "budg_dd_growth %lld, budg_idx_growth %lld\n", | 591 | "budg_dd_growth %lld, budg_idx_growth %lld\n", current->pid, |
| 592 | c->budg_data_growth, c->budg_dd_growth, c->budg_idx_growth); | 592 | c->budg_data_growth, c->budg_dd_growth, c->budg_idx_growth); |
| 593 | printk(KERN_DEBUG "\tdata budget sum %lld, total budget sum %lld, " | 593 | printk(KERN_DEBUG "\tdata budget sum %lld, total budget sum %lld, " |
| 594 | "freeable_cnt %d\n", c->budg_data_growth + c->budg_dd_growth, | 594 | "freeable_cnt %d\n", c->budg_data_growth + c->budg_dd_growth, |
| @@ -634,7 +634,7 @@ void dbg_dump_lprops(struct ubifs_info *c) | |||
| 634 | struct ubifs_lprops lp; | 634 | struct ubifs_lprops lp; |
| 635 | struct ubifs_lp_stats lst; | 635 | struct ubifs_lp_stats lst; |
| 636 | 636 | ||
| 637 | printk(KERN_DEBUG "Dumping LEB properties\n"); | 637 | printk(KERN_DEBUG "(pid %d) Dumping LEB properties\n", current->pid); |
| 638 | ubifs_get_lp_stats(c, &lst); | 638 | ubifs_get_lp_stats(c, &lst); |
| 639 | dbg_dump_lstats(&lst); | 639 | dbg_dump_lstats(&lst); |
| 640 | 640 | ||
| @@ -655,7 +655,7 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum) | |||
| 655 | if (dbg_failure_mode) | 655 | if (dbg_failure_mode) |
| 656 | return; | 656 | return; |
| 657 | 657 | ||
| 658 | printk(KERN_DEBUG "Dumping LEB %d\n", lnum); | 658 | printk(KERN_DEBUG "(pid %d) Dumping LEB %d\n", current->pid, lnum); |
| 659 | 659 | ||
| 660 | sleb = ubifs_scan(c, lnum, 0, c->dbg_buf); | 660 | sleb = ubifs_scan(c, lnum, 0, c->dbg_buf); |
| 661 | if (IS_ERR(sleb)) { | 661 | if (IS_ERR(sleb)) { |
| @@ -720,8 +720,8 @@ void dbg_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat) | |||
| 720 | { | 720 | { |
| 721 | int i; | 721 | int i; |
| 722 | 722 | ||
| 723 | printk(KERN_DEBUG "Dumping heap cat %d (%d elements)\n", | 723 | printk(KERN_DEBUG "(pid %d) Dumping heap cat %d (%d elements)\n", |
| 724 | cat, heap->cnt); | 724 | current->pid, cat, heap->cnt); |
| 725 | for (i = 0; i < heap->cnt; i++) { | 725 | for (i = 0; i < heap->cnt; i++) { |
| 726 | struct ubifs_lprops *lprops = heap->arr[i]; | 726 | struct ubifs_lprops *lprops = heap->arr[i]; |
| 727 | 727 | ||
| @@ -736,7 +736,7 @@ void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, | |||
| 736 | { | 736 | { |
| 737 | int i; | 737 | int i; |
| 738 | 738 | ||
| 739 | printk(KERN_DEBUG "Dumping pnode:\n"); | 739 | printk(KERN_DEBUG "(pid %d) Dumping pnode:\n", current->pid); |
| 740 | printk(KERN_DEBUG "\taddress %zx parent %zx cnext %zx\n", | 740 | printk(KERN_DEBUG "\taddress %zx parent %zx cnext %zx\n", |
| 741 | (size_t)pnode, (size_t)parent, (size_t)pnode->cnext); | 741 | (size_t)pnode, (size_t)parent, (size_t)pnode->cnext); |
| 742 | printk(KERN_DEBUG "\tflags %lu iip %d level %d num %d\n", | 742 | printk(KERN_DEBUG "\tflags %lu iip %d level %d num %d\n", |
| @@ -755,7 +755,7 @@ void dbg_dump_tnc(struct ubifs_info *c) | |||
| 755 | int level; | 755 | int level; |
| 756 | 756 | ||
| 757 | printk(KERN_DEBUG "\n"); | 757 | printk(KERN_DEBUG "\n"); |
| 758 | printk(KERN_DEBUG "Dumping the TNC tree\n"); | 758 | printk(KERN_DEBUG "(pid %d) Dumping the TNC tree\n", current->pid); |
| 759 | znode = ubifs_tnc_levelorder_next(c->zroot.znode, NULL); | 759 | znode = ubifs_tnc_levelorder_next(c->zroot.znode, NULL); |
| 760 | level = znode->level; | 760 | level = znode->level; |
| 761 | printk(KERN_DEBUG "== Level %d ==\n", level); | 761 | printk(KERN_DEBUG "== Level %d ==\n", level); |
| @@ -2208,16 +2208,17 @@ int dbg_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset, | |||
| 2208 | int dbg_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf, | 2208 | int dbg_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf, |
| 2209 | int offset, int len, int dtype) | 2209 | int offset, int len, int dtype) |
| 2210 | { | 2210 | { |
| 2211 | int err; | 2211 | int err, failing; |
| 2212 | 2212 | ||
| 2213 | if (in_failure_mode(desc)) | 2213 | if (in_failure_mode(desc)) |
| 2214 | return -EIO; | 2214 | return -EIO; |
| 2215 | if (do_fail(desc, lnum, 1)) | 2215 | failing = do_fail(desc, lnum, 1); |
| 2216 | if (failing) | ||
| 2216 | cut_data(buf, len); | 2217 | cut_data(buf, len); |
| 2217 | err = ubi_leb_write(desc, lnum, buf, offset, len, dtype); | 2218 | err = ubi_leb_write(desc, lnum, buf, offset, len, dtype); |
| 2218 | if (err) | 2219 | if (err) |
| 2219 | return err; | 2220 | return err; |
| 2220 | if (in_failure_mode(desc)) | 2221 | if (failing) |
| 2221 | return -EIO; | 2222 | return -EIO; |
| 2222 | return 0; | 2223 | return 0; |
| 2223 | } | 2224 | } |
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h index 3c4f1e93c9e0..50315fc57185 100644 --- a/fs/ubifs/debug.h +++ b/fs/ubifs/debug.h | |||
| @@ -27,7 +27,7 @@ | |||
| 27 | 27 | ||
| 28 | #define UBIFS_DBG(op) op | 28 | #define UBIFS_DBG(op) op |
| 29 | 29 | ||
| 30 | #define ubifs_assert(expr) do { \ | 30 | #define ubifs_assert(expr) do { \ |
| 31 | if (unlikely(!(expr))) { \ | 31 | if (unlikely(!(expr))) { \ |
| 32 | printk(KERN_CRIT "UBIFS assert failed in %s at %u (pid %d)\n", \ | 32 | printk(KERN_CRIT "UBIFS assert failed in %s at %u (pid %d)\n", \ |
| 33 | __func__, __LINE__, current->pid); \ | 33 | __func__, __LINE__, current->pid); \ |
| @@ -73,50 +73,50 @@ const char *dbg_key_str1(const struct ubifs_info *c, | |||
| 73 | const union ubifs_key *key); | 73 | const union ubifs_key *key); |
| 74 | 74 | ||
| 75 | /* | 75 | /* |
| 76 | * DBGKEY macros require dbg_lock to be held, which it is in the dbg message | 76 | * DBGKEY macros require @dbg_lock to be held, which it is in the dbg message |
| 77 | * macros. | 77 | * macros. |
| 78 | */ | 78 | */ |
| 79 | #define DBGKEY(key) dbg_key_str0(c, (key)) | 79 | #define DBGKEY(key) dbg_key_str0(c, (key)) |
| 80 | #define DBGKEY1(key) dbg_key_str1(c, (key)) | 80 | #define DBGKEY1(key) dbg_key_str1(c, (key)) |
| 81 | 81 | ||
| 82 | /* General messages */ | 82 | /* General messages */ |
| 83 | #define dbg_gen(fmt, ...) dbg_do_msg(UBIFS_MSG_GEN, fmt, ##__VA_ARGS__) | 83 | #define dbg_gen(fmt, ...) dbg_do_msg(UBIFS_MSG_GEN, fmt, ##__VA_ARGS__) |
| 84 | 84 | ||
| 85 | /* Additional journal messages */ | 85 | /* Additional journal messages */ |
| 86 | #define dbg_jnl(fmt, ...) dbg_do_msg(UBIFS_MSG_JNL, fmt, ##__VA_ARGS__) | 86 | #define dbg_jnl(fmt, ...) dbg_do_msg(UBIFS_MSG_JNL, fmt, ##__VA_ARGS__) |
| 87 | 87 | ||
| 88 | /* Additional TNC messages */ | 88 | /* Additional TNC messages */ |
| 89 | #define dbg_tnc(fmt, ...) dbg_do_msg(UBIFS_MSG_TNC, fmt, ##__VA_ARGS__) | 89 | #define dbg_tnc(fmt, ...) dbg_do_msg(UBIFS_MSG_TNC, fmt, ##__VA_ARGS__) |
| 90 | 90 | ||
| 91 | /* Additional lprops messages */ | 91 | /* Additional lprops messages */ |
| 92 | #define dbg_lp(fmt, ...) dbg_do_msg(UBIFS_MSG_LP, fmt, ##__VA_ARGS__) | 92 | #define dbg_lp(fmt, ...) dbg_do_msg(UBIFS_MSG_LP, fmt, ##__VA_ARGS__) |
| 93 | 93 | ||
| 94 | /* Additional LEB find messages */ | 94 | /* Additional LEB find messages */ |
| 95 | #define dbg_find(fmt, ...) dbg_do_msg(UBIFS_MSG_FIND, fmt, ##__VA_ARGS__) | 95 | #define dbg_find(fmt, ...) dbg_do_msg(UBIFS_MSG_FIND, fmt, ##__VA_ARGS__) |
| 96 | 96 | ||
| 97 | /* Additional mount messages */ | 97 | /* Additional mount messages */ |
| 98 | #define dbg_mnt(fmt, ...) dbg_do_msg(UBIFS_MSG_MNT, fmt, ##__VA_ARGS__) | 98 | #define dbg_mnt(fmt, ...) dbg_do_msg(UBIFS_MSG_MNT, fmt, ##__VA_ARGS__) |
| 99 | 99 | ||
| 100 | /* Additional I/O messages */ | 100 | /* Additional I/O messages */ |
| 101 | #define dbg_io(fmt, ...) dbg_do_msg(UBIFS_MSG_IO, fmt, ##__VA_ARGS__) | 101 | #define dbg_io(fmt, ...) dbg_do_msg(UBIFS_MSG_IO, fmt, ##__VA_ARGS__) |
| 102 | 102 | ||
| 103 | /* Additional commit messages */ | 103 | /* Additional commit messages */ |
| 104 | #define dbg_cmt(fmt, ...) dbg_do_msg(UBIFS_MSG_CMT, fmt, ##__VA_ARGS__) | 104 | #define dbg_cmt(fmt, ...) dbg_do_msg(UBIFS_MSG_CMT, fmt, ##__VA_ARGS__) |
| 105 | 105 | ||
| 106 | /* Additional budgeting messages */ | 106 | /* Additional budgeting messages */ |
| 107 | #define dbg_budg(fmt, ...) dbg_do_msg(UBIFS_MSG_BUDG, fmt, ##__VA_ARGS__) | 107 | #define dbg_budg(fmt, ...) dbg_do_msg(UBIFS_MSG_BUDG, fmt, ##__VA_ARGS__) |
| 108 | 108 | ||
| 109 | /* Additional log messages */ | 109 | /* Additional log messages */ |
| 110 | #define dbg_log(fmt, ...) dbg_do_msg(UBIFS_MSG_LOG, fmt, ##__VA_ARGS__) | 110 | #define dbg_log(fmt, ...) dbg_do_msg(UBIFS_MSG_LOG, fmt, ##__VA_ARGS__) |
| 111 | 111 | ||
| 112 | /* Additional gc messages */ | 112 | /* Additional gc messages */ |
| 113 | #define dbg_gc(fmt, ...) dbg_do_msg(UBIFS_MSG_GC, fmt, ##__VA_ARGS__) | 113 | #define dbg_gc(fmt, ...) dbg_do_msg(UBIFS_MSG_GC, fmt, ##__VA_ARGS__) |
| 114 | 114 | ||
| 115 | /* Additional scan messages */ | 115 | /* Additional scan messages */ |
| 116 | #define dbg_scan(fmt, ...) dbg_do_msg(UBIFS_MSG_SCAN, fmt, ##__VA_ARGS__) | 116 | #define dbg_scan(fmt, ...) dbg_do_msg(UBIFS_MSG_SCAN, fmt, ##__VA_ARGS__) |
| 117 | 117 | ||
| 118 | /* Additional recovery messages */ | 118 | /* Additional recovery messages */ |
| 119 | #define dbg_rcvry(fmt, ...) dbg_do_msg(UBIFS_MSG_RCVRY, fmt, ##__VA_ARGS__) | 119 | #define dbg_rcvry(fmt, ...) dbg_do_msg(UBIFS_MSG_RCVRY, fmt, ##__VA_ARGS__) |
| 120 | 120 | ||
| 121 | /* | 121 | /* |
| 122 | * Debugging message type flags (must match msg_type_names in debug.c). | 122 | * Debugging message type flags (must match msg_type_names in debug.c). |
| @@ -239,34 +239,23 @@ typedef int (*dbg_leaf_callback)(struct ubifs_info *c, | |||
| 239 | struct ubifs_zbranch *zbr, void *priv); | 239 | struct ubifs_zbranch *zbr, void *priv); |
| 240 | typedef int (*dbg_znode_callback)(struct ubifs_info *c, | 240 | typedef int (*dbg_znode_callback)(struct ubifs_info *c, |
| 241 | struct ubifs_znode *znode, void *priv); | 241 | struct ubifs_znode *znode, void *priv); |
| 242 | |||
| 243 | int dbg_walk_index(struct ubifs_info *c, dbg_leaf_callback leaf_cb, | 242 | int dbg_walk_index(struct ubifs_info *c, dbg_leaf_callback leaf_cb, |
| 244 | dbg_znode_callback znode_cb, void *priv); | 243 | dbg_znode_callback znode_cb, void *priv); |
| 245 | 244 | ||
| 246 | /* Checking functions */ | 245 | /* Checking functions */ |
| 247 | 246 | ||
| 248 | int dbg_check_lprops(struct ubifs_info *c); | 247 | int dbg_check_lprops(struct ubifs_info *c); |
| 249 | |||
| 250 | int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot); | 248 | int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot); |
| 251 | int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot); | 249 | int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot); |
| 252 | |||
| 253 | int dbg_check_cats(struct ubifs_info *c); | 250 | int dbg_check_cats(struct ubifs_info *c); |
| 254 | |||
| 255 | int dbg_check_ltab(struct ubifs_info *c); | 251 | int dbg_check_ltab(struct ubifs_info *c); |
| 256 | |||
| 257 | int dbg_check_synced_i_size(struct inode *inode); | 252 | int dbg_check_synced_i_size(struct inode *inode); |
| 258 | |||
| 259 | int dbg_check_dir_size(struct ubifs_info *c, const struct inode *dir); | 253 | int dbg_check_dir_size(struct ubifs_info *c, const struct inode *dir); |
| 260 | |||
| 261 | int dbg_check_tnc(struct ubifs_info *c, int extra); | 254 | int dbg_check_tnc(struct ubifs_info *c, int extra); |
| 262 | |||
| 263 | int dbg_check_idx_size(struct ubifs_info *c, long long idx_size); | 255 | int dbg_check_idx_size(struct ubifs_info *c, long long idx_size); |
| 264 | |||
| 265 | int dbg_check_filesystem(struct ubifs_info *c); | 256 | int dbg_check_filesystem(struct ubifs_info *c); |
| 266 | |||
| 267 | void dbg_check_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat, | 257 | void dbg_check_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat, |
| 268 | int add_pos); | 258 | int add_pos); |
| 269 | |||
| 270 | int dbg_check_lprops(struct ubifs_info *c); | 259 | int dbg_check_lprops(struct ubifs_info *c); |
| 271 | int dbg_check_lpt_nodes(struct ubifs_info *c, struct ubifs_cnode *cnode, | 260 | int dbg_check_lpt_nodes(struct ubifs_info *c, struct ubifs_cnode *cnode, |
| 272 | int row, int col); | 261 | int row, int col); |
| @@ -329,71 +318,77 @@ static inline int dbg_change(struct ubi_volume_desc *desc, int lnum, | |||
| 329 | #else /* !CONFIG_UBIFS_FS_DEBUG */ | 318 | #else /* !CONFIG_UBIFS_FS_DEBUG */ |
| 330 | 319 | ||
| 331 | #define UBIFS_DBG(op) | 320 | #define UBIFS_DBG(op) |
| 332 | #define ubifs_assert(expr) ({}) | 321 | |
| 333 | #define ubifs_assert_cmt_locked(c) | 322 | /* Use "if (0)" to make compiler check arguments even if debugging is off */ |
| 323 | #define ubifs_assert(expr) do { \ | ||
| 324 | if (0 && (expr)) \ | ||
| 325 | printk(KERN_CRIT "UBIFS assert failed in %s at %u (pid %d)\n", \ | ||
| 326 | __func__, __LINE__, current->pid); \ | ||
| 327 | } while (0) | ||
| 328 | |||
| 329 | #define dbg_err(fmt, ...) do { \ | ||
| 330 | if (0) \ | ||
| 331 | ubifs_err(fmt, ##__VA_ARGS__); \ | ||
| 332 | } while (0) | ||
| 333 | |||
| 334 | #define dbg_msg(fmt, ...) do { \ | ||
| 335 | if (0) \ | ||
| 336 | printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "\n", \ | ||
| 337 | current->pid, __func__, ##__VA_ARGS__); \ | ||
| 338 | } while (0) | ||
| 339 | |||
| 334 | #define dbg_dump_stack() | 340 | #define dbg_dump_stack() |
| 335 | #define dbg_err(fmt, ...) ({}) | 341 | #define ubifs_assert_cmt_locked(c) |
| 336 | #define dbg_msg(fmt, ...) ({}) | ||
| 337 | #define dbg_key(c, key, fmt, ...) ({}) | ||
| 338 | |||
| 339 | #define dbg_gen(fmt, ...) ({}) | ||
| 340 | #define dbg_jnl(fmt, ...) ({}) | ||
| 341 | #define dbg_tnc(fmt, ...) ({}) | ||
| 342 | #define dbg_lp(fmt, ...) ({}) | ||
| 343 | #define dbg_find(fmt, ...) ({}) | ||
| 344 | #define dbg_mnt(fmt, ...) ({}) | ||
| 345 | #define dbg_io(fmt, ...) ({}) | ||
| 346 | #define dbg_cmt(fmt, ...) ({}) | ||
| 347 | #define dbg_budg(fmt, ...) ({}) | ||
| 348 | #define dbg_log(fmt, ...) ({}) | ||
| 349 | #define dbg_gc(fmt, ...) ({}) | ||
| 350 | #define dbg_scan(fmt, ...) ({}) | ||
| 351 | #define dbg_rcvry(fmt, ...) ({}) | ||
| 352 | |||
| 353 | #define dbg_ntype(type) "" | ||
| 354 | #define dbg_cstate(cmt_state) "" | ||
| 355 | #define dbg_get_key_dump(c, key) ({}) | ||
| 356 | #define dbg_dump_inode(c, inode) ({}) | ||
| 357 | #define dbg_dump_node(c, node) ({}) | ||
| 358 | #define dbg_dump_budget_req(req) ({}) | ||
| 359 | #define dbg_dump_lstats(lst) ({}) | ||
| 360 | #define dbg_dump_budg(c) ({}) | ||
| 361 | #define dbg_dump_lprop(c, lp) ({}) | ||
| 362 | #define dbg_dump_lprops(c) ({}) | ||
| 363 | #define dbg_dump_leb(c, lnum) ({}) | ||
| 364 | #define dbg_dump_znode(c, znode) ({}) | ||
| 365 | #define dbg_dump_heap(c, heap, cat) ({}) | ||
| 366 | #define dbg_dump_pnode(c, pnode, parent, iip) ({}) | ||
| 367 | #define dbg_dump_tnc(c) ({}) | ||
| 368 | #define dbg_dump_index(c) ({}) | ||
| 369 | 342 | ||
| 370 | #define dbg_walk_index(c, leaf_cb, znode_cb, priv) 0 | 343 | #define dbg_gen(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
| 344 | #define dbg_jnl(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | ||
| 345 | #define dbg_tnc(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | ||
| 346 | #define dbg_lp(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | ||
| 347 | #define dbg_find(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | ||
| 348 | #define dbg_mnt(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | ||
| 349 | #define dbg_io(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | ||
| 350 | #define dbg_cmt(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | ||
| 351 | #define dbg_budg(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | ||
| 352 | #define dbg_log(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | ||
| 353 | #define dbg_gc(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | ||
| 354 | #define dbg_scan(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | ||
| 355 | #define dbg_rcvry(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | ||
| 356 | |||
| 357 | #define DBGKEY(key) ((char *)(key)) | ||
| 358 | #define DBGKEY1(key) ((char *)(key)) | ||
| 359 | |||
| 360 | #define dbg_ntype(type) "" | ||
| 361 | #define dbg_cstate(cmt_state) "" | ||
| 362 | #define dbg_get_key_dump(c, key) ({}) | ||
| 363 | #define dbg_dump_inode(c, inode) ({}) | ||
| 364 | #define dbg_dump_node(c, node) ({}) | ||
| 365 | #define dbg_dump_budget_req(req) ({}) | ||
| 366 | #define dbg_dump_lstats(lst) ({}) | ||
| 367 | #define dbg_dump_budg(c) ({}) | ||
| 368 | #define dbg_dump_lprop(c, lp) ({}) | ||
| 369 | #define dbg_dump_lprops(c) ({}) | ||
| 370 | #define dbg_dump_leb(c, lnum) ({}) | ||
| 371 | #define dbg_dump_znode(c, znode) ({}) | ||
| 372 | #define dbg_dump_heap(c, heap, cat) ({}) | ||
| 373 | #define dbg_dump_pnode(c, pnode, parent, iip) ({}) | ||
| 374 | #define dbg_dump_tnc(c) ({}) | ||
| 375 | #define dbg_dump_index(c) ({}) | ||
| 371 | 376 | ||
| 377 | #define dbg_walk_index(c, leaf_cb, znode_cb, priv) 0 | ||
| 372 | #define dbg_old_index_check_init(c, zroot) 0 | 378 | #define dbg_old_index_check_init(c, zroot) 0 |
| 373 | #define dbg_check_old_index(c, zroot) 0 | 379 | #define dbg_check_old_index(c, zroot) 0 |
| 374 | |||
| 375 | #define dbg_check_cats(c) 0 | 380 | #define dbg_check_cats(c) 0 |
| 376 | |||
| 377 | #define dbg_check_ltab(c) 0 | 381 | #define dbg_check_ltab(c) 0 |
| 378 | |||
| 379 | #define dbg_check_synced_i_size(inode) 0 | 382 | #define dbg_check_synced_i_size(inode) 0 |
| 380 | |||
| 381 | #define dbg_check_dir_size(c, dir) 0 | 383 | #define dbg_check_dir_size(c, dir) 0 |
| 382 | |||
| 383 | #define dbg_check_tnc(c, x) 0 | 384 | #define dbg_check_tnc(c, x) 0 |
| 384 | |||
| 385 | #define dbg_check_idx_size(c, idx_size) 0 | 385 | #define dbg_check_idx_size(c, idx_size) 0 |
| 386 | |||
| 387 | #define dbg_check_filesystem(c) 0 | 386 | #define dbg_check_filesystem(c) 0 |
| 388 | |||
| 389 | #define dbg_check_heap(c, heap, cat, add_pos) ({}) | 387 | #define dbg_check_heap(c, heap, cat, add_pos) ({}) |
| 390 | |||
| 391 | #define dbg_check_lprops(c) 0 | 388 | #define dbg_check_lprops(c) 0 |
| 392 | #define dbg_check_lpt_nodes(c, cnode, row, col) 0 | 389 | #define dbg_check_lpt_nodes(c, cnode, row, col) 0 |
| 393 | |||
| 394 | #define dbg_force_in_the_gaps_enabled 0 | 390 | #define dbg_force_in_the_gaps_enabled 0 |
| 395 | #define dbg_force_in_the_gaps() 0 | 391 | #define dbg_force_in_the_gaps() 0 |
| 396 | |||
| 397 | #define dbg_failure_mode 0 | 392 | #define dbg_failure_mode 0 |
| 398 | #define dbg_failure_mode_registration(c) ({}) | 393 | #define dbg_failure_mode_registration(c) ({}) |
| 399 | #define dbg_failure_mode_deregistration(c) ({}) | 394 | #define dbg_failure_mode_deregistration(c) ({}) |
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index e90374be7d3b..5c96f1fb7016 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c | |||
| @@ -165,7 +165,6 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir, | |||
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | inode->i_ino = ++c->highest_inum; | 167 | inode->i_ino = ++c->highest_inum; |
| 168 | inode->i_generation = ++c->vfs_gen; | ||
| 169 | /* | 168 | /* |
| 170 | * The creation sequence number remains with this inode for its | 169 | * The creation sequence number remains with this inode for its |
| 171 | * lifetime. All nodes for this inode have a greater sequence number, | 170 | * lifetime. All nodes for this inode have a greater sequence number, |
| @@ -220,15 +219,7 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry, | |||
| 220 | 219 | ||
| 221 | err = ubifs_tnc_lookup_nm(c, &key, dent, &dentry->d_name); | 220 | err = ubifs_tnc_lookup_nm(c, &key, dent, &dentry->d_name); |
| 222 | if (err) { | 221 | if (err) { |
| 223 | /* | 222 | if (err == -ENOENT) { |
| 224 | * Do not hash the direntry if parent 'i_nlink' is zero, because | ||
| 225 | * this has side-effects - '->delete_inode()' call will not be | ||
| 226 | * called for the parent orphan inode, because 'd_count' of its | ||
| 227 | * direntry will stay 1 (it'll be negative direntry I guess) | ||
| 228 | * and prevent 'iput_final()' until the dentry is destroyed due | ||
| 229 | * to unmount or memory pressure. | ||
| 230 | */ | ||
| 231 | if (err == -ENOENT && dir->i_nlink != 0) { | ||
| 232 | dbg_gen("not found"); | 223 | dbg_gen("not found"); |
| 233 | goto done; | 224 | goto done; |
| 234 | } | 225 | } |
| @@ -525,7 +516,7 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir, | |||
| 525 | struct ubifs_inode *dir_ui = ubifs_inode(dir); | 516 | struct ubifs_inode *dir_ui = ubifs_inode(dir); |
| 526 | int err, sz_change = CALC_DENT_SIZE(dentry->d_name.len); | 517 | int err, sz_change = CALC_DENT_SIZE(dentry->d_name.len); |
| 527 | struct ubifs_budget_req req = { .new_dent = 1, .dirtied_ino = 2, | 518 | struct ubifs_budget_req req = { .new_dent = 1, .dirtied_ino = 2, |
| 528 | .dirtied_ino_d = ui->data_len }; | 519 | .dirtied_ino_d = ALIGN(ui->data_len, 8) }; |
| 529 | 520 | ||
| 530 | /* | 521 | /* |
| 531 | * Budget request settings: new direntry, changing the target inode, | 522 | * Budget request settings: new direntry, changing the target inode, |
| @@ -727,8 +718,7 @@ static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
| 727 | struct ubifs_inode *dir_ui = ubifs_inode(dir); | 718 | struct ubifs_inode *dir_ui = ubifs_inode(dir); |
| 728 | struct ubifs_info *c = dir->i_sb->s_fs_info; | 719 | struct ubifs_info *c = dir->i_sb->s_fs_info; |
| 729 | int err, sz_change = CALC_DENT_SIZE(dentry->d_name.len); | 720 | int err, sz_change = CALC_DENT_SIZE(dentry->d_name.len); |
| 730 | struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1, | 721 | struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1 }; |
| 731 | .dirtied_ino_d = 1 }; | ||
| 732 | 722 | ||
| 733 | /* | 723 | /* |
| 734 | * Budget request settings: new inode, new direntry and changing parent | 724 | * Budget request settings: new inode, new direntry and changing parent |
| @@ -789,7 +779,8 @@ static int ubifs_mknod(struct inode *dir, struct dentry *dentry, | |||
| 789 | int sz_change = CALC_DENT_SIZE(dentry->d_name.len); | 779 | int sz_change = CALC_DENT_SIZE(dentry->d_name.len); |
| 790 | int err, devlen = 0; | 780 | int err, devlen = 0; |
| 791 | struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1, | 781 | struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1, |
| 792 | .new_ino_d = devlen, .dirtied_ino = 1 }; | 782 | .new_ino_d = ALIGN(devlen, 8), |
| 783 | .dirtied_ino = 1 }; | ||
| 793 | 784 | ||
| 794 | /* | 785 | /* |
| 795 | * Budget request settings: new inode, new direntry and changing parent | 786 | * Budget request settings: new inode, new direntry and changing parent |
| @@ -863,7 +854,8 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry, | |||
| 863 | int err, len = strlen(symname); | 854 | int err, len = strlen(symname); |
| 864 | int sz_change = CALC_DENT_SIZE(dentry->d_name.len); | 855 | int sz_change = CALC_DENT_SIZE(dentry->d_name.len); |
| 865 | struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1, | 856 | struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1, |
| 866 | .new_ino_d = len, .dirtied_ino = 1 }; | 857 | .new_ino_d = ALIGN(len, 8), |
| 858 | .dirtied_ino = 1 }; | ||
| 867 | 859 | ||
| 868 | /* | 860 | /* |
| 869 | * Budget request settings: new inode, new direntry and changing parent | 861 | * Budget request settings: new inode, new direntry and changing parent |
| @@ -1012,7 +1004,7 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 1012 | struct ubifs_budget_req req = { .new_dent = 1, .mod_dent = 1, | 1004 | struct ubifs_budget_req req = { .new_dent = 1, .mod_dent = 1, |
| 1013 | .dirtied_ino = 3 }; | 1005 | .dirtied_ino = 3 }; |
| 1014 | struct ubifs_budget_req ino_req = { .dirtied_ino = 1, | 1006 | struct ubifs_budget_req ino_req = { .dirtied_ino = 1, |
| 1015 | .dirtied_ino_d = old_inode_ui->data_len }; | 1007 | .dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) }; |
| 1016 | struct timespec time; | 1008 | struct timespec time; |
| 1017 | 1009 | ||
| 1018 | /* | 1010 | /* |
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 8565e586e533..4071d1cae29f 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c | |||
| @@ -890,7 +890,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode, | |||
| 890 | loff_t new_size = attr->ia_size; | 890 | loff_t new_size = attr->ia_size; |
| 891 | struct ubifs_inode *ui = ubifs_inode(inode); | 891 | struct ubifs_inode *ui = ubifs_inode(inode); |
| 892 | struct ubifs_budget_req req = { .dirtied_ino = 1, | 892 | struct ubifs_budget_req req = { .dirtied_ino = 1, |
| 893 | .dirtied_ino_d = ui->data_len }; | 893 | .dirtied_ino_d = ALIGN(ui->data_len, 8) }; |
| 894 | 894 | ||
| 895 | err = ubifs_budget_space(c, &req); | 895 | err = ubifs_budget_space(c, &req); |
| 896 | if (err) | 896 | if (err) |
| @@ -941,7 +941,8 @@ int ubifs_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 941 | struct inode *inode = dentry->d_inode; | 941 | struct inode *inode = dentry->d_inode; |
| 942 | struct ubifs_info *c = inode->i_sb->s_fs_info; | 942 | struct ubifs_info *c = inode->i_sb->s_fs_info; |
| 943 | 943 | ||
| 944 | dbg_gen("ino %lu, ia_valid %#x", inode->i_ino, attr->ia_valid); | 944 | dbg_gen("ino %lu, mode %#x, ia_valid %#x", |
| 945 | inode->i_ino, inode->i_mode, attr->ia_valid); | ||
| 945 | err = inode_change_ok(inode, attr); | 946 | err = inode_change_ok(inode, attr); |
| 946 | if (err) | 947 | if (err) |
| 947 | return err; | 948 | return err; |
| @@ -1051,7 +1052,7 @@ static int update_mctime(struct ubifs_info *c, struct inode *inode) | |||
| 1051 | if (mctime_update_needed(inode, &now)) { | 1052 | if (mctime_update_needed(inode, &now)) { |
| 1052 | int err, release; | 1053 | int err, release; |
| 1053 | struct ubifs_budget_req req = { .dirtied_ino = 1, | 1054 | struct ubifs_budget_req req = { .dirtied_ino = 1, |
| 1054 | .dirtied_ino_d = ui->data_len }; | 1055 | .dirtied_ino_d = ALIGN(ui->data_len, 8) }; |
| 1055 | 1056 | ||
| 1056 | err = ubifs_budget_space(c, &req); | 1057 | err = ubifs_budget_space(c, &req); |
| 1057 | if (err) | 1058 | if (err) |
| @@ -1270,6 +1271,7 @@ struct file_operations ubifs_file_operations = { | |||
| 1270 | .fsync = ubifs_fsync, | 1271 | .fsync = ubifs_fsync, |
| 1271 | .unlocked_ioctl = ubifs_ioctl, | 1272 | .unlocked_ioctl = ubifs_ioctl, |
| 1272 | .splice_read = generic_file_splice_read, | 1273 | .splice_read = generic_file_splice_read, |
| 1274 | .splice_write = generic_file_splice_write, | ||
| 1273 | #ifdef CONFIG_COMPAT | 1275 | #ifdef CONFIG_COMPAT |
| 1274 | .compat_ioctl = ubifs_compat_ioctl, | 1276 | .compat_ioctl = ubifs_compat_ioctl, |
| 1275 | #endif | 1277 | #endif |
diff --git a/fs/ubifs/find.c b/fs/ubifs/find.c index 10394c548367..adee7b5ddeab 100644 --- a/fs/ubifs/find.c +++ b/fs/ubifs/find.c | |||
| @@ -290,9 +290,14 @@ int ubifs_find_dirty_leb(struct ubifs_info *c, struct ubifs_lprops *ret_lp, | |||
| 290 | idx_lp = idx_heap->arr[0]; | 290 | idx_lp = idx_heap->arr[0]; |
| 291 | sum = idx_lp->free + idx_lp->dirty; | 291 | sum = idx_lp->free + idx_lp->dirty; |
| 292 | /* | 292 | /* |
| 293 | * Since we reserve twice as more space for the index than it | 293 | * Since we reserve thrice as much space for the index than it |
| 294 | * actually takes, it does not make sense to pick indexing LEBs | 294 | * actually takes, it does not make sense to pick indexing LEBs |
| 295 | * with less than half LEB of dirty space. | 295 | * with less than, say, half LEB of dirty space. May be half is |
| 296 | * not the optimal boundary - this should be tested and | ||
| 297 | * checked. This boundary should determine how much we use | ||
| 298 | * in-the-gaps to consolidate the index comparing to how much | ||
| 299 | * we use garbage collector to consolidate it. The "half" | ||
| 300 | * criteria just feels to be fine. | ||
| 296 | */ | 301 | */ |
| 297 | if (sum < min_space || sum < c->half_leb_size) | 302 | if (sum < min_space || sum < c->half_leb_size) |
| 298 | idx_lp = NULL; | 303 | idx_lp = NULL; |
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index 3374f91b6709..054363f2b207 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c | |||
| @@ -54,6 +54,20 @@ | |||
| 54 | #include "ubifs.h" | 54 | #include "ubifs.h" |
| 55 | 55 | ||
| 56 | /** | 56 | /** |
| 57 | * ubifs_ro_mode - switch UBIFS to read read-only mode. | ||
| 58 | * @c: UBIFS file-system description object | ||
| 59 | * @err: error code which is the reason of switching to R/O mode | ||
| 60 | */ | ||
| 61 | void ubifs_ro_mode(struct ubifs_info *c, int err) | ||
| 62 | { | ||
| 63 | if (!c->ro_media) { | ||
| 64 | c->ro_media = 1; | ||
| 65 | ubifs_warn("switched to read-only mode, error %d", err); | ||
| 66 | dbg_dump_stack(); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | /** | ||
| 57 | * ubifs_check_node - check node. | 71 | * ubifs_check_node - check node. |
| 58 | * @c: UBIFS file-system description object | 72 | * @c: UBIFS file-system description object |
| 59 | * @buf: node to check | 73 | * @buf: node to check |
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index 283155abe5f5..22993f867d19 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c | |||
| @@ -447,13 +447,11 @@ static int get_dent_type(int mode) | |||
| 447 | * @ino: buffer in which to pack inode node | 447 | * @ino: buffer in which to pack inode node |
| 448 | * @inode: inode to pack | 448 | * @inode: inode to pack |
| 449 | * @last: indicates the last node of the group | 449 | * @last: indicates the last node of the group |
| 450 | * @last_reference: non-zero if this is a deletion inode | ||
| 451 | */ | 450 | */ |
| 452 | static void pack_inode(struct ubifs_info *c, struct ubifs_ino_node *ino, | 451 | static void pack_inode(struct ubifs_info *c, struct ubifs_ino_node *ino, |
| 453 | const struct inode *inode, int last, | 452 | const struct inode *inode, int last) |
| 454 | int last_reference) | ||
| 455 | { | 453 | { |
| 456 | int data_len = 0; | 454 | int data_len = 0, last_reference = !inode->i_nlink; |
| 457 | struct ubifs_inode *ui = ubifs_inode(inode); | 455 | struct ubifs_inode *ui = ubifs_inode(inode); |
| 458 | 456 | ||
| 459 | ino->ch.node_type = UBIFS_INO_NODE; | 457 | ino->ch.node_type = UBIFS_INO_NODE; |
| @@ -596,9 +594,9 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir, | |||
| 596 | ubifs_prep_grp_node(c, dent, dlen, 0); | 594 | ubifs_prep_grp_node(c, dent, dlen, 0); |
| 597 | 595 | ||
| 598 | ino = (void *)dent + aligned_dlen; | 596 | ino = (void *)dent + aligned_dlen; |
| 599 | pack_inode(c, ino, inode, 0, last_reference); | 597 | pack_inode(c, ino, inode, 0); |
| 600 | ino = (void *)ino + aligned_ilen; | 598 | ino = (void *)ino + aligned_ilen; |
| 601 | pack_inode(c, ino, dir, 1, 0); | 599 | pack_inode(c, ino, dir, 1); |
| 602 | 600 | ||
| 603 | if (last_reference) { | 601 | if (last_reference) { |
| 604 | err = ubifs_add_orphan(c, inode->i_ino); | 602 | err = ubifs_add_orphan(c, inode->i_ino); |
| @@ -606,6 +604,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir, | |||
| 606 | release_head(c, BASEHD); | 604 | release_head(c, BASEHD); |
| 607 | goto out_finish; | 605 | goto out_finish; |
| 608 | } | 606 | } |
| 607 | ui->del_cmtno = c->cmt_no; | ||
| 609 | } | 608 | } |
| 610 | 609 | ||
| 611 | err = write_head(c, BASEHD, dent, len, &lnum, &dent_offs, sync); | 610 | err = write_head(c, BASEHD, dent, len, &lnum, &dent_offs, sync); |
| @@ -750,30 +749,25 @@ out_free: | |||
| 750 | * ubifs_jnl_write_inode - flush inode to the journal. | 749 | * ubifs_jnl_write_inode - flush inode to the journal. |
| 751 | * @c: UBIFS file-system description object | 750 | * @c: UBIFS file-system description object |
| 752 | * @inode: inode to flush | 751 | * @inode: inode to flush |
| 753 | * @deletion: inode has been deleted | ||
| 754 | * | 752 | * |
| 755 | * This function writes inode @inode to the journal. If the inode is | 753 | * This function writes inode @inode to the journal. If the inode is |
| 756 | * synchronous, it also synchronizes the write-buffer. Returns zero in case of | 754 | * synchronous, it also synchronizes the write-buffer. Returns zero in case of |
| 757 | * success and a negative error code in case of failure. | 755 | * success and a negative error code in case of failure. |
| 758 | */ | 756 | */ |
| 759 | int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode, | 757 | int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode) |
| 760 | int deletion) | ||
| 761 | { | 758 | { |
| 762 | int err, len, lnum, offs, sync = 0; | 759 | int err, lnum, offs; |
| 763 | struct ubifs_ino_node *ino; | 760 | struct ubifs_ino_node *ino; |
| 764 | struct ubifs_inode *ui = ubifs_inode(inode); | 761 | struct ubifs_inode *ui = ubifs_inode(inode); |
| 762 | int sync = 0, len = UBIFS_INO_NODE_SZ, last_reference = !inode->i_nlink; | ||
| 765 | 763 | ||
| 766 | dbg_jnl("ino %lu%s", inode->i_ino, | 764 | dbg_jnl("ino %lu, nlink %u", inode->i_ino, inode->i_nlink); |
| 767 | deletion ? " (last reference)" : ""); | ||
| 768 | if (deletion) | ||
| 769 | ubifs_assert(inode->i_nlink == 0); | ||
| 770 | 765 | ||
| 771 | len = UBIFS_INO_NODE_SZ; | ||
| 772 | /* | 766 | /* |
| 773 | * If the inode is being deleted, do not write the attached data. No | 767 | * If the inode is being deleted, do not write the attached data. No |
| 774 | * need to synchronize the write-buffer either. | 768 | * need to synchronize the write-buffer either. |
| 775 | */ | 769 | */ |
| 776 | if (!deletion) { | 770 | if (!last_reference) { |
| 777 | len += ui->data_len; | 771 | len += ui->data_len; |
| 778 | sync = IS_SYNC(inode); | 772 | sync = IS_SYNC(inode); |
| 779 | } | 773 | } |
| @@ -786,7 +780,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode, | |||
| 786 | if (err) | 780 | if (err) |
| 787 | goto out_free; | 781 | goto out_free; |
| 788 | 782 | ||
| 789 | pack_inode(c, ino, inode, 1, deletion); | 783 | pack_inode(c, ino, inode, 1); |
| 790 | err = write_head(c, BASEHD, ino, len, &lnum, &offs, sync); | 784 | err = write_head(c, BASEHD, ino, len, &lnum, &offs, sync); |
| 791 | if (err) | 785 | if (err) |
| 792 | goto out_release; | 786 | goto out_release; |
| @@ -795,7 +789,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode, | |||
| 795 | inode->i_ino); | 789 | inode->i_ino); |
| 796 | release_head(c, BASEHD); | 790 | release_head(c, BASEHD); |
| 797 | 791 | ||
| 798 | if (deletion) { | 792 | if (last_reference) { |
| 799 | err = ubifs_tnc_remove_ino(c, inode->i_ino); | 793 | err = ubifs_tnc_remove_ino(c, inode->i_ino); |
| 800 | if (err) | 794 | if (err) |
| 801 | goto out_ro; | 795 | goto out_ro; |
| @@ -828,6 +822,65 @@ out_free: | |||
| 828 | } | 822 | } |
| 829 | 823 | ||
| 830 | /** | 824 | /** |
| 825 | * ubifs_jnl_delete_inode - delete an inode. | ||
| 826 | * @c: UBIFS file-system description object | ||
| 827 | * @inode: inode to delete | ||
| 828 | * | ||
| 829 | * This function deletes inode @inode which includes removing it from orphans, | ||
| 830 | * deleting it from TNC and, in some cases, writing a deletion inode to the | ||
| 831 | * journal. | ||
| 832 | * | ||
| 833 | * When regular file inodes are unlinked or a directory inode is removed, the | ||
| 834 | * 'ubifs_jnl_update()' function writes a corresponding deletion inode and | ||
| 835 | * direntry to the media, and adds the inode to orphans. After this, when the | ||
| 836 | * last reference to this inode has been dropped, this function is called. In | ||
| 837 | * general, it has to write one more deletion inode to the media, because if | ||
| 838 | * a commit happened between 'ubifs_jnl_update()' and | ||
| 839 | * 'ubifs_jnl_delete_inode()', the deletion inode is not in the journal | ||
| 840 | * anymore, and in fact it might not be on the flash anymore, because it might | ||
| 841 | * have been garbage-collected already. And for optimization reasons UBIFS does | ||
| 842 | * not read the orphan area if it has been unmounted cleanly, so it would have | ||
| 843 | * no indication in the journal that there is a deleted inode which has to be | ||
| 844 | * removed from TNC. | ||
| 845 | * | ||
| 846 | * However, if there was no commit between 'ubifs_jnl_update()' and | ||
| 847 | * 'ubifs_jnl_delete_inode()', then there is no need to write the deletion | ||
| 848 | * inode to the media for the second time. And this is quite a typical case. | ||
| 849 | * | ||
| 850 | * This function returns zero in case of success and a negative error code in | ||
| 851 | * case of failure. | ||
| 852 | */ | ||
| 853 | int ubifs_jnl_delete_inode(struct ubifs_info *c, const struct inode *inode) | ||
| 854 | { | ||
| 855 | int err; | ||
| 856 | struct ubifs_inode *ui = ubifs_inode(inode); | ||
| 857 | |||
| 858 | ubifs_assert(inode->i_nlink == 0); | ||
| 859 | |||
| 860 | if (ui->del_cmtno != c->cmt_no) | ||
| 861 | /* A commit happened for sure */ | ||
| 862 | return ubifs_jnl_write_inode(c, inode); | ||
| 863 | |||
| 864 | down_read(&c->commit_sem); | ||
| 865 | /* | ||
| 866 | * Check commit number again, because the first test has been done | ||
| 867 | * without @c->commit_sem, so a commit might have happened. | ||
| 868 | */ | ||
| 869 | if (ui->del_cmtno != c->cmt_no) { | ||
| 870 | up_read(&c->commit_sem); | ||
| 871 | return ubifs_jnl_write_inode(c, inode); | ||
| 872 | } | ||
| 873 | |||
| 874 | err = ubifs_tnc_remove_ino(c, inode->i_ino); | ||
| 875 | if (err) | ||
| 876 | ubifs_ro_mode(c, err); | ||
| 877 | else | ||
| 878 | ubifs_delete_orphan(c, inode->i_ino); | ||
| 879 | up_read(&c->commit_sem); | ||
| 880 | return err; | ||
| 881 | } | ||
| 882 | |||
| 883 | /** | ||
| 831 | * ubifs_jnl_rename - rename a directory entry. | 884 | * ubifs_jnl_rename - rename a directory entry. |
| 832 | * @c: UBIFS file-system description object | 885 | * @c: UBIFS file-system description object |
| 833 | * @old_dir: parent inode of directory entry to rename | 886 | * @old_dir: parent inode of directory entry to rename |
| @@ -917,16 +970,16 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir, | |||
| 917 | 970 | ||
| 918 | p = (void *)dent2 + aligned_dlen2; | 971 | p = (void *)dent2 + aligned_dlen2; |
| 919 | if (new_inode) { | 972 | if (new_inode) { |
| 920 | pack_inode(c, p, new_inode, 0, last_reference); | 973 | pack_inode(c, p, new_inode, 0); |
| 921 | p += ALIGN(ilen, 8); | 974 | p += ALIGN(ilen, 8); |
| 922 | } | 975 | } |
| 923 | 976 | ||
| 924 | if (!move) | 977 | if (!move) |
| 925 | pack_inode(c, p, old_dir, 1, 0); | 978 | pack_inode(c, p, old_dir, 1); |
| 926 | else { | 979 | else { |
| 927 | pack_inode(c, p, old_dir, 0, 0); | 980 | pack_inode(c, p, old_dir, 0); |
| 928 | p += ALIGN(plen, 8); | 981 | p += ALIGN(plen, 8); |
| 929 | pack_inode(c, p, new_dir, 1, 0); | 982 | pack_inode(c, p, new_dir, 1); |
| 930 | } | 983 | } |
| 931 | 984 | ||
| 932 | if (last_reference) { | 985 | if (last_reference) { |
| @@ -935,6 +988,7 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir, | |||
| 935 | release_head(c, BASEHD); | 988 | release_head(c, BASEHD); |
| 936 | goto out_finish; | 989 | goto out_finish; |
| 937 | } | 990 | } |
| 991 | new_ui->del_cmtno = c->cmt_no; | ||
| 938 | } | 992 | } |
| 939 | 993 | ||
| 940 | err = write_head(c, BASEHD, dent, len, &lnum, &offs, sync); | 994 | err = write_head(c, BASEHD, dent, len, &lnum, &offs, sync); |
| @@ -1131,7 +1185,7 @@ int ubifs_jnl_truncate(struct ubifs_info *c, const struct inode *inode, | |||
| 1131 | if (err) | 1185 | if (err) |
| 1132 | goto out_free; | 1186 | goto out_free; |
| 1133 | 1187 | ||
| 1134 | pack_inode(c, ino, inode, 0, 0); | 1188 | pack_inode(c, ino, inode, 0); |
| 1135 | ubifs_prep_grp_node(c, trun, UBIFS_TRUN_NODE_SZ, dlen ? 0 : 1); | 1189 | ubifs_prep_grp_node(c, trun, UBIFS_TRUN_NODE_SZ, dlen ? 0 : 1); |
| 1136 | if (dlen) | 1190 | if (dlen) |
| 1137 | ubifs_prep_grp_node(c, dn, dlen, 1); | 1191 | ubifs_prep_grp_node(c, dn, dlen, 1); |
| @@ -1251,9 +1305,9 @@ int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host, | |||
| 1251 | ubifs_prep_grp_node(c, xent, xlen, 0); | 1305 | ubifs_prep_grp_node(c, xent, xlen, 0); |
| 1252 | 1306 | ||
| 1253 | ino = (void *)xent + aligned_xlen; | 1307 | ino = (void *)xent + aligned_xlen; |
| 1254 | pack_inode(c, ino, inode, 0, 1); | 1308 | pack_inode(c, ino, inode, 0); |
| 1255 | ino = (void *)ino + UBIFS_INO_NODE_SZ; | 1309 | ino = (void *)ino + UBIFS_INO_NODE_SZ; |
| 1256 | pack_inode(c, ino, host, 1, 0); | 1310 | pack_inode(c, ino, host, 1); |
| 1257 | 1311 | ||
| 1258 | err = write_head(c, BASEHD, xent, len, &lnum, &xent_offs, sync); | 1312 | err = write_head(c, BASEHD, xent, len, &lnum, &xent_offs, sync); |
| 1259 | if (!sync && !err) | 1313 | if (!sync && !err) |
| @@ -1320,7 +1374,7 @@ int ubifs_jnl_change_xattr(struct ubifs_info *c, const struct inode *inode, | |||
| 1320 | const struct inode *host) | 1374 | const struct inode *host) |
| 1321 | { | 1375 | { |
| 1322 | int err, len1, len2, aligned_len, aligned_len1, lnum, offs; | 1376 | int err, len1, len2, aligned_len, aligned_len1, lnum, offs; |
| 1323 | struct ubifs_inode *host_ui = ubifs_inode(inode); | 1377 | struct ubifs_inode *host_ui = ubifs_inode(host); |
| 1324 | struct ubifs_ino_node *ino; | 1378 | struct ubifs_ino_node *ino; |
| 1325 | union ubifs_key key; | 1379 | union ubifs_key key; |
| 1326 | int sync = IS_DIRSYNC(host); | 1380 | int sync = IS_DIRSYNC(host); |
| @@ -1344,8 +1398,8 @@ int ubifs_jnl_change_xattr(struct ubifs_info *c, const struct inode *inode, | |||
| 1344 | if (err) | 1398 | if (err) |
| 1345 | goto out_free; | 1399 | goto out_free; |
| 1346 | 1400 | ||
| 1347 | pack_inode(c, ino, host, 0, 0); | 1401 | pack_inode(c, ino, host, 0); |
| 1348 | pack_inode(c, (void *)ino + aligned_len1, inode, 1, 0); | 1402 | pack_inode(c, (void *)ino + aligned_len1, inode, 1); |
| 1349 | 1403 | ||
| 1350 | err = write_head(c, BASEHD, ino, aligned_len, &lnum, &offs, 0); | 1404 | err = write_head(c, BASEHD, ino, aligned_len, &lnum, &offs, 0); |
| 1351 | if (!sync && !err) { | 1405 | if (!sync && !err) { |
diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c index 36857b9ed59e..3e0aa7367556 100644 --- a/fs/ubifs/log.c +++ b/fs/ubifs/log.c | |||
| @@ -317,6 +317,8 @@ int ubifs_add_bud_to_log(struct ubifs_info *c, int jhead, int lnum, int offs) | |||
| 317 | return 0; | 317 | return 0; |
| 318 | 318 | ||
| 319 | out_unlock: | 319 | out_unlock: |
| 320 | if (err != -EAGAIN) | ||
| 321 | ubifs_ro_mode(c, err); | ||
| 320 | mutex_unlock(&c->log_mutex); | 322 | mutex_unlock(&c->log_mutex); |
| 321 | kfree(ref); | 323 | kfree(ref); |
| 322 | kfree(bud); | 324 | kfree(bud); |
| @@ -410,7 +412,7 @@ int ubifs_log_start_commit(struct ubifs_info *c, int *ltail_lnum) | |||
| 410 | return -ENOMEM; | 412 | return -ENOMEM; |
| 411 | 413 | ||
| 412 | cs->ch.node_type = UBIFS_CS_NODE; | 414 | cs->ch.node_type = UBIFS_CS_NODE; |
| 413 | cs->cmt_no = cpu_to_le64(c->cmt_no + 1); | 415 | cs->cmt_no = cpu_to_le64(c->cmt_no); |
| 414 | ubifs_prepare_node(c, cs, UBIFS_CS_NODE_SZ, 0); | 416 | ubifs_prepare_node(c, cs, UBIFS_CS_NODE_SZ, 0); |
| 415 | 417 | ||
| 416 | /* | 418 | /* |
diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h index 4beccfc256d2..87dabf9fe742 100644 --- a/fs/ubifs/misc.h +++ b/fs/ubifs/misc.h | |||
| @@ -80,20 +80,6 @@ static inline struct ubifs_inode *ubifs_inode(const struct inode *inode) | |||
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | /** | 82 | /** |
| 83 | * ubifs_ro_mode - switch UBIFS to read read-only mode. | ||
| 84 | * @c: UBIFS file-system description object | ||
| 85 | * @err: error code which is the reason of switching to R/O mode | ||
| 86 | */ | ||
| 87 | static inline void ubifs_ro_mode(struct ubifs_info *c, int err) | ||
| 88 | { | ||
| 89 | if (!c->ro_media) { | ||
| 90 | c->ro_media = 1; | ||
| 91 | ubifs_warn("switched to read-only mode, error %d", err); | ||
| 92 | dbg_dump_stack(); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 96 | /** | ||
| 97 | * ubifs_compr_present - check if compressor was compiled in. | 83 | * ubifs_compr_present - check if compressor was compiled in. |
| 98 | * @compr_type: compressor type to check | 84 | * @compr_type: compressor type to check |
| 99 | * | 85 | * |
| @@ -322,7 +308,7 @@ static inline long long ubifs_reported_space(const struct ubifs_info *c, | |||
| 322 | { | 308 | { |
| 323 | int divisor, factor; | 309 | int divisor, factor; |
| 324 | 310 | ||
| 325 | divisor = UBIFS_MAX_DATA_NODE_SZ + (c->max_idx_node_sz << 1); | 311 | divisor = UBIFS_MAX_DATA_NODE_SZ + (c->max_idx_node_sz * 3); |
| 326 | factor = UBIFS_MAX_DATA_NODE_SZ - UBIFS_DATA_NODE_SZ; | 312 | factor = UBIFS_MAX_DATA_NODE_SZ - UBIFS_DATA_NODE_SZ; |
| 327 | do_div(free, divisor); | 313 | do_div(free, divisor); |
| 328 | 314 | ||
diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c index 3afeb9242c6a..02d3462f4d3e 100644 --- a/fs/ubifs/orphan.c +++ b/fs/ubifs/orphan.c | |||
| @@ -310,10 +310,10 @@ static int write_orph_node(struct ubifs_info *c, int atomic) | |||
| 310 | c->cmt_orphans -= cnt; | 310 | c->cmt_orphans -= cnt; |
| 311 | spin_unlock(&c->orphan_lock); | 311 | spin_unlock(&c->orphan_lock); |
| 312 | if (c->cmt_orphans) | 312 | if (c->cmt_orphans) |
| 313 | orph->cmt_no = cpu_to_le64(c->cmt_no + 1); | 313 | orph->cmt_no = cpu_to_le64(c->cmt_no); |
| 314 | else | 314 | else |
| 315 | /* Mark the last node of the commit */ | 315 | /* Mark the last node of the commit */ |
| 316 | orph->cmt_no = cpu_to_le64((c->cmt_no + 1) | (1ULL << 63)); | 316 | orph->cmt_no = cpu_to_le64((c->cmt_no) | (1ULL << 63)); |
| 317 | ubifs_assert(c->ohead_offs + len <= c->leb_size); | 317 | ubifs_assert(c->ohead_offs + len <= c->leb_size); |
| 318 | ubifs_assert(c->ohead_lnum >= c->orph_first); | 318 | ubifs_assert(c->ohead_lnum >= c->orph_first); |
| 319 | ubifs_assert(c->ohead_lnum <= c->orph_last); | 319 | ubifs_assert(c->ohead_lnum <= c->orph_last); |
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index ca1e2d4e03cc..f71e6b8822c4 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
| @@ -30,7 +30,6 @@ | |||
| 30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
| 31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
| 32 | #include <linux/ctype.h> | 32 | #include <linux/ctype.h> |
| 33 | #include <linux/random.h> | ||
| 34 | #include <linux/kthread.h> | 33 | #include <linux/kthread.h> |
| 35 | #include <linux/parser.h> | 34 | #include <linux/parser.h> |
| 36 | #include <linux/seq_file.h> | 35 | #include <linux/seq_file.h> |
| @@ -149,7 +148,7 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum) | |||
| 149 | if (err) | 148 | if (err) |
| 150 | goto out_invalid; | 149 | goto out_invalid; |
| 151 | 150 | ||
| 152 | /* Disable readahead */ | 151 | /* Disable read-ahead */ |
| 153 | inode->i_mapping->backing_dev_info = &c->bdi; | 152 | inode->i_mapping->backing_dev_info = &c->bdi; |
| 154 | 153 | ||
| 155 | switch (inode->i_mode & S_IFMT) { | 154 | switch (inode->i_mode & S_IFMT) { |
| @@ -278,7 +277,7 @@ static void ubifs_destroy_inode(struct inode *inode) | |||
| 278 | */ | 277 | */ |
| 279 | static int ubifs_write_inode(struct inode *inode, int wait) | 278 | static int ubifs_write_inode(struct inode *inode, int wait) |
| 280 | { | 279 | { |
| 281 | int err; | 280 | int err = 0; |
| 282 | struct ubifs_info *c = inode->i_sb->s_fs_info; | 281 | struct ubifs_info *c = inode->i_sb->s_fs_info; |
| 283 | struct ubifs_inode *ui = ubifs_inode(inode); | 282 | struct ubifs_inode *ui = ubifs_inode(inode); |
| 284 | 283 | ||
| @@ -299,10 +298,18 @@ static int ubifs_write_inode(struct inode *inode, int wait) | |||
| 299 | return 0; | 298 | return 0; |
| 300 | } | 299 | } |
| 301 | 300 | ||
| 302 | dbg_gen("inode %lu", inode->i_ino); | 301 | /* |
| 303 | err = ubifs_jnl_write_inode(c, inode, 0); | 302 | * As an optimization, do not write orphan inodes to the media just |
| 304 | if (err) | 303 | * because this is not needed. |
| 305 | ubifs_err("can't write inode %lu, error %d", inode->i_ino, err); | 304 | */ |
| 305 | dbg_gen("inode %lu, mode %#x, nlink %u", | ||
| 306 | inode->i_ino, (int)inode->i_mode, inode->i_nlink); | ||
| 307 | if (inode->i_nlink) { | ||
| 308 | err = ubifs_jnl_write_inode(c, inode); | ||
| 309 | if (err) | ||
| 310 | ubifs_err("can't write inode %lu, error %d", | ||
| 311 | inode->i_ino, err); | ||
| 312 | } | ||
| 306 | 313 | ||
| 307 | ui->dirty = 0; | 314 | ui->dirty = 0; |
| 308 | mutex_unlock(&ui->ui_mutex); | 315 | mutex_unlock(&ui->ui_mutex); |
| @@ -314,8 +321,9 @@ static void ubifs_delete_inode(struct inode *inode) | |||
| 314 | { | 321 | { |
| 315 | int err; | 322 | int err; |
| 316 | struct ubifs_info *c = inode->i_sb->s_fs_info; | 323 | struct ubifs_info *c = inode->i_sb->s_fs_info; |
| 324 | struct ubifs_inode *ui = ubifs_inode(inode); | ||
| 317 | 325 | ||
| 318 | if (ubifs_inode(inode)->xattr) | 326 | if (ui->xattr) |
| 319 | /* | 327 | /* |
| 320 | * Extended attribute inode deletions are fully handled in | 328 | * Extended attribute inode deletions are fully handled in |
| 321 | * 'ubifs_removexattr()'. These inodes are special and have | 329 | * 'ubifs_removexattr()'. These inodes are special and have |
| @@ -323,7 +331,7 @@ static void ubifs_delete_inode(struct inode *inode) | |||
| 323 | */ | 331 | */ |
| 324 | goto out; | 332 | goto out; |
| 325 | 333 | ||
| 326 | dbg_gen("inode %lu", inode->i_ino); | 334 | dbg_gen("inode %lu, mode %#x", inode->i_ino, (int)inode->i_mode); |
| 327 | ubifs_assert(!atomic_read(&inode->i_count)); | 335 | ubifs_assert(!atomic_read(&inode->i_count)); |
| 328 | ubifs_assert(inode->i_nlink == 0); | 336 | ubifs_assert(inode->i_nlink == 0); |
| 329 | 337 | ||
| @@ -331,15 +339,19 @@ static void ubifs_delete_inode(struct inode *inode) | |||
| 331 | if (is_bad_inode(inode)) | 339 | if (is_bad_inode(inode)) |
| 332 | goto out; | 340 | goto out; |
| 333 | 341 | ||
| 334 | ubifs_inode(inode)->ui_size = inode->i_size = 0; | 342 | ui->ui_size = inode->i_size = 0; |
| 335 | err = ubifs_jnl_write_inode(c, inode, 1); | 343 | err = ubifs_jnl_delete_inode(c, inode); |
| 336 | if (err) | 344 | if (err) |
| 337 | /* | 345 | /* |
| 338 | * Worst case we have a lost orphan inode wasting space, so a | 346 | * Worst case we have a lost orphan inode wasting space, so a |
| 339 | * simple error message is ok here. | 347 | * simple error message is OK here. |
| 340 | */ | 348 | */ |
| 341 | ubifs_err("can't write inode %lu, error %d", inode->i_ino, err); | 349 | ubifs_err("can't delete inode %lu, error %d", |
| 350 | inode->i_ino, err); | ||
| 351 | |||
| 342 | out: | 352 | out: |
| 353 | if (ui->dirty) | ||
| 354 | ubifs_release_dirty_inode_budget(c, ui); | ||
| 343 | clear_inode(inode); | 355 | clear_inode(inode); |
| 344 | } | 356 | } |
| 345 | 357 | ||
| @@ -1122,8 +1134,8 @@ static int mount_ubifs(struct ubifs_info *c) | |||
| 1122 | if (err) | 1134 | if (err) |
| 1123 | goto out_infos; | 1135 | goto out_infos; |
| 1124 | 1136 | ||
| 1125 | ubifs_msg("mounted UBI device %d, volume %d", c->vi.ubi_num, | 1137 | ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"", |
| 1126 | c->vi.vol_id); | 1138 | c->vi.ubi_num, c->vi.vol_id, c->vi.name); |
| 1127 | if (mounted_read_only) | 1139 | if (mounted_read_only) |
| 1128 | ubifs_msg("mounted read-only"); | 1140 | ubifs_msg("mounted read-only"); |
| 1129 | x = (long long)c->main_lebs * c->leb_size; | 1141 | x = (long long)c->main_lebs * c->leb_size; |
| @@ -1469,6 +1481,7 @@ static void ubifs_put_super(struct super_block *sb) | |||
| 1469 | */ | 1481 | */ |
| 1470 | ubifs_assert(atomic_long_read(&c->dirty_pg_cnt) == 0); | 1482 | ubifs_assert(atomic_long_read(&c->dirty_pg_cnt) == 0); |
| 1471 | ubifs_assert(c->budg_idx_growth == 0); | 1483 | ubifs_assert(c->budg_idx_growth == 0); |
| 1484 | ubifs_assert(c->budg_dd_growth == 0); | ||
| 1472 | ubifs_assert(c->budg_data_growth == 0); | 1485 | ubifs_assert(c->budg_data_growth == 0); |
| 1473 | 1486 | ||
| 1474 | /* | 1487 | /* |
| @@ -1657,7 +1670,6 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1657 | INIT_LIST_HEAD(&c->orph_new); | 1670 | INIT_LIST_HEAD(&c->orph_new); |
| 1658 | 1671 | ||
| 1659 | c->highest_inum = UBIFS_FIRST_INO; | 1672 | c->highest_inum = UBIFS_FIRST_INO; |
| 1660 | get_random_bytes(&c->vfs_gen, sizeof(int)); | ||
| 1661 | c->lhead_lnum = c->ltail_lnum = UBIFS_LOG_LNUM; | 1673 | c->lhead_lnum = c->ltail_lnum = UBIFS_LOG_LNUM; |
| 1662 | 1674 | ||
| 1663 | ubi_get_volume_info(ubi, &c->vi); | 1675 | ubi_get_volume_info(ubi, &c->vi); |
| @@ -1671,10 +1683,10 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1671 | } | 1683 | } |
| 1672 | 1684 | ||
| 1673 | /* | 1685 | /* |
| 1674 | * UBIFS provids 'backing_dev_info' in order to disable readahead. For | 1686 | * UBIFS provides 'backing_dev_info' in order to disable read-ahead. For |
| 1675 | * UBIFS, I/O is not deferred, it is done immediately in readpage, | 1687 | * UBIFS, I/O is not deferred, it is done immediately in readpage, |
| 1676 | * which means the user would have to wait not just for their own I/O | 1688 | * which means the user would have to wait not just for their own I/O |
| 1677 | * but the readahead I/O as well i.e. completely pointless. | 1689 | * but the read-ahead I/O as well i.e. completely pointless. |
| 1678 | * | 1690 | * |
| 1679 | * Read-ahead will be disabled because @c->bdi.ra_pages is 0. | 1691 | * Read-ahead will be disabled because @c->bdi.ra_pages is 0. |
| 1680 | */ | 1692 | */ |
diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c index 8117e65ba2e9..8ac76b1c2d55 100644 --- a/fs/ubifs/tnc_commit.c +++ b/fs/ubifs/tnc_commit.c | |||
| @@ -372,26 +372,25 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt) | |||
| 372 | written = layout_leb_in_gaps(c, p); | 372 | written = layout_leb_in_gaps(c, p); |
| 373 | if (written < 0) { | 373 | if (written < 0) { |
| 374 | err = written; | 374 | err = written; |
| 375 | if (err == -ENOSPC) { | 375 | if (err != -ENOSPC) { |
| 376 | if (!dbg_force_in_the_gaps_enabled) { | 376 | kfree(c->gap_lebs); |
| 377 | /* | 377 | c->gap_lebs = NULL; |
| 378 | * Do not print scary warnings if the | 378 | return err; |
| 379 | * debugging option which forces | ||
| 380 | * in-the-gaps is enabled. | ||
| 381 | */ | ||
| 382 | ubifs_err("out of space"); | ||
| 383 | spin_lock(&c->space_lock); | ||
| 384 | dbg_dump_budg(c); | ||
| 385 | spin_unlock(&c->space_lock); | ||
| 386 | dbg_dump_lprops(c); | ||
| 387 | } | ||
| 388 | /* Try to commit anyway */ | ||
| 389 | err = 0; | ||
| 390 | break; | ||
| 391 | } | 379 | } |
| 392 | kfree(c->gap_lebs); | 380 | if (!dbg_force_in_the_gaps_enabled) { |
| 393 | c->gap_lebs = NULL; | 381 | /* |
| 394 | return err; | 382 | * Do not print scary warnings if the debugging |
| 383 | * option which forces in-the-gaps is enabled. | ||
| 384 | */ | ||
| 385 | ubifs_err("out of space"); | ||
| 386 | spin_lock(&c->space_lock); | ||
| 387 | dbg_dump_budg(c); | ||
| 388 | spin_unlock(&c->space_lock); | ||
| 389 | dbg_dump_lprops(c); | ||
| 390 | } | ||
| 391 | /* Try to commit anyway */ | ||
| 392 | err = 0; | ||
| 393 | break; | ||
| 395 | } | 394 | } |
| 396 | p++; | 395 | p++; |
| 397 | cnt -= written; | 396 | cnt -= written; |
diff --git a/fs/ubifs/ubifs-media.h b/fs/ubifs/ubifs-media.h index 0cc7da9bed47..bd2121f3426e 100644 --- a/fs/ubifs/ubifs-media.h +++ b/fs/ubifs/ubifs-media.h | |||
| @@ -228,10 +228,10 @@ enum { | |||
| 228 | /* Minimum number of orphan area logical eraseblocks */ | 228 | /* Minimum number of orphan area logical eraseblocks */ |
| 229 | #define UBIFS_MIN_ORPH_LEBS 1 | 229 | #define UBIFS_MIN_ORPH_LEBS 1 |
| 230 | /* | 230 | /* |
| 231 | * Minimum number of main area logical eraseblocks (buds, 2 for the index, 1 | 231 | * Minimum number of main area logical eraseblocks (buds, 3 for the index, 1 |
| 232 | * for GC, 1 for deletions, and at least 1 for committed data). | 232 | * for GC, 1 for deletions, and at least 1 for committed data). |
| 233 | */ | 233 | */ |
| 234 | #define UBIFS_MIN_MAIN_LEBS (UBIFS_MIN_BUD_LEBS + 5) | 234 | #define UBIFS_MIN_MAIN_LEBS (UBIFS_MIN_BUD_LEBS + 6) |
| 235 | 235 | ||
| 236 | /* Minimum number of logical eraseblocks */ | 236 | /* Minimum number of logical eraseblocks */ |
| 237 | #define UBIFS_MIN_LEB_CNT (UBIFS_SB_LEBS + UBIFS_MST_LEBS + \ | 237 | #define UBIFS_MIN_LEB_CNT (UBIFS_SB_LEBS + UBIFS_MST_LEBS + \ |
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index e4f89f271827..d7f706f7a302 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h | |||
| @@ -20,8 +20,6 @@ | |||
| 20 | * Adrian Hunter | 20 | * Adrian Hunter |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | /* Implementation version 0.7 */ | ||
| 24 | |||
| 25 | #ifndef __UBIFS_H__ | 23 | #ifndef __UBIFS_H__ |
| 26 | #define __UBIFS_H__ | 24 | #define __UBIFS_H__ |
| 27 | 25 | ||
| @@ -322,6 +320,8 @@ struct ubifs_gced_idx_leb { | |||
| 322 | * struct ubifs_inode - UBIFS in-memory inode description. | 320 | * struct ubifs_inode - UBIFS in-memory inode description. |
| 323 | * @vfs_inode: VFS inode description object | 321 | * @vfs_inode: VFS inode description object |
| 324 | * @creat_sqnum: sequence number at time of creation | 322 | * @creat_sqnum: sequence number at time of creation |
| 323 | * @del_cmtno: commit number corresponding to the time the inode was deleted, | ||
| 324 | * protected by @c->commit_sem; | ||
| 325 | * @xattr_size: summarized size of all extended attributes in bytes | 325 | * @xattr_size: summarized size of all extended attributes in bytes |
| 326 | * @xattr_cnt: count of extended attributes this inode has | 326 | * @xattr_cnt: count of extended attributes this inode has |
| 327 | * @xattr_names: sum of lengths of all extended attribute names belonging to | 327 | * @xattr_names: sum of lengths of all extended attribute names belonging to |
| @@ -373,6 +373,7 @@ struct ubifs_gced_idx_leb { | |||
| 373 | struct ubifs_inode { | 373 | struct ubifs_inode { |
| 374 | struct inode vfs_inode; | 374 | struct inode vfs_inode; |
| 375 | unsigned long long creat_sqnum; | 375 | unsigned long long creat_sqnum; |
| 376 | unsigned long long del_cmtno; | ||
| 376 | unsigned int xattr_size; | 377 | unsigned int xattr_size; |
| 377 | unsigned int xattr_cnt; | 378 | unsigned int xattr_cnt; |
| 378 | unsigned int xattr_names; | 379 | unsigned int xattr_names; |
| @@ -779,7 +780,7 @@ struct ubifs_compressor { | |||
| 779 | /** | 780 | /** |
| 780 | * struct ubifs_budget_req - budget requirements of an operation. | 781 | * struct ubifs_budget_req - budget requirements of an operation. |
| 781 | * | 782 | * |
| 782 | * @fast: non-zero if the budgeting should try to aquire budget quickly and | 783 | * @fast: non-zero if the budgeting should try to acquire budget quickly and |
| 783 | * should not try to call write-back | 784 | * should not try to call write-back |
| 784 | * @recalculate: non-zero if @idx_growth, @data_growth, and @dd_growth fields | 785 | * @recalculate: non-zero if @idx_growth, @data_growth, and @dd_growth fields |
| 785 | * have to be re-calculated | 786 | * have to be re-calculated |
| @@ -805,21 +806,31 @@ struct ubifs_compressor { | |||
| 805 | * An inode may contain 4KiB of data at max., thus the widths of @new_ino_d | 806 | * An inode may contain 4KiB of data at max., thus the widths of @new_ino_d |
| 806 | * is 13 bits, and @dirtied_ino_d - 15, because up to 4 inodes may be made | 807 | * is 13 bits, and @dirtied_ino_d - 15, because up to 4 inodes may be made |
| 807 | * dirty by the re-name operation. | 808 | * dirty by the re-name operation. |
| 809 | * | ||
| 810 | * Note, UBIFS aligns node lengths to 8-bytes boundary, so the requester has to | ||
| 811 | * make sure the amount of inode data which contribute to @new_ino_d and | ||
| 812 | * @dirtied_ino_d fields are aligned. | ||
| 808 | */ | 813 | */ |
| 809 | struct ubifs_budget_req { | 814 | struct ubifs_budget_req { |
| 810 | unsigned int fast:1; | 815 | unsigned int fast:1; |
| 811 | unsigned int recalculate:1; | 816 | unsigned int recalculate:1; |
| 817 | #ifndef UBIFS_DEBUG | ||
| 812 | unsigned int new_page:1; | 818 | unsigned int new_page:1; |
| 813 | unsigned int dirtied_page:1; | 819 | unsigned int dirtied_page:1; |
| 814 | unsigned int new_dent:1; | 820 | unsigned int new_dent:1; |
| 815 | unsigned int mod_dent:1; | 821 | unsigned int mod_dent:1; |
| 816 | unsigned int new_ino:1; | 822 | unsigned int new_ino:1; |
| 817 | unsigned int new_ino_d:13; | 823 | unsigned int new_ino_d:13; |
| 818 | #ifndef UBIFS_DEBUG | ||
| 819 | unsigned int dirtied_ino:4; | 824 | unsigned int dirtied_ino:4; |
| 820 | unsigned int dirtied_ino_d:15; | 825 | unsigned int dirtied_ino_d:15; |
| 821 | #else | 826 | #else |
| 822 | /* Not bit-fields to check for overflows */ | 827 | /* Not bit-fields to check for overflows */ |
| 828 | unsigned int new_page; | ||
| 829 | unsigned int dirtied_page; | ||
| 830 | unsigned int new_dent; | ||
| 831 | unsigned int mod_dent; | ||
| 832 | unsigned int new_ino; | ||
| 833 | unsigned int new_ino_d; | ||
| 823 | unsigned int dirtied_ino; | 834 | unsigned int dirtied_ino; |
| 824 | unsigned int dirtied_ino_d; | 835 | unsigned int dirtied_ino_d; |
| 825 | #endif | 836 | #endif |
| @@ -860,13 +871,13 @@ struct ubifs_mount_opts { | |||
| 860 | * struct ubifs_info - UBIFS file-system description data structure | 871 | * struct ubifs_info - UBIFS file-system description data structure |
| 861 | * (per-superblock). | 872 | * (per-superblock). |
| 862 | * @vfs_sb: VFS @struct super_block object | 873 | * @vfs_sb: VFS @struct super_block object |
| 863 | * @bdi: backing device info object to make VFS happy and disable readahead | 874 | * @bdi: backing device info object to make VFS happy and disable read-ahead |
| 864 | * | 875 | * |
| 865 | * @highest_inum: highest used inode number | 876 | * @highest_inum: highest used inode number |
| 866 | * @vfs_gen: VFS inode generation counter | ||
| 867 | * @max_sqnum: current global sequence number | 877 | * @max_sqnum: current global sequence number |
| 868 | * @cmt_no: commit number (last successfully completed commit) | 878 | * @cmt_no: commit number of the last successfully completed commit, protected |
| 869 | * @cnt_lock: protects @highest_inum, @vfs_gen, and @max_sqnum counters | 879 | * by @commit_sem |
| 880 | * @cnt_lock: protects @highest_inum and @max_sqnum counters | ||
| 870 | * @fmt_version: UBIFS on-flash format version | 881 | * @fmt_version: UBIFS on-flash format version |
| 871 | * @uuid: UUID from super block | 882 | * @uuid: UUID from super block |
| 872 | * | 883 | * |
| @@ -1103,7 +1114,6 @@ struct ubifs_info { | |||
| 1103 | struct backing_dev_info bdi; | 1114 | struct backing_dev_info bdi; |
| 1104 | 1115 | ||
| 1105 | ino_t highest_inum; | 1116 | ino_t highest_inum; |
| 1106 | unsigned int vfs_gen; | ||
| 1107 | unsigned long long max_sqnum; | 1117 | unsigned long long max_sqnum; |
| 1108 | unsigned long long cmt_no; | 1118 | unsigned long long cmt_no; |
| 1109 | spinlock_t cnt_lock; | 1119 | spinlock_t cnt_lock; |
| @@ -1346,6 +1356,7 @@ extern struct backing_dev_info ubifs_backing_dev_info; | |||
| 1346 | extern struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; | 1356 | extern struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; |
| 1347 | 1357 | ||
| 1348 | /* io.c */ | 1358 | /* io.c */ |
| 1359 | void ubifs_ro_mode(struct ubifs_info *c, int err); | ||
| 1349 | int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len); | 1360 | int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len); |
| 1350 | int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs, | 1361 | int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs, |
| 1351 | int dtype); | 1362 | int dtype); |
| @@ -1399,8 +1410,8 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir, | |||
| 1399 | int deletion, int xent); | 1410 | int deletion, int xent); |
| 1400 | int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, | 1411 | int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, |
| 1401 | const union ubifs_key *key, const void *buf, int len); | 1412 | const union ubifs_key *key, const void *buf, int len); |
| 1402 | int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode, | 1413 | int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode); |
| 1403 | int last_reference); | 1414 | int ubifs_jnl_delete_inode(struct ubifs_info *c, const struct inode *inode); |
| 1404 | int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir, | 1415 | int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir, |
| 1405 | const struct dentry *old_dentry, | 1416 | const struct dentry *old_dentry, |
| 1406 | const struct inode *new_dir, | 1417 | const struct inode *new_dir, |
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c index 1388a078e1a9..649bec78b645 100644 --- a/fs/ubifs/xattr.c +++ b/fs/ubifs/xattr.c | |||
| @@ -61,7 +61,7 @@ | |||
| 61 | 61 | ||
| 62 | /* | 62 | /* |
| 63 | * Limit the number of extended attributes per inode so that the total size | 63 | * Limit the number of extended attributes per inode so that the total size |
| 64 | * (xattr_size) is guaranteeded to fit in an 'unsigned int'. | 64 | * (@xattr_size) is guaranteeded to fit in an 'unsigned int'. |
| 65 | */ | 65 | */ |
| 66 | #define MAX_XATTRS_PER_INODE 65535 | 66 | #define MAX_XATTRS_PER_INODE 65535 |
| 67 | 67 | ||
| @@ -103,14 +103,14 @@ static int create_xattr(struct ubifs_info *c, struct inode *host, | |||
| 103 | struct inode *inode; | 103 | struct inode *inode; |
| 104 | struct ubifs_inode *ui, *host_ui = ubifs_inode(host); | 104 | struct ubifs_inode *ui, *host_ui = ubifs_inode(host); |
| 105 | struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1, | 105 | struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1, |
| 106 | .new_ino_d = size, .dirtied_ino = 1, | 106 | .new_ino_d = ALIGN(size, 8), .dirtied_ino = 1, |
| 107 | .dirtied_ino_d = host_ui->data_len}; | 107 | .dirtied_ino_d = ALIGN(host_ui->data_len, 8) }; |
| 108 | 108 | ||
| 109 | if (host_ui->xattr_cnt >= MAX_XATTRS_PER_INODE) | 109 | if (host_ui->xattr_cnt >= MAX_XATTRS_PER_INODE) |
| 110 | return -ENOSPC; | 110 | return -ENOSPC; |
| 111 | /* | 111 | /* |
| 112 | * Linux limits the maximum size of the extended attribute names list | 112 | * Linux limits the maximum size of the extended attribute names list |
| 113 | * to %XATTR_LIST_MAX. This means we should not allow creating more* | 113 | * to %XATTR_LIST_MAX. This means we should not allow creating more |
| 114 | * extended attributes if the name list becomes larger. This limitation | 114 | * extended attributes if the name list becomes larger. This limitation |
| 115 | * is artificial for UBIFS, though. | 115 | * is artificial for UBIFS, though. |
| 116 | */ | 116 | */ |
| @@ -128,7 +128,6 @@ static int create_xattr(struct ubifs_info *c, struct inode *host, | |||
| 128 | goto out_budg; | 128 | goto out_budg; |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | mutex_lock(&host_ui->ui_mutex); | ||
| 132 | /* Re-define all operations to be "nothing" */ | 131 | /* Re-define all operations to be "nothing" */ |
| 133 | inode->i_mapping->a_ops = &none_address_operations; | 132 | inode->i_mapping->a_ops = &none_address_operations; |
| 134 | inode->i_op = &none_inode_operations; | 133 | inode->i_op = &none_inode_operations; |
| @@ -141,23 +140,19 @@ static int create_xattr(struct ubifs_info *c, struct inode *host, | |||
| 141 | ui->data = kmalloc(size, GFP_NOFS); | 140 | ui->data = kmalloc(size, GFP_NOFS); |
| 142 | if (!ui->data) { | 141 | if (!ui->data) { |
| 143 | err = -ENOMEM; | 142 | err = -ENOMEM; |
| 144 | goto out_unlock; | 143 | goto out_free; |
| 145 | } | 144 | } |
| 146 | |||
| 147 | memcpy(ui->data, value, size); | 145 | memcpy(ui->data, value, size); |
| 146 | inode->i_size = ui->ui_size = size; | ||
| 147 | ui->data_len = size; | ||
| 148 | |||
| 149 | mutex_lock(&host_ui->ui_mutex); | ||
| 148 | host->i_ctime = ubifs_current_time(host); | 150 | host->i_ctime = ubifs_current_time(host); |
| 149 | host_ui->xattr_cnt += 1; | 151 | host_ui->xattr_cnt += 1; |
| 150 | host_ui->xattr_size += CALC_DENT_SIZE(nm->len); | 152 | host_ui->xattr_size += CALC_DENT_SIZE(nm->len); |
| 151 | host_ui->xattr_size += CALC_XATTR_BYTES(size); | 153 | host_ui->xattr_size += CALC_XATTR_BYTES(size); |
| 152 | host_ui->xattr_names += nm->len; | 154 | host_ui->xattr_names += nm->len; |
| 153 | 155 | ||
| 154 | /* | ||
| 155 | * We do not use i_size_write() because nobody can race with us as we | ||
| 156 | * are holding host @host->i_mutex - every xattr operation for this | ||
| 157 | * inode is serialized by it. | ||
| 158 | */ | ||
| 159 | inode->i_size = ui->ui_size = size; | ||
| 160 | ui->data_len = size; | ||
| 161 | err = ubifs_jnl_update(c, host, nm, inode, 0, 1); | 156 | err = ubifs_jnl_update(c, host, nm, inode, 0, 1); |
| 162 | if (err) | 157 | if (err) |
| 163 | goto out_cancel; | 158 | goto out_cancel; |
| @@ -172,8 +167,8 @@ out_cancel: | |||
| 172 | host_ui->xattr_cnt -= 1; | 167 | host_ui->xattr_cnt -= 1; |
| 173 | host_ui->xattr_size -= CALC_DENT_SIZE(nm->len); | 168 | host_ui->xattr_size -= CALC_DENT_SIZE(nm->len); |
| 174 | host_ui->xattr_size -= CALC_XATTR_BYTES(size); | 169 | host_ui->xattr_size -= CALC_XATTR_BYTES(size); |
| 175 | out_unlock: | ||
| 176 | mutex_unlock(&host_ui->ui_mutex); | 170 | mutex_unlock(&host_ui->ui_mutex); |
| 171 | out_free: | ||
| 177 | make_bad_inode(inode); | 172 | make_bad_inode(inode); |
| 178 | iput(inode); | 173 | iput(inode); |
| 179 | out_budg: | 174 | out_budg: |
| @@ -200,29 +195,28 @@ static int change_xattr(struct ubifs_info *c, struct inode *host, | |||
| 200 | struct ubifs_inode *host_ui = ubifs_inode(host); | 195 | struct ubifs_inode *host_ui = ubifs_inode(host); |
| 201 | struct ubifs_inode *ui = ubifs_inode(inode); | 196 | struct ubifs_inode *ui = ubifs_inode(inode); |
| 202 | struct ubifs_budget_req req = { .dirtied_ino = 2, | 197 | struct ubifs_budget_req req = { .dirtied_ino = 2, |
| 203 | .dirtied_ino_d = size + host_ui->data_len }; | 198 | .dirtied_ino_d = ALIGN(size, 8) + ALIGN(host_ui->data_len, 8) }; |
| 204 | 199 | ||
| 205 | ubifs_assert(ui->data_len == inode->i_size); | 200 | ubifs_assert(ui->data_len == inode->i_size); |
| 206 | err = ubifs_budget_space(c, &req); | 201 | err = ubifs_budget_space(c, &req); |
| 207 | if (err) | 202 | if (err) |
| 208 | return err; | 203 | return err; |
| 209 | 204 | ||
| 210 | mutex_lock(&host_ui->ui_mutex); | ||
| 211 | host->i_ctime = ubifs_current_time(host); | ||
| 212 | host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len); | ||
| 213 | host_ui->xattr_size += CALC_XATTR_BYTES(size); | ||
| 214 | |||
| 215 | kfree(ui->data); | 205 | kfree(ui->data); |
| 216 | ui->data = kmalloc(size, GFP_NOFS); | 206 | ui->data = kmalloc(size, GFP_NOFS); |
| 217 | if (!ui->data) { | 207 | if (!ui->data) { |
| 218 | err = -ENOMEM; | 208 | err = -ENOMEM; |
| 219 | goto out_unlock; | 209 | goto out_free; |
| 220 | } | 210 | } |
| 221 | |||
| 222 | memcpy(ui->data, value, size); | 211 | memcpy(ui->data, value, size); |
| 223 | inode->i_size = ui->ui_size = size; | 212 | inode->i_size = ui->ui_size = size; |
| 224 | ui->data_len = size; | 213 | ui->data_len = size; |
| 225 | 214 | ||
| 215 | mutex_lock(&host_ui->ui_mutex); | ||
| 216 | host->i_ctime = ubifs_current_time(host); | ||
| 217 | host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len); | ||
| 218 | host_ui->xattr_size += CALC_XATTR_BYTES(size); | ||
| 219 | |||
| 226 | /* | 220 | /* |
| 227 | * It is important to write the host inode after the xattr inode | 221 | * It is important to write the host inode after the xattr inode |
| 228 | * because if the host inode gets synchronized (via 'fsync()'), then | 222 | * because if the host inode gets synchronized (via 'fsync()'), then |
| @@ -240,9 +234,9 @@ static int change_xattr(struct ubifs_info *c, struct inode *host, | |||
| 240 | out_cancel: | 234 | out_cancel: |
| 241 | host_ui->xattr_size -= CALC_XATTR_BYTES(size); | 235 | host_ui->xattr_size -= CALC_XATTR_BYTES(size); |
| 242 | host_ui->xattr_size += CALC_XATTR_BYTES(ui->data_len); | 236 | host_ui->xattr_size += CALC_XATTR_BYTES(ui->data_len); |
| 243 | make_bad_inode(inode); | ||
| 244 | out_unlock: | ||
| 245 | mutex_unlock(&host_ui->ui_mutex); | 237 | mutex_unlock(&host_ui->ui_mutex); |
| 238 | make_bad_inode(inode); | ||
| 239 | out_free: | ||
| 246 | ubifs_release_budget(c, &req); | 240 | ubifs_release_budget(c, &req); |
| 247 | return err; | 241 | return err; |
| 248 | } | 242 | } |
| @@ -312,6 +306,7 @@ int ubifs_setxattr(struct dentry *dentry, const char *name, | |||
| 312 | 306 | ||
| 313 | dbg_gen("xattr '%s', host ino %lu ('%.*s'), size %zd", name, | 307 | dbg_gen("xattr '%s', host ino %lu ('%.*s'), size %zd", name, |
| 314 | host->i_ino, dentry->d_name.len, dentry->d_name.name, size); | 308 | host->i_ino, dentry->d_name.len, dentry->d_name.name, size); |
| 309 | ubifs_assert(mutex_is_locked(&host->i_mutex)); | ||
| 315 | 310 | ||
| 316 | if (size > UBIFS_MAX_INO_DATA) | 311 | if (size > UBIFS_MAX_INO_DATA) |
| 317 | return -ERANGE; | 312 | return -ERANGE; |
| @@ -384,7 +379,6 @@ ssize_t ubifs_getxattr(struct dentry *dentry, const char *name, void *buf, | |||
| 384 | if (!xent) | 379 | if (!xent) |
| 385 | return -ENOMEM; | 380 | return -ENOMEM; |
| 386 | 381 | ||
| 387 | mutex_lock(&host->i_mutex); | ||
| 388 | xent_key_init(c, &key, host->i_ino, &nm); | 382 | xent_key_init(c, &key, host->i_ino, &nm); |
| 389 | err = ubifs_tnc_lookup_nm(c, &key, xent, &nm); | 383 | err = ubifs_tnc_lookup_nm(c, &key, xent, &nm); |
| 390 | if (err) { | 384 | if (err) { |
| @@ -419,7 +413,6 @@ ssize_t ubifs_getxattr(struct dentry *dentry, const char *name, void *buf, | |||
| 419 | out_iput: | 413 | out_iput: |
| 420 | iput(inode); | 414 | iput(inode); |
| 421 | out_unlock: | 415 | out_unlock: |
| 422 | mutex_unlock(&host->i_mutex); | ||
| 423 | kfree(xent); | 416 | kfree(xent); |
| 424 | return err; | 417 | return err; |
| 425 | } | 418 | } |
| @@ -449,8 +442,6 @@ ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
| 449 | return -ERANGE; | 442 | return -ERANGE; |
| 450 | 443 | ||
| 451 | lowest_xent_key(c, &key, host->i_ino); | 444 | lowest_xent_key(c, &key, host->i_ino); |
| 452 | |||
| 453 | mutex_lock(&host->i_mutex); | ||
| 454 | while (1) { | 445 | while (1) { |
| 455 | int type; | 446 | int type; |
| 456 | 447 | ||
| @@ -479,7 +470,6 @@ ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
| 479 | pxent = xent; | 470 | pxent = xent; |
| 480 | key_read(c, &xent->key, &key); | 471 | key_read(c, &xent->key, &key); |
| 481 | } | 472 | } |
| 482 | mutex_unlock(&host->i_mutex); | ||
| 483 | 473 | ||
| 484 | kfree(pxent); | 474 | kfree(pxent); |
| 485 | if (err != -ENOENT) { | 475 | if (err != -ENOENT) { |
| @@ -497,8 +487,8 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host, | |||
| 497 | int err; | 487 | int err; |
| 498 | struct ubifs_inode *host_ui = ubifs_inode(host); | 488 | struct ubifs_inode *host_ui = ubifs_inode(host); |
| 499 | struct ubifs_inode *ui = ubifs_inode(inode); | 489 | struct ubifs_inode *ui = ubifs_inode(inode); |
| 500 | struct ubifs_budget_req req = { .dirtied_ino = 1, .mod_dent = 1, | 490 | struct ubifs_budget_req req = { .dirtied_ino = 2, .mod_dent = 1, |
| 501 | .dirtied_ino_d = host_ui->data_len }; | 491 | .dirtied_ino_d = ALIGN(host_ui->data_len, 8) }; |
| 502 | 492 | ||
| 503 | ubifs_assert(ui->data_len == inode->i_size); | 493 | ubifs_assert(ui->data_len == inode->i_size); |
| 504 | 494 | ||
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c index 5f60363b9343..5311c1acdd40 100644 --- a/fs/xfs/linux-2.6/xfs_file.c +++ b/fs/xfs/linux-2.6/xfs_file.c | |||
| @@ -475,6 +475,7 @@ const struct file_operations xfs_invis_file_operations = { | |||
| 475 | const struct file_operations xfs_dir_file_operations = { | 475 | const struct file_operations xfs_dir_file_operations = { |
| 476 | .read = generic_read_dir, | 476 | .read = generic_read_dir, |
| 477 | .readdir = xfs_file_readdir, | 477 | .readdir = xfs_file_readdir, |
| 478 | .llseek = generic_file_llseek, | ||
| 478 | .unlocked_ioctl = xfs_file_ioctl, | 479 | .unlocked_ioctl = xfs_file_ioctl, |
| 479 | #ifdef CONFIG_COMPAT | 480 | #ifdef CONFIG_COMPAT |
| 480 | .compat_ioctl = xfs_file_compat_ioctl, | 481 | .compat_ioctl = xfs_file_compat_ioctl, |
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index 91bcd979242c..095d271f3434 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c | |||
| @@ -355,7 +355,7 @@ xfs_vn_ci_lookup( | |||
| 355 | /* else case-insensitive match... */ | 355 | /* else case-insensitive match... */ |
| 356 | dname.name = ci_name.name; | 356 | dname.name = ci_name.name; |
| 357 | dname.len = ci_name.len; | 357 | dname.len = ci_name.len; |
| 358 | dentry = d_add_ci(VFS_I(ip), dentry, &dname); | 358 | dentry = d_add_ci(dentry, VFS_I(ip), &dname); |
| 359 | kmem_free(ci_name.name); | 359 | kmem_free(ci_name.name); |
| 360 | return dentry; | 360 | return dentry; |
| 361 | } | 361 | } |
diff --git a/fs/xfs/xfs_dmapi.h b/fs/xfs/xfs_dmapi.h index cdc2d3464a1a..2813cdd72375 100644 --- a/fs/xfs/xfs_dmapi.h +++ b/fs/xfs/xfs_dmapi.h | |||
| @@ -18,7 +18,6 @@ | |||
| 18 | #ifndef __XFS_DMAPI_H__ | 18 | #ifndef __XFS_DMAPI_H__ |
| 19 | #define __XFS_DMAPI_H__ | 19 | #define __XFS_DMAPI_H__ |
| 20 | 20 | ||
| 21 | #include <linux/version.h> | ||
| 22 | /* Values used to define the on-disk version of dm_attrname_t. All | 21 | /* Values used to define the on-disk version of dm_attrname_t. All |
| 23 | * on-disk attribute names start with the 8-byte string "SGI_DMI_". | 22 | * on-disk attribute names start with the 8-byte string "SGI_DMI_". |
| 24 | * | 23 | * |
