diff options
author | Ingo Molnar <mingo@kernel.org> | 2014-05-07 07:39:22 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-05-07 07:39:22 -0400 |
commit | 37b16beaa92860c378273ccdcc2ccb22c6cee047 (patch) | |
tree | 4fc7f879c32d11d318f411dbe128d080ed8478f9 /fs | |
parent | 3e46d21285577a8c9e4c37f9b1002e567c440b28 (diff) | |
parent | a4b4f11b2783ec678cccb4ce7e4ce9665aa04a24 (diff) |
Merge branch 'perf/urgent' into perf/core, to avoid conflicts
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/affs/super.c | 2 | ||||
-rw-r--r-- | fs/aio.c | 42 | ||||
-rw-r--r-- | fs/autofs4/root.c | 4 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 14 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 10 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 6 | ||||
-rw-r--r-- | fs/btrfs/file.c | 8 | ||||
-rw-r--r-- | fs/btrfs/inode-map.c | 24 | ||||
-rw-r--r-- | fs/btrfs/ioctl.c | 4 | ||||
-rw-r--r-- | fs/btrfs/send.c | 5 | ||||
-rw-r--r-- | fs/btrfs/super.c | 22 | ||||
-rw-r--r-- | fs/ceph/caps.c | 2 | ||||
-rw-r--r-- | fs/ceph/dir.c | 33 | ||||
-rw-r--r-- | fs/ceph/inode.c | 71 | ||||
-rw-r--r-- | fs/ceph/ioctl.c | 3 | ||||
-rw-r--r-- | fs/ceph/locks.c | 1 | ||||
-rw-r--r-- | fs/ceph/super.h | 1 | ||||
-rw-r--r-- | fs/compat.c | 14 | ||||
-rw-r--r-- | fs/dcache.c | 318 | ||||
-rw-r--r-- | fs/fcntl.c | 12 | ||||
-rw-r--r-- | fs/fuse/control.c | 2 | ||||
-rw-r--r-- | fs/fuse/dir.c | 146 | ||||
-rw-r--r-- | fs/fuse/file.c | 84 | ||||
-rw-r--r-- | fs/fuse/fuse_i.h | 10 | ||||
-rw-r--r-- | fs/fuse/inode.c | 16 | ||||
-rw-r--r-- | fs/hugetlbfs/inode.c | 5 | ||||
-rw-r--r-- | fs/kernfs/dir.c | 9 | ||||
-rw-r--r-- | fs/kernfs/file.c | 2 | ||||
-rw-r--r-- | fs/locks.c | 55 | ||||
-rw-r--r-- | fs/namei.c | 6 | ||||
-rw-r--r-- | fs/nfsd/nfs4callback.c | 4 | ||||
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 8 | ||||
-rw-r--r-- | fs/notify/fanotify/fanotify_user.c | 2 | ||||
-rw-r--r-- | fs/posix_acl.c | 6 | ||||
-rw-r--r-- | fs/ubifs/super.c | 2 |
35 files changed, 465 insertions, 488 deletions
diff --git a/fs/affs/super.c b/fs/affs/super.c index 6d589f28bf9b..895ac7dc9dbf 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c | |||
@@ -340,8 +340,6 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) | |||
340 | &blocksize,&sbi->s_prefix, | 340 | &blocksize,&sbi->s_prefix, |
341 | sbi->s_volume, &mount_flags)) { | 341 | sbi->s_volume, &mount_flags)) { |
342 | printk(KERN_ERR "AFFS: Error parsing options\n"); | 342 | printk(KERN_ERR "AFFS: Error parsing options\n"); |
343 | kfree(sbi->s_prefix); | ||
344 | kfree(sbi); | ||
345 | return -EINVAL; | 343 | return -EINVAL; |
346 | } | 344 | } |
347 | /* N.B. after this point s_prefix must be released */ | 345 | /* N.B. after this point s_prefix must be released */ |
@@ -112,6 +112,11 @@ struct kioctx { | |||
112 | 112 | ||
113 | struct work_struct free_work; | 113 | struct work_struct free_work; |
114 | 114 | ||
115 | /* | ||
116 | * signals when all in-flight requests are done | ||
117 | */ | ||
118 | struct completion *requests_done; | ||
119 | |||
115 | struct { | 120 | struct { |
116 | /* | 121 | /* |
117 | * This counts the number of available slots in the ringbuffer, | 122 | * This counts the number of available slots in the ringbuffer, |
@@ -508,6 +513,10 @@ static void free_ioctx_reqs(struct percpu_ref *ref) | |||
508 | { | 513 | { |
509 | struct kioctx *ctx = container_of(ref, struct kioctx, reqs); | 514 | struct kioctx *ctx = container_of(ref, struct kioctx, reqs); |
510 | 515 | ||
516 | /* At this point we know that there are no any in-flight requests */ | ||
517 | if (ctx->requests_done) | ||
518 | complete(ctx->requests_done); | ||
519 | |||
511 | INIT_WORK(&ctx->free_work, free_ioctx); | 520 | INIT_WORK(&ctx->free_work, free_ioctx); |
512 | schedule_work(&ctx->free_work); | 521 | schedule_work(&ctx->free_work); |
513 | } | 522 | } |
@@ -718,7 +727,8 @@ err: | |||
718 | * when the processes owning a context have all exited to encourage | 727 | * when the processes owning a context have all exited to encourage |
719 | * the rapid destruction of the kioctx. | 728 | * the rapid destruction of the kioctx. |
720 | */ | 729 | */ |
721 | static void kill_ioctx(struct mm_struct *mm, struct kioctx *ctx) | 730 | static void kill_ioctx(struct mm_struct *mm, struct kioctx *ctx, |
731 | struct completion *requests_done) | ||
722 | { | 732 | { |
723 | if (!atomic_xchg(&ctx->dead, 1)) { | 733 | if (!atomic_xchg(&ctx->dead, 1)) { |
724 | struct kioctx_table *table; | 734 | struct kioctx_table *table; |
@@ -747,7 +757,11 @@ static void kill_ioctx(struct mm_struct *mm, struct kioctx *ctx) | |||
747 | if (ctx->mmap_size) | 757 | if (ctx->mmap_size) |
748 | vm_munmap(ctx->mmap_base, ctx->mmap_size); | 758 | vm_munmap(ctx->mmap_base, ctx->mmap_size); |
749 | 759 | ||
760 | ctx->requests_done = requests_done; | ||
750 | percpu_ref_kill(&ctx->users); | 761 | percpu_ref_kill(&ctx->users); |
762 | } else { | ||
763 | if (requests_done) | ||
764 | complete(requests_done); | ||
751 | } | 765 | } |
752 | } | 766 | } |
753 | 767 | ||
@@ -809,7 +823,7 @@ void exit_aio(struct mm_struct *mm) | |||
809 | */ | 823 | */ |
810 | ctx->mmap_size = 0; | 824 | ctx->mmap_size = 0; |
811 | 825 | ||
812 | kill_ioctx(mm, ctx); | 826 | kill_ioctx(mm, ctx, NULL); |
813 | } | 827 | } |
814 | } | 828 | } |
815 | 829 | ||
@@ -1185,7 +1199,7 @@ SYSCALL_DEFINE2(io_setup, unsigned, nr_events, aio_context_t __user *, ctxp) | |||
1185 | if (!IS_ERR(ioctx)) { | 1199 | if (!IS_ERR(ioctx)) { |
1186 | ret = put_user(ioctx->user_id, ctxp); | 1200 | ret = put_user(ioctx->user_id, ctxp); |
1187 | if (ret) | 1201 | if (ret) |
1188 | kill_ioctx(current->mm, ioctx); | 1202 | kill_ioctx(current->mm, ioctx, NULL); |
1189 | percpu_ref_put(&ioctx->users); | 1203 | percpu_ref_put(&ioctx->users); |
1190 | } | 1204 | } |
1191 | 1205 | ||
@@ -1203,8 +1217,22 @@ SYSCALL_DEFINE1(io_destroy, aio_context_t, ctx) | |||
1203 | { | 1217 | { |
1204 | struct kioctx *ioctx = lookup_ioctx(ctx); | 1218 | struct kioctx *ioctx = lookup_ioctx(ctx); |
1205 | if (likely(NULL != ioctx)) { | 1219 | if (likely(NULL != ioctx)) { |
1206 | kill_ioctx(current->mm, ioctx); | 1220 | struct completion requests_done = |
1221 | COMPLETION_INITIALIZER_ONSTACK(requests_done); | ||
1222 | |||
1223 | /* Pass requests_done to kill_ioctx() where it can be set | ||
1224 | * in a thread-safe way. If we try to set it here then we have | ||
1225 | * a race condition if two io_destroy() called simultaneously. | ||
1226 | */ | ||
1227 | kill_ioctx(current->mm, ioctx, &requests_done); | ||
1207 | percpu_ref_put(&ioctx->users); | 1228 | percpu_ref_put(&ioctx->users); |
1229 | |||
1230 | /* Wait until all IO for the context are done. Otherwise kernel | ||
1231 | * keep using user-space buffers even if user thinks the context | ||
1232 | * is destroyed. | ||
1233 | */ | ||
1234 | wait_for_completion(&requests_done); | ||
1235 | |||
1208 | return 0; | 1236 | return 0; |
1209 | } | 1237 | } |
1210 | pr_debug("EINVAL: io_destroy: invalid context id\n"); | 1238 | pr_debug("EINVAL: io_destroy: invalid context id\n"); |
@@ -1299,10 +1327,8 @@ rw_common: | |||
1299 | &iovec, compat) | 1327 | &iovec, compat) |
1300 | : aio_setup_single_vector(req, rw, buf, &nr_segs, | 1328 | : aio_setup_single_vector(req, rw, buf, &nr_segs, |
1301 | iovec); | 1329 | iovec); |
1302 | if (ret) | 1330 | if (!ret) |
1303 | return ret; | 1331 | ret = rw_verify_area(rw, file, &req->ki_pos, req->ki_nbytes); |
1304 | |||
1305 | ret = rw_verify_area(rw, file, &req->ki_pos, req->ki_nbytes); | ||
1306 | if (ret < 0) { | 1332 | if (ret < 0) { |
1307 | if (iovec != &inline_vec) | 1333 | if (iovec != &inline_vec) |
1308 | kfree(iovec); | 1334 | kfree(iovec); |
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index 2caf36ac3e93..cc87c1abac97 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c | |||
@@ -179,7 +179,7 @@ static struct dentry *autofs4_lookup_active(struct dentry *dentry) | |||
179 | spin_lock(&active->d_lock); | 179 | spin_lock(&active->d_lock); |
180 | 180 | ||
181 | /* Already gone? */ | 181 | /* Already gone? */ |
182 | if (!d_count(active)) | 182 | if ((int) d_count(active) <= 0) |
183 | goto next; | 183 | goto next; |
184 | 184 | ||
185 | qstr = &active->d_name; | 185 | qstr = &active->d_name; |
@@ -230,7 +230,7 @@ static struct dentry *autofs4_lookup_expiring(struct dentry *dentry) | |||
230 | 230 | ||
231 | spin_lock(&expiring->d_lock); | 231 | spin_lock(&expiring->d_lock); |
232 | 232 | ||
233 | /* Bad luck, we've already been dentry_iput */ | 233 | /* We've already been dentry_iput or unlinked */ |
234 | if (!expiring->d_inode) | 234 | if (!expiring->d_inode) |
235 | goto next; | 235 | goto next; |
236 | 236 | ||
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 4c48df572bd6..ba6b88528dc7 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -2058,6 +2058,20 @@ struct btrfs_ioctl_defrag_range_args { | |||
2058 | #define btrfs_raw_test_opt(o, opt) ((o) & BTRFS_MOUNT_##opt) | 2058 | #define btrfs_raw_test_opt(o, opt) ((o) & BTRFS_MOUNT_##opt) |
2059 | #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \ | 2059 | #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \ |
2060 | BTRFS_MOUNT_##opt) | 2060 | BTRFS_MOUNT_##opt) |
2061 | #define btrfs_set_and_info(root, opt, fmt, args...) \ | ||
2062 | { \ | ||
2063 | if (!btrfs_test_opt(root, opt)) \ | ||
2064 | btrfs_info(root->fs_info, fmt, ##args); \ | ||
2065 | btrfs_set_opt(root->fs_info->mount_opt, opt); \ | ||
2066 | } | ||
2067 | |||
2068 | #define btrfs_clear_and_info(root, opt, fmt, args...) \ | ||
2069 | { \ | ||
2070 | if (btrfs_test_opt(root, opt)) \ | ||
2071 | btrfs_info(root->fs_info, fmt, ##args); \ | ||
2072 | btrfs_clear_opt(root->fs_info->mount_opt, opt); \ | ||
2073 | } | ||
2074 | |||
2061 | /* | 2075 | /* |
2062 | * Inode flags | 2076 | * Inode flags |
2063 | */ | 2077 | */ |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 029d46c2e170..983314932af3 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -2861,7 +2861,7 @@ retry_root_backup: | |||
2861 | printk(KERN_ERR "BTRFS: failed to read log tree\n"); | 2861 | printk(KERN_ERR "BTRFS: failed to read log tree\n"); |
2862 | free_extent_buffer(log_tree_root->node); | 2862 | free_extent_buffer(log_tree_root->node); |
2863 | kfree(log_tree_root); | 2863 | kfree(log_tree_root); |
2864 | goto fail_trans_kthread; | 2864 | goto fail_qgroup; |
2865 | } | 2865 | } |
2866 | /* returns with log_tree_root freed on success */ | 2866 | /* returns with log_tree_root freed on success */ |
2867 | ret = btrfs_recover_log_trees(log_tree_root); | 2867 | ret = btrfs_recover_log_trees(log_tree_root); |
@@ -2870,24 +2870,24 @@ retry_root_backup: | |||
2870 | "Failed to recover log tree"); | 2870 | "Failed to recover log tree"); |
2871 | free_extent_buffer(log_tree_root->node); | 2871 | free_extent_buffer(log_tree_root->node); |
2872 | kfree(log_tree_root); | 2872 | kfree(log_tree_root); |
2873 | goto fail_trans_kthread; | 2873 | goto fail_qgroup; |
2874 | } | 2874 | } |
2875 | 2875 | ||
2876 | if (sb->s_flags & MS_RDONLY) { | 2876 | if (sb->s_flags & MS_RDONLY) { |
2877 | ret = btrfs_commit_super(tree_root); | 2877 | ret = btrfs_commit_super(tree_root); |
2878 | if (ret) | 2878 | if (ret) |
2879 | goto fail_trans_kthread; | 2879 | goto fail_qgroup; |
2880 | } | 2880 | } |
2881 | } | 2881 | } |
2882 | 2882 | ||
2883 | ret = btrfs_find_orphan_roots(tree_root); | 2883 | ret = btrfs_find_orphan_roots(tree_root); |
2884 | if (ret) | 2884 | if (ret) |
2885 | goto fail_trans_kthread; | 2885 | goto fail_qgroup; |
2886 | 2886 | ||
2887 | if (!(sb->s_flags & MS_RDONLY)) { | 2887 | if (!(sb->s_flags & MS_RDONLY)) { |
2888 | ret = btrfs_cleanup_fs_roots(fs_info); | 2888 | ret = btrfs_cleanup_fs_roots(fs_info); |
2889 | if (ret) | 2889 | if (ret) |
2890 | goto fail_trans_kthread; | 2890 | goto fail_qgroup; |
2891 | 2891 | ||
2892 | ret = btrfs_recover_relocation(tree_root); | 2892 | ret = btrfs_recover_relocation(tree_root); |
2893 | if (ret < 0) { | 2893 | if (ret < 0) { |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 1306487c82cf..5590af92094b 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -1542,6 +1542,7 @@ again: | |||
1542 | ret = 0; | 1542 | ret = 0; |
1543 | } | 1543 | } |
1544 | if (ret) { | 1544 | if (ret) { |
1545 | key.objectid = bytenr; | ||
1545 | key.type = BTRFS_EXTENT_ITEM_KEY; | 1546 | key.type = BTRFS_EXTENT_ITEM_KEY; |
1546 | key.offset = num_bytes; | 1547 | key.offset = num_bytes; |
1547 | btrfs_release_path(path); | 1548 | btrfs_release_path(path); |
@@ -3542,11 +3543,13 @@ static u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags) | |||
3542 | return extended_to_chunk(flags | tmp); | 3543 | return extended_to_chunk(flags | tmp); |
3543 | } | 3544 | } |
3544 | 3545 | ||
3545 | static u64 get_alloc_profile(struct btrfs_root *root, u64 flags) | 3546 | static u64 get_alloc_profile(struct btrfs_root *root, u64 orig_flags) |
3546 | { | 3547 | { |
3547 | unsigned seq; | 3548 | unsigned seq; |
3549 | u64 flags; | ||
3548 | 3550 | ||
3549 | do { | 3551 | do { |
3552 | flags = orig_flags; | ||
3550 | seq = read_seqbegin(&root->fs_info->profiles_lock); | 3553 | seq = read_seqbegin(&root->fs_info->profiles_lock); |
3551 | 3554 | ||
3552 | if (flags & BTRFS_BLOCK_GROUP_DATA) | 3555 | if (flags & BTRFS_BLOCK_GROUP_DATA) |
@@ -5719,6 +5722,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans, | |||
5719 | 5722 | ||
5720 | if (ret > 0 && skinny_metadata) { | 5723 | if (ret > 0 && skinny_metadata) { |
5721 | skinny_metadata = false; | 5724 | skinny_metadata = false; |
5725 | key.objectid = bytenr; | ||
5722 | key.type = BTRFS_EXTENT_ITEM_KEY; | 5726 | key.type = BTRFS_EXTENT_ITEM_KEY; |
5723 | key.offset = num_bytes; | 5727 | key.offset = num_bytes; |
5724 | btrfs_release_path(path); | 5728 | btrfs_release_path(path); |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index eb742c07e7a4..ae6af072b635 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -800,7 +800,7 @@ next_slot: | |||
800 | if (start > key.offset && end < extent_end) { | 800 | if (start > key.offset && end < extent_end) { |
801 | BUG_ON(del_nr > 0); | 801 | BUG_ON(del_nr > 0); |
802 | if (extent_type == BTRFS_FILE_EXTENT_INLINE) { | 802 | if (extent_type == BTRFS_FILE_EXTENT_INLINE) { |
803 | ret = -EINVAL; | 803 | ret = -EOPNOTSUPP; |
804 | break; | 804 | break; |
805 | } | 805 | } |
806 | 806 | ||
@@ -846,7 +846,7 @@ next_slot: | |||
846 | */ | 846 | */ |
847 | if (start <= key.offset && end < extent_end) { | 847 | if (start <= key.offset && end < extent_end) { |
848 | if (extent_type == BTRFS_FILE_EXTENT_INLINE) { | 848 | if (extent_type == BTRFS_FILE_EXTENT_INLINE) { |
849 | ret = -EINVAL; | 849 | ret = -EOPNOTSUPP; |
850 | break; | 850 | break; |
851 | } | 851 | } |
852 | 852 | ||
@@ -872,7 +872,7 @@ next_slot: | |||
872 | if (start > key.offset && end >= extent_end) { | 872 | if (start > key.offset && end >= extent_end) { |
873 | BUG_ON(del_nr > 0); | 873 | BUG_ON(del_nr > 0); |
874 | if (extent_type == BTRFS_FILE_EXTENT_INLINE) { | 874 | if (extent_type == BTRFS_FILE_EXTENT_INLINE) { |
875 | ret = -EINVAL; | 875 | ret = -EOPNOTSUPP; |
876 | break; | 876 | break; |
877 | } | 877 | } |
878 | 878 | ||
@@ -1777,7 +1777,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, | |||
1777 | start_pos = round_down(pos, root->sectorsize); | 1777 | start_pos = round_down(pos, root->sectorsize); |
1778 | if (start_pos > i_size_read(inode)) { | 1778 | if (start_pos > i_size_read(inode)) { |
1779 | /* Expand hole size to cover write data, preventing empty gap */ | 1779 | /* Expand hole size to cover write data, preventing empty gap */ |
1780 | end_pos = round_up(pos + iov->iov_len, root->sectorsize); | 1780 | end_pos = round_up(pos + count, root->sectorsize); |
1781 | err = btrfs_cont_expand(inode, i_size_read(inode), end_pos); | 1781 | err = btrfs_cont_expand(inode, i_size_read(inode), end_pos); |
1782 | if (err) { | 1782 | if (err) { |
1783 | mutex_unlock(&inode->i_mutex); | 1783 | mutex_unlock(&inode->i_mutex); |
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c index cc8ca193d830..86935f5ae291 100644 --- a/fs/btrfs/inode-map.c +++ b/fs/btrfs/inode-map.c | |||
@@ -176,7 +176,11 @@ static void start_caching(struct btrfs_root *root) | |||
176 | 176 | ||
177 | tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu\n", | 177 | tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu\n", |
178 | root->root_key.objectid); | 178 | root->root_key.objectid); |
179 | BUG_ON(IS_ERR(tsk)); /* -ENOMEM */ | 179 | if (IS_ERR(tsk)) { |
180 | btrfs_warn(root->fs_info, "failed to start inode caching task"); | ||
181 | btrfs_clear_and_info(root, CHANGE_INODE_CACHE, | ||
182 | "disabling inode map caching"); | ||
183 | } | ||
180 | } | 184 | } |
181 | 185 | ||
182 | int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid) | 186 | int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid) |
@@ -205,24 +209,14 @@ again: | |||
205 | 209 | ||
206 | void btrfs_return_ino(struct btrfs_root *root, u64 objectid) | 210 | void btrfs_return_ino(struct btrfs_root *root, u64 objectid) |
207 | { | 211 | { |
208 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; | ||
209 | struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; | 212 | struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; |
210 | 213 | ||
211 | if (!btrfs_test_opt(root, INODE_MAP_CACHE)) | 214 | if (!btrfs_test_opt(root, INODE_MAP_CACHE)) |
212 | return; | 215 | return; |
213 | |||
214 | again: | 216 | again: |
215 | if (root->cached == BTRFS_CACHE_FINISHED) { | 217 | if (root->cached == BTRFS_CACHE_FINISHED) { |
216 | __btrfs_add_free_space(ctl, objectid, 1); | 218 | __btrfs_add_free_space(pinned, objectid, 1); |
217 | } else { | 219 | } else { |
218 | /* | ||
219 | * If we are in the process of caching free ino chunks, | ||
220 | * to avoid adding the same inode number to the free_ino | ||
221 | * tree twice due to cross transaction, we'll leave it | ||
222 | * in the pinned tree until a transaction is committed | ||
223 | * or the caching work is done. | ||
224 | */ | ||
225 | |||
226 | down_write(&root->fs_info->commit_root_sem); | 220 | down_write(&root->fs_info->commit_root_sem); |
227 | spin_lock(&root->cache_lock); | 221 | spin_lock(&root->cache_lock); |
228 | if (root->cached == BTRFS_CACHE_FINISHED) { | 222 | if (root->cached == BTRFS_CACHE_FINISHED) { |
@@ -234,11 +228,7 @@ again: | |||
234 | 228 | ||
235 | start_caching(root); | 229 | start_caching(root); |
236 | 230 | ||
237 | if (objectid <= root->cache_progress || | 231 | __btrfs_add_free_space(pinned, objectid, 1); |
238 | objectid >= root->highest_objectid) | ||
239 | __btrfs_add_free_space(ctl, objectid, 1); | ||
240 | else | ||
241 | __btrfs_add_free_space(pinned, objectid, 1); | ||
242 | 232 | ||
243 | up_write(&root->fs_info->commit_root_sem); | 233 | up_write(&root->fs_info->commit_root_sem); |
244 | } | 234 | } |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index e79ff6b90cb7..2ad7de94efef 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -3066,7 +3066,7 @@ process_slot: | |||
3066 | new_key.offset + datal, | 3066 | new_key.offset + datal, |
3067 | 1); | 3067 | 1); |
3068 | if (ret) { | 3068 | if (ret) { |
3069 | if (ret != -EINVAL) | 3069 | if (ret != -EOPNOTSUPP) |
3070 | btrfs_abort_transaction(trans, | 3070 | btrfs_abort_transaction(trans, |
3071 | root, ret); | 3071 | root, ret); |
3072 | btrfs_end_transaction(trans, root); | 3072 | btrfs_end_transaction(trans, root); |
@@ -3141,7 +3141,7 @@ process_slot: | |||
3141 | new_key.offset + datal, | 3141 | new_key.offset + datal, |
3142 | 1); | 3142 | 1); |
3143 | if (ret) { | 3143 | if (ret) { |
3144 | if (ret != -EINVAL) | 3144 | if (ret != -EOPNOTSUPP) |
3145 | btrfs_abort_transaction(trans, | 3145 | btrfs_abort_transaction(trans, |
3146 | root, ret); | 3146 | root, ret); |
3147 | btrfs_end_transaction(trans, root); | 3147 | btrfs_end_transaction(trans, root); |
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 1ac3ca98c429..eb6537a08c1b 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c | |||
@@ -349,6 +349,11 @@ static int fs_path_ensure_buf(struct fs_path *p, int len) | |||
349 | if (p->buf_len >= len) | 349 | if (p->buf_len >= len) |
350 | return 0; | 350 | return 0; |
351 | 351 | ||
352 | if (len > PATH_MAX) { | ||
353 | WARN_ON(1); | ||
354 | return -ENOMEM; | ||
355 | } | ||
356 | |||
352 | path_len = p->end - p->start; | 357 | path_len = p->end - p->start; |
353 | old_buf_len = p->buf_len; | 358 | old_buf_len = p->buf_len; |
354 | 359 | ||
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 5011aadacab8..9601d25a4607 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -385,20 +385,6 @@ static match_table_t tokens = { | |||
385 | {Opt_err, NULL}, | 385 | {Opt_err, NULL}, |
386 | }; | 386 | }; |
387 | 387 | ||
388 | #define btrfs_set_and_info(root, opt, fmt, args...) \ | ||
389 | { \ | ||
390 | if (!btrfs_test_opt(root, opt)) \ | ||
391 | btrfs_info(root->fs_info, fmt, ##args); \ | ||
392 | btrfs_set_opt(root->fs_info->mount_opt, opt); \ | ||
393 | } | ||
394 | |||
395 | #define btrfs_clear_and_info(root, opt, fmt, args...) \ | ||
396 | { \ | ||
397 | if (btrfs_test_opt(root, opt)) \ | ||
398 | btrfs_info(root->fs_info, fmt, ##args); \ | ||
399 | btrfs_clear_opt(root->fs_info->mount_opt, opt); \ | ||
400 | } | ||
401 | |||
402 | /* | 388 | /* |
403 | * Regular mount options parser. Everything that is needed only when | 389 | * Regular mount options parser. Everything that is needed only when |
404 | * reading in a new superblock is parsed here. | 390 | * reading in a new superblock is parsed here. |
@@ -1186,7 +1172,6 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags, | |||
1186 | return ERR_PTR(-ENOMEM); | 1172 | return ERR_PTR(-ENOMEM); |
1187 | mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name, | 1173 | mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name, |
1188 | newargs); | 1174 | newargs); |
1189 | kfree(newargs); | ||
1190 | 1175 | ||
1191 | if (PTR_RET(mnt) == -EBUSY) { | 1176 | if (PTR_RET(mnt) == -EBUSY) { |
1192 | if (flags & MS_RDONLY) { | 1177 | if (flags & MS_RDONLY) { |
@@ -1196,17 +1181,22 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags, | |||
1196 | int r; | 1181 | int r; |
1197 | mnt = vfs_kern_mount(&btrfs_fs_type, flags | MS_RDONLY, device_name, | 1182 | mnt = vfs_kern_mount(&btrfs_fs_type, flags | MS_RDONLY, device_name, |
1198 | newargs); | 1183 | newargs); |
1199 | if (IS_ERR(mnt)) | 1184 | if (IS_ERR(mnt)) { |
1185 | kfree(newargs); | ||
1200 | return ERR_CAST(mnt); | 1186 | return ERR_CAST(mnt); |
1187 | } | ||
1201 | 1188 | ||
1202 | r = btrfs_remount(mnt->mnt_sb, &flags, NULL); | 1189 | r = btrfs_remount(mnt->mnt_sb, &flags, NULL); |
1203 | if (r < 0) { | 1190 | if (r < 0) { |
1204 | /* FIXME: release vfsmount mnt ??*/ | 1191 | /* FIXME: release vfsmount mnt ??*/ |
1192 | kfree(newargs); | ||
1205 | return ERR_PTR(r); | 1193 | return ERR_PTR(r); |
1206 | } | 1194 | } |
1207 | } | 1195 | } |
1208 | } | 1196 | } |
1209 | 1197 | ||
1198 | kfree(newargs); | ||
1199 | |||
1210 | if (IS_ERR(mnt)) | 1200 | if (IS_ERR(mnt)) |
1211 | return ERR_CAST(mnt); | 1201 | return ERR_CAST(mnt); |
1212 | 1202 | ||
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 2e5e648eb5c3..c561b628ebce 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c | |||
@@ -3261,7 +3261,7 @@ int ceph_encode_inode_release(void **p, struct inode *inode, | |||
3261 | rel->seq = cpu_to_le32(cap->seq); | 3261 | rel->seq = cpu_to_le32(cap->seq); |
3262 | rel->issue_seq = cpu_to_le32(cap->issue_seq), | 3262 | rel->issue_seq = cpu_to_le32(cap->issue_seq), |
3263 | rel->mseq = cpu_to_le32(cap->mseq); | 3263 | rel->mseq = cpu_to_le32(cap->mseq); |
3264 | rel->caps = cpu_to_le32(cap->issued); | 3264 | rel->caps = cpu_to_le32(cap->implemented); |
3265 | rel->wanted = cpu_to_le32(cap->mds_wanted); | 3265 | rel->wanted = cpu_to_le32(cap->mds_wanted); |
3266 | rel->dname_len = 0; | 3266 | rel->dname_len = 0; |
3267 | rel->dname_seq = 0; | 3267 | rel->dname_seq = 0; |
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 766410a12c2c..c29d6ae68874 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c | |||
@@ -141,7 +141,7 @@ static int __dcache_readdir(struct file *file, struct dir_context *ctx, | |||
141 | 141 | ||
142 | /* start at beginning? */ | 142 | /* start at beginning? */ |
143 | if (ctx->pos == 2 || last == NULL || | 143 | if (ctx->pos == 2 || last == NULL || |
144 | ctx->pos < ceph_dentry(last)->offset) { | 144 | fpos_cmp(ctx->pos, ceph_dentry(last)->offset) < 0) { |
145 | if (list_empty(&parent->d_subdirs)) | 145 | if (list_empty(&parent->d_subdirs)) |
146 | goto out_unlock; | 146 | goto out_unlock; |
147 | p = parent->d_subdirs.prev; | 147 | p = parent->d_subdirs.prev; |
@@ -182,9 +182,16 @@ more: | |||
182 | spin_unlock(&dentry->d_lock); | 182 | spin_unlock(&dentry->d_lock); |
183 | spin_unlock(&parent->d_lock); | 183 | spin_unlock(&parent->d_lock); |
184 | 184 | ||
185 | /* make sure a dentry wasn't dropped while we didn't have parent lock */ | ||
186 | if (!ceph_dir_is_complete(dir)) { | ||
187 | dout(" lost dir complete on %p; falling back to mds\n", dir); | ||
188 | dput(dentry); | ||
189 | err = -EAGAIN; | ||
190 | goto out; | ||
191 | } | ||
192 | |||
185 | dout(" %llu (%llu) dentry %p %.*s %p\n", di->offset, ctx->pos, | 193 | dout(" %llu (%llu) dentry %p %.*s %p\n", di->offset, ctx->pos, |
186 | dentry, dentry->d_name.len, dentry->d_name.name, dentry->d_inode); | 194 | dentry, dentry->d_name.len, dentry->d_name.name, dentry->d_inode); |
187 | ctx->pos = di->offset; | ||
188 | if (!dir_emit(ctx, dentry->d_name.name, | 195 | if (!dir_emit(ctx, dentry->d_name.name, |
189 | dentry->d_name.len, | 196 | dentry->d_name.len, |
190 | ceph_translate_ino(dentry->d_sb, dentry->d_inode->i_ino), | 197 | ceph_translate_ino(dentry->d_sb, dentry->d_inode->i_ino), |
@@ -198,19 +205,12 @@ more: | |||
198 | return 0; | 205 | return 0; |
199 | } | 206 | } |
200 | 207 | ||
208 | ctx->pos = di->offset + 1; | ||
209 | |||
201 | if (last) | 210 | if (last) |
202 | dput(last); | 211 | dput(last); |
203 | last = dentry; | 212 | last = dentry; |
204 | 213 | ||
205 | ctx->pos++; | ||
206 | |||
207 | /* make sure a dentry wasn't dropped while we didn't have parent lock */ | ||
208 | if (!ceph_dir_is_complete(dir)) { | ||
209 | dout(" lost dir complete on %p; falling back to mds\n", dir); | ||
210 | err = -EAGAIN; | ||
211 | goto out; | ||
212 | } | ||
213 | |||
214 | spin_lock(&parent->d_lock); | 214 | spin_lock(&parent->d_lock); |
215 | p = p->prev; /* advance to next dentry */ | 215 | p = p->prev; /* advance to next dentry */ |
216 | goto more; | 216 | goto more; |
@@ -296,6 +296,8 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx) | |||
296 | err = __dcache_readdir(file, ctx, shared_gen); | 296 | err = __dcache_readdir(file, ctx, shared_gen); |
297 | if (err != -EAGAIN) | 297 | if (err != -EAGAIN) |
298 | return err; | 298 | return err; |
299 | frag = fpos_frag(ctx->pos); | ||
300 | off = fpos_off(ctx->pos); | ||
299 | } else { | 301 | } else { |
300 | spin_unlock(&ci->i_ceph_lock); | 302 | spin_unlock(&ci->i_ceph_lock); |
301 | } | 303 | } |
@@ -446,7 +448,6 @@ more: | |||
446 | if (atomic_read(&ci->i_release_count) == fi->dir_release_count) { | 448 | if (atomic_read(&ci->i_release_count) == fi->dir_release_count) { |
447 | dout(" marking %p complete\n", inode); | 449 | dout(" marking %p complete\n", inode); |
448 | __ceph_dir_set_complete(ci, fi->dir_release_count); | 450 | __ceph_dir_set_complete(ci, fi->dir_release_count); |
449 | ci->i_max_offset = ctx->pos; | ||
450 | } | 451 | } |
451 | spin_unlock(&ci->i_ceph_lock); | 452 | spin_unlock(&ci->i_ceph_lock); |
452 | 453 | ||
@@ -935,14 +936,16 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
935 | * to do it here. | 936 | * to do it here. |
936 | */ | 937 | */ |
937 | 938 | ||
938 | /* d_move screws up d_subdirs order */ | ||
939 | ceph_dir_clear_complete(new_dir); | ||
940 | |||
941 | d_move(old_dentry, new_dentry); | 939 | d_move(old_dentry, new_dentry); |
942 | 940 | ||
943 | /* ensure target dentry is invalidated, despite | 941 | /* ensure target dentry is invalidated, despite |
944 | rehashing bug in vfs_rename_dir */ | 942 | rehashing bug in vfs_rename_dir */ |
945 | ceph_invalidate_dentry_lease(new_dentry); | 943 | ceph_invalidate_dentry_lease(new_dentry); |
944 | |||
945 | /* d_move screws up sibling dentries' offsets */ | ||
946 | ceph_dir_clear_complete(old_dir); | ||
947 | ceph_dir_clear_complete(new_dir); | ||
948 | |||
946 | } | 949 | } |
947 | ceph_mdsc_put_request(req); | 950 | ceph_mdsc_put_request(req); |
948 | return err; | 951 | return err; |
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 0b0728e5be2d..233c6f96910a 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c | |||
@@ -744,7 +744,6 @@ static int fill_inode(struct inode *inode, | |||
744 | !__ceph_dir_is_complete(ci)) { | 744 | !__ceph_dir_is_complete(ci)) { |
745 | dout(" marking %p complete (empty)\n", inode); | 745 | dout(" marking %p complete (empty)\n", inode); |
746 | __ceph_dir_set_complete(ci, atomic_read(&ci->i_release_count)); | 746 | __ceph_dir_set_complete(ci, atomic_read(&ci->i_release_count)); |
747 | ci->i_max_offset = 2; | ||
748 | } | 747 | } |
749 | no_change: | 748 | no_change: |
750 | /* only update max_size on auth cap */ | 749 | /* only update max_size on auth cap */ |
@@ -890,41 +889,6 @@ out_unlock: | |||
890 | } | 889 | } |
891 | 890 | ||
892 | /* | 891 | /* |
893 | * Set dentry's directory position based on the current dir's max, and | ||
894 | * order it in d_subdirs, so that dcache_readdir behaves. | ||
895 | * | ||
896 | * Always called under directory's i_mutex. | ||
897 | */ | ||
898 | static void ceph_set_dentry_offset(struct dentry *dn) | ||
899 | { | ||
900 | struct dentry *dir = dn->d_parent; | ||
901 | struct inode *inode = dir->d_inode; | ||
902 | struct ceph_inode_info *ci; | ||
903 | struct ceph_dentry_info *di; | ||
904 | |||
905 | BUG_ON(!inode); | ||
906 | |||
907 | ci = ceph_inode(inode); | ||
908 | di = ceph_dentry(dn); | ||
909 | |||
910 | spin_lock(&ci->i_ceph_lock); | ||
911 | if (!__ceph_dir_is_complete(ci)) { | ||
912 | spin_unlock(&ci->i_ceph_lock); | ||
913 | return; | ||
914 | } | ||
915 | di->offset = ceph_inode(inode)->i_max_offset++; | ||
916 | spin_unlock(&ci->i_ceph_lock); | ||
917 | |||
918 | spin_lock(&dir->d_lock); | ||
919 | spin_lock_nested(&dn->d_lock, DENTRY_D_LOCK_NESTED); | ||
920 | list_move(&dn->d_u.d_child, &dir->d_subdirs); | ||
921 | dout("set_dentry_offset %p %lld (%p %p)\n", dn, di->offset, | ||
922 | dn->d_u.d_child.prev, dn->d_u.d_child.next); | ||
923 | spin_unlock(&dn->d_lock); | ||
924 | spin_unlock(&dir->d_lock); | ||
925 | } | ||
926 | |||
927 | /* | ||
928 | * splice a dentry to an inode. | 892 | * splice a dentry to an inode. |
929 | * caller must hold directory i_mutex for this to be safe. | 893 | * caller must hold directory i_mutex for this to be safe. |
930 | * | 894 | * |
@@ -933,7 +897,7 @@ static void ceph_set_dentry_offset(struct dentry *dn) | |||
933 | * the caller) if we fail. | 897 | * the caller) if we fail. |
934 | */ | 898 | */ |
935 | static struct dentry *splice_dentry(struct dentry *dn, struct inode *in, | 899 | static struct dentry *splice_dentry(struct dentry *dn, struct inode *in, |
936 | bool *prehash, bool set_offset) | 900 | bool *prehash) |
937 | { | 901 | { |
938 | struct dentry *realdn; | 902 | struct dentry *realdn; |
939 | 903 | ||
@@ -965,8 +929,6 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in, | |||
965 | } | 929 | } |
966 | if ((!prehash || *prehash) && d_unhashed(dn)) | 930 | if ((!prehash || *prehash) && d_unhashed(dn)) |
967 | d_rehash(dn); | 931 | d_rehash(dn); |
968 | if (set_offset) | ||
969 | ceph_set_dentry_offset(dn); | ||
970 | out: | 932 | out: |
971 | return dn; | 933 | return dn; |
972 | } | 934 | } |
@@ -987,7 +949,6 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, | |||
987 | { | 949 | { |
988 | struct ceph_mds_reply_info_parsed *rinfo = &req->r_reply_info; | 950 | struct ceph_mds_reply_info_parsed *rinfo = &req->r_reply_info; |
989 | struct inode *in = NULL; | 951 | struct inode *in = NULL; |
990 | struct ceph_mds_reply_inode *ininfo; | ||
991 | struct ceph_vino vino; | 952 | struct ceph_vino vino; |
992 | struct ceph_fs_client *fsc = ceph_sb_to_client(sb); | 953 | struct ceph_fs_client *fsc = ceph_sb_to_client(sb); |
993 | int err = 0; | 954 | int err = 0; |
@@ -1161,6 +1122,9 @@ retry_lookup: | |||
1161 | 1122 | ||
1162 | /* rename? */ | 1123 | /* rename? */ |
1163 | if (req->r_old_dentry && req->r_op == CEPH_MDS_OP_RENAME) { | 1124 | if (req->r_old_dentry && req->r_op == CEPH_MDS_OP_RENAME) { |
1125 | struct inode *olddir = req->r_old_dentry_dir; | ||
1126 | BUG_ON(!olddir); | ||
1127 | |||
1164 | dout(" src %p '%.*s' dst %p '%.*s'\n", | 1128 | dout(" src %p '%.*s' dst %p '%.*s'\n", |
1165 | req->r_old_dentry, | 1129 | req->r_old_dentry, |
1166 | req->r_old_dentry->d_name.len, | 1130 | req->r_old_dentry->d_name.len, |
@@ -1180,13 +1144,10 @@ retry_lookup: | |||
1180 | rehashing bug in vfs_rename_dir */ | 1144 | rehashing bug in vfs_rename_dir */ |
1181 | ceph_invalidate_dentry_lease(dn); | 1145 | ceph_invalidate_dentry_lease(dn); |
1182 | 1146 | ||
1183 | /* | 1147 | /* d_move screws up sibling dentries' offsets */ |
1184 | * d_move() puts the renamed dentry at the end of | 1148 | ceph_dir_clear_complete(dir); |
1185 | * d_subdirs. We need to assign it an appropriate | 1149 | ceph_dir_clear_complete(olddir); |
1186 | * directory offset so we can behave when dir is | 1150 | |
1187 | * complete. | ||
1188 | */ | ||
1189 | ceph_set_dentry_offset(req->r_old_dentry); | ||
1190 | dout("dn %p gets new offset %lld\n", req->r_old_dentry, | 1151 | dout("dn %p gets new offset %lld\n", req->r_old_dentry, |
1191 | ceph_dentry(req->r_old_dentry)->offset); | 1152 | ceph_dentry(req->r_old_dentry)->offset); |
1192 | 1153 | ||
@@ -1213,8 +1174,9 @@ retry_lookup: | |||
1213 | 1174 | ||
1214 | /* attach proper inode */ | 1175 | /* attach proper inode */ |
1215 | if (!dn->d_inode) { | 1176 | if (!dn->d_inode) { |
1177 | ceph_dir_clear_complete(dir); | ||
1216 | ihold(in); | 1178 | ihold(in); |
1217 | dn = splice_dentry(dn, in, &have_lease, true); | 1179 | dn = splice_dentry(dn, in, &have_lease); |
1218 | if (IS_ERR(dn)) { | 1180 | if (IS_ERR(dn)) { |
1219 | err = PTR_ERR(dn); | 1181 | err = PTR_ERR(dn); |
1220 | goto done; | 1182 | goto done; |
@@ -1235,17 +1197,16 @@ retry_lookup: | |||
1235 | (req->r_op == CEPH_MDS_OP_LOOKUPSNAP || | 1197 | (req->r_op == CEPH_MDS_OP_LOOKUPSNAP || |
1236 | req->r_op == CEPH_MDS_OP_MKSNAP)) { | 1198 | req->r_op == CEPH_MDS_OP_MKSNAP)) { |
1237 | struct dentry *dn = req->r_dentry; | 1199 | struct dentry *dn = req->r_dentry; |
1200 | struct inode *dir = req->r_locked_dir; | ||
1238 | 1201 | ||
1239 | /* fill out a snapdir LOOKUPSNAP dentry */ | 1202 | /* fill out a snapdir LOOKUPSNAP dentry */ |
1240 | BUG_ON(!dn); | 1203 | BUG_ON(!dn); |
1241 | BUG_ON(!req->r_locked_dir); | 1204 | BUG_ON(!dir); |
1242 | BUG_ON(ceph_snap(req->r_locked_dir) != CEPH_SNAPDIR); | 1205 | BUG_ON(ceph_snap(dir) != CEPH_SNAPDIR); |
1243 | ininfo = rinfo->targeti.in; | ||
1244 | vino.ino = le64_to_cpu(ininfo->ino); | ||
1245 | vino.snap = le64_to_cpu(ininfo->snapid); | ||
1246 | dout(" linking snapped dir %p to dn %p\n", in, dn); | 1206 | dout(" linking snapped dir %p to dn %p\n", in, dn); |
1207 | ceph_dir_clear_complete(dir); | ||
1247 | ihold(in); | 1208 | ihold(in); |
1248 | dn = splice_dentry(dn, in, NULL, true); | 1209 | dn = splice_dentry(dn, in, NULL); |
1249 | if (IS_ERR(dn)) { | 1210 | if (IS_ERR(dn)) { |
1250 | err = PTR_ERR(dn); | 1211 | err = PTR_ERR(dn); |
1251 | goto done; | 1212 | goto done; |
@@ -1407,7 +1368,7 @@ retry_lookup: | |||
1407 | } | 1368 | } |
1408 | 1369 | ||
1409 | if (!dn->d_inode) { | 1370 | if (!dn->d_inode) { |
1410 | dn = splice_dentry(dn, in, NULL, false); | 1371 | dn = splice_dentry(dn, in, NULL); |
1411 | if (IS_ERR(dn)) { | 1372 | if (IS_ERR(dn)) { |
1412 | err = PTR_ERR(dn); | 1373 | err = PTR_ERR(dn); |
1413 | dn = NULL; | 1374 | dn = NULL; |
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c index fdf941b44ff1..a822a6e58290 100644 --- a/fs/ceph/ioctl.c +++ b/fs/ceph/ioctl.c | |||
@@ -109,6 +109,8 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) | |||
109 | return PTR_ERR(req); | 109 | return PTR_ERR(req); |
110 | req->r_inode = inode; | 110 | req->r_inode = inode; |
111 | ihold(inode); | 111 | ihold(inode); |
112 | req->r_num_caps = 1; | ||
113 | |||
112 | req->r_inode_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL; | 114 | req->r_inode_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL; |
113 | 115 | ||
114 | req->r_args.setlayout.layout.fl_stripe_unit = | 116 | req->r_args.setlayout.layout.fl_stripe_unit = |
@@ -153,6 +155,7 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg) | |||
153 | return PTR_ERR(req); | 155 | return PTR_ERR(req); |
154 | req->r_inode = inode; | 156 | req->r_inode = inode; |
155 | ihold(inode); | 157 | ihold(inode); |
158 | req->r_num_caps = 1; | ||
156 | 159 | ||
157 | req->r_args.setlayout.layout.fl_stripe_unit = | 160 | req->r_args.setlayout.layout.fl_stripe_unit = |
158 | cpu_to_le32(l.stripe_unit); | 161 | cpu_to_le32(l.stripe_unit); |
diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c index d94ba0df9f4d..191398852a2e 100644 --- a/fs/ceph/locks.c +++ b/fs/ceph/locks.c | |||
@@ -45,6 +45,7 @@ static int ceph_lock_message(u8 lock_type, u16 operation, struct file *file, | |||
45 | return PTR_ERR(req); | 45 | return PTR_ERR(req); |
46 | req->r_inode = inode; | 46 | req->r_inode = inode; |
47 | ihold(inode); | 47 | ihold(inode); |
48 | req->r_num_caps = 1; | ||
48 | 49 | ||
49 | /* mds requires start and length rather than start and end */ | 50 | /* mds requires start and length rather than start and end */ |
50 | if (LLONG_MAX == fl->fl_end) | 51 | if (LLONG_MAX == fl->fl_end) |
diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 7866cd05a6bb..ead05cc1f447 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h | |||
@@ -266,7 +266,6 @@ struct ceph_inode_info { | |||
266 | struct timespec i_rctime; | 266 | struct timespec i_rctime; |
267 | u64 i_rbytes, i_rfiles, i_rsubdirs; | 267 | u64 i_rbytes, i_rfiles, i_rsubdirs; |
268 | u64 i_files, i_subdirs; | 268 | u64 i_files, i_subdirs; |
269 | u64 i_max_offset; /* largest readdir offset, set with complete dir */ | ||
270 | 269 | ||
271 | struct rb_root i_fragtree; | 270 | struct rb_root i_fragtree; |
272 | struct mutex i_fragtree_mutex; | 271 | struct mutex i_fragtree_mutex; |
diff --git a/fs/compat.c b/fs/compat.c index ca926ad0430c..66d3d3c6b4b2 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -457,9 +457,9 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, | |||
457 | case F_GETLK64: | 457 | case F_GETLK64: |
458 | case F_SETLK64: | 458 | case F_SETLK64: |
459 | case F_SETLKW64: | 459 | case F_SETLKW64: |
460 | case F_GETLKP: | 460 | case F_OFD_GETLK: |
461 | case F_SETLKP: | 461 | case F_OFD_SETLK: |
462 | case F_SETLKPW: | 462 | case F_OFD_SETLKW: |
463 | ret = get_compat_flock64(&f, compat_ptr(arg)); | 463 | ret = get_compat_flock64(&f, compat_ptr(arg)); |
464 | if (ret != 0) | 464 | if (ret != 0) |
465 | break; | 465 | break; |
@@ -468,7 +468,7 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, | |||
468 | conv_cmd = convert_fcntl_cmd(cmd); | 468 | conv_cmd = convert_fcntl_cmd(cmd); |
469 | ret = sys_fcntl(fd, conv_cmd, (unsigned long)&f); | 469 | ret = sys_fcntl(fd, conv_cmd, (unsigned long)&f); |
470 | set_fs(old_fs); | 470 | set_fs(old_fs); |
471 | if ((conv_cmd == F_GETLK || conv_cmd == F_GETLKP) && ret == 0) { | 471 | if ((conv_cmd == F_GETLK || conv_cmd == F_OFD_GETLK) && ret == 0) { |
472 | /* need to return lock information - see above for commentary */ | 472 | /* need to return lock information - see above for commentary */ |
473 | if (f.l_start > COMPAT_LOFF_T_MAX) | 473 | if (f.l_start > COMPAT_LOFF_T_MAX) |
474 | ret = -EOVERFLOW; | 474 | ret = -EOVERFLOW; |
@@ -493,9 +493,9 @@ COMPAT_SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, | |||
493 | case F_GETLK64: | 493 | case F_GETLK64: |
494 | case F_SETLK64: | 494 | case F_SETLK64: |
495 | case F_SETLKW64: | 495 | case F_SETLKW64: |
496 | case F_GETLKP: | 496 | case F_OFD_GETLK: |
497 | case F_SETLKP: | 497 | case F_OFD_SETLK: |
498 | case F_SETLKPW: | 498 | case F_OFD_SETLKW: |
499 | return -EINVAL; | 499 | return -EINVAL; |
500 | } | 500 | } |
501 | return compat_sys_fcntl64(fd, cmd, arg); | 501 | return compat_sys_fcntl64(fd, cmd, arg); |
diff --git a/fs/dcache.c b/fs/dcache.c index 40707d88a945..42ae01eefc07 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -246,16 +246,8 @@ static void __d_free(struct rcu_head *head) | |||
246 | kmem_cache_free(dentry_cache, dentry); | 246 | kmem_cache_free(dentry_cache, dentry); |
247 | } | 247 | } |
248 | 248 | ||
249 | /* | 249 | static void dentry_free(struct dentry *dentry) |
250 | * no locks, please. | ||
251 | */ | ||
252 | static void d_free(struct dentry *dentry) | ||
253 | { | 250 | { |
254 | BUG_ON((int)dentry->d_lockref.count > 0); | ||
255 | this_cpu_dec(nr_dentry); | ||
256 | if (dentry->d_op && dentry->d_op->d_release) | ||
257 | dentry->d_op->d_release(dentry); | ||
258 | |||
259 | /* if dentry was never visible to RCU, immediate free is OK */ | 251 | /* if dentry was never visible to RCU, immediate free is OK */ |
260 | if (!(dentry->d_flags & DCACHE_RCUACCESS)) | 252 | if (!(dentry->d_flags & DCACHE_RCUACCESS)) |
261 | __d_free(&dentry->d_u.d_rcu); | 253 | __d_free(&dentry->d_u.d_rcu); |
@@ -403,56 +395,6 @@ static void dentry_lru_add(struct dentry *dentry) | |||
403 | d_lru_add(dentry); | 395 | d_lru_add(dentry); |
404 | } | 396 | } |
405 | 397 | ||
406 | /* | ||
407 | * Remove a dentry with references from the LRU. | ||
408 | * | ||
409 | * If we are on the shrink list, then we can get to try_prune_one_dentry() and | ||
410 | * lose our last reference through the parent walk. In this case, we need to | ||
411 | * remove ourselves from the shrink list, not the LRU. | ||
412 | */ | ||
413 | static void dentry_lru_del(struct dentry *dentry) | ||
414 | { | ||
415 | if (dentry->d_flags & DCACHE_LRU_LIST) { | ||
416 | if (dentry->d_flags & DCACHE_SHRINK_LIST) | ||
417 | return d_shrink_del(dentry); | ||
418 | d_lru_del(dentry); | ||
419 | } | ||
420 | } | ||
421 | |||
422 | /** | ||
423 | * d_kill - kill dentry and return parent | ||
424 | * @dentry: dentry to kill | ||
425 | * @parent: parent dentry | ||
426 | * | ||
427 | * The dentry must already be unhashed and removed from the LRU. | ||
428 | * | ||
429 | * If this is the root of the dentry tree, return NULL. | ||
430 | * | ||
431 | * dentry->d_lock and parent->d_lock must be held by caller, and are dropped by | ||
432 | * d_kill. | ||
433 | */ | ||
434 | static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent) | ||
435 | __releases(dentry->d_lock) | ||
436 | __releases(parent->d_lock) | ||
437 | __releases(dentry->d_inode->i_lock) | ||
438 | { | ||
439 | list_del(&dentry->d_u.d_child); | ||
440 | /* | ||
441 | * Inform d_walk() that we are no longer attached to the | ||
442 | * dentry tree | ||
443 | */ | ||
444 | dentry->d_flags |= DCACHE_DENTRY_KILLED; | ||
445 | if (parent) | ||
446 | spin_unlock(&parent->d_lock); | ||
447 | dentry_iput(dentry); | ||
448 | /* | ||
449 | * dentry_iput drops the locks, at which point nobody (except | ||
450 | * transient RCU lookups) can reach this dentry. | ||
451 | */ | ||
452 | d_free(dentry); | ||
453 | return parent; | ||
454 | } | ||
455 | |||
456 | /** | 398 | /** |
457 | * d_drop - drop a dentry | 399 | * d_drop - drop a dentry |
458 | * @dentry: dentry to drop | 400 | * @dentry: dentry to drop |
@@ -510,7 +452,14 @@ dentry_kill(struct dentry *dentry, int unlock_on_failure) | |||
510 | __releases(dentry->d_lock) | 452 | __releases(dentry->d_lock) |
511 | { | 453 | { |
512 | struct inode *inode; | 454 | struct inode *inode; |
513 | struct dentry *parent; | 455 | struct dentry *parent = NULL; |
456 | bool can_free = true; | ||
457 | |||
458 | if (unlikely(dentry->d_flags & DCACHE_DENTRY_KILLED)) { | ||
459 | can_free = dentry->d_flags & DCACHE_MAY_FREE; | ||
460 | spin_unlock(&dentry->d_lock); | ||
461 | goto out; | ||
462 | } | ||
514 | 463 | ||
515 | inode = dentry->d_inode; | 464 | inode = dentry->d_inode; |
516 | if (inode && !spin_trylock(&inode->i_lock)) { | 465 | if (inode && !spin_trylock(&inode->i_lock)) { |
@@ -521,9 +470,7 @@ relock: | |||
521 | } | 470 | } |
522 | return dentry; /* try again with same dentry */ | 471 | return dentry; /* try again with same dentry */ |
523 | } | 472 | } |
524 | if (IS_ROOT(dentry)) | 473 | if (!IS_ROOT(dentry)) |
525 | parent = NULL; | ||
526 | else | ||
527 | parent = dentry->d_parent; | 474 | parent = dentry->d_parent; |
528 | if (parent && !spin_trylock(&parent->d_lock)) { | 475 | if (parent && !spin_trylock(&parent->d_lock)) { |
529 | if (inode) | 476 | if (inode) |
@@ -543,10 +490,40 @@ relock: | |||
543 | if ((dentry->d_flags & DCACHE_OP_PRUNE) && !d_unhashed(dentry)) | 490 | if ((dentry->d_flags & DCACHE_OP_PRUNE) && !d_unhashed(dentry)) |
544 | dentry->d_op->d_prune(dentry); | 491 | dentry->d_op->d_prune(dentry); |
545 | 492 | ||
546 | dentry_lru_del(dentry); | 493 | if (dentry->d_flags & DCACHE_LRU_LIST) { |
494 | if (!(dentry->d_flags & DCACHE_SHRINK_LIST)) | ||
495 | d_lru_del(dentry); | ||
496 | } | ||
547 | /* if it was on the hash then remove it */ | 497 | /* if it was on the hash then remove it */ |
548 | __d_drop(dentry); | 498 | __d_drop(dentry); |
549 | return d_kill(dentry, parent); | 499 | list_del(&dentry->d_u.d_child); |
500 | /* | ||
501 | * Inform d_walk() that we are no longer attached to the | ||
502 | * dentry tree | ||
503 | */ | ||
504 | dentry->d_flags |= DCACHE_DENTRY_KILLED; | ||
505 | if (parent) | ||
506 | spin_unlock(&parent->d_lock); | ||
507 | dentry_iput(dentry); | ||
508 | /* | ||
509 | * dentry_iput drops the locks, at which point nobody (except | ||
510 | * transient RCU lookups) can reach this dentry. | ||
511 | */ | ||
512 | BUG_ON((int)dentry->d_lockref.count > 0); | ||
513 | this_cpu_dec(nr_dentry); | ||
514 | if (dentry->d_op && dentry->d_op->d_release) | ||
515 | dentry->d_op->d_release(dentry); | ||
516 | |||
517 | spin_lock(&dentry->d_lock); | ||
518 | if (dentry->d_flags & DCACHE_SHRINK_LIST) { | ||
519 | dentry->d_flags |= DCACHE_MAY_FREE; | ||
520 | can_free = false; | ||
521 | } | ||
522 | spin_unlock(&dentry->d_lock); | ||
523 | out: | ||
524 | if (likely(can_free)) | ||
525 | dentry_free(dentry); | ||
526 | return parent; | ||
550 | } | 527 | } |
551 | 528 | ||
552 | /* | 529 | /* |
@@ -815,65 +792,13 @@ restart: | |||
815 | } | 792 | } |
816 | EXPORT_SYMBOL(d_prune_aliases); | 793 | EXPORT_SYMBOL(d_prune_aliases); |
817 | 794 | ||
818 | /* | ||
819 | * Try to throw away a dentry - free the inode, dput the parent. | ||
820 | * Requires dentry->d_lock is held, and dentry->d_count == 0. | ||
821 | * Releases dentry->d_lock. | ||
822 | * | ||
823 | * This may fail if locks cannot be acquired no problem, just try again. | ||
824 | */ | ||
825 | static struct dentry * try_prune_one_dentry(struct dentry *dentry) | ||
826 | __releases(dentry->d_lock) | ||
827 | { | ||
828 | struct dentry *parent; | ||
829 | |||
830 | parent = dentry_kill(dentry, 0); | ||
831 | /* | ||
832 | * If dentry_kill returns NULL, we have nothing more to do. | ||
833 | * if it returns the same dentry, trylocks failed. In either | ||
834 | * case, just loop again. | ||
835 | * | ||
836 | * Otherwise, we need to prune ancestors too. This is necessary | ||
837 | * to prevent quadratic behavior of shrink_dcache_parent(), but | ||
838 | * is also expected to be beneficial in reducing dentry cache | ||
839 | * fragmentation. | ||
840 | */ | ||
841 | if (!parent) | ||
842 | return NULL; | ||
843 | if (parent == dentry) | ||
844 | return dentry; | ||
845 | |||
846 | /* Prune ancestors. */ | ||
847 | dentry = parent; | ||
848 | while (dentry) { | ||
849 | if (lockref_put_or_lock(&dentry->d_lockref)) | ||
850 | return NULL; | ||
851 | dentry = dentry_kill(dentry, 1); | ||
852 | } | ||
853 | return NULL; | ||
854 | } | ||
855 | |||
856 | static void shrink_dentry_list(struct list_head *list) | 795 | static void shrink_dentry_list(struct list_head *list) |
857 | { | 796 | { |
858 | struct dentry *dentry; | 797 | struct dentry *dentry, *parent; |
859 | 798 | ||
860 | rcu_read_lock(); | 799 | while (!list_empty(list)) { |
861 | for (;;) { | 800 | dentry = list_entry(list->prev, struct dentry, d_lru); |
862 | dentry = list_entry_rcu(list->prev, struct dentry, d_lru); | ||
863 | if (&dentry->d_lru == list) | ||
864 | break; /* empty */ | ||
865 | |||
866 | /* | ||
867 | * Get the dentry lock, and re-verify that the dentry is | ||
868 | * this on the shrinking list. If it is, we know that | ||
869 | * DCACHE_SHRINK_LIST and DCACHE_LRU_LIST are set. | ||
870 | */ | ||
871 | spin_lock(&dentry->d_lock); | 801 | spin_lock(&dentry->d_lock); |
872 | if (dentry != list_entry(list->prev, struct dentry, d_lru)) { | ||
873 | spin_unlock(&dentry->d_lock); | ||
874 | continue; | ||
875 | } | ||
876 | |||
877 | /* | 802 | /* |
878 | * The dispose list is isolated and dentries are not accounted | 803 | * The dispose list is isolated and dentries are not accounted |
879 | * to the LRU here, so we can simply remove it from the list | 804 | * to the LRU here, so we can simply remove it from the list |
@@ -885,30 +810,38 @@ static void shrink_dentry_list(struct list_head *list) | |||
885 | * We found an inuse dentry which was not removed from | 810 | * We found an inuse dentry which was not removed from |
886 | * the LRU because of laziness during lookup. Do not free it. | 811 | * the LRU because of laziness during lookup. Do not free it. |
887 | */ | 812 | */ |
888 | if (dentry->d_lockref.count) { | 813 | if ((int)dentry->d_lockref.count > 0) { |
889 | spin_unlock(&dentry->d_lock); | 814 | spin_unlock(&dentry->d_lock); |
890 | continue; | 815 | continue; |
891 | } | 816 | } |
892 | rcu_read_unlock(); | ||
893 | 817 | ||
818 | parent = dentry_kill(dentry, 0); | ||
894 | /* | 819 | /* |
895 | * If 'try_to_prune()' returns a dentry, it will | 820 | * If dentry_kill returns NULL, we have nothing more to do. |
896 | * be the same one we passed in, and d_lock will | ||
897 | * have been held the whole time, so it will not | ||
898 | * have been added to any other lists. We failed | ||
899 | * to get the inode lock. | ||
900 | * | ||
901 | * We just add it back to the shrink list. | ||
902 | */ | 821 | */ |
903 | dentry = try_prune_one_dentry(dentry); | 822 | if (!parent) |
823 | continue; | ||
904 | 824 | ||
905 | rcu_read_lock(); | 825 | if (unlikely(parent == dentry)) { |
906 | if (dentry) { | 826 | /* |
827 | * trylocks have failed and d_lock has been held the | ||
828 | * whole time, so it could not have been added to any | ||
829 | * other lists. Just add it back to the shrink list. | ||
830 | */ | ||
907 | d_shrink_add(dentry, list); | 831 | d_shrink_add(dentry, list); |
908 | spin_unlock(&dentry->d_lock); | 832 | spin_unlock(&dentry->d_lock); |
833 | continue; | ||
909 | } | 834 | } |
835 | /* | ||
836 | * We need to prune ancestors too. This is necessary to prevent | ||
837 | * quadratic behavior of shrink_dcache_parent(), but is also | ||
838 | * expected to be beneficial in reducing dentry cache | ||
839 | * fragmentation. | ||
840 | */ | ||
841 | dentry = parent; | ||
842 | while (dentry && !lockref_put_or_lock(&dentry->d_lockref)) | ||
843 | dentry = dentry_kill(dentry, 1); | ||
910 | } | 844 | } |
911 | rcu_read_unlock(); | ||
912 | } | 845 | } |
913 | 846 | ||
914 | static enum lru_status | 847 | static enum lru_status |
@@ -1261,34 +1194,23 @@ static enum d_walk_ret select_collect(void *_data, struct dentry *dentry) | |||
1261 | if (data->start == dentry) | 1194 | if (data->start == dentry) |
1262 | goto out; | 1195 | goto out; |
1263 | 1196 | ||
1264 | /* | 1197 | if (dentry->d_flags & DCACHE_SHRINK_LIST) { |
1265 | * move only zero ref count dentries to the dispose list. | ||
1266 | * | ||
1267 | * Those which are presently on the shrink list, being processed | ||
1268 | * by shrink_dentry_list(), shouldn't be moved. Otherwise the | ||
1269 | * loop in shrink_dcache_parent() might not make any progress | ||
1270 | * and loop forever. | ||
1271 | */ | ||
1272 | if (dentry->d_lockref.count) { | ||
1273 | dentry_lru_del(dentry); | ||
1274 | } else if (!(dentry->d_flags & DCACHE_SHRINK_LIST)) { | ||
1275 | /* | ||
1276 | * We can't use d_lru_shrink_move() because we | ||
1277 | * need to get the global LRU lock and do the | ||
1278 | * LRU accounting. | ||
1279 | */ | ||
1280 | d_lru_del(dentry); | ||
1281 | d_shrink_add(dentry, &data->dispose); | ||
1282 | data->found++; | 1198 | data->found++; |
1283 | ret = D_WALK_NORETRY; | 1199 | } else { |
1200 | if (dentry->d_flags & DCACHE_LRU_LIST) | ||
1201 | d_lru_del(dentry); | ||
1202 | if (!dentry->d_lockref.count) { | ||
1203 | d_shrink_add(dentry, &data->dispose); | ||
1204 | data->found++; | ||
1205 | } | ||
1284 | } | 1206 | } |
1285 | /* | 1207 | /* |
1286 | * We can return to the caller if we have found some (this | 1208 | * We can return to the caller if we have found some (this |
1287 | * ensures forward progress). We'll be coming back to find | 1209 | * ensures forward progress). We'll be coming back to find |
1288 | * the rest. | 1210 | * the rest. |
1289 | */ | 1211 | */ |
1290 | if (data->found && need_resched()) | 1212 | if (!list_empty(&data->dispose)) |
1291 | ret = D_WALK_QUIT; | 1213 | ret = need_resched() ? D_WALK_QUIT : D_WALK_NORETRY; |
1292 | out: | 1214 | out: |
1293 | return ret; | 1215 | return ret; |
1294 | } | 1216 | } |
@@ -1318,45 +1240,35 @@ void shrink_dcache_parent(struct dentry *parent) | |||
1318 | } | 1240 | } |
1319 | EXPORT_SYMBOL(shrink_dcache_parent); | 1241 | EXPORT_SYMBOL(shrink_dcache_parent); |
1320 | 1242 | ||
1321 | static enum d_walk_ret umount_collect(void *_data, struct dentry *dentry) | 1243 | static enum d_walk_ret umount_check(void *_data, struct dentry *dentry) |
1322 | { | 1244 | { |
1323 | struct select_data *data = _data; | 1245 | /* it has busy descendents; complain about those instead */ |
1324 | enum d_walk_ret ret = D_WALK_CONTINUE; | 1246 | if (!list_empty(&dentry->d_subdirs)) |
1247 | return D_WALK_CONTINUE; | ||
1325 | 1248 | ||
1326 | if (dentry->d_lockref.count) { | 1249 | /* root with refcount 1 is fine */ |
1327 | dentry_lru_del(dentry); | 1250 | if (dentry == _data && dentry->d_lockref.count == 1) |
1328 | if (likely(!list_empty(&dentry->d_subdirs))) | 1251 | return D_WALK_CONTINUE; |
1329 | goto out; | 1252 | |
1330 | if (dentry == data->start && dentry->d_lockref.count == 1) | 1253 | printk(KERN_ERR "BUG: Dentry %p{i=%lx,n=%pd} " |
1331 | goto out; | 1254 | " still in use (%d) [unmount of %s %s]\n", |
1332 | printk(KERN_ERR | ||
1333 | "BUG: Dentry %p{i=%lx,n=%s}" | ||
1334 | " still in use (%d)" | ||
1335 | " [unmount of %s %s]\n", | ||
1336 | dentry, | 1255 | dentry, |
1337 | dentry->d_inode ? | 1256 | dentry->d_inode ? |
1338 | dentry->d_inode->i_ino : 0UL, | 1257 | dentry->d_inode->i_ino : 0UL, |
1339 | dentry->d_name.name, | 1258 | dentry, |
1340 | dentry->d_lockref.count, | 1259 | dentry->d_lockref.count, |
1341 | dentry->d_sb->s_type->name, | 1260 | dentry->d_sb->s_type->name, |
1342 | dentry->d_sb->s_id); | 1261 | dentry->d_sb->s_id); |
1343 | BUG(); | 1262 | WARN_ON(1); |
1344 | } else if (!(dentry->d_flags & DCACHE_SHRINK_LIST)) { | 1263 | return D_WALK_CONTINUE; |
1345 | /* | 1264 | } |
1346 | * We can't use d_lru_shrink_move() because we | 1265 | |
1347 | * need to get the global LRU lock and do the | 1266 | static void do_one_tree(struct dentry *dentry) |
1348 | * LRU accounting. | 1267 | { |
1349 | */ | 1268 | shrink_dcache_parent(dentry); |
1350 | if (dentry->d_flags & DCACHE_LRU_LIST) | 1269 | d_walk(dentry, dentry, umount_check, NULL); |
1351 | d_lru_del(dentry); | 1270 | d_drop(dentry); |
1352 | d_shrink_add(dentry, &data->dispose); | 1271 | dput(dentry); |
1353 | data->found++; | ||
1354 | ret = D_WALK_NORETRY; | ||
1355 | } | ||
1356 | out: | ||
1357 | if (data->found && need_resched()) | ||
1358 | ret = D_WALK_QUIT; | ||
1359 | return ret; | ||
1360 | } | 1272 | } |
1361 | 1273 | ||
1362 | /* | 1274 | /* |
@@ -1366,40 +1278,15 @@ void shrink_dcache_for_umount(struct super_block *sb) | |||
1366 | { | 1278 | { |
1367 | struct dentry *dentry; | 1279 | struct dentry *dentry; |
1368 | 1280 | ||
1369 | if (down_read_trylock(&sb->s_umount)) | 1281 | WARN(down_read_trylock(&sb->s_umount), "s_umount should've been locked"); |
1370 | BUG(); | ||
1371 | 1282 | ||
1372 | dentry = sb->s_root; | 1283 | dentry = sb->s_root; |
1373 | sb->s_root = NULL; | 1284 | sb->s_root = NULL; |
1374 | for (;;) { | 1285 | do_one_tree(dentry); |
1375 | struct select_data data; | ||
1376 | |||
1377 | INIT_LIST_HEAD(&data.dispose); | ||
1378 | data.start = dentry; | ||
1379 | data.found = 0; | ||
1380 | |||
1381 | d_walk(dentry, &data, umount_collect, NULL); | ||
1382 | if (!data.found) | ||
1383 | break; | ||
1384 | |||
1385 | shrink_dentry_list(&data.dispose); | ||
1386 | cond_resched(); | ||
1387 | } | ||
1388 | d_drop(dentry); | ||
1389 | dput(dentry); | ||
1390 | 1286 | ||
1391 | while (!hlist_bl_empty(&sb->s_anon)) { | 1287 | while (!hlist_bl_empty(&sb->s_anon)) { |
1392 | struct select_data data; | 1288 | dentry = dget(hlist_bl_entry(hlist_bl_first(&sb->s_anon), struct dentry, d_hash)); |
1393 | dentry = hlist_bl_entry(hlist_bl_first(&sb->s_anon), struct dentry, d_hash); | 1289 | do_one_tree(dentry); |
1394 | |||
1395 | INIT_LIST_HEAD(&data.dispose); | ||
1396 | data.start = NULL; | ||
1397 | data.found = 0; | ||
1398 | |||
1399 | d_walk(dentry, &data, umount_collect, NULL); | ||
1400 | if (data.found) | ||
1401 | shrink_dentry_list(&data.dispose); | ||
1402 | cond_resched(); | ||
1403 | } | 1290 | } |
1404 | } | 1291 | } |
1405 | 1292 | ||
@@ -1647,8 +1534,7 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode) | |||
1647 | unsigned add_flags = d_flags_for_inode(inode); | 1534 | unsigned add_flags = d_flags_for_inode(inode); |
1648 | 1535 | ||
1649 | spin_lock(&dentry->d_lock); | 1536 | spin_lock(&dentry->d_lock); |
1650 | dentry->d_flags &= ~DCACHE_ENTRY_TYPE; | 1537 | __d_set_type(dentry, add_flags); |
1651 | dentry->d_flags |= add_flags; | ||
1652 | if (inode) | 1538 | if (inode) |
1653 | hlist_add_head(&dentry->d_alias, &inode->i_dentry); | 1539 | hlist_add_head(&dentry->d_alias, &inode->i_dentry); |
1654 | dentry->d_inode = inode; | 1540 | dentry->d_inode = inode; |
diff --git a/fs/fcntl.c b/fs/fcntl.c index 9ead1596399a..72c82f69b01b 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -274,15 +274,15 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, | |||
274 | break; | 274 | break; |
275 | #if BITS_PER_LONG != 32 | 275 | #if BITS_PER_LONG != 32 |
276 | /* 32-bit arches must use fcntl64() */ | 276 | /* 32-bit arches must use fcntl64() */ |
277 | case F_GETLKP: | 277 | case F_OFD_GETLK: |
278 | #endif | 278 | #endif |
279 | case F_GETLK: | 279 | case F_GETLK: |
280 | err = fcntl_getlk(filp, cmd, (struct flock __user *) arg); | 280 | err = fcntl_getlk(filp, cmd, (struct flock __user *) arg); |
281 | break; | 281 | break; |
282 | #if BITS_PER_LONG != 32 | 282 | #if BITS_PER_LONG != 32 |
283 | /* 32-bit arches must use fcntl64() */ | 283 | /* 32-bit arches must use fcntl64() */ |
284 | case F_SETLKP: | 284 | case F_OFD_SETLK: |
285 | case F_SETLKPW: | 285 | case F_OFD_SETLKW: |
286 | #endif | 286 | #endif |
287 | /* Fallthrough */ | 287 | /* Fallthrough */ |
288 | case F_SETLK: | 288 | case F_SETLK: |
@@ -399,13 +399,13 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, | |||
399 | 399 | ||
400 | switch (cmd) { | 400 | switch (cmd) { |
401 | case F_GETLK64: | 401 | case F_GETLK64: |
402 | case F_GETLKP: | 402 | case F_OFD_GETLK: |
403 | err = fcntl_getlk64(f.file, cmd, (struct flock64 __user *) arg); | 403 | err = fcntl_getlk64(f.file, cmd, (struct flock64 __user *) arg); |
404 | break; | 404 | break; |
405 | case F_SETLK64: | 405 | case F_SETLK64: |
406 | case F_SETLKW64: | 406 | case F_SETLKW64: |
407 | case F_SETLKP: | 407 | case F_OFD_SETLK: |
408 | case F_SETLKPW: | 408 | case F_OFD_SETLKW: |
409 | err = fcntl_setlk64(fd, f.file, cmd, | 409 | err = fcntl_setlk64(fd, f.file, cmd, |
410 | (struct flock64 __user *) arg); | 410 | (struct flock64 __user *) arg); |
411 | break; | 411 | break; |
diff --git a/fs/fuse/control.c b/fs/fuse/control.c index a0b0855d00a9..205e0d5d5307 100644 --- a/fs/fuse/control.c +++ b/fs/fuse/control.c | |||
@@ -348,7 +348,7 @@ int __init fuse_ctl_init(void) | |||
348 | return register_filesystem(&fuse_ctl_fs_type); | 348 | return register_filesystem(&fuse_ctl_fs_type); |
349 | } | 349 | } |
350 | 350 | ||
351 | void fuse_ctl_cleanup(void) | 351 | void __exit fuse_ctl_cleanup(void) |
352 | { | 352 | { |
353 | unregister_filesystem(&fuse_ctl_fs_type); | 353 | unregister_filesystem(&fuse_ctl_fs_type); |
354 | } | 354 | } |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 5b4e035b364c..42198359fa1b 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -679,6 +679,14 @@ static int fuse_symlink(struct inode *dir, struct dentry *entry, | |||
679 | return create_new_entry(fc, req, dir, entry, S_IFLNK); | 679 | return create_new_entry(fc, req, dir, entry, S_IFLNK); |
680 | } | 680 | } |
681 | 681 | ||
682 | static inline void fuse_update_ctime(struct inode *inode) | ||
683 | { | ||
684 | if (!IS_NOCMTIME(inode)) { | ||
685 | inode->i_ctime = current_fs_time(inode->i_sb); | ||
686 | mark_inode_dirty_sync(inode); | ||
687 | } | ||
688 | } | ||
689 | |||
682 | static int fuse_unlink(struct inode *dir, struct dentry *entry) | 690 | static int fuse_unlink(struct inode *dir, struct dentry *entry) |
683 | { | 691 | { |
684 | int err; | 692 | int err; |
@@ -713,6 +721,7 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry) | |||
713 | fuse_invalidate_attr(inode); | 721 | fuse_invalidate_attr(inode); |
714 | fuse_invalidate_attr(dir); | 722 | fuse_invalidate_attr(dir); |
715 | fuse_invalidate_entry_cache(entry); | 723 | fuse_invalidate_entry_cache(entry); |
724 | fuse_update_ctime(inode); | ||
716 | } else if (err == -EINTR) | 725 | } else if (err == -EINTR) |
717 | fuse_invalidate_entry(entry); | 726 | fuse_invalidate_entry(entry); |
718 | return err; | 727 | return err; |
@@ -743,23 +752,26 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry) | |||
743 | return err; | 752 | return err; |
744 | } | 753 | } |
745 | 754 | ||
746 | static int fuse_rename(struct inode *olddir, struct dentry *oldent, | 755 | static int fuse_rename_common(struct inode *olddir, struct dentry *oldent, |
747 | struct inode *newdir, struct dentry *newent) | 756 | struct inode *newdir, struct dentry *newent, |
757 | unsigned int flags, int opcode, size_t argsize) | ||
748 | { | 758 | { |
749 | int err; | 759 | int err; |
750 | struct fuse_rename_in inarg; | 760 | struct fuse_rename2_in inarg; |
751 | struct fuse_conn *fc = get_fuse_conn(olddir); | 761 | struct fuse_conn *fc = get_fuse_conn(olddir); |
752 | struct fuse_req *req = fuse_get_req_nopages(fc); | 762 | struct fuse_req *req; |
753 | 763 | ||
764 | req = fuse_get_req_nopages(fc); | ||
754 | if (IS_ERR(req)) | 765 | if (IS_ERR(req)) |
755 | return PTR_ERR(req); | 766 | return PTR_ERR(req); |
756 | 767 | ||
757 | memset(&inarg, 0, sizeof(inarg)); | 768 | memset(&inarg, 0, argsize); |
758 | inarg.newdir = get_node_id(newdir); | 769 | inarg.newdir = get_node_id(newdir); |
759 | req->in.h.opcode = FUSE_RENAME; | 770 | inarg.flags = flags; |
771 | req->in.h.opcode = opcode; | ||
760 | req->in.h.nodeid = get_node_id(olddir); | 772 | req->in.h.nodeid = get_node_id(olddir); |
761 | req->in.numargs = 3; | 773 | req->in.numargs = 3; |
762 | req->in.args[0].size = sizeof(inarg); | 774 | req->in.args[0].size = argsize; |
763 | req->in.args[0].value = &inarg; | 775 | req->in.args[0].value = &inarg; |
764 | req->in.args[1].size = oldent->d_name.len + 1; | 776 | req->in.args[1].size = oldent->d_name.len + 1; |
765 | req->in.args[1].value = oldent->d_name.name; | 777 | req->in.args[1].value = oldent->d_name.name; |
@@ -771,15 +783,22 @@ static int fuse_rename(struct inode *olddir, struct dentry *oldent, | |||
771 | if (!err) { | 783 | if (!err) { |
772 | /* ctime changes */ | 784 | /* ctime changes */ |
773 | fuse_invalidate_attr(oldent->d_inode); | 785 | fuse_invalidate_attr(oldent->d_inode); |
786 | fuse_update_ctime(oldent->d_inode); | ||
787 | |||
788 | if (flags & RENAME_EXCHANGE) { | ||
789 | fuse_invalidate_attr(newent->d_inode); | ||
790 | fuse_update_ctime(newent->d_inode); | ||
791 | } | ||
774 | 792 | ||
775 | fuse_invalidate_attr(olddir); | 793 | fuse_invalidate_attr(olddir); |
776 | if (olddir != newdir) | 794 | if (olddir != newdir) |
777 | fuse_invalidate_attr(newdir); | 795 | fuse_invalidate_attr(newdir); |
778 | 796 | ||
779 | /* newent will end up negative */ | 797 | /* newent will end up negative */ |
780 | if (newent->d_inode) { | 798 | if (!(flags & RENAME_EXCHANGE) && newent->d_inode) { |
781 | fuse_invalidate_attr(newent->d_inode); | 799 | fuse_invalidate_attr(newent->d_inode); |
782 | fuse_invalidate_entry_cache(newent); | 800 | fuse_invalidate_entry_cache(newent); |
801 | fuse_update_ctime(newent->d_inode); | ||
783 | } | 802 | } |
784 | } else if (err == -EINTR) { | 803 | } else if (err == -EINTR) { |
785 | /* If request was interrupted, DEITY only knows if the | 804 | /* If request was interrupted, DEITY only knows if the |
@@ -795,6 +814,36 @@ static int fuse_rename(struct inode *olddir, struct dentry *oldent, | |||
795 | return err; | 814 | return err; |
796 | } | 815 | } |
797 | 816 | ||
817 | static int fuse_rename(struct inode *olddir, struct dentry *oldent, | ||
818 | struct inode *newdir, struct dentry *newent) | ||
819 | { | ||
820 | return fuse_rename_common(olddir, oldent, newdir, newent, 0, | ||
821 | FUSE_RENAME, sizeof(struct fuse_rename_in)); | ||
822 | } | ||
823 | |||
824 | static int fuse_rename2(struct inode *olddir, struct dentry *oldent, | ||
825 | struct inode *newdir, struct dentry *newent, | ||
826 | unsigned int flags) | ||
827 | { | ||
828 | struct fuse_conn *fc = get_fuse_conn(olddir); | ||
829 | int err; | ||
830 | |||
831 | if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE)) | ||
832 | return -EINVAL; | ||
833 | |||
834 | if (fc->no_rename2 || fc->minor < 23) | ||
835 | return -EINVAL; | ||
836 | |||
837 | err = fuse_rename_common(olddir, oldent, newdir, newent, flags, | ||
838 | FUSE_RENAME2, sizeof(struct fuse_rename2_in)); | ||
839 | if (err == -ENOSYS) { | ||
840 | fc->no_rename2 = 1; | ||
841 | err = -EINVAL; | ||
842 | } | ||
843 | return err; | ||
844 | |||
845 | } | ||
846 | |||
798 | static int fuse_link(struct dentry *entry, struct inode *newdir, | 847 | static int fuse_link(struct dentry *entry, struct inode *newdir, |
799 | struct dentry *newent) | 848 | struct dentry *newent) |
800 | { | 849 | { |
@@ -829,6 +878,7 @@ static int fuse_link(struct dentry *entry, struct inode *newdir, | |||
829 | inc_nlink(inode); | 878 | inc_nlink(inode); |
830 | spin_unlock(&fc->lock); | 879 | spin_unlock(&fc->lock); |
831 | fuse_invalidate_attr(inode); | 880 | fuse_invalidate_attr(inode); |
881 | fuse_update_ctime(inode); | ||
832 | } else if (err == -EINTR) { | 882 | } else if (err == -EINTR) { |
833 | fuse_invalidate_attr(inode); | 883 | fuse_invalidate_attr(inode); |
834 | } | 884 | } |
@@ -846,6 +896,8 @@ static void fuse_fillattr(struct inode *inode, struct fuse_attr *attr, | |||
846 | attr->size = i_size_read(inode); | 896 | attr->size = i_size_read(inode); |
847 | attr->mtime = inode->i_mtime.tv_sec; | 897 | attr->mtime = inode->i_mtime.tv_sec; |
848 | attr->mtimensec = inode->i_mtime.tv_nsec; | 898 | attr->mtimensec = inode->i_mtime.tv_nsec; |
899 | attr->ctime = inode->i_ctime.tv_sec; | ||
900 | attr->ctimensec = inode->i_ctime.tv_nsec; | ||
849 | } | 901 | } |
850 | 902 | ||
851 | stat->dev = inode->i_sb->s_dev; | 903 | stat->dev = inode->i_sb->s_dev; |
@@ -1504,7 +1556,7 @@ static bool update_mtime(unsigned ivalid, bool trust_local_mtime) | |||
1504 | } | 1556 | } |
1505 | 1557 | ||
1506 | static void iattr_to_fattr(struct iattr *iattr, struct fuse_setattr_in *arg, | 1558 | static void iattr_to_fattr(struct iattr *iattr, struct fuse_setattr_in *arg, |
1507 | bool trust_local_mtime) | 1559 | bool trust_local_cmtime) |
1508 | { | 1560 | { |
1509 | unsigned ivalid = iattr->ia_valid; | 1561 | unsigned ivalid = iattr->ia_valid; |
1510 | 1562 | ||
@@ -1523,13 +1575,18 @@ static void iattr_to_fattr(struct iattr *iattr, struct fuse_setattr_in *arg, | |||
1523 | if (!(ivalid & ATTR_ATIME_SET)) | 1575 | if (!(ivalid & ATTR_ATIME_SET)) |
1524 | arg->valid |= FATTR_ATIME_NOW; | 1576 | arg->valid |= FATTR_ATIME_NOW; |
1525 | } | 1577 | } |
1526 | if ((ivalid & ATTR_MTIME) && update_mtime(ivalid, trust_local_mtime)) { | 1578 | if ((ivalid & ATTR_MTIME) && update_mtime(ivalid, trust_local_cmtime)) { |
1527 | arg->valid |= FATTR_MTIME; | 1579 | arg->valid |= FATTR_MTIME; |
1528 | arg->mtime = iattr->ia_mtime.tv_sec; | 1580 | arg->mtime = iattr->ia_mtime.tv_sec; |
1529 | arg->mtimensec = iattr->ia_mtime.tv_nsec; | 1581 | arg->mtimensec = iattr->ia_mtime.tv_nsec; |
1530 | if (!(ivalid & ATTR_MTIME_SET) && !trust_local_mtime) | 1582 | if (!(ivalid & ATTR_MTIME_SET) && !trust_local_cmtime) |
1531 | arg->valid |= FATTR_MTIME_NOW; | 1583 | arg->valid |= FATTR_MTIME_NOW; |
1532 | } | 1584 | } |
1585 | if ((ivalid & ATTR_CTIME) && trust_local_cmtime) { | ||
1586 | arg->valid |= FATTR_CTIME; | ||
1587 | arg->ctime = iattr->ia_ctime.tv_sec; | ||
1588 | arg->ctimensec = iattr->ia_ctime.tv_nsec; | ||
1589 | } | ||
1533 | } | 1590 | } |
1534 | 1591 | ||
1535 | /* | 1592 | /* |
@@ -1597,39 +1654,38 @@ static void fuse_setattr_fill(struct fuse_conn *fc, struct fuse_req *req, | |||
1597 | /* | 1654 | /* |
1598 | * Flush inode->i_mtime to the server | 1655 | * Flush inode->i_mtime to the server |
1599 | */ | 1656 | */ |
1600 | int fuse_flush_mtime(struct file *file, bool nofail) | 1657 | int fuse_flush_times(struct inode *inode, struct fuse_file *ff) |
1601 | { | 1658 | { |
1602 | struct inode *inode = file->f_mapping->host; | ||
1603 | struct fuse_inode *fi = get_fuse_inode(inode); | ||
1604 | struct fuse_conn *fc = get_fuse_conn(inode); | 1659 | struct fuse_conn *fc = get_fuse_conn(inode); |
1605 | struct fuse_req *req = NULL; | 1660 | struct fuse_req *req; |
1606 | struct fuse_setattr_in inarg; | 1661 | struct fuse_setattr_in inarg; |
1607 | struct fuse_attr_out outarg; | 1662 | struct fuse_attr_out outarg; |
1608 | int err; | 1663 | int err; |
1609 | 1664 | ||
1610 | if (nofail) { | 1665 | req = fuse_get_req_nopages(fc); |
1611 | req = fuse_get_req_nofail_nopages(fc, file); | 1666 | if (IS_ERR(req)) |
1612 | } else { | 1667 | return PTR_ERR(req); |
1613 | req = fuse_get_req_nopages(fc); | ||
1614 | if (IS_ERR(req)) | ||
1615 | return PTR_ERR(req); | ||
1616 | } | ||
1617 | 1668 | ||
1618 | memset(&inarg, 0, sizeof(inarg)); | 1669 | memset(&inarg, 0, sizeof(inarg)); |
1619 | memset(&outarg, 0, sizeof(outarg)); | 1670 | memset(&outarg, 0, sizeof(outarg)); |
1620 | 1671 | ||
1621 | inarg.valid |= FATTR_MTIME; | 1672 | inarg.valid = FATTR_MTIME; |
1622 | inarg.mtime = inode->i_mtime.tv_sec; | 1673 | inarg.mtime = inode->i_mtime.tv_sec; |
1623 | inarg.mtimensec = inode->i_mtime.tv_nsec; | 1674 | inarg.mtimensec = inode->i_mtime.tv_nsec; |
1624 | 1675 | if (fc->minor >= 23) { | |
1676 | inarg.valid |= FATTR_CTIME; | ||
1677 | inarg.ctime = inode->i_ctime.tv_sec; | ||
1678 | inarg.ctimensec = inode->i_ctime.tv_nsec; | ||
1679 | } | ||
1680 | if (ff) { | ||
1681 | inarg.valid |= FATTR_FH; | ||
1682 | inarg.fh = ff->fh; | ||
1683 | } | ||
1625 | fuse_setattr_fill(fc, req, inode, &inarg, &outarg); | 1684 | fuse_setattr_fill(fc, req, inode, &inarg, &outarg); |
1626 | fuse_request_send(fc, req); | 1685 | fuse_request_send(fc, req); |
1627 | err = req->out.h.error; | 1686 | err = req->out.h.error; |
1628 | fuse_put_request(fc, req); | 1687 | fuse_put_request(fc, req); |
1629 | 1688 | ||
1630 | if (!err) | ||
1631 | clear_bit(FUSE_I_MTIME_DIRTY, &fi->state); | ||
1632 | |||
1633 | return err; | 1689 | return err; |
1634 | } | 1690 | } |
1635 | 1691 | ||
@@ -1653,7 +1709,7 @@ int fuse_do_setattr(struct inode *inode, struct iattr *attr, | |||
1653 | bool is_wb = fc->writeback_cache; | 1709 | bool is_wb = fc->writeback_cache; |
1654 | loff_t oldsize; | 1710 | loff_t oldsize; |
1655 | int err; | 1711 | int err; |
1656 | bool trust_local_mtime = is_wb && S_ISREG(inode->i_mode); | 1712 | bool trust_local_cmtime = is_wb && S_ISREG(inode->i_mode); |
1657 | 1713 | ||
1658 | if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS)) | 1714 | if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS)) |
1659 | attr->ia_valid |= ATTR_FORCE; | 1715 | attr->ia_valid |= ATTR_FORCE; |
@@ -1678,11 +1734,13 @@ int fuse_do_setattr(struct inode *inode, struct iattr *attr, | |||
1678 | if (is_truncate) { | 1734 | if (is_truncate) { |
1679 | fuse_set_nowrite(inode); | 1735 | fuse_set_nowrite(inode); |
1680 | set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state); | 1736 | set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state); |
1737 | if (trust_local_cmtime && attr->ia_size != inode->i_size) | ||
1738 | attr->ia_valid |= ATTR_MTIME | ATTR_CTIME; | ||
1681 | } | 1739 | } |
1682 | 1740 | ||
1683 | memset(&inarg, 0, sizeof(inarg)); | 1741 | memset(&inarg, 0, sizeof(inarg)); |
1684 | memset(&outarg, 0, sizeof(outarg)); | 1742 | memset(&outarg, 0, sizeof(outarg)); |
1685 | iattr_to_fattr(attr, &inarg, trust_local_mtime); | 1743 | iattr_to_fattr(attr, &inarg, trust_local_cmtime); |
1686 | if (file) { | 1744 | if (file) { |
1687 | struct fuse_file *ff = file->private_data; | 1745 | struct fuse_file *ff = file->private_data; |
1688 | inarg.valid |= FATTR_FH; | 1746 | inarg.valid |= FATTR_FH; |
@@ -1711,9 +1769,12 @@ int fuse_do_setattr(struct inode *inode, struct iattr *attr, | |||
1711 | 1769 | ||
1712 | spin_lock(&fc->lock); | 1770 | spin_lock(&fc->lock); |
1713 | /* the kernel maintains i_mtime locally */ | 1771 | /* the kernel maintains i_mtime locally */ |
1714 | if (trust_local_mtime && (attr->ia_valid & ATTR_MTIME)) { | 1772 | if (trust_local_cmtime) { |
1715 | inode->i_mtime = attr->ia_mtime; | 1773 | if (attr->ia_valid & ATTR_MTIME) |
1716 | clear_bit(FUSE_I_MTIME_DIRTY, &fi->state); | 1774 | inode->i_mtime = attr->ia_mtime; |
1775 | if (attr->ia_valid & ATTR_CTIME) | ||
1776 | inode->i_ctime = attr->ia_ctime; | ||
1777 | /* FIXME: clear I_DIRTY_SYNC? */ | ||
1717 | } | 1778 | } |
1718 | 1779 | ||
1719 | fuse_change_attributes_common(inode, &outarg.attr, | 1780 | fuse_change_attributes_common(inode, &outarg.attr, |
@@ -1810,8 +1871,10 @@ static int fuse_setxattr(struct dentry *entry, const char *name, | |||
1810 | fc->no_setxattr = 1; | 1871 | fc->no_setxattr = 1; |
1811 | err = -EOPNOTSUPP; | 1872 | err = -EOPNOTSUPP; |
1812 | } | 1873 | } |
1813 | if (!err) | 1874 | if (!err) { |
1814 | fuse_invalidate_attr(inode); | 1875 | fuse_invalidate_attr(inode); |
1876 | fuse_update_ctime(inode); | ||
1877 | } | ||
1815 | return err; | 1878 | return err; |
1816 | } | 1879 | } |
1817 | 1880 | ||
@@ -1941,20 +2004,11 @@ static int fuse_removexattr(struct dentry *entry, const char *name) | |||
1941 | fc->no_removexattr = 1; | 2004 | fc->no_removexattr = 1; |
1942 | err = -EOPNOTSUPP; | 2005 | err = -EOPNOTSUPP; |
1943 | } | 2006 | } |
1944 | if (!err) | 2007 | if (!err) { |
1945 | fuse_invalidate_attr(inode); | 2008 | fuse_invalidate_attr(inode); |
1946 | return err; | 2009 | fuse_update_ctime(inode); |
1947 | } | ||
1948 | |||
1949 | static int fuse_update_time(struct inode *inode, struct timespec *now, | ||
1950 | int flags) | ||
1951 | { | ||
1952 | if (flags & S_MTIME) { | ||
1953 | inode->i_mtime = *now; | ||
1954 | set_bit(FUSE_I_MTIME_DIRTY, &get_fuse_inode(inode)->state); | ||
1955 | BUG_ON(!S_ISREG(inode->i_mode)); | ||
1956 | } | 2010 | } |
1957 | return 0; | 2011 | return err; |
1958 | } | 2012 | } |
1959 | 2013 | ||
1960 | static const struct inode_operations fuse_dir_inode_operations = { | 2014 | static const struct inode_operations fuse_dir_inode_operations = { |
@@ -1964,6 +2018,7 @@ static const struct inode_operations fuse_dir_inode_operations = { | |||
1964 | .unlink = fuse_unlink, | 2018 | .unlink = fuse_unlink, |
1965 | .rmdir = fuse_rmdir, | 2019 | .rmdir = fuse_rmdir, |
1966 | .rename = fuse_rename, | 2020 | .rename = fuse_rename, |
2021 | .rename2 = fuse_rename2, | ||
1967 | .link = fuse_link, | 2022 | .link = fuse_link, |
1968 | .setattr = fuse_setattr, | 2023 | .setattr = fuse_setattr, |
1969 | .create = fuse_create, | 2024 | .create = fuse_create, |
@@ -1996,7 +2051,6 @@ static const struct inode_operations fuse_common_inode_operations = { | |||
1996 | .getxattr = fuse_getxattr, | 2051 | .getxattr = fuse_getxattr, |
1997 | .listxattr = fuse_listxattr, | 2052 | .listxattr = fuse_listxattr, |
1998 | .removexattr = fuse_removexattr, | 2053 | .removexattr = fuse_removexattr, |
1999 | .update_time = fuse_update_time, | ||
2000 | }; | 2054 | }; |
2001 | 2055 | ||
2002 | static const struct inode_operations fuse_symlink_inode_operations = { | 2056 | static const struct inode_operations fuse_symlink_inode_operations = { |
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 13f8bdec5110..96d513e01a5d 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -223,6 +223,8 @@ void fuse_finish_open(struct inode *inode, struct file *file) | |||
223 | i_size_write(inode, 0); | 223 | i_size_write(inode, 0); |
224 | spin_unlock(&fc->lock); | 224 | spin_unlock(&fc->lock); |
225 | fuse_invalidate_attr(inode); | 225 | fuse_invalidate_attr(inode); |
226 | if (fc->writeback_cache) | ||
227 | file_update_time(file); | ||
226 | } | 228 | } |
227 | if ((file->f_mode & FMODE_WRITE) && fc->writeback_cache) | 229 | if ((file->f_mode & FMODE_WRITE) && fc->writeback_cache) |
228 | fuse_link_write_file(file); | 230 | fuse_link_write_file(file); |
@@ -232,18 +234,26 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir) | |||
232 | { | 234 | { |
233 | struct fuse_conn *fc = get_fuse_conn(inode); | 235 | struct fuse_conn *fc = get_fuse_conn(inode); |
234 | int err; | 236 | int err; |
237 | bool lock_inode = (file->f_flags & O_TRUNC) && | ||
238 | fc->atomic_o_trunc && | ||
239 | fc->writeback_cache; | ||
235 | 240 | ||
236 | err = generic_file_open(inode, file); | 241 | err = generic_file_open(inode, file); |
237 | if (err) | 242 | if (err) |
238 | return err; | 243 | return err; |
239 | 244 | ||
245 | if (lock_inode) | ||
246 | mutex_lock(&inode->i_mutex); | ||
247 | |||
240 | err = fuse_do_open(fc, get_node_id(inode), file, isdir); | 248 | err = fuse_do_open(fc, get_node_id(inode), file, isdir); |
241 | if (err) | ||
242 | return err; | ||
243 | 249 | ||
244 | fuse_finish_open(inode, file); | 250 | if (!err) |
251 | fuse_finish_open(inode, file); | ||
245 | 252 | ||
246 | return 0; | 253 | if (lock_inode) |
254 | mutex_unlock(&inode->i_mutex); | ||
255 | |||
256 | return err; | ||
247 | } | 257 | } |
248 | 258 | ||
249 | static void fuse_prepare_release(struct fuse_file *ff, int flags, int opcode) | 259 | static void fuse_prepare_release(struct fuse_file *ff, int flags, int opcode) |
@@ -314,10 +324,7 @@ static int fuse_release(struct inode *inode, struct file *file) | |||
314 | 324 | ||
315 | /* see fuse_vma_close() for !writeback_cache case */ | 325 | /* see fuse_vma_close() for !writeback_cache case */ |
316 | if (fc->writeback_cache) | 326 | if (fc->writeback_cache) |
317 | filemap_write_and_wait(file->f_mapping); | 327 | write_inode_now(inode, 1); |
318 | |||
319 | if (test_bit(FUSE_I_MTIME_DIRTY, &get_fuse_inode(inode)->state)) | ||
320 | fuse_flush_mtime(file, true); | ||
321 | 328 | ||
322 | fuse_release_common(file, FUSE_RELEASE); | 329 | fuse_release_common(file, FUSE_RELEASE); |
323 | 330 | ||
@@ -439,7 +446,7 @@ static int fuse_flush(struct file *file, fl_owner_t id) | |||
439 | if (fc->no_flush) | 446 | if (fc->no_flush) |
440 | return 0; | 447 | return 0; |
441 | 448 | ||
442 | err = filemap_write_and_wait(file->f_mapping); | 449 | err = write_inode_now(inode, 1); |
443 | if (err) | 450 | if (err) |
444 | return err; | 451 | return err; |
445 | 452 | ||
@@ -480,13 +487,6 @@ int fuse_fsync_common(struct file *file, loff_t start, loff_t end, | |||
480 | if (is_bad_inode(inode)) | 487 | if (is_bad_inode(inode)) |
481 | return -EIO; | 488 | return -EIO; |
482 | 489 | ||
483 | err = filemap_write_and_wait_range(inode->i_mapping, start, end); | ||
484 | if (err) | ||
485 | return err; | ||
486 | |||
487 | if ((!isdir && fc->no_fsync) || (isdir && fc->no_fsyncdir)) | ||
488 | return 0; | ||
489 | |||
490 | mutex_lock(&inode->i_mutex); | 490 | mutex_lock(&inode->i_mutex); |
491 | 491 | ||
492 | /* | 492 | /* |
@@ -494,17 +494,17 @@ int fuse_fsync_common(struct file *file, loff_t start, loff_t end, | |||
494 | * wait for all outstanding writes, before sending the FSYNC | 494 | * wait for all outstanding writes, before sending the FSYNC |
495 | * request. | 495 | * request. |
496 | */ | 496 | */ |
497 | err = write_inode_now(inode, 0); | 497 | err = filemap_write_and_wait_range(inode->i_mapping, start, end); |
498 | if (err) | 498 | if (err) |
499 | goto out; | 499 | goto out; |
500 | 500 | ||
501 | fuse_sync_writes(inode); | 501 | fuse_sync_writes(inode); |
502 | err = sync_inode_metadata(inode, 1); | ||
503 | if (err) | ||
504 | goto out; | ||
502 | 505 | ||
503 | if (test_bit(FUSE_I_MTIME_DIRTY, &get_fuse_inode(inode)->state)) { | 506 | if ((!isdir && fc->no_fsync) || (isdir && fc->no_fsyncdir)) |
504 | int err = fuse_flush_mtime(file, false); | 507 | goto out; |
505 | if (err) | ||
506 | goto out; | ||
507 | } | ||
508 | 508 | ||
509 | req = fuse_get_req_nopages(fc); | 509 | req = fuse_get_req_nopages(fc); |
510 | if (IS_ERR(req)) { | 510 | if (IS_ERR(req)) { |
@@ -1659,13 +1659,13 @@ static void fuse_writepage_end(struct fuse_conn *fc, struct fuse_req *req) | |||
1659 | fuse_writepage_free(fc, req); | 1659 | fuse_writepage_free(fc, req); |
1660 | } | 1660 | } |
1661 | 1661 | ||
1662 | static struct fuse_file *fuse_write_file_get(struct fuse_conn *fc, | 1662 | static struct fuse_file *__fuse_write_file_get(struct fuse_conn *fc, |
1663 | struct fuse_inode *fi) | 1663 | struct fuse_inode *fi) |
1664 | { | 1664 | { |
1665 | struct fuse_file *ff = NULL; | 1665 | struct fuse_file *ff = NULL; |
1666 | 1666 | ||
1667 | spin_lock(&fc->lock); | 1667 | spin_lock(&fc->lock); |
1668 | if (!WARN_ON(list_empty(&fi->write_files))) { | 1668 | if (!list_empty(&fi->write_files)) { |
1669 | ff = list_entry(fi->write_files.next, struct fuse_file, | 1669 | ff = list_entry(fi->write_files.next, struct fuse_file, |
1670 | write_entry); | 1670 | write_entry); |
1671 | fuse_file_get(ff); | 1671 | fuse_file_get(ff); |
@@ -1675,6 +1675,29 @@ static struct fuse_file *fuse_write_file_get(struct fuse_conn *fc, | |||
1675 | return ff; | 1675 | return ff; |
1676 | } | 1676 | } |
1677 | 1677 | ||
1678 | static struct fuse_file *fuse_write_file_get(struct fuse_conn *fc, | ||
1679 | struct fuse_inode *fi) | ||
1680 | { | ||
1681 | struct fuse_file *ff = __fuse_write_file_get(fc, fi); | ||
1682 | WARN_ON(!ff); | ||
1683 | return ff; | ||
1684 | } | ||
1685 | |||
1686 | int fuse_write_inode(struct inode *inode, struct writeback_control *wbc) | ||
1687 | { | ||
1688 | struct fuse_conn *fc = get_fuse_conn(inode); | ||
1689 | struct fuse_inode *fi = get_fuse_inode(inode); | ||
1690 | struct fuse_file *ff; | ||
1691 | int err; | ||
1692 | |||
1693 | ff = __fuse_write_file_get(fc, fi); | ||
1694 | err = fuse_flush_times(inode, ff); | ||
1695 | if (ff) | ||
1696 | fuse_file_put(ff, 0); | ||
1697 | |||
1698 | return err; | ||
1699 | } | ||
1700 | |||
1678 | static int fuse_writepage_locked(struct page *page) | 1701 | static int fuse_writepage_locked(struct page *page) |
1679 | { | 1702 | { |
1680 | struct address_space *mapping = page->mapping; | 1703 | struct address_space *mapping = page->mapping; |
@@ -2972,6 +2995,9 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset, | |||
2972 | bool lock_inode = !(mode & FALLOC_FL_KEEP_SIZE) || | 2995 | bool lock_inode = !(mode & FALLOC_FL_KEEP_SIZE) || |
2973 | (mode & FALLOC_FL_PUNCH_HOLE); | 2996 | (mode & FALLOC_FL_PUNCH_HOLE); |
2974 | 2997 | ||
2998 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) | ||
2999 | return -EOPNOTSUPP; | ||
3000 | |||
2975 | if (fc->no_fallocate) | 3001 | if (fc->no_fallocate) |
2976 | return -EOPNOTSUPP; | 3002 | return -EOPNOTSUPP; |
2977 | 3003 | ||
@@ -3017,12 +3043,8 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset, | |||
3017 | if (!(mode & FALLOC_FL_KEEP_SIZE)) { | 3043 | if (!(mode & FALLOC_FL_KEEP_SIZE)) { |
3018 | bool changed = fuse_write_update_size(inode, offset + length); | 3044 | bool changed = fuse_write_update_size(inode, offset + length); |
3019 | 3045 | ||
3020 | if (changed && fc->writeback_cache) { | 3046 | if (changed && fc->writeback_cache) |
3021 | struct fuse_inode *fi = get_fuse_inode(inode); | 3047 | file_update_time(file); |
3022 | |||
3023 | inode->i_mtime = current_fs_time(inode->i_sb); | ||
3024 | set_bit(FUSE_I_MTIME_DIRTY, &fi->state); | ||
3025 | } | ||
3026 | } | 3048 | } |
3027 | 3049 | ||
3028 | if (mode & FALLOC_FL_PUNCH_HOLE) | 3050 | if (mode & FALLOC_FL_PUNCH_HOLE) |
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index a257ed8ebee6..7aa5c75e0de1 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
@@ -119,8 +119,6 @@ enum { | |||
119 | FUSE_I_INIT_RDPLUS, | 119 | FUSE_I_INIT_RDPLUS, |
120 | /** An operation changing file size is in progress */ | 120 | /** An operation changing file size is in progress */ |
121 | FUSE_I_SIZE_UNSTABLE, | 121 | FUSE_I_SIZE_UNSTABLE, |
122 | /** i_mtime has been updated locally; a flush to userspace needed */ | ||
123 | FUSE_I_MTIME_DIRTY, | ||
124 | }; | 122 | }; |
125 | 123 | ||
126 | struct fuse_conn; | 124 | struct fuse_conn; |
@@ -544,6 +542,9 @@ struct fuse_conn { | |||
544 | /** Is fallocate not implemented by fs? */ | 542 | /** Is fallocate not implemented by fs? */ |
545 | unsigned no_fallocate:1; | 543 | unsigned no_fallocate:1; |
546 | 544 | ||
545 | /** Is rename with flags implemented by fs? */ | ||
546 | unsigned no_rename2:1; | ||
547 | |||
547 | /** Use enhanced/automatic page cache invalidation. */ | 548 | /** Use enhanced/automatic page cache invalidation. */ |
548 | unsigned auto_inval_data:1; | 549 | unsigned auto_inval_data:1; |
549 | 550 | ||
@@ -725,7 +726,7 @@ int fuse_dev_init(void); | |||
725 | void fuse_dev_cleanup(void); | 726 | void fuse_dev_cleanup(void); |
726 | 727 | ||
727 | int fuse_ctl_init(void); | 728 | int fuse_ctl_init(void); |
728 | void fuse_ctl_cleanup(void); | 729 | void __exit fuse_ctl_cleanup(void); |
729 | 730 | ||
730 | /** | 731 | /** |
731 | * Allocate a request | 732 | * Allocate a request |
@@ -891,7 +892,8 @@ int fuse_dev_release(struct inode *inode, struct file *file); | |||
891 | 892 | ||
892 | bool fuse_write_update_size(struct inode *inode, loff_t pos); | 893 | bool fuse_write_update_size(struct inode *inode, loff_t pos); |
893 | 894 | ||
894 | int fuse_flush_mtime(struct file *file, bool nofail); | 895 | int fuse_flush_times(struct inode *inode, struct fuse_file *ff); |
896 | int fuse_write_inode(struct inode *inode, struct writeback_control *wbc); | ||
895 | 897 | ||
896 | int fuse_do_setattr(struct inode *inode, struct iattr *attr, | 898 | int fuse_do_setattr(struct inode *inode, struct iattr *attr, |
897 | struct file *file); | 899 | struct file *file); |
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 8d611696fcad..754dcf23de8a 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -175,9 +175,9 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr, | |||
175 | if (!fc->writeback_cache || !S_ISREG(inode->i_mode)) { | 175 | if (!fc->writeback_cache || !S_ISREG(inode->i_mode)) { |
176 | inode->i_mtime.tv_sec = attr->mtime; | 176 | inode->i_mtime.tv_sec = attr->mtime; |
177 | inode->i_mtime.tv_nsec = attr->mtimensec; | 177 | inode->i_mtime.tv_nsec = attr->mtimensec; |
178 | inode->i_ctime.tv_sec = attr->ctime; | ||
179 | inode->i_ctime.tv_nsec = attr->ctimensec; | ||
178 | } | 180 | } |
179 | inode->i_ctime.tv_sec = attr->ctime; | ||
180 | inode->i_ctime.tv_nsec = attr->ctimensec; | ||
181 | 181 | ||
182 | if (attr->blksize != 0) | 182 | if (attr->blksize != 0) |
183 | inode->i_blkbits = ilog2(attr->blksize); | 183 | inode->i_blkbits = ilog2(attr->blksize); |
@@ -256,6 +256,8 @@ static void fuse_init_inode(struct inode *inode, struct fuse_attr *attr) | |||
256 | inode->i_size = attr->size; | 256 | inode->i_size = attr->size; |
257 | inode->i_mtime.tv_sec = attr->mtime; | 257 | inode->i_mtime.tv_sec = attr->mtime; |
258 | inode->i_mtime.tv_nsec = attr->mtimensec; | 258 | inode->i_mtime.tv_nsec = attr->mtimensec; |
259 | inode->i_ctime.tv_sec = attr->ctime; | ||
260 | inode->i_ctime.tv_nsec = attr->ctimensec; | ||
259 | if (S_ISREG(inode->i_mode)) { | 261 | if (S_ISREG(inode->i_mode)) { |
260 | fuse_init_common(inode); | 262 | fuse_init_common(inode); |
261 | fuse_init_file_inode(inode); | 263 | fuse_init_file_inode(inode); |
@@ -303,7 +305,7 @@ struct inode *fuse_iget(struct super_block *sb, u64 nodeid, | |||
303 | 305 | ||
304 | if ((inode->i_state & I_NEW)) { | 306 | if ((inode->i_state & I_NEW)) { |
305 | inode->i_flags |= S_NOATIME; | 307 | inode->i_flags |= S_NOATIME; |
306 | if (!fc->writeback_cache || !S_ISREG(inode->i_mode)) | 308 | if (!fc->writeback_cache || !S_ISREG(attr->mode)) |
307 | inode->i_flags |= S_NOCMTIME; | 309 | inode->i_flags |= S_NOCMTIME; |
308 | inode->i_generation = generation; | 310 | inode->i_generation = generation; |
309 | inode->i_data.backing_dev_info = &fc->bdi; | 311 | inode->i_data.backing_dev_info = &fc->bdi; |
@@ -788,6 +790,7 @@ static const struct super_operations fuse_super_operations = { | |||
788 | .alloc_inode = fuse_alloc_inode, | 790 | .alloc_inode = fuse_alloc_inode, |
789 | .destroy_inode = fuse_destroy_inode, | 791 | .destroy_inode = fuse_destroy_inode, |
790 | .evict_inode = fuse_evict_inode, | 792 | .evict_inode = fuse_evict_inode, |
793 | .write_inode = fuse_write_inode, | ||
791 | .drop_inode = generic_delete_inode, | 794 | .drop_inode = generic_delete_inode, |
792 | .remount_fs = fuse_remount_fs, | 795 | .remount_fs = fuse_remount_fs, |
793 | .put_super = fuse_put_super, | 796 | .put_super = fuse_put_super, |
@@ -890,6 +893,11 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) | |||
890 | fc->async_dio = 1; | 893 | fc->async_dio = 1; |
891 | if (arg->flags & FUSE_WRITEBACK_CACHE) | 894 | if (arg->flags & FUSE_WRITEBACK_CACHE) |
892 | fc->writeback_cache = 1; | 895 | fc->writeback_cache = 1; |
896 | if (arg->time_gran && arg->time_gran <= 1000000000) | ||
897 | fc->sb->s_time_gran = arg->time_gran; | ||
898 | else | ||
899 | fc->sb->s_time_gran = 1000000000; | ||
900 | |||
893 | } else { | 901 | } else { |
894 | ra_pages = fc->max_read / PAGE_CACHE_SIZE; | 902 | ra_pages = fc->max_read / PAGE_CACHE_SIZE; |
895 | fc->no_lock = 1; | 903 | fc->no_lock = 1; |
@@ -996,7 +1004,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) | |||
996 | if (sb->s_flags & MS_MANDLOCK) | 1004 | if (sb->s_flags & MS_MANDLOCK) |
997 | goto err; | 1005 | goto err; |
998 | 1006 | ||
999 | sb->s_flags &= ~MS_NOSEC; | 1007 | sb->s_flags &= ~(MS_NOSEC | MS_I_VERSION); |
1000 | 1008 | ||
1001 | if (!parse_fuse_opt((char *) data, &d, is_bdev)) | 1009 | if (!parse_fuse_opt((char *) data, &d, is_bdev)) |
1002 | goto err; | 1010 | goto err; |
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 204027520937..e19d4c0cacae 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -1030,6 +1030,11 @@ static int __init init_hugetlbfs_fs(void) | |||
1030 | int error; | 1030 | int error; |
1031 | int i; | 1031 | int i; |
1032 | 1032 | ||
1033 | if (!hugepages_supported()) { | ||
1034 | pr_info("hugetlbfs: disabling because there are no supported hugepage sizes\n"); | ||
1035 | return -ENOTSUPP; | ||
1036 | } | ||
1037 | |||
1033 | error = bdi_init(&hugetlbfs_backing_dev_info); | 1038 | error = bdi_init(&hugetlbfs_backing_dev_info); |
1034 | if (error) | 1039 | if (error) |
1035 | return error; | 1040 | return error; |
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 78f3403300af..ac127cd008bf 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c | |||
@@ -232,9 +232,6 @@ static int kernfs_link_sibling(struct kernfs_node *kn) | |||
232 | struct rb_node **node = &kn->parent->dir.children.rb_node; | 232 | struct rb_node **node = &kn->parent->dir.children.rb_node; |
233 | struct rb_node *parent = NULL; | 233 | struct rb_node *parent = NULL; |
234 | 234 | ||
235 | if (kernfs_type(kn) == KERNFS_DIR) | ||
236 | kn->parent->dir.subdirs++; | ||
237 | |||
238 | while (*node) { | 235 | while (*node) { |
239 | struct kernfs_node *pos; | 236 | struct kernfs_node *pos; |
240 | int result; | 237 | int result; |
@@ -249,9 +246,15 @@ static int kernfs_link_sibling(struct kernfs_node *kn) | |||
249 | else | 246 | else |
250 | return -EEXIST; | 247 | return -EEXIST; |
251 | } | 248 | } |
249 | |||
252 | /* add new node and rebalance the tree */ | 250 | /* add new node and rebalance the tree */ |
253 | rb_link_node(&kn->rb, parent, node); | 251 | rb_link_node(&kn->rb, parent, node); |
254 | rb_insert_color(&kn->rb, &kn->parent->dir.children); | 252 | rb_insert_color(&kn->rb, &kn->parent->dir.children); |
253 | |||
254 | /* successfully added, account subdir number */ | ||
255 | if (kernfs_type(kn) == KERNFS_DIR) | ||
256 | kn->parent->dir.subdirs++; | ||
257 | |||
255 | return 0; | 258 | return 0; |
256 | } | 259 | } |
257 | 260 | ||
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 8034706a7af8..e01ea4a14a01 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c | |||
@@ -484,6 +484,8 @@ static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma) | |||
484 | 484 | ||
485 | ops = kernfs_ops(of->kn); | 485 | ops = kernfs_ops(of->kn); |
486 | rc = ops->mmap(of, vma); | 486 | rc = ops->mmap(of, vma); |
487 | if (rc) | ||
488 | goto out_put; | ||
487 | 489 | ||
488 | /* | 490 | /* |
489 | * PowerPC's pci_mmap of legacy_mem uses shmem_zero_setup() | 491 | * PowerPC's pci_mmap of legacy_mem uses shmem_zero_setup() |
diff --git a/fs/locks.c b/fs/locks.c index 13fc7a6d380a..e663aeac579e 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -135,7 +135,7 @@ | |||
135 | #define IS_POSIX(fl) (fl->fl_flags & FL_POSIX) | 135 | #define IS_POSIX(fl) (fl->fl_flags & FL_POSIX) |
136 | #define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK) | 136 | #define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK) |
137 | #define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG)) | 137 | #define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG)) |
138 | #define IS_FILE_PVT(fl) (fl->fl_flags & FL_FILE_PVT) | 138 | #define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK) |
139 | 139 | ||
140 | static bool lease_breaking(struct file_lock *fl) | 140 | static bool lease_breaking(struct file_lock *fl) |
141 | { | 141 | { |
@@ -564,7 +564,7 @@ static void __locks_insert_block(struct file_lock *blocker, | |||
564 | BUG_ON(!list_empty(&waiter->fl_block)); | 564 | BUG_ON(!list_empty(&waiter->fl_block)); |
565 | waiter->fl_next = blocker; | 565 | waiter->fl_next = blocker; |
566 | list_add_tail(&waiter->fl_block, &blocker->fl_block); | 566 | list_add_tail(&waiter->fl_block, &blocker->fl_block); |
567 | if (IS_POSIX(blocker) && !IS_FILE_PVT(blocker)) | 567 | if (IS_POSIX(blocker) && !IS_OFDLCK(blocker)) |
568 | locks_insert_global_blocked(waiter); | 568 | locks_insert_global_blocked(waiter); |
569 | } | 569 | } |
570 | 570 | ||
@@ -759,12 +759,12 @@ EXPORT_SYMBOL(posix_test_lock); | |||
759 | * of tasks (such as posix threads) sharing the same open file table. | 759 | * of tasks (such as posix threads) sharing the same open file table. |
760 | * To handle those cases, we just bail out after a few iterations. | 760 | * To handle those cases, we just bail out after a few iterations. |
761 | * | 761 | * |
762 | * For FL_FILE_PVT locks, the owner is the filp, not the files_struct. | 762 | * For FL_OFDLCK locks, the owner is the filp, not the files_struct. |
763 | * Because the owner is not even nominally tied to a thread of | 763 | * Because the owner is not even nominally tied to a thread of |
764 | * execution, the deadlock detection below can't reasonably work well. Just | 764 | * execution, the deadlock detection below can't reasonably work well. Just |
765 | * skip it for those. | 765 | * skip it for those. |
766 | * | 766 | * |
767 | * In principle, we could do a more limited deadlock detection on FL_FILE_PVT | 767 | * In principle, we could do a more limited deadlock detection on FL_OFDLCK |
768 | * locks that just checks for the case where two tasks are attempting to | 768 | * locks that just checks for the case where two tasks are attempting to |
769 | * upgrade from read to write locks on the same inode. | 769 | * upgrade from read to write locks on the same inode. |
770 | */ | 770 | */ |
@@ -791,9 +791,9 @@ static int posix_locks_deadlock(struct file_lock *caller_fl, | |||
791 | 791 | ||
792 | /* | 792 | /* |
793 | * This deadlock detector can't reasonably detect deadlocks with | 793 | * This deadlock detector can't reasonably detect deadlocks with |
794 | * FL_FILE_PVT locks, since they aren't owned by a process, per-se. | 794 | * FL_OFDLCK locks, since they aren't owned by a process, per-se. |
795 | */ | 795 | */ |
796 | if (IS_FILE_PVT(caller_fl)) | 796 | if (IS_OFDLCK(caller_fl)) |
797 | return 0; | 797 | return 0; |
798 | 798 | ||
799 | while ((block_fl = what_owner_is_waiting_for(block_fl))) { | 799 | while ((block_fl = what_owner_is_waiting_for(block_fl))) { |
@@ -1391,11 +1391,10 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) | |||
1391 | 1391 | ||
1392 | restart: | 1392 | restart: |
1393 | break_time = flock->fl_break_time; | 1393 | break_time = flock->fl_break_time; |
1394 | if (break_time != 0) { | 1394 | if (break_time != 0) |
1395 | break_time -= jiffies; | 1395 | break_time -= jiffies; |
1396 | if (break_time == 0) | 1396 | if (break_time == 0) |
1397 | break_time++; | 1397 | break_time++; |
1398 | } | ||
1399 | locks_insert_block(flock, new_fl); | 1398 | locks_insert_block(flock, new_fl); |
1400 | spin_unlock(&inode->i_lock); | 1399 | spin_unlock(&inode->i_lock); |
1401 | error = wait_event_interruptible_timeout(new_fl->fl_wait, | 1400 | error = wait_event_interruptible_timeout(new_fl->fl_wait, |
@@ -1891,7 +1890,7 @@ EXPORT_SYMBOL_GPL(vfs_test_lock); | |||
1891 | 1890 | ||
1892 | static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) | 1891 | static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) |
1893 | { | 1892 | { |
1894 | flock->l_pid = IS_FILE_PVT(fl) ? -1 : fl->fl_pid; | 1893 | flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid; |
1895 | #if BITS_PER_LONG == 32 | 1894 | #if BITS_PER_LONG == 32 |
1896 | /* | 1895 | /* |
1897 | * Make sure we can represent the posix lock via | 1896 | * Make sure we can represent the posix lock via |
@@ -1913,7 +1912,7 @@ static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) | |||
1913 | #if BITS_PER_LONG == 32 | 1912 | #if BITS_PER_LONG == 32 |
1914 | static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl) | 1913 | static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl) |
1915 | { | 1914 | { |
1916 | flock->l_pid = IS_FILE_PVT(fl) ? -1 : fl->fl_pid; | 1915 | flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid; |
1917 | flock->l_start = fl->fl_start; | 1916 | flock->l_start = fl->fl_start; |
1918 | flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : | 1917 | flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : |
1919 | fl->fl_end - fl->fl_start + 1; | 1918 | fl->fl_end - fl->fl_start + 1; |
@@ -1942,13 +1941,13 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock __user *l) | |||
1942 | if (error) | 1941 | if (error) |
1943 | goto out; | 1942 | goto out; |
1944 | 1943 | ||
1945 | if (cmd == F_GETLKP) { | 1944 | if (cmd == F_OFD_GETLK) { |
1946 | error = -EINVAL; | 1945 | error = -EINVAL; |
1947 | if (flock.l_pid != 0) | 1946 | if (flock.l_pid != 0) |
1948 | goto out; | 1947 | goto out; |
1949 | 1948 | ||
1950 | cmd = F_GETLK; | 1949 | cmd = F_GETLK; |
1951 | file_lock.fl_flags |= FL_FILE_PVT; | 1950 | file_lock.fl_flags |= FL_OFDLCK; |
1952 | file_lock.fl_owner = (fl_owner_t)filp; | 1951 | file_lock.fl_owner = (fl_owner_t)filp; |
1953 | } | 1952 | } |
1954 | 1953 | ||
@@ -2074,25 +2073,25 @@ again: | |||
2074 | 2073 | ||
2075 | /* | 2074 | /* |
2076 | * If the cmd is requesting file-private locks, then set the | 2075 | * If the cmd is requesting file-private locks, then set the |
2077 | * FL_FILE_PVT flag and override the owner. | 2076 | * FL_OFDLCK flag and override the owner. |
2078 | */ | 2077 | */ |
2079 | switch (cmd) { | 2078 | switch (cmd) { |
2080 | case F_SETLKP: | 2079 | case F_OFD_SETLK: |
2081 | error = -EINVAL; | 2080 | error = -EINVAL; |
2082 | if (flock.l_pid != 0) | 2081 | if (flock.l_pid != 0) |
2083 | goto out; | 2082 | goto out; |
2084 | 2083 | ||
2085 | cmd = F_SETLK; | 2084 | cmd = F_SETLK; |
2086 | file_lock->fl_flags |= FL_FILE_PVT; | 2085 | file_lock->fl_flags |= FL_OFDLCK; |
2087 | file_lock->fl_owner = (fl_owner_t)filp; | 2086 | file_lock->fl_owner = (fl_owner_t)filp; |
2088 | break; | 2087 | break; |
2089 | case F_SETLKPW: | 2088 | case F_OFD_SETLKW: |
2090 | error = -EINVAL; | 2089 | error = -EINVAL; |
2091 | if (flock.l_pid != 0) | 2090 | if (flock.l_pid != 0) |
2092 | goto out; | 2091 | goto out; |
2093 | 2092 | ||
2094 | cmd = F_SETLKW; | 2093 | cmd = F_SETLKW; |
2095 | file_lock->fl_flags |= FL_FILE_PVT; | 2094 | file_lock->fl_flags |= FL_OFDLCK; |
2096 | file_lock->fl_owner = (fl_owner_t)filp; | 2095 | file_lock->fl_owner = (fl_owner_t)filp; |
2097 | /* Fallthrough */ | 2096 | /* Fallthrough */ |
2098 | case F_SETLKW: | 2097 | case F_SETLKW: |
@@ -2144,13 +2143,13 @@ int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 __user *l) | |||
2144 | if (error) | 2143 | if (error) |
2145 | goto out; | 2144 | goto out; |
2146 | 2145 | ||
2147 | if (cmd == F_GETLKP) { | 2146 | if (cmd == F_OFD_GETLK) { |
2148 | error = -EINVAL; | 2147 | error = -EINVAL; |
2149 | if (flock.l_pid != 0) | 2148 | if (flock.l_pid != 0) |
2150 | goto out; | 2149 | goto out; |
2151 | 2150 | ||
2152 | cmd = F_GETLK64; | 2151 | cmd = F_GETLK64; |
2153 | file_lock.fl_flags |= FL_FILE_PVT; | 2152 | file_lock.fl_flags |= FL_OFDLCK; |
2154 | file_lock.fl_owner = (fl_owner_t)filp; | 2153 | file_lock.fl_owner = (fl_owner_t)filp; |
2155 | } | 2154 | } |
2156 | 2155 | ||
@@ -2209,25 +2208,25 @@ again: | |||
2209 | 2208 | ||
2210 | /* | 2209 | /* |
2211 | * If the cmd is requesting file-private locks, then set the | 2210 | * If the cmd is requesting file-private locks, then set the |
2212 | * FL_FILE_PVT flag and override the owner. | 2211 | * FL_OFDLCK flag and override the owner. |
2213 | */ | 2212 | */ |
2214 | switch (cmd) { | 2213 | switch (cmd) { |
2215 | case F_SETLKP: | 2214 | case F_OFD_SETLK: |
2216 | error = -EINVAL; | 2215 | error = -EINVAL; |
2217 | if (flock.l_pid != 0) | 2216 | if (flock.l_pid != 0) |
2218 | goto out; | 2217 | goto out; |
2219 | 2218 | ||
2220 | cmd = F_SETLK64; | 2219 | cmd = F_SETLK64; |
2221 | file_lock->fl_flags |= FL_FILE_PVT; | 2220 | file_lock->fl_flags |= FL_OFDLCK; |
2222 | file_lock->fl_owner = (fl_owner_t)filp; | 2221 | file_lock->fl_owner = (fl_owner_t)filp; |
2223 | break; | 2222 | break; |
2224 | case F_SETLKPW: | 2223 | case F_OFD_SETLKW: |
2225 | error = -EINVAL; | 2224 | error = -EINVAL; |
2226 | if (flock.l_pid != 0) | 2225 | if (flock.l_pid != 0) |
2227 | goto out; | 2226 | goto out; |
2228 | 2227 | ||
2229 | cmd = F_SETLKW64; | 2228 | cmd = F_SETLKW64; |
2230 | file_lock->fl_flags |= FL_FILE_PVT; | 2229 | file_lock->fl_flags |= FL_OFDLCK; |
2231 | file_lock->fl_owner = (fl_owner_t)filp; | 2230 | file_lock->fl_owner = (fl_owner_t)filp; |
2232 | /* Fallthrough */ | 2231 | /* Fallthrough */ |
2233 | case F_SETLKW64: | 2232 | case F_SETLKW64: |
@@ -2413,8 +2412,8 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, | |||
2413 | if (IS_POSIX(fl)) { | 2412 | if (IS_POSIX(fl)) { |
2414 | if (fl->fl_flags & FL_ACCESS) | 2413 | if (fl->fl_flags & FL_ACCESS) |
2415 | seq_printf(f, "ACCESS"); | 2414 | seq_printf(f, "ACCESS"); |
2416 | else if (IS_FILE_PVT(fl)) | 2415 | else if (IS_OFDLCK(fl)) |
2417 | seq_printf(f, "FLPVT "); | 2416 | seq_printf(f, "OFDLCK"); |
2418 | else | 2417 | else |
2419 | seq_printf(f, "POSIX "); | 2418 | seq_printf(f, "POSIX "); |
2420 | 2419 | ||
diff --git a/fs/namei.c b/fs/namei.c index c6157c894fce..80168273396b 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -1542,7 +1542,7 @@ static inline int walk_component(struct nameidata *nd, struct path *path, | |||
1542 | inode = path->dentry->d_inode; | 1542 | inode = path->dentry->d_inode; |
1543 | } | 1543 | } |
1544 | err = -ENOENT; | 1544 | err = -ENOENT; |
1545 | if (!inode) | 1545 | if (!inode || d_is_negative(path->dentry)) |
1546 | goto out_path_put; | 1546 | goto out_path_put; |
1547 | 1547 | ||
1548 | if (should_follow_link(path->dentry, follow)) { | 1548 | if (should_follow_link(path->dentry, follow)) { |
@@ -2249,7 +2249,7 @@ mountpoint_last(struct nameidata *nd, struct path *path) | |||
2249 | mutex_unlock(&dir->d_inode->i_mutex); | 2249 | mutex_unlock(&dir->d_inode->i_mutex); |
2250 | 2250 | ||
2251 | done: | 2251 | done: |
2252 | if (!dentry->d_inode) { | 2252 | if (!dentry->d_inode || d_is_negative(dentry)) { |
2253 | error = -ENOENT; | 2253 | error = -ENOENT; |
2254 | dput(dentry); | 2254 | dput(dentry); |
2255 | goto out; | 2255 | goto out; |
@@ -2994,7 +2994,7 @@ retry_lookup: | |||
2994 | finish_lookup: | 2994 | finish_lookup: |
2995 | /* we _can_ be in RCU mode here */ | 2995 | /* we _can_ be in RCU mode here */ |
2996 | error = -ENOENT; | 2996 | error = -ENOENT; |
2997 | if (d_is_negative(path->dentry)) { | 2997 | if (!inode || d_is_negative(path->dentry)) { |
2998 | path_to_nameidata(path, nd); | 2998 | path_to_nameidata(path, nd); |
2999 | goto out; | 2999 | goto out; |
3000 | } | 3000 | } |
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 39c8ef875f91..2c73cae9899d 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c | |||
@@ -654,9 +654,11 @@ static struct rpc_clnt *create_backchannel_client(struct rpc_create_args *args) | |||
654 | 654 | ||
655 | static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses) | 655 | static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses) |
656 | { | 656 | { |
657 | int maxtime = max_cb_time(clp->net); | ||
657 | struct rpc_timeout timeparms = { | 658 | struct rpc_timeout timeparms = { |
658 | .to_initval = max_cb_time(clp->net), | 659 | .to_initval = maxtime, |
659 | .to_retries = 0, | 660 | .to_retries = 0, |
661 | .to_maxval = maxtime, | ||
660 | }; | 662 | }; |
661 | struct rpc_create_args args = { | 663 | struct rpc_create_args args = { |
662 | .net = clp->net, | 664 | .net = clp->net, |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 2723c1badd01..18881f34737a 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -3627,14 +3627,6 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op) | |||
3627 | /* nfsd4_check_resp_size guarantees enough room for error status */ | 3627 | /* nfsd4_check_resp_size guarantees enough room for error status */ |
3628 | if (!op->status) | 3628 | if (!op->status) |
3629 | op->status = nfsd4_check_resp_size(resp, 0); | 3629 | op->status = nfsd4_check_resp_size(resp, 0); |
3630 | if (op->status == nfserr_resource && nfsd4_has_session(&resp->cstate)) { | ||
3631 | struct nfsd4_slot *slot = resp->cstate.slot; | ||
3632 | |||
3633 | if (slot->sl_flags & NFSD4_SLOT_CACHETHIS) | ||
3634 | op->status = nfserr_rep_too_big_to_cache; | ||
3635 | else | ||
3636 | op->status = nfserr_rep_too_big; | ||
3637 | } | ||
3638 | if (so) { | 3630 | if (so) { |
3639 | so->so_replay.rp_status = op->status; | 3631 | so->so_replay.rp_status = op->status; |
3640 | so->so_replay.rp_buflen = (char *)resp->p - (char *)(statp+1); | 3632 | so->so_replay.rp_buflen = (char *)resp->p - (char *)(statp+1); |
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 4e565c814309..732648b270dc 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c | |||
@@ -698,6 +698,8 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags) | |||
698 | } | 698 | } |
699 | group->overflow_event = &oevent->fse; | 699 | group->overflow_event = &oevent->fse; |
700 | 700 | ||
701 | if (force_o_largefile()) | ||
702 | event_f_flags |= O_LARGEFILE; | ||
701 | group->fanotify_data.f_flags = event_f_flags; | 703 | group->fanotify_data.f_flags = event_f_flags; |
702 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS | 704 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS |
703 | spin_lock_init(&group->fanotify_data.access_lock); | 705 | spin_lock_init(&group->fanotify_data.access_lock); |
diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 9e363e41dacc..0855f772cd41 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c | |||
@@ -246,6 +246,12 @@ posix_acl_equiv_mode(const struct posix_acl *acl, umode_t *mode_p) | |||
246 | umode_t mode = 0; | 246 | umode_t mode = 0; |
247 | int not_equiv = 0; | 247 | int not_equiv = 0; |
248 | 248 | ||
249 | /* | ||
250 | * A null ACL can always be presented as mode bits. | ||
251 | */ | ||
252 | if (!acl) | ||
253 | return 0; | ||
254 | |||
249 | FOREACH_ACL_ENTRY(pa, acl, pe) { | 255 | FOREACH_ACL_ENTRY(pa, acl, pe) { |
250 | switch (pa->e_tag) { | 256 | switch (pa->e_tag) { |
251 | case ACL_USER_OBJ: | 257 | case ACL_USER_OBJ: |
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index a1266089eca1..a81c7b556896 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -1556,7 +1556,7 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1556 | if (c->space_fixup) { | 1556 | if (c->space_fixup) { |
1557 | err = ubifs_fixup_free_space(c); | 1557 | err = ubifs_fixup_free_space(c); |
1558 | if (err) | 1558 | if (err) |
1559 | return err; | 1559 | goto out; |
1560 | } | 1560 | } |
1561 | 1561 | ||
1562 | err = check_free_space(c); | 1562 | err = check_free_space(c); |