Commit dea655c2 authored by David Howells's avatar David Howells Committed by Al Viro

VFS: fs library helpers: d_inode() annotations

library helpers called by filesystem drivers on their own inodes
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 75c3cfa8
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
static inline int simple_positive(struct dentry *dentry) static inline int simple_positive(struct dentry *dentry)
{ {
return dentry->d_inode && !d_unhashed(dentry); return d_really_is_positive(dentry) && !d_unhashed(dentry);
} }
int simple_getattr(struct vfsmount *mnt, struct dentry *dentry, int simple_getattr(struct vfsmount *mnt, struct dentry *dentry,
struct kstat *stat) struct kstat *stat)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = d_inode(dentry);
generic_fillattr(inode, stat); generic_fillattr(inode, stat);
stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9); stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9);
return 0; return 0;
...@@ -94,7 +94,7 @@ EXPORT_SYMBOL(dcache_dir_close); ...@@ -94,7 +94,7 @@ EXPORT_SYMBOL(dcache_dir_close);
loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
{ {
struct dentry *dentry = file->f_path.dentry; struct dentry *dentry = file->f_path.dentry;
mutex_lock(&dentry->d_inode->i_mutex); mutex_lock(&d_inode(dentry)->i_mutex);
switch (whence) { switch (whence) {
case 1: case 1:
offset += file->f_pos; offset += file->f_pos;
...@@ -102,7 +102,7 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) ...@@ -102,7 +102,7 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
if (offset >= 0) if (offset >= 0)
break; break;
default: default:
mutex_unlock(&dentry->d_inode->i_mutex); mutex_unlock(&d_inode(dentry)->i_mutex);
return -EINVAL; return -EINVAL;
} }
if (offset != file->f_pos) { if (offset != file->f_pos) {
...@@ -129,7 +129,7 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) ...@@ -129,7 +129,7 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
} }
} }
mutex_unlock(&dentry->d_inode->i_mutex); mutex_unlock(&d_inode(dentry)->i_mutex);
return offset; return offset;
} }
EXPORT_SYMBOL(dcache_dir_lseek); EXPORT_SYMBOL(dcache_dir_lseek);
...@@ -169,7 +169,7 @@ int dcache_readdir(struct file *file, struct dir_context *ctx) ...@@ -169,7 +169,7 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
spin_unlock(&next->d_lock); spin_unlock(&next->d_lock);
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
if (!dir_emit(ctx, next->d_name.name, next->d_name.len, if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
next->d_inode->i_ino, dt_type(next->d_inode))) d_inode(next)->i_ino, dt_type(d_inode(next))))
return 0; return 0;
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
...@@ -270,7 +270,7 @@ EXPORT_SYMBOL(simple_open); ...@@ -270,7 +270,7 @@ EXPORT_SYMBOL(simple_open);
int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
{ {
struct inode *inode = old_dentry->d_inode; struct inode *inode = d_inode(old_dentry);
inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
inc_nlink(inode); inc_nlink(inode);
...@@ -304,7 +304,7 @@ EXPORT_SYMBOL(simple_empty); ...@@ -304,7 +304,7 @@ EXPORT_SYMBOL(simple_empty);
int simple_unlink(struct inode *dir, struct dentry *dentry) int simple_unlink(struct inode *dir, struct dentry *dentry)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = d_inode(dentry);
inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
drop_nlink(inode); drop_nlink(inode);
...@@ -318,7 +318,7 @@ int simple_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -318,7 +318,7 @@ int simple_rmdir(struct inode *dir, struct dentry *dentry)
if (!simple_empty(dentry)) if (!simple_empty(dentry))
return -ENOTEMPTY; return -ENOTEMPTY;
drop_nlink(dentry->d_inode); drop_nlink(d_inode(dentry));
simple_unlink(dir, dentry); simple_unlink(dir, dentry);
drop_nlink(dir); drop_nlink(dir);
return 0; return 0;
...@@ -328,16 +328,16 @@ EXPORT_SYMBOL(simple_rmdir); ...@@ -328,16 +328,16 @@ EXPORT_SYMBOL(simple_rmdir);
int simple_rename(struct inode *old_dir, struct dentry *old_dentry, int simple_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry) struct inode *new_dir, struct dentry *new_dentry)
{ {
struct inode *inode = old_dentry->d_inode; struct inode *inode = d_inode(old_dentry);
int they_are_dirs = d_is_dir(old_dentry); int they_are_dirs = d_is_dir(old_dentry);
if (!simple_empty(new_dentry)) if (!simple_empty(new_dentry))
return -ENOTEMPTY; return -ENOTEMPTY;
if (new_dentry->d_inode) { if (d_really_is_positive(new_dentry)) {
simple_unlink(new_dir, new_dentry); simple_unlink(new_dir, new_dentry);
if (they_are_dirs) { if (they_are_dirs) {
drop_nlink(new_dentry->d_inode); drop_nlink(d_inode(new_dentry));
drop_nlink(old_dir); drop_nlink(old_dir);
} }
} else if (they_are_dirs) { } else if (they_are_dirs) {
...@@ -368,7 +368,7 @@ EXPORT_SYMBOL(simple_rename); ...@@ -368,7 +368,7 @@ EXPORT_SYMBOL(simple_rename);
*/ */
int simple_setattr(struct dentry *dentry, struct iattr *iattr) int simple_setattr(struct dentry *dentry, struct iattr *iattr)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = d_inode(dentry);
int error; int error;
error = inode_change_ok(inode, iattr); error = inode_change_ok(inode, iattr);
......
...@@ -2299,7 +2299,7 @@ int dquot_quota_on(struct super_block *sb, int type, int format_id, ...@@ -2299,7 +2299,7 @@ int dquot_quota_on(struct super_block *sb, int type, int format_id,
if (path->dentry->d_sb != sb) if (path->dentry->d_sb != sb)
error = -EXDEV; error = -EXDEV;
else else
error = vfs_load_quota_inode(path->dentry->d_inode, type, error = vfs_load_quota_inode(d_inode(path->dentry), type,
format_id, DQUOT_USAGE_ENABLED | format_id, DQUOT_USAGE_ENABLED |
DQUOT_LIMITS_ENABLED); DQUOT_LIMITS_ENABLED);
return error; return error;
...@@ -2363,20 +2363,20 @@ int dquot_quota_on_mount(struct super_block *sb, char *qf_name, ...@@ -2363,20 +2363,20 @@ int dquot_quota_on_mount(struct super_block *sb, char *qf_name,
struct dentry *dentry; struct dentry *dentry;
int error; int error;
mutex_lock(&sb->s_root->d_inode->i_mutex); mutex_lock(&d_inode(sb->s_root)->i_mutex);
dentry = lookup_one_len(qf_name, sb->s_root, strlen(qf_name)); dentry = lookup_one_len(qf_name, sb->s_root, strlen(qf_name));
mutex_unlock(&sb->s_root->d_inode->i_mutex); mutex_unlock(&d_inode(sb->s_root)->i_mutex);
if (IS_ERR(dentry)) if (IS_ERR(dentry))
return PTR_ERR(dentry); return PTR_ERR(dentry);
if (!dentry->d_inode) { if (d_really_is_negative(dentry)) {
error = -ENOENT; error = -ENOENT;
goto out; goto out;
} }
error = security_quota_on(dentry); error = security_quota_on(dentry);
if (!error) if (!error)
error = vfs_load_quota_inode(dentry->d_inode, type, format_id, error = vfs_load_quota_inode(d_inode(dentry), type, format_id,
DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
out: out:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment