diff options
195 files changed, 1449 insertions, 1230 deletions
diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index f1b87d8aa2da..46f3bb7a02f5 100644 --- a/Documentation/filesystems/porting +++ b/Documentation/filesystems/porting | |||
@@ -525,3 +525,56 @@ in your dentry operations instead. | |||
525 | set_delayed_call() where it used to set *cookie. | 525 | set_delayed_call() where it used to set *cookie. |
526 | ->put_link() is gone - just give the destructor to set_delayed_call() | 526 | ->put_link() is gone - just give the destructor to set_delayed_call() |
527 | in ->get_link(). | 527 | in ->get_link(). |
528 | -- | ||
529 | [mandatory] | ||
530 | ->getxattr() and xattr_handler.get() get dentry and inode passed separately. | ||
531 | dentry might be yet to be attached to inode, so do _not_ use its ->d_inode | ||
532 | in the instances. Rationale: !@#!@# security_d_instantiate() needs to be | ||
533 | called before we attach dentry to inode. | ||
534 | -- | ||
535 | [mandatory] | ||
536 | symlinks are no longer the only inodes that do *not* have i_bdev/i_cdev/ | ||
537 | i_pipe/i_link union zeroed out at inode eviction. As the result, you can't | ||
538 | assume that non-NULL value in ->i_nlink at ->destroy_inode() implies that | ||
539 | it's a symlink. Checking ->i_mode is really needed now. In-tree we had | ||
540 | to fix shmem_destroy_callback() that used to take that kind of shortcut; | ||
541 | watch out, since that shortcut is no longer valid. | ||
542 | -- | ||
543 | [mandatory] | ||
544 | ->i_mutex is replaced with ->i_rwsem now. inode_lock() et.al. work as | ||
545 | they used to - they just take it exclusive. However, ->lookup() may be | ||
546 | called with parent locked shared. Its instances must not | ||
547 | * use d_instantiate) and d_rehash() separately - use d_add() or | ||
548 | d_splice_alias() instead. | ||
549 | * use d_rehash() alone - call d_add(new_dentry, NULL) instead. | ||
550 | * in the unlikely case when (read-only) access to filesystem | ||
551 | data structures needs exclusion for some reason, arrange it | ||
552 | yourself. None of the in-tree filesystems needed that. | ||
553 | * rely on ->d_parent and ->d_name not changing after dentry has | ||
554 | been fed to d_add() or d_splice_alias(). Again, none of the | ||
555 | in-tree instances relied upon that. | ||
556 | We are guaranteed that lookups of the same name in the same directory | ||
557 | will not happen in parallel ("same" in the sense of your ->d_compare()). | ||
558 | Lookups on different names in the same directory can and do happen in | ||
559 | parallel now. | ||
560 | -- | ||
561 | [recommended] | ||
562 | ->iterate_shared() is added; it's a parallel variant of ->iterate(). | ||
563 | Exclusion on struct file level is still provided (as well as that | ||
564 | between it and lseek on the same struct file), but if your directory | ||
565 | has been opened several times, you can get these called in parallel. | ||
566 | Exclusion between that method and all directory-modifying ones is | ||
567 | still provided, of course. | ||
568 | |||
569 | Often enough ->iterate() can serve as ->iterate_shared() without any | ||
570 | changes - it is a read-only operation, after all. If you have any | ||
571 | per-inode or per-dentry in-core data structures modified by ->iterate(), | ||
572 | you might need something to serialize the access to them. If you | ||
573 | do dcache pre-seeding, you'll need to switch to d_alloc_parallel() for | ||
574 | that; look for in-tree examples. | ||
575 | |||
576 | Old method is only used if the new one is absent; eventually it will | ||
577 | be removed. Switch while you still can; the old one won't stay. | ||
578 | -- | ||
579 | [mandatory] | ||
580 | ->atomic_open() calls without O_CREAT may happen in parallel. | ||
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 6cc08166ff00..ffb93f499c83 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c | |||
@@ -147,7 +147,7 @@ SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd, | |||
147 | long __user *, basep) | 147 | long __user *, basep) |
148 | { | 148 | { |
149 | int error; | 149 | int error; |
150 | struct fd arg = fdget(fd); | 150 | struct fd arg = fdget_pos(fd); |
151 | struct osf_dirent_callback buf = { | 151 | struct osf_dirent_callback buf = { |
152 | .ctx.actor = osf_filldir, | 152 | .ctx.actor = osf_filldir, |
153 | .dirent = dirent, | 153 | .dirent = dirent, |
@@ -164,7 +164,7 @@ SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd, | |||
164 | if (count != buf.count) | 164 | if (count != buf.count) |
165 | error = count - buf.count; | 165 | error = count - buf.count; |
166 | 166 | ||
167 | fdput(arg); | 167 | fdput_pos(arg); |
168 | return error; | 168 | return error; |
169 | } | 169 | } |
170 | 170 | ||
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c index 6ca5f0525e57..5be15cff758d 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c | |||
@@ -238,7 +238,7 @@ const struct file_operations spufs_context_fops = { | |||
238 | .release = spufs_dir_close, | 238 | .release = spufs_dir_close, |
239 | .llseek = dcache_dir_lseek, | 239 | .llseek = dcache_dir_lseek, |
240 | .read = generic_read_dir, | 240 | .read = generic_read_dir, |
241 | .iterate = dcache_readdir, | 241 | .iterate_shared = dcache_readdir, |
242 | .fsync = noop_fsync, | 242 | .fsync = noop_fsync, |
243 | }; | 243 | }; |
244 | EXPORT_SYMBOL_GPL(spufs_context_fops); | 244 | EXPORT_SYMBOL_GPL(spufs_context_fops); |
diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index e4c82883e580..7a0a67f3c4e7 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c | |||
@@ -1865,7 +1865,6 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin) | |||
1865 | int api32 = ll_need_32bit_api(sbi); | 1865 | int api32 = ll_need_32bit_api(sbi); |
1866 | loff_t ret = -EINVAL; | 1866 | loff_t ret = -EINVAL; |
1867 | 1867 | ||
1868 | inode_lock(inode); | ||
1869 | switch (origin) { | 1868 | switch (origin) { |
1870 | case SEEK_SET: | 1869 | case SEEK_SET: |
1871 | break; | 1870 | break; |
@@ -1903,7 +1902,6 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin) | |||
1903 | goto out; | 1902 | goto out; |
1904 | 1903 | ||
1905 | out: | 1904 | out: |
1906 | inode_unlock(inode); | ||
1907 | return ret; | 1905 | return ret; |
1908 | } | 1906 | } |
1909 | 1907 | ||
@@ -1922,7 +1920,7 @@ const struct file_operations ll_dir_operations = { | |||
1922 | .open = ll_dir_open, | 1920 | .open = ll_dir_open, |
1923 | .release = ll_dir_release, | 1921 | .release = ll_dir_release, |
1924 | .read = generic_read_dir, | 1922 | .read = generic_read_dir, |
1925 | .iterate = ll_readdir, | 1923 | .iterate_shared = ll_readdir, |
1926 | .unlocked_ioctl = ll_dir_ioctl, | 1924 | .unlocked_ioctl = ll_dir_ioctl, |
1927 | .fsync = ll_fsync, | 1925 | .fsync = ll_fsync, |
1928 | }; | 1926 | }; |
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index e3c0f1dd4d31..65a6acec663b 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h | |||
@@ -1042,8 +1042,8 @@ static inline __u64 ll_file_maxbytes(struct inode *inode) | |||
1042 | /* llite/xattr.c */ | 1042 | /* llite/xattr.c */ |
1043 | int ll_setxattr(struct dentry *dentry, const char *name, | 1043 | int ll_setxattr(struct dentry *dentry, const char *name, |
1044 | const void *value, size_t size, int flags); | 1044 | const void *value, size_t size, int flags); |
1045 | ssize_t ll_getxattr(struct dentry *dentry, const char *name, | 1045 | ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode, |
1046 | void *buffer, size_t size); | 1046 | const char *name, void *buffer, size_t size); |
1047 | ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size); | 1047 | ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size); |
1048 | int ll_removexattr(struct dentry *dentry, const char *name); | 1048 | int ll_removexattr(struct dentry *dentry, const char *name); |
1049 | 1049 | ||
diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index b68dcc921ca2..c671f221c28c 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c | |||
@@ -451,11 +451,9 @@ out: | |||
451 | return rc; | 451 | return rc; |
452 | } | 452 | } |
453 | 453 | ||
454 | ssize_t ll_getxattr(struct dentry *dentry, const char *name, | 454 | ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode, |
455 | void *buffer, size_t size) | 455 | const char *name, void *buffer, size_t size) |
456 | { | 456 | { |
457 | struct inode *inode = d_inode(dentry); | ||
458 | |||
459 | LASSERT(inode); | 457 | LASSERT(inode); |
460 | LASSERT(name); | 458 | LASSERT(name); |
461 | 459 | ||
diff --git a/fs/9p/acl.c b/fs/9p/acl.c index 9da967f38387..eb3589edf485 100644 --- a/fs/9p/acl.c +++ b/fs/9p/acl.c | |||
@@ -93,7 +93,7 @@ static struct posix_acl *v9fs_get_cached_acl(struct inode *inode, int type) | |||
93 | * instantiating the inode (v9fs_inode_from_fid) | 93 | * instantiating the inode (v9fs_inode_from_fid) |
94 | */ | 94 | */ |
95 | acl = get_cached_acl(inode, type); | 95 | acl = get_cached_acl(inode, type); |
96 | BUG_ON(acl == ACL_NOT_CACHED); | 96 | BUG_ON(is_uncached_acl(acl)); |
97 | return acl; | 97 | return acl; |
98 | } | 98 | } |
99 | 99 | ||
@@ -213,8 +213,8 @@ int v9fs_acl_mode(struct inode *dir, umode_t *modep, | |||
213 | } | 213 | } |
214 | 214 | ||
215 | static int v9fs_xattr_get_acl(const struct xattr_handler *handler, | 215 | static int v9fs_xattr_get_acl(const struct xattr_handler *handler, |
216 | struct dentry *dentry, const char *name, | 216 | struct dentry *dentry, struct inode *inode, |
217 | void *buffer, size_t size) | 217 | const char *name, void *buffer, size_t size) |
218 | { | 218 | { |
219 | struct v9fs_session_info *v9ses; | 219 | struct v9fs_session_info *v9ses; |
220 | struct posix_acl *acl; | 220 | struct posix_acl *acl; |
@@ -227,7 +227,7 @@ static int v9fs_xattr_get_acl(const struct xattr_handler *handler, | |||
227 | if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) | 227 | if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) |
228 | return v9fs_xattr_get(dentry, handler->name, buffer, size); | 228 | return v9fs_xattr_get(dentry, handler->name, buffer, size); |
229 | 229 | ||
230 | acl = v9fs_get_cached_acl(d_inode(dentry), handler->flags); | 230 | acl = v9fs_get_cached_acl(inode, handler->flags); |
231 | if (IS_ERR(acl)) | 231 | if (IS_ERR(acl)) |
232 | return PTR_ERR(acl); | 232 | return PTR_ERR(acl); |
233 | if (acl == NULL) | 233 | if (acl == NULL) |
diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c index 5cc00e56206e..b0405d6aac85 100644 --- a/fs/9p/vfs_dir.c +++ b/fs/9p/vfs_dir.c | |||
@@ -246,7 +246,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp) | |||
246 | const struct file_operations v9fs_dir_operations = { | 246 | const struct file_operations v9fs_dir_operations = { |
247 | .read = generic_read_dir, | 247 | .read = generic_read_dir, |
248 | .llseek = generic_file_llseek, | 248 | .llseek = generic_file_llseek, |
249 | .iterate = v9fs_dir_readdir, | 249 | .iterate_shared = v9fs_dir_readdir, |
250 | .open = v9fs_file_open, | 250 | .open = v9fs_file_open, |
251 | .release = v9fs_dir_release, | 251 | .release = v9fs_dir_release, |
252 | }; | 252 | }; |
@@ -254,7 +254,7 @@ const struct file_operations v9fs_dir_operations = { | |||
254 | const struct file_operations v9fs_dir_operations_dotl = { | 254 | const struct file_operations v9fs_dir_operations_dotl = { |
255 | .read = generic_read_dir, | 255 | .read = generic_read_dir, |
256 | .llseek = generic_file_llseek, | 256 | .llseek = generic_file_llseek, |
257 | .iterate = v9fs_dir_readdir_dotl, | 257 | .iterate_shared = v9fs_dir_readdir_dotl, |
258 | .open = v9fs_file_open, | 258 | .open = v9fs_file_open, |
259 | .release = v9fs_dir_release, | 259 | .release = v9fs_dir_release, |
260 | .fsync = v9fs_file_fsync_dotl, | 260 | .fsync = v9fs_file_fsync_dotl, |
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 3a08b3e6ff1d..f4645c515262 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -1071,7 +1071,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
1071 | if (IS_ERR(st)) | 1071 | if (IS_ERR(st)) |
1072 | return PTR_ERR(st); | 1072 | return PTR_ERR(st); |
1073 | 1073 | ||
1074 | v9fs_stat2inode(st, d_inode(dentry), d_inode(dentry)->i_sb); | 1074 | v9fs_stat2inode(st, d_inode(dentry), dentry->d_sb); |
1075 | generic_fillattr(d_inode(dentry), stat); | 1075 | generic_fillattr(d_inode(dentry), stat); |
1076 | 1076 | ||
1077 | p9stat_free(st); | 1077 | p9stat_free(st); |
diff --git a/fs/9p/xattr.c b/fs/9p/xattr.c index 9dd9b47a6c1a..18c62bae9591 100644 --- a/fs/9p/xattr.c +++ b/fs/9p/xattr.c | |||
@@ -138,8 +138,8 @@ ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) | |||
138 | } | 138 | } |
139 | 139 | ||
140 | static int v9fs_xattr_handler_get(const struct xattr_handler *handler, | 140 | static int v9fs_xattr_handler_get(const struct xattr_handler *handler, |
141 | struct dentry *dentry, const char *name, | 141 | struct dentry *dentry, struct inode *inode, |
142 | void *buffer, size_t size) | 142 | const char *name, void *buffer, size_t size) |
143 | { | 143 | { |
144 | const char *full_name = xattr_full_name(handler, name); | 144 | const char *full_name = xattr_full_name(handler, name); |
145 | 145 | ||
diff --git a/fs/affs/dir.c b/fs/affs/dir.c index ac4f318aafba..f1e7294381c5 100644 --- a/fs/affs/dir.c +++ b/fs/affs/dir.c | |||
@@ -20,7 +20,7 @@ static int affs_readdir(struct file *, struct dir_context *); | |||
20 | const struct file_operations affs_dir_operations = { | 20 | const struct file_operations affs_dir_operations = { |
21 | .read = generic_read_dir, | 21 | .read = generic_read_dir, |
22 | .llseek = generic_file_llseek, | 22 | .llseek = generic_file_llseek, |
23 | .iterate = affs_readdir, | 23 | .iterate_shared = affs_readdir, |
24 | .fsync = affs_file_fsync, | 24 | .fsync = affs_file_fsync, |
25 | }; | 25 | }; |
26 | 26 | ||
diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 5fda2bc53cd7..eba541004d90 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c | |||
@@ -43,7 +43,7 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
43 | const struct file_operations afs_dir_file_operations = { | 43 | const struct file_operations afs_dir_file_operations = { |
44 | .open = afs_dir_open, | 44 | .open = afs_dir_open, |
45 | .release = afs_release, | 45 | .release = afs_release, |
46 | .iterate = afs_readdir, | 46 | .iterate_shared = afs_readdir, |
47 | .lock = afs_lock, | 47 | .lock = afs_lock, |
48 | .llseek = generic_file_llseek, | 48 | .llseek = generic_file_llseek, |
49 | }; | 49 | }; |
@@ -128,7 +128,7 @@ struct afs_lookup_cookie { | |||
128 | /* | 128 | /* |
129 | * check that a directory page is valid | 129 | * check that a directory page is valid |
130 | */ | 130 | */ |
131 | static inline void afs_dir_check_page(struct inode *dir, struct page *page) | 131 | static inline bool afs_dir_check_page(struct inode *dir, struct page *page) |
132 | { | 132 | { |
133 | struct afs_dir_page *dbuf; | 133 | struct afs_dir_page *dbuf; |
134 | loff_t latter; | 134 | loff_t latter; |
@@ -168,11 +168,11 @@ static inline void afs_dir_check_page(struct inode *dir, struct page *page) | |||
168 | } | 168 | } |
169 | 169 | ||
170 | SetPageChecked(page); | 170 | SetPageChecked(page); |
171 | return; | 171 | return true; |
172 | 172 | ||
173 | error: | 173 | error: |
174 | SetPageChecked(page); | ||
175 | SetPageError(page); | 174 | SetPageError(page); |
175 | return false; | ||
176 | } | 176 | } |
177 | 177 | ||
178 | /* | 178 | /* |
@@ -196,10 +196,10 @@ static struct page *afs_dir_get_page(struct inode *dir, unsigned long index, | |||
196 | page = read_cache_page(dir->i_mapping, index, afs_page_filler, key); | 196 | page = read_cache_page(dir->i_mapping, index, afs_page_filler, key); |
197 | if (!IS_ERR(page)) { | 197 | if (!IS_ERR(page)) { |
198 | kmap(page); | 198 | kmap(page); |
199 | if (!PageChecked(page)) | 199 | if (unlikely(!PageChecked(page))) { |
200 | afs_dir_check_page(dir, page); | 200 | if (PageError(page) || !afs_dir_check_page(dir, page)) |
201 | if (PageError(page)) | 201 | goto fail; |
202 | goto fail; | 202 | } |
203 | } | 203 | } |
204 | return page; | 204 | return page; |
205 | 205 | ||
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index 7ab923940d18..78bd80298528 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c | |||
@@ -39,7 +39,7 @@ const struct file_operations autofs4_root_operations = { | |||
39 | .open = dcache_dir_open, | 39 | .open = dcache_dir_open, |
40 | .release = dcache_dir_close, | 40 | .release = dcache_dir_close, |
41 | .read = generic_read_dir, | 41 | .read = generic_read_dir, |
42 | .iterate = dcache_readdir, | 42 | .iterate_shared = dcache_readdir, |
43 | .llseek = dcache_dir_lseek, | 43 | .llseek = dcache_dir_lseek, |
44 | .unlocked_ioctl = autofs4_root_ioctl, | 44 | .unlocked_ioctl = autofs4_root_ioctl, |
45 | #ifdef CONFIG_COMPAT | 45 | #ifdef CONFIG_COMPAT |
@@ -51,7 +51,7 @@ const struct file_operations autofs4_dir_operations = { | |||
51 | .open = autofs4_dir_open, | 51 | .open = autofs4_dir_open, |
52 | .release = dcache_dir_close, | 52 | .release = dcache_dir_close, |
53 | .read = generic_read_dir, | 53 | .read = generic_read_dir, |
54 | .iterate = dcache_readdir, | 54 | .iterate_shared = dcache_readdir, |
55 | .llseek = dcache_dir_lseek, | 55 | .llseek = dcache_dir_lseek, |
56 | }; | 56 | }; |
57 | 57 | ||
diff --git a/fs/bad_inode.c b/fs/bad_inode.c index 103f5d7c3083..72e35b721608 100644 --- a/fs/bad_inode.c +++ b/fs/bad_inode.c | |||
@@ -106,8 +106,8 @@ static int bad_inode_setxattr(struct dentry *dentry, const char *name, | |||
106 | return -EIO; | 106 | return -EIO; |
107 | } | 107 | } |
108 | 108 | ||
109 | static ssize_t bad_inode_getxattr(struct dentry *dentry, const char *name, | 109 | static ssize_t bad_inode_getxattr(struct dentry *dentry, struct inode *inode, |
110 | void *buffer, size_t size) | 110 | const char *name, void *buffer, size_t size) |
111 | { | 111 | { |
112 | return -EIO; | 112 | return -EIO; |
113 | } | 113 | } |
diff --git a/fs/befs/befs.h b/fs/befs/befs.h index 35d19e8731e3..e0f59263a96d 100644 --- a/fs/befs/befs.h +++ b/fs/befs/befs.h | |||
@@ -116,7 +116,7 @@ BEFS_I(const struct inode *inode) | |||
116 | } | 116 | } |
117 | 117 | ||
118 | static inline befs_blocknr_t | 118 | static inline befs_blocknr_t |
119 | iaddr2blockno(struct super_block *sb, befs_inode_addr * iaddr) | 119 | iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr) |
120 | { | 120 | { |
121 | return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) + | 121 | return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) + |
122 | iaddr->start); | 122 | iaddr->start); |
@@ -141,7 +141,7 @@ befs_iaddrs_per_block(struct super_block *sb) | |||
141 | } | 141 | } |
142 | 142 | ||
143 | static inline int | 143 | static inline int |
144 | befs_iaddr_is_empty(befs_inode_addr * iaddr) | 144 | befs_iaddr_is_empty(const befs_inode_addr *iaddr) |
145 | { | 145 | { |
146 | return (!iaddr->allocation_group) && (!iaddr->start) && (!iaddr->len); | 146 | return (!iaddr->allocation_group) && (!iaddr->start) && (!iaddr->len); |
147 | } | 147 | } |
diff --git a/fs/befs/btree.c b/fs/befs/btree.c index 22c166280883..307645f9e284 100644 --- a/fs/befs/btree.c +++ b/fs/befs/btree.c | |||
@@ -88,15 +88,15 @@ struct befs_btree_node { | |||
88 | static const befs_off_t befs_bt_inval = 0xffffffffffffffffULL; | 88 | static const befs_off_t befs_bt_inval = 0xffffffffffffffffULL; |
89 | 89 | ||
90 | /* local functions */ | 90 | /* local functions */ |
91 | static int befs_btree_seekleaf(struct super_block *sb, befs_data_stream * ds, | 91 | static int befs_btree_seekleaf(struct super_block *sb, const befs_data_stream *ds, |
92 | befs_btree_super * bt_super, | 92 | befs_btree_super * bt_super, |
93 | struct befs_btree_node *this_node, | 93 | struct befs_btree_node *this_node, |
94 | befs_off_t * node_off); | 94 | befs_off_t * node_off); |
95 | 95 | ||
96 | static int befs_bt_read_super(struct super_block *sb, befs_data_stream * ds, | 96 | static int befs_bt_read_super(struct super_block *sb, const befs_data_stream *ds, |
97 | befs_btree_super * sup); | 97 | befs_btree_super * sup); |
98 | 98 | ||
99 | static int befs_bt_read_node(struct super_block *sb, befs_data_stream * ds, | 99 | static int befs_bt_read_node(struct super_block *sb, const befs_data_stream *ds, |
100 | struct befs_btree_node *node, | 100 | struct befs_btree_node *node, |
101 | befs_off_t node_off); | 101 | befs_off_t node_off); |
102 | 102 | ||
@@ -134,7 +134,7 @@ static int befs_compare_strings(const void *key1, int keylen1, | |||
134 | * On failure, BEFS_ERR is returned. | 134 | * On failure, BEFS_ERR is returned. |
135 | */ | 135 | */ |
136 | static int | 136 | static int |
137 | befs_bt_read_super(struct super_block *sb, befs_data_stream * ds, | 137 | befs_bt_read_super(struct super_block *sb, const befs_data_stream *ds, |
138 | befs_btree_super * sup) | 138 | befs_btree_super * sup) |
139 | { | 139 | { |
140 | struct buffer_head *bh; | 140 | struct buffer_head *bh; |
@@ -193,7 +193,7 @@ befs_bt_read_super(struct super_block *sb, befs_data_stream * ds, | |||
193 | */ | 193 | */ |
194 | 194 | ||
195 | static int | 195 | static int |
196 | befs_bt_read_node(struct super_block *sb, befs_data_stream * ds, | 196 | befs_bt_read_node(struct super_block *sb, const befs_data_stream *ds, |
197 | struct befs_btree_node *node, befs_off_t node_off) | 197 | struct befs_btree_node *node, befs_off_t node_off) |
198 | { | 198 | { |
199 | uint off = 0; | 199 | uint off = 0; |
@@ -247,7 +247,7 @@ befs_bt_read_node(struct super_block *sb, befs_data_stream * ds, | |||
247 | * actuall value stored with the key. | 247 | * actuall value stored with the key. |
248 | */ | 248 | */ |
249 | int | 249 | int |
250 | befs_btree_find(struct super_block *sb, befs_data_stream * ds, | 250 | befs_btree_find(struct super_block *sb, const befs_data_stream *ds, |
251 | const char *key, befs_off_t * value) | 251 | const char *key, befs_off_t * value) |
252 | { | 252 | { |
253 | struct befs_btree_node *this_node; | 253 | struct befs_btree_node *this_node; |
@@ -416,7 +416,7 @@ befs_find_key(struct super_block *sb, struct befs_btree_node *node, | |||
416 | * until the (key_no)th key is found or the tree is out of keys. | 416 | * until the (key_no)th key is found or the tree is out of keys. |
417 | */ | 417 | */ |
418 | int | 418 | int |
419 | befs_btree_read(struct super_block *sb, befs_data_stream * ds, | 419 | befs_btree_read(struct super_block *sb, const befs_data_stream *ds, |
420 | loff_t key_no, size_t bufsize, char *keybuf, size_t * keysize, | 420 | loff_t key_no, size_t bufsize, char *keybuf, size_t * keysize, |
421 | befs_off_t * value) | 421 | befs_off_t * value) |
422 | { | 422 | { |
@@ -548,7 +548,7 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds, | |||
548 | * Also checks for an empty tree. If there are no keys, returns BEFS_BT_EMPTY. | 548 | * Also checks for an empty tree. If there are no keys, returns BEFS_BT_EMPTY. |
549 | */ | 549 | */ |
550 | static int | 550 | static int |
551 | befs_btree_seekleaf(struct super_block *sb, befs_data_stream * ds, | 551 | befs_btree_seekleaf(struct super_block *sb, const befs_data_stream *ds, |
552 | befs_btree_super *bt_super, | 552 | befs_btree_super *bt_super, |
553 | struct befs_btree_node *this_node, | 553 | struct befs_btree_node *this_node, |
554 | befs_off_t * node_off) | 554 | befs_off_t * node_off) |
diff --git a/fs/befs/btree.h b/fs/befs/btree.h index 92e781e5f30e..f2a8f637e9e0 100644 --- a/fs/befs/btree.h +++ b/fs/befs/btree.h | |||
@@ -4,10 +4,10 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | 6 | ||
7 | int befs_btree_find(struct super_block *sb, befs_data_stream * ds, | 7 | int befs_btree_find(struct super_block *sb, const befs_data_stream *ds, |
8 | const char *key, befs_off_t * value); | 8 | const char *key, befs_off_t * value); |
9 | 9 | ||
10 | int befs_btree_read(struct super_block *sb, befs_data_stream * ds, | 10 | int befs_btree_read(struct super_block *sb, const befs_data_stream *ds, |
11 | loff_t key_no, size_t bufsize, char *keybuf, | 11 | loff_t key_no, size_t bufsize, char *keybuf, |
12 | size_t * keysize, befs_off_t * value); | 12 | size_t * keysize, befs_off_t * value); |
13 | 13 | ||
diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c index ebd50718659f..dde0b79f3948 100644 --- a/fs/befs/datastream.c +++ b/fs/befs/datastream.c | |||
@@ -21,16 +21,16 @@ | |||
21 | const befs_inode_addr BAD_IADDR = { 0, 0, 0 }; | 21 | const befs_inode_addr BAD_IADDR = { 0, 0, 0 }; |
22 | 22 | ||
23 | static int befs_find_brun_direct(struct super_block *sb, | 23 | static int befs_find_brun_direct(struct super_block *sb, |
24 | befs_data_stream * data, | 24 | const befs_data_stream *data, |
25 | befs_blocknr_t blockno, befs_block_run * run); | 25 | befs_blocknr_t blockno, befs_block_run * run); |
26 | 26 | ||
27 | static int befs_find_brun_indirect(struct super_block *sb, | 27 | static int befs_find_brun_indirect(struct super_block *sb, |
28 | befs_data_stream * data, | 28 | const befs_data_stream *data, |
29 | befs_blocknr_t blockno, | 29 | befs_blocknr_t blockno, |
30 | befs_block_run * run); | 30 | befs_block_run * run); |
31 | 31 | ||
32 | static int befs_find_brun_dblindirect(struct super_block *sb, | 32 | static int befs_find_brun_dblindirect(struct super_block *sb, |
33 | befs_data_stream * data, | 33 | const befs_data_stream *data, |
34 | befs_blocknr_t blockno, | 34 | befs_blocknr_t blockno, |
35 | befs_block_run * run); | 35 | befs_block_run * run); |
36 | 36 | ||
@@ -45,7 +45,7 @@ static int befs_find_brun_dblindirect(struct super_block *sb, | |||
45 | * if you don't need to know offset just set @off = NULL. | 45 | * if you don't need to know offset just set @off = NULL. |
46 | */ | 46 | */ |
47 | struct buffer_head * | 47 | struct buffer_head * |
48 | befs_read_datastream(struct super_block *sb, befs_data_stream * ds, | 48 | befs_read_datastream(struct super_block *sb, const befs_data_stream *ds, |
49 | befs_off_t pos, uint * off) | 49 | befs_off_t pos, uint * off) |
50 | { | 50 | { |
51 | struct buffer_head *bh = NULL; | 51 | struct buffer_head *bh = NULL; |
@@ -87,7 +87,7 @@ befs_read_datastream(struct super_block *sb, befs_data_stream * ds, | |||
87 | * 2001-11-15 Will Dyson | 87 | * 2001-11-15 Will Dyson |
88 | */ | 88 | */ |
89 | int | 89 | int |
90 | befs_fblock2brun(struct super_block *sb, befs_data_stream * data, | 90 | befs_fblock2brun(struct super_block *sb, const befs_data_stream *data, |
91 | befs_blocknr_t fblock, befs_block_run * run) | 91 | befs_blocknr_t fblock, befs_block_run * run) |
92 | { | 92 | { |
93 | int err; | 93 | int err; |
@@ -122,8 +122,8 @@ befs_fblock2brun(struct super_block *sb, befs_data_stream * data, | |||
122 | * Returns the number of bytes read | 122 | * Returns the number of bytes read |
123 | */ | 123 | */ |
124 | size_t | 124 | size_t |
125 | befs_read_lsymlink(struct super_block * sb, befs_data_stream * ds, void *buff, | 125 | befs_read_lsymlink(struct super_block *sb, const befs_data_stream *ds, |
126 | befs_off_t len) | 126 | void *buff, befs_off_t len) |
127 | { | 127 | { |
128 | befs_off_t bytes_read = 0; /* bytes readed */ | 128 | befs_off_t bytes_read = 0; /* bytes readed */ |
129 | u16 plen; | 129 | u16 plen; |
@@ -163,7 +163,7 @@ befs_read_lsymlink(struct super_block * sb, befs_data_stream * ds, void *buff, | |||
163 | */ | 163 | */ |
164 | 164 | ||
165 | befs_blocknr_t | 165 | befs_blocknr_t |
166 | befs_count_blocks(struct super_block * sb, befs_data_stream * ds) | 166 | befs_count_blocks(struct super_block *sb, const befs_data_stream *ds) |
167 | { | 167 | { |
168 | befs_blocknr_t blocks; | 168 | befs_blocknr_t blocks; |
169 | befs_blocknr_t datablocks; /* File data blocks */ | 169 | befs_blocknr_t datablocks; /* File data blocks */ |
@@ -243,11 +243,11 @@ befs_count_blocks(struct super_block * sb, befs_data_stream * ds) | |||
243 | 2001-11-15 Will Dyson | 243 | 2001-11-15 Will Dyson |
244 | */ | 244 | */ |
245 | static int | 245 | static int |
246 | befs_find_brun_direct(struct super_block *sb, befs_data_stream * data, | 246 | befs_find_brun_direct(struct super_block *sb, const befs_data_stream *data, |
247 | befs_blocknr_t blockno, befs_block_run * run) | 247 | befs_blocknr_t blockno, befs_block_run * run) |
248 | { | 248 | { |
249 | int i; | 249 | int i; |
250 | befs_block_run *array = data->direct; | 250 | const befs_block_run *array = data->direct; |
251 | befs_blocknr_t sum; | 251 | befs_blocknr_t sum; |
252 | befs_blocknr_t max_block = | 252 | befs_blocknr_t max_block = |
253 | data->max_direct_range >> BEFS_SB(sb)->block_shift; | 253 | data->max_direct_range >> BEFS_SB(sb)->block_shift; |
@@ -304,7 +304,8 @@ befs_find_brun_direct(struct super_block *sb, befs_data_stream * data, | |||
304 | */ | 304 | */ |
305 | static int | 305 | static int |
306 | befs_find_brun_indirect(struct super_block *sb, | 306 | befs_find_brun_indirect(struct super_block *sb, |
307 | befs_data_stream * data, befs_blocknr_t blockno, | 307 | const befs_data_stream *data, |
308 | befs_blocknr_t blockno, | ||
308 | befs_block_run * run) | 309 | befs_block_run * run) |
309 | { | 310 | { |
310 | int i, j; | 311 | int i, j; |
@@ -412,7 +413,8 @@ befs_find_brun_indirect(struct super_block *sb, | |||
412 | */ | 413 | */ |
413 | static int | 414 | static int |
414 | befs_find_brun_dblindirect(struct super_block *sb, | 415 | befs_find_brun_dblindirect(struct super_block *sb, |
415 | befs_data_stream * data, befs_blocknr_t blockno, | 416 | const befs_data_stream *data, |
417 | befs_blocknr_t blockno, | ||
416 | befs_block_run * run) | 418 | befs_block_run * run) |
417 | { | 419 | { |
418 | int dblindir_indx; | 420 | int dblindir_indx; |
diff --git a/fs/befs/datastream.h b/fs/befs/datastream.h index 45e8a3c98249..91ba8203d83f 100644 --- a/fs/befs/datastream.h +++ b/fs/befs/datastream.h | |||
@@ -4,16 +4,17 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | struct buffer_head *befs_read_datastream(struct super_block *sb, | 6 | struct buffer_head *befs_read_datastream(struct super_block *sb, |
7 | befs_data_stream * ds, befs_off_t pos, | 7 | const befs_data_stream *ds, |
8 | uint * off); | 8 | befs_off_t pos, uint * off); |
9 | 9 | ||
10 | int befs_fblock2brun(struct super_block *sb, befs_data_stream * data, | 10 | int befs_fblock2brun(struct super_block *sb, const befs_data_stream *data, |
11 | befs_blocknr_t fblock, befs_block_run * run); | 11 | befs_blocknr_t fblock, befs_block_run * run); |
12 | 12 | ||
13 | size_t befs_read_lsymlink(struct super_block *sb, befs_data_stream * data, | 13 | size_t befs_read_lsymlink(struct super_block *sb, const befs_data_stream *data, |
14 | void *buff, befs_off_t len); | 14 | void *buff, befs_off_t len); |
15 | 15 | ||
16 | befs_blocknr_t befs_count_blocks(struct super_block *sb, befs_data_stream * ds); | 16 | befs_blocknr_t befs_count_blocks(struct super_block *sb, |
17 | const befs_data_stream *ds); | ||
17 | 18 | ||
18 | extern const befs_inode_addr BAD_IADDR; | 19 | extern const befs_inode_addr BAD_IADDR; |
19 | 20 | ||
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index cc0e08252913..71112aa07d84 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c | |||
@@ -66,7 +66,7 @@ static struct kmem_cache *befs_inode_cachep; | |||
66 | 66 | ||
67 | static const struct file_operations befs_dir_operations = { | 67 | static const struct file_operations befs_dir_operations = { |
68 | .read = generic_read_dir, | 68 | .read = generic_read_dir, |
69 | .iterate = befs_readdir, | 69 | .iterate_shared = befs_readdir, |
70 | .llseek = generic_file_llseek, | 70 | .llseek = generic_file_llseek, |
71 | }; | 71 | }; |
72 | 72 | ||
@@ -157,7 +157,7 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) | |||
157 | { | 157 | { |
158 | struct inode *inode = NULL; | 158 | struct inode *inode = NULL; |
159 | struct super_block *sb = dir->i_sb; | 159 | struct super_block *sb = dir->i_sb; |
160 | befs_data_stream *ds = &BEFS_I(dir)->i_data.ds; | 160 | const befs_data_stream *ds = &BEFS_I(dir)->i_data.ds; |
161 | befs_off_t offset; | 161 | befs_off_t offset; |
162 | int ret; | 162 | int ret; |
163 | int utfnamelen; | 163 | int utfnamelen; |
@@ -207,7 +207,7 @@ befs_readdir(struct file *file, struct dir_context *ctx) | |||
207 | { | 207 | { |
208 | struct inode *inode = file_inode(file); | 208 | struct inode *inode = file_inode(file); |
209 | struct super_block *sb = inode->i_sb; | 209 | struct super_block *sb = inode->i_sb; |
210 | befs_data_stream *ds = &BEFS_I(inode)->i_data.ds; | 210 | const befs_data_stream *ds = &BEFS_I(inode)->i_data.ds; |
211 | befs_off_t value; | 211 | befs_off_t value; |
212 | int result; | 212 | int result; |
213 | size_t keysize; | 213 | size_t keysize; |
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c index 3ec6113146c0..34a5bc2f1290 100644 --- a/fs/bfs/dir.c +++ b/fs/bfs/dir.c | |||
@@ -70,7 +70,7 @@ static int bfs_readdir(struct file *f, struct dir_context *ctx) | |||
70 | 70 | ||
71 | const struct file_operations bfs_dir_operations = { | 71 | const struct file_operations bfs_dir_operations = { |
72 | .read = generic_read_dir, | 72 | .read = generic_read_dir, |
73 | .iterate = bfs_readdir, | 73 | .iterate_shared = bfs_readdir, |
74 | .fsync = generic_file_fsync, | 74 | .fsync = generic_file_fsync, |
75 | .llseek = generic_file_llseek, | 75 | .llseek = generic_file_llseek, |
76 | }; | 76 | }; |
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index 6d263bb1621c..67a607709d4f 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c | |||
@@ -63,9 +63,6 @@ struct posix_acl *btrfs_get_acl(struct inode *inode, int type) | |||
63 | } | 63 | } |
64 | kfree(value); | 64 | kfree(value); |
65 | 65 | ||
66 | if (!IS_ERR(acl)) | ||
67 | set_cached_acl(inode, type, acl); | ||
68 | |||
69 | return acl; | 66 | return acl; |
70 | } | 67 | } |
71 | 68 | ||
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 2aaba58b4856..3e2ada1267f3 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -10181,7 +10181,7 @@ static const struct inode_operations btrfs_dir_ro_inode_operations = { | |||
10181 | static const struct file_operations btrfs_dir_file_operations = { | 10181 | static const struct file_operations btrfs_dir_file_operations = { |
10182 | .llseek = generic_file_llseek, | 10182 | .llseek = generic_file_llseek, |
10183 | .read = generic_read_dir, | 10183 | .read = generic_read_dir, |
10184 | .iterate = btrfs_real_readdir, | 10184 | .iterate_shared = btrfs_real_readdir, |
10185 | .unlocked_ioctl = btrfs_ioctl, | 10185 | .unlocked_ioctl = btrfs_ioctl, |
10186 | #ifdef CONFIG_COMPAT | 10186 | #ifdef CONFIG_COMPAT |
10187 | .compat_ioctl = btrfs_ioctl, | 10187 | .compat_ioctl = btrfs_ioctl, |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 5a23806ae418..0b8ba717175b 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -837,9 +837,11 @@ static noinline int btrfs_mksubvol(struct path *parent, | |||
837 | struct dentry *dentry; | 837 | struct dentry *dentry; |
838 | int error; | 838 | int error; |
839 | 839 | ||
840 | error = mutex_lock_killable_nested(&dir->i_mutex, I_MUTEX_PARENT); | 840 | inode_lock_nested(dir, I_MUTEX_PARENT); |
841 | if (error == -EINTR) | 841 | // XXX: should've been |
842 | return error; | 842 | // mutex_lock_killable_nested(&dir->i_mutex, I_MUTEX_PARENT); |
843 | // if (error == -EINTR) | ||
844 | // return error; | ||
843 | 845 | ||
844 | dentry = lookup_one_len(name, parent->dentry, namelen); | 846 | dentry = lookup_one_len(name, parent->dentry, namelen); |
845 | error = PTR_ERR(dentry); | 847 | error = PTR_ERR(dentry); |
@@ -2366,9 +2368,11 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, | |||
2366 | goto out; | 2368 | goto out; |
2367 | 2369 | ||
2368 | 2370 | ||
2369 | err = mutex_lock_killable_nested(&dir->i_mutex, I_MUTEX_PARENT); | 2371 | inode_lock_nested(dir, I_MUTEX_PARENT); |
2370 | if (err == -EINTR) | 2372 | // XXX: should've been |
2371 | goto out_drop_write; | 2373 | // err = mutex_lock_killable_nested(&dir->i_mutex, I_MUTEX_PARENT); |
2374 | // if (err == -EINTR) | ||
2375 | // goto out_drop_write; | ||
2372 | dentry = lookup_one_len(vol_args->name, parent, namelen); | 2376 | dentry = lookup_one_len(vol_args->name, parent, namelen); |
2373 | if (IS_ERR(dentry)) { | 2377 | if (IS_ERR(dentry)) { |
2374 | err = PTR_ERR(dentry); | 2378 | err = PTR_ERR(dentry); |
@@ -2558,7 +2562,7 @@ out_dput: | |||
2558 | dput(dentry); | 2562 | dput(dentry); |
2559 | out_unlock_dir: | 2563 | out_unlock_dir: |
2560 | inode_unlock(dir); | 2564 | inode_unlock(dir); |
2561 | out_drop_write: | 2565 | //out_drop_write: |
2562 | mnt_drop_write_file(file); | 2566 | mnt_drop_write_file(file); |
2563 | out: | 2567 | out: |
2564 | kfree(vol_args); | 2568 | kfree(vol_args); |
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 517d0ccb351e..e692eea87af6 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -4988,7 +4988,7 @@ static noinline int check_parent_dirs_for_sync(struct btrfs_trans_handle *trans, | |||
4988 | goto out; | 4988 | goto out; |
4989 | 4989 | ||
4990 | if (!S_ISDIR(inode->i_mode)) { | 4990 | if (!S_ISDIR(inode->i_mode)) { |
4991 | if (!parent || d_really_is_negative(parent) || sb != d_inode(parent)->i_sb) | 4991 | if (!parent || d_really_is_negative(parent) || sb != parent->d_sb) |
4992 | goto out; | 4992 | goto out; |
4993 | inode = d_inode(parent); | 4993 | inode = d_inode(parent); |
4994 | } | 4994 | } |
@@ -5009,7 +5009,7 @@ static noinline int check_parent_dirs_for_sync(struct btrfs_trans_handle *trans, | |||
5009 | break; | 5009 | break; |
5010 | } | 5010 | } |
5011 | 5011 | ||
5012 | if (!parent || d_really_is_negative(parent) || sb != d_inode(parent)->i_sb) | 5012 | if (!parent || d_really_is_negative(parent) || sb != parent->d_sb) |
5013 | break; | 5013 | break; |
5014 | 5014 | ||
5015 | if (IS_ROOT(parent)) | 5015 | if (IS_ROOT(parent)) |
@@ -5422,7 +5422,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans, | |||
5422 | } | 5422 | } |
5423 | 5423 | ||
5424 | while (1) { | 5424 | while (1) { |
5425 | if (!parent || d_really_is_negative(parent) || sb != d_inode(parent)->i_sb) | 5425 | if (!parent || d_really_is_negative(parent) || sb != parent->d_sb) |
5426 | break; | 5426 | break; |
5427 | 5427 | ||
5428 | inode = d_inode(parent); | 5428 | inode = d_inode(parent); |
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index 145d2b89e62d..03224b00ea70 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c | |||
@@ -369,11 +369,9 @@ err: | |||
369 | } | 369 | } |
370 | 370 | ||
371 | static int btrfs_xattr_handler_get(const struct xattr_handler *handler, | 371 | static int btrfs_xattr_handler_get(const struct xattr_handler *handler, |
372 | struct dentry *dentry, const char *name, | 372 | struct dentry *unused, struct inode *inode, |
373 | void *buffer, size_t size) | 373 | const char *name, void *buffer, size_t size) |
374 | { | 374 | { |
375 | struct inode *inode = d_inode(dentry); | ||
376 | |||
377 | name = xattr_full_name(handler, name); | 375 | name = xattr_full_name(handler, name); |
378 | return __btrfs_getxattr(inode, name, buffer, size); | 376 | return __btrfs_getxattr(inode, name, buffer, size); |
379 | } | 377 | } |
diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index f19708487e2f..5457f216e2e5 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c | |||
@@ -37,6 +37,8 @@ static inline void ceph_set_cached_acl(struct inode *inode, | |||
37 | spin_lock(&ci->i_ceph_lock); | 37 | spin_lock(&ci->i_ceph_lock); |
38 | if (__ceph_caps_issued_mask(ci, CEPH_CAP_XATTR_SHARED, 0)) | 38 | if (__ceph_caps_issued_mask(ci, CEPH_CAP_XATTR_SHARED, 0)) |
39 | set_cached_acl(inode, type, acl); | 39 | set_cached_acl(inode, type, acl); |
40 | else | ||
41 | forget_cached_acl(inode, type); | ||
40 | spin_unlock(&ci->i_ceph_lock); | 42 | spin_unlock(&ci->i_ceph_lock); |
41 | } | 43 | } |
42 | 44 | ||
diff --git a/fs/ceph/super.h b/fs/ceph/super.h index e705c4d612d7..beb893bb234f 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h | |||
@@ -795,7 +795,7 @@ extern int ceph_setxattr(struct dentry *, const char *, const void *, | |||
795 | int __ceph_setxattr(struct dentry *, const char *, const void *, size_t, int); | 795 | int __ceph_setxattr(struct dentry *, const char *, const void *, size_t, int); |
796 | ssize_t __ceph_getxattr(struct inode *, const char *, void *, size_t); | 796 | ssize_t __ceph_getxattr(struct inode *, const char *, void *, size_t); |
797 | int __ceph_removexattr(struct dentry *, const char *); | 797 | int __ceph_removexattr(struct dentry *, const char *); |
798 | extern ssize_t ceph_getxattr(struct dentry *, const char *, void *, size_t); | 798 | extern ssize_t ceph_getxattr(struct dentry *, struct inode *, const char *, void *, size_t); |
799 | extern ssize_t ceph_listxattr(struct dentry *, char *, size_t); | 799 | extern ssize_t ceph_listxattr(struct dentry *, char *, size_t); |
800 | extern int ceph_removexattr(struct dentry *, const char *); | 800 | extern int ceph_removexattr(struct dentry *, const char *); |
801 | extern void __ceph_build_xattrs_blob(struct ceph_inode_info *ci); | 801 | extern void __ceph_build_xattrs_blob(struct ceph_inode_info *ci); |
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index 9410abdef3ce..c6e917d360f7 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c | |||
@@ -804,13 +804,13 @@ out: | |||
804 | return err; | 804 | return err; |
805 | } | 805 | } |
806 | 806 | ||
807 | ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value, | 807 | ssize_t ceph_getxattr(struct dentry *dentry, struct inode *inode, |
808 | size_t size) | 808 | const char *name, void *value, size_t size) |
809 | { | 809 | { |
810 | if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) | 810 | if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) |
811 | return generic_getxattr(dentry, name, value, size); | 811 | return generic_getxattr(dentry, inode, name, value, size); |
812 | 812 | ||
813 | return __ceph_getxattr(d_inode(dentry), name, value, size); | 813 | return __ceph_getxattr(inode, name, value, size); |
814 | } | 814 | } |
815 | 815 | ||
816 | ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size) | 816 | ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size) |
diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c index e956cba94338..94f2c8a9ae6d 100644 --- a/fs/cifs/cifs_dfs_ref.c +++ b/fs/cifs/cifs_dfs_ref.c | |||
@@ -302,7 +302,7 @@ static struct vfsmount *cifs_dfs_do_automount(struct dentry *mntpt) | |||
302 | if (full_path == NULL) | 302 | if (full_path == NULL) |
303 | goto cdda_exit; | 303 | goto cdda_exit; |
304 | 304 | ||
305 | cifs_sb = CIFS_SB(d_inode(mntpt)->i_sb); | 305 | cifs_sb = CIFS_SB(mntpt->d_sb); |
306 | tlink = cifs_sb_tlink(cifs_sb); | 306 | tlink = cifs_sb_tlink(cifs_sb); |
307 | if (IS_ERR(tlink)) { | 307 | if (IS_ERR(tlink)) { |
308 | mnt = ERR_CAST(tlink); | 308 | mnt = ERR_CAST(tlink); |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 89201564c346..aadb59388e90 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -1083,7 +1083,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = { | |||
1083 | }; | 1083 | }; |
1084 | 1084 | ||
1085 | const struct file_operations cifs_dir_ops = { | 1085 | const struct file_operations cifs_dir_ops = { |
1086 | .iterate = cifs_readdir, | 1086 | .iterate_shared = cifs_readdir, |
1087 | .release = cifs_closedir, | 1087 | .release = cifs_closedir, |
1088 | .read = generic_read_dir, | 1088 | .read = generic_read_dir, |
1089 | .unlocked_ioctl = cifs_ioctl, | 1089 | .unlocked_ioctl = cifs_ioctl, |
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 83aac8ba50b0..c89ecd7a5c39 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h | |||
@@ -123,7 +123,7 @@ extern int cifs_symlink(struct inode *inode, struct dentry *direntry, | |||
123 | extern int cifs_removexattr(struct dentry *, const char *); | 123 | extern int cifs_removexattr(struct dentry *, const char *); |
124 | extern int cifs_setxattr(struct dentry *, const char *, const void *, | 124 | extern int cifs_setxattr(struct dentry *, const char *, const void *, |
125 | size_t, int); | 125 | size_t, int); |
126 | extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t); | 126 | extern ssize_t cifs_getxattr(struct dentry *, struct inode *, const char *, void *, size_t); |
127 | extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); | 127 | extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); |
128 | extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg); | 128 | extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg); |
129 | #ifdef CONFIG_CIFS_NFSD_EXPORT | 129 | #ifdef CONFIG_CIFS_NFSD_EXPORT |
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 5f9ad5c42180..514dadb0575d 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -2418,8 +2418,7 @@ cifs_setattr_exit: | |||
2418 | int | 2418 | int |
2419 | cifs_setattr(struct dentry *direntry, struct iattr *attrs) | 2419 | cifs_setattr(struct dentry *direntry, struct iattr *attrs) |
2420 | { | 2420 | { |
2421 | struct inode *inode = d_inode(direntry); | 2421 | struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); |
2422 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); | ||
2423 | struct cifs_tcon *pTcon = cifs_sb_master_tcon(cifs_sb); | 2422 | struct cifs_tcon *pTcon = cifs_sb_master_tcon(cifs_sb); |
2424 | 2423 | ||
2425 | if (pTcon->unix_ext) | 2424 | if (pTcon->unix_ext) |
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index b30a4a6d98a0..867439c21001 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c | |||
@@ -78,20 +78,34 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name, | |||
78 | { | 78 | { |
79 | struct dentry *dentry, *alias; | 79 | struct dentry *dentry, *alias; |
80 | struct inode *inode; | 80 | struct inode *inode; |
81 | struct super_block *sb = d_inode(parent)->i_sb; | 81 | struct super_block *sb = parent->d_sb; |
82 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); | 82 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); |
83 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); | ||
83 | 84 | ||
84 | cifs_dbg(FYI, "%s: for %s\n", __func__, name->name); | 85 | cifs_dbg(FYI, "%s: for %s\n", __func__, name->name); |
85 | 86 | ||
86 | dentry = d_hash_and_lookup(parent, name); | 87 | dentry = d_hash_and_lookup(parent, name); |
88 | if (!dentry) { | ||
89 | /* | ||
90 | * If we know that the inode will need to be revalidated | ||
91 | * immediately, then don't create a new dentry for it. | ||
92 | * We'll end up doing an on the wire call either way and | ||
93 | * this spares us an invalidation. | ||
94 | */ | ||
95 | if (fattr->cf_flags & CIFS_FATTR_NEED_REVAL) | ||
96 | return; | ||
97 | retry: | ||
98 | dentry = d_alloc_parallel(parent, name, &wq); | ||
99 | } | ||
87 | if (IS_ERR(dentry)) | 100 | if (IS_ERR(dentry)) |
88 | return; | 101 | return; |
89 | 102 | if (!d_in_lookup(dentry)) { | |
90 | if (dentry) { | ||
91 | inode = d_inode(dentry); | 103 | inode = d_inode(dentry); |
92 | if (inode) { | 104 | if (inode) { |
93 | if (d_mountpoint(dentry)) | 105 | if (d_mountpoint(dentry)) { |
94 | goto out; | 106 | dput(dentry); |
107 | return; | ||
108 | } | ||
95 | /* | 109 | /* |
96 | * If we're generating inode numbers, then we don't | 110 | * If we're generating inode numbers, then we don't |
97 | * want to clobber the existing one with the one that | 111 | * want to clobber the existing one with the one that |
@@ -106,33 +120,22 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name, | |||
106 | (inode->i_mode & S_IFMT) == | 120 | (inode->i_mode & S_IFMT) == |
107 | (fattr->cf_mode & S_IFMT)) { | 121 | (fattr->cf_mode & S_IFMT)) { |
108 | cifs_fattr_to_inode(inode, fattr); | 122 | cifs_fattr_to_inode(inode, fattr); |
109 | goto out; | 123 | dput(dentry); |
124 | return; | ||
110 | } | 125 | } |
111 | } | 126 | } |
112 | d_invalidate(dentry); | 127 | d_invalidate(dentry); |
113 | dput(dentry); | 128 | dput(dentry); |
129 | goto retry; | ||
130 | } else { | ||
131 | inode = cifs_iget(sb, fattr); | ||
132 | if (!inode) | ||
133 | inode = ERR_PTR(-ENOMEM); | ||
134 | alias = d_splice_alias(inode, dentry); | ||
135 | d_lookup_done(dentry); | ||
136 | if (alias && !IS_ERR(alias)) | ||
137 | dput(alias); | ||
114 | } | 138 | } |
115 | |||
116 | /* | ||
117 | * If we know that the inode will need to be revalidated immediately, | ||
118 | * then don't create a new dentry for it. We'll end up doing an on | ||
119 | * the wire call either way and this spares us an invalidation. | ||
120 | */ | ||
121 | if (fattr->cf_flags & CIFS_FATTR_NEED_REVAL) | ||
122 | return; | ||
123 | |||
124 | dentry = d_alloc(parent, name); | ||
125 | if (!dentry) | ||
126 | return; | ||
127 | |||
128 | inode = cifs_iget(sb, fattr); | ||
129 | if (!inode) | ||
130 | goto out; | ||
131 | |||
132 | alias = d_splice_alias(inode, dentry); | ||
133 | if (alias && !IS_ERR(alias)) | ||
134 | dput(alias); | ||
135 | out: | ||
136 | dput(dentry); | 139 | dput(dentry); |
137 | } | 140 | } |
138 | 141 | ||
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c index f5dc2f0df4ad..5d57c85703a9 100644 --- a/fs/cifs/xattr.c +++ b/fs/cifs/xattr.c | |||
@@ -42,21 +42,11 @@ int cifs_removexattr(struct dentry *direntry, const char *ea_name) | |||
42 | int rc = -EOPNOTSUPP; | 42 | int rc = -EOPNOTSUPP; |
43 | #ifdef CONFIG_CIFS_XATTR | 43 | #ifdef CONFIG_CIFS_XATTR |
44 | unsigned int xid; | 44 | unsigned int xid; |
45 | struct cifs_sb_info *cifs_sb; | 45 | struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); |
46 | struct tcon_link *tlink; | 46 | struct tcon_link *tlink; |
47 | struct cifs_tcon *pTcon; | 47 | struct cifs_tcon *pTcon; |
48 | struct super_block *sb; | ||
49 | char *full_path = NULL; | 48 | char *full_path = NULL; |
50 | 49 | ||
51 | if (direntry == NULL) | ||
52 | return -EIO; | ||
53 | if (d_really_is_negative(direntry)) | ||
54 | return -EIO; | ||
55 | sb = d_inode(direntry)->i_sb; | ||
56 | if (sb == NULL) | ||
57 | return -EIO; | ||
58 | |||
59 | cifs_sb = CIFS_SB(sb); | ||
60 | tlink = cifs_sb_tlink(cifs_sb); | 50 | tlink = cifs_sb_tlink(cifs_sb); |
61 | if (IS_ERR(tlink)) | 51 | if (IS_ERR(tlink)) |
62 | return PTR_ERR(tlink); | 52 | return PTR_ERR(tlink); |
@@ -103,21 +93,12 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, | |||
103 | int rc = -EOPNOTSUPP; | 93 | int rc = -EOPNOTSUPP; |
104 | #ifdef CONFIG_CIFS_XATTR | 94 | #ifdef CONFIG_CIFS_XATTR |
105 | unsigned int xid; | 95 | unsigned int xid; |
106 | struct cifs_sb_info *cifs_sb; | 96 | struct super_block *sb = direntry->d_sb; |
97 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); | ||
107 | struct tcon_link *tlink; | 98 | struct tcon_link *tlink; |
108 | struct cifs_tcon *pTcon; | 99 | struct cifs_tcon *pTcon; |
109 | struct super_block *sb; | ||
110 | char *full_path; | 100 | char *full_path; |
111 | 101 | ||
112 | if (direntry == NULL) | ||
113 | return -EIO; | ||
114 | if (d_really_is_negative(direntry)) | ||
115 | return -EIO; | ||
116 | sb = d_inode(direntry)->i_sb; | ||
117 | if (sb == NULL) | ||
118 | return -EIO; | ||
119 | |||
120 | cifs_sb = CIFS_SB(sb); | ||
121 | tlink = cifs_sb_tlink(cifs_sb); | 102 | tlink = cifs_sb_tlink(cifs_sb); |
122 | if (IS_ERR(tlink)) | 103 | if (IS_ERR(tlink)) |
123 | return PTR_ERR(tlink); | 104 | return PTR_ERR(tlink); |
@@ -232,27 +213,18 @@ set_ea_exit: | |||
232 | return rc; | 213 | return rc; |
233 | } | 214 | } |
234 | 215 | ||
235 | ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, | 216 | ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode, |
236 | void *ea_value, size_t buf_size) | 217 | const char *ea_name, void *ea_value, size_t buf_size) |
237 | { | 218 | { |
238 | ssize_t rc = -EOPNOTSUPP; | 219 | ssize_t rc = -EOPNOTSUPP; |
239 | #ifdef CONFIG_CIFS_XATTR | 220 | #ifdef CONFIG_CIFS_XATTR |
240 | unsigned int xid; | 221 | unsigned int xid; |
241 | struct cifs_sb_info *cifs_sb; | 222 | struct super_block *sb = direntry->d_sb; |
223 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); | ||
242 | struct tcon_link *tlink; | 224 | struct tcon_link *tlink; |
243 | struct cifs_tcon *pTcon; | 225 | struct cifs_tcon *pTcon; |
244 | struct super_block *sb; | ||
245 | char *full_path; | 226 | char *full_path; |
246 | 227 | ||
247 | if (direntry == NULL) | ||
248 | return -EIO; | ||
249 | if (d_really_is_negative(direntry)) | ||
250 | return -EIO; | ||
251 | sb = d_inode(direntry)->i_sb; | ||
252 | if (sb == NULL) | ||
253 | return -EIO; | ||
254 | |||
255 | cifs_sb = CIFS_SB(sb); | ||
256 | tlink = cifs_sb_tlink(cifs_sb); | 228 | tlink = cifs_sb_tlink(cifs_sb); |
257 | if (IS_ERR(tlink)) | 229 | if (IS_ERR(tlink)) |
258 | return PTR_ERR(tlink); | 230 | return PTR_ERR(tlink); |
@@ -324,7 +296,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, | |||
324 | goto get_ea_exit; /* rc already EOPNOTSUPP */ | 296 | goto get_ea_exit; /* rc already EOPNOTSUPP */ |
325 | 297 | ||
326 | pacl = pTcon->ses->server->ops->get_acl(cifs_sb, | 298 | pacl = pTcon->ses->server->ops->get_acl(cifs_sb, |
327 | d_inode(direntry), full_path, &acllen); | 299 | inode, full_path, &acllen); |
328 | if (IS_ERR(pacl)) { | 300 | if (IS_ERR(pacl)) { |
329 | rc = PTR_ERR(pacl); | 301 | rc = PTR_ERR(pacl); |
330 | cifs_dbg(VFS, "%s: error %zd getting sec desc\n", | 302 | cifs_dbg(VFS, "%s: error %zd getting sec desc\n", |
@@ -374,21 +346,11 @@ ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size) | |||
374 | ssize_t rc = -EOPNOTSUPP; | 346 | ssize_t rc = -EOPNOTSUPP; |
375 | #ifdef CONFIG_CIFS_XATTR | 347 | #ifdef CONFIG_CIFS_XATTR |
376 | unsigned int xid; | 348 | unsigned int xid; |
377 | struct cifs_sb_info *cifs_sb; | 349 | struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); |
378 | struct tcon_link *tlink; | 350 | struct tcon_link *tlink; |
379 | struct cifs_tcon *pTcon; | 351 | struct cifs_tcon *pTcon; |
380 | struct super_block *sb; | ||
381 | char *full_path; | 352 | char *full_path; |
382 | 353 | ||
383 | if (direntry == NULL) | ||
384 | return -EIO; | ||
385 | if (d_really_is_negative(direntry)) | ||
386 | return -EIO; | ||
387 | sb = d_inode(direntry)->i_sb; | ||
388 | if (sb == NULL) | ||
389 | return -EIO; | ||
390 | |||
391 | cifs_sb = CIFS_SB(sb); | ||
392 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) | 354 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) |
393 | return -EOPNOTSUPP; | 355 | return -EOPNOTSUPP; |
394 | 356 | ||
diff --git a/fs/coda/dir.c b/fs/coda/dir.c index 42e731b8c80a..6fb8672c0892 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c | |||
@@ -424,16 +424,22 @@ static int coda_readdir(struct file *coda_file, struct dir_context *ctx) | |||
424 | BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); | 424 | BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); |
425 | host_file = cfi->cfi_container; | 425 | host_file = cfi->cfi_container; |
426 | 426 | ||
427 | if (host_file->f_op->iterate) { | 427 | if (host_file->f_op->iterate || host_file->f_op->iterate_shared) { |
428 | struct inode *host_inode = file_inode(host_file); | 428 | struct inode *host_inode = file_inode(host_file); |
429 | |||
430 | inode_lock(host_inode); | ||
431 | ret = -ENOENT; | 429 | ret = -ENOENT; |
432 | if (!IS_DEADDIR(host_inode)) { | 430 | if (!IS_DEADDIR(host_inode)) { |
433 | ret = host_file->f_op->iterate(host_file, ctx); | 431 | if (host_file->f_op->iterate_shared) { |
434 | file_accessed(host_file); | 432 | inode_lock_shared(host_inode); |
433 | ret = host_file->f_op->iterate_shared(host_file, ctx); | ||
434 | file_accessed(host_file); | ||
435 | inode_unlock_shared(host_inode); | ||
436 | } else { | ||
437 | inode_lock(host_inode); | ||
438 | ret = host_file->f_op->iterate(host_file, ctx); | ||
439 | file_accessed(host_file); | ||
440 | inode_unlock(host_inode); | ||
441 | } | ||
435 | } | 442 | } |
436 | inode_unlock(host_inode); | ||
437 | return ret; | 443 | return ret; |
438 | } | 444 | } |
439 | /* Venus: we must read Venus dirents from a file */ | 445 | /* Venus: we must read Venus dirents from a file */ |
diff --git a/fs/compat.c b/fs/compat.c index a71936a3f4cb..8754e9aa14ad 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -884,7 +884,7 @@ COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd, | |||
884 | struct compat_old_linux_dirent __user *, dirent, unsigned int, count) | 884 | struct compat_old_linux_dirent __user *, dirent, unsigned int, count) |
885 | { | 885 | { |
886 | int error; | 886 | int error; |
887 | struct fd f = fdget(fd); | 887 | struct fd f = fdget_pos(fd); |
888 | struct compat_readdir_callback buf = { | 888 | struct compat_readdir_callback buf = { |
889 | .ctx.actor = compat_fillonedir, | 889 | .ctx.actor = compat_fillonedir, |
890 | .dirent = dirent | 890 | .dirent = dirent |
@@ -897,7 +897,7 @@ COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd, | |||
897 | if (buf.result) | 897 | if (buf.result) |
898 | error = buf.result; | 898 | error = buf.result; |
899 | 899 | ||
900 | fdput(f); | 900 | fdput_pos(f); |
901 | return error; | 901 | return error; |
902 | } | 902 | } |
903 | 903 | ||
@@ -975,7 +975,7 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd, | |||
975 | if (!access_ok(VERIFY_WRITE, dirent, count)) | 975 | if (!access_ok(VERIFY_WRITE, dirent, count)) |
976 | return -EFAULT; | 976 | return -EFAULT; |
977 | 977 | ||
978 | f = fdget(fd); | 978 | f = fdget_pos(fd); |
979 | if (!f.file) | 979 | if (!f.file) |
980 | return -EBADF; | 980 | return -EBADF; |
981 | 981 | ||
@@ -989,7 +989,7 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd, | |||
989 | else | 989 | else |
990 | error = count - buf.count; | 990 | error = count - buf.count; |
991 | } | 991 | } |
992 | fdput(f); | 992 | fdput_pos(f); |
993 | return error; | 993 | return error; |
994 | } | 994 | } |
995 | 995 | ||
@@ -1062,7 +1062,7 @@ COMPAT_SYSCALL_DEFINE3(getdents64, unsigned int, fd, | |||
1062 | if (!access_ok(VERIFY_WRITE, dirent, count)) | 1062 | if (!access_ok(VERIFY_WRITE, dirent, count)) |
1063 | return -EFAULT; | 1063 | return -EFAULT; |
1064 | 1064 | ||
1065 | f = fdget(fd); | 1065 | f = fdget_pos(fd); |
1066 | if (!f.file) | 1066 | if (!f.file) |
1067 | return -EBADF; | 1067 | return -EBADF; |
1068 | 1068 | ||
@@ -1077,7 +1077,7 @@ COMPAT_SYSCALL_DEFINE3(getdents64, unsigned int, fd, | |||
1077 | else | 1077 | else |
1078 | error = count - buf.count; | 1078 | error = count - buf.count; |
1079 | } | 1079 | } |
1080 | fdput(f); | 1080 | fdput_pos(f); |
1081 | return error; | 1081 | return error; |
1082 | } | 1082 | } |
1083 | #endif /* __ARCH_WANT_COMPAT_SYS_GETDENTS64 */ | 1083 | #endif /* __ARCH_WANT_COMPAT_SYS_GETDENTS64 */ |
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index ea59c891fc53..56fb26127fef 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -494,7 +494,7 @@ out: | |||
494 | * If there is an error, the caller will reset the flags via | 494 | * If there is an error, the caller will reset the flags via |
495 | * configfs_detach_rollback(). | 495 | * configfs_detach_rollback(). |
496 | */ | 496 | */ |
497 | static int configfs_detach_prep(struct dentry *dentry, struct mutex **wait_mutex) | 497 | static int configfs_detach_prep(struct dentry *dentry, struct dentry **wait) |
498 | { | 498 | { |
499 | struct configfs_dirent *parent_sd = dentry->d_fsdata; | 499 | struct configfs_dirent *parent_sd = dentry->d_fsdata; |
500 | struct configfs_dirent *sd; | 500 | struct configfs_dirent *sd; |
@@ -515,8 +515,8 @@ static int configfs_detach_prep(struct dentry *dentry, struct mutex **wait_mutex | |||
515 | if (sd->s_type & CONFIGFS_USET_DEFAULT) { | 515 | if (sd->s_type & CONFIGFS_USET_DEFAULT) { |
516 | /* Abort if racing with mkdir() */ | 516 | /* Abort if racing with mkdir() */ |
517 | if (sd->s_type & CONFIGFS_USET_IN_MKDIR) { | 517 | if (sd->s_type & CONFIGFS_USET_IN_MKDIR) { |
518 | if (wait_mutex) | 518 | if (wait) |
519 | *wait_mutex = &d_inode(sd->s_dentry)->i_mutex; | 519 | *wait= dget(sd->s_dentry); |
520 | return -EAGAIN; | 520 | return -EAGAIN; |
521 | } | 521 | } |
522 | 522 | ||
@@ -524,7 +524,7 @@ static int configfs_detach_prep(struct dentry *dentry, struct mutex **wait_mutex | |||
524 | * Yup, recursive. If there's a problem, blame | 524 | * Yup, recursive. If there's a problem, blame |
525 | * deep nesting of default_groups | 525 | * deep nesting of default_groups |
526 | */ | 526 | */ |
527 | ret = configfs_detach_prep(sd->s_dentry, wait_mutex); | 527 | ret = configfs_detach_prep(sd->s_dentry, wait); |
528 | if (!ret) | 528 | if (!ret) |
529 | continue; | 529 | continue; |
530 | } else | 530 | } else |
@@ -1458,7 +1458,7 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
1458 | * the new link is temporarily attached | 1458 | * the new link is temporarily attached |
1459 | */ | 1459 | */ |
1460 | do { | 1460 | do { |
1461 | struct mutex *wait_mutex; | 1461 | struct dentry *wait; |
1462 | 1462 | ||
1463 | mutex_lock(&configfs_symlink_mutex); | 1463 | mutex_lock(&configfs_symlink_mutex); |
1464 | spin_lock(&configfs_dirent_lock); | 1464 | spin_lock(&configfs_dirent_lock); |
@@ -1469,7 +1469,7 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
1469 | */ | 1469 | */ |
1470 | ret = sd->s_dependent_count ? -EBUSY : 0; | 1470 | ret = sd->s_dependent_count ? -EBUSY : 0; |
1471 | if (!ret) { | 1471 | if (!ret) { |
1472 | ret = configfs_detach_prep(dentry, &wait_mutex); | 1472 | ret = configfs_detach_prep(dentry, &wait); |
1473 | if (ret) | 1473 | if (ret) |
1474 | configfs_detach_rollback(dentry); | 1474 | configfs_detach_rollback(dentry); |
1475 | } | 1475 | } |
@@ -1483,8 +1483,9 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | /* Wait until the racing operation terminates */ | 1485 | /* Wait until the racing operation terminates */ |
1486 | mutex_lock(wait_mutex); | 1486 | inode_lock(d_inode(wait)); |
1487 | mutex_unlock(wait_mutex); | 1487 | inode_unlock(d_inode(wait)); |
1488 | dput(wait); | ||
1488 | } | 1489 | } |
1489 | } while (ret == -EAGAIN); | 1490 | } while (ret == -EAGAIN); |
1490 | 1491 | ||
@@ -1632,11 +1633,9 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx) | |||
1632 | 1633 | ||
1633 | if (!dir_emit_dots(file, ctx)) | 1634 | if (!dir_emit_dots(file, ctx)) |
1634 | return 0; | 1635 | return 0; |
1635 | if (ctx->pos == 2) { | 1636 | spin_lock(&configfs_dirent_lock); |
1636 | spin_lock(&configfs_dirent_lock); | 1637 | if (ctx->pos == 2) |
1637 | list_move(q, &parent_sd->s_children); | 1638 | list_move(q, &parent_sd->s_children); |
1638 | spin_unlock(&configfs_dirent_lock); | ||
1639 | } | ||
1640 | for (p = q->next; p != &parent_sd->s_children; p = p->next) { | 1639 | for (p = q->next; p != &parent_sd->s_children; p = p->next) { |
1641 | struct configfs_dirent *next; | 1640 | struct configfs_dirent *next; |
1642 | const char *name; | 1641 | const char *name; |
@@ -1647,9 +1646,6 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx) | |||
1647 | if (!next->s_element) | 1646 | if (!next->s_element) |
1648 | continue; | 1647 | continue; |
1649 | 1648 | ||
1650 | name = configfs_get_name(next); | ||
1651 | len = strlen(name); | ||
1652 | |||
1653 | /* | 1649 | /* |
1654 | * We'll have a dentry and an inode for | 1650 | * We'll have a dentry and an inode for |
1655 | * PINNED items and for open attribute | 1651 | * PINNED items and for open attribute |
@@ -1663,7 +1659,6 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx) | |||
1663 | * they close it. Beyond that, we don't | 1659 | * they close it. Beyond that, we don't |
1664 | * care. | 1660 | * care. |
1665 | */ | 1661 | */ |
1666 | spin_lock(&configfs_dirent_lock); | ||
1667 | dentry = next->s_dentry; | 1662 | dentry = next->s_dentry; |
1668 | if (dentry) | 1663 | if (dentry) |
1669 | inode = d_inode(dentry); | 1664 | inode = d_inode(dentry); |
@@ -1673,15 +1668,18 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx) | |||
1673 | if (!inode) | 1668 | if (!inode) |
1674 | ino = iunique(sb, 2); | 1669 | ino = iunique(sb, 2); |
1675 | 1670 | ||
1671 | name = configfs_get_name(next); | ||
1672 | len = strlen(name); | ||
1673 | |||
1676 | if (!dir_emit(ctx, name, len, ino, dt_type(next))) | 1674 | if (!dir_emit(ctx, name, len, ino, dt_type(next))) |
1677 | return 0; | 1675 | return 0; |
1678 | 1676 | ||
1679 | spin_lock(&configfs_dirent_lock); | 1677 | spin_lock(&configfs_dirent_lock); |
1680 | list_move(q, p); | 1678 | list_move(q, p); |
1681 | spin_unlock(&configfs_dirent_lock); | ||
1682 | p = q; | 1679 | p = q; |
1683 | ctx->pos++; | 1680 | ctx->pos++; |
1684 | } | 1681 | } |
1682 | spin_unlock(&configfs_dirent_lock); | ||
1685 | return 0; | 1683 | return 0; |
1686 | } | 1684 | } |
1687 | 1685 | ||
@@ -1689,7 +1687,6 @@ static loff_t configfs_dir_lseek(struct file *file, loff_t offset, int whence) | |||
1689 | { | 1687 | { |
1690 | struct dentry * dentry = file->f_path.dentry; | 1688 | struct dentry * dentry = file->f_path.dentry; |
1691 | 1689 | ||
1692 | inode_lock(d_inode(dentry)); | ||
1693 | switch (whence) { | 1690 | switch (whence) { |
1694 | case 1: | 1691 | case 1: |
1695 | offset += file->f_pos; | 1692 | offset += file->f_pos; |
@@ -1697,7 +1694,6 @@ static loff_t configfs_dir_lseek(struct file *file, loff_t offset, int whence) | |||
1697 | if (offset >= 0) | 1694 | if (offset >= 0) |
1698 | break; | 1695 | break; |
1699 | default: | 1696 | default: |
1700 | inode_unlock(d_inode(dentry)); | ||
1701 | return -EINVAL; | 1697 | return -EINVAL; |
1702 | } | 1698 | } |
1703 | if (offset != file->f_pos) { | 1699 | if (offset != file->f_pos) { |
@@ -1723,7 +1719,6 @@ static loff_t configfs_dir_lseek(struct file *file, loff_t offset, int whence) | |||
1723 | spin_unlock(&configfs_dirent_lock); | 1719 | spin_unlock(&configfs_dirent_lock); |
1724 | } | 1720 | } |
1725 | } | 1721 | } |
1726 | inode_unlock(d_inode(dentry)); | ||
1727 | return offset; | 1722 | return offset; |
1728 | } | 1723 | } |
1729 | 1724 | ||
@@ -1732,7 +1727,7 @@ const struct file_operations configfs_dir_operations = { | |||
1732 | .release = configfs_dir_close, | 1727 | .release = configfs_dir_close, |
1733 | .llseek = configfs_dir_lseek, | 1728 | .llseek = configfs_dir_lseek, |
1734 | .read = generic_read_dir, | 1729 | .read = generic_read_dir, |
1735 | .iterate = configfs_readdir, | 1730 | .iterate_shared = configfs_readdir, |
1736 | }; | 1731 | }; |
1737 | 1732 | ||
1738 | /** | 1733 | /** |
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c index 03d124ae27d7..0387968e6f47 100644 --- a/fs/configfs/inode.c +++ b/fs/configfs/inode.c | |||
@@ -156,7 +156,7 @@ static void configfs_set_inode_lock_class(struct configfs_dirent *sd, | |||
156 | 156 | ||
157 | if (depth > 0) { | 157 | if (depth > 0) { |
158 | if (depth <= ARRAY_SIZE(default_group_class)) { | 158 | if (depth <= ARRAY_SIZE(default_group_class)) { |
159 | lockdep_set_class(&inode->i_mutex, | 159 | lockdep_set_class(&inode->i_rwsem, |
160 | &default_group_class[depth - 1]); | 160 | &default_group_class[depth - 1]); |
161 | } else { | 161 | } else { |
162 | /* | 162 | /* |
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index 3a32ddf98095..7919967488cb 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c | |||
@@ -561,7 +561,7 @@ static const struct address_space_operations cramfs_aops = { | |||
561 | static const struct file_operations cramfs_directory_operations = { | 561 | static const struct file_operations cramfs_directory_operations = { |
562 | .llseek = generic_file_llseek, | 562 | .llseek = generic_file_llseek, |
563 | .read = generic_read_dir, | 563 | .read = generic_read_dir, |
564 | .iterate = cramfs_readdir, | 564 | .iterate_shared = cramfs_readdir, |
565 | }; | 565 | }; |
566 | 566 | ||
567 | static const struct inode_operations cramfs_dir_inode_operations = { | 567 | static const struct inode_operations cramfs_dir_inode_operations = { |
diff --git a/fs/dcache.c b/fs/dcache.c index d5ecc6e477da..e49ba7d1b957 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -111,6 +111,17 @@ static inline struct hlist_bl_head *d_hash(const struct dentry *parent, | |||
111 | return dentry_hashtable + hash_32(hash, d_hash_shift); | 111 | return dentry_hashtable + hash_32(hash, d_hash_shift); |
112 | } | 112 | } |
113 | 113 | ||
114 | #define IN_LOOKUP_SHIFT 10 | ||
115 | static struct hlist_bl_head in_lookup_hashtable[1 << IN_LOOKUP_SHIFT]; | ||
116 | |||
117 | static inline struct hlist_bl_head *in_lookup_hash(const struct dentry *parent, | ||
118 | unsigned int hash) | ||
119 | { | ||
120 | hash += (unsigned long) parent / L1_CACHE_BYTES; | ||
121 | return in_lookup_hashtable + hash_32(hash, IN_LOOKUP_SHIFT); | ||
122 | } | ||
123 | |||
124 | |||
114 | /* Statistics gathering. */ | 125 | /* Statistics gathering. */ |
115 | struct dentry_stat_t dentry_stat = { | 126 | struct dentry_stat_t dentry_stat = { |
116 | .age_limit = 45, | 127 | .age_limit = 45, |
@@ -761,6 +772,8 @@ repeat: | |||
761 | /* Slow case: now with the dentry lock held */ | 772 | /* Slow case: now with the dentry lock held */ |
762 | rcu_read_unlock(); | 773 | rcu_read_unlock(); |
763 | 774 | ||
775 | WARN_ON(d_in_lookup(dentry)); | ||
776 | |||
764 | /* Unreachable? Get rid of it */ | 777 | /* Unreachable? Get rid of it */ |
765 | if (unlikely(d_unhashed(dentry))) | 778 | if (unlikely(d_unhashed(dentry))) |
766 | goto kill_it; | 779 | goto kill_it; |
@@ -1746,6 +1759,7 @@ type_determined: | |||
1746 | static void __d_instantiate(struct dentry *dentry, struct inode *inode) | 1759 | static void __d_instantiate(struct dentry *dentry, struct inode *inode) |
1747 | { | 1760 | { |
1748 | unsigned add_flags = d_flags_for_inode(inode); | 1761 | unsigned add_flags = d_flags_for_inode(inode); |
1762 | WARN_ON(d_in_lookup(dentry)); | ||
1749 | 1763 | ||
1750 | spin_lock(&dentry->d_lock); | 1764 | spin_lock(&dentry->d_lock); |
1751 | hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry); | 1765 | hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry); |
@@ -1775,11 +1789,11 @@ void d_instantiate(struct dentry *entry, struct inode * inode) | |||
1775 | { | 1789 | { |
1776 | BUG_ON(!hlist_unhashed(&entry->d_u.d_alias)); | 1790 | BUG_ON(!hlist_unhashed(&entry->d_u.d_alias)); |
1777 | if (inode) { | 1791 | if (inode) { |
1792 | security_d_instantiate(entry, inode); | ||
1778 | spin_lock(&inode->i_lock); | 1793 | spin_lock(&inode->i_lock); |
1779 | __d_instantiate(entry, inode); | 1794 | __d_instantiate(entry, inode); |
1780 | spin_unlock(&inode->i_lock); | 1795 | spin_unlock(&inode->i_lock); |
1781 | } | 1796 | } |
1782 | security_d_instantiate(entry, inode); | ||
1783 | } | 1797 | } |
1784 | EXPORT_SYMBOL(d_instantiate); | 1798 | EXPORT_SYMBOL(d_instantiate); |
1785 | 1799 | ||
@@ -1796,6 +1810,7 @@ int d_instantiate_no_diralias(struct dentry *entry, struct inode *inode) | |||
1796 | { | 1810 | { |
1797 | BUG_ON(!hlist_unhashed(&entry->d_u.d_alias)); | 1811 | BUG_ON(!hlist_unhashed(&entry->d_u.d_alias)); |
1798 | 1812 | ||
1813 | security_d_instantiate(entry, inode); | ||
1799 | spin_lock(&inode->i_lock); | 1814 | spin_lock(&inode->i_lock); |
1800 | if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry)) { | 1815 | if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry)) { |
1801 | spin_unlock(&inode->i_lock); | 1816 | spin_unlock(&inode->i_lock); |
@@ -1804,7 +1819,6 @@ int d_instantiate_no_diralias(struct dentry *entry, struct inode *inode) | |||
1804 | } | 1819 | } |
1805 | __d_instantiate(entry, inode); | 1820 | __d_instantiate(entry, inode); |
1806 | spin_unlock(&inode->i_lock); | 1821 | spin_unlock(&inode->i_lock); |
1807 | security_d_instantiate(entry, inode); | ||
1808 | 1822 | ||
1809 | return 0; | 1823 | return 0; |
1810 | } | 1824 | } |
@@ -1878,6 +1892,7 @@ static struct dentry *__d_obtain_alias(struct inode *inode, int disconnected) | |||
1878 | goto out_iput; | 1892 | goto out_iput; |
1879 | } | 1893 | } |
1880 | 1894 | ||
1895 | security_d_instantiate(tmp, inode); | ||
1881 | spin_lock(&inode->i_lock); | 1896 | spin_lock(&inode->i_lock); |
1882 | res = __d_find_any_alias(inode); | 1897 | res = __d_find_any_alias(inode); |
1883 | if (res) { | 1898 | if (res) { |
@@ -1900,13 +1915,10 @@ static struct dentry *__d_obtain_alias(struct inode *inode, int disconnected) | |||
1900 | hlist_bl_unlock(&tmp->d_sb->s_anon); | 1915 | hlist_bl_unlock(&tmp->d_sb->s_anon); |
1901 | spin_unlock(&tmp->d_lock); | 1916 | spin_unlock(&tmp->d_lock); |
1902 | spin_unlock(&inode->i_lock); | 1917 | spin_unlock(&inode->i_lock); |
1903 | security_d_instantiate(tmp, inode); | ||
1904 | 1918 | ||
1905 | return tmp; | 1919 | return tmp; |
1906 | 1920 | ||
1907 | out_iput: | 1921 | out_iput: |
1908 | if (res && !IS_ERR(res)) | ||
1909 | security_d_instantiate(res, inode); | ||
1910 | iput(inode); | 1922 | iput(inode); |
1911 | return res; | 1923 | return res; |
1912 | } | 1924 | } |
@@ -1975,28 +1987,36 @@ EXPORT_SYMBOL(d_obtain_root); | |||
1975 | struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, | 1987 | struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, |
1976 | struct qstr *name) | 1988 | struct qstr *name) |
1977 | { | 1989 | { |
1978 | struct dentry *found; | 1990 | struct dentry *found, *res; |
1979 | struct dentry *new; | ||
1980 | 1991 | ||
1981 | /* | 1992 | /* |
1982 | * First check if a dentry matching the name already exists, | 1993 | * First check if a dentry matching the name already exists, |
1983 | * if not go ahead and create it now. | 1994 | * if not go ahead and create it now. |
1984 | */ | 1995 | */ |
1985 | found = d_hash_and_lookup(dentry->d_parent, name); | 1996 | found = d_hash_and_lookup(dentry->d_parent, name); |
1986 | if (!found) { | 1997 | if (found) { |
1987 | new = d_alloc(dentry->d_parent, name); | 1998 | iput(inode); |
1988 | if (!new) { | 1999 | return found; |
1989 | found = ERR_PTR(-ENOMEM); | 2000 | } |
1990 | } else { | 2001 | if (d_in_lookup(dentry)) { |
1991 | found = d_splice_alias(inode, new); | 2002 | found = d_alloc_parallel(dentry->d_parent, name, |
1992 | if (found) { | 2003 | dentry->d_wait); |
1993 | dput(new); | 2004 | if (IS_ERR(found) || !d_in_lookup(found)) { |
1994 | return found; | 2005 | iput(inode); |
1995 | } | 2006 | return found; |
1996 | return new; | ||
1997 | } | 2007 | } |
2008 | } else { | ||
2009 | found = d_alloc(dentry->d_parent, name); | ||
2010 | if (!found) { | ||
2011 | iput(inode); | ||
2012 | return ERR_PTR(-ENOMEM); | ||
2013 | } | ||
2014 | } | ||
2015 | res = d_splice_alias(inode, found); | ||
2016 | if (res) { | ||
2017 | dput(found); | ||
2018 | return res; | ||
1998 | } | 2019 | } |
1999 | iput(inode); | ||
2000 | return found; | 2020 | return found; |
2001 | } | 2021 | } |
2002 | EXPORT_SYMBOL(d_add_ci); | 2022 | EXPORT_SYMBOL(d_add_ci); |
@@ -2363,17 +2383,194 @@ void d_rehash(struct dentry * entry) | |||
2363 | } | 2383 | } |
2364 | EXPORT_SYMBOL(d_rehash); | 2384 | EXPORT_SYMBOL(d_rehash); |
2365 | 2385 | ||
2386 | static inline unsigned start_dir_add(struct inode *dir) | ||
2387 | { | ||
2388 | |||
2389 | for (;;) { | ||
2390 | unsigned n = dir->i_dir_seq; | ||
2391 | if (!(n & 1) && cmpxchg(&dir->i_dir_seq, n, n + 1) == n) | ||
2392 | return n; | ||
2393 | cpu_relax(); | ||
2394 | } | ||
2395 | } | ||
2396 | |||
2397 | static inline void end_dir_add(struct inode *dir, unsigned n) | ||
2398 | { | ||
2399 | smp_store_release(&dir->i_dir_seq, n + 2); | ||
2400 | } | ||
2401 | |||
2402 | static void d_wait_lookup(struct dentry *dentry) | ||
2403 | { | ||
2404 | if (d_in_lookup(dentry)) { | ||
2405 | DECLARE_WAITQUEUE(wait, current); | ||
2406 | add_wait_queue(dentry->d_wait, &wait); | ||
2407 | do { | ||
2408 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
2409 | spin_unlock(&dentry->d_lock); | ||
2410 | schedule(); | ||
2411 | spin_lock(&dentry->d_lock); | ||
2412 | } while (d_in_lookup(dentry)); | ||
2413 | } | ||
2414 | } | ||
2415 | |||
2416 | struct dentry *d_alloc_parallel(struct dentry *parent, | ||
2417 | const struct qstr *name, | ||
2418 | wait_queue_head_t *wq) | ||
2419 | { | ||
2420 | unsigned int len = name->len; | ||
2421 | unsigned int hash = name->hash; | ||
2422 | const unsigned char *str = name->name; | ||
2423 | struct hlist_bl_head *b = in_lookup_hash(parent, hash); | ||
2424 | struct hlist_bl_node *node; | ||
2425 | struct dentry *new = d_alloc(parent, name); | ||
2426 | struct dentry *dentry; | ||
2427 | unsigned seq, r_seq, d_seq; | ||
2428 | |||
2429 | if (unlikely(!new)) | ||
2430 | return ERR_PTR(-ENOMEM); | ||
2431 | |||
2432 | retry: | ||
2433 | rcu_read_lock(); | ||
2434 | seq = smp_load_acquire(&parent->d_inode->i_dir_seq) & ~1; | ||
2435 | r_seq = read_seqbegin(&rename_lock); | ||
2436 | dentry = __d_lookup_rcu(parent, name, &d_seq); | ||
2437 | if (unlikely(dentry)) { | ||
2438 | if (!lockref_get_not_dead(&dentry->d_lockref)) { | ||
2439 | rcu_read_unlock(); | ||
2440 | goto retry; | ||
2441 | } | ||
2442 | if (read_seqcount_retry(&dentry->d_seq, d_seq)) { | ||
2443 | rcu_read_unlock(); | ||
2444 | dput(dentry); | ||
2445 | goto retry; | ||
2446 | } | ||
2447 | rcu_read_unlock(); | ||
2448 | dput(new); | ||
2449 | return dentry; | ||
2450 | } | ||
2451 | if (unlikely(read_seqretry(&rename_lock, r_seq))) { | ||
2452 | rcu_read_unlock(); | ||
2453 | goto retry; | ||
2454 | } | ||
2455 | hlist_bl_lock(b); | ||
2456 | if (unlikely(parent->d_inode->i_dir_seq != seq)) { | ||
2457 | hlist_bl_unlock(b); | ||
2458 | rcu_read_unlock(); | ||
2459 | goto retry; | ||
2460 | } | ||
2461 | rcu_read_unlock(); | ||
2462 | /* | ||
2463 | * No changes for the parent since the beginning of d_lookup(). | ||
2464 | * Since all removals from the chain happen with hlist_bl_lock(), | ||
2465 | * any potential in-lookup matches are going to stay here until | ||
2466 | * we unlock the chain. All fields are stable in everything | ||
2467 | * we encounter. | ||
2468 | */ | ||
2469 | hlist_bl_for_each_entry(dentry, node, b, d_u.d_in_lookup_hash) { | ||
2470 | if (dentry->d_name.hash != hash) | ||
2471 | continue; | ||
2472 | if (dentry->d_parent != parent) | ||
2473 | continue; | ||
2474 | if (d_unhashed(dentry)) | ||
2475 | continue; | ||
2476 | if (parent->d_flags & DCACHE_OP_COMPARE) { | ||
2477 | int tlen = dentry->d_name.len; | ||
2478 | const char *tname = dentry->d_name.name; | ||
2479 | if (parent->d_op->d_compare(parent, dentry, tlen, tname, name)) | ||
2480 | continue; | ||
2481 | } else { | ||
2482 | if (dentry->d_name.len != len) | ||
2483 | continue; | ||
2484 | if (dentry_cmp(dentry, str, len)) | ||
2485 | continue; | ||
2486 | } | ||
2487 | dget(dentry); | ||
2488 | hlist_bl_unlock(b); | ||
2489 | /* somebody is doing lookup for it right now; wait for it */ | ||
2490 | spin_lock(&dentry->d_lock); | ||
2491 | d_wait_lookup(dentry); | ||
2492 | /* | ||
2493 | * it's not in-lookup anymore; in principle we should repeat | ||
2494 | * everything from dcache lookup, but it's likely to be what | ||
2495 | * d_lookup() would've found anyway. If it is, just return it; | ||
2496 | * otherwise we really have to repeat the whole thing. | ||
2497 | */ | ||
2498 | if (unlikely(dentry->d_name.hash != hash)) | ||
2499 | goto mismatch; | ||
2500 | if (unlikely(dentry->d_parent != parent)) | ||
2501 | goto mismatch; | ||
2502 | if (unlikely(d_unhashed(dentry))) | ||
2503 | goto mismatch; | ||
2504 | if (parent->d_flags & DCACHE_OP_COMPARE) { | ||
2505 | int tlen = dentry->d_name.len; | ||
2506 | const char *tname = dentry->d_name.name; | ||
2507 | if (parent->d_op->d_compare(parent, dentry, tlen, tname, name)) | ||
2508 | goto mismatch; | ||
2509 | } else { | ||
2510 | if (unlikely(dentry->d_name.len != len)) | ||
2511 | goto mismatch; | ||
2512 | if (unlikely(dentry_cmp(dentry, str, len))) | ||
2513 | goto mismatch; | ||
2514 | } | ||
2515 | /* OK, it *is* a hashed match; return it */ | ||
2516 | spin_unlock(&dentry->d_lock); | ||
2517 | dput(new); | ||
2518 | return dentry; | ||
2519 | } | ||
2520 | /* we can't take ->d_lock here; it's OK, though. */ | ||
2521 | new->d_flags |= DCACHE_PAR_LOOKUP; | ||
2522 | new->d_wait = wq; | ||
2523 | hlist_bl_add_head_rcu(&new->d_u.d_in_lookup_hash, b); | ||
2524 | hlist_bl_unlock(b); | ||
2525 | return new; | ||
2526 | mismatch: | ||
2527 | spin_unlock(&dentry->d_lock); | ||
2528 | dput(dentry); | ||
2529 | goto retry; | ||
2530 | } | ||
2531 | EXPORT_SYMBOL(d_alloc_parallel); | ||
2532 | |||
2533 | void __d_lookup_done(struct dentry *dentry) | ||
2534 | { | ||
2535 | struct hlist_bl_head *b = in_lookup_hash(dentry->d_parent, | ||
2536 | dentry->d_name.hash); | ||
2537 | hlist_bl_lock(b); | ||
2538 | dentry->d_flags &= ~DCACHE_PAR_LOOKUP; | ||
2539 | __hlist_bl_del(&dentry->d_u.d_in_lookup_hash); | ||
2540 | wake_up_all(dentry->d_wait); | ||
2541 | dentry->d_wait = NULL; | ||
2542 | hlist_bl_unlock(b); | ||
2543 | INIT_HLIST_NODE(&dentry->d_u.d_alias); | ||
2544 | INIT_LIST_HEAD(&dentry->d_lru); | ||
2545 | } | ||
2546 | EXPORT_SYMBOL(__d_lookup_done); | ||
2366 | 2547 | ||
2367 | /* inode->i_lock held if inode is non-NULL */ | 2548 | /* inode->i_lock held if inode is non-NULL */ |
2368 | 2549 | ||
2369 | static inline void __d_add(struct dentry *dentry, struct inode *inode) | 2550 | static inline void __d_add(struct dentry *dentry, struct inode *inode) |
2370 | { | 2551 | { |
2552 | struct inode *dir = NULL; | ||
2553 | unsigned n; | ||
2554 | spin_lock(&dentry->d_lock); | ||
2555 | if (unlikely(d_in_lookup(dentry))) { | ||
2556 | dir = dentry->d_parent->d_inode; | ||
2557 | n = start_dir_add(dir); | ||
2558 | __d_lookup_done(dentry); | ||
2559 | } | ||
2371 | if (inode) { | 2560 | if (inode) { |
2372 | __d_instantiate(dentry, inode); | 2561 | unsigned add_flags = d_flags_for_inode(inode); |
2562 | hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry); | ||
2563 | raw_write_seqcount_begin(&dentry->d_seq); | ||
2564 | __d_set_inode_and_type(dentry, inode, add_flags); | ||
2565 | raw_write_seqcount_end(&dentry->d_seq); | ||
2566 | __fsnotify_d_instantiate(dentry); | ||
2567 | } | ||
2568 | _d_rehash(dentry); | ||
2569 | if (dir) | ||
2570 | end_dir_add(dir, n); | ||
2571 | spin_unlock(&dentry->d_lock); | ||
2572 | if (inode) | ||
2373 | spin_unlock(&inode->i_lock); | 2573 | spin_unlock(&inode->i_lock); |
2374 | } | ||
2375 | security_d_instantiate(dentry, inode); | ||
2376 | d_rehash(dentry); | ||
2377 | } | 2574 | } |
2378 | 2575 | ||
2379 | /** | 2576 | /** |
@@ -2387,8 +2584,10 @@ static inline void __d_add(struct dentry *dentry, struct inode *inode) | |||
2387 | 2584 | ||
2388 | void d_add(struct dentry *entry, struct inode *inode) | 2585 | void d_add(struct dentry *entry, struct inode *inode) |
2389 | { | 2586 | { |
2390 | if (inode) | 2587 | if (inode) { |
2588 | security_d_instantiate(entry, inode); | ||
2391 | spin_lock(&inode->i_lock); | 2589 | spin_lock(&inode->i_lock); |
2590 | } | ||
2392 | __d_add(entry, inode); | 2591 | __d_add(entry, inode); |
2393 | } | 2592 | } |
2394 | EXPORT_SYMBOL(d_add); | 2593 | EXPORT_SYMBOL(d_add); |
@@ -2598,6 +2797,8 @@ static void dentry_unlock_for_move(struct dentry *dentry, struct dentry *target) | |||
2598 | static void __d_move(struct dentry *dentry, struct dentry *target, | 2797 | static void __d_move(struct dentry *dentry, struct dentry *target, |
2599 | bool exchange) | 2798 | bool exchange) |
2600 | { | 2799 | { |
2800 | struct inode *dir = NULL; | ||
2801 | unsigned n; | ||
2601 | if (!dentry->d_inode) | 2802 | if (!dentry->d_inode) |
2602 | printk(KERN_WARNING "VFS: moving negative dcache entry\n"); | 2803 | printk(KERN_WARNING "VFS: moving negative dcache entry\n"); |
2603 | 2804 | ||
@@ -2605,6 +2806,11 @@ static void __d_move(struct dentry *dentry, struct dentry *target, | |||
2605 | BUG_ON(d_ancestor(target, dentry)); | 2806 | BUG_ON(d_ancestor(target, dentry)); |
2606 | 2807 | ||
2607 | dentry_lock_for_move(dentry, target); | 2808 | dentry_lock_for_move(dentry, target); |
2809 | if (unlikely(d_in_lookup(target))) { | ||
2810 | dir = target->d_parent->d_inode; | ||
2811 | n = start_dir_add(dir); | ||
2812 | __d_lookup_done(target); | ||
2813 | } | ||
2608 | 2814 | ||
2609 | write_seqcount_begin(&dentry->d_seq); | 2815 | write_seqcount_begin(&dentry->d_seq); |
2610 | write_seqcount_begin_nested(&target->d_seq, DENTRY_D_LOCK_NESTED); | 2816 | write_seqcount_begin_nested(&target->d_seq, DENTRY_D_LOCK_NESTED); |
@@ -2654,6 +2860,8 @@ static void __d_move(struct dentry *dentry, struct dentry *target, | |||
2654 | write_seqcount_end(&target->d_seq); | 2860 | write_seqcount_end(&target->d_seq); |
2655 | write_seqcount_end(&dentry->d_seq); | 2861 | write_seqcount_end(&dentry->d_seq); |
2656 | 2862 | ||
2863 | if (dir) | ||
2864 | end_dir_add(dir, n); | ||
2657 | dentry_unlock_for_move(dentry, target); | 2865 | dentry_unlock_for_move(dentry, target); |
2658 | } | 2866 | } |
2659 | 2867 | ||
@@ -2724,7 +2932,8 @@ struct dentry *d_ancestor(struct dentry *p1, struct dentry *p2) | |||
2724 | static int __d_unalias(struct inode *inode, | 2932 | static int __d_unalias(struct inode *inode, |
2725 | struct dentry *dentry, struct dentry *alias) | 2933 | struct dentry *dentry, struct dentry *alias) |
2726 | { | 2934 | { |
2727 | struct mutex *m1 = NULL, *m2 = NULL; | 2935 | struct mutex *m1 = NULL; |
2936 | struct rw_semaphore *m2 = NULL; | ||
2728 | int ret = -ESTALE; | 2937 | int ret = -ESTALE; |
2729 | 2938 | ||
2730 | /* If alias and dentry share a parent, then no extra locks required */ | 2939 | /* If alias and dentry share a parent, then no extra locks required */ |
@@ -2735,15 +2944,15 @@ static int __d_unalias(struct inode *inode, | |||
2735 | if (!mutex_trylock(&dentry->d_sb->s_vfs_rename_mutex)) | 2944 | if (!mutex_trylock(&dentry->d_sb->s_vfs_rename_mutex)) |
2736 | goto out_err; | 2945 | goto out_err; |
2737 | m1 = &dentry->d_sb->s_vfs_rename_mutex; | 2946 | m1 = &dentry->d_sb->s_vfs_rename_mutex; |
2738 | if (!inode_trylock(alias->d_parent->d_inode)) | 2947 | if (!inode_trylock_shared(alias->d_parent->d_inode)) |
2739 | goto out_err; | 2948 | goto out_err; |
2740 | m2 = &alias->d_parent->d_inode->i_mutex; | 2949 | m2 = &alias->d_parent->d_inode->i_rwsem; |
2741 | out_unalias: | 2950 | out_unalias: |
2742 | __d_move(alias, dentry, false); | 2951 | __d_move(alias, dentry, false); |
2743 | ret = 0; | 2952 | ret = 0; |
2744 | out_err: | 2953 | out_err: |
2745 | if (m2) | 2954 | if (m2) |
2746 | mutex_unlock(m2); | 2955 | up_read(m2); |
2747 | if (m1) | 2956 | if (m1) |
2748 | mutex_unlock(m1); | 2957 | mutex_unlock(m1); |
2749 | return ret; | 2958 | return ret; |
@@ -2782,6 +2991,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) | |||
2782 | if (!inode) | 2991 | if (!inode) |
2783 | goto out; | 2992 | goto out; |
2784 | 2993 | ||
2994 | security_d_instantiate(dentry, inode); | ||
2785 | spin_lock(&inode->i_lock); | 2995 | spin_lock(&inode->i_lock); |
2786 | if (S_ISDIR(inode->i_mode)) { | 2996 | if (S_ISDIR(inode->i_mode)) { |
2787 | struct dentry *new = __d_find_any_alias(inode); | 2997 | struct dentry *new = __d_find_any_alias(inode); |
@@ -2809,7 +3019,6 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) | |||
2809 | } else { | 3019 | } else { |
2810 | __d_move(new, dentry, false); | 3020 | __d_move(new, dentry, false); |
2811 | write_sequnlock(&rename_lock); | 3021 | write_sequnlock(&rename_lock); |
2812 | security_d_instantiate(new, inode); | ||
2813 | } | 3022 | } |
2814 | iput(inode); | 3023 | iput(inode); |
2815 | return new; | 3024 | return new; |
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index 9b4713c25db7..ebd40f46ed4c 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
@@ -1369,7 +1369,9 @@ int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode) | |||
1369 | ssize_t size; | 1369 | ssize_t size; |
1370 | int rc = 0; | 1370 | int rc = 0; |
1371 | 1371 | ||
1372 | size = ecryptfs_getxattr_lower(lower_dentry, ECRYPTFS_XATTR_NAME, | 1372 | size = ecryptfs_getxattr_lower(lower_dentry, |
1373 | ecryptfs_inode_to_lower(ecryptfs_inode), | ||
1374 | ECRYPTFS_XATTR_NAME, | ||
1373 | page_virt, ECRYPTFS_DEFAULT_EXTENT_SIZE); | 1375 | page_virt, ECRYPTFS_DEFAULT_EXTENT_SIZE); |
1374 | if (size < 0) { | 1376 | if (size < 0) { |
1375 | if (unlikely(ecryptfs_verbosity > 0)) | 1377 | if (unlikely(ecryptfs_verbosity > 0)) |
@@ -1391,6 +1393,7 @@ int ecryptfs_read_and_validate_xattr_region(struct dentry *dentry, | |||
1391 | int rc; | 1393 | int rc; |
1392 | 1394 | ||
1393 | rc = ecryptfs_getxattr_lower(ecryptfs_dentry_to_lower(dentry), | 1395 | rc = ecryptfs_getxattr_lower(ecryptfs_dentry_to_lower(dentry), |
1396 | ecryptfs_inode_to_lower(inode), | ||
1394 | ECRYPTFS_XATTR_NAME, file_size, | 1397 | ECRYPTFS_XATTR_NAME, file_size, |
1395 | ECRYPTFS_SIZE_AND_MARKER_BYTES); | 1398 | ECRYPTFS_SIZE_AND_MARKER_BYTES); |
1396 | if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES) | 1399 | if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES) |
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index c7761a91cc2c..3ec495db7e82 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h | |||
@@ -606,8 +606,8 @@ ecryptfs_parse_packet_set(struct ecryptfs_crypt_stat *crypt_stat, | |||
606 | unsigned char *src, struct dentry *ecryptfs_dentry); | 606 | unsigned char *src, struct dentry *ecryptfs_dentry); |
607 | int ecryptfs_truncate(struct dentry *dentry, loff_t new_length); | 607 | int ecryptfs_truncate(struct dentry *dentry, loff_t new_length); |
608 | ssize_t | 608 | ssize_t |
609 | ecryptfs_getxattr_lower(struct dentry *lower_dentry, const char *name, | 609 | ecryptfs_getxattr_lower(struct dentry *lower_dentry, struct inode *lower_inode, |
610 | void *value, size_t size); | 610 | const char *name, void *value, size_t size); |
611 | int | 611 | int |
612 | ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, | 612 | ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, |
613 | size_t size, int flags); | 613 | size_t size, int flags); |
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index f02404052b7b..7000b96b783e 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
@@ -383,7 +383,7 @@ ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
383 | #endif | 383 | #endif |
384 | 384 | ||
385 | const struct file_operations ecryptfs_dir_fops = { | 385 | const struct file_operations ecryptfs_dir_fops = { |
386 | .iterate = ecryptfs_readdir, | 386 | .iterate_shared = ecryptfs_readdir, |
387 | .read = generic_read_dir, | 387 | .read = generic_read_dir, |
388 | .unlocked_ioctl = ecryptfs_unlocked_ioctl, | 388 | .unlocked_ioctl = ecryptfs_unlocked_ioctl, |
389 | #ifdef CONFIG_COMPAT | 389 | #ifdef CONFIG_COMPAT |
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 3ce01dd4a371..9b022e906660 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -1036,29 +1036,30 @@ out: | |||
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | ssize_t | 1038 | ssize_t |
1039 | ecryptfs_getxattr_lower(struct dentry *lower_dentry, const char *name, | 1039 | ecryptfs_getxattr_lower(struct dentry *lower_dentry, struct inode *lower_inode, |
1040 | void *value, size_t size) | 1040 | const char *name, void *value, size_t size) |
1041 | { | 1041 | { |
1042 | int rc = 0; | 1042 | int rc = 0; |
1043 | 1043 | ||
1044 | if (!d_inode(lower_dentry)->i_op->getxattr) { | 1044 | if (!lower_inode->i_op->getxattr) { |
1045 | rc = -EOPNOTSUPP; | 1045 | rc = -EOPNOTSUPP; |
1046 | goto out; | 1046 | goto out; |
1047 | } | 1047 | } |
1048 | inode_lock(d_inode(lower_dentry)); | 1048 | inode_lock(lower_inode); |
1049 | rc = d_inode(lower_dentry)->i_op->getxattr(lower_dentry, name, value, | 1049 | rc = lower_inode->i_op->getxattr(lower_dentry, lower_inode, |
1050 | size); | 1050 | name, value, size); |
1051 | inode_unlock(d_inode(lower_dentry)); | 1051 | inode_unlock(lower_inode); |
1052 | out: | 1052 | out: |
1053 | return rc; | 1053 | return rc; |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | static ssize_t | 1056 | static ssize_t |
1057 | ecryptfs_getxattr(struct dentry *dentry, const char *name, void *value, | 1057 | ecryptfs_getxattr(struct dentry *dentry, struct inode *inode, |
1058 | size_t size) | 1058 | const char *name, void *value, size_t size) |
1059 | { | 1059 | { |
1060 | return ecryptfs_getxattr_lower(ecryptfs_dentry_to_lower(dentry), name, | 1060 | return ecryptfs_getxattr_lower(ecryptfs_dentry_to_lower(dentry), |
1061 | value, size); | 1061 | ecryptfs_inode_to_lower(inode), |
1062 | name, value, size); | ||
1062 | } | 1063 | } |
1063 | 1064 | ||
1064 | static ssize_t | 1065 | static ssize_t |
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index e6b1d80952b9..148d11b514fb 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c | |||
@@ -436,7 +436,8 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode) | |||
436 | goto out; | 436 | goto out; |
437 | } | 437 | } |
438 | inode_lock(lower_inode); | 438 | inode_lock(lower_inode); |
439 | size = lower_inode->i_op->getxattr(lower_dentry, ECRYPTFS_XATTR_NAME, | 439 | size = lower_inode->i_op->getxattr(lower_dentry, lower_inode, |
440 | ECRYPTFS_XATTR_NAME, | ||
440 | xattr_virt, PAGE_SIZE); | 441 | xattr_virt, PAGE_SIZE); |
441 | if (size < 0) | 442 | if (size < 0) |
442 | size = 8; | 443 | size = 8; |
diff --git a/fs/efs/dir.c b/fs/efs/dir.c index ce63b24f7c3e..a7be96e5f1cb 100644 --- a/fs/efs/dir.c +++ b/fs/efs/dir.c | |||
@@ -12,7 +12,7 @@ static int efs_readdir(struct file *, struct dir_context *); | |||
12 | const struct file_operations efs_dir_operations = { | 12 | const struct file_operations efs_dir_operations = { |
13 | .llseek = generic_file_llseek, | 13 | .llseek = generic_file_llseek, |
14 | .read = generic_read_dir, | 14 | .read = generic_read_dir, |
15 | .iterate = efs_readdir, | 15 | .iterate_shared = efs_readdir, |
16 | }; | 16 | }; |
17 | 17 | ||
18 | const struct inode_operations efs_dir_inode_operations = { | 18 | const struct inode_operations efs_dir_inode_operations = { |
@@ -100,4 +100,3 @@ static int efs_readdir(struct file *file, struct dir_context *ctx) | |||
100 | ctx->pos = (block << EFS_DIRBSIZE_BITS) | slot; | 100 | ctx->pos = (block << EFS_DIRBSIZE_BITS) | slot; |
101 | return 0; | 101 | return 0; |
102 | } | 102 | } |
103 | |||
diff --git a/fs/efs/namei.c b/fs/efs/namei.c index 40ba9cc41bf7..d34a40edcdb2 100644 --- a/fs/efs/namei.c +++ b/fs/efs/namei.c | |||
@@ -113,7 +113,7 @@ struct dentry *efs_get_parent(struct dentry *child) | |||
113 | 113 | ||
114 | ino = efs_find_entry(d_inode(child), "..", 2); | 114 | ino = efs_find_entry(d_inode(child), "..", 2); |
115 | if (ino) | 115 | if (ino) |
116 | parent = d_obtain_alias(efs_iget(d_inode(child)->i_sb, ino)); | 116 | parent = d_obtain_alias(efs_iget(child->d_sb, ino)); |
117 | 117 | ||
118 | return parent; | 118 | return parent; |
119 | } | 119 | } |
diff --git a/fs/exofs/dir.c b/fs/exofs/dir.c index 547b93cbea63..f69a1b5826a5 100644 --- a/fs/exofs/dir.c +++ b/fs/exofs/dir.c | |||
@@ -79,7 +79,7 @@ static int exofs_commit_chunk(struct page *page, loff_t pos, unsigned len) | |||
79 | return err; | 79 | return err; |
80 | } | 80 | } |
81 | 81 | ||
82 | static void exofs_check_page(struct page *page) | 82 | static bool exofs_check_page(struct page *page) |
83 | { | 83 | { |
84 | struct inode *dir = page->mapping->host; | 84 | struct inode *dir = page->mapping->host; |
85 | unsigned chunk_size = exofs_chunk_size(dir); | 85 | unsigned chunk_size = exofs_chunk_size(dir); |
@@ -114,7 +114,7 @@ static void exofs_check_page(struct page *page) | |||
114 | goto Eend; | 114 | goto Eend; |
115 | out: | 115 | out: |
116 | SetPageChecked(page); | 116 | SetPageChecked(page); |
117 | return; | 117 | return true; |
118 | 118 | ||
119 | Ebadsize: | 119 | Ebadsize: |
120 | EXOFS_ERR("ERROR [exofs_check_page]: " | 120 | EXOFS_ERR("ERROR [exofs_check_page]: " |
@@ -150,8 +150,8 @@ Eend: | |||
150 | dir->i_ino, (page->index<<PAGE_SHIFT)+offs, | 150 | dir->i_ino, (page->index<<PAGE_SHIFT)+offs, |
151 | _LLU(le64_to_cpu(p->inode_no))); | 151 | _LLU(le64_to_cpu(p->inode_no))); |
152 | fail: | 152 | fail: |
153 | SetPageChecked(page); | ||
154 | SetPageError(page); | 153 | SetPageError(page); |
154 | return false; | ||
155 | } | 155 | } |
156 | 156 | ||
157 | static struct page *exofs_get_page(struct inode *dir, unsigned long n) | 157 | static struct page *exofs_get_page(struct inode *dir, unsigned long n) |
@@ -161,10 +161,10 @@ static struct page *exofs_get_page(struct inode *dir, unsigned long n) | |||
161 | 161 | ||
162 | if (!IS_ERR(page)) { | 162 | if (!IS_ERR(page)) { |
163 | kmap(page); | 163 | kmap(page); |
164 | if (!PageChecked(page)) | 164 | if (unlikely(!PageChecked(page))) { |
165 | exofs_check_page(page); | 165 | if (PageError(page) || !exofs_check_page(page)) |
166 | if (PageError(page)) | 166 | goto fail; |
167 | goto fail; | 167 | } |
168 | } | 168 | } |
169 | return page; | 169 | return page; |
170 | 170 | ||
@@ -657,5 +657,5 @@ not_empty: | |||
657 | const struct file_operations exofs_dir_operations = { | 657 | const struct file_operations exofs_dir_operations = { |
658 | .llseek = generic_file_llseek, | 658 | .llseek = generic_file_llseek, |
659 | .read = generic_read_dir, | 659 | .read = generic_read_dir, |
660 | .iterate = exofs_readdir, | 660 | .iterate_shared = exofs_readdir, |
661 | }; | 661 | }; |
diff --git a/fs/exofs/super.c b/fs/exofs/super.c index 6658a50530a0..192373653dfb 100644 --- a/fs/exofs/super.c +++ b/fs/exofs/super.c | |||
@@ -958,7 +958,7 @@ static struct dentry *exofs_get_parent(struct dentry *child) | |||
958 | if (!ino) | 958 | if (!ino) |
959 | return ERR_PTR(-ESTALE); | 959 | return ERR_PTR(-ESTALE); |
960 | 960 | ||
961 | return d_obtain_alias(exofs_iget(d_inode(child)->i_sb, ino)); | 961 | return d_obtain_alias(exofs_iget(child->d_sb, ino)); |
962 | } | 962 | } |
963 | 963 | ||
964 | static struct inode *exofs_nfs_get_inode(struct super_block *sb, | 964 | static struct inode *exofs_nfs_get_inode(struct super_block *sb, |
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c index c46f1a190b8d..207ba8d627ca 100644 --- a/fs/exportfs/expfs.c +++ b/fs/exportfs/expfs.c | |||
@@ -143,14 +143,18 @@ static struct dentry *reconnect_one(struct vfsmount *mnt, | |||
143 | if (err) | 143 | if (err) |
144 | goto out_err; | 144 | goto out_err; |
145 | dprintk("%s: found name: %s\n", __func__, nbuf); | 145 | dprintk("%s: found name: %s\n", __func__, nbuf); |
146 | inode_lock(parent->d_inode); | 146 | tmp = lookup_one_len_unlocked(nbuf, parent, strlen(nbuf)); |
147 | tmp = lookup_one_len(nbuf, parent, strlen(nbuf)); | ||
148 | inode_unlock(parent->d_inode); | ||
149 | if (IS_ERR(tmp)) { | 147 | if (IS_ERR(tmp)) { |
150 | dprintk("%s: lookup failed: %d\n", __func__, PTR_ERR(tmp)); | 148 | dprintk("%s: lookup failed: %d\n", __func__, PTR_ERR(tmp)); |
151 | goto out_err; | 149 | goto out_err; |
152 | } | 150 | } |
153 | if (tmp != dentry) { | 151 | if (tmp != dentry) { |
152 | /* | ||
153 | * Somebody has renamed it since exportfs_get_name(); | ||
154 | * great, since it could've only been renamed if it | ||
155 | * got looked up and thus connected, and it would | ||
156 | * remain connected afterwards. We are done. | ||
157 | */ | ||
154 | dput(tmp); | 158 | dput(tmp); |
155 | goto out_reconnected; | 159 | goto out_reconnected; |
156 | } | 160 | } |
@@ -308,7 +312,7 @@ static int get_name(const struct path *path, char *name, struct dentry *child) | |||
308 | goto out; | 312 | goto out; |
309 | 313 | ||
310 | error = -EINVAL; | 314 | error = -EINVAL; |
311 | if (!file->f_op->iterate) | 315 | if (!file->f_op->iterate && !file->f_op->iterate_shared) |
312 | goto out_close; | 316 | goto out_close; |
313 | 317 | ||
314 | buffer.sequence = 0; | 318 | buffer.sequence = 0; |
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c index 27695e6f4e46..42f1d1814083 100644 --- a/fs/ext2/acl.c +++ b/fs/ext2/acl.c | |||
@@ -172,9 +172,6 @@ ext2_get_acl(struct inode *inode, int type) | |||
172 | acl = ERR_PTR(retval); | 172 | acl = ERR_PTR(retval); |
173 | kfree(value); | 173 | kfree(value); |
174 | 174 | ||
175 | if (!IS_ERR(acl)) | ||
176 | set_cached_acl(inode, type, acl); | ||
177 | |||
178 | return acl; | 175 | return acl; |
179 | } | 176 | } |
180 | 177 | ||
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index 7ff6fcfa685d..19efd1197fa5 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c | |||
@@ -110,7 +110,7 @@ static int ext2_commit_chunk(struct page *page, loff_t pos, unsigned len) | |||
110 | return err; | 110 | return err; |
111 | } | 111 | } |
112 | 112 | ||
113 | static void ext2_check_page(struct page *page, int quiet) | 113 | static bool ext2_check_page(struct page *page, int quiet) |
114 | { | 114 | { |
115 | struct inode *dir = page->mapping->host; | 115 | struct inode *dir = page->mapping->host; |
116 | struct super_block *sb = dir->i_sb; | 116 | struct super_block *sb = dir->i_sb; |
@@ -148,7 +148,7 @@ static void ext2_check_page(struct page *page, int quiet) | |||
148 | goto Eend; | 148 | goto Eend; |
149 | out: | 149 | out: |
150 | SetPageChecked(page); | 150 | SetPageChecked(page); |
151 | return; | 151 | return true; |
152 | 152 | ||
153 | /* Too bad, we had an error */ | 153 | /* Too bad, we had an error */ |
154 | 154 | ||
@@ -190,8 +190,8 @@ Eend: | |||
190 | (unsigned long) le32_to_cpu(p->inode)); | 190 | (unsigned long) le32_to_cpu(p->inode)); |
191 | } | 191 | } |
192 | fail: | 192 | fail: |
193 | SetPageChecked(page); | ||
194 | SetPageError(page); | 193 | SetPageError(page); |
194 | return false; | ||
195 | } | 195 | } |
196 | 196 | ||
197 | static struct page * ext2_get_page(struct inode *dir, unsigned long n, | 197 | static struct page * ext2_get_page(struct inode *dir, unsigned long n, |
@@ -201,10 +201,10 @@ static struct page * ext2_get_page(struct inode *dir, unsigned long n, | |||
201 | struct page *page = read_mapping_page(mapping, n, NULL); | 201 | struct page *page = read_mapping_page(mapping, n, NULL); |
202 | if (!IS_ERR(page)) { | 202 | if (!IS_ERR(page)) { |
203 | kmap(page); | 203 | kmap(page); |
204 | if (!PageChecked(page)) | 204 | if (unlikely(!PageChecked(page))) { |
205 | ext2_check_page(page, quiet); | 205 | if (PageError(page) || !ext2_check_page(page, quiet)) |
206 | if (PageError(page)) | 206 | goto fail; |
207 | goto fail; | 207 | } |
208 | } | 208 | } |
209 | return page; | 209 | return page; |
210 | 210 | ||
@@ -716,7 +716,7 @@ not_empty: | |||
716 | const struct file_operations ext2_dir_operations = { | 716 | const struct file_operations ext2_dir_operations = { |
717 | .llseek = generic_file_llseek, | 717 | .llseek = generic_file_llseek, |
718 | .read = generic_read_dir, | 718 | .read = generic_read_dir, |
719 | .iterate = ext2_readdir, | 719 | .iterate_shared = ext2_readdir, |
720 | .unlocked_ioctl = ext2_ioctl, | 720 | .unlocked_ioctl = ext2_ioctl, |
721 | #ifdef CONFIG_COMPAT | 721 | #ifdef CONFIG_COMPAT |
722 | .compat_ioctl = ext2_compat_ioctl, | 722 | .compat_ioctl = ext2_compat_ioctl, |
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index d34843925b23..d446203127fc 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c | |||
@@ -82,7 +82,7 @@ struct dentry *ext2_get_parent(struct dentry *child) | |||
82 | unsigned long ino = ext2_inode_by_name(d_inode(child), &dotdot); | 82 | unsigned long ino = ext2_inode_by_name(d_inode(child), &dotdot); |
83 | if (!ino) | 83 | if (!ino) |
84 | return ERR_PTR(-ENOENT); | 84 | return ERR_PTR(-ENOENT); |
85 | return d_obtain_alias(ext2_iget(d_inode(child)->i_sb, ino)); | 85 | return d_obtain_alias(ext2_iget(child->d_sb, ino)); |
86 | } | 86 | } |
87 | 87 | ||
88 | /* | 88 | /* |
diff --git a/fs/ext2/xattr_security.c b/fs/ext2/xattr_security.c index ba97f243b050..7fd3b867ce65 100644 --- a/fs/ext2/xattr_security.c +++ b/fs/ext2/xattr_security.c | |||
@@ -9,10 +9,10 @@ | |||
9 | 9 | ||
10 | static int | 10 | static int |
11 | ext2_xattr_security_get(const struct xattr_handler *handler, | 11 | ext2_xattr_security_get(const struct xattr_handler *handler, |
12 | struct dentry *dentry, const char *name, | 12 | struct dentry *unused, struct inode *inode, |
13 | void *buffer, size_t size) | 13 | const char *name, void *buffer, size_t size) |
14 | { | 14 | { |
15 | return ext2_xattr_get(d_inode(dentry), EXT2_XATTR_INDEX_SECURITY, name, | 15 | return ext2_xattr_get(inode, EXT2_XATTR_INDEX_SECURITY, name, |
16 | buffer, size); | 16 | buffer, size); |
17 | } | 17 | } |
18 | 18 | ||
diff --git a/fs/ext2/xattr_trusted.c b/fs/ext2/xattr_trusted.c index 2c94d1930626..0f85705ff519 100644 --- a/fs/ext2/xattr_trusted.c +++ b/fs/ext2/xattr_trusted.c | |||
@@ -16,10 +16,10 @@ ext2_xattr_trusted_list(struct dentry *dentry) | |||
16 | 16 | ||
17 | static int | 17 | static int |
18 | ext2_xattr_trusted_get(const struct xattr_handler *handler, | 18 | ext2_xattr_trusted_get(const struct xattr_handler *handler, |
19 | struct dentry *dentry, const char *name, | 19 | struct dentry *unused, struct inode *inode, |
20 | void *buffer, size_t size) | 20 | const char *name, void *buffer, size_t size) |
21 | { | 21 | { |
22 | return ext2_xattr_get(d_inode(dentry), EXT2_XATTR_INDEX_TRUSTED, name, | 22 | return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name, |
23 | buffer, size); | 23 | buffer, size); |
24 | } | 24 | } |
25 | 25 | ||
diff --git a/fs/ext2/xattr_user.c b/fs/ext2/xattr_user.c index 72a2a96d677f..1fafd27037cc 100644 --- a/fs/ext2/xattr_user.c +++ b/fs/ext2/xattr_user.c | |||
@@ -18,12 +18,12 @@ ext2_xattr_user_list(struct dentry *dentry) | |||
18 | 18 | ||
19 | static int | 19 | static int |
20 | ext2_xattr_user_get(const struct xattr_handler *handler, | 20 | ext2_xattr_user_get(const struct xattr_handler *handler, |
21 | struct dentry *dentry, const char *name, | 21 | struct dentry *unused, struct inode *inode, |
22 | void *buffer, size_t size) | 22 | const char *name, void *buffer, size_t size) |
23 | { | 23 | { |
24 | if (!test_opt(dentry->d_sb, XATTR_USER)) | 24 | if (!test_opt(inode->i_sb, XATTR_USER)) |
25 | return -EOPNOTSUPP; | 25 | return -EOPNOTSUPP; |
26 | return ext2_xattr_get(d_inode(dentry), EXT2_XATTR_INDEX_USER, | 26 | return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER, |
27 | name, buffer, size); | 27 | name, buffer, size); |
28 | } | 28 | } |
29 | 29 | ||
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index 69b1e73026a5..c6601a476c02 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c | |||
@@ -172,9 +172,6 @@ ext4_get_acl(struct inode *inode, int type) | |||
172 | acl = ERR_PTR(retval); | 172 | acl = ERR_PTR(retval); |
173 | kfree(value); | 173 | kfree(value); |
174 | 174 | ||
175 | if (!IS_ERR(acl)) | ||
176 | set_cached_acl(inode, type, acl); | ||
177 | |||
178 | return acl; | 175 | return acl; |
179 | } | 176 | } |
180 | 177 | ||
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c index 561d7308b393..5d00bf060254 100644 --- a/fs/ext4/dir.c +++ b/fs/ext4/dir.c | |||
@@ -266,7 +266,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx) | |||
266 | ctx->pos += ext4_rec_len_from_disk(de->rec_len, | 266 | ctx->pos += ext4_rec_len_from_disk(de->rec_len, |
267 | sb->s_blocksize); | 267 | sb->s_blocksize); |
268 | } | 268 | } |
269 | if ((ctx->pos < inode->i_size) && !dir_relax(inode)) | 269 | if ((ctx->pos < inode->i_size) && !dir_relax_shared(inode)) |
270 | goto done; | 270 | goto done; |
271 | brelse(bh); | 271 | brelse(bh); |
272 | bh = NULL; | 272 | bh = NULL; |
@@ -644,7 +644,7 @@ int ext4_check_all_de(struct inode *dir, struct buffer_head *bh, void *buf, | |||
644 | const struct file_operations ext4_dir_operations = { | 644 | const struct file_operations ext4_dir_operations = { |
645 | .llseek = ext4_dir_llseek, | 645 | .llseek = ext4_dir_llseek, |
646 | .read = generic_read_dir, | 646 | .read = generic_read_dir, |
647 | .iterate = ext4_readdir, | 647 | .iterate_shared = ext4_readdir, |
648 | .unlocked_ioctl = ext4_ioctl, | 648 | .unlocked_ioctl = ext4_ioctl, |
649 | #ifdef CONFIG_COMPAT | 649 | #ifdef CONFIG_COMPAT |
650 | .compat_ioctl = ext4_compat_ioctl, | 650 | .compat_ioctl = ext4_compat_ioctl, |
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 48e4b8907826..5611ec9348d7 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -1638,13 +1638,13 @@ struct dentry *ext4_get_parent(struct dentry *child) | |||
1638 | ino = le32_to_cpu(de->inode); | 1638 | ino = le32_to_cpu(de->inode); |
1639 | brelse(bh); | 1639 | brelse(bh); |
1640 | 1640 | ||
1641 | if (!ext4_valid_inum(d_inode(child)->i_sb, ino)) { | 1641 | if (!ext4_valid_inum(child->d_sb, ino)) { |
1642 | EXT4_ERROR_INODE(d_inode(child), | 1642 | EXT4_ERROR_INODE(d_inode(child), |
1643 | "bad parent inode number: %u", ino); | 1643 | "bad parent inode number: %u", ino); |
1644 | return ERR_PTR(-EFSCORRUPTED); | 1644 | return ERR_PTR(-EFSCORRUPTED); |
1645 | } | 1645 | } |
1646 | 1646 | ||
1647 | return d_obtain_alias(ext4_iget_normal(d_inode(child)->i_sb, ino)); | 1647 | return d_obtain_alias(ext4_iget_normal(child->d_sb, ino)); |
1648 | } | 1648 | } |
1649 | 1649 | ||
1650 | /* | 1650 | /* |
diff --git a/fs/ext4/xattr_security.c b/fs/ext4/xattr_security.c index 3e81bdca071a..123a7d010efe 100644 --- a/fs/ext4/xattr_security.c +++ b/fs/ext4/xattr_security.c | |||
@@ -13,10 +13,10 @@ | |||
13 | 13 | ||
14 | static int | 14 | static int |
15 | ext4_xattr_security_get(const struct xattr_handler *handler, | 15 | ext4_xattr_security_get(const struct xattr_handler *handler, |
16 | struct dentry *dentry, const char *name, | 16 | struct dentry *unused, struct inode *inode, |
17 | void *buffer, size_t size) | 17 | const char *name, void *buffer, size_t size) |
18 | { | 18 | { |
19 | return ext4_xattr_get(d_inode(dentry), EXT4_XATTR_INDEX_SECURITY, | 19 | return ext4_xattr_get(inode, EXT4_XATTR_INDEX_SECURITY, |
20 | name, buffer, size); | 20 | name, buffer, size); |
21 | } | 21 | } |
22 | 22 | ||
diff --git a/fs/ext4/xattr_trusted.c b/fs/ext4/xattr_trusted.c index 2a3c6f9b8cb8..60652fa24cbc 100644 --- a/fs/ext4/xattr_trusted.c +++ b/fs/ext4/xattr_trusted.c | |||
@@ -20,10 +20,10 @@ ext4_xattr_trusted_list(struct dentry *dentry) | |||
20 | 20 | ||
21 | static int | 21 | static int |
22 | ext4_xattr_trusted_get(const struct xattr_handler *handler, | 22 | ext4_xattr_trusted_get(const struct xattr_handler *handler, |
23 | struct dentry *dentry, const char *name, void *buffer, | 23 | struct dentry *unused, struct inode *inode, |
24 | size_t size) | 24 | const char *name, void *buffer, size_t size) |
25 | { | 25 | { |
26 | return ext4_xattr_get(d_inode(dentry), EXT4_XATTR_INDEX_TRUSTED, | 26 | return ext4_xattr_get(inode, EXT4_XATTR_INDEX_TRUSTED, |
27 | name, buffer, size); | 27 | name, buffer, size); |
28 | } | 28 | } |
29 | 29 | ||
diff --git a/fs/ext4/xattr_user.c b/fs/ext4/xattr_user.c index d152f431e432..17a446ffecd3 100644 --- a/fs/ext4/xattr_user.c +++ b/fs/ext4/xattr_user.c | |||
@@ -19,12 +19,12 @@ ext4_xattr_user_list(struct dentry *dentry) | |||
19 | 19 | ||
20 | static int | 20 | static int |
21 | ext4_xattr_user_get(const struct xattr_handler *handler, | 21 | ext4_xattr_user_get(const struct xattr_handler *handler, |
22 | struct dentry *dentry, const char *name, | 22 | struct dentry *unused, struct inode *inode, |
23 | void *buffer, size_t size) | 23 | const char *name, void *buffer, size_t size) |
24 | { | 24 | { |
25 | if (!test_opt(dentry->d_sb, XATTR_USER)) | 25 | if (!test_opt(inode->i_sb, XATTR_USER)) |
26 | return -EOPNOTSUPP; | 26 | return -EOPNOTSUPP; |
27 | return ext4_xattr_get(d_inode(dentry), EXT4_XATTR_INDEX_USER, | 27 | return ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER, |
28 | name, buffer, size); | 28 | name, buffer, size); |
29 | } | 29 | } |
30 | 30 | ||
diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c index c8f25f7241f0..6f1fdda977b3 100644 --- a/fs/f2fs/acl.c +++ b/fs/f2fs/acl.c | |||
@@ -190,9 +190,6 @@ static struct posix_acl *__f2fs_get_acl(struct inode *inode, int type, | |||
190 | acl = ERR_PTR(retval); | 190 | acl = ERR_PTR(retval); |
191 | kfree(value); | 191 | kfree(value); |
192 | 192 | ||
193 | if (!IS_ERR(acl)) | ||
194 | set_cached_acl(inode, type, acl); | ||
195 | |||
196 | return acl; | 193 | return acl; |
197 | } | 194 | } |
198 | 195 | ||
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index af819571bce7..9e4615146d13 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c | |||
@@ -902,7 +902,7 @@ static int f2fs_dir_open(struct inode *inode, struct file *filp) | |||
902 | const struct file_operations f2fs_dir_operations = { | 902 | const struct file_operations f2fs_dir_operations = { |
903 | .llseek = generic_file_llseek, | 903 | .llseek = generic_file_llseek, |
904 | .read = generic_read_dir, | 904 | .read = generic_read_dir, |
905 | .iterate = f2fs_readdir, | 905 | .iterate_shared = f2fs_readdir, |
906 | .fsync = f2fs_sync_file, | 906 | .fsync = f2fs_sync_file, |
907 | .open = f2fs_dir_open, | 907 | .open = f2fs_dir_open, |
908 | .unlocked_ioctl = f2fs_ioctl, | 908 | .unlocked_ioctl = f2fs_ioctl, |
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 013e57932d61..324ed3812f30 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c | |||
@@ -202,7 +202,7 @@ struct dentry *f2fs_get_parent(struct dentry *child) | |||
202 | unsigned long ino = f2fs_inode_by_name(d_inode(child), &dotdot); | 202 | unsigned long ino = f2fs_inode_by_name(d_inode(child), &dotdot); |
203 | if (!ino) | 203 | if (!ino) |
204 | return ERR_PTR(-ENOENT); | 204 | return ERR_PTR(-ENOENT); |
205 | return d_obtain_alias(f2fs_iget(d_inode(child)->i_sb, ino)); | 205 | return d_obtain_alias(f2fs_iget(child->d_sb, ino)); |
206 | } | 206 | } |
207 | 207 | ||
208 | static int __recover_dot_dentries(struct inode *dir, nid_t pino) | 208 | static int __recover_dot_dentries(struct inode *dir, nid_t pino) |
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index 06a72dc0191a..17fd2b1a6848 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c | |||
@@ -26,10 +26,10 @@ | |||
26 | #include "xattr.h" | 26 | #include "xattr.h" |
27 | 27 | ||
28 | static int f2fs_xattr_generic_get(const struct xattr_handler *handler, | 28 | static int f2fs_xattr_generic_get(const struct xattr_handler *handler, |
29 | struct dentry *dentry, const char *name, void *buffer, | 29 | struct dentry *unused, struct inode *inode, |
30 | size_t size) | 30 | const char *name, void *buffer, size_t size) |
31 | { | 31 | { |
32 | struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb); | 32 | struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); |
33 | 33 | ||
34 | switch (handler->flags) { | 34 | switch (handler->flags) { |
35 | case F2FS_XATTR_INDEX_USER: | 35 | case F2FS_XATTR_INDEX_USER: |
@@ -45,7 +45,7 @@ static int f2fs_xattr_generic_get(const struct xattr_handler *handler, | |||
45 | default: | 45 | default: |
46 | return -EINVAL; | 46 | return -EINVAL; |
47 | } | 47 | } |
48 | return f2fs_getxattr(d_inode(dentry), handler->flags, name, | 48 | return f2fs_getxattr(inode, handler->flags, name, |
49 | buffer, size, NULL); | 49 | buffer, size, NULL); |
50 | } | 50 | } |
51 | 51 | ||
@@ -86,11 +86,9 @@ static bool f2fs_xattr_trusted_list(struct dentry *dentry) | |||
86 | } | 86 | } |
87 | 87 | ||
88 | static int f2fs_xattr_advise_get(const struct xattr_handler *handler, | 88 | static int f2fs_xattr_advise_get(const struct xattr_handler *handler, |
89 | struct dentry *dentry, const char *name, void *buffer, | 89 | struct dentry *unused, struct inode *inode, |
90 | size_t size) | 90 | const char *name, void *buffer, size_t size) |
91 | { | 91 | { |
92 | struct inode *inode = d_inode(dentry); | ||
93 | |||
94 | if (buffer) | 92 | if (buffer) |
95 | *((char *)buffer) = F2FS_I(inode)->i_advise; | 93 | *((char *)buffer) = F2FS_I(inode)->i_advise; |
96 | return sizeof(char); | 94 | return sizeof(char); |
diff --git a/fs/fat/dir.c b/fs/fat/dir.c index d0b95c95079b..663e428596c6 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c | |||
@@ -769,7 +769,7 @@ static int fat_ioctl_readdir(struct inode *inode, struct file *file, | |||
769 | 769 | ||
770 | buf.dirent = dirent; | 770 | buf.dirent = dirent; |
771 | buf.result = 0; | 771 | buf.result = 0; |
772 | inode_lock(inode); | 772 | inode_lock_shared(inode); |
773 | buf.ctx.pos = file->f_pos; | 773 | buf.ctx.pos = file->f_pos; |
774 | ret = -ENOENT; | 774 | ret = -ENOENT; |
775 | if (!IS_DEADDIR(inode)) { | 775 | if (!IS_DEADDIR(inode)) { |
@@ -777,7 +777,7 @@ static int fat_ioctl_readdir(struct inode *inode, struct file *file, | |||
777 | short_only, both ? &buf : NULL); | 777 | short_only, both ? &buf : NULL); |
778 | file->f_pos = buf.ctx.pos; | 778 | file->f_pos = buf.ctx.pos; |
779 | } | 779 | } |
780 | inode_unlock(inode); | 780 | inode_unlock_shared(inode); |
781 | if (ret >= 0) | 781 | if (ret >= 0) |
782 | ret = buf.result; | 782 | ret = buf.result; |
783 | return ret; | 783 | return ret; |
@@ -861,7 +861,7 @@ static long fat_compat_dir_ioctl(struct file *filp, unsigned cmd, | |||
861 | const struct file_operations fat_dir_operations = { | 861 | const struct file_operations fat_dir_operations = { |
862 | .llseek = generic_file_llseek, | 862 | .llseek = generic_file_llseek, |
863 | .read = generic_read_dir, | 863 | .read = generic_read_dir, |
864 | .iterate = fat_readdir, | 864 | .iterate_shared = fat_readdir, |
865 | .unlocked_ioctl = fat_dir_ioctl, | 865 | .unlocked_ioctl = fat_dir_ioctl, |
866 | #ifdef CONFIG_COMPAT | 866 | #ifdef CONFIG_COMPAT |
867 | .compat_ioctl = fat_compat_dir_ioctl, | 867 | .compat_ioctl = fat_compat_dir_ioctl, |
@@ -784,6 +784,11 @@ unsigned long __fdget_pos(unsigned int fd) | |||
784 | return v; | 784 | return v; |
785 | } | 785 | } |
786 | 786 | ||
787 | void __f_unlock_pos(struct file *f) | ||
788 | { | ||
789 | mutex_unlock(&f->f_pos_lock); | ||
790 | } | ||
791 | |||
787 | /* | 792 | /* |
788 | * We only lock f_pos if we have threads or if the file might be | 793 | * We only lock f_pos if we have threads or if the file might be |
789 | * shared with another process. In both cases we'll have an elevated | 794 | * shared with another process. In both cases we'll have an elevated |
diff --git a/fs/freevxfs/vxfs_lookup.c b/fs/freevxfs/vxfs_lookup.c index a49e0cfbb686..6d576b97f2c8 100644 --- a/fs/freevxfs/vxfs_lookup.c +++ b/fs/freevxfs/vxfs_lookup.c | |||
@@ -58,7 +58,7 @@ const struct inode_operations vxfs_dir_inode_ops = { | |||
58 | const struct file_operations vxfs_dir_operations = { | 58 | const struct file_operations vxfs_dir_operations = { |
59 | .llseek = generic_file_llseek, | 59 | .llseek = generic_file_llseek, |
60 | .read = generic_read_dir, | 60 | .read = generic_read_dir, |
61 | .iterate = vxfs_readdir, | 61 | .iterate_shared = vxfs_readdir, |
62 | }; | 62 | }; |
63 | 63 | ||
64 | static inline u_long | 64 | static inline u_long |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 4b855b65d457..b9419058108f 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -1162,7 +1162,6 @@ static int fuse_direntplus_link(struct file *file, | |||
1162 | struct fuse_direntplus *direntplus, | 1162 | struct fuse_direntplus *direntplus, |
1163 | u64 attr_version) | 1163 | u64 attr_version) |
1164 | { | 1164 | { |
1165 | int err; | ||
1166 | struct fuse_entry_out *o = &direntplus->entry_out; | 1165 | struct fuse_entry_out *o = &direntplus->entry_out; |
1167 | struct fuse_dirent *dirent = &direntplus->dirent; | 1166 | struct fuse_dirent *dirent = &direntplus->dirent; |
1168 | struct dentry *parent = file->f_path.dentry; | 1167 | struct dentry *parent = file->f_path.dentry; |
@@ -1172,6 +1171,7 @@ static int fuse_direntplus_link(struct file *file, | |||
1172 | struct inode *dir = d_inode(parent); | 1171 | struct inode *dir = d_inode(parent); |
1173 | struct fuse_conn *fc; | 1172 | struct fuse_conn *fc; |
1174 | struct inode *inode; | 1173 | struct inode *inode; |
1174 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); | ||
1175 | 1175 | ||
1176 | if (!o->nodeid) { | 1176 | if (!o->nodeid) { |
1177 | /* | 1177 | /* |
@@ -1204,65 +1204,61 @@ static int fuse_direntplus_link(struct file *file, | |||
1204 | 1204 | ||
1205 | name.hash = full_name_hash(name.name, name.len); | 1205 | name.hash = full_name_hash(name.name, name.len); |
1206 | dentry = d_lookup(parent, &name); | 1206 | dentry = d_lookup(parent, &name); |
1207 | if (dentry) { | 1207 | if (!dentry) { |
1208 | retry: | ||
1209 | dentry = d_alloc_parallel(parent, &name, &wq); | ||
1210 | if (IS_ERR(dentry)) | ||
1211 | return PTR_ERR(dentry); | ||
1212 | } | ||
1213 | if (!d_in_lookup(dentry)) { | ||
1214 | struct fuse_inode *fi; | ||
1208 | inode = d_inode(dentry); | 1215 | inode = d_inode(dentry); |
1209 | if (!inode) { | 1216 | if (!inode || |
1210 | d_drop(dentry); | 1217 | get_node_id(inode) != o->nodeid || |
1211 | } else if (get_node_id(inode) != o->nodeid || | 1218 | ((o->attr.mode ^ inode->i_mode) & S_IFMT)) { |
1212 | ((o->attr.mode ^ inode->i_mode) & S_IFMT)) { | ||
1213 | d_invalidate(dentry); | 1219 | d_invalidate(dentry); |
1214 | } else if (is_bad_inode(inode)) { | 1220 | dput(dentry); |
1215 | err = -EIO; | 1221 | goto retry; |
1216 | goto out; | 1222 | } |
1217 | } else { | 1223 | if (is_bad_inode(inode)) { |
1218 | struct fuse_inode *fi; | 1224 | dput(dentry); |
1219 | fi = get_fuse_inode(inode); | 1225 | return -EIO; |
1220 | spin_lock(&fc->lock); | ||
1221 | fi->nlookup++; | ||
1222 | spin_unlock(&fc->lock); | ||
1223 | |||
1224 | fuse_change_attributes(inode, &o->attr, | ||
1225 | entry_attr_timeout(o), | ||
1226 | attr_version); | ||
1227 | |||
1228 | /* | ||
1229 | * The other branch to 'found' comes via fuse_iget() | ||
1230 | * which bumps nlookup inside | ||
1231 | */ | ||
1232 | goto found; | ||
1233 | } | 1226 | } |
1234 | dput(dentry); | ||
1235 | } | ||
1236 | |||
1237 | dentry = d_alloc(parent, &name); | ||
1238 | err = -ENOMEM; | ||
1239 | if (!dentry) | ||
1240 | goto out; | ||
1241 | 1227 | ||
1242 | inode = fuse_iget(dir->i_sb, o->nodeid, o->generation, | 1228 | fi = get_fuse_inode(inode); |
1243 | &o->attr, entry_attr_timeout(o), attr_version); | 1229 | spin_lock(&fc->lock); |
1244 | if (!inode) | 1230 | fi->nlookup++; |
1245 | goto out; | 1231 | spin_unlock(&fc->lock); |
1246 | 1232 | ||
1247 | alias = d_splice_alias(inode, dentry); | 1233 | fuse_change_attributes(inode, &o->attr, |
1248 | err = PTR_ERR(alias); | 1234 | entry_attr_timeout(o), |
1249 | if (IS_ERR(alias)) | 1235 | attr_version); |
1250 | goto out; | 1236 | /* |
1237 | * The other branch comes via fuse_iget() | ||
1238 | * which bumps nlookup inside | ||
1239 | */ | ||
1240 | } else { | ||
1241 | inode = fuse_iget(dir->i_sb, o->nodeid, o->generation, | ||
1242 | &o->attr, entry_attr_timeout(o), | ||
1243 | attr_version); | ||
1244 | if (!inode) | ||
1245 | inode = ERR_PTR(-ENOMEM); | ||
1251 | 1246 | ||
1252 | if (alias) { | 1247 | alias = d_splice_alias(inode, dentry); |
1253 | dput(dentry); | 1248 | d_lookup_done(dentry); |
1254 | dentry = alias; | 1249 | if (alias) { |
1250 | dput(dentry); | ||
1251 | dentry = alias; | ||
1252 | } | ||
1253 | if (IS_ERR(dentry)) | ||
1254 | return PTR_ERR(dentry); | ||
1255 | } | 1255 | } |
1256 | |||
1257 | found: | ||
1258 | if (fc->readdirplus_auto) | 1256 | if (fc->readdirplus_auto) |
1259 | set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state); | 1257 | set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state); |
1260 | fuse_change_entry_timeout(dentry, o); | 1258 | fuse_change_entry_timeout(dentry, o); |
1261 | 1259 | ||
1262 | err = 0; | ||
1263 | out: | ||
1264 | dput(dentry); | 1260 | dput(dentry); |
1265 | return err; | 1261 | return 0; |
1266 | } | 1262 | } |
1267 | 1263 | ||
1268 | static int parse_dirplusfile(char *buf, size_t nbytes, struct file *file, | 1264 | static int parse_dirplusfile(char *buf, size_t nbytes, struct file *file, |
@@ -1759,10 +1755,9 @@ static int fuse_setxattr(struct dentry *entry, const char *name, | |||
1759 | return err; | 1755 | return err; |
1760 | } | 1756 | } |
1761 | 1757 | ||
1762 | static ssize_t fuse_getxattr(struct dentry *entry, const char *name, | 1758 | static ssize_t fuse_getxattr(struct dentry *entry, struct inode *inode, |
1763 | void *value, size_t size) | 1759 | const char *name, void *value, size_t size) |
1764 | { | 1760 | { |
1765 | struct inode *inode = d_inode(entry); | ||
1766 | struct fuse_conn *fc = get_fuse_conn(inode); | 1761 | struct fuse_conn *fc = get_fuse_conn(inode); |
1767 | FUSE_ARGS(args); | 1762 | FUSE_ARGS(args); |
1768 | struct fuse_getxattr_in inarg; | 1763 | struct fuse_getxattr_in inarg; |
@@ -1893,7 +1888,7 @@ static const struct inode_operations fuse_dir_inode_operations = { | |||
1893 | static const struct file_operations fuse_dir_operations = { | 1888 | static const struct file_operations fuse_dir_operations = { |
1894 | .llseek = generic_file_llseek, | 1889 | .llseek = generic_file_llseek, |
1895 | .read = generic_read_dir, | 1890 | .read = generic_read_dir, |
1896 | .iterate = fuse_readdir, | 1891 | .iterate_shared = fuse_readdir, |
1897 | .open = fuse_dir_open, | 1892 | .open = fuse_dir_open, |
1898 | .release = fuse_dir_release, | 1893 | .release = fuse_dir_release, |
1899 | .fsync = fuse_dir_fsync, | 1894 | .fsync = fuse_dir_fsync, |
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 208efc70ad49..a3e7358e3cd1 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c | |||
@@ -1119,7 +1119,7 @@ const struct file_operations gfs2_file_fops = { | |||
1119 | }; | 1119 | }; |
1120 | 1120 | ||
1121 | const struct file_operations gfs2_dir_fops = { | 1121 | const struct file_operations gfs2_dir_fops = { |
1122 | .iterate = gfs2_readdir, | 1122 | .iterate_shared = gfs2_readdir, |
1123 | .unlocked_ioctl = gfs2_ioctl, | 1123 | .unlocked_ioctl = gfs2_ioctl, |
1124 | .open = gfs2_open, | 1124 | .open = gfs2_open, |
1125 | .release = gfs2_release, | 1125 | .release = gfs2_release, |
@@ -1147,7 +1147,7 @@ const struct file_operations gfs2_file_fops_nolock = { | |||
1147 | }; | 1147 | }; |
1148 | 1148 | ||
1149 | const struct file_operations gfs2_dir_fops_nolock = { | 1149 | const struct file_operations gfs2_dir_fops_nolock = { |
1150 | .iterate = gfs2_readdir, | 1150 | .iterate_shared = gfs2_readdir, |
1151 | .unlocked_ioctl = gfs2_ioctl, | 1151 | .unlocked_ioctl = gfs2_ioctl, |
1152 | .open = gfs2_open, | 1152 | .open = gfs2_open, |
1153 | .release = gfs2_release, | 1153 | .release = gfs2_release, |
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index bb30f9a72c65..45f516cada78 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -1968,22 +1968,21 @@ static int gfs2_setxattr(struct dentry *dentry, const char *name, | |||
1968 | return ret; | 1968 | return ret; |
1969 | } | 1969 | } |
1970 | 1970 | ||
1971 | static ssize_t gfs2_getxattr(struct dentry *dentry, const char *name, | 1971 | static ssize_t gfs2_getxattr(struct dentry *dentry, struct inode *inode, |
1972 | void *data, size_t size) | 1972 | const char *name, void *data, size_t size) |
1973 | { | 1973 | { |
1974 | struct inode *inode = d_inode(dentry); | ||
1975 | struct gfs2_inode *ip = GFS2_I(inode); | 1974 | struct gfs2_inode *ip = GFS2_I(inode); |
1976 | struct gfs2_holder gh; | 1975 | struct gfs2_holder gh; |
1977 | int ret; | 1976 | int ret; |
1978 | 1977 | ||
1979 | /* For selinux during lookup */ | 1978 | /* For selinux during lookup */ |
1980 | if (gfs2_glock_is_locked_by_me(ip->i_gl)) | 1979 | if (gfs2_glock_is_locked_by_me(ip->i_gl)) |
1981 | return generic_getxattr(dentry, name, data, size); | 1980 | return generic_getxattr(dentry, inode, name, data, size); |
1982 | 1981 | ||
1983 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); | 1982 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); |
1984 | ret = gfs2_glock_nq(&gh); | 1983 | ret = gfs2_glock_nq(&gh); |
1985 | if (ret == 0) { | 1984 | if (ret == 0) { |
1986 | ret = generic_getxattr(dentry, name, data, size); | 1985 | ret = generic_getxattr(dentry, inode, name, data, size); |
1987 | gfs2_glock_dq(&gh); | 1986 | gfs2_glock_dq(&gh); |
1988 | } | 1987 | } |
1989 | gfs2_holder_uninit(&gh); | 1988 | gfs2_holder_uninit(&gh); |
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 49b0bff18fe3..45463600fb81 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
@@ -824,7 +824,7 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo) | |||
824 | * i_mutex on quota files is special. Since this inode is hidden system | 824 | * i_mutex on quota files is special. Since this inode is hidden system |
825 | * file, we are safe to define locking ourselves. | 825 | * file, we are safe to define locking ourselves. |
826 | */ | 826 | */ |
827 | lockdep_set_class(&sdp->sd_quota_inode->i_mutex, | 827 | lockdep_set_class(&sdp->sd_quota_inode->i_rwsem, |
828 | &gfs2_quota_imutex_key); | 828 | &gfs2_quota_imutex_key); |
829 | 829 | ||
830 | error = gfs2_rindex_update(sdp); | 830 | error = gfs2_rindex_update(sdp); |
@@ -1360,7 +1360,7 @@ static struct dentry *gfs2_mount_meta(struct file_system_type *fs_type, | |||
1360 | return ERR_PTR(error); | 1360 | return ERR_PTR(error); |
1361 | } | 1361 | } |
1362 | s = sget(&gfs2_fs_type, test_gfs2_super, set_meta_super, flags, | 1362 | s = sget(&gfs2_fs_type, test_gfs2_super, set_meta_super, flags, |
1363 | d_inode(path.dentry)->i_sb->s_bdev); | 1363 | path.dentry->d_sb->s_bdev); |
1364 | path_put(&path); | 1364 | path_put(&path); |
1365 | if (IS_ERR(s)) { | 1365 | if (IS_ERR(s)) { |
1366 | pr_warn("gfs2 mount does not exist\n"); | 1366 | pr_warn("gfs2 mount does not exist\n"); |
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index f8a0cd821290..9b2ff353e45f 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
@@ -1176,7 +1176,7 @@ static int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *s | |||
1176 | 1176 | ||
1177 | static int gfs2_statfs(struct dentry *dentry, struct kstatfs *buf) | 1177 | static int gfs2_statfs(struct dentry *dentry, struct kstatfs *buf) |
1178 | { | 1178 | { |
1179 | struct super_block *sb = d_inode(dentry)->i_sb; | 1179 | struct super_block *sb = dentry->d_sb; |
1180 | struct gfs2_sbd *sdp = sb->s_fs_info; | 1180 | struct gfs2_sbd *sdp = sb->s_fs_info; |
1181 | struct gfs2_statfs_change_host sc; | 1181 | struct gfs2_statfs_change_host sc; |
1182 | int error; | 1182 | int error; |
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c index e8dfb4740c04..619886ba6e78 100644 --- a/fs/gfs2/xattr.c +++ b/fs/gfs2/xattr.c | |||
@@ -584,10 +584,10 @@ out: | |||
584 | * Returns: actual size of data on success, -errno on error | 584 | * Returns: actual size of data on success, -errno on error |
585 | */ | 585 | */ |
586 | static int gfs2_xattr_get(const struct xattr_handler *handler, | 586 | static int gfs2_xattr_get(const struct xattr_handler *handler, |
587 | struct dentry *dentry, const char *name, | 587 | struct dentry *unused, struct inode *inode, |
588 | void *buffer, size_t size) | 588 | const char *name, void *buffer, size_t size) |
589 | { | 589 | { |
590 | struct gfs2_inode *ip = GFS2_I(d_inode(dentry)); | 590 | struct gfs2_inode *ip = GFS2_I(inode); |
591 | struct gfs2_ea_location el; | 591 | struct gfs2_ea_location el; |
592 | int type = handler->flags; | 592 | int type = handler->flags; |
593 | int error; | 593 | int error; |
diff --git a/fs/hfs/attr.c b/fs/hfs/attr.c index 8d931b157bbe..064f92f17efc 100644 --- a/fs/hfs/attr.c +++ b/fs/hfs/attr.c | |||
@@ -56,10 +56,9 @@ out: | |||
56 | return res; | 56 | return res; |
57 | } | 57 | } |
58 | 58 | ||
59 | ssize_t hfs_getxattr(struct dentry *dentry, const char *name, | 59 | ssize_t hfs_getxattr(struct dentry *unused, struct inode *inode, |
60 | void *value, size_t size) | 60 | const char *name, void *value, size_t size) |
61 | { | 61 | { |
62 | struct inode *inode = d_inode(dentry); | ||
63 | struct hfs_find_data fd; | 62 | struct hfs_find_data fd; |
64 | hfs_cat_rec rec; | 63 | hfs_cat_rec rec; |
65 | struct hfs_cat_file *file; | 64 | struct hfs_cat_file *file; |
diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c index 1eb5d415d434..98cde8ba5dc2 100644 --- a/fs/hfs/catalog.c +++ b/fs/hfs/catalog.c | |||
@@ -240,10 +240,13 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, struct qstr *str) | |||
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | /* we only need to take spinlock for exclusion with ->release() */ | ||
244 | spin_lock(&HFS_I(dir)->open_dir_lock); | ||
243 | list_for_each_entry(rd, &HFS_I(dir)->open_dir_list, list) { | 245 | list_for_each_entry(rd, &HFS_I(dir)->open_dir_list, list) { |
244 | if (fd.tree->keycmp(fd.search_key, (void *)&rd->key) < 0) | 246 | if (fd.tree->keycmp(fd.search_key, (void *)&rd->key) < 0) |
245 | rd->file->f_pos--; | 247 | rd->file->f_pos--; |
246 | } | 248 | } |
249 | spin_unlock(&HFS_I(dir)->open_dir_lock); | ||
247 | 250 | ||
248 | res = hfs_brec_remove(&fd); | 251 | res = hfs_brec_remove(&fd); |
249 | if (res) | 252 | if (res) |
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c index e9f2b855f831..163190ecc0d2 100644 --- a/fs/hfs/dir.c +++ b/fs/hfs/dir.c | |||
@@ -161,8 +161,14 @@ static int hfs_readdir(struct file *file, struct dir_context *ctx) | |||
161 | } | 161 | } |
162 | file->private_data = rd; | 162 | file->private_data = rd; |
163 | rd->file = file; | 163 | rd->file = file; |
164 | spin_lock(&HFS_I(inode)->open_dir_lock); | ||
164 | list_add(&rd->list, &HFS_I(inode)->open_dir_list); | 165 | list_add(&rd->list, &HFS_I(inode)->open_dir_list); |
166 | spin_unlock(&HFS_I(inode)->open_dir_lock); | ||
165 | } | 167 | } |
168 | /* | ||
169 | * Can be done after the list insertion; exclusion with | ||
170 | * hfs_delete_cat() is provided by directory lock. | ||
171 | */ | ||
166 | memcpy(&rd->key, &fd.key, sizeof(struct hfs_cat_key)); | 172 | memcpy(&rd->key, &fd.key, sizeof(struct hfs_cat_key)); |
167 | out: | 173 | out: |
168 | hfs_find_exit(&fd); | 174 | hfs_find_exit(&fd); |
@@ -173,9 +179,9 @@ static int hfs_dir_release(struct inode *inode, struct file *file) | |||
173 | { | 179 | { |
174 | struct hfs_readdir_data *rd = file->private_data; | 180 | struct hfs_readdir_data *rd = file->private_data; |
175 | if (rd) { | 181 | if (rd) { |
176 | inode_lock(inode); | 182 | spin_lock(&HFS_I(inode)->open_dir_lock); |
177 | list_del(&rd->list); | 183 | list_del(&rd->list); |
178 | inode_unlock(inode); | 184 | spin_unlock(&HFS_I(inode)->open_dir_lock); |
179 | kfree(rd); | 185 | kfree(rd); |
180 | } | 186 | } |
181 | return 0; | 187 | return 0; |
@@ -303,7 +309,7 @@ static int hfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
303 | 309 | ||
304 | const struct file_operations hfs_dir_operations = { | 310 | const struct file_operations hfs_dir_operations = { |
305 | .read = generic_read_dir, | 311 | .read = generic_read_dir, |
306 | .iterate = hfs_readdir, | 312 | .iterate_shared = hfs_readdir, |
307 | .llseek = generic_file_llseek, | 313 | .llseek = generic_file_llseek, |
308 | .release = hfs_dir_release, | 314 | .release = hfs_dir_release, |
309 | }; | 315 | }; |
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h index 1f1c7dcbcc2f..fa3eed86837c 100644 --- a/fs/hfs/hfs_fs.h +++ b/fs/hfs/hfs_fs.h | |||
@@ -69,6 +69,7 @@ struct hfs_inode_info { | |||
69 | struct hfs_cat_key cat_key; | 69 | struct hfs_cat_key cat_key; |
70 | 70 | ||
71 | struct list_head open_dir_list; | 71 | struct list_head open_dir_list; |
72 | spinlock_t open_dir_lock; | ||
72 | struct inode *rsrc_inode; | 73 | struct inode *rsrc_inode; |
73 | 74 | ||
74 | struct mutex extents_lock; | 75 | struct mutex extents_lock; |
@@ -213,8 +214,8 @@ extern void hfs_delete_inode(struct inode *); | |||
213 | /* attr.c */ | 214 | /* attr.c */ |
214 | extern int hfs_setxattr(struct dentry *dentry, const char *name, | 215 | extern int hfs_setxattr(struct dentry *dentry, const char *name, |
215 | const void *value, size_t size, int flags); | 216 | const void *value, size_t size, int flags); |
216 | extern ssize_t hfs_getxattr(struct dentry *dentry, const char *name, | 217 | extern ssize_t hfs_getxattr(struct dentry *dentry, struct inode *inode, |
217 | void *value, size_t size); | 218 | const char *name, void *value, size_t size); |
218 | extern ssize_t hfs_listxattr(struct dentry *dentry, char *buffer, size_t size); | 219 | extern ssize_t hfs_listxattr(struct dentry *dentry, char *buffer, size_t size); |
219 | 220 | ||
220 | /* mdb.c */ | 221 | /* mdb.c */ |
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c index cb1e5faa2fb7..ba533c79a806 100644 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c | |||
@@ -187,6 +187,7 @@ struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, umode_t mode) | |||
187 | 187 | ||
188 | mutex_init(&HFS_I(inode)->extents_lock); | 188 | mutex_init(&HFS_I(inode)->extents_lock); |
189 | INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list); | 189 | INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list); |
190 | spin_lock_init(&HFS_I(inode)->open_dir_lock); | ||
190 | hfs_cat_build_key(sb, (btree_key *)&HFS_I(inode)->cat_key, dir->i_ino, name); | 191 | hfs_cat_build_key(sb, (btree_key *)&HFS_I(inode)->cat_key, dir->i_ino, name); |
191 | inode->i_ino = HFS_SB(sb)->next_id++; | 192 | inode->i_ino = HFS_SB(sb)->next_id++; |
192 | inode->i_mode = mode; | 193 | inode->i_mode = mode; |
@@ -318,6 +319,7 @@ static int hfs_read_inode(struct inode *inode, void *data) | |||
318 | HFS_I(inode)->rsrc_inode = NULL; | 319 | HFS_I(inode)->rsrc_inode = NULL; |
319 | mutex_init(&HFS_I(inode)->extents_lock); | 320 | mutex_init(&HFS_I(inode)->extents_lock); |
320 | INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list); | 321 | INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list); |
322 | spin_lock_init(&HFS_I(inode)->open_dir_lock); | ||
321 | 323 | ||
322 | /* Initialize the inode */ | 324 | /* Initialize the inode */ |
323 | inode->i_uid = hsb->s_uid; | 325 | inode->i_uid = hsb->s_uid; |
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c index 022974ab6e3c..fb707e8f423a 100644 --- a/fs/hfsplus/catalog.c +++ b/fs/hfsplus/catalog.c | |||
@@ -374,12 +374,15 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str) | |||
374 | hfsplus_free_fork(sb, cnid, &fork, HFSPLUS_TYPE_RSRC); | 374 | hfsplus_free_fork(sb, cnid, &fork, HFSPLUS_TYPE_RSRC); |
375 | } | 375 | } |
376 | 376 | ||
377 | /* we only need to take spinlock for exclusion with ->release() */ | ||
378 | spin_lock(&HFSPLUS_I(dir)->open_dir_lock); | ||
377 | list_for_each(pos, &HFSPLUS_I(dir)->open_dir_list) { | 379 | list_for_each(pos, &HFSPLUS_I(dir)->open_dir_list) { |
378 | struct hfsplus_readdir_data *rd = | 380 | struct hfsplus_readdir_data *rd = |
379 | list_entry(pos, struct hfsplus_readdir_data, list); | 381 | list_entry(pos, struct hfsplus_readdir_data, list); |
380 | if (fd.tree->keycmp(fd.search_key, (void *)&rd->key) < 0) | 382 | if (fd.tree->keycmp(fd.search_key, (void *)&rd->key) < 0) |
381 | rd->file->f_pos--; | 383 | rd->file->f_pos--; |
382 | } | 384 | } |
385 | spin_unlock(&HFSPLUS_I(dir)->open_dir_lock); | ||
383 | 386 | ||
384 | err = hfs_brec_remove(&fd); | 387 | err = hfs_brec_remove(&fd); |
385 | if (err) | 388 | if (err) |
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index a4e867e08947..42e128661dc1 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c | |||
@@ -271,8 +271,14 @@ next: | |||
271 | } | 271 | } |
272 | file->private_data = rd; | 272 | file->private_data = rd; |
273 | rd->file = file; | 273 | rd->file = file; |
274 | spin_lock(&HFSPLUS_I(inode)->open_dir_lock); | ||
274 | list_add(&rd->list, &HFSPLUS_I(inode)->open_dir_list); | 275 | list_add(&rd->list, &HFSPLUS_I(inode)->open_dir_list); |
276 | spin_unlock(&HFSPLUS_I(inode)->open_dir_lock); | ||
275 | } | 277 | } |
278 | /* | ||
279 | * Can be done after the list insertion; exclusion with | ||
280 | * hfsplus_delete_cat() is provided by directory lock. | ||
281 | */ | ||
276 | memcpy(&rd->key, fd.key, sizeof(struct hfsplus_cat_key)); | 282 | memcpy(&rd->key, fd.key, sizeof(struct hfsplus_cat_key)); |
277 | out: | 283 | out: |
278 | kfree(strbuf); | 284 | kfree(strbuf); |
@@ -284,9 +290,9 @@ static int hfsplus_dir_release(struct inode *inode, struct file *file) | |||
284 | { | 290 | { |
285 | struct hfsplus_readdir_data *rd = file->private_data; | 291 | struct hfsplus_readdir_data *rd = file->private_data; |
286 | if (rd) { | 292 | if (rd) { |
287 | inode_lock(inode); | 293 | spin_lock(&HFSPLUS_I(inode)->open_dir_lock); |
288 | list_del(&rd->list); | 294 | list_del(&rd->list); |
289 | inode_unlock(inode); | 295 | spin_unlock(&HFSPLUS_I(inode)->open_dir_lock); |
290 | kfree(rd); | 296 | kfree(rd); |
291 | } | 297 | } |
292 | return 0; | 298 | return 0; |
@@ -569,7 +575,7 @@ const struct inode_operations hfsplus_dir_inode_operations = { | |||
569 | const struct file_operations hfsplus_dir_operations = { | 575 | const struct file_operations hfsplus_dir_operations = { |
570 | .fsync = hfsplus_file_fsync, | 576 | .fsync = hfsplus_file_fsync, |
571 | .read = generic_read_dir, | 577 | .read = generic_read_dir, |
572 | .iterate = hfsplus_readdir, | 578 | .iterate_shared = hfsplus_readdir, |
573 | .unlocked_ioctl = hfsplus_ioctl, | 579 | .unlocked_ioctl = hfsplus_ioctl, |
574 | .llseek = generic_file_llseek, | 580 | .llseek = generic_file_llseek, |
575 | .release = hfsplus_dir_release, | 581 | .release = hfsplus_dir_release, |
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index f91a1faf819e..fdc3446d934a 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h | |||
@@ -244,6 +244,7 @@ struct hfsplus_inode_info { | |||
244 | u8 userflags; /* BSD user file flags */ | 244 | u8 userflags; /* BSD user file flags */ |
245 | u32 subfolders; /* Subfolder count (HFSX only) */ | 245 | u32 subfolders; /* Subfolder count (HFSX only) */ |
246 | struct list_head open_dir_list; | 246 | struct list_head open_dir_list; |
247 | spinlock_t open_dir_lock; | ||
247 | loff_t phys_size; | 248 | loff_t phys_size; |
248 | 249 | ||
249 | struct inode vfs_inode; | 250 | struct inode vfs_inode; |
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index b28f39865c3a..037f738c5871 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c | |||
@@ -374,6 +374,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode) | |||
374 | 374 | ||
375 | hip = HFSPLUS_I(inode); | 375 | hip = HFSPLUS_I(inode); |
376 | INIT_LIST_HEAD(&hip->open_dir_list); | 376 | INIT_LIST_HEAD(&hip->open_dir_list); |
377 | spin_lock_init(&hip->open_dir_lock); | ||
377 | mutex_init(&hip->extents_lock); | 378 | mutex_init(&hip->extents_lock); |
378 | atomic_set(&hip->opencnt, 0); | 379 | atomic_set(&hip->opencnt, 0); |
379 | hip->extent_state = 0; | 380 | hip->extent_state = 0; |
diff --git a/fs/hfsplus/posix_acl.c b/fs/hfsplus/posix_acl.c index afb33eda6d7d..ab7ea2506b4d 100644 --- a/fs/hfsplus/posix_acl.c +++ b/fs/hfsplus/posix_acl.c | |||
@@ -48,9 +48,6 @@ struct posix_acl *hfsplus_get_posix_acl(struct inode *inode, int type) | |||
48 | 48 | ||
49 | hfsplus_destroy_attr_entry((hfsplus_attr_entry *)value); | 49 | hfsplus_destroy_attr_entry((hfsplus_attr_entry *)value); |
50 | 50 | ||
51 | if (!IS_ERR(acl)) | ||
52 | set_cached_acl(inode, type, acl); | ||
53 | |||
54 | return acl; | 51 | return acl; |
55 | } | 52 | } |
56 | 53 | ||
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index c35911362ff9..755bf30ba1ce 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c | |||
@@ -67,6 +67,7 @@ struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino) | |||
67 | return inode; | 67 | return inode; |
68 | 68 | ||
69 | INIT_LIST_HEAD(&HFSPLUS_I(inode)->open_dir_list); | 69 | INIT_LIST_HEAD(&HFSPLUS_I(inode)->open_dir_list); |
70 | spin_lock_init(&HFSPLUS_I(inode)->open_dir_lock); | ||
70 | mutex_init(&HFSPLUS_I(inode)->extents_lock); | 71 | mutex_init(&HFSPLUS_I(inode)->extents_lock); |
71 | HFSPLUS_I(inode)->flags = 0; | 72 | HFSPLUS_I(inode)->flags = 0; |
72 | HFSPLUS_I(inode)->extent_state = 0; | 73 | HFSPLUS_I(inode)->extent_state = 0; |
diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c index 70e445ff0cff..4f118d282a7a 100644 --- a/fs/hfsplus/xattr.c +++ b/fs/hfsplus/xattr.c | |||
@@ -579,7 +579,7 @@ failed_getxattr_init: | |||
579 | return res; | 579 | return res; |
580 | } | 580 | } |
581 | 581 | ||
582 | ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name, | 582 | ssize_t hfsplus_getxattr(struct inode *inode, const char *name, |
583 | void *value, size_t size, | 583 | void *value, size_t size, |
584 | const char *prefix, size_t prefixlen) | 584 | const char *prefix, size_t prefixlen) |
585 | { | 585 | { |
@@ -594,7 +594,7 @@ ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name, | |||
594 | strcpy(xattr_name, prefix); | 594 | strcpy(xattr_name, prefix); |
595 | strcpy(xattr_name + prefixlen, name); | 595 | strcpy(xattr_name + prefixlen, name); |
596 | 596 | ||
597 | res = __hfsplus_getxattr(d_inode(dentry), xattr_name, value, size); | 597 | res = __hfsplus_getxattr(inode, xattr_name, value, size); |
598 | kfree(xattr_name); | 598 | kfree(xattr_name); |
599 | return res; | 599 | return res; |
600 | 600 | ||
@@ -844,8 +844,8 @@ end_removexattr: | |||
844 | } | 844 | } |
845 | 845 | ||
846 | static int hfsplus_osx_getxattr(const struct xattr_handler *handler, | 846 | static int hfsplus_osx_getxattr(const struct xattr_handler *handler, |
847 | struct dentry *dentry, const char *name, | 847 | struct dentry *unused, struct inode *inode, |
848 | void *buffer, size_t size) | 848 | const char *name, void *buffer, size_t size) |
849 | { | 849 | { |
850 | /* | 850 | /* |
851 | * Don't allow retrieving properly prefixed attributes | 851 | * Don't allow retrieving properly prefixed attributes |
@@ -860,7 +860,7 @@ static int hfsplus_osx_getxattr(const struct xattr_handler *handler, | |||
860 | * creates), so we pass the name through unmodified (after | 860 | * creates), so we pass the name through unmodified (after |
861 | * ensuring it doesn't conflict with another namespace). | 861 | * ensuring it doesn't conflict with another namespace). |
862 | */ | 862 | */ |
863 | return __hfsplus_getxattr(d_inode(dentry), name, buffer, size); | 863 | return __hfsplus_getxattr(inode, name, buffer, size); |
864 | } | 864 | } |
865 | 865 | ||
866 | static int hfsplus_osx_setxattr(const struct xattr_handler *handler, | 866 | static int hfsplus_osx_setxattr(const struct xattr_handler *handler, |
diff --git a/fs/hfsplus/xattr.h b/fs/hfsplus/xattr.h index f9b0955b3d28..d04ba6f58df2 100644 --- a/fs/hfsplus/xattr.h +++ b/fs/hfsplus/xattr.h | |||
@@ -28,7 +28,7 @@ int hfsplus_setxattr(struct dentry *dentry, const char *name, | |||
28 | ssize_t __hfsplus_getxattr(struct inode *inode, const char *name, | 28 | ssize_t __hfsplus_getxattr(struct inode *inode, const char *name, |
29 | void *value, size_t size); | 29 | void *value, size_t size); |
30 | 30 | ||
31 | ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name, | 31 | ssize_t hfsplus_getxattr(struct inode *inode, const char *name, |
32 | void *value, size_t size, | 32 | void *value, size_t size, |
33 | const char *prefix, size_t prefixlen); | 33 | const char *prefix, size_t prefixlen); |
34 | 34 | ||
diff --git a/fs/hfsplus/xattr_security.c b/fs/hfsplus/xattr_security.c index 72a68a3a0c99..ae2ca8c2e335 100644 --- a/fs/hfsplus/xattr_security.c +++ b/fs/hfsplus/xattr_security.c | |||
@@ -14,10 +14,10 @@ | |||
14 | #include "acl.h" | 14 | #include "acl.h" |
15 | 15 | ||
16 | static int hfsplus_security_getxattr(const struct xattr_handler *handler, | 16 | static int hfsplus_security_getxattr(const struct xattr_handler *handler, |
17 | struct dentry *dentry, const char *name, | 17 | struct dentry *unused, struct inode *inode, |
18 | void *buffer, size_t size) | 18 | const char *name, void *buffer, size_t size) |
19 | { | 19 | { |
20 | return hfsplus_getxattr(dentry, name, buffer, size, | 20 | return hfsplus_getxattr(inode, name, buffer, size, |
21 | XATTR_SECURITY_PREFIX, | 21 | XATTR_SECURITY_PREFIX, |
22 | XATTR_SECURITY_PREFIX_LEN); | 22 | XATTR_SECURITY_PREFIX_LEN); |
23 | } | 23 | } |
diff --git a/fs/hfsplus/xattr_trusted.c b/fs/hfsplus/xattr_trusted.c index 95a7704c7abb..eae2947060aa 100644 --- a/fs/hfsplus/xattr_trusted.c +++ b/fs/hfsplus/xattr_trusted.c | |||
@@ -12,10 +12,10 @@ | |||
12 | #include "xattr.h" | 12 | #include "xattr.h" |
13 | 13 | ||
14 | static int hfsplus_trusted_getxattr(const struct xattr_handler *handler, | 14 | static int hfsplus_trusted_getxattr(const struct xattr_handler *handler, |
15 | struct dentry *dentry, const char *name, | 15 | struct dentry *unused, struct inode *inode, |
16 | void *buffer, size_t size) | 16 | const char *name, void *buffer, size_t size) |
17 | { | 17 | { |
18 | return hfsplus_getxattr(dentry, name, buffer, size, | 18 | return hfsplus_getxattr(inode, name, buffer, size, |
19 | XATTR_TRUSTED_PREFIX, | 19 | XATTR_TRUSTED_PREFIX, |
20 | XATTR_TRUSTED_PREFIX_LEN); | 20 | XATTR_TRUSTED_PREFIX_LEN); |
21 | } | 21 | } |
diff --git a/fs/hfsplus/xattr_user.c b/fs/hfsplus/xattr_user.c index 6fc269baf959..3c9eec3e4c7b 100644 --- a/fs/hfsplus/xattr_user.c +++ b/fs/hfsplus/xattr_user.c | |||
@@ -12,11 +12,11 @@ | |||
12 | #include "xattr.h" | 12 | #include "xattr.h" |
13 | 13 | ||
14 | static int hfsplus_user_getxattr(const struct xattr_handler *handler, | 14 | static int hfsplus_user_getxattr(const struct xattr_handler *handler, |
15 | struct dentry *dentry, const char *name, | 15 | struct dentry *unused, struct inode *inode, |
16 | void *buffer, size_t size) | 16 | const char *name, void *buffer, size_t size) |
17 | { | 17 | { |
18 | 18 | ||
19 | return hfsplus_getxattr(dentry, name, buffer, size, | 19 | return hfsplus_getxattr(inode, name, buffer, size, |
20 | XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN); | 20 | XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN); |
21 | } | 21 | } |
22 | 22 | ||
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 7016653f3e41..5c57654927a6 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -398,7 +398,7 @@ static const struct file_operations hostfs_file_fops = { | |||
398 | 398 | ||
399 | static const struct file_operations hostfs_dir_fops = { | 399 | static const struct file_operations hostfs_dir_fops = { |
400 | .llseek = generic_file_llseek, | 400 | .llseek = generic_file_llseek, |
401 | .iterate = hostfs_readdir, | 401 | .iterate_shared = hostfs_readdir, |
402 | .read = generic_read_dir, | 402 | .read = generic_read_dir, |
403 | .open = hostfs_open, | 403 | .open = hostfs_open, |
404 | .fsync = hostfs_fsync, | 404 | .fsync = hostfs_fsync, |
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c index e57a53c13d86..7b9150c2e75c 100644 --- a/fs/hpfs/dir.c +++ b/fs/hpfs/dir.c | |||
@@ -44,7 +44,11 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence) | |||
44 | else goto fail; | 44 | else goto fail; |
45 | if (pos == 12) goto fail; | 45 | if (pos == 12) goto fail; |
46 | } | 46 | } |
47 | hpfs_add_pos(i, &filp->f_pos); | 47 | if (unlikely(hpfs_add_pos(i, &filp->f_pos) < 0)) { |
48 | hpfs_unlock(s); | ||
49 | inode_unlock(i); | ||
50 | return -ENOMEM; | ||
51 | } | ||
48 | ok: | 52 | ok: |
49 | filp->f_pos = new_off; | 53 | filp->f_pos = new_off; |
50 | hpfs_unlock(s); | 54 | hpfs_unlock(s); |
@@ -141,8 +145,10 @@ static int hpfs_readdir(struct file *file, struct dir_context *ctx) | |||
141 | ctx->pos = 1; | 145 | ctx->pos = 1; |
142 | } | 146 | } |
143 | if (ctx->pos == 1) { | 147 | if (ctx->pos == 1) { |
148 | ret = hpfs_add_pos(inode, &file->f_pos); | ||
149 | if (unlikely(ret < 0)) | ||
150 | goto out; | ||
144 | ctx->pos = ((loff_t) hpfs_de_as_down_as_possible(inode->i_sb, hpfs_inode->i_dno) << 4) + 1; | 151 | ctx->pos = ((loff_t) hpfs_de_as_down_as_possible(inode->i_sb, hpfs_inode->i_dno) << 4) + 1; |
145 | hpfs_add_pos(inode, &file->f_pos); | ||
146 | file->f_version = inode->i_version; | 152 | file->f_version = inode->i_version; |
147 | } | 153 | } |
148 | next_pos = ctx->pos; | 154 | next_pos = ctx->pos; |
@@ -324,7 +330,7 @@ const struct file_operations hpfs_dir_ops = | |||
324 | { | 330 | { |
325 | .llseek = hpfs_dir_lseek, | 331 | .llseek = hpfs_dir_lseek, |
326 | .read = generic_read_dir, | 332 | .read = generic_read_dir, |
327 | .iterate = hpfs_readdir, | 333 | .iterate_shared = hpfs_readdir, |
328 | .release = hpfs_dir_release, | 334 | .release = hpfs_dir_release, |
329 | .fsync = hpfs_file_fsync, | 335 | .fsync = hpfs_file_fsync, |
330 | .unlocked_ioctl = hpfs_ioctl, | 336 | .unlocked_ioctl = hpfs_ioctl, |
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c index 2923a7bd82ac..86ab7e790b4e 100644 --- a/fs/hpfs/dnode.c +++ b/fs/hpfs/dnode.c | |||
@@ -21,7 +21,7 @@ static loff_t get_pos(struct dnode *d, struct hpfs_dirent *fde) | |||
21 | return ((loff_t)le32_to_cpu(d->self) << 4) | (loff_t)1; | 21 | return ((loff_t)le32_to_cpu(d->self) << 4) | (loff_t)1; |
22 | } | 22 | } |
23 | 23 | ||
24 | void hpfs_add_pos(struct inode *inode, loff_t *pos) | 24 | int hpfs_add_pos(struct inode *inode, loff_t *pos) |
25 | { | 25 | { |
26 | struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); | 26 | struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); |
27 | int i = 0; | 27 | int i = 0; |
@@ -29,11 +29,12 @@ void hpfs_add_pos(struct inode *inode, loff_t *pos) | |||
29 | 29 | ||
30 | if (hpfs_inode->i_rddir_off) | 30 | if (hpfs_inode->i_rddir_off) |
31 | for (; hpfs_inode->i_rddir_off[i]; i++) | 31 | for (; hpfs_inode->i_rddir_off[i]; i++) |
32 | if (hpfs_inode->i_rddir_off[i] == pos) return; | 32 | if (hpfs_inode->i_rddir_off[i] == pos) |
33 | return 0; | ||
33 | if (!(i&0x0f)) { | 34 | if (!(i&0x0f)) { |
34 | if (!(ppos = kmalloc((i+0x11) * sizeof(loff_t*), GFP_NOFS))) { | 35 | if (!(ppos = kmalloc((i+0x11) * sizeof(loff_t*), GFP_NOFS))) { |
35 | pr_err("out of memory for position list\n"); | 36 | pr_err("out of memory for position list\n"); |
36 | return; | 37 | return -ENOMEM; |
37 | } | 38 | } |
38 | if (hpfs_inode->i_rddir_off) { | 39 | if (hpfs_inode->i_rddir_off) { |
39 | memcpy(ppos, hpfs_inode->i_rddir_off, i * sizeof(loff_t)); | 40 | memcpy(ppos, hpfs_inode->i_rddir_off, i * sizeof(loff_t)); |
@@ -43,6 +44,7 @@ void hpfs_add_pos(struct inode *inode, loff_t *pos) | |||
43 | } | 44 | } |
44 | hpfs_inode->i_rddir_off[i] = pos; | 45 | hpfs_inode->i_rddir_off[i] = pos; |
45 | hpfs_inode->i_rddir_off[i + 1] = NULL; | 46 | hpfs_inode->i_rddir_off[i + 1] = NULL; |
47 | return 0; | ||
46 | } | 48 | } |
47 | 49 | ||
48 | void hpfs_del_pos(struct inode *inode, loff_t *pos) | 50 | void hpfs_del_pos(struct inode *inode, loff_t *pos) |
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h index 975654a63c13..aebb78f9e47f 100644 --- a/fs/hpfs/hpfs_fn.h +++ b/fs/hpfs/hpfs_fn.h | |||
@@ -242,7 +242,7 @@ extern const struct file_operations hpfs_dir_ops; | |||
242 | 242 | ||
243 | /* dnode.c */ | 243 | /* dnode.c */ |
244 | 244 | ||
245 | void hpfs_add_pos(struct inode *, loff_t *); | 245 | int hpfs_add_pos(struct inode *, loff_t *); |
246 | void hpfs_del_pos(struct inode *, loff_t *); | 246 | void hpfs_del_pos(struct inode *, loff_t *); |
247 | struct hpfs_dirent *hpfs_add_de(struct super_block *, struct dnode *, | 247 | struct hpfs_dirent *hpfs_add_de(struct super_block *, struct dnode *, |
248 | const unsigned char *, unsigned, secno); | 248 | const unsigned char *, unsigned, secno); |
diff --git a/fs/inode.c b/fs/inode.c index 69b8b526c194..4ccbc21b30ce 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -151,6 +151,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode) | |||
151 | inode->i_bdev = NULL; | 151 | inode->i_bdev = NULL; |
152 | inode->i_cdev = NULL; | 152 | inode->i_cdev = NULL; |
153 | inode->i_link = NULL; | 153 | inode->i_link = NULL; |
154 | inode->i_dir_seq = 0; | ||
154 | inode->i_rdev = 0; | 155 | inode->i_rdev = 0; |
155 | inode->dirtied_when = 0; | 156 | inode->dirtied_when = 0; |
156 | 157 | ||
@@ -165,8 +166,8 @@ int inode_init_always(struct super_block *sb, struct inode *inode) | |||
165 | spin_lock_init(&inode->i_lock); | 166 | spin_lock_init(&inode->i_lock); |
166 | lockdep_set_class(&inode->i_lock, &sb->s_type->i_lock_key); | 167 | lockdep_set_class(&inode->i_lock, &sb->s_type->i_lock_key); |
167 | 168 | ||
168 | mutex_init(&inode->i_mutex); | 169 | init_rwsem(&inode->i_rwsem); |
169 | lockdep_set_class(&inode->i_mutex, &sb->s_type->i_mutex_key); | 170 | lockdep_set_class(&inode->i_rwsem, &sb->s_type->i_mutex_key); |
170 | 171 | ||
171 | atomic_set(&inode->i_dio_count, 0); | 172 | atomic_set(&inode->i_dio_count, 0); |
172 | 173 | ||
@@ -238,9 +239,9 @@ void __destroy_inode(struct inode *inode) | |||
238 | } | 239 | } |
239 | 240 | ||
240 | #ifdef CONFIG_FS_POSIX_ACL | 241 | #ifdef CONFIG_FS_POSIX_ACL |
241 | if (inode->i_acl && inode->i_acl != ACL_NOT_CACHED) | 242 | if (inode->i_acl && !is_uncached_acl(inode->i_acl)) |
242 | posix_acl_release(inode->i_acl); | 243 | posix_acl_release(inode->i_acl); |
243 | if (inode->i_default_acl && inode->i_default_acl != ACL_NOT_CACHED) | 244 | if (inode->i_default_acl && !is_uncached_acl(inode->i_default_acl)) |
244 | posix_acl_release(inode->i_default_acl); | 245 | posix_acl_release(inode->i_default_acl); |
245 | #endif | 246 | #endif |
246 | this_cpu_dec(nr_inodes); | 247 | this_cpu_dec(nr_inodes); |
@@ -924,13 +925,13 @@ void lockdep_annotate_inode_mutex_key(struct inode *inode) | |||
924 | struct file_system_type *type = inode->i_sb->s_type; | 925 | struct file_system_type *type = inode->i_sb->s_type; |
925 | 926 | ||
926 | /* Set new key only if filesystem hasn't already changed it */ | 927 | /* Set new key only if filesystem hasn't already changed it */ |
927 | if (lockdep_match_class(&inode->i_mutex, &type->i_mutex_key)) { | 928 | if (lockdep_match_class(&inode->i_rwsem, &type->i_mutex_key)) { |
928 | /* | 929 | /* |
929 | * ensure nobody is actually holding i_mutex | 930 | * ensure nobody is actually holding i_mutex |
930 | */ | 931 | */ |
931 | mutex_destroy(&inode->i_mutex); | 932 | // mutex_destroy(&inode->i_mutex); |
932 | mutex_init(&inode->i_mutex); | 933 | init_rwsem(&inode->i_rwsem); |
933 | lockdep_set_class(&inode->i_mutex, | 934 | lockdep_set_class(&inode->i_rwsem, |
934 | &type->i_mutex_dir_key); | 935 | &type->i_mutex_dir_key); |
935 | } | 936 | } |
936 | } | 937 | } |
diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c index b943cbd963bb..e7599615e4e0 100644 --- a/fs/isofs/dir.c +++ b/fs/isofs/dir.c | |||
@@ -58,7 +58,7 @@ int get_acorn_filename(struct iso_directory_record *de, | |||
58 | std = sizeof(struct iso_directory_record) + de->name_len[0]; | 58 | std = sizeof(struct iso_directory_record) + de->name_len[0]; |
59 | if (std & 1) | 59 | if (std & 1) |
60 | std++; | 60 | std++; |
61 | if ((*((unsigned char *) de) - std) != 32) | 61 | if (de->length[0] - std != 32) |
62 | return retnamlen; | 62 | return retnamlen; |
63 | chr = ((unsigned char *) de) + std; | 63 | chr = ((unsigned char *) de) + std; |
64 | if (strncmp(chr, "ARCHIMEDES", 10)) | 64 | if (strncmp(chr, "ARCHIMEDES", 10)) |
@@ -269,7 +269,7 @@ const struct file_operations isofs_dir_operations = | |||
269 | { | 269 | { |
270 | .llseek = generic_file_llseek, | 270 | .llseek = generic_file_llseek, |
271 | .read = generic_read_dir, | 271 | .read = generic_read_dir, |
272 | .iterate = isofs_readdir, | 272 | .iterate_shared = isofs_readdir, |
273 | }; | 273 | }; |
274 | 274 | ||
275 | /* | 275 | /* |
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index 2f7a3c090489..bc2693d56298 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c | |||
@@ -203,8 +203,6 @@ struct posix_acl *jffs2_get_acl(struct inode *inode, int type) | |||
203 | acl = ERR_PTR(rc); | 203 | acl = ERR_PTR(rc); |
204 | } | 204 | } |
205 | kfree(value); | 205 | kfree(value); |
206 | if (!IS_ERR(acl)) | ||
207 | set_cached_acl(inode, type, acl); | ||
208 | return acl; | 206 | return acl; |
209 | } | 207 | } |
210 | 208 | ||
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index 30c4c9ebb693..84c4bf3631a2 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c | |||
@@ -40,7 +40,7 @@ static int jffs2_rename (struct inode *, struct dentry *, | |||
40 | const struct file_operations jffs2_dir_operations = | 40 | const struct file_operations jffs2_dir_operations = |
41 | { | 41 | { |
42 | .read = generic_read_dir, | 42 | .read = generic_read_dir, |
43 | .iterate = jffs2_readdir, | 43 | .iterate_shared=jffs2_readdir, |
44 | .unlocked_ioctl=jffs2_ioctl, | 44 | .unlocked_ioctl=jffs2_ioctl, |
45 | .fsync = jffs2_fsync, | 45 | .fsync = jffs2_fsync, |
46 | .llseek = generic_file_llseek, | 46 | .llseek = generic_file_llseek, |
@@ -241,7 +241,7 @@ static int jffs2_unlink(struct inode *dir_i, struct dentry *dentry) | |||
241 | 241 | ||
242 | static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct dentry *dentry) | 242 | static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct dentry *dentry) |
243 | { | 243 | { |
244 | struct jffs2_sb_info *c = JFFS2_SB_INFO(d_inode(old_dentry)->i_sb); | 244 | struct jffs2_sb_info *c = JFFS2_SB_INFO(old_dentry->d_sb); |
245 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(d_inode(old_dentry)); | 245 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(d_inode(old_dentry)); |
246 | struct jffs2_inode_info *dir_f = JFFS2_INODE_INFO(dir_i); | 246 | struct jffs2_inode_info *dir_f = JFFS2_INODE_INFO(dir_i); |
247 | int ret; | 247 | int ret; |
diff --git a/fs/jffs2/security.c b/fs/jffs2/security.c index 7a28facd7175..3ed9a4b49778 100644 --- a/fs/jffs2/security.c +++ b/fs/jffs2/security.c | |||
@@ -49,10 +49,10 @@ int jffs2_init_security(struct inode *inode, struct inode *dir, | |||
49 | 49 | ||
50 | /* ---- XATTR Handler for "security.*" ----------------- */ | 50 | /* ---- XATTR Handler for "security.*" ----------------- */ |
51 | static int jffs2_security_getxattr(const struct xattr_handler *handler, | 51 | static int jffs2_security_getxattr(const struct xattr_handler *handler, |
52 | struct dentry *dentry, const char *name, | 52 | struct dentry *unused, struct inode *inode, |
53 | void *buffer, size_t size) | 53 | const char *name, void *buffer, size_t size) |
54 | { | 54 | { |
55 | return do_jffs2_getxattr(d_inode(dentry), JFFS2_XPREFIX_SECURITY, | 55 | return do_jffs2_getxattr(inode, JFFS2_XPREFIX_SECURITY, |
56 | name, buffer, size); | 56 | name, buffer, size); |
57 | } | 57 | } |
58 | 58 | ||
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index 0a9a114bb9d1..5ef21f4c4c77 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c | |||
@@ -147,7 +147,7 @@ static struct dentry *jffs2_get_parent(struct dentry *child) | |||
147 | JFFS2_DEBUG("Parent of directory ino #%u is #%u\n", | 147 | JFFS2_DEBUG("Parent of directory ino #%u is #%u\n", |
148 | f->inocache->ino, pino); | 148 | f->inocache->ino, pino); |
149 | 149 | ||
150 | return d_obtain_alias(jffs2_iget(d_inode(child)->i_sb, pino)); | 150 | return d_obtain_alias(jffs2_iget(child->d_sb, pino)); |
151 | } | 151 | } |
152 | 152 | ||
153 | static const struct export_operations jffs2_export_ops = { | 153 | static const struct export_operations jffs2_export_ops = { |
diff --git a/fs/jffs2/xattr_trusted.c b/fs/jffs2/xattr_trusted.c index b2555ef07a12..4ebecff1d922 100644 --- a/fs/jffs2/xattr_trusted.c +++ b/fs/jffs2/xattr_trusted.c | |||
@@ -17,10 +17,10 @@ | |||
17 | #include "nodelist.h" | 17 | #include "nodelist.h" |
18 | 18 | ||
19 | static int jffs2_trusted_getxattr(const struct xattr_handler *handler, | 19 | static int jffs2_trusted_getxattr(const struct xattr_handler *handler, |
20 | struct dentry *dentry, const char *name, | 20 | struct dentry *unused, struct inode *inode, |
21 | void *buffer, size_t size) | 21 | const char *name, void *buffer, size_t size) |
22 | { | 22 | { |
23 | return do_jffs2_getxattr(d_inode(dentry), JFFS2_XPREFIX_TRUSTED, | 23 | return do_jffs2_getxattr(inode, JFFS2_XPREFIX_TRUSTED, |
24 | name, buffer, size); | 24 | name, buffer, size); |
25 | } | 25 | } |
26 | 26 | ||
diff --git a/fs/jffs2/xattr_user.c b/fs/jffs2/xattr_user.c index 539bd630b5e4..bce249e1b277 100644 --- a/fs/jffs2/xattr_user.c +++ b/fs/jffs2/xattr_user.c | |||
@@ -17,10 +17,10 @@ | |||
17 | #include "nodelist.h" | 17 | #include "nodelist.h" |
18 | 18 | ||
19 | static int jffs2_user_getxattr(const struct xattr_handler *handler, | 19 | static int jffs2_user_getxattr(const struct xattr_handler *handler, |
20 | struct dentry *dentry, const char *name, | 20 | struct dentry *unused, struct inode *inode, |
21 | void *buffer, size_t size) | 21 | const char *name, void *buffer, size_t size) |
22 | { | 22 | { |
23 | return do_jffs2_getxattr(d_inode(dentry), JFFS2_XPREFIX_USER, | 23 | return do_jffs2_getxattr(inode, JFFS2_XPREFIX_USER, |
24 | name, buffer, size); | 24 | name, buffer, size); |
25 | } | 25 | } |
26 | 26 | ||
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c index 49456853e9de..21fa92ba2c19 100644 --- a/fs/jfs/acl.c +++ b/fs/jfs/acl.c | |||
@@ -34,10 +34,6 @@ struct posix_acl *jfs_get_acl(struct inode *inode, int type) | |||
34 | int size; | 34 | int size; |
35 | char *value = NULL; | 35 | char *value = NULL; |
36 | 36 | ||
37 | acl = get_cached_acl(inode, type); | ||
38 | if (acl != ACL_NOT_CACHED) | ||
39 | return acl; | ||
40 | |||
41 | switch(type) { | 37 | switch(type) { |
42 | case ACL_TYPE_ACCESS: | 38 | case ACL_TYPE_ACCESS: |
43 | ea_name = XATTR_NAME_POSIX_ACL_ACCESS; | 39 | ea_name = XATTR_NAME_POSIX_ACL_ACCESS; |
@@ -67,8 +63,6 @@ struct posix_acl *jfs_get_acl(struct inode *inode, int type) | |||
67 | acl = posix_acl_from_xattr(&init_user_ns, value, size); | 63 | acl = posix_acl_from_xattr(&init_user_ns, value, size); |
68 | } | 64 | } |
69 | kfree(value); | 65 | kfree(value); |
70 | if (!IS_ERR(acl)) | ||
71 | set_cached_acl(inode, type, acl); | ||
72 | return acl; | 66 | return acl; |
73 | } | 67 | } |
74 | 68 | ||
diff --git a/fs/jfs/jfs_xattr.h b/fs/jfs/jfs_xattr.h index e8d717dabca3..e69e14f3777b 100644 --- a/fs/jfs/jfs_xattr.h +++ b/fs/jfs/jfs_xattr.h | |||
@@ -57,7 +57,7 @@ extern int __jfs_setxattr(tid_t, struct inode *, const char *, const void *, | |||
57 | extern int jfs_setxattr(struct dentry *, const char *, const void *, size_t, | 57 | extern int jfs_setxattr(struct dentry *, const char *, const void *, size_t, |
58 | int); | 58 | int); |
59 | extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t); | 59 | extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t); |
60 | extern ssize_t jfs_getxattr(struct dentry *, const char *, void *, size_t); | 60 | extern ssize_t jfs_getxattr(struct dentry *, struct inode *, const char *, void *, size_t); |
61 | extern ssize_t jfs_listxattr(struct dentry *, char *, size_t); | 61 | extern ssize_t jfs_listxattr(struct dentry *, char *, size_t); |
62 | extern int jfs_removexattr(struct dentry *, const char *); | 62 | extern int jfs_removexattr(struct dentry *, const char *); |
63 | 63 | ||
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 701f89370de7..8a40941ac9a6 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c | |||
@@ -1524,7 +1524,7 @@ struct dentry *jfs_get_parent(struct dentry *dentry) | |||
1524 | parent_ino = | 1524 | parent_ino = |
1525 | le32_to_cpu(JFS_IP(d_inode(dentry))->i_dtroot.header.idotdot); | 1525 | le32_to_cpu(JFS_IP(d_inode(dentry))->i_dtroot.header.idotdot); |
1526 | 1526 | ||
1527 | return d_obtain_alias(jfs_iget(d_inode(dentry)->i_sb, parent_ino)); | 1527 | return d_obtain_alias(jfs_iget(dentry->d_sb, parent_ino)); |
1528 | } | 1528 | } |
1529 | 1529 | ||
1530 | const struct inode_operations jfs_dir_inode_operations = { | 1530 | const struct inode_operations jfs_dir_inode_operations = { |
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c index 48b15a6e5558..5becc6a3ff8c 100644 --- a/fs/jfs/xattr.c +++ b/fs/jfs/xattr.c | |||
@@ -933,8 +933,8 @@ ssize_t __jfs_getxattr(struct inode *inode, const char *name, void *data, | |||
933 | return size; | 933 | return size; |
934 | } | 934 | } |
935 | 935 | ||
936 | ssize_t jfs_getxattr(struct dentry *dentry, const char *name, void *data, | 936 | ssize_t jfs_getxattr(struct dentry *dentry, struct inode *inode, |
937 | size_t buf_size) | 937 | const char *name, void *data, size_t buf_size) |
938 | { | 938 | { |
939 | int err; | 939 | int err; |
940 | 940 | ||
@@ -944,7 +944,7 @@ ssize_t jfs_getxattr(struct dentry *dentry, const char *name, void *data, | |||
944 | * for it via sb->s_xattr. | 944 | * for it via sb->s_xattr. |
945 | */ | 945 | */ |
946 | if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) | 946 | if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) |
947 | return generic_getxattr(dentry, name, data, buf_size); | 947 | return generic_getxattr(dentry, inode, name, data, buf_size); |
948 | 948 | ||
949 | if (strncmp(name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) { | 949 | if (strncmp(name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) { |
950 | /* | 950 | /* |
@@ -959,7 +959,7 @@ ssize_t jfs_getxattr(struct dentry *dentry, const char *name, void *data, | |||
959 | return -EOPNOTSUPP; | 959 | return -EOPNOTSUPP; |
960 | } | 960 | } |
961 | 961 | ||
962 | err = __jfs_getxattr(d_inode(dentry), name, data, buf_size); | 962 | err = __jfs_getxattr(inode, name, data, buf_size); |
963 | 963 | ||
964 | return err; | 964 | return err; |
965 | } | 965 | } |
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 37f9678ae4df..68a44315d949 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c | |||
@@ -1643,22 +1643,9 @@ static int kernfs_fop_readdir(struct file *file, struct dir_context *ctx) | |||
1643 | return 0; | 1643 | return 0; |
1644 | } | 1644 | } |
1645 | 1645 | ||
1646 | static loff_t kernfs_dir_fop_llseek(struct file *file, loff_t offset, | ||
1647 | int whence) | ||
1648 | { | ||
1649 | struct inode *inode = file_inode(file); | ||
1650 | loff_t ret; | ||
1651 | |||
1652 | inode_lock(inode); | ||
1653 | ret = generic_file_llseek(file, offset, whence); | ||
1654 | inode_unlock(inode); | ||
1655 | |||
1656 | return ret; | ||
1657 | } | ||
1658 | |||
1659 | const struct file_operations kernfs_dir_fops = { | 1646 | const struct file_operations kernfs_dir_fops = { |
1660 | .read = generic_read_dir, | 1647 | .read = generic_read_dir, |
1661 | .iterate = kernfs_fop_readdir, | 1648 | .iterate_shared = kernfs_fop_readdir, |
1662 | .release = kernfs_dir_fop_release, | 1649 | .release = kernfs_dir_fop_release, |
1663 | .llseek = kernfs_dir_fop_llseek, | 1650 | .llseek = generic_file_llseek, |
1664 | }; | 1651 | }; |
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c index 16405ae88d2d..b5247226732b 100644 --- a/fs/kernfs/inode.c +++ b/fs/kernfs/inode.c | |||
@@ -208,10 +208,10 @@ int kernfs_iop_removexattr(struct dentry *dentry, const char *name) | |||
208 | return simple_xattr_set(&attrs->xattrs, name, NULL, 0, XATTR_REPLACE); | 208 | return simple_xattr_set(&attrs->xattrs, name, NULL, 0, XATTR_REPLACE); |
209 | } | 209 | } |
210 | 210 | ||
211 | ssize_t kernfs_iop_getxattr(struct dentry *dentry, const char *name, void *buf, | 211 | ssize_t kernfs_iop_getxattr(struct dentry *unused, struct inode *inode, |
212 | size_t size) | 212 | const char *name, void *buf, size_t size) |
213 | { | 213 | { |
214 | struct kernfs_node *kn = dentry->d_fsdata; | 214 | struct kernfs_node *kn = inode->i_private; |
215 | struct kernfs_iattrs *attrs; | 215 | struct kernfs_iattrs *attrs; |
216 | 216 | ||
217 | attrs = kernfs_iattrs(kn); | 217 | attrs = kernfs_iattrs(kn); |
diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h index 6762bfbd8207..45c9192c276e 100644 --- a/fs/kernfs/kernfs-internal.h +++ b/fs/kernfs/kernfs-internal.h | |||
@@ -84,8 +84,8 @@ int kernfs_iop_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
84 | int kernfs_iop_setxattr(struct dentry *dentry, const char *name, const void *value, | 84 | int kernfs_iop_setxattr(struct dentry *dentry, const char *name, const void *value, |
85 | size_t size, int flags); | 85 | size_t size, int flags); |
86 | int kernfs_iop_removexattr(struct dentry *dentry, const char *name); | 86 | int kernfs_iop_removexattr(struct dentry *dentry, const char *name); |
87 | ssize_t kernfs_iop_getxattr(struct dentry *dentry, const char *name, void *buf, | 87 | ssize_t kernfs_iop_getxattr(struct dentry *dentry, struct inode *inode, |
88 | size_t size); | 88 | const char *name, void *buf, size_t size); |
89 | ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size); | 89 | ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size); |
90 | 90 | ||
91 | /* | 91 | /* |
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c index 3d670a3678f2..63534f5f9073 100644 --- a/fs/kernfs/mount.c +++ b/fs/kernfs/mount.c | |||
@@ -135,9 +135,8 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn, | |||
135 | kntmp = find_next_ancestor(kn, knparent); | 135 | kntmp = find_next_ancestor(kn, knparent); |
136 | if (WARN_ON(!kntmp)) | 136 | if (WARN_ON(!kntmp)) |
137 | return ERR_PTR(-EINVAL); | 137 | return ERR_PTR(-EINVAL); |
138 | mutex_lock(&d_inode(dentry)->i_mutex); | 138 | dtmp = lookup_one_len_unlocked(kntmp->name, dentry, |
139 | dtmp = lookup_one_len(kntmp->name, dentry, strlen(kntmp->name)); | 139 | strlen(kntmp->name)); |
140 | mutex_unlock(&d_inode(dentry)->i_mutex); | ||
141 | dput(dentry); | 140 | dput(dentry); |
142 | if (IS_ERR(dtmp)) | 141 | if (IS_ERR(dtmp)) |
143 | return dtmp; | 142 | return dtmp; |
diff --git a/fs/libfs.c b/fs/libfs.c index f3fa82ce9b70..8765ff1adc07 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -89,7 +89,6 @@ EXPORT_SYMBOL(dcache_dir_close); | |||
89 | loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) | 89 | loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) |
90 | { | 90 | { |
91 | struct dentry *dentry = file->f_path.dentry; | 91 | struct dentry *dentry = file->f_path.dentry; |
92 | inode_lock(d_inode(dentry)); | ||
93 | switch (whence) { | 92 | switch (whence) { |
94 | case 1: | 93 | case 1: |
95 | offset += file->f_pos; | 94 | offset += file->f_pos; |
@@ -97,7 +96,6 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) | |||
97 | if (offset >= 0) | 96 | if (offset >= 0) |
98 | break; | 97 | break; |
99 | default: | 98 | default: |
100 | inode_unlock(d_inode(dentry)); | ||
101 | return -EINVAL; | 99 | return -EINVAL; |
102 | } | 100 | } |
103 | if (offset != file->f_pos) { | 101 | if (offset != file->f_pos) { |
@@ -124,7 +122,6 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) | |||
124 | spin_unlock(&dentry->d_lock); | 122 | spin_unlock(&dentry->d_lock); |
125 | } | 123 | } |
126 | } | 124 | } |
127 | inode_unlock(d_inode(dentry)); | ||
128 | return offset; | 125 | return offset; |
129 | } | 126 | } |
130 | EXPORT_SYMBOL(dcache_dir_lseek); | 127 | EXPORT_SYMBOL(dcache_dir_lseek); |
@@ -190,7 +187,7 @@ const struct file_operations simple_dir_operations = { | |||
190 | .release = dcache_dir_close, | 187 | .release = dcache_dir_close, |
191 | .llseek = dcache_dir_lseek, | 188 | .llseek = dcache_dir_lseek, |
192 | .read = generic_read_dir, | 189 | .read = generic_read_dir, |
193 | .iterate = dcache_readdir, | 190 | .iterate_shared = dcache_readdir, |
194 | .fsync = noop_fsync, | 191 | .fsync = noop_fsync, |
195 | }; | 192 | }; |
196 | EXPORT_SYMBOL(simple_dir_operations); | 193 | EXPORT_SYMBOL(simple_dir_operations); |
@@ -1127,8 +1124,8 @@ static int empty_dir_setxattr(struct dentry *dentry, const char *name, | |||
1127 | return -EOPNOTSUPP; | 1124 | return -EOPNOTSUPP; |
1128 | } | 1125 | } |
1129 | 1126 | ||
1130 | static ssize_t empty_dir_getxattr(struct dentry *dentry, const char *name, | 1127 | static ssize_t empty_dir_getxattr(struct dentry *dentry, struct inode *inode, |
1131 | void *value, size_t size) | 1128 | const char *name, void *value, size_t size) |
1132 | { | 1129 | { |
1133 | return -EOPNOTSUPP; | 1130 | return -EOPNOTSUPP; |
1134 | } | 1131 | } |
@@ -1169,7 +1166,7 @@ static int empty_dir_readdir(struct file *file, struct dir_context *ctx) | |||
1169 | static const struct file_operations empty_dir_operations = { | 1166 | static const struct file_operations empty_dir_operations = { |
1170 | .llseek = empty_dir_llseek, | 1167 | .llseek = empty_dir_llseek, |
1171 | .read = generic_read_dir, | 1168 | .read = generic_read_dir, |
1172 | .iterate = empty_dir_readdir, | 1169 | .iterate_shared = empty_dir_readdir, |
1173 | .fsync = noop_fsync, | 1170 | .fsync = noop_fsync, |
1174 | }; | 1171 | }; |
1175 | 1172 | ||
diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c index ddbed2be5366..2d5336bd4efd 100644 --- a/fs/logfs/dir.c +++ b/fs/logfs/dir.c | |||
@@ -791,7 +791,7 @@ const struct inode_operations logfs_dir_iops = { | |||
791 | const struct file_operations logfs_dir_fops = { | 791 | const struct file_operations logfs_dir_fops = { |
792 | .fsync = logfs_fsync, | 792 | .fsync = logfs_fsync, |
793 | .unlocked_ioctl = logfs_ioctl, | 793 | .unlocked_ioctl = logfs_ioctl, |
794 | .iterate = logfs_readdir, | 794 | .iterate_shared = logfs_readdir, |
795 | .read = generic_read_dir, | 795 | .read = generic_read_dir, |
796 | .llseek = default_llseek, | 796 | .llseek = generic_file_llseek, |
797 | }; | 797 | }; |
diff --git a/fs/minix/dir.c b/fs/minix/dir.c index 33957c07cd11..31dcd515b9d5 100644 --- a/fs/minix/dir.c +++ b/fs/minix/dir.c | |||
@@ -21,7 +21,7 @@ static int minix_readdir(struct file *, struct dir_context *); | |||
21 | const struct file_operations minix_dir_operations = { | 21 | const struct file_operations minix_dir_operations = { |
22 | .llseek = generic_file_llseek, | 22 | .llseek = generic_file_llseek, |
23 | .read = generic_read_dir, | 23 | .read = generic_read_dir, |
24 | .iterate = minix_readdir, | 24 | .iterate_shared = minix_readdir, |
25 | .fsync = generic_file_fsync, | 25 | .fsync = generic_file_fsync, |
26 | }; | 26 | }; |
27 | 27 | ||
diff --git a/fs/namei.c b/fs/namei.c index 42f8ca038254..11f3a18d9d2d 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -265,7 +265,7 @@ static int check_acl(struct inode *inode, int mask) | |||
265 | if (!acl) | 265 | if (!acl) |
266 | return -EAGAIN; | 266 | return -EAGAIN; |
267 | /* no ->get_acl() calls in RCU mode... */ | 267 | /* no ->get_acl() calls in RCU mode... */ |
268 | if (acl == ACL_NOT_CACHED) | 268 | if (is_uncached_acl(acl)) |
269 | return -ECHILD; | 269 | return -ECHILD; |
270 | return posix_acl_permission(inode, acl, mask & ~MAY_NOT_BLOCK); | 270 | return posix_acl_permission(inode, acl, mask & ~MAY_NOT_BLOCK); |
271 | } | 271 | } |
@@ -1603,32 +1603,42 @@ static struct dentry *lookup_slow(const struct qstr *name, | |||
1603 | struct dentry *dir, | 1603 | struct dentry *dir, |
1604 | unsigned int flags) | 1604 | unsigned int flags) |
1605 | { | 1605 | { |
1606 | struct dentry *dentry; | 1606 | struct dentry *dentry = ERR_PTR(-ENOENT), *old; |
1607 | inode_lock(dir->d_inode); | 1607 | struct inode *inode = dir->d_inode; |
1608 | dentry = d_lookup(dir, name); | 1608 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); |
1609 | if (unlikely(dentry)) { | 1609 | |
1610 | inode_lock_shared(inode); | ||
1611 | /* Don't go there if it's already dead */ | ||
1612 | if (unlikely(IS_DEADDIR(inode))) | ||
1613 | goto out; | ||
1614 | again: | ||
1615 | dentry = d_alloc_parallel(dir, name, &wq); | ||
1616 | if (IS_ERR(dentry)) | ||
1617 | goto out; | ||
1618 | if (unlikely(!d_in_lookup(dentry))) { | ||
1610 | if ((dentry->d_flags & DCACHE_OP_REVALIDATE) && | 1619 | if ((dentry->d_flags & DCACHE_OP_REVALIDATE) && |
1611 | !(flags & LOOKUP_NO_REVAL)) { | 1620 | !(flags & LOOKUP_NO_REVAL)) { |
1612 | int error = d_revalidate(dentry, flags); | 1621 | int error = d_revalidate(dentry, flags); |
1613 | if (unlikely(error <= 0)) { | 1622 | if (unlikely(error <= 0)) { |
1614 | if (!error) | 1623 | if (!error) { |
1615 | d_invalidate(dentry); | 1624 | d_invalidate(dentry); |
1625 | dput(dentry); | ||
1626 | goto again; | ||
1627 | } | ||
1616 | dput(dentry); | 1628 | dput(dentry); |
1617 | dentry = ERR_PTR(error); | 1629 | dentry = ERR_PTR(error); |
1618 | } | 1630 | } |
1619 | } | 1631 | } |
1620 | if (dentry) { | 1632 | } else { |
1621 | inode_unlock(dir->d_inode); | 1633 | old = inode->i_op->lookup(inode, dentry, flags); |
1622 | return dentry; | 1634 | d_lookup_done(dentry); |
1635 | if (unlikely(old)) { | ||
1636 | dput(dentry); | ||
1637 | dentry = old; | ||
1623 | } | 1638 | } |
1624 | } | 1639 | } |
1625 | dentry = d_alloc(dir, name); | 1640 | out: |
1626 | if (unlikely(!dentry)) { | 1641 | inode_unlock_shared(inode); |
1627 | inode_unlock(dir->d_inode); | ||
1628 | return ERR_PTR(-ENOMEM); | ||
1629 | } | ||
1630 | dentry = lookup_real(dir->d_inode, dentry, flags); | ||
1631 | inode_unlock(dir->d_inode); | ||
1632 | return dentry; | 1642 | return dentry; |
1633 | } | 1643 | } |
1634 | 1644 | ||
@@ -2697,7 +2707,7 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2) | |||
2697 | return NULL; | 2707 | return NULL; |
2698 | } | 2708 | } |
2699 | 2709 | ||
2700 | mutex_lock(&p1->d_inode->i_sb->s_vfs_rename_mutex); | 2710 | mutex_lock(&p1->d_sb->s_vfs_rename_mutex); |
2701 | 2711 | ||
2702 | p = d_ancestor(p2, p1); | 2712 | p = d_ancestor(p2, p1); |
2703 | if (p) { | 2713 | if (p) { |
@@ -2724,7 +2734,7 @@ void unlock_rename(struct dentry *p1, struct dentry *p2) | |||
2724 | inode_unlock(p1->d_inode); | 2734 | inode_unlock(p1->d_inode); |
2725 | if (p1 != p2) { | 2735 | if (p1 != p2) { |
2726 | inode_unlock(p2->d_inode); | 2736 | inode_unlock(p2->d_inode); |
2727 | mutex_unlock(&p1->d_inode->i_sb->s_vfs_rename_mutex); | 2737 | mutex_unlock(&p1->d_sb->s_vfs_rename_mutex); |
2728 | } | 2738 | } |
2729 | } | 2739 | } |
2730 | EXPORT_SYMBOL(unlock_rename); | 2740 | EXPORT_SYMBOL(unlock_rename); |
@@ -2856,143 +2866,56 @@ static int may_o_create(struct path *dir, struct dentry *dentry, umode_t mode) | |||
2856 | static int atomic_open(struct nameidata *nd, struct dentry *dentry, | 2866 | static int atomic_open(struct nameidata *nd, struct dentry *dentry, |
2857 | struct path *path, struct file *file, | 2867 | struct path *path, struct file *file, |
2858 | const struct open_flags *op, | 2868 | const struct open_flags *op, |
2859 | bool got_write, bool need_lookup, | 2869 | int open_flag, umode_t mode, |
2860 | int *opened) | 2870 | int *opened) |
2861 | { | 2871 | { |
2872 | struct dentry *const DENTRY_NOT_SET = (void *) -1UL; | ||
2862 | struct inode *dir = nd->path.dentry->d_inode; | 2873 | struct inode *dir = nd->path.dentry->d_inode; |
2863 | unsigned open_flag = open_to_namei_flags(op->open_flag); | ||
2864 | umode_t mode; | ||
2865 | int error; | 2874 | int error; |
2866 | int acc_mode; | ||
2867 | int create_error = 0; | ||
2868 | struct dentry *const DENTRY_NOT_SET = (void *) -1UL; | ||
2869 | bool excl; | ||
2870 | |||
2871 | BUG_ON(dentry->d_inode); | ||
2872 | |||
2873 | /* Don't create child dentry for a dead directory. */ | ||
2874 | if (unlikely(IS_DEADDIR(dir))) { | ||
2875 | error = -ENOENT; | ||
2876 | goto out; | ||
2877 | } | ||
2878 | 2875 | ||
2879 | mode = op->mode; | 2876 | if (!(~open_flag & (O_EXCL | O_CREAT))) /* both O_EXCL and O_CREAT */ |
2880 | if ((open_flag & O_CREAT) && !IS_POSIXACL(dir)) | ||
2881 | mode &= ~current_umask(); | ||
2882 | |||
2883 | excl = (open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT); | ||
2884 | if (excl) | ||
2885 | open_flag &= ~O_TRUNC; | 2877 | open_flag &= ~O_TRUNC; |
2886 | 2878 | ||
2887 | /* | ||
2888 | * Checking write permission is tricky, bacuse we don't know if we are | ||
2889 | * going to actually need it: O_CREAT opens should work as long as the | ||
2890 | * file exists. But checking existence breaks atomicity. The trick is | ||
2891 | * to check access and if not granted clear O_CREAT from the flags. | ||
2892 | * | ||
2893 | * Another problem is returing the "right" error value (e.g. for an | ||
2894 | * O_EXCL open we want to return EEXIST not EROFS). | ||
2895 | */ | ||
2896 | if (((open_flag & (O_CREAT | O_TRUNC)) || | ||
2897 | (open_flag & O_ACCMODE) != O_RDONLY) && unlikely(!got_write)) { | ||
2898 | if (!(open_flag & O_CREAT)) { | ||
2899 | /* | ||
2900 | * No O_CREATE -> atomicity not a requirement -> fall | ||
2901 | * back to lookup + open | ||
2902 | */ | ||
2903 | goto no_open; | ||
2904 | } else if (open_flag & (O_EXCL | O_TRUNC)) { | ||
2905 | /* Fall back and fail with the right error */ | ||
2906 | create_error = -EROFS; | ||
2907 | goto no_open; | ||
2908 | } else { | ||
2909 | /* No side effects, safe to clear O_CREAT */ | ||
2910 | create_error = -EROFS; | ||
2911 | open_flag &= ~O_CREAT; | ||
2912 | } | ||
2913 | } | ||
2914 | |||
2915 | if (open_flag & O_CREAT) { | ||
2916 | error = may_o_create(&nd->path, dentry, mode); | ||
2917 | if (error) { | ||
2918 | create_error = error; | ||
2919 | if (open_flag & O_EXCL) | ||
2920 | goto no_open; | ||
2921 | open_flag &= ~O_CREAT; | ||
2922 | } | ||
2923 | } | ||
2924 | |||
2925 | if (nd->flags & LOOKUP_DIRECTORY) | 2879 | if (nd->flags & LOOKUP_DIRECTORY) |
2926 | open_flag |= O_DIRECTORY; | 2880 | open_flag |= O_DIRECTORY; |
2927 | 2881 | ||
2928 | file->f_path.dentry = DENTRY_NOT_SET; | 2882 | file->f_path.dentry = DENTRY_NOT_SET; |
2929 | file->f_path.mnt = nd->path.mnt; | 2883 | file->f_path.mnt = nd->path.mnt; |
2930 | error = dir->i_op->atomic_open(dir, dentry, file, open_flag, mode, | 2884 | error = dir->i_op->atomic_open(dir, dentry, file, |
2931 | opened); | 2885 | open_to_namei_flags(open_flag), |
2932 | if (error < 0) { | 2886 | mode, opened); |
2933 | if (create_error && error == -ENOENT) | 2887 | d_lookup_done(dentry); |
2934 | error = create_error; | 2888 | if (!error) { |
2935 | goto out; | 2889 | /* |
2936 | } | 2890 | * We didn't have the inode before the open, so check open |
2937 | 2891 | * permission here. | |
2938 | if (error) { /* returned 1, that is */ | 2892 | */ |
2893 | int acc_mode = op->acc_mode; | ||
2894 | if (*opened & FILE_CREATED) { | ||
2895 | WARN_ON(!(open_flag & O_CREAT)); | ||
2896 | fsnotify_create(dir, dentry); | ||
2897 | acc_mode = 0; | ||
2898 | } | ||
2899 | error = may_open(&file->f_path, acc_mode, open_flag); | ||
2900 | if (WARN_ON(error > 0)) | ||
2901 | error = -EINVAL; | ||
2902 | } else if (error > 0) { | ||
2939 | if (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) { | 2903 | if (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) { |
2940 | error = -EIO; | 2904 | error = -EIO; |
2941 | goto out; | ||
2942 | } | ||
2943 | if (file->f_path.dentry) { | ||
2944 | dput(dentry); | ||
2945 | dentry = file->f_path.dentry; | ||
2946 | } | ||
2947 | if (*opened & FILE_CREATED) | ||
2948 | fsnotify_create(dir, dentry); | ||
2949 | if (!dentry->d_inode) { | ||
2950 | WARN_ON(*opened & FILE_CREATED); | ||
2951 | if (create_error) { | ||
2952 | error = create_error; | ||
2953 | goto out; | ||
2954 | } | ||
2955 | } else { | 2905 | } else { |
2956 | if (excl && !(*opened & FILE_CREATED)) { | 2906 | if (file->f_path.dentry) { |
2957 | error = -EEXIST; | 2907 | dput(dentry); |
2958 | goto out; | 2908 | dentry = file->f_path.dentry; |
2959 | } | 2909 | } |
2910 | if (*opened & FILE_CREATED) | ||
2911 | fsnotify_create(dir, dentry); | ||
2912 | path->dentry = dentry; | ||
2913 | path->mnt = nd->path.mnt; | ||
2914 | return 1; | ||
2960 | } | 2915 | } |
2961 | goto looked_up; | ||
2962 | } | ||
2963 | |||
2964 | /* | ||
2965 | * We didn't have the inode before the open, so check open permission | ||
2966 | * here. | ||
2967 | */ | ||
2968 | acc_mode = op->acc_mode; | ||
2969 | if (*opened & FILE_CREATED) { | ||
2970 | WARN_ON(!(open_flag & O_CREAT)); | ||
2971 | fsnotify_create(dir, dentry); | ||
2972 | acc_mode = 0; | ||
2973 | } | 2916 | } |
2974 | error = may_open(&file->f_path, acc_mode, open_flag); | ||
2975 | if (error) | ||
2976 | fput(file); | ||
2977 | |||
2978 | out: | ||
2979 | dput(dentry); | 2917 | dput(dentry); |
2980 | return error; | 2918 | return error; |
2981 | |||
2982 | no_open: | ||
2983 | if (need_lookup) { | ||
2984 | dentry = lookup_real(dir, dentry, nd->flags); | ||
2985 | if (IS_ERR(dentry)) | ||
2986 | return PTR_ERR(dentry); | ||
2987 | } | ||
2988 | if (create_error && !dentry->d_inode) { | ||
2989 | error = create_error; | ||
2990 | goto out; | ||
2991 | } | ||
2992 | looked_up: | ||
2993 | path->dentry = dentry; | ||
2994 | path->mnt = nd->path.mnt; | ||
2995 | return 1; | ||
2996 | } | 2919 | } |
2997 | 2920 | ||
2998 | /* | 2921 | /* |
@@ -3020,62 +2943,118 @@ static int lookup_open(struct nameidata *nd, struct path *path, | |||
3020 | { | 2943 | { |
3021 | struct dentry *dir = nd->path.dentry; | 2944 | struct dentry *dir = nd->path.dentry; |
3022 | struct inode *dir_inode = dir->d_inode; | 2945 | struct inode *dir_inode = dir->d_inode; |
2946 | int open_flag = op->open_flag; | ||
3023 | struct dentry *dentry; | 2947 | struct dentry *dentry; |
3024 | int error; | 2948 | int error, create_error = 0; |
3025 | bool need_lookup = false; | 2949 | umode_t mode = op->mode; |
2950 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); | ||
2951 | |||
2952 | if (unlikely(IS_DEADDIR(dir_inode))) | ||
2953 | return -ENOENT; | ||
3026 | 2954 | ||
3027 | *opened &= ~FILE_CREATED; | 2955 | *opened &= ~FILE_CREATED; |
3028 | dentry = lookup_dcache(&nd->last, dir, nd->flags); | 2956 | dentry = d_lookup(dir, &nd->last); |
3029 | if (IS_ERR(dentry)) | 2957 | for (;;) { |
3030 | return PTR_ERR(dentry); | 2958 | if (!dentry) { |
2959 | dentry = d_alloc_parallel(dir, &nd->last, &wq); | ||
2960 | if (IS_ERR(dentry)) | ||
2961 | return PTR_ERR(dentry); | ||
2962 | } | ||
2963 | if (d_in_lookup(dentry)) | ||
2964 | break; | ||
3031 | 2965 | ||
3032 | if (!dentry) { | 2966 | if (!(dentry->d_flags & DCACHE_OP_REVALIDATE)) |
3033 | dentry = d_alloc(dir, &nd->last); | 2967 | break; |
3034 | if (unlikely(!dentry)) | 2968 | |
3035 | return -ENOMEM; | 2969 | error = d_revalidate(dentry, nd->flags); |
3036 | need_lookup = true; | 2970 | if (likely(error > 0)) |
3037 | } else if (dentry->d_inode) { | 2971 | break; |
2972 | if (error) | ||
2973 | goto out_dput; | ||
2974 | d_invalidate(dentry); | ||
2975 | dput(dentry); | ||
2976 | dentry = NULL; | ||
2977 | } | ||
2978 | if (dentry->d_inode) { | ||
3038 | /* Cached positive dentry: will open in f_op->open */ | 2979 | /* Cached positive dentry: will open in f_op->open */ |
3039 | goto out_no_open; | 2980 | goto out_no_open; |
3040 | } | 2981 | } |
3041 | 2982 | ||
3042 | if ((nd->flags & LOOKUP_OPEN) && dir_inode->i_op->atomic_open) { | 2983 | /* |
3043 | return atomic_open(nd, dentry, path, file, op, got_write, | 2984 | * Checking write permission is tricky, bacuse we don't know if we are |
3044 | need_lookup, opened); | 2985 | * going to actually need it: O_CREAT opens should work as long as the |
2986 | * file exists. But checking existence breaks atomicity. The trick is | ||
2987 | * to check access and if not granted clear O_CREAT from the flags. | ||
2988 | * | ||
2989 | * Another problem is returing the "right" error value (e.g. for an | ||
2990 | * O_EXCL open we want to return EEXIST not EROFS). | ||
2991 | */ | ||
2992 | if (open_flag & O_CREAT) { | ||
2993 | if (!IS_POSIXACL(dir->d_inode)) | ||
2994 | mode &= ~current_umask(); | ||
2995 | if (unlikely(!got_write)) { | ||
2996 | create_error = -EROFS; | ||
2997 | open_flag &= ~O_CREAT; | ||
2998 | if (open_flag & (O_EXCL | O_TRUNC)) | ||
2999 | goto no_open; | ||
3000 | /* No side effects, safe to clear O_CREAT */ | ||
3001 | } else { | ||
3002 | create_error = may_o_create(&nd->path, dentry, mode); | ||
3003 | if (create_error) { | ||
3004 | open_flag &= ~O_CREAT; | ||
3005 | if (open_flag & O_EXCL) | ||
3006 | goto no_open; | ||
3007 | } | ||
3008 | } | ||
3009 | } else if ((open_flag & (O_TRUNC|O_WRONLY|O_RDWR)) && | ||
3010 | unlikely(!got_write)) { | ||
3011 | /* | ||
3012 | * No O_CREATE -> atomicity not a requirement -> fall | ||
3013 | * back to lookup + open | ||
3014 | */ | ||
3015 | goto no_open; | ||
3045 | } | 3016 | } |
3046 | 3017 | ||
3047 | if (need_lookup) { | 3018 | if (dir_inode->i_op->atomic_open) { |
3048 | BUG_ON(dentry->d_inode); | 3019 | error = atomic_open(nd, dentry, path, file, op, open_flag, |
3020 | mode, opened); | ||
3021 | if (unlikely(error == -ENOENT) && create_error) | ||
3022 | error = create_error; | ||
3023 | return error; | ||
3024 | } | ||
3049 | 3025 | ||
3050 | dentry = lookup_real(dir_inode, dentry, nd->flags); | 3026 | no_open: |
3051 | if (IS_ERR(dentry)) | 3027 | if (d_in_lookup(dentry)) { |
3052 | return PTR_ERR(dentry); | 3028 | struct dentry *res = dir_inode->i_op->lookup(dir_inode, dentry, |
3029 | nd->flags); | ||
3030 | d_lookup_done(dentry); | ||
3031 | if (unlikely(res)) { | ||
3032 | if (IS_ERR(res)) { | ||
3033 | error = PTR_ERR(res); | ||
3034 | goto out_dput; | ||
3035 | } | ||
3036 | dput(dentry); | ||
3037 | dentry = res; | ||
3038 | } | ||
3053 | } | 3039 | } |
3054 | 3040 | ||
3055 | /* Negative dentry, just create the file */ | 3041 | /* Negative dentry, just create the file */ |
3056 | if (!dentry->d_inode && (op->open_flag & O_CREAT)) { | 3042 | if (!dentry->d_inode && (open_flag & O_CREAT)) { |
3057 | umode_t mode = op->mode; | ||
3058 | if (!IS_POSIXACL(dir->d_inode)) | ||
3059 | mode &= ~current_umask(); | ||
3060 | /* | ||
3061 | * This write is needed to ensure that a | ||
3062 | * rw->ro transition does not occur between | ||
3063 | * the time when the file is created and when | ||
3064 | * a permanent write count is taken through | ||
3065 | * the 'struct file' in finish_open(). | ||
3066 | */ | ||
3067 | if (!got_write) { | ||
3068 | error = -EROFS; | ||
3069 | goto out_dput; | ||
3070 | } | ||
3071 | *opened |= FILE_CREATED; | 3043 | *opened |= FILE_CREATED; |
3072 | error = security_path_mknod(&nd->path, dentry, mode, 0); | 3044 | audit_inode_child(dir_inode, dentry, AUDIT_TYPE_CHILD_CREATE); |
3073 | if (error) | 3045 | if (!dir_inode->i_op->create) { |
3046 | error = -EACCES; | ||
3074 | goto out_dput; | 3047 | goto out_dput; |
3075 | error = vfs_create(dir->d_inode, dentry, mode, | 3048 | } |
3076 | nd->flags & LOOKUP_EXCL); | 3049 | error = dir_inode->i_op->create(dir_inode, dentry, mode, |
3050 | open_flag & O_EXCL); | ||
3077 | if (error) | 3051 | if (error) |
3078 | goto out_dput; | 3052 | goto out_dput; |
3053 | fsnotify_create(dir_inode, dentry); | ||
3054 | } | ||
3055 | if (unlikely(create_error) && !dentry->d_inode) { | ||
3056 | error = create_error; | ||
3057 | goto out_dput; | ||
3079 | } | 3058 | } |
3080 | out_no_open: | 3059 | out_no_open: |
3081 | path->dentry = dentry; | 3060 | path->dentry = dentry; |
@@ -3147,7 +3126,7 @@ static int do_last(struct nameidata *nd, | |||
3147 | } | 3126 | } |
3148 | 3127 | ||
3149 | retry_lookup: | 3128 | retry_lookup: |
3150 | if (op->open_flag & (O_CREAT | O_TRUNC | O_WRONLY | O_RDWR)) { | 3129 | if (open_flag & (O_CREAT | O_TRUNC | O_WRONLY | O_RDWR)) { |
3151 | error = mnt_want_write(nd->path.mnt); | 3130 | error = mnt_want_write(nd->path.mnt); |
3152 | if (!error) | 3131 | if (!error) |
3153 | got_write = true; | 3132 | got_write = true; |
@@ -3157,9 +3136,15 @@ retry_lookup: | |||
3157 | * dropping this one anyway. | 3136 | * dropping this one anyway. |
3158 | */ | 3137 | */ |
3159 | } | 3138 | } |
3160 | inode_lock(dir->d_inode); | 3139 | if (open_flag & O_CREAT) |
3140 | inode_lock(dir->d_inode); | ||
3141 | else | ||
3142 | inode_lock_shared(dir->d_inode); | ||
3161 | error = lookup_open(nd, &path, file, op, got_write, opened); | 3143 | error = lookup_open(nd, &path, file, op, got_write, opened); |
3162 | inode_unlock(dir->d_inode); | 3144 | if (open_flag & O_CREAT) |
3145 | inode_unlock(dir->d_inode); | ||
3146 | else | ||
3147 | inode_unlock_shared(dir->d_inode); | ||
3163 | 3148 | ||
3164 | if (error <= 0) { | 3149 | if (error <= 0) { |
3165 | if (error) | 3150 | if (error) |
@@ -3239,10 +3224,6 @@ finish_open: | |||
3239 | return error; | 3224 | return error; |
3240 | } | 3225 | } |
3241 | audit_inode(nd->name, nd->path.dentry, 0); | 3226 | audit_inode(nd->name, nd->path.dentry, 0); |
3242 | if (unlikely(d_is_symlink(nd->path.dentry)) && !(open_flag & O_PATH)) { | ||
3243 | error = -ELOOP; | ||
3244 | goto out; | ||
3245 | } | ||
3246 | error = -EISDIR; | 3227 | error = -EISDIR; |
3247 | if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry)) | 3228 | if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry)) |
3248 | goto out; | 3229 | goto out; |
@@ -3259,11 +3240,9 @@ finish_open: | |||
3259 | got_write = true; | 3240 | got_write = true; |
3260 | } | 3241 | } |
3261 | finish_open_created: | 3242 | finish_open_created: |
3262 | if (likely(!(open_flag & O_PATH))) { | 3243 | error = may_open(&nd->path, acc_mode, open_flag); |
3263 | error = may_open(&nd->path, acc_mode, open_flag); | 3244 | if (error) |
3264 | if (error) | 3245 | goto out; |
3265 | goto out; | ||
3266 | } | ||
3267 | BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */ | 3246 | BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */ |
3268 | error = vfs_open(&nd->path, file, current_cred()); | 3247 | error = vfs_open(&nd->path, file, current_cred()); |
3269 | if (!error) { | 3248 | if (!error) { |
@@ -3275,18 +3254,13 @@ finish_open_created: | |||
3275 | } | 3254 | } |
3276 | opened: | 3255 | opened: |
3277 | error = open_check_o_direct(file); | 3256 | error = open_check_o_direct(file); |
3278 | if (error) | 3257 | if (!error) |
3279 | goto exit_fput; | 3258 | error = ima_file_check(file, op->acc_mode, *opened); |
3280 | error = ima_file_check(file, op->acc_mode, *opened); | 3259 | if (!error && will_truncate) |
3281 | if (error) | ||
3282 | goto exit_fput; | ||
3283 | |||
3284 | if (will_truncate) { | ||
3285 | error = handle_truncate(file); | 3260 | error = handle_truncate(file); |
3286 | if (error) | ||
3287 | goto exit_fput; | ||
3288 | } | ||
3289 | out: | 3261 | out: |
3262 | if (unlikely(error) && (*opened & FILE_OPENED)) | ||
3263 | fput(file); | ||
3290 | if (unlikely(error > 0)) { | 3264 | if (unlikely(error > 0)) { |
3291 | WARN_ON(1); | 3265 | WARN_ON(1); |
3292 | error = -EINVAL; | 3266 | error = -EINVAL; |
@@ -3296,10 +3270,6 @@ out: | |||
3296 | path_put(&save_parent); | 3270 | path_put(&save_parent); |
3297 | return error; | 3271 | return error; |
3298 | 3272 | ||
3299 | exit_fput: | ||
3300 | fput(file); | ||
3301 | goto out; | ||
3302 | |||
3303 | stale_open: | 3273 | stale_open: |
3304 | /* If no saved parent or already retried then can't retry */ | 3274 | /* If no saved parent or already retried then can't retry */ |
3305 | if (!save_parent.dentry || retried) | 3275 | if (!save_parent.dentry || retried) |
@@ -3377,6 +3347,18 @@ out: | |||
3377 | return error; | 3347 | return error; |
3378 | } | 3348 | } |
3379 | 3349 | ||
3350 | static int do_o_path(struct nameidata *nd, unsigned flags, struct file *file) | ||
3351 | { | ||
3352 | struct path path; | ||
3353 | int error = path_lookupat(nd, flags, &path); | ||
3354 | if (!error) { | ||
3355 | audit_inode(nd->name, path.dentry, 0); | ||
3356 | error = vfs_open(&path, file, current_cred()); | ||
3357 | path_put(&path); | ||
3358 | } | ||
3359 | return error; | ||
3360 | } | ||
3361 | |||
3380 | static struct file *path_openat(struct nameidata *nd, | 3362 | static struct file *path_openat(struct nameidata *nd, |
3381 | const struct open_flags *op, unsigned flags) | 3363 | const struct open_flags *op, unsigned flags) |
3382 | { | 3364 | { |
@@ -3396,6 +3378,13 @@ static struct file *path_openat(struct nameidata *nd, | |||
3396 | goto out2; | 3378 | goto out2; |
3397 | } | 3379 | } |
3398 | 3380 | ||
3381 | if (unlikely(file->f_flags & O_PATH)) { | ||
3382 | error = do_o_path(nd, flags, file); | ||
3383 | if (!error) | ||
3384 | opened |= FILE_OPENED; | ||
3385 | goto out2; | ||
3386 | } | ||
3387 | |||
3399 | s = path_init(nd, flags); | 3388 | s = path_init(nd, flags); |
3400 | if (IS_ERR(s)) { | 3389 | if (IS_ERR(s)) { |
3401 | put_filp(file); | 3390 | put_filp(file); |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 33eb81738d03..aaf7bd0cbae2 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -57,7 +57,7 @@ static void nfs_readdir_clear_array(struct page*); | |||
57 | const struct file_operations nfs_dir_operations = { | 57 | const struct file_operations nfs_dir_operations = { |
58 | .llseek = nfs_llseek_dir, | 58 | .llseek = nfs_llseek_dir, |
59 | .read = generic_read_dir, | 59 | .read = generic_read_dir, |
60 | .iterate = nfs_readdir, | 60 | .iterate_shared = nfs_readdir, |
61 | .open = nfs_opendir, | 61 | .open = nfs_opendir, |
62 | .release = nfs_closedir, | 62 | .release = nfs_closedir, |
63 | .fsync = nfs_fsync_dir, | 63 | .fsync = nfs_fsync_dir, |
@@ -145,6 +145,7 @@ struct nfs_cache_array_entry { | |||
145 | }; | 145 | }; |
146 | 146 | ||
147 | struct nfs_cache_array { | 147 | struct nfs_cache_array { |
148 | atomic_t refcount; | ||
148 | int size; | 149 | int size; |
149 | int eof_index; | 150 | int eof_index; |
150 | u64 last_cookie; | 151 | u64 last_cookie; |
@@ -200,11 +201,20 @@ void nfs_readdir_clear_array(struct page *page) | |||
200 | int i; | 201 | int i; |
201 | 202 | ||
202 | array = kmap_atomic(page); | 203 | array = kmap_atomic(page); |
203 | for (i = 0; i < array->size; i++) | 204 | if (atomic_dec_and_test(&array->refcount)) |
204 | kfree(array->array[i].string.name); | 205 | for (i = 0; i < array->size; i++) |
206 | kfree(array->array[i].string.name); | ||
205 | kunmap_atomic(array); | 207 | kunmap_atomic(array); |
206 | } | 208 | } |
207 | 209 | ||
210 | static bool grab_page(struct page *page) | ||
211 | { | ||
212 | struct nfs_cache_array *array = kmap_atomic(page); | ||
213 | bool res = atomic_inc_not_zero(&array->refcount); | ||
214 | kunmap_atomic(array); | ||
215 | return res; | ||
216 | } | ||
217 | |||
208 | /* | 218 | /* |
209 | * the caller is responsible for freeing qstr.name | 219 | * the caller is responsible for freeing qstr.name |
210 | * when called by nfs_readdir_add_to_array, the strings will be freed in | 220 | * when called by nfs_readdir_add_to_array, the strings will be freed in |
@@ -470,6 +480,7 @@ static | |||
470 | void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry) | 480 | void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry) |
471 | { | 481 | { |
472 | struct qstr filename = QSTR_INIT(entry->name, entry->len); | 482 | struct qstr filename = QSTR_INIT(entry->name, entry->len); |
483 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); | ||
473 | struct dentry *dentry; | 484 | struct dentry *dentry; |
474 | struct dentry *alias; | 485 | struct dentry *alias; |
475 | struct inode *dir = d_inode(parent); | 486 | struct inode *dir = d_inode(parent); |
@@ -489,7 +500,13 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry) | |||
489 | filename.hash = full_name_hash(filename.name, filename.len); | 500 | filename.hash = full_name_hash(filename.name, filename.len); |
490 | 501 | ||
491 | dentry = d_lookup(parent, &filename); | 502 | dentry = d_lookup(parent, &filename); |
492 | if (dentry != NULL) { | 503 | again: |
504 | if (!dentry) { | ||
505 | dentry = d_alloc_parallel(parent, &filename, &wq); | ||
506 | if (IS_ERR(dentry)) | ||
507 | return; | ||
508 | } | ||
509 | if (!d_in_lookup(dentry)) { | ||
493 | /* Is there a mountpoint here? If so, just exit */ | 510 | /* Is there a mountpoint here? If so, just exit */ |
494 | if (!nfs_fsid_equal(&NFS_SB(dentry->d_sb)->fsid, | 511 | if (!nfs_fsid_equal(&NFS_SB(dentry->d_sb)->fsid, |
495 | &entry->fattr->fsid)) | 512 | &entry->fattr->fsid)) |
@@ -503,26 +520,21 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry) | |||
503 | } else { | 520 | } else { |
504 | d_invalidate(dentry); | 521 | d_invalidate(dentry); |
505 | dput(dentry); | 522 | dput(dentry); |
523 | dentry = NULL; | ||
524 | goto again; | ||
506 | } | 525 | } |
507 | } | 526 | } |
508 | 527 | ||
509 | dentry = d_alloc(parent, &filename); | ||
510 | if (dentry == NULL) | ||
511 | return; | ||
512 | |||
513 | inode = nfs_fhget(dentry->d_sb, entry->fh, entry->fattr, entry->label); | 528 | inode = nfs_fhget(dentry->d_sb, entry->fh, entry->fattr, entry->label); |
514 | if (IS_ERR(inode)) | ||
515 | goto out; | ||
516 | |||
517 | alias = d_splice_alias(inode, dentry); | 529 | alias = d_splice_alias(inode, dentry); |
518 | if (IS_ERR(alias)) | 530 | d_lookup_done(dentry); |
519 | goto out; | 531 | if (alias) { |
520 | else if (alias) { | 532 | if (IS_ERR(alias)) |
521 | nfs_set_verifier(alias, nfs_save_change_attribute(dir)); | 533 | goto out; |
522 | dput(alias); | 534 | dput(dentry); |
523 | } else | 535 | dentry = alias; |
524 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 536 | } |
525 | 537 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | |
526 | out: | 538 | out: |
527 | dput(dentry); | 539 | dput(dentry); |
528 | } | 540 | } |
@@ -643,6 +655,7 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, | |||
643 | goto out_label_free; | 655 | goto out_label_free; |
644 | } | 656 | } |
645 | memset(array, 0, sizeof(struct nfs_cache_array)); | 657 | memset(array, 0, sizeof(struct nfs_cache_array)); |
658 | atomic_set(&array->refcount, 1); | ||
646 | array->eof_index = -1; | 659 | array->eof_index = -1; |
647 | 660 | ||
648 | status = nfs_readdir_alloc_pages(pages, array_size); | 661 | status = nfs_readdir_alloc_pages(pages, array_size); |
@@ -705,8 +718,7 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page* page) | |||
705 | static | 718 | static |
706 | void cache_page_release(nfs_readdir_descriptor_t *desc) | 719 | void cache_page_release(nfs_readdir_descriptor_t *desc) |
707 | { | 720 | { |
708 | if (!desc->page->mapping) | 721 | nfs_readdir_clear_array(desc->page); |
709 | nfs_readdir_clear_array(desc->page); | ||
710 | put_page(desc->page); | 722 | put_page(desc->page); |
711 | desc->page = NULL; | 723 | desc->page = NULL; |
712 | } | 724 | } |
@@ -714,8 +726,16 @@ void cache_page_release(nfs_readdir_descriptor_t *desc) | |||
714 | static | 726 | static |
715 | struct page *get_cache_page(nfs_readdir_descriptor_t *desc) | 727 | struct page *get_cache_page(nfs_readdir_descriptor_t *desc) |
716 | { | 728 | { |
717 | return read_cache_page(file_inode(desc->file)->i_mapping, | 729 | struct page *page; |
730 | |||
731 | for (;;) { | ||
732 | page = read_cache_page(file_inode(desc->file)->i_mapping, | ||
718 | desc->page_index, (filler_t *)nfs_readdir_filler, desc); | 733 | desc->page_index, (filler_t *)nfs_readdir_filler, desc); |
734 | if (IS_ERR(page) || grab_page(page)) | ||
735 | break; | ||
736 | put_page(page); | ||
737 | } | ||
738 | return page; | ||
719 | } | 739 | } |
720 | 740 | ||
721 | /* | 741 | /* |
@@ -889,7 +909,6 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) | |||
889 | desc->decode = NFS_PROTO(inode)->decode_dirent; | 909 | desc->decode = NFS_PROTO(inode)->decode_dirent; |
890 | desc->plus = nfs_use_readdirplus(inode, ctx) ? 1 : 0; | 910 | desc->plus = nfs_use_readdirplus(inode, ctx) ? 1 : 0; |
891 | 911 | ||
892 | nfs_block_sillyrename(dentry); | ||
893 | if (ctx->pos == 0 || nfs_dir_mapping_need_revalidate(inode)) | 912 | if (ctx->pos == 0 || nfs_dir_mapping_need_revalidate(inode)) |
894 | res = nfs_revalidate_mapping(inode, file->f_mapping); | 913 | res = nfs_revalidate_mapping(inode, file->f_mapping); |
895 | if (res < 0) | 914 | if (res < 0) |
@@ -925,7 +944,6 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) | |||
925 | break; | 944 | break; |
926 | } while (!desc->eof); | 945 | } while (!desc->eof); |
927 | out: | 946 | out: |
928 | nfs_unblock_sillyrename(dentry); | ||
929 | if (res > 0) | 947 | if (res > 0) |
930 | res = 0; | 948 | res = 0; |
931 | dfprintk(FILE, "NFS: readdir(%pD2) returns %d\n", file, res); | 949 | dfprintk(FILE, "NFS: readdir(%pD2) returns %d\n", file, res); |
@@ -934,13 +952,11 @@ out: | |||
934 | 952 | ||
935 | static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence) | 953 | static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence) |
936 | { | 954 | { |
937 | struct inode *inode = file_inode(filp); | ||
938 | struct nfs_open_dir_context *dir_ctx = filp->private_data; | 955 | struct nfs_open_dir_context *dir_ctx = filp->private_data; |
939 | 956 | ||
940 | dfprintk(FILE, "NFS: llseek dir(%pD2, %lld, %d)\n", | 957 | dfprintk(FILE, "NFS: llseek dir(%pD2, %lld, %d)\n", |
941 | filp, offset, whence); | 958 | filp, offset, whence); |
942 | 959 | ||
943 | inode_lock(inode); | ||
944 | switch (whence) { | 960 | switch (whence) { |
945 | case 1: | 961 | case 1: |
946 | offset += filp->f_pos; | 962 | offset += filp->f_pos; |
@@ -948,16 +964,13 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence) | |||
948 | if (offset >= 0) | 964 | if (offset >= 0) |
949 | break; | 965 | break; |
950 | default: | 966 | default: |
951 | offset = -EINVAL; | 967 | return -EINVAL; |
952 | goto out; | ||
953 | } | 968 | } |
954 | if (offset != filp->f_pos) { | 969 | if (offset != filp->f_pos) { |
955 | filp->f_pos = offset; | 970 | filp->f_pos = offset; |
956 | dir_ctx->dir_cookie = 0; | 971 | dir_ctx->dir_cookie = 0; |
957 | dir_ctx->duped = 0; | 972 | dir_ctx->duped = 0; |
958 | } | 973 | } |
959 | out: | ||
960 | inode_unlock(inode); | ||
961 | return offset; | 974 | return offset; |
962 | } | 975 | } |
963 | 976 | ||
@@ -1383,7 +1396,6 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in | |||
1383 | parent = dentry->d_parent; | 1396 | parent = dentry->d_parent; |
1384 | /* Protect against concurrent sillydeletes */ | 1397 | /* Protect against concurrent sillydeletes */ |
1385 | trace_nfs_lookup_enter(dir, dentry, flags); | 1398 | trace_nfs_lookup_enter(dir, dentry, flags); |
1386 | nfs_block_sillyrename(parent); | ||
1387 | error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label); | 1399 | error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label); |
1388 | if (error == -ENOENT) | 1400 | if (error == -ENOENT) |
1389 | goto no_entry; | 1401 | goto no_entry; |
@@ -1408,7 +1420,6 @@ no_entry: | |||
1408 | } | 1420 | } |
1409 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 1421 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
1410 | out_unblock_sillyrename: | 1422 | out_unblock_sillyrename: |
1411 | nfs_unblock_sillyrename(parent); | ||
1412 | trace_nfs_lookup_exit(dir, dentry, flags, error); | 1423 | trace_nfs_lookup_exit(dir, dentry, flags, error); |
1413 | nfs4_label_free(label); | 1424 | nfs4_label_free(label); |
1414 | out: | 1425 | out: |
@@ -1520,9 +1531,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry, | |||
1520 | goto out; | 1531 | goto out; |
1521 | 1532 | ||
1522 | trace_nfs_atomic_open_enter(dir, ctx, open_flags); | 1533 | trace_nfs_atomic_open_enter(dir, ctx, open_flags); |
1523 | nfs_block_sillyrename(dentry->d_parent); | ||
1524 | inode = NFS_PROTO(dir)->open_context(dir, ctx, open_flags, &attr, opened); | 1534 | inode = NFS_PROTO(dir)->open_context(dir, ctx, open_flags, &attr, opened); |
1525 | nfs_unblock_sillyrename(dentry->d_parent); | ||
1526 | if (IS_ERR(inode)) { | 1535 | if (IS_ERR(inode)) { |
1527 | err = PTR_ERR(inode); | 1536 | err = PTR_ERR(inode); |
1528 | trace_nfs_atomic_open_exit(dir, ctx, open_flags, err); | 1537 | trace_nfs_atomic_open_exit(dir, ctx, open_flags, err); |
@@ -1766,7 +1775,7 @@ int nfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
1766 | 1775 | ||
1767 | trace_nfs_rmdir_enter(dir, dentry); | 1776 | trace_nfs_rmdir_enter(dir, dentry); |
1768 | if (d_really_is_positive(dentry)) { | 1777 | if (d_really_is_positive(dentry)) { |
1769 | nfs_wait_on_sillyrename(dentry); | 1778 | down_write(&NFS_I(d_inode(dentry))->rmdir_sem); |
1770 | error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); | 1779 | error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); |
1771 | /* Ensure the VFS deletes this inode */ | 1780 | /* Ensure the VFS deletes this inode */ |
1772 | switch (error) { | 1781 | switch (error) { |
@@ -1776,6 +1785,7 @@ int nfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
1776 | case -ENOENT: | 1785 | case -ENOENT: |
1777 | nfs_dentry_handle_enoent(dentry); | 1786 | nfs_dentry_handle_enoent(dentry); |
1778 | } | 1787 | } |
1788 | up_write(&NFS_I(d_inode(dentry))->rmdir_sem); | ||
1779 | } else | 1789 | } else |
1780 | error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); | 1790 | error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); |
1781 | trace_nfs_rmdir_exit(dir, dentry, error); | 1791 | trace_nfs_rmdir_exit(dir, dentry, error); |
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index c93826e4a8c6..438d4e70742f 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
@@ -396,7 +396,7 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq, bool write) | |||
396 | static void nfs_direct_readpage_release(struct nfs_page *req) | 396 | static void nfs_direct_readpage_release(struct nfs_page *req) |
397 | { | 397 | { |
398 | dprintk("NFS: direct read done (%s/%llu %d@%lld)\n", | 398 | dprintk("NFS: direct read done (%s/%llu %d@%lld)\n", |
399 | d_inode(req->wb_context->dentry)->i_sb->s_id, | 399 | req->wb_context->dentry->d_sb->s_id, |
400 | (unsigned long long)NFS_FILEID(d_inode(req->wb_context->dentry)), | 400 | (unsigned long long)NFS_FILEID(d_inode(req->wb_context->dentry)), |
401 | req->wb_bytes, | 401 | req->wb_bytes, |
402 | (long long)req_offset(req)); | 402 | (long long)req_offset(req)); |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 738c84a42eb0..52e7d6869e3b 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -1958,9 +1958,7 @@ static void init_once(void *foo) | |||
1958 | nfsi->nrequests = 0; | 1958 | nfsi->nrequests = 0; |
1959 | nfsi->commit_info.ncommit = 0; | 1959 | nfsi->commit_info.ncommit = 0; |
1960 | atomic_set(&nfsi->commit_info.rpcs_out, 0); | 1960 | atomic_set(&nfsi->commit_info.rpcs_out, 0); |
1961 | atomic_set(&nfsi->silly_count, 1); | 1961 | init_rwsem(&nfsi->rmdir_sem); |
1962 | INIT_HLIST_HEAD(&nfsi->silly_list); | ||
1963 | init_waitqueue_head(&nfsi->waitqueue); | ||
1964 | nfs4_init_once(nfsi); | 1962 | nfs4_init_once(nfsi); |
1965 | } | 1963 | } |
1966 | 1964 | ||
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c index 17c0fa1eccfa..720d92f5abfb 100644 --- a/fs/nfs/nfs3acl.c +++ b/fs/nfs/nfs3acl.c | |||
@@ -11,6 +11,38 @@ | |||
11 | 11 | ||
12 | #define NFSDBG_FACILITY NFSDBG_PROC | 12 | #define NFSDBG_FACILITY NFSDBG_PROC |
13 | 13 | ||
14 | /* | ||
15 | * nfs3_prepare_get_acl, nfs3_complete_get_acl, nfs3_abort_get_acl: Helpers for | ||
16 | * caching get_acl results in a race-free way. See fs/posix_acl.c:get_acl() | ||
17 | * for explanations. | ||
18 | */ | ||
19 | static void nfs3_prepare_get_acl(struct posix_acl **p) | ||
20 | { | ||
21 | struct posix_acl *sentinel = uncached_acl_sentinel(current); | ||
22 | |||
23 | if (cmpxchg(p, ACL_NOT_CACHED, sentinel) != ACL_NOT_CACHED) { | ||
24 | /* Not the first reader or sentinel already in place. */ | ||
25 | } | ||
26 | } | ||
27 | |||
28 | static void nfs3_complete_get_acl(struct posix_acl **p, struct posix_acl *acl) | ||
29 | { | ||
30 | struct posix_acl *sentinel = uncached_acl_sentinel(current); | ||
31 | |||
32 | /* Only cache the ACL if our sentinel is still in place. */ | ||
33 | posix_acl_dup(acl); | ||
34 | if (cmpxchg(p, sentinel, acl) != sentinel) | ||
35 | posix_acl_release(acl); | ||
36 | } | ||
37 | |||
38 | static void nfs3_abort_get_acl(struct posix_acl **p) | ||
39 | { | ||
40 | struct posix_acl *sentinel = uncached_acl_sentinel(current); | ||
41 | |||
42 | /* Remove our sentinel upon failure. */ | ||
43 | cmpxchg(p, sentinel, ACL_NOT_CACHED); | ||
44 | } | ||
45 | |||
14 | struct posix_acl *nfs3_get_acl(struct inode *inode, int type) | 46 | struct posix_acl *nfs3_get_acl(struct inode *inode, int type) |
15 | { | 47 | { |
16 | struct nfs_server *server = NFS_SERVER(inode); | 48 | struct nfs_server *server = NFS_SERVER(inode); |
@@ -55,6 +87,11 @@ struct posix_acl *nfs3_get_acl(struct inode *inode, int type) | |||
55 | if (res.fattr == NULL) | 87 | if (res.fattr == NULL) |
56 | return ERR_PTR(-ENOMEM); | 88 | return ERR_PTR(-ENOMEM); |
57 | 89 | ||
90 | if (args.mask & NFS_ACL) | ||
91 | nfs3_prepare_get_acl(&inode->i_acl); | ||
92 | if (args.mask & NFS_DFACL) | ||
93 | nfs3_prepare_get_acl(&inode->i_default_acl); | ||
94 | |||
58 | status = rpc_call_sync(server->client_acl, &msg, 0); | 95 | status = rpc_call_sync(server->client_acl, &msg, 0); |
59 | dprintk("NFS reply getacl: %d\n", status); | 96 | dprintk("NFS reply getacl: %d\n", status); |
60 | 97 | ||
@@ -89,12 +126,12 @@ struct posix_acl *nfs3_get_acl(struct inode *inode, int type) | |||
89 | } | 126 | } |
90 | 127 | ||
91 | if (res.mask & NFS_ACL) | 128 | if (res.mask & NFS_ACL) |
92 | set_cached_acl(inode, ACL_TYPE_ACCESS, res.acl_access); | 129 | nfs3_complete_get_acl(&inode->i_acl, res.acl_access); |
93 | else | 130 | else |
94 | forget_cached_acl(inode, ACL_TYPE_ACCESS); | 131 | forget_cached_acl(inode, ACL_TYPE_ACCESS); |
95 | 132 | ||
96 | if (res.mask & NFS_DFACL) | 133 | if (res.mask & NFS_DFACL) |
97 | set_cached_acl(inode, ACL_TYPE_DEFAULT, res.acl_default); | 134 | nfs3_complete_get_acl(&inode->i_default_acl, res.acl_default); |
98 | else | 135 | else |
99 | forget_cached_acl(inode, ACL_TYPE_DEFAULT); | 136 | forget_cached_acl(inode, ACL_TYPE_DEFAULT); |
100 | 137 | ||
@@ -108,6 +145,8 @@ struct posix_acl *nfs3_get_acl(struct inode *inode, int type) | |||
108 | } | 145 | } |
109 | 146 | ||
110 | getout: | 147 | getout: |
148 | nfs3_abort_get_acl(&inode->i_acl); | ||
149 | nfs3_abort_get_acl(&inode->i_default_acl); | ||
111 | posix_acl_release(res.acl_access); | 150 | posix_acl_release(res.acl_access); |
112 | posix_acl_release(res.acl_default); | 151 | posix_acl_release(res.acl_default); |
113 | nfs_free_fattr(res.fattr); | 152 | nfs_free_fattr(res.fattr); |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 327b8c34d360..084e8570da18 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -3777,7 +3777,7 @@ static void nfs4_proc_unlink_setup(struct rpc_message *msg, struct inode *dir) | |||
3777 | 3777 | ||
3778 | static void nfs4_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlinkdata *data) | 3778 | static void nfs4_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlinkdata *data) |
3779 | { | 3779 | { |
3780 | nfs4_setup_sequence(NFS_SERVER(data->dir), | 3780 | nfs4_setup_sequence(NFS_SB(data->dentry->d_sb), |
3781 | &data->args.seq_args, | 3781 | &data->args.seq_args, |
3782 | &data->res.seq_res, | 3782 | &data->res.seq_res, |
3783 | task); | 3783 | task); |
@@ -6263,10 +6263,10 @@ static int nfs4_xattr_set_nfs4_acl(const struct xattr_handler *handler, | |||
6263 | } | 6263 | } |
6264 | 6264 | ||
6265 | static int nfs4_xattr_get_nfs4_acl(const struct xattr_handler *handler, | 6265 | static int nfs4_xattr_get_nfs4_acl(const struct xattr_handler *handler, |
6266 | struct dentry *dentry, const char *key, | 6266 | struct dentry *unused, struct inode *inode, |
6267 | void *buf, size_t buflen) | 6267 | const char *key, void *buf, size_t buflen) |
6268 | { | 6268 | { |
6269 | return nfs4_proc_get_acl(d_inode(dentry), buf, buflen); | 6269 | return nfs4_proc_get_acl(inode, buf, buflen); |
6270 | } | 6270 | } |
6271 | 6271 | ||
6272 | static bool nfs4_xattr_list_nfs4_acl(struct dentry *dentry) | 6272 | static bool nfs4_xattr_list_nfs4_acl(struct dentry *dentry) |
@@ -6288,11 +6288,11 @@ static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler, | |||
6288 | } | 6288 | } |
6289 | 6289 | ||
6290 | static int nfs4_xattr_get_nfs4_label(const struct xattr_handler *handler, | 6290 | static int nfs4_xattr_get_nfs4_label(const struct xattr_handler *handler, |
6291 | struct dentry *dentry, const char *key, | 6291 | struct dentry *unused, struct inode *inode, |
6292 | void *buf, size_t buflen) | 6292 | const char *key, void *buf, size_t buflen) |
6293 | { | 6293 | { |
6294 | if (security_ismaclabel(key)) | 6294 | if (security_ismaclabel(key)) |
6295 | return nfs4_get_security_label(d_inode(dentry), buf, buflen); | 6295 | return nfs4_get_security_label(inode, buf, buflen); |
6296 | return -EOPNOTSUPP; | 6296 | return -EOPNOTSUPP; |
6297 | } | 6297 | } |
6298 | 6298 | ||
diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h index 9f80a086b612..0b9e5cc9a747 100644 --- a/fs/nfs/nfstrace.h +++ b/fs/nfs/nfstrace.h | |||
@@ -702,7 +702,7 @@ TRACE_EVENT(nfs_sillyrename_unlink, | |||
702 | ), | 702 | ), |
703 | 703 | ||
704 | TP_fast_assign( | 704 | TP_fast_assign( |
705 | struct inode *dir = data->dir; | 705 | struct inode *dir = d_inode(data->dentry->d_parent); |
706 | size_t len = data->args.name.len; | 706 | size_t len = data->args.name.len; |
707 | __entry->dev = dir->i_sb->s_dev; | 707 | __entry->dev = dir->i_sb->s_dev; |
708 | __entry->dir = NFS_FILEID(dir); | 708 | __entry->dir = NFS_FILEID(dir); |
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index fa538b2ba251..1868246f56e6 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c | |||
@@ -30,45 +30,11 @@ | |||
30 | static void | 30 | static void |
31 | nfs_free_unlinkdata(struct nfs_unlinkdata *data) | 31 | nfs_free_unlinkdata(struct nfs_unlinkdata *data) |
32 | { | 32 | { |
33 | iput(data->dir); | ||
34 | put_rpccred(data->cred); | 33 | put_rpccred(data->cred); |
35 | kfree(data->args.name.name); | 34 | kfree(data->args.name.name); |
36 | kfree(data); | 35 | kfree(data); |
37 | } | 36 | } |
38 | 37 | ||
39 | #define NAME_ALLOC_LEN(len) ((len+16) & ~15) | ||
40 | /** | ||
41 | * nfs_copy_dname - copy dentry name to data structure | ||
42 | * @dentry: pointer to dentry | ||
43 | * @data: nfs_unlinkdata | ||
44 | */ | ||
45 | static int nfs_copy_dname(struct dentry *dentry, struct nfs_unlinkdata *data) | ||
46 | { | ||
47 | char *str; | ||
48 | int len = dentry->d_name.len; | ||
49 | |||
50 | str = kmemdup(dentry->d_name.name, NAME_ALLOC_LEN(len), GFP_KERNEL); | ||
51 | if (!str) | ||
52 | return -ENOMEM; | ||
53 | data->args.name.len = len; | ||
54 | data->args.name.name = str; | ||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | static void nfs_free_dname(struct nfs_unlinkdata *data) | ||
59 | { | ||
60 | kfree(data->args.name.name); | ||
61 | data->args.name.name = NULL; | ||
62 | data->args.name.len = 0; | ||
63 | } | ||
64 | |||
65 | static void nfs_dec_sillycount(struct inode *dir) | ||
66 | { | ||
67 | struct nfs_inode *nfsi = NFS_I(dir); | ||
68 | if (atomic_dec_return(&nfsi->silly_count) == 1) | ||
69 | wake_up(&nfsi->waitqueue); | ||
70 | } | ||
71 | |||
72 | /** | 38 | /** |
73 | * nfs_async_unlink_done - Sillydelete post-processing | 39 | * nfs_async_unlink_done - Sillydelete post-processing |
74 | * @task: rpc_task of the sillydelete | 40 | * @task: rpc_task of the sillydelete |
@@ -78,7 +44,7 @@ static void nfs_dec_sillycount(struct inode *dir) | |||
78 | static void nfs_async_unlink_done(struct rpc_task *task, void *calldata) | 44 | static void nfs_async_unlink_done(struct rpc_task *task, void *calldata) |
79 | { | 45 | { |
80 | struct nfs_unlinkdata *data = calldata; | 46 | struct nfs_unlinkdata *data = calldata; |
81 | struct inode *dir = data->dir; | 47 | struct inode *dir = d_inode(data->dentry->d_parent); |
82 | 48 | ||
83 | trace_nfs_sillyrename_unlink(data, task->tk_status); | 49 | trace_nfs_sillyrename_unlink(data, task->tk_status); |
84 | if (!NFS_PROTO(dir)->unlink_done(task, dir)) | 50 | if (!NFS_PROTO(dir)->unlink_done(task, dir)) |
@@ -95,17 +61,21 @@ static void nfs_async_unlink_done(struct rpc_task *task, void *calldata) | |||
95 | static void nfs_async_unlink_release(void *calldata) | 61 | static void nfs_async_unlink_release(void *calldata) |
96 | { | 62 | { |
97 | struct nfs_unlinkdata *data = calldata; | 63 | struct nfs_unlinkdata *data = calldata; |
98 | struct super_block *sb = data->dir->i_sb; | 64 | struct dentry *dentry = data->dentry; |
65 | struct super_block *sb = dentry->d_sb; | ||
99 | 66 | ||
100 | nfs_dec_sillycount(data->dir); | 67 | up_read_non_owner(&NFS_I(d_inode(dentry->d_parent))->rmdir_sem); |
68 | d_lookup_done(dentry); | ||
101 | nfs_free_unlinkdata(data); | 69 | nfs_free_unlinkdata(data); |
70 | dput(dentry); | ||
102 | nfs_sb_deactive(sb); | 71 | nfs_sb_deactive(sb); |
103 | } | 72 | } |
104 | 73 | ||
105 | static void nfs_unlink_prepare(struct rpc_task *task, void *calldata) | 74 | static void nfs_unlink_prepare(struct rpc_task *task, void *calldata) |
106 | { | 75 | { |
107 | struct nfs_unlinkdata *data = calldata; | 76 | struct nfs_unlinkdata *data = calldata; |
108 | NFS_PROTO(data->dir)->unlink_rpc_prepare(task, data); | 77 | struct inode *dir = d_inode(data->dentry->d_parent); |
78 | NFS_PROTO(dir)->unlink_rpc_prepare(task, data); | ||
109 | } | 79 | } |
110 | 80 | ||
111 | static const struct rpc_call_ops nfs_unlink_ops = { | 81 | static const struct rpc_call_ops nfs_unlink_ops = { |
@@ -114,7 +84,7 @@ static const struct rpc_call_ops nfs_unlink_ops = { | |||
114 | .rpc_call_prepare = nfs_unlink_prepare, | 84 | .rpc_call_prepare = nfs_unlink_prepare, |
115 | }; | 85 | }; |
116 | 86 | ||
117 | static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct nfs_unlinkdata *data) | 87 | static void nfs_do_call_unlink(struct nfs_unlinkdata *data) |
118 | { | 88 | { |
119 | struct rpc_message msg = { | 89 | struct rpc_message msg = { |
120 | .rpc_argp = &data->args, | 90 | .rpc_argp = &data->args, |
@@ -129,10 +99,31 @@ static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct n | |||
129 | .flags = RPC_TASK_ASYNC, | 99 | .flags = RPC_TASK_ASYNC, |
130 | }; | 100 | }; |
131 | struct rpc_task *task; | 101 | struct rpc_task *task; |
102 | struct inode *dir = d_inode(data->dentry->d_parent); | ||
103 | nfs_sb_active(dir->i_sb); | ||
104 | data->args.fh = NFS_FH(dir); | ||
105 | nfs_fattr_init(data->res.dir_attr); | ||
106 | |||
107 | NFS_PROTO(dir)->unlink_setup(&msg, dir); | ||
108 | |||
109 | task_setup_data.rpc_client = NFS_CLIENT(dir); | ||
110 | task = rpc_run_task(&task_setup_data); | ||
111 | if (!IS_ERR(task)) | ||
112 | rpc_put_task_async(task); | ||
113 | } | ||
114 | |||
115 | static int nfs_call_unlink(struct dentry *dentry, struct nfs_unlinkdata *data) | ||
116 | { | ||
117 | struct inode *dir = d_inode(dentry->d_parent); | ||
132 | struct dentry *alias; | 118 | struct dentry *alias; |
133 | 119 | ||
134 | alias = d_lookup(parent, &data->args.name); | 120 | down_read_non_owner(&NFS_I(dir)->rmdir_sem); |
135 | if (alias != NULL) { | 121 | alias = d_alloc_parallel(dentry->d_parent, &data->args.name, &data->wq); |
122 | if (IS_ERR(alias)) { | ||
123 | up_read_non_owner(&NFS_I(dir)->rmdir_sem); | ||
124 | return 0; | ||
125 | } | ||
126 | if (!d_in_lookup(alias)) { | ||
136 | int ret; | 127 | int ret; |
137 | void *devname_garbage = NULL; | 128 | void *devname_garbage = NULL; |
138 | 129 | ||
@@ -140,10 +131,8 @@ static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct n | |||
140 | * Hey, we raced with lookup... See if we need to transfer | 131 | * Hey, we raced with lookup... See if we need to transfer |
141 | * the sillyrename information to the aliased dentry. | 132 | * the sillyrename information to the aliased dentry. |
142 | */ | 133 | */ |
143 | nfs_free_dname(data); | ||
144 | ret = nfs_copy_dname(alias, data); | ||
145 | spin_lock(&alias->d_lock); | 134 | spin_lock(&alias->d_lock); |
146 | if (ret == 0 && d_really_is_positive(alias) && | 135 | if (d_really_is_positive(alias) && |
147 | !(alias->d_flags & DCACHE_NFSFS_RENAMED)) { | 136 | !(alias->d_flags & DCACHE_NFSFS_RENAMED)) { |
148 | devname_garbage = alias->d_fsdata; | 137 | devname_garbage = alias->d_fsdata; |
149 | alias->d_fsdata = data; | 138 | alias->d_fsdata = data; |
@@ -152,8 +141,8 @@ static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct n | |||
152 | } else | 141 | } else |
153 | ret = 0; | 142 | ret = 0; |
154 | spin_unlock(&alias->d_lock); | 143 | spin_unlock(&alias->d_lock); |
155 | nfs_dec_sillycount(dir); | ||
156 | dput(alias); | 144 | dput(alias); |
145 | up_read_non_owner(&NFS_I(dir)->rmdir_sem); | ||
157 | /* | 146 | /* |
158 | * If we'd displaced old cached devname, free it. At that | 147 | * If we'd displaced old cached devname, free it. At that |
159 | * point dentry is definitely not a root, so we won't need | 148 | * point dentry is definitely not a root, so we won't need |
@@ -162,94 +151,18 @@ static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct n | |||
162 | kfree(devname_garbage); | 151 | kfree(devname_garbage); |
163 | return ret; | 152 | return ret; |
164 | } | 153 | } |
165 | data->dir = igrab(dir); | 154 | data->dentry = alias; |
166 | if (!data->dir) { | 155 | nfs_do_call_unlink(data); |
167 | nfs_dec_sillycount(dir); | ||
168 | return 0; | ||
169 | } | ||
170 | nfs_sb_active(dir->i_sb); | ||
171 | data->args.fh = NFS_FH(dir); | ||
172 | nfs_fattr_init(data->res.dir_attr); | ||
173 | |||
174 | NFS_PROTO(dir)->unlink_setup(&msg, dir); | ||
175 | |||
176 | task_setup_data.rpc_client = NFS_CLIENT(dir); | ||
177 | task = rpc_run_task(&task_setup_data); | ||
178 | if (!IS_ERR(task)) | ||
179 | rpc_put_task_async(task); | ||
180 | return 1; | 156 | return 1; |
181 | } | 157 | } |
182 | 158 | ||
183 | static int nfs_call_unlink(struct dentry *dentry, struct nfs_unlinkdata *data) | ||
184 | { | ||
185 | struct dentry *parent; | ||
186 | struct inode *dir; | ||
187 | int ret = 0; | ||
188 | |||
189 | |||
190 | parent = dget_parent(dentry); | ||
191 | if (parent == NULL) | ||
192 | goto out_free; | ||
193 | dir = d_inode(parent); | ||
194 | /* Non-exclusive lock protects against concurrent lookup() calls */ | ||
195 | spin_lock(&dir->i_lock); | ||
196 | if (atomic_inc_not_zero(&NFS_I(dir)->silly_count) == 0) { | ||
197 | /* Deferred delete */ | ||
198 | hlist_add_head(&data->list, &NFS_I(dir)->silly_list); | ||
199 | spin_unlock(&dir->i_lock); | ||
200 | ret = 1; | ||
201 | goto out_dput; | ||
202 | } | ||
203 | spin_unlock(&dir->i_lock); | ||
204 | ret = nfs_do_call_unlink(parent, dir, data); | ||
205 | out_dput: | ||
206 | dput(parent); | ||
207 | out_free: | ||
208 | return ret; | ||
209 | } | ||
210 | |||
211 | void nfs_wait_on_sillyrename(struct dentry *dentry) | ||
212 | { | ||
213 | struct nfs_inode *nfsi = NFS_I(d_inode(dentry)); | ||
214 | |||
215 | wait_event(nfsi->waitqueue, atomic_read(&nfsi->silly_count) <= 1); | ||
216 | } | ||
217 | |||
218 | void nfs_block_sillyrename(struct dentry *dentry) | ||
219 | { | ||
220 | struct nfs_inode *nfsi = NFS_I(d_inode(dentry)); | ||
221 | |||
222 | wait_event(nfsi->waitqueue, atomic_cmpxchg(&nfsi->silly_count, 1, 0) == 1); | ||
223 | } | ||
224 | |||
225 | void nfs_unblock_sillyrename(struct dentry *dentry) | ||
226 | { | ||
227 | struct inode *dir = d_inode(dentry); | ||
228 | struct nfs_inode *nfsi = NFS_I(dir); | ||
229 | struct nfs_unlinkdata *data; | ||
230 | |||
231 | atomic_inc(&nfsi->silly_count); | ||
232 | spin_lock(&dir->i_lock); | ||
233 | while (!hlist_empty(&nfsi->silly_list)) { | ||
234 | if (!atomic_inc_not_zero(&nfsi->silly_count)) | ||
235 | break; | ||
236 | data = hlist_entry(nfsi->silly_list.first, struct nfs_unlinkdata, list); | ||
237 | hlist_del(&data->list); | ||
238 | spin_unlock(&dir->i_lock); | ||
239 | if (nfs_do_call_unlink(dentry, dir, data) == 0) | ||
240 | nfs_free_unlinkdata(data); | ||
241 | spin_lock(&dir->i_lock); | ||
242 | } | ||
243 | spin_unlock(&dir->i_lock); | ||
244 | } | ||
245 | |||
246 | /** | 159 | /** |
247 | * nfs_async_unlink - asynchronous unlinking of a file | 160 | * nfs_async_unlink - asynchronous unlinking of a file |
248 | * @dir: parent directory of dentry | 161 | * @dir: parent directory of dentry |
249 | * @dentry: dentry to unlink | 162 | * @dentry: dentry to unlink |
250 | */ | 163 | */ |
251 | static int | 164 | static int |
252 | nfs_async_unlink(struct inode *dir, struct dentry *dentry) | 165 | nfs_async_unlink(struct dentry *dentry, struct qstr *name) |
253 | { | 166 | { |
254 | struct nfs_unlinkdata *data; | 167 | struct nfs_unlinkdata *data; |
255 | int status = -ENOMEM; | 168 | int status = -ENOMEM; |
@@ -258,13 +171,18 @@ nfs_async_unlink(struct inode *dir, struct dentry *dentry) | |||
258 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 171 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
259 | if (data == NULL) | 172 | if (data == NULL) |
260 | goto out; | 173 | goto out; |
174 | data->args.name.name = kstrdup(name->name, GFP_KERNEL); | ||
175 | if (!data->args.name.name) | ||
176 | goto out_free; | ||
177 | data->args.name.len = name->len; | ||
261 | 178 | ||
262 | data->cred = rpc_lookup_cred(); | 179 | data->cred = rpc_lookup_cred(); |
263 | if (IS_ERR(data->cred)) { | 180 | if (IS_ERR(data->cred)) { |
264 | status = PTR_ERR(data->cred); | 181 | status = PTR_ERR(data->cred); |
265 | goto out_free; | 182 | goto out_free_name; |
266 | } | 183 | } |
267 | data->res.dir_attr = &data->dir_attr; | 184 | data->res.dir_attr = &data->dir_attr; |
185 | init_waitqueue_head(&data->wq); | ||
268 | 186 | ||
269 | status = -EBUSY; | 187 | status = -EBUSY; |
270 | spin_lock(&dentry->d_lock); | 188 | spin_lock(&dentry->d_lock); |
@@ -284,6 +202,8 @@ nfs_async_unlink(struct inode *dir, struct dentry *dentry) | |||
284 | out_unlock: | 202 | out_unlock: |
285 | spin_unlock(&dentry->d_lock); | 203 | spin_unlock(&dentry->d_lock); |
286 | put_rpccred(data->cred); | 204 | put_rpccred(data->cred); |
205 | out_free_name: | ||
206 | kfree(data->args.name.name); | ||
287 | out_free: | 207 | out_free: |
288 | kfree(data); | 208 | kfree(data); |
289 | out: | 209 | out: |
@@ -302,17 +222,15 @@ out: | |||
302 | void | 222 | void |
303 | nfs_complete_unlink(struct dentry *dentry, struct inode *inode) | 223 | nfs_complete_unlink(struct dentry *dentry, struct inode *inode) |
304 | { | 224 | { |
305 | struct nfs_unlinkdata *data = NULL; | 225 | struct nfs_unlinkdata *data; |
306 | 226 | ||
307 | spin_lock(&dentry->d_lock); | 227 | spin_lock(&dentry->d_lock); |
308 | if (dentry->d_flags & DCACHE_NFSFS_RENAMED) { | 228 | dentry->d_flags &= ~DCACHE_NFSFS_RENAMED; |
309 | dentry->d_flags &= ~DCACHE_NFSFS_RENAMED; | 229 | data = dentry->d_fsdata; |
310 | data = dentry->d_fsdata; | 230 | dentry->d_fsdata = NULL; |
311 | dentry->d_fsdata = NULL; | ||
312 | } | ||
313 | spin_unlock(&dentry->d_lock); | 231 | spin_unlock(&dentry->d_lock); |
314 | 232 | ||
315 | if (data != NULL && (NFS_STALE(inode) || !nfs_call_unlink(dentry, data))) | 233 | if (NFS_STALE(inode) || !nfs_call_unlink(dentry, data)) |
316 | nfs_free_unlinkdata(data); | 234 | nfs_free_unlinkdata(data); |
317 | } | 235 | } |
318 | 236 | ||
@@ -559,18 +477,10 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry) | |||
559 | /* queue unlink first. Can't do this from rpc_release as it | 477 | /* queue unlink first. Can't do this from rpc_release as it |
560 | * has to allocate memory | 478 | * has to allocate memory |
561 | */ | 479 | */ |
562 | error = nfs_async_unlink(dir, dentry); | 480 | error = nfs_async_unlink(dentry, &sdentry->d_name); |
563 | if (error) | 481 | if (error) |
564 | goto out_dput; | 482 | goto out_dput; |
565 | 483 | ||
566 | /* populate unlinkdata with the right dname */ | ||
567 | error = nfs_copy_dname(sdentry, | ||
568 | (struct nfs_unlinkdata *)dentry->d_fsdata); | ||
569 | if (error) { | ||
570 | nfs_cancel_async_unlink(dentry); | ||
571 | goto out_dput; | ||
572 | } | ||
573 | |||
574 | /* run the rename task, undo unlink if it fails */ | 484 | /* run the rename task, undo unlink if it fails */ |
575 | task = nfs_async_rename(dir, dir, dentry, sdentry, | 485 | task = nfs_async_rename(dir, dir, dentry, sdentry, |
576 | nfs_complete_sillyrename); | 486 | nfs_complete_sillyrename); |
diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index 51c3b06e8036..d818e4ffd79f 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c | |||
@@ -552,7 +552,7 @@ nfsd3_proc_fsinfo(struct svc_rqst * rqstp, struct nfsd_fhandle *argp, | |||
552 | * different read/write sizes for file systems known to have | 552 | * different read/write sizes for file systems known to have |
553 | * problems with large blocks */ | 553 | * problems with large blocks */ |
554 | if (nfserr == 0) { | 554 | if (nfserr == 0) { |
555 | struct super_block *sb = d_inode(argp->fh.fh_dentry)->i_sb; | 555 | struct super_block *sb = argp->fh.fh_dentry->d_sb; |
556 | 556 | ||
557 | /* Note that we don't care for remote fs's here */ | 557 | /* Note that we don't care for remote fs's here */ |
558 | if (sb->s_magic == MSDOS_SUPER_MAGIC) { | 558 | if (sb->s_magic == MSDOS_SUPER_MAGIC) { |
@@ -588,7 +588,7 @@ nfsd3_proc_pathconf(struct svc_rqst * rqstp, struct nfsd_fhandle *argp, | |||
588 | nfserr = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP); | 588 | nfserr = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP); |
589 | 589 | ||
590 | if (nfserr == 0) { | 590 | if (nfserr == 0) { |
591 | struct super_block *sb = d_inode(argp->fh.fh_dentry)->i_sb; | 591 | struct super_block *sb = argp->fh.fh_dentry->d_sb; |
592 | 592 | ||
593 | /* Note that we don't care for remote fs's here */ | 593 | /* Note that we don't care for remote fs's here */ |
594 | switch (sb->s_magic) { | 594 | switch (sb->s_magic) { |
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 2246454dec76..93d5853f8c99 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c | |||
@@ -146,7 +146,7 @@ static __be32 *encode_fsid(__be32 *p, struct svc_fh *fhp) | |||
146 | default: | 146 | default: |
147 | case FSIDSOURCE_DEV: | 147 | case FSIDSOURCE_DEV: |
148 | p = xdr_encode_hyper(p, (u64)huge_encode_dev | 148 | p = xdr_encode_hyper(p, (u64)huge_encode_dev |
149 | (d_inode(fhp->fh_dentry)->i_sb->s_dev)); | 149 | (fhp->fh_dentry->d_sb->s_dev)); |
150 | break; | 150 | break; |
151 | case FSIDSOURCE_FSID: | 151 | case FSIDSOURCE_FSID: |
152 | p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid); | 152 | p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid); |
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index c1681ce894c5..a8919444c460 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c | |||
@@ -426,7 +426,7 @@ static bool is_root_export(struct svc_export *exp) | |||
426 | 426 | ||
427 | static struct super_block *exp_sb(struct svc_export *exp) | 427 | static struct super_block *exp_sb(struct svc_export *exp) |
428 | { | 428 | { |
429 | return d_inode(exp->ex_path.dentry)->i_sb; | 429 | return exp->ex_path.dentry->d_sb; |
430 | } | 430 | } |
431 | 431 | ||
432 | static bool fsid_type_ok_for_exp(u8 fsid_type, struct svc_export *exp) | 432 | static bool fsid_type_ok_for_exp(u8 fsid_type, struct svc_export *exp) |
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index e08f064e4bd7..6723d45a631a 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c | |||
@@ -102,7 +102,7 @@ static void nilfs_commit_chunk(struct page *page, | |||
102 | unlock_page(page); | 102 | unlock_page(page); |
103 | } | 103 | } |
104 | 104 | ||
105 | static void nilfs_check_page(struct page *page) | 105 | static bool nilfs_check_page(struct page *page) |
106 | { | 106 | { |
107 | struct inode *dir = page->mapping->host; | 107 | struct inode *dir = page->mapping->host; |
108 | struct super_block *sb = dir->i_sb; | 108 | struct super_block *sb = dir->i_sb; |
@@ -137,7 +137,7 @@ static void nilfs_check_page(struct page *page) | |||
137 | goto Eend; | 137 | goto Eend; |
138 | out: | 138 | out: |
139 | SetPageChecked(page); | 139 | SetPageChecked(page); |
140 | return; | 140 | return true; |
141 | 141 | ||
142 | /* Too bad, we had an error */ | 142 | /* Too bad, we had an error */ |
143 | 143 | ||
@@ -173,8 +173,8 @@ Eend: | |||
173 | dir->i_ino, (page->index<<PAGE_SHIFT)+offs, | 173 | dir->i_ino, (page->index<<PAGE_SHIFT)+offs, |
174 | (unsigned long) le64_to_cpu(p->inode)); | 174 | (unsigned long) le64_to_cpu(p->inode)); |
175 | fail: | 175 | fail: |
176 | SetPageChecked(page); | ||
177 | SetPageError(page); | 176 | SetPageError(page); |
177 | return false; | ||
178 | } | 178 | } |
179 | 179 | ||
180 | static struct page *nilfs_get_page(struct inode *dir, unsigned long n) | 180 | static struct page *nilfs_get_page(struct inode *dir, unsigned long n) |
@@ -184,10 +184,10 @@ static struct page *nilfs_get_page(struct inode *dir, unsigned long n) | |||
184 | 184 | ||
185 | if (!IS_ERR(page)) { | 185 | if (!IS_ERR(page)) { |
186 | kmap(page); | 186 | kmap(page); |
187 | if (!PageChecked(page)) | 187 | if (unlikely(!PageChecked(page))) { |
188 | nilfs_check_page(page); | 188 | if (PageError(page) || !nilfs_check_page(page)) |
189 | if (PageError(page)) | 189 | goto fail; |
190 | goto fail; | 190 | } |
191 | } | 191 | } |
192 | return page; | 192 | return page; |
193 | 193 | ||
@@ -661,7 +661,7 @@ not_empty: | |||
661 | const struct file_operations nilfs_dir_operations = { | 661 | const struct file_operations nilfs_dir_operations = { |
662 | .llseek = generic_file_llseek, | 662 | .llseek = generic_file_llseek, |
663 | .read = generic_read_dir, | 663 | .read = generic_read_dir, |
664 | .iterate = nilfs_readdir, | 664 | .iterate_shared = nilfs_readdir, |
665 | .unlocked_ioctl = nilfs_ioctl, | 665 | .unlocked_ioctl = nilfs_ioctl, |
666 | #ifdef CONFIG_COMPAT | 666 | #ifdef CONFIG_COMPAT |
667 | .compat_ioctl = nilfs_compat_ioctl, | 667 | .compat_ioctl = nilfs_compat_ioctl, |
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index 151bc19d47c0..3b2af05f9fb4 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c | |||
@@ -457,7 +457,7 @@ static struct dentry *nilfs_get_parent(struct dentry *child) | |||
457 | 457 | ||
458 | root = NILFS_I(d_inode(child))->i_root; | 458 | root = NILFS_I(d_inode(child))->i_root; |
459 | 459 | ||
460 | inode = nilfs_iget(d_inode(child)->i_sb, root, ino); | 460 | inode = nilfs_iget(child->d_sb, root, ino); |
461 | if (IS_ERR(inode)) | 461 | if (IS_ERR(inode)) |
462 | return ERR_CAST(inode); | 462 | return ERR_CAST(inode); |
463 | 463 | ||
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index ad1577348a92..abb0b0bf7c7f 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -2311,7 +2311,7 @@ static void ocfs2_dio_end_io_write(struct inode *inode, | |||
2311 | /* ocfs2_file_write_iter will get i_mutex, so we need not lock if we | 2311 | /* ocfs2_file_write_iter will get i_mutex, so we need not lock if we |
2312 | * are in that context. */ | 2312 | * are in that context. */ |
2313 | if (dwc->dw_writer_pid != task_pid_nr(current)) { | 2313 | if (dwc->dw_writer_pid != task_pid_nr(current)) { |
2314 | mutex_lock(&inode->i_mutex); | 2314 | inode_lock(inode); |
2315 | locked = 1; | 2315 | locked = 1; |
2316 | } | 2316 | } |
2317 | 2317 | ||
@@ -2390,7 +2390,7 @@ out: | |||
2390 | ocfs2_free_alloc_context(meta_ac); | 2390 | ocfs2_free_alloc_context(meta_ac); |
2391 | ocfs2_run_deallocs(osb, &dealloc); | 2391 | ocfs2_run_deallocs(osb, &dealloc); |
2392 | if (locked) | 2392 | if (locked) |
2393 | mutex_unlock(&inode->i_mutex); | 2393 | inode_unlock(inode); |
2394 | ocfs2_dio_free_write_ctx(inode, dwc); | 2394 | ocfs2_dio_free_write_ctx(inode, dwc); |
2395 | } | 2395 | } |
2396 | 2396 | ||
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 474e57f834e6..1eaa9100c889 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #include "uptodate.h" | 54 | #include "uptodate.h" |
55 | #include "quota.h" | 55 | #include "quota.h" |
56 | #include "refcounttree.h" | 56 | #include "refcounttree.h" |
57 | #include "acl.h" | ||
57 | 58 | ||
58 | #include "buffer_head_io.h" | 59 | #include "buffer_head_io.h" |
59 | 60 | ||
@@ -3623,6 +3624,8 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres, | |||
3623 | filemap_fdatawait(mapping); | 3624 | filemap_fdatawait(mapping); |
3624 | } | 3625 | } |
3625 | 3626 | ||
3627 | forget_all_cached_acls(inode); | ||
3628 | |||
3626 | out: | 3629 | out: |
3627 | return UNBLOCK_CONTINUE; | 3630 | return UNBLOCK_CONTINUE; |
3628 | } | 3631 | } |
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 59cce53c91d8..4e7b0dc22450 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -1290,7 +1290,7 @@ int ocfs2_getattr(struct vfsmount *mnt, | |||
1290 | struct kstat *stat) | 1290 | struct kstat *stat) |
1291 | { | 1291 | { |
1292 | struct inode *inode = d_inode(dentry); | 1292 | struct inode *inode = d_inode(dentry); |
1293 | struct super_block *sb = d_inode(dentry)->i_sb; | 1293 | struct super_block *sb = dentry->d_sb; |
1294 | struct ocfs2_super *osb = sb->s_fs_info; | 1294 | struct ocfs2_super *osb = sb->s_fs_info; |
1295 | int err; | 1295 | int err; |
1296 | 1296 | ||
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 12f4a9e9800f..0748777f2e2a 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c | |||
@@ -262,7 +262,7 @@ static int ocfs2_init_locked_inode(struct inode *inode, void *opaque) | |||
262 | inode->i_ino = args->fi_ino; | 262 | inode->i_ino = args->fi_ino; |
263 | OCFS2_I(inode)->ip_blkno = args->fi_blkno; | 263 | OCFS2_I(inode)->ip_blkno = args->fi_blkno; |
264 | if (args->fi_sysfile_type != 0) | 264 | if (args->fi_sysfile_type != 0) |
265 | lockdep_set_class(&inode->i_mutex, | 265 | lockdep_set_class(&inode->i_rwsem, |
266 | &ocfs2_sysfile_lock_key[args->fi_sysfile_type]); | 266 | &ocfs2_sysfile_lock_key[args->fi_sysfile_type]); |
267 | if (args->fi_sysfile_type == USER_QUOTA_SYSTEM_INODE || | 267 | if (args->fi_sysfile_type == USER_QUOTA_SYSTEM_INODE || |
268 | args->fi_sysfile_type == GROUP_QUOTA_SYSTEM_INODE || | 268 | args->fi_sysfile_type == GROUP_QUOTA_SYSTEM_INODE || |
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index f19b7381a998..ad16995c9e7a 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -7246,10 +7246,10 @@ leave: | |||
7246 | * 'security' attributes support | 7246 | * 'security' attributes support |
7247 | */ | 7247 | */ |
7248 | static int ocfs2_xattr_security_get(const struct xattr_handler *handler, | 7248 | static int ocfs2_xattr_security_get(const struct xattr_handler *handler, |
7249 | struct dentry *dentry, const char *name, | 7249 | struct dentry *unused, struct inode *inode, |
7250 | void *buffer, size_t size) | 7250 | const char *name, void *buffer, size_t size) |
7251 | { | 7251 | { |
7252 | return ocfs2_xattr_get(d_inode(dentry), OCFS2_XATTR_INDEX_SECURITY, | 7252 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_SECURITY, |
7253 | name, buffer, size); | 7253 | name, buffer, size); |
7254 | } | 7254 | } |
7255 | 7255 | ||
@@ -7317,10 +7317,10 @@ const struct xattr_handler ocfs2_xattr_security_handler = { | |||
7317 | * 'trusted' attributes support | 7317 | * 'trusted' attributes support |
7318 | */ | 7318 | */ |
7319 | static int ocfs2_xattr_trusted_get(const struct xattr_handler *handler, | 7319 | static int ocfs2_xattr_trusted_get(const struct xattr_handler *handler, |
7320 | struct dentry *dentry, const char *name, | 7320 | struct dentry *unused, struct inode *inode, |
7321 | void *buffer, size_t size) | 7321 | const char *name, void *buffer, size_t size) |
7322 | { | 7322 | { |
7323 | return ocfs2_xattr_get(d_inode(dentry), OCFS2_XATTR_INDEX_TRUSTED, | 7323 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, |
7324 | name, buffer, size); | 7324 | name, buffer, size); |
7325 | } | 7325 | } |
7326 | 7326 | ||
@@ -7342,14 +7342,14 @@ const struct xattr_handler ocfs2_xattr_trusted_handler = { | |||
7342 | * 'user' attributes support | 7342 | * 'user' attributes support |
7343 | */ | 7343 | */ |
7344 | static int ocfs2_xattr_user_get(const struct xattr_handler *handler, | 7344 | static int ocfs2_xattr_user_get(const struct xattr_handler *handler, |
7345 | struct dentry *dentry, const char *name, | 7345 | struct dentry *unusde, struct inode *inode, |
7346 | void *buffer, size_t size) | 7346 | const char *name, void *buffer, size_t size) |
7347 | { | 7347 | { |
7348 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); | 7348 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
7349 | 7349 | ||
7350 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | 7350 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) |
7351 | return -EOPNOTSUPP; | 7351 | return -EOPNOTSUPP; |
7352 | return ocfs2_xattr_get(d_inode(dentry), OCFS2_XATTR_INDEX_USER, name, | 7352 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name, |
7353 | buffer, size); | 7353 | buffer, size); |
7354 | } | 7354 | } |
7355 | 7355 | ||
diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c index f833bf8d5792..c8cbf3b60645 100644 --- a/fs/omfs/dir.c +++ b/fs/omfs/dir.c | |||
@@ -452,6 +452,6 @@ const struct inode_operations omfs_dir_inops = { | |||
452 | 452 | ||
453 | const struct file_operations omfs_dir_operations = { | 453 | const struct file_operations omfs_dir_operations = { |
454 | .read = generic_read_dir, | 454 | .read = generic_read_dir, |
455 | .iterate = omfs_readdir, | 455 | .iterate_shared = omfs_readdir, |
456 | .llseek = generic_file_llseek, | 456 | .llseek = generic_file_llseek, |
457 | }; | 457 | }; |
@@ -713,7 +713,7 @@ static int do_dentry_open(struct file *f, | |||
713 | } | 713 | } |
714 | 714 | ||
715 | /* POSIX.1-2008/SUSv4 Section XSI 2.9.7 */ | 715 | /* POSIX.1-2008/SUSv4 Section XSI 2.9.7 */ |
716 | if (S_ISREG(inode->i_mode)) | 716 | if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)) |
717 | f->f_mode |= FMODE_ATOMIC_POS; | 717 | f->f_mode |= FMODE_ATOMIC_POS; |
718 | 718 | ||
719 | f->f_op = fops_get(inode->i_fop); | 719 | f->f_op = fops_get(inode->i_fop); |
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c index b61b883c8ff8..c7a86993d97e 100644 --- a/fs/openpromfs/inode.c +++ b/fs/openpromfs/inode.c | |||
@@ -166,7 +166,7 @@ static int openpromfs_readdir(struct file *, struct dir_context *); | |||
166 | 166 | ||
167 | static const struct file_operations openprom_operations = { | 167 | static const struct file_operations openprom_operations = { |
168 | .read = generic_read_dir, | 168 | .read = generic_read_dir, |
169 | .iterate = openpromfs_readdir, | 169 | .iterate_shared = openpromfs_readdir, |
170 | .llseek = generic_file_llseek, | 170 | .llseek = generic_file_llseek, |
171 | }; | 171 | }; |
172 | 172 | ||
diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c index ae92795ed965..491e82c6f705 100644 --- a/fs/orangefs/file.c +++ b/fs/orangefs/file.c | |||
@@ -445,7 +445,7 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *ite | |||
445 | 445 | ||
446 | gossip_debug(GOSSIP_FILE_DEBUG, "orangefs_file_write_iter\n"); | 446 | gossip_debug(GOSSIP_FILE_DEBUG, "orangefs_file_write_iter\n"); |
447 | 447 | ||
448 | mutex_lock(&file->f_mapping->host->i_mutex); | 448 | inode_lock(file->f_mapping->host); |
449 | 449 | ||
450 | /* Make sure generic_write_checks sees an up to date inode size. */ | 450 | /* Make sure generic_write_checks sees an up to date inode size. */ |
451 | if (file->f_flags & O_APPEND) { | 451 | if (file->f_flags & O_APPEND) { |
@@ -492,7 +492,7 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *ite | |||
492 | 492 | ||
493 | out: | 493 | out: |
494 | 494 | ||
495 | mutex_unlock(&file->f_mapping->host->i_mutex); | 495 | inode_unlock(file->f_mapping->host); |
496 | return rc; | 496 | return rc; |
497 | } | 497 | } |
498 | 498 | ||
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h index a9925e296ceb..2281882f718e 100644 --- a/fs/orangefs/orangefs-kernel.h +++ b/fs/orangefs/orangefs-kernel.h | |||
@@ -612,11 +612,11 @@ do { \ | |||
612 | static inline void orangefs_i_size_write(struct inode *inode, loff_t i_size) | 612 | static inline void orangefs_i_size_write(struct inode *inode, loff_t i_size) |
613 | { | 613 | { |
614 | #if BITS_PER_LONG == 32 && defined(CONFIG_SMP) | 614 | #if BITS_PER_LONG == 32 && defined(CONFIG_SMP) |
615 | mutex_lock(&inode->i_mutex); | 615 | inode_lock(inode); |
616 | #endif | 616 | #endif |
617 | i_size_write(inode, i_size); | 617 | i_size_write(inode, i_size); |
618 | #if BITS_PER_LONG == 32 && defined(CONFIG_SMP) | 618 | #if BITS_PER_LONG == 32 && defined(CONFIG_SMP) |
619 | mutex_unlock(&inode->i_mutex); | 619 | inode_unlock(inode); |
620 | #endif | 620 | #endif |
621 | } | 621 | } |
622 | 622 | ||
diff --git a/fs/orangefs/xattr.c b/fs/orangefs/xattr.c index 63a6280d8c3a..99c19545752c 100644 --- a/fs/orangefs/xattr.c +++ b/fs/orangefs/xattr.c | |||
@@ -463,12 +463,13 @@ static int orangefs_xattr_set_default(const struct xattr_handler *handler, | |||
463 | } | 463 | } |
464 | 464 | ||
465 | static int orangefs_xattr_get_default(const struct xattr_handler *handler, | 465 | static int orangefs_xattr_get_default(const struct xattr_handler *handler, |
466 | struct dentry *dentry, | 466 | struct dentry *unused, |
467 | struct inode *inode, | ||
467 | const char *name, | 468 | const char *name, |
468 | void *buffer, | 469 | void *buffer, |
469 | size_t size) | 470 | size_t size) |
470 | { | 471 | { |
471 | return orangefs_inode_getxattr(dentry->d_inode, | 472 | return orangefs_inode_getxattr(inode, |
472 | ORANGEFS_XATTR_NAME_DEFAULT_PREFIX, | 473 | ORANGEFS_XATTR_NAME_DEFAULT_PREFIX, |
473 | name, | 474 | name, |
474 | buffer, | 475 | buffer, |
@@ -492,12 +493,13 @@ static int orangefs_xattr_set_trusted(const struct xattr_handler *handler, | |||
492 | } | 493 | } |
493 | 494 | ||
494 | static int orangefs_xattr_get_trusted(const struct xattr_handler *handler, | 495 | static int orangefs_xattr_get_trusted(const struct xattr_handler *handler, |
495 | struct dentry *dentry, | 496 | struct dentry *unused, |
497 | struct inode *inode, | ||
496 | const char *name, | 498 | const char *name, |
497 | void *buffer, | 499 | void *buffer, |
498 | size_t size) | 500 | size_t size) |
499 | { | 501 | { |
500 | return orangefs_inode_getxattr(dentry->d_inode, | 502 | return orangefs_inode_getxattr(inode, |
501 | ORANGEFS_XATTR_NAME_TRUSTED_PREFIX, | 503 | ORANGEFS_XATTR_NAME_TRUSTED_PREFIX, |
502 | name, | 504 | name, |
503 | buffer, | 505 | buffer, |
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index a4ff5d0d7db9..c7b31a03dc9c 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c | |||
@@ -246,8 +246,8 @@ static bool ovl_need_xattr_filter(struct dentry *dentry, | |||
246 | return false; | 246 | return false; |
247 | } | 247 | } |
248 | 248 | ||
249 | ssize_t ovl_getxattr(struct dentry *dentry, const char *name, | 249 | ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode, |
250 | void *value, size_t size) | 250 | const char *name, void *value, size_t size) |
251 | { | 251 | { |
252 | struct path realpath; | 252 | struct path realpath; |
253 | enum ovl_path_type type = ovl_path_real(dentry, &realpath); | 253 | enum ovl_path_type type = ovl_path_real(dentry, &realpath); |
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 6a7090f4a441..99ec4b035237 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h | |||
@@ -173,8 +173,8 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr); | |||
173 | int ovl_permission(struct inode *inode, int mask); | 173 | int ovl_permission(struct inode *inode, int mask); |
174 | int ovl_setxattr(struct dentry *dentry, const char *name, | 174 | int ovl_setxattr(struct dentry *dentry, const char *name, |
175 | const void *value, size_t size, int flags); | 175 | const void *value, size_t size, int flags); |
176 | ssize_t ovl_getxattr(struct dentry *dentry, const char *name, | 176 | ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode, |
177 | void *value, size_t size); | 177 | const char *name, void *value, size_t size); |
178 | ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); | 178 | ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); |
179 | int ovl_removexattr(struct dentry *dentry, const char *name); | 179 | int ovl_removexattr(struct dentry *dentry, const char *name); |
180 | struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags); | 180 | struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags); |
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c index 6ec1e43a9a54..da186ee4f846 100644 --- a/fs/overlayfs/readdir.c +++ b/fs/overlayfs/readdir.c | |||
@@ -218,7 +218,9 @@ static int ovl_check_whiteouts(struct dentry *dir, struct ovl_readdir_data *rdd) | |||
218 | cap_raise(override_cred->cap_effective, CAP_DAC_OVERRIDE); | 218 | cap_raise(override_cred->cap_effective, CAP_DAC_OVERRIDE); |
219 | old_cred = override_creds(override_cred); | 219 | old_cred = override_creds(override_cred); |
220 | 220 | ||
221 | err = mutex_lock_killable(&dir->d_inode->i_mutex); | 221 | inode_lock(dir->d_inode); |
222 | err = 0; | ||
223 | // XXX: err = mutex_lock_killable(&dir->d_inode->i_mutex); | ||
222 | if (!err) { | 224 | if (!err) { |
223 | while (rdd->first_maybe_whiteout) { | 225 | while (rdd->first_maybe_whiteout) { |
224 | p = rdd->first_maybe_whiteout; | 226 | p = rdd->first_maybe_whiteout; |
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 791235e03d17..ed53ae0fe868 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c | |||
@@ -274,7 +274,7 @@ static bool ovl_is_opaquedir(struct dentry *dentry) | |||
274 | if (!S_ISDIR(inode->i_mode) || !inode->i_op->getxattr) | 274 | if (!S_ISDIR(inode->i_mode) || !inode->i_op->getxattr) |
275 | return false; | 275 | return false; |
276 | 276 | ||
277 | res = inode->i_op->getxattr(dentry, OVL_XATTR_OPAQUE, &val, 1); | 277 | res = inode->i_op->getxattr(dentry, inode, OVL_XATTR_OPAQUE, &val, 1); |
278 | if (res == 1 && val == 'y') | 278 | if (res == 1 && val == 'y') |
279 | return true; | 279 | return true; |
280 | 280 | ||
diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 711dd5170376..2c60f17e7d92 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/export.h> | 21 | #include <linux/export.h> |
22 | #include <linux/user_namespace.h> | 22 | #include <linux/user_namespace.h> |
23 | 23 | ||
24 | struct posix_acl **acl_by_type(struct inode *inode, int type) | 24 | static struct posix_acl **acl_by_type(struct inode *inode, int type) |
25 | { | 25 | { |
26 | switch (type) { | 26 | switch (type) { |
27 | case ACL_TYPE_ACCESS: | 27 | case ACL_TYPE_ACCESS: |
@@ -32,19 +32,22 @@ struct posix_acl **acl_by_type(struct inode *inode, int type) | |||
32 | BUG(); | 32 | BUG(); |
33 | } | 33 | } |
34 | } | 34 | } |
35 | EXPORT_SYMBOL(acl_by_type); | ||
36 | 35 | ||
37 | struct posix_acl *get_cached_acl(struct inode *inode, int type) | 36 | struct posix_acl *get_cached_acl(struct inode *inode, int type) |
38 | { | 37 | { |
39 | struct posix_acl **p = acl_by_type(inode, type); | 38 | struct posix_acl **p = acl_by_type(inode, type); |
40 | struct posix_acl *acl = ACCESS_ONCE(*p); | 39 | struct posix_acl *acl; |
41 | if (acl) { | 40 | |
42 | spin_lock(&inode->i_lock); | 41 | for (;;) { |
43 | acl = *p; | 42 | rcu_read_lock(); |
44 | if (acl != ACL_NOT_CACHED) | 43 | acl = rcu_dereference(*p); |
45 | acl = posix_acl_dup(acl); | 44 | if (!acl || is_uncached_acl(acl) || |
46 | spin_unlock(&inode->i_lock); | 45 | atomic_inc_not_zero(&acl->a_refcount)) |
46 | break; | ||
47 | rcu_read_unlock(); | ||
48 | cpu_relax(); | ||
47 | } | 49 | } |
50 | rcu_read_unlock(); | ||
48 | return acl; | 51 | return acl; |
49 | } | 52 | } |
50 | EXPORT_SYMBOL(get_cached_acl); | 53 | EXPORT_SYMBOL(get_cached_acl); |
@@ -59,58 +62,72 @@ void set_cached_acl(struct inode *inode, int type, struct posix_acl *acl) | |||
59 | { | 62 | { |
60 | struct posix_acl **p = acl_by_type(inode, type); | 63 | struct posix_acl **p = acl_by_type(inode, type); |
61 | struct posix_acl *old; | 64 | struct posix_acl *old; |
62 | spin_lock(&inode->i_lock); | 65 | |
63 | old = *p; | 66 | old = xchg(p, posix_acl_dup(acl)); |
64 | rcu_assign_pointer(*p, posix_acl_dup(acl)); | 67 | if (!is_uncached_acl(old)) |
65 | spin_unlock(&inode->i_lock); | ||
66 | if (old != ACL_NOT_CACHED) | ||
67 | posix_acl_release(old); | 68 | posix_acl_release(old); |
68 | } | 69 | } |
69 | EXPORT_SYMBOL(set_cached_acl); | 70 | EXPORT_SYMBOL(set_cached_acl); |
70 | 71 | ||
71 | void forget_cached_acl(struct inode *inode, int type) | 72 | static void __forget_cached_acl(struct posix_acl **p) |
72 | { | 73 | { |
73 | struct posix_acl **p = acl_by_type(inode, type); | ||
74 | struct posix_acl *old; | 74 | struct posix_acl *old; |
75 | spin_lock(&inode->i_lock); | 75 | |
76 | old = *p; | 76 | old = xchg(p, ACL_NOT_CACHED); |
77 | *p = ACL_NOT_CACHED; | 77 | if (!is_uncached_acl(old)) |
78 | spin_unlock(&inode->i_lock); | ||
79 | if (old != ACL_NOT_CACHED) | ||
80 | posix_acl_release(old); | 78 | posix_acl_release(old); |
81 | } | 79 | } |
80 | |||
81 | void forget_cached_acl(struct inode *inode, int type) | ||
82 | { | ||
83 | __forget_cached_acl(acl_by_type(inode, type)); | ||
84 | } | ||
82 | EXPORT_SYMBOL(forget_cached_acl); | 85 | EXPORT_SYMBOL(forget_cached_acl); |
83 | 86 | ||
84 | void forget_all_cached_acls(struct inode *inode) | 87 | void forget_all_cached_acls(struct inode *inode) |
85 | { | 88 | { |
86 | struct posix_acl *old_access, *old_default; | 89 | __forget_cached_acl(&inode->i_acl); |
87 | spin_lock(&inode->i_lock); | 90 | __forget_cached_acl(&inode->i_default_acl); |
88 | old_access = inode->i_acl; | ||
89 | old_default = inode->i_default_acl; | ||
90 | inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED; | ||
91 | spin_unlock(&inode->i_lock); | ||
92 | if (old_access != ACL_NOT_CACHED) | ||
93 | posix_acl_release(old_access); | ||
94 | if (old_default != ACL_NOT_CACHED) | ||
95 | posix_acl_release(old_default); | ||
96 | } | 91 | } |
97 | EXPORT_SYMBOL(forget_all_cached_acls); | 92 | EXPORT_SYMBOL(forget_all_cached_acls); |
98 | 93 | ||
99 | struct posix_acl *get_acl(struct inode *inode, int type) | 94 | struct posix_acl *get_acl(struct inode *inode, int type) |
100 | { | 95 | { |
96 | void *sentinel; | ||
97 | struct posix_acl **p; | ||
101 | struct posix_acl *acl; | 98 | struct posix_acl *acl; |
102 | 99 | ||
100 | /* | ||
101 | * The sentinel is used to detect when another operation like | ||
102 | * set_cached_acl() or forget_cached_acl() races with get_acl(). | ||
103 | * It is guaranteed that is_uncached_acl(sentinel) is true. | ||
104 | */ | ||
105 | |||
103 | acl = get_cached_acl(inode, type); | 106 | acl = get_cached_acl(inode, type); |
104 | if (acl != ACL_NOT_CACHED) | 107 | if (!is_uncached_acl(acl)) |
105 | return acl; | 108 | return acl; |
106 | 109 | ||
107 | if (!IS_POSIXACL(inode)) | 110 | if (!IS_POSIXACL(inode)) |
108 | return NULL; | 111 | return NULL; |
109 | 112 | ||
113 | sentinel = uncached_acl_sentinel(current); | ||
114 | p = acl_by_type(inode, type); | ||
115 | |||
110 | /* | 116 | /* |
111 | * A filesystem can force a ACL callback by just never filling the | 117 | * If the ACL isn't being read yet, set our sentinel. Otherwise, the |
112 | * ACL cache. But normally you'd fill the cache either at inode | 118 | * current value of the ACL will not be ACL_NOT_CACHED and so our own |
113 | * instantiation time, or on the first ->get_acl call. | 119 | * sentinel will not be set; another task will update the cache. We |
120 | * could wait for that other task to complete its job, but it's easier | ||
121 | * to just call ->get_acl to fetch the ACL ourself. (This is going to | ||
122 | * be an unlikely race.) | ||
123 | */ | ||
124 | if (cmpxchg(p, ACL_NOT_CACHED, sentinel) != ACL_NOT_CACHED) | ||
125 | /* fall through */ ; | ||
126 | |||
127 | /* | ||
128 | * Normally, the ACL returned by ->get_acl will be cached. | ||
129 | * A filesystem can prevent that by calling | ||
130 | * forget_cached_acl(inode, type) in ->get_acl. | ||
114 | * | 131 | * |
115 | * If the filesystem doesn't have a get_acl() function at all, we'll | 132 | * If the filesystem doesn't have a get_acl() function at all, we'll |
116 | * just create the negative cache entry. | 133 | * just create the negative cache entry. |
@@ -119,7 +136,24 @@ struct posix_acl *get_acl(struct inode *inode, int type) | |||
119 | set_cached_acl(inode, type, NULL); | 136 | set_cached_acl(inode, type, NULL); |
120 | return NULL; | 137 | return NULL; |
121 | } | 138 | } |
122 | return inode->i_op->get_acl(inode, type); | 139 | acl = inode->i_op->get_acl(inode, type); |
140 | |||
141 | if (IS_ERR(acl)) { | ||
142 | /* | ||
143 | * Remove our sentinel so that we don't block future attempts | ||
144 | * to cache the ACL. | ||
145 | */ | ||
146 | cmpxchg(p, sentinel, ACL_NOT_CACHED); | ||
147 | return acl; | ||
148 | } | ||
149 | |||
150 | /* | ||
151 | * Cache the result, but only if our sentinel is still in place. | ||
152 | */ | ||
153 | posix_acl_dup(acl); | ||
154 | if (unlikely(cmpxchg(p, sentinel, acl) != sentinel)) | ||
155 | posix_acl_release(acl); | ||
156 | return acl; | ||
123 | } | 157 | } |
124 | EXPORT_SYMBOL(get_acl); | 158 | EXPORT_SYMBOL(get_acl); |
125 | 159 | ||
@@ -763,18 +797,18 @@ EXPORT_SYMBOL (posix_acl_to_xattr); | |||
763 | 797 | ||
764 | static int | 798 | static int |
765 | posix_acl_xattr_get(const struct xattr_handler *handler, | 799 | posix_acl_xattr_get(const struct xattr_handler *handler, |
766 | struct dentry *dentry, const char *name, | 800 | struct dentry *unused, struct inode *inode, |
767 | void *value, size_t size) | 801 | const char *name, void *value, size_t size) |
768 | { | 802 | { |
769 | struct posix_acl *acl; | 803 | struct posix_acl *acl; |
770 | int error; | 804 | int error; |
771 | 805 | ||
772 | if (!IS_POSIXACL(d_backing_inode(dentry))) | 806 | if (!IS_POSIXACL(inode)) |
773 | return -EOPNOTSUPP; | 807 | return -EOPNOTSUPP; |
774 | if (d_is_symlink(dentry)) | 808 | if (S_ISLNK(inode->i_mode)) |
775 | return -EOPNOTSUPP; | 809 | return -EOPNOTSUPP; |
776 | 810 | ||
777 | acl = get_acl(d_backing_inode(dentry), handler->flags); | 811 | acl = get_acl(inode, handler->flags); |
778 | if (IS_ERR(acl)) | 812 | if (IS_ERR(acl)) |
779 | return PTR_ERR(acl); | 813 | return PTR_ERR(acl); |
780 | if (acl == NULL) | 814 | if (acl == NULL) |
diff --git a/fs/proc/base.c b/fs/proc/base.c index 0d163a84082d..ff4527dd69b7 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -1820,12 +1820,17 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx, | |||
1820 | 1820 | ||
1821 | child = d_hash_and_lookup(dir, &qname); | 1821 | child = d_hash_and_lookup(dir, &qname); |
1822 | if (!child) { | 1822 | if (!child) { |
1823 | child = d_alloc(dir, &qname); | 1823 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); |
1824 | if (!child) | 1824 | child = d_alloc_parallel(dir, &qname, &wq); |
1825 | goto end_instantiate; | 1825 | if (IS_ERR(child)) |
1826 | if (instantiate(d_inode(dir), child, task, ptr) < 0) { | ||
1827 | dput(child); | ||
1828 | goto end_instantiate; | 1826 | goto end_instantiate; |
1827 | if (d_in_lookup(child)) { | ||
1828 | int err = instantiate(d_inode(dir), child, task, ptr); | ||
1829 | d_lookup_done(child); | ||
1830 | if (err < 0) { | ||
1831 | dput(child); | ||
1832 | goto end_instantiate; | ||
1833 | } | ||
1829 | } | 1834 | } |
1830 | } | 1835 | } |
1831 | inode = d_inode(child); | 1836 | inode = d_inode(child); |
@@ -2155,8 +2160,8 @@ out: | |||
2155 | 2160 | ||
2156 | static const struct file_operations proc_map_files_operations = { | 2161 | static const struct file_operations proc_map_files_operations = { |
2157 | .read = generic_read_dir, | 2162 | .read = generic_read_dir, |
2158 | .iterate = proc_map_files_readdir, | 2163 | .iterate_shared = proc_map_files_readdir, |
2159 | .llseek = default_llseek, | 2164 | .llseek = generic_file_llseek, |
2160 | }; | 2165 | }; |
2161 | 2166 | ||
2162 | #ifdef CONFIG_CHECKPOINT_RESTORE | 2167 | #ifdef CONFIG_CHECKPOINT_RESTORE |
@@ -2503,8 +2508,8 @@ static int proc_attr_dir_readdir(struct file *file, struct dir_context *ctx) | |||
2503 | 2508 | ||
2504 | static const struct file_operations proc_attr_dir_operations = { | 2509 | static const struct file_operations proc_attr_dir_operations = { |
2505 | .read = generic_read_dir, | 2510 | .read = generic_read_dir, |
2506 | .iterate = proc_attr_dir_readdir, | 2511 | .iterate_shared = proc_attr_dir_readdir, |
2507 | .llseek = default_llseek, | 2512 | .llseek = generic_file_llseek, |
2508 | }; | 2513 | }; |
2509 | 2514 | ||
2510 | static struct dentry *proc_attr_dir_lookup(struct inode *dir, | 2515 | static struct dentry *proc_attr_dir_lookup(struct inode *dir, |
@@ -2911,8 +2916,8 @@ static int proc_tgid_base_readdir(struct file *file, struct dir_context *ctx) | |||
2911 | 2916 | ||
2912 | static const struct file_operations proc_tgid_base_operations = { | 2917 | static const struct file_operations proc_tgid_base_operations = { |
2913 | .read = generic_read_dir, | 2918 | .read = generic_read_dir, |
2914 | .iterate = proc_tgid_base_readdir, | 2919 | .iterate_shared = proc_tgid_base_readdir, |
2915 | .llseek = default_llseek, | 2920 | .llseek = generic_file_llseek, |
2916 | }; | 2921 | }; |
2917 | 2922 | ||
2918 | static struct dentry *proc_tgid_base_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) | 2923 | static struct dentry *proc_tgid_base_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) |
@@ -3259,8 +3264,8 @@ static struct dentry *proc_tid_base_lookup(struct inode *dir, struct dentry *den | |||
3259 | 3264 | ||
3260 | static const struct file_operations proc_tid_base_operations = { | 3265 | static const struct file_operations proc_tid_base_operations = { |
3261 | .read = generic_read_dir, | 3266 | .read = generic_read_dir, |
3262 | .iterate = proc_tid_base_readdir, | 3267 | .iterate_shared = proc_tid_base_readdir, |
3263 | .llseek = default_llseek, | 3268 | .llseek = generic_file_llseek, |
3264 | }; | 3269 | }; |
3265 | 3270 | ||
3266 | static const struct inode_operations proc_tid_base_inode_operations = { | 3271 | static const struct inode_operations proc_tid_base_inode_operations = { |
@@ -3470,6 +3475,6 @@ static const struct inode_operations proc_task_inode_operations = { | |||
3470 | 3475 | ||
3471 | static const struct file_operations proc_task_operations = { | 3476 | static const struct file_operations proc_task_operations = { |
3472 | .read = generic_read_dir, | 3477 | .read = generic_read_dir, |
3473 | .iterate = proc_task_readdir, | 3478 | .iterate_shared = proc_task_readdir, |
3474 | .llseek = default_llseek, | 3479 | .llseek = generic_file_llseek, |
3475 | }; | 3480 | }; |
diff --git a/fs/proc/fd.c b/fs/proc/fd.c index 56afa5ef08f2..01df23cc81f6 100644 --- a/fs/proc/fd.c +++ b/fs/proc/fd.c | |||
@@ -276,8 +276,8 @@ static int proc_readfd(struct file *file, struct dir_context *ctx) | |||
276 | 276 | ||
277 | const struct file_operations proc_fd_operations = { | 277 | const struct file_operations proc_fd_operations = { |
278 | .read = generic_read_dir, | 278 | .read = generic_read_dir, |
279 | .iterate = proc_readfd, | 279 | .iterate_shared = proc_readfd, |
280 | .llseek = default_llseek, | 280 | .llseek = generic_file_llseek, |
281 | }; | 281 | }; |
282 | 282 | ||
283 | static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry, | 283 | static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry, |
@@ -361,6 +361,6 @@ const struct inode_operations proc_fdinfo_inode_operations = { | |||
361 | 361 | ||
362 | const struct file_operations proc_fdinfo_operations = { | 362 | const struct file_operations proc_fdinfo_operations = { |
363 | .read = generic_read_dir, | 363 | .read = generic_read_dir, |
364 | .iterate = proc_readfdinfo, | 364 | .iterate_shared = proc_readfdinfo, |
365 | .llseek = default_llseek, | 365 | .llseek = generic_file_llseek, |
366 | }; | 366 | }; |
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index ff3ffc76a937..c633476616e0 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -318,7 +318,7 @@ int proc_readdir(struct file *file, struct dir_context *ctx) | |||
318 | static const struct file_operations proc_dir_operations = { | 318 | static const struct file_operations proc_dir_operations = { |
319 | .llseek = generic_file_llseek, | 319 | .llseek = generic_file_llseek, |
320 | .read = generic_read_dir, | 320 | .read = generic_read_dir, |
321 | .iterate = proc_readdir, | 321 | .iterate_shared = proc_readdir, |
322 | }; | 322 | }; |
323 | 323 | ||
324 | /* | 324 | /* |
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c index 72cb26f85d58..51b8b0a8ad91 100644 --- a/fs/proc/namespaces.c +++ b/fs/proc/namespaces.c | |||
@@ -139,7 +139,8 @@ out: | |||
139 | 139 | ||
140 | const struct file_operations proc_ns_dir_operations = { | 140 | const struct file_operations proc_ns_dir_operations = { |
141 | .read = generic_read_dir, | 141 | .read = generic_read_dir, |
142 | .iterate = proc_ns_dir_readdir, | 142 | .iterate_shared = proc_ns_dir_readdir, |
143 | .llseek = generic_file_llseek, | ||
143 | }; | 144 | }; |
144 | 145 | ||
145 | static struct dentry *proc_ns_dir_lookup(struct inode *dir, | 146 | static struct dentry *proc_ns_dir_lookup(struct inode *dir, |
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c index 350984a19c83..c8bbc68cdb05 100644 --- a/fs/proc/proc_net.c +++ b/fs/proc/proc_net.c | |||
@@ -179,7 +179,7 @@ static int proc_tgid_net_readdir(struct file *file, struct dir_context *ctx) | |||
179 | const struct file_operations proc_net_operations = { | 179 | const struct file_operations proc_net_operations = { |
180 | .llseek = generic_file_llseek, | 180 | .llseek = generic_file_llseek, |
181 | .read = generic_read_dir, | 181 | .read = generic_read_dir, |
182 | .iterate = proc_tgid_net_readdir, | 182 | .iterate_shared = proc_tgid_net_readdir, |
183 | }; | 183 | }; |
184 | 184 | ||
185 | static __net_init int proc_net_ns_init(struct net *net) | 185 | static __net_init int proc_net_ns_init(struct net *net) |
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index fe5b6e6c4671..5e57c3e46e1d 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
@@ -627,18 +627,19 @@ static bool proc_sys_fill_cache(struct file *file, | |||
627 | 627 | ||
628 | child = d_lookup(dir, &qname); | 628 | child = d_lookup(dir, &qname); |
629 | if (!child) { | 629 | if (!child) { |
630 | child = d_alloc(dir, &qname); | 630 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); |
631 | if (child) { | 631 | child = d_alloc_parallel(dir, &qname, &wq); |
632 | if (IS_ERR(child)) | ||
633 | return false; | ||
634 | if (d_in_lookup(child)) { | ||
632 | inode = proc_sys_make_inode(dir->d_sb, head, table); | 635 | inode = proc_sys_make_inode(dir->d_sb, head, table); |
633 | if (!inode) { | 636 | if (!inode) { |
637 | d_lookup_done(child); | ||
634 | dput(child); | 638 | dput(child); |
635 | return false; | 639 | return false; |
636 | } else { | ||
637 | d_set_d_op(child, &proc_sys_dentry_operations); | ||
638 | d_add(child, inode); | ||
639 | } | 640 | } |
640 | } else { | 641 | d_set_d_op(child, &proc_sys_dentry_operations); |
641 | return false; | 642 | d_add(child, inode); |
642 | } | 643 | } |
643 | } | 644 | } |
644 | inode = d_inode(child); | 645 | inode = d_inode(child); |
@@ -789,7 +790,7 @@ static const struct file_operations proc_sys_file_operations = { | |||
789 | 790 | ||
790 | static const struct file_operations proc_sys_dir_file_operations = { | 791 | static const struct file_operations proc_sys_dir_file_operations = { |
791 | .read = generic_read_dir, | 792 | .read = generic_read_dir, |
792 | .iterate = proc_sys_readdir, | 793 | .iterate_shared = proc_sys_readdir, |
793 | .llseek = generic_file_llseek, | 794 | .llseek = generic_file_llseek, |
794 | }; | 795 | }; |
795 | 796 | ||
diff --git a/fs/proc/root.c b/fs/proc/root.c index 361ab4ee42fc..55bc7d6c8aac 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c | |||
@@ -226,8 +226,8 @@ static int proc_root_readdir(struct file *file, struct dir_context *ctx) | |||
226 | */ | 226 | */ |
227 | static const struct file_operations proc_root_operations = { | 227 | static const struct file_operations proc_root_operations = { |
228 | .read = generic_read_dir, | 228 | .read = generic_read_dir, |
229 | .iterate = proc_root_readdir, | 229 | .iterate_shared = proc_root_readdir, |
230 | .llseek = default_llseek, | 230 | .llseek = generic_file_llseek, |
231 | }; | 231 | }; |
232 | 232 | ||
233 | /* | 233 | /* |
diff --git a/fs/qnx4/dir.c b/fs/qnx4/dir.c index b218f965817b..781056a0480f 100644 --- a/fs/qnx4/dir.c +++ b/fs/qnx4/dir.c | |||
@@ -71,7 +71,7 @@ const struct file_operations qnx4_dir_operations = | |||
71 | { | 71 | { |
72 | .llseek = generic_file_llseek, | 72 | .llseek = generic_file_llseek, |
73 | .read = generic_read_dir, | 73 | .read = generic_read_dir, |
74 | .iterate = qnx4_readdir, | 74 | .iterate_shared = qnx4_readdir, |
75 | .fsync = generic_file_fsync, | 75 | .fsync = generic_file_fsync, |
76 | }; | 76 | }; |
77 | 77 | ||
diff --git a/fs/qnx6/dir.c b/fs/qnx6/dir.c index 144ceda4948e..27637e0bdc9f 100644 --- a/fs/qnx6/dir.c +++ b/fs/qnx6/dir.c | |||
@@ -272,7 +272,7 @@ found: | |||
272 | const struct file_operations qnx6_dir_operations = { | 272 | const struct file_operations qnx6_dir_operations = { |
273 | .llseek = generic_file_llseek, | 273 | .llseek = generic_file_llseek, |
274 | .read = generic_read_dir, | 274 | .read = generic_read_dir, |
275 | .iterate = qnx6_readdir, | 275 | .iterate_shared = qnx6_readdir, |
276 | .fsync = generic_file_fsync, | 276 | .fsync = generic_file_fsync, |
277 | }; | 277 | }; |
278 | 278 | ||
diff --git a/fs/read_write.c b/fs/read_write.c index cf377cf9dfe3..69c7c3c2955c 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
@@ -302,18 +302,6 @@ loff_t vfs_llseek(struct file *file, loff_t offset, int whence) | |||
302 | } | 302 | } |
303 | EXPORT_SYMBOL(vfs_llseek); | 303 | EXPORT_SYMBOL(vfs_llseek); |
304 | 304 | ||
305 | static inline struct fd fdget_pos(int fd) | ||
306 | { | ||
307 | return __to_fd(__fdget_pos(fd)); | ||
308 | } | ||
309 | |||
310 | static inline void fdput_pos(struct fd f) | ||
311 | { | ||
312 | if (f.flags & FDPUT_POS_UNLOCK) | ||
313 | mutex_unlock(&f.file->f_pos_lock); | ||
314 | fdput(f); | ||
315 | } | ||
316 | |||
317 | SYSCALL_DEFINE3(lseek, unsigned int, fd, off_t, offset, unsigned int, whence) | 305 | SYSCALL_DEFINE3(lseek, unsigned int, fd, off_t, offset, unsigned int, whence) |
318 | { | 306 | { |
319 | off_t retval; | 307 | off_t retval; |
diff --git a/fs/readdir.c b/fs/readdir.c index e69ef3b79787..a86c6c04b9bc 100644 --- a/fs/readdir.c +++ b/fs/readdir.c | |||
@@ -24,27 +24,40 @@ | |||
24 | int iterate_dir(struct file *file, struct dir_context *ctx) | 24 | int iterate_dir(struct file *file, struct dir_context *ctx) |
25 | { | 25 | { |
26 | struct inode *inode = file_inode(file); | 26 | struct inode *inode = file_inode(file); |
27 | bool shared = false; | ||
27 | int res = -ENOTDIR; | 28 | int res = -ENOTDIR; |
28 | if (!file->f_op->iterate) | 29 | if (file->f_op->iterate_shared) |
30 | shared = true; | ||
31 | else if (!file->f_op->iterate) | ||
29 | goto out; | 32 | goto out; |
30 | 33 | ||
31 | res = security_file_permission(file, MAY_READ); | 34 | res = security_file_permission(file, MAY_READ); |
32 | if (res) | 35 | if (res) |
33 | goto out; | 36 | goto out; |
34 | 37 | ||
35 | res = mutex_lock_killable(&inode->i_mutex); | 38 | if (shared) |
36 | if (res) | 39 | inode_lock_shared(inode); |
37 | goto out; | 40 | else |
41 | inode_lock(inode); | ||
42 | // res = mutex_lock_killable(&inode->i_mutex); | ||
43 | // if (res) | ||
44 | // goto out; | ||
38 | 45 | ||
39 | res = -ENOENT; | 46 | res = -ENOENT; |
40 | if (!IS_DEADDIR(inode)) { | 47 | if (!IS_DEADDIR(inode)) { |
41 | ctx->pos = file->f_pos; | 48 | ctx->pos = file->f_pos; |
42 | res = file->f_op->iterate(file, ctx); | 49 | if (shared) |
50 | res = file->f_op->iterate_shared(file, ctx); | ||
51 | else | ||
52 | res = file->f_op->iterate(file, ctx); | ||
43 | file->f_pos = ctx->pos; | 53 | file->f_pos = ctx->pos; |
44 | fsnotify_access(file); | 54 | fsnotify_access(file); |
45 | file_accessed(file); | 55 | file_accessed(file); |
46 | } | 56 | } |
47 | inode_unlock(inode); | 57 | if (shared) |
58 | inode_unlock_shared(inode); | ||
59 | else | ||
60 | inode_unlock(inode); | ||
48 | out: | 61 | out: |
49 | return res; | 62 | return res; |
50 | } | 63 | } |
@@ -111,7 +124,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd, | |||
111 | struct old_linux_dirent __user *, dirent, unsigned int, count) | 124 | struct old_linux_dirent __user *, dirent, unsigned int, count) |
112 | { | 125 | { |
113 | int error; | 126 | int error; |
114 | struct fd f = fdget(fd); | 127 | struct fd f = fdget_pos(fd); |
115 | struct readdir_callback buf = { | 128 | struct readdir_callback buf = { |
116 | .ctx.actor = fillonedir, | 129 | .ctx.actor = fillonedir, |
117 | .dirent = dirent | 130 | .dirent = dirent |
@@ -124,7 +137,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd, | |||
124 | if (buf.result) | 137 | if (buf.result) |
125 | error = buf.result; | 138 | error = buf.result; |
126 | 139 | ||
127 | fdput(f); | 140 | fdput_pos(f); |
128 | return error; | 141 | return error; |
129 | } | 142 | } |
130 | 143 | ||
@@ -208,7 +221,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd, | |||
208 | if (!access_ok(VERIFY_WRITE, dirent, count)) | 221 | if (!access_ok(VERIFY_WRITE, dirent, count)) |
209 | return -EFAULT; | 222 | return -EFAULT; |
210 | 223 | ||
211 | f = fdget(fd); | 224 | f = fdget_pos(fd); |
212 | if (!f.file) | 225 | if (!f.file) |
213 | return -EBADF; | 226 | return -EBADF; |
214 | 227 | ||
@@ -222,7 +235,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd, | |||
222 | else | 235 | else |
223 | error = count - buf.count; | 236 | error = count - buf.count; |
224 | } | 237 | } |
225 | fdput(f); | 238 | fdput_pos(f); |
226 | return error; | 239 | return error; |
227 | } | 240 | } |
228 | 241 | ||
@@ -289,7 +302,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd, | |||
289 | if (!access_ok(VERIFY_WRITE, dirent, count)) | 302 | if (!access_ok(VERIFY_WRITE, dirent, count)) |
290 | return -EFAULT; | 303 | return -EFAULT; |
291 | 304 | ||
292 | f = fdget(fd); | 305 | f = fdget_pos(fd); |
293 | if (!f.file) | 306 | if (!f.file) |
294 | return -EBADF; | 307 | return -EBADF; |
295 | 308 | ||
@@ -304,6 +317,6 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd, | |||
304 | else | 317 | else |
305 | error = count - buf.count; | 318 | error = count - buf.count; |
306 | } | 319 | } |
307 | fdput(f); | 320 | fdput_pos(f); |
308 | return error; | 321 | return error; |
309 | } | 322 | } |
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c index 3abd4004184b..45aa05e2232f 100644 --- a/fs/reiserfs/dir.c +++ b/fs/reiserfs/dir.c | |||
@@ -20,7 +20,7 @@ static int reiserfs_dir_fsync(struct file *filp, loff_t start, loff_t end, | |||
20 | const struct file_operations reiserfs_dir_operations = { | 20 | const struct file_operations reiserfs_dir_operations = { |
21 | .llseek = generic_file_llseek, | 21 | .llseek = generic_file_llseek, |
22 | .read = generic_read_dir, | 22 | .read = generic_read_dir, |
23 | .iterate = reiserfs_readdir, | 23 | .iterate_shared = reiserfs_readdir, |
24 | .fsync = reiserfs_dir_fsync, | 24 | .fsync = reiserfs_dir_fsync, |
25 | .unlocked_ioctl = reiserfs_ioctl, | 25 | .unlocked_ioctl = reiserfs_ioctl, |
26 | #ifdef CONFIG_COMPAT | 26 | #ifdef CONFIG_COMPAT |
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c index 389773711de4..90f815bdfa8a 100644 --- a/fs/reiserfs/file.c +++ b/fs/reiserfs/file.c | |||
@@ -260,10 +260,10 @@ const struct file_operations reiserfs_file_operations = { | |||
260 | 260 | ||
261 | const struct inode_operations reiserfs_file_inode_operations = { | 261 | const struct inode_operations reiserfs_file_inode_operations = { |
262 | .setattr = reiserfs_setattr, | 262 | .setattr = reiserfs_setattr, |
263 | .setxattr = reiserfs_setxattr, | 263 | .setxattr = generic_setxattr, |
264 | .getxattr = reiserfs_getxattr, | 264 | .getxattr = generic_getxattr, |
265 | .listxattr = reiserfs_listxattr, | 265 | .listxattr = reiserfs_listxattr, |
266 | .removexattr = reiserfs_removexattr, | 266 | .removexattr = generic_removexattr, |
267 | .permission = reiserfs_permission, | 267 | .permission = reiserfs_permission, |
268 | .get_acl = reiserfs_get_acl, | 268 | .get_acl = reiserfs_get_acl, |
269 | .set_acl = reiserfs_set_acl, | 269 | .set_acl = reiserfs_set_acl, |
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c index 57045f423893..2f1ddc908013 100644 --- a/fs/reiserfs/ioctl.c +++ b/fs/reiserfs/ioctl.c | |||
@@ -187,7 +187,11 @@ int reiserfs_unpack(struct inode *inode, struct file *filp) | |||
187 | } | 187 | } |
188 | 188 | ||
189 | /* we need to make sure nobody is changing the file size beneath us */ | 189 | /* we need to make sure nobody is changing the file size beneath us */ |
190 | reiserfs_mutex_lock_safe(&inode->i_mutex, inode->i_sb); | 190 | { |
191 | int depth = reiserfs_write_unlock_nested(inode->i_sb); | ||
192 | inode_lock(inode); | ||
193 | reiserfs_write_lock_nested(inode->i_sb, depth); | ||
194 | } | ||
191 | 195 | ||
192 | reiserfs_write_lock(inode->i_sb); | 196 | reiserfs_write_lock(inode->i_sb); |
193 | 197 | ||
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index 2a12d46d7fb4..8a36696d6df9 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c | |||
@@ -1650,10 +1650,10 @@ const struct inode_operations reiserfs_dir_inode_operations = { | |||
1650 | .mknod = reiserfs_mknod, | 1650 | .mknod = reiserfs_mknod, |
1651 | .rename = reiserfs_rename, | 1651 | .rename = reiserfs_rename, |
1652 | .setattr = reiserfs_setattr, | 1652 | .setattr = reiserfs_setattr, |
1653 | .setxattr = reiserfs_setxattr, | 1653 | .setxattr = generic_setxattr, |
1654 | .getxattr = reiserfs_getxattr, | 1654 | .getxattr = generic_getxattr, |
1655 | .listxattr = reiserfs_listxattr, | 1655 | .listxattr = reiserfs_listxattr, |
1656 | .removexattr = reiserfs_removexattr, | 1656 | .removexattr = generic_removexattr, |
1657 | .permission = reiserfs_permission, | 1657 | .permission = reiserfs_permission, |
1658 | .get_acl = reiserfs_get_acl, | 1658 | .get_acl = reiserfs_get_acl, |
1659 | .set_acl = reiserfs_set_acl, | 1659 | .set_acl = reiserfs_set_acl, |
@@ -1667,10 +1667,10 @@ const struct inode_operations reiserfs_symlink_inode_operations = { | |||
1667 | .readlink = generic_readlink, | 1667 | .readlink = generic_readlink, |
1668 | .get_link = page_get_link, | 1668 | .get_link = page_get_link, |
1669 | .setattr = reiserfs_setattr, | 1669 | .setattr = reiserfs_setattr, |
1670 | .setxattr = reiserfs_setxattr, | 1670 | .setxattr = generic_setxattr, |
1671 | .getxattr = reiserfs_getxattr, | 1671 | .getxattr = generic_getxattr, |
1672 | .listxattr = reiserfs_listxattr, | 1672 | .listxattr = reiserfs_listxattr, |
1673 | .removexattr = reiserfs_removexattr, | 1673 | .removexattr = generic_removexattr, |
1674 | .permission = reiserfs_permission, | 1674 | .permission = reiserfs_permission, |
1675 | }; | 1675 | }; |
1676 | 1676 | ||
@@ -1679,10 +1679,10 @@ const struct inode_operations reiserfs_symlink_inode_operations = { | |||
1679 | */ | 1679 | */ |
1680 | const struct inode_operations reiserfs_special_inode_operations = { | 1680 | const struct inode_operations reiserfs_special_inode_operations = { |
1681 | .setattr = reiserfs_setattr, | 1681 | .setattr = reiserfs_setattr, |
1682 | .setxattr = reiserfs_setxattr, | 1682 | .setxattr = generic_setxattr, |
1683 | .getxattr = reiserfs_getxattr, | 1683 | .getxattr = generic_getxattr, |
1684 | .listxattr = reiserfs_listxattr, | 1684 | .listxattr = reiserfs_listxattr, |
1685 | .removexattr = reiserfs_removexattr, | 1685 | .removexattr = generic_removexattr, |
1686 | .permission = reiserfs_permission, | 1686 | .permission = reiserfs_permission, |
1687 | .get_acl = reiserfs_get_acl, | 1687 | .get_acl = reiserfs_get_acl, |
1688 | .set_acl = reiserfs_set_acl, | 1688 | .set_acl = reiserfs_set_acl, |
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index 28f5f8b11370..a33812ae9fad 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c | |||
@@ -764,60 +764,6 @@ find_xattr_handler_prefix(const struct xattr_handler **handlers, | |||
764 | return xah; | 764 | return xah; |
765 | } | 765 | } |
766 | 766 | ||
767 | |||
768 | /* | ||
769 | * Inode operation getxattr() | ||
770 | */ | ||
771 | ssize_t | ||
772 | reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, | ||
773 | size_t size) | ||
774 | { | ||
775 | const struct xattr_handler *handler; | ||
776 | |||
777 | handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); | ||
778 | |||
779 | if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1) | ||
780 | return -EOPNOTSUPP; | ||
781 | |||
782 | return handler->get(handler, dentry, name, buffer, size); | ||
783 | } | ||
784 | |||
785 | /* | ||
786 | * Inode operation setxattr() | ||
787 | * | ||
788 | * d_inode(dentry)->i_mutex down | ||
789 | */ | ||
790 | int | ||
791 | reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, | ||
792 | size_t size, int flags) | ||
793 | { | ||
794 | const struct xattr_handler *handler; | ||
795 | |||
796 | handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); | ||
797 | |||
798 | if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1) | ||
799 | return -EOPNOTSUPP; | ||
800 | |||
801 | return handler->set(handler, dentry, name, value, size, flags); | ||
802 | } | ||
803 | |||
804 | /* | ||
805 | * Inode operation removexattr() | ||
806 | * | ||
807 | * d_inode(dentry)->i_mutex down | ||
808 | */ | ||
809 | int reiserfs_removexattr(struct dentry *dentry, const char *name) | ||
810 | { | ||
811 | const struct xattr_handler *handler; | ||
812 | |||
813 | handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); | ||
814 | |||
815 | if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1) | ||
816 | return -EOPNOTSUPP; | ||
817 | |||
818 | return handler->set(handler, dentry, name, NULL, 0, XATTR_REPLACE); | ||
819 | } | ||
820 | |||
821 | struct listxattr_buf { | 767 | struct listxattr_buf { |
822 | struct dir_context ctx; | 768 | struct dir_context ctx; |
823 | size_t size; | 769 | size_t size; |
diff --git a/fs/reiserfs/xattr.h b/fs/reiserfs/xattr.h index 15dde6262c00..613ff5aef94e 100644 --- a/fs/reiserfs/xattr.h +++ b/fs/reiserfs/xattr.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <linux/init.h> | 2 | #include <linux/init.h> |
3 | #include <linux/list.h> | 3 | #include <linux/list.h> |
4 | #include <linux/rwsem.h> | 4 | #include <linux/rwsem.h> |
5 | #include <linux/xattr.h> | ||
5 | 6 | ||
6 | struct inode; | 7 | struct inode; |
7 | struct dentry; | 8 | struct dentry; |
@@ -18,12 +19,7 @@ int reiserfs_permission(struct inode *inode, int mask); | |||
18 | 19 | ||
19 | #ifdef CONFIG_REISERFS_FS_XATTR | 20 | #ifdef CONFIG_REISERFS_FS_XATTR |
20 | #define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir) | 21 | #define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir) |
21 | ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name, | ||
22 | void *buffer, size_t size); | ||
23 | int reiserfs_setxattr(struct dentry *dentry, const char *name, | ||
24 | const void *value, size_t size, int flags); | ||
25 | ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size); | 22 | ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size); |
26 | int reiserfs_removexattr(struct dentry *dentry, const char *name); | ||
27 | 23 | ||
28 | int reiserfs_xattr_get(struct inode *, const char *, void *, size_t); | 24 | int reiserfs_xattr_get(struct inode *, const char *, void *, size_t); |
29 | int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int); | 25 | int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int); |
@@ -92,10 +88,7 @@ static inline void reiserfs_init_xattr_rwsem(struct inode *inode) | |||
92 | 88 | ||
93 | #else | 89 | #else |
94 | 90 | ||
95 | #define reiserfs_getxattr NULL | ||
96 | #define reiserfs_setxattr NULL | ||
97 | #define reiserfs_listxattr NULL | 91 | #define reiserfs_listxattr NULL |
98 | #define reiserfs_removexattr NULL | ||
99 | 92 | ||
100 | static inline void reiserfs_init_xattr_rwsem(struct inode *inode) | 93 | static inline void reiserfs_init_xattr_rwsem(struct inode *inode) |
101 | { | 94 | { |
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c index 558a16beaacb..dbed42f755e0 100644 --- a/fs/reiserfs/xattr_acl.c +++ b/fs/reiserfs/xattr_acl.c | |||
@@ -197,10 +197,8 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) | |||
197 | 197 | ||
198 | size = reiserfs_xattr_get(inode, name, NULL, 0); | 198 | size = reiserfs_xattr_get(inode, name, NULL, 0); |
199 | if (size < 0) { | 199 | if (size < 0) { |
200 | if (size == -ENODATA || size == -ENOSYS) { | 200 | if (size == -ENODATA || size == -ENOSYS) |
201 | set_cached_acl(inode, type, NULL); | ||
202 | return NULL; | 201 | return NULL; |
203 | } | ||
204 | return ERR_PTR(size); | 202 | return ERR_PTR(size); |
205 | } | 203 | } |
206 | 204 | ||
@@ -220,8 +218,6 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) | |||
220 | } else { | 218 | } else { |
221 | acl = reiserfs_posix_acl_from_disk(value, retval); | 219 | acl = reiserfs_posix_acl_from_disk(value, retval); |
222 | } | 220 | } |
223 | if (!IS_ERR(acl)) | ||
224 | set_cached_acl(inode, type, acl); | ||
225 | 221 | ||
226 | kfree(value); | 222 | kfree(value); |
227 | return acl; | 223 | return acl; |
@@ -370,7 +366,7 @@ int reiserfs_cache_default_acl(struct inode *inode) | |||
370 | if (IS_PRIVATE(inode)) | 366 | if (IS_PRIVATE(inode)) |
371 | return 0; | 367 | return 0; |
372 | 368 | ||
373 | acl = reiserfs_get_acl(inode, ACL_TYPE_DEFAULT); | 369 | acl = get_acl(inode, ACL_TYPE_DEFAULT); |
374 | 370 | ||
375 | if (acl && !IS_ERR(acl)) { | 371 | if (acl && !IS_ERR(acl)) { |
376 | int size = reiserfs_acl_size(acl->a_count); | 372 | int size = reiserfs_acl_size(acl->a_count); |
diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c index ab0217d32039..86aeb9dd805a 100644 --- a/fs/reiserfs/xattr_security.c +++ b/fs/reiserfs/xattr_security.c | |||
@@ -9,29 +9,26 @@ | |||
9 | #include <linux/uaccess.h> | 9 | #include <linux/uaccess.h> |
10 | 10 | ||
11 | static int | 11 | static int |
12 | security_get(const struct xattr_handler *handler, struct dentry *dentry, | 12 | security_get(const struct xattr_handler *handler, struct dentry *unused, |
13 | const char *name, void *buffer, size_t size) | 13 | struct inode *inode, const char *name, void *buffer, size_t size) |
14 | { | 14 | { |
15 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) | 15 | if (IS_PRIVATE(inode)) |
16 | return -EINVAL; | ||
17 | |||
18 | if (IS_PRIVATE(d_inode(dentry))) | ||
19 | return -EPERM; | 16 | return -EPERM; |
20 | 17 | ||
21 | return reiserfs_xattr_get(d_inode(dentry), name, buffer, size); | 18 | return reiserfs_xattr_get(inode, xattr_full_name(handler, name), |
19 | buffer, size); | ||
22 | } | 20 | } |
23 | 21 | ||
24 | static int | 22 | static int |
25 | security_set(const struct xattr_handler *handler, struct dentry *dentry, | 23 | security_set(const struct xattr_handler *handler, struct dentry *dentry, |
26 | const char *name, const void *buffer, size_t size, int flags) | 24 | const char *name, const void *buffer, size_t size, int flags) |
27 | { | 25 | { |
28 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) | ||
29 | return -EINVAL; | ||
30 | |||
31 | if (IS_PRIVATE(d_inode(dentry))) | 26 | if (IS_PRIVATE(d_inode(dentry))) |
32 | return -EPERM; | 27 | return -EPERM; |
33 | 28 | ||
34 | return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags); | 29 | return reiserfs_xattr_set(d_inode(dentry), |
30 | xattr_full_name(handler, name), | ||
31 | buffer, size, flags); | ||
35 | } | 32 | } |
36 | 33 | ||
37 | static bool security_list(struct dentry *dentry) | 34 | static bool security_list(struct dentry *dentry) |
diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c index 64b67aa643a9..31837f031f59 100644 --- a/fs/reiserfs/xattr_trusted.c +++ b/fs/reiserfs/xattr_trusted.c | |||
@@ -8,29 +8,26 @@ | |||
8 | #include <linux/uaccess.h> | 8 | #include <linux/uaccess.h> |
9 | 9 | ||
10 | static int | 10 | static int |
11 | trusted_get(const struct xattr_handler *handler, struct dentry *dentry, | 11 | trusted_get(const struct xattr_handler *handler, struct dentry *unused, |
12 | const char *name, void *buffer, size_t size) | 12 | struct inode *inode, const char *name, void *buffer, size_t size) |
13 | { | 13 | { |
14 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) | 14 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) |
15 | return -EINVAL; | ||
16 | |||
17 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry))) | ||
18 | return -EPERM; | 15 | return -EPERM; |
19 | 16 | ||
20 | return reiserfs_xattr_get(d_inode(dentry), name, buffer, size); | 17 | return reiserfs_xattr_get(inode, xattr_full_name(handler, name), |
18 | buffer, size); | ||
21 | } | 19 | } |
22 | 20 | ||
23 | static int | 21 | static int |
24 | trusted_set(const struct xattr_handler *handler, struct dentry *dentry, | 22 | trusted_set(const struct xattr_handler *handler, struct dentry *dentry, |
25 | const char *name, const void *buffer, size_t size, int flags) | 23 | const char *name, const void *buffer, size_t size, int flags) |
26 | { | 24 | { |
27 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) | ||
28 | return -EINVAL; | ||
29 | |||
30 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry))) | 25 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry))) |
31 | return -EPERM; | 26 | return -EPERM; |
32 | 27 | ||
33 | return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags); | 28 | return reiserfs_xattr_set(d_inode(dentry), |
29 | xattr_full_name(handler, name), | ||
30 | buffer, size, flags); | ||
34 | } | 31 | } |
35 | 32 | ||
36 | static bool trusted_list(struct dentry *dentry) | 33 | static bool trusted_list(struct dentry *dentry) |
diff --git a/fs/reiserfs/xattr_user.c b/fs/reiserfs/xattr_user.c index 12e6306f562a..f7c39731684b 100644 --- a/fs/reiserfs/xattr_user.c +++ b/fs/reiserfs/xattr_user.c | |||
@@ -7,27 +7,24 @@ | |||
7 | #include <linux/uaccess.h> | 7 | #include <linux/uaccess.h> |
8 | 8 | ||
9 | static int | 9 | static int |
10 | user_get(const struct xattr_handler *handler, struct dentry *dentry, | 10 | user_get(const struct xattr_handler *handler, struct dentry *unused, |
11 | const char *name, void *buffer, size_t size) | 11 | struct inode *inode, const char *name, void *buffer, size_t size) |
12 | { | 12 | { |
13 | 13 | if (!reiserfs_xattrs_user(inode->i_sb)) | |
14 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) | ||
15 | return -EINVAL; | ||
16 | if (!reiserfs_xattrs_user(dentry->d_sb)) | ||
17 | return -EOPNOTSUPP; | 14 | return -EOPNOTSUPP; |
18 | return reiserfs_xattr_get(d_inode(dentry), name, buffer, size); | 15 | return reiserfs_xattr_get(inode, xattr_full_name(handler, name), |
16 | buffer, size); | ||
19 | } | 17 | } |
20 | 18 | ||
21 | static int | 19 | static int |
22 | user_set(const struct xattr_handler *handler, struct dentry *dentry, | 20 | user_set(const struct xattr_handler *handler, struct dentry *dentry, |
23 | const char *name, const void *buffer, size_t size, int flags) | 21 | const char *name, const void *buffer, size_t size, int flags) |
24 | { | 22 | { |
25 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) | ||
26 | return -EINVAL; | ||
27 | |||
28 | if (!reiserfs_xattrs_user(dentry->d_sb)) | 23 | if (!reiserfs_xattrs_user(dentry->d_sb)) |
29 | return -EOPNOTSUPP; | 24 | return -EOPNOTSUPP; |
30 | return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags); | 25 | return reiserfs_xattr_set(d_inode(dentry), |
26 | xattr_full_name(handler, name), | ||
27 | buffer, size, flags); | ||
31 | } | 28 | } |
32 | 29 | ||
33 | static bool user_list(struct dentry *dentry) | 30 | static bool user_list(struct dentry *dentry) |
diff --git a/fs/romfs/super.c b/fs/romfs/super.c index 6b00ca357c58..d0f8a38dfafa 100644 --- a/fs/romfs/super.c +++ b/fs/romfs/super.c | |||
@@ -280,8 +280,8 @@ error: | |||
280 | 280 | ||
281 | static const struct file_operations romfs_dir_operations = { | 281 | static const struct file_operations romfs_dir_operations = { |
282 | .read = generic_read_dir, | 282 | .read = generic_read_dir, |
283 | .iterate = romfs_readdir, | 283 | .iterate_shared = romfs_readdir, |
284 | .llseek = default_llseek, | 284 | .llseek = generic_file_llseek, |
285 | }; | 285 | }; |
286 | 286 | ||
287 | static const struct inode_operations romfs_dir_inode_operations = { | 287 | static const struct inode_operations romfs_dir_inode_operations = { |
diff --git a/fs/squashfs/dir.c b/fs/squashfs/dir.c index d8c2d747be28..a5845f94a2a1 100644 --- a/fs/squashfs/dir.c +++ b/fs/squashfs/dir.c | |||
@@ -231,6 +231,6 @@ failed_read: | |||
231 | 231 | ||
232 | const struct file_operations squashfs_dir_ops = { | 232 | const struct file_operations squashfs_dir_ops = { |
233 | .read = generic_read_dir, | 233 | .read = generic_read_dir, |
234 | .iterate = squashfs_readdir, | 234 | .iterate_shared = squashfs_readdir, |
235 | .llseek = default_llseek, | 235 | .llseek = generic_file_llseek, |
236 | }; | 236 | }; |
diff --git a/fs/squashfs/xattr.c b/fs/squashfs/xattr.c index 1e9de96288d8..1548b3784548 100644 --- a/fs/squashfs/xattr.c +++ b/fs/squashfs/xattr.c | |||
@@ -214,10 +214,12 @@ failed: | |||
214 | 214 | ||
215 | 215 | ||
216 | static int squashfs_xattr_handler_get(const struct xattr_handler *handler, | 216 | static int squashfs_xattr_handler_get(const struct xattr_handler *handler, |
217 | struct dentry *d, const char *name, | 217 | struct dentry *unused, |
218 | struct inode *inode, | ||
219 | const char *name, | ||
218 | void *buffer, size_t size) | 220 | void *buffer, size_t size) |
219 | { | 221 | { |
220 | return squashfs_xattr_get(d_inode(d), handler->flags, name, | 222 | return squashfs_xattr_get(inode, handler->flags, name, |
221 | buffer, size); | 223 | buffer, size); |
222 | } | 224 | } |
223 | 225 | ||
diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index c0f0a3e643eb..2661b77fc8a7 100644 --- a/fs/sysv/dir.c +++ b/fs/sysv/dir.c | |||
@@ -23,7 +23,7 @@ static int sysv_readdir(struct file *, struct dir_context *); | |||
23 | const struct file_operations sysv_dir_operations = { | 23 | const struct file_operations sysv_dir_operations = { |
24 | .llseek = generic_file_llseek, | 24 | .llseek = generic_file_llseek, |
25 | .read = generic_read_dir, | 25 | .read = generic_read_dir, |
26 | .iterate = sysv_readdir, | 26 | .iterate_shared = sysv_readdir, |
27 | .fsync = generic_file_fsync, | 27 | .fsync = generic_file_fsync, |
28 | }; | 28 | }; |
29 | 29 | ||
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 795992a8321e..34a5356d0ce7 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c | |||
@@ -1195,7 +1195,7 @@ const struct file_operations ubifs_dir_operations = { | |||
1195 | .llseek = generic_file_llseek, | 1195 | .llseek = generic_file_llseek, |
1196 | .release = ubifs_dir_release, | 1196 | .release = ubifs_dir_release, |
1197 | .read = generic_read_dir, | 1197 | .read = generic_read_dir, |
1198 | .iterate = ubifs_readdir, | 1198 | .iterate_shared = ubifs_readdir, |
1199 | .fsync = ubifs_fsync, | 1199 | .fsync = ubifs_fsync, |
1200 | .unlocked_ioctl = ubifs_ioctl, | 1200 | .unlocked_ioctl = ubifs_ioctl, |
1201 | #ifdef CONFIG_COMPAT | 1201 | #ifdef CONFIG_COMPAT |
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 4cd7e569cd00..12e79e60c176 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h | |||
@@ -1734,8 +1734,8 @@ int ubifs_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
1734 | /* xattr.c */ | 1734 | /* xattr.c */ |
1735 | int ubifs_setxattr(struct dentry *dentry, const char *name, | 1735 | int ubifs_setxattr(struct dentry *dentry, const char *name, |
1736 | const void *value, size_t size, int flags); | 1736 | const void *value, size_t size, int flags); |
1737 | ssize_t ubifs_getxattr(struct dentry *dentry, const char *name, void *buf, | 1737 | ssize_t ubifs_getxattr(struct dentry *dentry, struct inode *host, |
1738 | size_t size); | 1738 | const char *name, void *buf, size_t size); |
1739 | ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size); | 1739 | ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size); |
1740 | int ubifs_removexattr(struct dentry *dentry, const char *name); | 1740 | int ubifs_removexattr(struct dentry *dentry, const char *name); |
1741 | int ubifs_init_security(struct inode *dentry, struct inode *inode, | 1741 | int ubifs_init_security(struct inode *dentry, struct inode *inode, |
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c index b043e044121d..413d650c9476 100644 --- a/fs/ubifs/xattr.c +++ b/fs/ubifs/xattr.c | |||
@@ -372,10 +372,10 @@ int ubifs_setxattr(struct dentry *dentry, const char *name, | |||
372 | return setxattr(d_inode(dentry), name, value, size, flags); | 372 | return setxattr(d_inode(dentry), name, value, size, flags); |
373 | } | 373 | } |
374 | 374 | ||
375 | ssize_t ubifs_getxattr(struct dentry *dentry, const char *name, void *buf, | 375 | ssize_t ubifs_getxattr(struct dentry *dentry, struct inode *host, |
376 | size_t size) | 376 | const char *name, void *buf, size_t size) |
377 | { | 377 | { |
378 | struct inode *inode, *host = d_inode(dentry); | 378 | struct inode *inode; |
379 | struct ubifs_info *c = host->i_sb->s_fs_info; | 379 | struct ubifs_info *c = host->i_sb->s_fs_info; |
380 | struct qstr nm = QSTR_INIT(name, strlen(name)); | 380 | struct qstr nm = QSTR_INIT(name, strlen(name)); |
381 | struct ubifs_inode *ui; | 381 | struct ubifs_inode *ui; |
diff --git a/fs/udf/dir.c b/fs/udf/dir.c index b51b371b874a..4c5593abc553 100644 --- a/fs/udf/dir.c +++ b/fs/udf/dir.c | |||
@@ -202,7 +202,7 @@ out: | |||
202 | const struct file_operations udf_dir_operations = { | 202 | const struct file_operations udf_dir_operations = { |
203 | .llseek = generic_file_llseek, | 203 | .llseek = generic_file_llseek, |
204 | .read = generic_read_dir, | 204 | .read = generic_read_dir, |
205 | .iterate = udf_readdir, | 205 | .iterate_shared = udf_readdir, |
206 | .unlocked_ioctl = udf_ioctl, | 206 | .unlocked_ioctl = udf_ioctl, |
207 | .fsync = generic_file_fsync, | 207 | .fsync = generic_file_fsync, |
208 | }; | 208 | }; |
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index a2ba11eca995..c3e5c9679371 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
@@ -1250,7 +1250,7 @@ static struct dentry *udf_get_parent(struct dentry *child) | |||
1250 | brelse(fibh.sbh); | 1250 | brelse(fibh.sbh); |
1251 | 1251 | ||
1252 | tloc = lelb_to_cpu(cfi.icb.extLocation); | 1252 | tloc = lelb_to_cpu(cfi.icb.extLocation); |
1253 | inode = udf_iget(d_inode(child)->i_sb, &tloc); | 1253 | inode = udf_iget(child->d_sb, &tloc); |
1254 | if (IS_ERR(inode)) | 1254 | if (IS_ERR(inode)) |
1255 | return ERR_CAST(inode); | 1255 | return ERR_CAST(inode); |
1256 | 1256 | ||
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 0b1457292734..57dcceda17d6 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c | |||
@@ -105,7 +105,7 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, | |||
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | static void ufs_check_page(struct page *page) | 108 | static bool ufs_check_page(struct page *page) |
109 | { | 109 | { |
110 | struct inode *dir = page->mapping->host; | 110 | struct inode *dir = page->mapping->host; |
111 | struct super_block *sb = dir->i_sb; | 111 | struct super_block *sb = dir->i_sb; |
@@ -143,7 +143,7 @@ static void ufs_check_page(struct page *page) | |||
143 | goto Eend; | 143 | goto Eend; |
144 | out: | 144 | out: |
145 | SetPageChecked(page); | 145 | SetPageChecked(page); |
146 | return; | 146 | return true; |
147 | 147 | ||
148 | /* Too bad, we had an error */ | 148 | /* Too bad, we had an error */ |
149 | 149 | ||
@@ -180,8 +180,8 @@ Eend: | |||
180 | "offset=%lu", | 180 | "offset=%lu", |
181 | dir->i_ino, (page->index<<PAGE_SHIFT)+offs); | 181 | dir->i_ino, (page->index<<PAGE_SHIFT)+offs); |
182 | fail: | 182 | fail: |
183 | SetPageChecked(page); | ||
184 | SetPageError(page); | 183 | SetPageError(page); |
184 | return false; | ||
185 | } | 185 | } |
186 | 186 | ||
187 | static struct page *ufs_get_page(struct inode *dir, unsigned long n) | 187 | static struct page *ufs_get_page(struct inode *dir, unsigned long n) |
@@ -190,10 +190,10 @@ static struct page *ufs_get_page(struct inode *dir, unsigned long n) | |||
190 | struct page *page = read_mapping_page(mapping, n, NULL); | 190 | struct page *page = read_mapping_page(mapping, n, NULL); |
191 | if (!IS_ERR(page)) { | 191 | if (!IS_ERR(page)) { |
192 | kmap(page); | 192 | kmap(page); |
193 | if (!PageChecked(page)) | 193 | if (unlikely(!PageChecked(page))) { |
194 | ufs_check_page(page); | 194 | if (PageError(page) || !ufs_check_page(page)) |
195 | if (PageError(page)) | 195 | goto fail; |
196 | goto fail; | 196 | } |
197 | } | 197 | } |
198 | return page; | 198 | return page; |
199 | 199 | ||
@@ -653,7 +653,7 @@ not_empty: | |||
653 | 653 | ||
654 | const struct file_operations ufs_dir_operations = { | 654 | const struct file_operations ufs_dir_operations = { |
655 | .read = generic_read_dir, | 655 | .read = generic_read_dir, |
656 | .iterate = ufs_readdir, | 656 | .iterate_shared = ufs_readdir, |
657 | .fsync = generic_file_fsync, | 657 | .fsync = generic_file_fsync, |
658 | .llseek = generic_file_llseek, | 658 | .llseek = generic_file_llseek, |
659 | }; | 659 | }; |
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 442fd52ebffe..f04ab232d08d 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -132,7 +132,7 @@ static struct dentry *ufs_get_parent(struct dentry *child) | |||
132 | ino = ufs_inode_by_name(d_inode(child), &dot_dot); | 132 | ino = ufs_inode_by_name(d_inode(child), &dot_dot); |
133 | if (!ino) | 133 | if (!ino) |
134 | return ERR_PTR(-ENOENT); | 134 | return ERR_PTR(-ENOENT); |
135 | return d_obtain_alias(ufs_iget(d_inode(child)->i_sb, ino)); | 135 | return d_obtain_alias(ufs_iget(child->d_sb, ino)); |
136 | } | 136 | } |
137 | 137 | ||
138 | static const struct export_operations ufs_export_ops = { | 138 | static const struct export_operations ufs_export_ops = { |
diff --git a/fs/xattr.c b/fs/xattr.c index 4861322e28e8..b11945e15fde 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
@@ -192,7 +192,7 @@ vfs_getxattr_alloc(struct dentry *dentry, const char *name, char **xattr_value, | |||
192 | if (!inode->i_op->getxattr) | 192 | if (!inode->i_op->getxattr) |
193 | return -EOPNOTSUPP; | 193 | return -EOPNOTSUPP; |
194 | 194 | ||
195 | error = inode->i_op->getxattr(dentry, name, NULL, 0); | 195 | error = inode->i_op->getxattr(dentry, inode, name, NULL, 0); |
196 | if (error < 0) | 196 | if (error < 0) |
197 | return error; | 197 | return error; |
198 | 198 | ||
@@ -203,7 +203,7 @@ vfs_getxattr_alloc(struct dentry *dentry, const char *name, char **xattr_value, | |||
203 | memset(value, 0, error + 1); | 203 | memset(value, 0, error + 1); |
204 | } | 204 | } |
205 | 205 | ||
206 | error = inode->i_op->getxattr(dentry, name, value, error); | 206 | error = inode->i_op->getxattr(dentry, inode, name, value, error); |
207 | *xattr_value = value; | 207 | *xattr_value = value; |
208 | return error; | 208 | return error; |
209 | } | 209 | } |
@@ -236,7 +236,7 @@ vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size) | |||
236 | } | 236 | } |
237 | nolsm: | 237 | nolsm: |
238 | if (inode->i_op->getxattr) | 238 | if (inode->i_op->getxattr) |
239 | error = inode->i_op->getxattr(dentry, name, value, size); | 239 | error = inode->i_op->getxattr(dentry, inode, name, value, size); |
240 | else | 240 | else |
241 | error = -EOPNOTSUPP; | 241 | error = -EOPNOTSUPP; |
242 | 242 | ||
@@ -691,14 +691,16 @@ xattr_resolve_name(const struct xattr_handler **handlers, const char **name) | |||
691 | * Find the handler for the prefix and dispatch its get() operation. | 691 | * Find the handler for the prefix and dispatch its get() operation. |
692 | */ | 692 | */ |
693 | ssize_t | 693 | ssize_t |
694 | generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) | 694 | generic_getxattr(struct dentry *dentry, struct inode *inode, |
695 | const char *name, void *buffer, size_t size) | ||
695 | { | 696 | { |
696 | const struct xattr_handler *handler; | 697 | const struct xattr_handler *handler; |
697 | 698 | ||
698 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); | 699 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
699 | if (IS_ERR(handler)) | 700 | if (IS_ERR(handler)) |
700 | return PTR_ERR(handler); | 701 | return PTR_ERR(handler); |
701 | return handler->get(handler, dentry, name, buffer, size); | 702 | return handler->get(handler, dentry, inode, |
703 | name, buffer, size); | ||
702 | } | 704 | } |
703 | 705 | ||
704 | /* | 706 | /* |
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c index 2d5df1f23bbc..b6e527b8eccb 100644 --- a/fs/xfs/xfs_acl.c +++ b/fs/xfs/xfs_acl.c | |||
@@ -158,22 +158,14 @@ xfs_get_acl(struct inode *inode, int type) | |||
158 | if (error) { | 158 | if (error) { |
159 | /* | 159 | /* |
160 | * If the attribute doesn't exist make sure we have a negative | 160 | * If the attribute doesn't exist make sure we have a negative |
161 | * cache entry, for any other error assume it is transient and | 161 | * cache entry, for any other error assume it is transient. |
162 | * leave the cache entry as ACL_NOT_CACHED. | ||
163 | */ | 162 | */ |
164 | if (error == -ENOATTR) | 163 | if (error != -ENOATTR) |
165 | goto out_update_cache; | 164 | acl = ERR_PTR(error); |
166 | acl = ERR_PTR(error); | 165 | } else { |
167 | goto out; | 166 | acl = xfs_acl_from_disk(xfs_acl, len, |
167 | XFS_ACL_MAX_ENTRIES(ip->i_mount)); | ||
168 | } | 168 | } |
169 | |||
170 | acl = xfs_acl_from_disk(xfs_acl, len, XFS_ACL_MAX_ENTRIES(ip->i_mount)); | ||
171 | if (IS_ERR(acl)) | ||
172 | goto out; | ||
173 | |||
174 | out_update_cache: | ||
175 | set_cached_acl(inode, type, acl); | ||
176 | out: | ||
177 | kmem_free(xfs_acl); | 169 | kmem_free(xfs_acl); |
178 | return acl; | 170 | return acl; |
179 | } | 171 | } |
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 569938a4a357..345fd85a1997 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
@@ -1714,7 +1714,7 @@ const struct file_operations xfs_file_operations = { | |||
1714 | const struct file_operations xfs_dir_file_operations = { | 1714 | const struct file_operations xfs_dir_file_operations = { |
1715 | .open = xfs_dir_open, | 1715 | .open = xfs_dir_open, |
1716 | .read = generic_read_dir, | 1716 | .read = generic_read_dir, |
1717 | .iterate = xfs_file_readdir, | 1717 | .iterate_shared = xfs_file_readdir, |
1718 | .llseek = generic_file_llseek, | 1718 | .llseek = generic_file_llseek, |
1719 | .unlocked_ioctl = xfs_file_ioctl, | 1719 | .unlocked_ioctl = xfs_file_ioctl, |
1720 | #ifdef CONFIG_COMPAT | 1720 | #ifdef CONFIG_COMPAT |
diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 110f1d7d86b0..d111f691f313 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c | |||
@@ -32,11 +32,11 @@ | |||
32 | 32 | ||
33 | 33 | ||
34 | static int | 34 | static int |
35 | xfs_xattr_get(const struct xattr_handler *handler, struct dentry *dentry, | 35 | xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused, |
36 | const char *name, void *value, size_t size) | 36 | struct inode *inode, const char *name, void *value, size_t size) |
37 | { | 37 | { |
38 | int xflags = handler->flags; | 38 | int xflags = handler->flags; |
39 | struct xfs_inode *ip = XFS_I(d_inode(dentry)); | 39 | struct xfs_inode *ip = XFS_I(inode); |
40 | int error, asize = size; | 40 | int error, asize = size; |
41 | 41 | ||
42 | /* Convert Linux syscall to XFS internal ATTR flags */ | 42 | /* Convert Linux syscall to XFS internal ATTR flags */ |
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 7e9422cb5989..f8506e8dd4d4 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -123,7 +123,10 @@ struct dentry { | |||
123 | unsigned long d_time; /* used by d_revalidate */ | 123 | unsigned long d_time; /* used by d_revalidate */ |
124 | void *d_fsdata; /* fs-specific data */ | 124 | void *d_fsdata; /* fs-specific data */ |
125 | 125 | ||
126 | struct list_head d_lru; /* LRU list */ | 126 | union { |
127 | struct list_head d_lru; /* LRU list */ | ||
128 | wait_queue_head_t *d_wait; /* in-lookup ones only */ | ||
129 | }; | ||
127 | struct list_head d_child; /* child of parent list */ | 130 | struct list_head d_child; /* child of parent list */ |
128 | struct list_head d_subdirs; /* our children */ | 131 | struct list_head d_subdirs; /* our children */ |
129 | /* | 132 | /* |
@@ -131,6 +134,7 @@ struct dentry { | |||
131 | */ | 134 | */ |
132 | union { | 135 | union { |
133 | struct hlist_node d_alias; /* inode alias list */ | 136 | struct hlist_node d_alias; /* inode alias list */ |
137 | struct hlist_bl_node d_in_lookup_hash; /* only for in-lookup ones */ | ||
134 | struct rcu_head d_rcu; | 138 | struct rcu_head d_rcu; |
135 | } d_u; | 139 | } d_u; |
136 | }; | 140 | }; |
@@ -232,6 +236,8 @@ struct dentry_operations { | |||
232 | #define DCACHE_ENCRYPTED_WITH_KEY 0x04000000 /* dir is encrypted with a valid key */ | 236 | #define DCACHE_ENCRYPTED_WITH_KEY 0x04000000 /* dir is encrypted with a valid key */ |
233 | #define DCACHE_OP_REAL 0x08000000 | 237 | #define DCACHE_OP_REAL 0x08000000 |
234 | 238 | ||
239 | #define DCACHE_PAR_LOOKUP 0x10000000 /* being looked up (with parent locked shared) */ | ||
240 | |||
235 | extern seqlock_t rename_lock; | 241 | extern seqlock_t rename_lock; |
236 | 242 | ||
237 | /* | 243 | /* |
@@ -248,6 +254,8 @@ extern void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op | |||
248 | /* allocate/de-allocate */ | 254 | /* allocate/de-allocate */ |
249 | extern struct dentry * d_alloc(struct dentry *, const struct qstr *); | 255 | extern struct dentry * d_alloc(struct dentry *, const struct qstr *); |
250 | extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *); | 256 | extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *); |
257 | extern struct dentry * d_alloc_parallel(struct dentry *, const struct qstr *, | ||
258 | wait_queue_head_t *); | ||
251 | extern struct dentry * d_splice_alias(struct inode *, struct dentry *); | 259 | extern struct dentry * d_splice_alias(struct inode *, struct dentry *); |
252 | extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *); | 260 | extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *); |
253 | extern struct dentry * d_exact_alias(struct dentry *, struct inode *); | 261 | extern struct dentry * d_exact_alias(struct dentry *, struct inode *); |
@@ -367,6 +375,22 @@ static inline void dont_mount(struct dentry *dentry) | |||
367 | spin_unlock(&dentry->d_lock); | 375 | spin_unlock(&dentry->d_lock); |
368 | } | 376 | } |
369 | 377 | ||
378 | extern void __d_lookup_done(struct dentry *); | ||
379 | |||
380 | static inline int d_in_lookup(struct dentry *dentry) | ||
381 | { | ||
382 | return dentry->d_flags & DCACHE_PAR_LOOKUP; | ||
383 | } | ||
384 | |||
385 | static inline void d_lookup_done(struct dentry *dentry) | ||
386 | { | ||
387 | if (unlikely(d_in_lookup(dentry))) { | ||
388 | spin_lock(&dentry->d_lock); | ||
389 | __d_lookup_done(dentry); | ||
390 | spin_unlock(&dentry->d_lock); | ||
391 | } | ||
392 | } | ||
393 | |||
370 | extern void dput(struct dentry *); | 394 | extern void dput(struct dentry *); |
371 | 395 | ||
372 | static inline bool d_managed(const struct dentry *dentry) | 396 | static inline bool d_managed(const struct dentry *dentry) |
diff --git a/include/linux/file.h b/include/linux/file.h index f87d30882a24..7444f5feda12 100644 --- a/include/linux/file.h +++ b/include/linux/file.h | |||
@@ -44,6 +44,7 @@ extern struct file *fget_raw(unsigned int fd); | |||
44 | extern unsigned long __fdget(unsigned int fd); | 44 | extern unsigned long __fdget(unsigned int fd); |
45 | extern unsigned long __fdget_raw(unsigned int fd); | 45 | extern unsigned long __fdget_raw(unsigned int fd); |
46 | extern unsigned long __fdget_pos(unsigned int fd); | 46 | extern unsigned long __fdget_pos(unsigned int fd); |
47 | extern void __f_unlock_pos(struct file *); | ||
47 | 48 | ||
48 | static inline struct fd __to_fd(unsigned long v) | 49 | static inline struct fd __to_fd(unsigned long v) |
49 | { | 50 | { |
@@ -60,6 +61,18 @@ static inline struct fd fdget_raw(unsigned int fd) | |||
60 | return __to_fd(__fdget_raw(fd)); | 61 | return __to_fd(__fdget_raw(fd)); |
61 | } | 62 | } |
62 | 63 | ||
64 | static inline struct fd fdget_pos(int fd) | ||
65 | { | ||
66 | return __to_fd(__fdget_pos(fd)); | ||
67 | } | ||
68 | |||
69 | static inline void fdput_pos(struct fd f) | ||
70 | { | ||
71 | if (f.flags & FDPUT_POS_UNLOCK) | ||
72 | __f_unlock_pos(f.file); | ||
73 | fdput(f); | ||
74 | } | ||
75 | |||
63 | extern int f_dupfd(unsigned int from, struct file *file, unsigned flags); | 76 | extern int f_dupfd(unsigned int from, struct file *file, unsigned flags); |
64 | extern int replace_fd(unsigned fd, struct file *file, unsigned flags); | 77 | extern int replace_fd(unsigned fd, struct file *file, unsigned flags); |
65 | extern void set_close_on_exec(unsigned int fd, int flag); | 78 | extern void set_close_on_exec(unsigned int fd, int flag); |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 70e61b58baaf..e87245ac6941 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -577,6 +577,18 @@ static inline void mapping_allow_writable(struct address_space *mapping) | |||
577 | struct posix_acl; | 577 | struct posix_acl; |
578 | #define ACL_NOT_CACHED ((void *)(-1)) | 578 | #define ACL_NOT_CACHED ((void *)(-1)) |
579 | 579 | ||
580 | static inline struct posix_acl * | ||
581 | uncached_acl_sentinel(struct task_struct *task) | ||
582 | { | ||
583 | return (void *)task + 1; | ||
584 | } | ||
585 | |||
586 | static inline bool | ||
587 | is_uncached_acl(struct posix_acl *acl) | ||
588 | { | ||
589 | return (long)acl & 1; | ||
590 | } | ||
591 | |||
580 | #define IOP_FASTPERM 0x0001 | 592 | #define IOP_FASTPERM 0x0001 |
581 | #define IOP_LOOKUP 0x0002 | 593 | #define IOP_LOOKUP 0x0002 |
582 | #define IOP_NOFOLLOW 0x0004 | 594 | #define IOP_NOFOLLOW 0x0004 |
@@ -635,7 +647,7 @@ struct inode { | |||
635 | 647 | ||
636 | /* Misc */ | 648 | /* Misc */ |
637 | unsigned long i_state; | 649 | unsigned long i_state; |
638 | struct mutex i_mutex; | 650 | struct rw_semaphore i_rwsem; |
639 | 651 | ||
640 | unsigned long dirtied_when; /* jiffies of first dirtying */ | 652 | unsigned long dirtied_when; /* jiffies of first dirtying */ |
641 | unsigned long dirtied_time_when; | 653 | unsigned long dirtied_time_when; |
@@ -672,6 +684,7 @@ struct inode { | |||
672 | struct block_device *i_bdev; | 684 | struct block_device *i_bdev; |
673 | struct cdev *i_cdev; | 685 | struct cdev *i_cdev; |
674 | char *i_link; | 686 | char *i_link; |
687 | unsigned i_dir_seq; | ||
675 | }; | 688 | }; |
676 | 689 | ||
677 | __u32 i_generation; | 690 | __u32 i_generation; |
@@ -721,27 +734,42 @@ enum inode_i_mutex_lock_class | |||
721 | 734 | ||
722 | static inline void inode_lock(struct inode *inode) | 735 | static inline void inode_lock(struct inode *inode) |
723 | { | 736 | { |
724 | mutex_lock(&inode->i_mutex); | 737 | down_write(&inode->i_rwsem); |
725 | } | 738 | } |
726 | 739 | ||
727 | static inline void inode_unlock(struct inode *inode) | 740 | static inline void inode_unlock(struct inode *inode) |
728 | { | 741 | { |
729 | mutex_unlock(&inode->i_mutex); | 742 | up_write(&inode->i_rwsem); |
743 | } | ||
744 | |||
745 | static inline void inode_lock_shared(struct inode *inode) | ||
746 | { | ||
747 | down_read(&inode->i_rwsem); | ||
748 | } | ||
749 | |||
750 | static inline void inode_unlock_shared(struct inode *inode) | ||
751 | { | ||
752 | up_read(&inode->i_rwsem); | ||
730 | } | 753 | } |
731 | 754 | ||
732 | static inline int inode_trylock(struct inode *inode) | 755 | static inline int inode_trylock(struct inode *inode) |
733 | { | 756 | { |
734 | return mutex_trylock(&inode->i_mutex); | 757 | return down_write_trylock(&inode->i_rwsem); |
758 | } | ||
759 | |||
760 | static inline int inode_trylock_shared(struct inode *inode) | ||
761 | { | ||
762 | return down_read_trylock(&inode->i_rwsem); | ||
735 | } | 763 | } |
736 | 764 | ||
737 | static inline int inode_is_locked(struct inode *inode) | 765 | static inline int inode_is_locked(struct inode *inode) |
738 | { | 766 | { |
739 | return mutex_is_locked(&inode->i_mutex); | 767 | return rwsem_is_locked(&inode->i_rwsem); |
740 | } | 768 | } |
741 | 769 | ||
742 | static inline void inode_lock_nested(struct inode *inode, unsigned subclass) | 770 | static inline void inode_lock_nested(struct inode *inode, unsigned subclass) |
743 | { | 771 | { |
744 | mutex_lock_nested(&inode->i_mutex, subclass); | 772 | down_write_nested(&inode->i_rwsem, subclass); |
745 | } | 773 | } |
746 | 774 | ||
747 | void lock_two_nondirectories(struct inode *, struct inode*); | 775 | void lock_two_nondirectories(struct inode *, struct inode*); |
@@ -1646,6 +1674,7 @@ struct file_operations { | |||
1646 | ssize_t (*read_iter) (struct kiocb *, struct iov_iter *); | 1674 | ssize_t (*read_iter) (struct kiocb *, struct iov_iter *); |
1647 | ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); | 1675 | ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); |
1648 | int (*iterate) (struct file *, struct dir_context *); | 1676 | int (*iterate) (struct file *, struct dir_context *); |
1677 | int (*iterate_shared) (struct file *, struct dir_context *); | ||
1649 | unsigned int (*poll) (struct file *, struct poll_table_struct *); | 1678 | unsigned int (*poll) (struct file *, struct poll_table_struct *); |
1650 | long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); | 1679 | long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); |
1651 | long (*compat_ioctl) (struct file *, unsigned int, unsigned long); | 1680 | long (*compat_ioctl) (struct file *, unsigned int, unsigned long); |
@@ -1700,7 +1729,8 @@ struct inode_operations { | |||
1700 | int (*setattr) (struct dentry *, struct iattr *); | 1729 | int (*setattr) (struct dentry *, struct iattr *); |
1701 | int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); | 1730 | int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); |
1702 | int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); | 1731 | int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); |
1703 | ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t); | 1732 | ssize_t (*getxattr) (struct dentry *, struct inode *, |
1733 | const char *, void *, size_t); | ||
1704 | ssize_t (*listxattr) (struct dentry *, char *, size_t); | 1734 | ssize_t (*listxattr) (struct dentry *, char *, size_t); |
1705 | int (*removexattr) (struct dentry *, const char *); | 1735 | int (*removexattr) (struct dentry *, const char *); |
1706 | int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, | 1736 | int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, |
@@ -3104,6 +3134,13 @@ static inline bool dir_relax(struct inode *inode) | |||
3104 | return !IS_DEADDIR(inode); | 3134 | return !IS_DEADDIR(inode); |
3105 | } | 3135 | } |
3106 | 3136 | ||
3137 | static inline bool dir_relax_shared(struct inode *inode) | ||
3138 | { | ||
3139 | inode_unlock_shared(inode); | ||
3140 | inode_lock_shared(inode); | ||
3141 | return !IS_DEADDIR(inode); | ||
3142 | } | ||
3143 | |||
3107 | extern bool path_noexec(const struct path *path); | 3144 | extern bool path_noexec(const struct path *path); |
3108 | extern void inode_nohighmem(struct inode *inode); | 3145 | extern void inode_nohighmem(struct inode *inode); |
3109 | 3146 | ||
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 67300f8e5f2f..fa167f25465d 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h | |||
@@ -163,11 +163,9 @@ struct nfs_inode { | |||
163 | /* Open contexts for shared mmap writes */ | 163 | /* Open contexts for shared mmap writes */ |
164 | struct list_head open_files; | 164 | struct list_head open_files; |
165 | 165 | ||
166 | /* Number of in-flight sillydelete RPC calls */ | 166 | /* Readers: in-flight sillydelete RPC calls */ |
167 | atomic_t silly_count; | 167 | /* Writers: rmdir */ |
168 | /* List of deferred sillydelete requests */ | 168 | struct rw_semaphore rmdir_sem; |
169 | struct hlist_head silly_list; | ||
170 | wait_queue_head_t waitqueue; | ||
171 | 169 | ||
172 | #if IS_ENABLED(CONFIG_NFS_V4) | 170 | #if IS_ENABLED(CONFIG_NFS_V4) |
173 | struct nfs4_cached_acl *nfs4_acl; | 171 | struct nfs4_cached_acl *nfs4_acl; |
@@ -492,9 +490,6 @@ extern void nfs_release_automount_timer(void); | |||
492 | * linux/fs/nfs/unlink.c | 490 | * linux/fs/nfs/unlink.c |
493 | */ | 491 | */ |
494 | extern void nfs_complete_unlink(struct dentry *dentry, struct inode *); | 492 | extern void nfs_complete_unlink(struct dentry *dentry, struct inode *); |
495 | extern void nfs_wait_on_sillyrename(struct dentry *dentry); | ||
496 | extern void nfs_block_sillyrename(struct dentry *dentry); | ||
497 | extern void nfs_unblock_sillyrename(struct dentry *dentry); | ||
498 | 493 | ||
499 | /* | 494 | /* |
500 | * linux/fs/nfs/write.c | 495 | * linux/fs/nfs/write.c |
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index d320906cf13e..ee8491dadbf3 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h | |||
@@ -1468,10 +1468,10 @@ struct nfs_pgio_completion_ops { | |||
1468 | }; | 1468 | }; |
1469 | 1469 | ||
1470 | struct nfs_unlinkdata { | 1470 | struct nfs_unlinkdata { |
1471 | struct hlist_node list; | ||
1472 | struct nfs_removeargs args; | 1471 | struct nfs_removeargs args; |
1473 | struct nfs_removeres res; | 1472 | struct nfs_removeres res; |
1474 | struct inode *dir; | 1473 | struct dentry *dentry; |
1474 | wait_queue_head_t wq; | ||
1475 | struct rpc_cred *cred; | 1475 | struct rpc_cred *cred; |
1476 | struct nfs_fattr dir_attr; | 1476 | struct nfs_fattr dir_attr; |
1477 | long timeout; | 1477 | long timeout; |
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h index 3e96a6a76103..5b5a80cc5926 100644 --- a/include/linux/posix_acl.h +++ b/include/linux/posix_acl.h | |||
@@ -99,7 +99,6 @@ extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **, | |||
99 | extern int simple_set_acl(struct inode *, struct posix_acl *, int); | 99 | extern int simple_set_acl(struct inode *, struct posix_acl *, int); |
100 | extern int simple_acl_create(struct inode *, struct inode *); | 100 | extern int simple_acl_create(struct inode *, struct inode *); |
101 | 101 | ||
102 | struct posix_acl **acl_by_type(struct inode *inode, int type); | ||
103 | struct posix_acl *get_cached_acl(struct inode *inode, int type); | 102 | struct posix_acl *get_cached_acl(struct inode *inode, int type); |
104 | struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type); | 103 | struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type); |
105 | void set_cached_acl(struct inode *inode, int type, struct posix_acl *acl); | 104 | void set_cached_acl(struct inode *inode, int type, struct posix_acl *acl); |
diff --git a/include/linux/xattr.h b/include/linux/xattr.h index 4457541de3c9..1cc4c578deb9 100644 --- a/include/linux/xattr.h +++ b/include/linux/xattr.h | |||
@@ -30,7 +30,8 @@ struct xattr_handler { | |||
30 | int flags; /* fs private flags */ | 30 | int flags; /* fs private flags */ |
31 | bool (*list)(struct dentry *dentry); | 31 | bool (*list)(struct dentry *dentry); |
32 | int (*get)(const struct xattr_handler *, struct dentry *dentry, | 32 | int (*get)(const struct xattr_handler *, struct dentry *dentry, |
33 | const char *name, void *buffer, size_t size); | 33 | struct inode *inode, const char *name, void *buffer, |
34 | size_t size); | ||
34 | int (*set)(const struct xattr_handler *, struct dentry *dentry, | 35 | int (*set)(const struct xattr_handler *, struct dentry *dentry, |
35 | const char *name, const void *buffer, size_t size, | 36 | const char *name, const void *buffer, size_t size, |
36 | int flags); | 37 | int flags); |
@@ -51,7 +52,7 @@ int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, i | |||
51 | int vfs_setxattr(struct dentry *, const char *, const void *, size_t, int); | 52 | int vfs_setxattr(struct dentry *, const char *, const void *, size_t, int); |
52 | int vfs_removexattr(struct dentry *, const char *); | 53 | int vfs_removexattr(struct dentry *, const char *); |
53 | 54 | ||
54 | ssize_t generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size); | 55 | ssize_t generic_getxattr(struct dentry *dentry, struct inode *inode, const char *name, void *buffer, size_t size); |
55 | ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size); | 56 | ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size); |
56 | int generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags); | 57 | int generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags); |
57 | int generic_removexattr(struct dentry *dentry, const char *name); | 58 | int generic_removexattr(struct dentry *dentry, const char *name); |
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h index 4e4b2fa78609..09c71e9aaebf 100644 --- a/include/trace/events/ext4.h +++ b/include/trace/events/ext4.h | |||
@@ -872,7 +872,7 @@ TRACE_EVENT(ext4_sync_file_enter, | |||
872 | TP_fast_assign( | 872 | TP_fast_assign( |
873 | struct dentry *dentry = file->f_path.dentry; | 873 | struct dentry *dentry = file->f_path.dentry; |
874 | 874 | ||
875 | __entry->dev = d_inode(dentry)->i_sb->s_dev; | 875 | __entry->dev = dentry->d_sb->s_dev; |
876 | __entry->ino = d_inode(dentry)->i_ino; | 876 | __entry->ino = d_inode(dentry)->i_ino; |
877 | __entry->datasync = datasync; | 877 | __entry->datasync = datasync; |
878 | __entry->parent = d_inode(dentry->d_parent)->i_ino; | 878 | __entry->parent = d_inode(dentry->d_parent)->i_ino; |
@@ -1451,7 +1451,7 @@ TRACE_EVENT(ext4_unlink_enter, | |||
1451 | ), | 1451 | ), |
1452 | 1452 | ||
1453 | TP_fast_assign( | 1453 | TP_fast_assign( |
1454 | __entry->dev = d_inode(dentry)->i_sb->s_dev; | 1454 | __entry->dev = dentry->d_sb->s_dev; |
1455 | __entry->ino = d_inode(dentry)->i_ino; | 1455 | __entry->ino = d_inode(dentry)->i_ino; |
1456 | __entry->parent = parent->i_ino; | 1456 | __entry->parent = parent->i_ino; |
1457 | __entry->size = d_inode(dentry)->i_size; | 1457 | __entry->size = d_inode(dentry)->i_size; |
@@ -1475,7 +1475,7 @@ TRACE_EVENT(ext4_unlink_exit, | |||
1475 | ), | 1475 | ), |
1476 | 1476 | ||
1477 | TP_fast_assign( | 1477 | TP_fast_assign( |
1478 | __entry->dev = d_inode(dentry)->i_sb->s_dev; | 1478 | __entry->dev = dentry->d_sb->s_dev; |
1479 | __entry->ino = d_inode(dentry)->i_ino; | 1479 | __entry->ino = d_inode(dentry)->i_ino; |
1480 | __entry->ret = ret; | 1480 | __entry->ret = ret; |
1481 | ), | 1481 | ), |
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c index 3cf1c5978d39..d6709eb70970 100644 --- a/kernel/audit_watch.c +++ b/kernel/audit_watch.c | |||
@@ -367,7 +367,7 @@ static int audit_get_nd(struct audit_watch *watch, struct path *parent) | |||
367 | inode_unlock(d_backing_inode(parent->dentry)); | 367 | inode_unlock(d_backing_inode(parent->dentry)); |
368 | if (d_is_positive(d)) { | 368 | if (d_is_positive(d)) { |
369 | /* update watch filter fields */ | 369 | /* update watch filter fields */ |
370 | watch->dev = d_backing_inode(d)->i_sb->s_dev; | 370 | watch->dev = d->d_sb->s_dev; |
371 | watch->ino = d_backing_inode(d)->i_ino; | 371 | watch->ino = d_backing_inode(d)->i_ino; |
372 | } | 372 | } |
373 | dput(d); | 373 | dput(d); |
diff --git a/mm/shmem.c b/mm/shmem.c index 719bd6b88d98..e684a9140228 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -2646,10 +2646,10 @@ static int shmem_initxattrs(struct inode *inode, | |||
2646 | } | 2646 | } |
2647 | 2647 | ||
2648 | static int shmem_xattr_handler_get(const struct xattr_handler *handler, | 2648 | static int shmem_xattr_handler_get(const struct xattr_handler *handler, |
2649 | struct dentry *dentry, const char *name, | 2649 | struct dentry *unused, struct inode *inode, |
2650 | void *buffer, size_t size) | 2650 | const char *name, void *buffer, size_t size) |
2651 | { | 2651 | { |
2652 | struct shmem_inode_info *info = SHMEM_I(d_inode(dentry)); | 2652 | struct shmem_inode_info *info = SHMEM_I(inode); |
2653 | 2653 | ||
2654 | name = xattr_full_name(handler, name); | 2654 | name = xattr_full_name(handler, name); |
2655 | return simple_xattr_get(&info->xattrs, name, buffer, size); | 2655 | return simple_xattr_get(&info->xattrs, name, buffer, size); |
@@ -3123,7 +3123,8 @@ static struct inode *shmem_alloc_inode(struct super_block *sb) | |||
3123 | static void shmem_destroy_callback(struct rcu_head *head) | 3123 | static void shmem_destroy_callback(struct rcu_head *head) |
3124 | { | 3124 | { |
3125 | struct inode *inode = container_of(head, struct inode, i_rcu); | 3125 | struct inode *inode = container_of(head, struct inode, i_rcu); |
3126 | kfree(inode->i_link); | 3126 | if (S_ISLNK(inode->i_mode)) |
3127 | kfree(inode->i_link); | ||
3127 | kmem_cache_free(shmem_inode_cachep, SHMEM_I(inode)); | 3128 | kmem_cache_free(shmem_inode_cachep, SHMEM_I(inode)); |
3128 | } | 3129 | } |
3129 | 3130 | ||
diff --git a/net/socket.c b/net/socket.c index 5f77a8e93830..35e4523edada 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -466,7 +466,7 @@ static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed) | |||
466 | #define XATTR_SOCKPROTONAME_SUFFIX "sockprotoname" | 466 | #define XATTR_SOCKPROTONAME_SUFFIX "sockprotoname" |
467 | #define XATTR_NAME_SOCKPROTONAME (XATTR_SYSTEM_PREFIX XATTR_SOCKPROTONAME_SUFFIX) | 467 | #define XATTR_NAME_SOCKPROTONAME (XATTR_SYSTEM_PREFIX XATTR_SOCKPROTONAME_SUFFIX) |
468 | #define XATTR_NAME_SOCKPROTONAME_LEN (sizeof(XATTR_NAME_SOCKPROTONAME)-1) | 468 | #define XATTR_NAME_SOCKPROTONAME_LEN (sizeof(XATTR_NAME_SOCKPROTONAME)-1) |
469 | static ssize_t sockfs_getxattr(struct dentry *dentry, | 469 | static ssize_t sockfs_getxattr(struct dentry *dentry, struct inode *inode, |
470 | const char *name, void *value, size_t size) | 470 | const char *name, void *value, size_t size) |
471 | { | 471 | { |
472 | const char *proto_name; | 472 | const char *proto_name; |
diff --git a/security/commoncap.c b/security/commoncap.c index 2074bf6a2fe3..e7fadde737f4 100644 --- a/security/commoncap.c +++ b/security/commoncap.c | |||
@@ -313,7 +313,7 @@ int cap_inode_need_killpriv(struct dentry *dentry) | |||
313 | if (!inode->i_op->getxattr) | 313 | if (!inode->i_op->getxattr) |
314 | return 0; | 314 | return 0; |
315 | 315 | ||
316 | error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0); | 316 | error = inode->i_op->getxattr(dentry, inode, XATTR_NAME_CAPS, NULL, 0); |
317 | if (error <= 0) | 317 | if (error <= 0) |
318 | return 0; | 318 | return 0; |
319 | return 1; | 319 | return 1; |
@@ -397,8 +397,8 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data | |||
397 | if (!inode || !inode->i_op->getxattr) | 397 | if (!inode || !inode->i_op->getxattr) |
398 | return -ENODATA; | 398 | return -ENODATA; |
399 | 399 | ||
400 | size = inode->i_op->getxattr((struct dentry *)dentry, XATTR_NAME_CAPS, &caps, | 400 | size = inode->i_op->getxattr((struct dentry *)dentry, inode, |
401 | XATTR_CAPS_SZ); | 401 | XATTR_NAME_CAPS, &caps, XATTR_CAPS_SZ); |
402 | if (size == -ENODATA || size == -EOPNOTSUPP) | 402 | if (size == -ENODATA || size == -EOPNOTSUPP) |
403 | /* no data, that's ok */ | 403 | /* no data, that's ok */ |
404 | return -ENODATA; | 404 | return -ENODATA; |
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index e6ea9d4b1de9..b9e26288d30c 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c | |||
@@ -82,7 +82,7 @@ static int evm_find_protected_xattrs(struct dentry *dentry) | |||
82 | return -EOPNOTSUPP; | 82 | return -EOPNOTSUPP; |
83 | 83 | ||
84 | for (xattr = evm_config_xattrnames; *xattr != NULL; xattr++) { | 84 | for (xattr = evm_config_xattrnames; *xattr != NULL; xattr++) { |
85 | error = inode->i_op->getxattr(dentry, *xattr, NULL, 0); | 85 | error = inode->i_op->getxattr(dentry, inode, *xattr, NULL, 0); |
86 | if (error < 0) { | 86 | if (error < 0) { |
87 | if (error == -ENODATA) | 87 | if (error == -ENODATA) |
88 | continue; | 88 | continue; |
@@ -299,8 +299,8 @@ static int evm_protect_xattr(struct dentry *dentry, const char *xattr_name, | |||
299 | return 0; | 299 | return 0; |
300 | 300 | ||
301 | /* exception for pseudo filesystems */ | 301 | /* exception for pseudo filesystems */ |
302 | if (dentry->d_inode->i_sb->s_magic == TMPFS_MAGIC | 302 | if (dentry->d_sb->s_magic == TMPFS_MAGIC |
303 | || dentry->d_inode->i_sb->s_magic == SYSFS_MAGIC) | 303 | || dentry->d_sb->s_magic == SYSFS_MAGIC) |
304 | return 0; | 304 | return 0; |
305 | 305 | ||
306 | integrity_audit_msg(AUDIT_INTEGRITY_METADATA, | 306 | integrity_audit_msg(AUDIT_INTEGRITY_METADATA, |
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 912deee3f01e..469f5c75bd4b 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -506,7 +506,8 @@ static int sb_finish_set_opts(struct super_block *sb) | |||
506 | rc = -EOPNOTSUPP; | 506 | rc = -EOPNOTSUPP; |
507 | goto out; | 507 | goto out; |
508 | } | 508 | } |
509 | rc = root_inode->i_op->getxattr(root, XATTR_NAME_SELINUX, NULL, 0); | 509 | rc = root_inode->i_op->getxattr(root, root_inode, |
510 | XATTR_NAME_SELINUX, NULL, 0); | ||
510 | if (rc < 0 && rc != -ENODATA) { | 511 | if (rc < 0 && rc != -ENODATA) { |
511 | if (rc == -EOPNOTSUPP) | 512 | if (rc == -EOPNOTSUPP) |
512 | printk(KERN_WARNING "SELinux: (dev %s, type " | 513 | printk(KERN_WARNING "SELinux: (dev %s, type " |
@@ -1316,7 +1317,7 @@ static int selinux_genfs_get_sid(struct dentry *dentry, | |||
1316 | u32 *sid) | 1317 | u32 *sid) |
1317 | { | 1318 | { |
1318 | int rc; | 1319 | int rc; |
1319 | struct super_block *sb = dentry->d_inode->i_sb; | 1320 | struct super_block *sb = dentry->d_sb; |
1320 | char *buffer, *path; | 1321 | char *buffer, *path; |
1321 | 1322 | ||
1322 | buffer = (char *)__get_free_page(GFP_KERNEL); | 1323 | buffer = (char *)__get_free_page(GFP_KERNEL); |
@@ -1412,13 +1413,13 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent | |||
1412 | goto out_unlock; | 1413 | goto out_unlock; |
1413 | } | 1414 | } |
1414 | context[len] = '\0'; | 1415 | context[len] = '\0'; |
1415 | rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX, | 1416 | rc = inode->i_op->getxattr(dentry, inode, XATTR_NAME_SELINUX, |
1416 | context, len); | 1417 | context, len); |
1417 | if (rc == -ERANGE) { | 1418 | if (rc == -ERANGE) { |
1418 | kfree(context); | 1419 | kfree(context); |
1419 | 1420 | ||
1420 | /* Need a larger buffer. Query for the right size. */ | 1421 | /* Need a larger buffer. Query for the right size. */ |
1421 | rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX, | 1422 | rc = inode->i_op->getxattr(dentry, inode, XATTR_NAME_SELINUX, |
1422 | NULL, 0); | 1423 | NULL, 0); |
1423 | if (rc < 0) { | 1424 | if (rc < 0) { |
1424 | dput(dentry); | 1425 | dput(dentry); |
@@ -1432,7 +1433,7 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent | |||
1432 | goto out_unlock; | 1433 | goto out_unlock; |
1433 | } | 1434 | } |
1434 | context[len] = '\0'; | 1435 | context[len] = '\0'; |
1435 | rc = inode->i_op->getxattr(dentry, | 1436 | rc = inode->i_op->getxattr(dentry, inode, |
1436 | XATTR_NAME_SELINUX, | 1437 | XATTR_NAME_SELINUX, |
1437 | context, len); | 1438 | context, len); |
1438 | } | 1439 | } |
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 11f79013ae1f..ff2b8c3cf7a9 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
@@ -272,7 +272,7 @@ static struct smack_known *smk_fetch(const char *name, struct inode *ip, | |||
272 | if (buffer == NULL) | 272 | if (buffer == NULL) |
273 | return ERR_PTR(-ENOMEM); | 273 | return ERR_PTR(-ENOMEM); |
274 | 274 | ||
275 | rc = ip->i_op->getxattr(dp, name, buffer, SMK_LONGLABEL); | 275 | rc = ip->i_op->getxattr(dp, ip, name, buffer, SMK_LONGLABEL); |
276 | if (rc < 0) | 276 | if (rc < 0) |
277 | skp = ERR_PTR(rc); | 277 | skp = ERR_PTR(rc); |
278 | else if (rc == 0) | 278 | else if (rc == 0) |
@@ -1444,7 +1444,7 @@ static int smack_inode_removexattr(struct dentry *dentry, const char *name) | |||
1444 | * XATTR_NAME_SMACKIPOUT | 1444 | * XATTR_NAME_SMACKIPOUT |
1445 | */ | 1445 | */ |
1446 | if (strcmp(name, XATTR_NAME_SMACK) == 0) { | 1446 | if (strcmp(name, XATTR_NAME_SMACK) == 0) { |
1447 | struct super_block *sbp = d_backing_inode(dentry)->i_sb; | 1447 | struct super_block *sbp = dentry->d_sb; |
1448 | struct superblock_smack *sbsp = sbp->s_security; | 1448 | struct superblock_smack *sbsp = sbp->s_security; |
1449 | 1449 | ||
1450 | isp->smk_inode = sbsp->smk_default; | 1450 | isp->smk_inode = sbsp->smk_default; |
@@ -3519,7 +3519,7 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode) | |||
3519 | TRANS_TRUE, TRANS_TRUE_SIZE, | 3519 | TRANS_TRUE, TRANS_TRUE_SIZE, |
3520 | 0); | 3520 | 0); |
3521 | } else { | 3521 | } else { |
3522 | rc = inode->i_op->getxattr(dp, | 3522 | rc = inode->i_op->getxattr(dp, inode, |
3523 | XATTR_NAME_SMACKTRANSMUTE, trattr, | 3523 | XATTR_NAME_SMACKTRANSMUTE, trattr, |
3524 | TRANS_TRUE_SIZE); | 3524 | TRANS_TRUE_SIZE); |
3525 | if (rc >= 0 && strncmp(trattr, TRANS_TRUE, | 3525 | if (rc >= 0 && strncmp(trattr, TRANS_TRUE, |