diff options
author | David Howells <dhowells@redhat.com> | 2015-03-17 18:26:15 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-15 15:06:58 -0400 |
commit | dea655c28a32ac760c057383dadb5be0f5632362 (patch) | |
tree | 1bbbed2ea1d1ca3871b6e5273fbf58c304c32ad9 /fs | |
parent | 75c3cfa855dcedc84e7964269c9b6baf26137959 (diff) |
VFS: fs library helpers: d_inode() annotations
library helpers called by filesystem drivers on their own inodes
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/libfs.c | 26 | ||||
-rw-r--r-- | fs/quota/dquot.c | 10 |
2 files changed, 18 insertions, 18 deletions
diff --git a/fs/libfs.c b/fs/libfs.c index 0ab65122ee45..cb1fb4b9b637 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -22,13 +22,13 @@ | |||
22 | 22 | ||
23 | static inline int simple_positive(struct dentry *dentry) | 23 | static inline int simple_positive(struct dentry *dentry) |
24 | { | 24 | { |
25 | return dentry->d_inode && !d_unhashed(dentry); | 25 | return d_really_is_positive(dentry) && !d_unhashed(dentry); |
26 | } | 26 | } |
27 | 27 | ||
28 | int simple_getattr(struct vfsmount *mnt, struct dentry *dentry, | 28 | int simple_getattr(struct vfsmount *mnt, struct dentry *dentry, |
29 | struct kstat *stat) | 29 | struct kstat *stat) |
30 | { | 30 | { |
31 | struct inode *inode = dentry->d_inode; | 31 | struct inode *inode = d_inode(dentry); |
32 | generic_fillattr(inode, stat); | 32 | generic_fillattr(inode, stat); |
33 | stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9); | 33 | stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9); |
34 | return 0; | 34 | return 0; |
@@ -94,7 +94,7 @@ EXPORT_SYMBOL(dcache_dir_close); | |||
94 | loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) | 94 | loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) |
95 | { | 95 | { |
96 | struct dentry *dentry = file->f_path.dentry; | 96 | struct dentry *dentry = file->f_path.dentry; |
97 | mutex_lock(&dentry->d_inode->i_mutex); | 97 | mutex_lock(&d_inode(dentry)->i_mutex); |
98 | switch (whence) { | 98 | switch (whence) { |
99 | case 1: | 99 | case 1: |
100 | offset += file->f_pos; | 100 | offset += file->f_pos; |
@@ -102,7 +102,7 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) | |||
102 | if (offset >= 0) | 102 | if (offset >= 0) |
103 | break; | 103 | break; |
104 | default: | 104 | default: |
105 | mutex_unlock(&dentry->d_inode->i_mutex); | 105 | mutex_unlock(&d_inode(dentry)->i_mutex); |
106 | return -EINVAL; | 106 | return -EINVAL; |
107 | } | 107 | } |
108 | if (offset != file->f_pos) { | 108 | if (offset != file->f_pos) { |
@@ -129,7 +129,7 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) | |||
129 | spin_unlock(&dentry->d_lock); | 129 | spin_unlock(&dentry->d_lock); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | mutex_unlock(&dentry->d_inode->i_mutex); | 132 | mutex_unlock(&d_inode(dentry)->i_mutex); |
133 | return offset; | 133 | return offset; |
134 | } | 134 | } |
135 | EXPORT_SYMBOL(dcache_dir_lseek); | 135 | EXPORT_SYMBOL(dcache_dir_lseek); |
@@ -169,7 +169,7 @@ int dcache_readdir(struct file *file, struct dir_context *ctx) | |||
169 | spin_unlock(&next->d_lock); | 169 | spin_unlock(&next->d_lock); |
170 | spin_unlock(&dentry->d_lock); | 170 | spin_unlock(&dentry->d_lock); |
171 | if (!dir_emit(ctx, next->d_name.name, next->d_name.len, | 171 | if (!dir_emit(ctx, next->d_name.name, next->d_name.len, |
172 | next->d_inode->i_ino, dt_type(next->d_inode))) | 172 | d_inode(next)->i_ino, dt_type(d_inode(next)))) |
173 | return 0; | 173 | return 0; |
174 | spin_lock(&dentry->d_lock); | 174 | spin_lock(&dentry->d_lock); |
175 | spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED); | 175 | spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED); |
@@ -270,7 +270,7 @@ EXPORT_SYMBOL(simple_open); | |||
270 | 270 | ||
271 | int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) | 271 | int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) |
272 | { | 272 | { |
273 | struct inode *inode = old_dentry->d_inode; | 273 | struct inode *inode = d_inode(old_dentry); |
274 | 274 | ||
275 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; | 275 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; |
276 | inc_nlink(inode); | 276 | inc_nlink(inode); |
@@ -304,7 +304,7 @@ EXPORT_SYMBOL(simple_empty); | |||
304 | 304 | ||
305 | int simple_unlink(struct inode *dir, struct dentry *dentry) | 305 | int simple_unlink(struct inode *dir, struct dentry *dentry) |
306 | { | 306 | { |
307 | struct inode *inode = dentry->d_inode; | 307 | struct inode *inode = d_inode(dentry); |
308 | 308 | ||
309 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; | 309 | inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; |
310 | drop_nlink(inode); | 310 | drop_nlink(inode); |
@@ -318,7 +318,7 @@ int simple_rmdir(struct inode *dir, struct dentry *dentry) | |||
318 | if (!simple_empty(dentry)) | 318 | if (!simple_empty(dentry)) |
319 | return -ENOTEMPTY; | 319 | return -ENOTEMPTY; |
320 | 320 | ||
321 | drop_nlink(dentry->d_inode); | 321 | drop_nlink(d_inode(dentry)); |
322 | simple_unlink(dir, dentry); | 322 | simple_unlink(dir, dentry); |
323 | drop_nlink(dir); | 323 | drop_nlink(dir); |
324 | return 0; | 324 | return 0; |
@@ -328,16 +328,16 @@ EXPORT_SYMBOL(simple_rmdir); | |||
328 | int simple_rename(struct inode *old_dir, struct dentry *old_dentry, | 328 | int simple_rename(struct inode *old_dir, struct dentry *old_dentry, |
329 | struct inode *new_dir, struct dentry *new_dentry) | 329 | struct inode *new_dir, struct dentry *new_dentry) |
330 | { | 330 | { |
331 | struct inode *inode = old_dentry->d_inode; | 331 | struct inode *inode = d_inode(old_dentry); |
332 | int they_are_dirs = d_is_dir(old_dentry); | 332 | int they_are_dirs = d_is_dir(old_dentry); |
333 | 333 | ||
334 | if (!simple_empty(new_dentry)) | 334 | if (!simple_empty(new_dentry)) |
335 | return -ENOTEMPTY; | 335 | return -ENOTEMPTY; |
336 | 336 | ||
337 | if (new_dentry->d_inode) { | 337 | if (d_really_is_positive(new_dentry)) { |
338 | simple_unlink(new_dir, new_dentry); | 338 | simple_unlink(new_dir, new_dentry); |
339 | if (they_are_dirs) { | 339 | if (they_are_dirs) { |
340 | drop_nlink(new_dentry->d_inode); | 340 | drop_nlink(d_inode(new_dentry)); |
341 | drop_nlink(old_dir); | 341 | drop_nlink(old_dir); |
342 | } | 342 | } |
343 | } else if (they_are_dirs) { | 343 | } else if (they_are_dirs) { |
@@ -368,7 +368,7 @@ EXPORT_SYMBOL(simple_rename); | |||
368 | */ | 368 | */ |
369 | int simple_setattr(struct dentry *dentry, struct iattr *iattr) | 369 | int simple_setattr(struct dentry *dentry, struct iattr *iattr) |
370 | { | 370 | { |
371 | struct inode *inode = dentry->d_inode; | 371 | struct inode *inode = d_inode(dentry); |
372 | int error; | 372 | int error; |
373 | 373 | ||
374 | error = inode_change_ok(inode, iattr); | 374 | error = inode_change_ok(inode, iattr); |
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 0ccd4ba3a246..3a5f01319379 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -2299,7 +2299,7 @@ int dquot_quota_on(struct super_block *sb, int type, int format_id, | |||
2299 | if (path->dentry->d_sb != sb) | 2299 | if (path->dentry->d_sb != sb) |
2300 | error = -EXDEV; | 2300 | error = -EXDEV; |
2301 | else | 2301 | else |
2302 | error = vfs_load_quota_inode(path->dentry->d_inode, type, | 2302 | error = vfs_load_quota_inode(d_inode(path->dentry), type, |
2303 | format_id, DQUOT_USAGE_ENABLED | | 2303 | format_id, DQUOT_USAGE_ENABLED | |
2304 | DQUOT_LIMITS_ENABLED); | 2304 | DQUOT_LIMITS_ENABLED); |
2305 | return error; | 2305 | return error; |
@@ -2363,20 +2363,20 @@ int dquot_quota_on_mount(struct super_block *sb, char *qf_name, | |||
2363 | struct dentry *dentry; | 2363 | struct dentry *dentry; |
2364 | int error; | 2364 | int error; |
2365 | 2365 | ||
2366 | mutex_lock(&sb->s_root->d_inode->i_mutex); | 2366 | mutex_lock(&d_inode(sb->s_root)->i_mutex); |
2367 | dentry = lookup_one_len(qf_name, sb->s_root, strlen(qf_name)); | 2367 | dentry = lookup_one_len(qf_name, sb->s_root, strlen(qf_name)); |
2368 | mutex_unlock(&sb->s_root->d_inode->i_mutex); | 2368 | mutex_unlock(&d_inode(sb->s_root)->i_mutex); |
2369 | if (IS_ERR(dentry)) | 2369 | if (IS_ERR(dentry)) |
2370 | return PTR_ERR(dentry); | 2370 | return PTR_ERR(dentry); |
2371 | 2371 | ||
2372 | if (!dentry->d_inode) { | 2372 | if (d_really_is_negative(dentry)) { |
2373 | error = -ENOENT; | 2373 | error = -ENOENT; |
2374 | goto out; | 2374 | goto out; |
2375 | } | 2375 | } |
2376 | 2376 | ||
2377 | error = security_quota_on(dentry); | 2377 | error = security_quota_on(dentry); |
2378 | if (!error) | 2378 | if (!error) |
2379 | error = vfs_load_quota_inode(dentry->d_inode, type, format_id, | 2379 | error = vfs_load_quota_inode(d_inode(dentry), type, format_id, |
2380 | DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); | 2380 | DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); |
2381 | 2381 | ||
2382 | out: | 2382 | out: |