提交 ce40fa78 编写于 作者: D David Howells 提交者: Al Viro

Cachefiles: Fix up scripted S_ISDIR/S_ISREG/S_ISLNK conversions

Fix up the following scripted S_ISDIR/S_ISREG/S_ISLNK conversions (or lack
thereof) in cachefiles:

 (1) Cachefiles mostly wants to use d_can_lookup() rather than d_is_dir() as
     it doesn't want to deal with automounts in its cache.

 (2) Coccinelle didn't find S_IS* expressions in ASSERT() statements in
     cachefiles.
Signed-off-by: NDavid Howells <dhowells@redhat.com>
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 e36cb0b8
...@@ -574,7 +574,7 @@ static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args) ...@@ -574,7 +574,7 @@ static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args)
/* extract the directory dentry from the cwd */ /* extract the directory dentry from the cwd */
get_fs_pwd(current->fs, &path); get_fs_pwd(current->fs, &path);
if (!d_is_dir(path.dentry)) if (!d_can_lookup(path.dentry))
goto notdir; goto notdir;
cachefiles_begin_secure(cache, &saved_cred); cachefiles_begin_secure(cache, &saved_cred);
...@@ -646,7 +646,7 @@ static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args) ...@@ -646,7 +646,7 @@ static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args)
/* extract the directory dentry from the cwd */ /* extract the directory dentry from the cwd */
get_fs_pwd(current->fs, &path); get_fs_pwd(current->fs, &path);
if (!d_is_dir(path.dentry)) if (!d_can_lookup(path.dentry))
goto notdir; goto notdir;
cachefiles_begin_secure(cache, &saved_cred); cachefiles_begin_secure(cache, &saved_cred);
......
...@@ -437,7 +437,7 @@ static int cachefiles_attr_changed(struct fscache_object *_object) ...@@ -437,7 +437,7 @@ static int cachefiles_attr_changed(struct fscache_object *_object)
if (!object->backer) if (!object->backer)
return -ENOBUFS; return -ENOBUFS;
ASSERT(S_ISREG(object->backer->d_inode->i_mode)); ASSERT(d_is_reg(object->backer));
fscache_set_store_limit(&object->fscache, ni_size); fscache_set_store_limit(&object->fscache, ni_size);
...@@ -501,7 +501,7 @@ static void cachefiles_invalidate_object(struct fscache_operation *op) ...@@ -501,7 +501,7 @@ static void cachefiles_invalidate_object(struct fscache_operation *op)
op->object->debug_id, (unsigned long long)ni_size); op->object->debug_id, (unsigned long long)ni_size);
if (object->backer) { if (object->backer) {
ASSERT(S_ISREG(object->backer->d_inode->i_mode)); ASSERT(d_is_reg(object->backer));
fscache_set_store_limit(&object->fscache, ni_size); fscache_set_store_limit(&object->fscache, ni_size);
......
...@@ -323,7 +323,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache, ...@@ -323,7 +323,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache,
return 0; return 0;
} }
if (!d_is_dir(cache->graveyard)) { if (!d_can_lookup(cache->graveyard)) {
unlock_rename(cache->graveyard, dir); unlock_rename(cache->graveyard, dir);
cachefiles_io_error(cache, "Graveyard no longer a directory"); cachefiles_io_error(cache, "Graveyard no longer a directory");
return -EIO; return -EIO;
...@@ -539,7 +539,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent, ...@@ -539,7 +539,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent,
_debug("mkdir -> %p{%p{ino=%lu}}", _debug("mkdir -> %p{%p{ino=%lu}}",
next, next->d_inode, next->d_inode->i_ino); next, next->d_inode, next->d_inode->i_ino);
} else if (!d_is_dir(next)) { } else if (!d_can_lookup(next)) {
pr_err("inode %lu is not a directory\n", pr_err("inode %lu is not a directory\n",
next->d_inode->i_ino); next->d_inode->i_ino);
ret = -ENOBUFS; ret = -ENOBUFS;
...@@ -568,7 +568,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent, ...@@ -568,7 +568,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent,
_debug("create -> %p{%p{ino=%lu}}", _debug("create -> %p{%p{ino=%lu}}",
next, next->d_inode, next->d_inode->i_ino); next, next->d_inode, next->d_inode->i_ino);
} else if (!d_is_dir(next) && } else if (!d_can_lookup(next) &&
!d_is_reg(next) !d_is_reg(next)
) { ) {
pr_err("inode %lu is not a file or directory\n", pr_err("inode %lu is not a file or directory\n",
...@@ -763,7 +763,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache, ...@@ -763,7 +763,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
/* we need to make sure the subdir is a directory */ /* we need to make sure the subdir is a directory */
ASSERT(subdir->d_inode); ASSERT(subdir->d_inode);
if (!d_is_dir(subdir)) { if (!d_can_lookup(subdir)) {
pr_err("%s is not a directory\n", dirname); pr_err("%s is not a directory\n", dirname);
ret = -EIO; ret = -EIO;
goto check_error; goto check_error;
......
...@@ -900,7 +900,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page) ...@@ -900,7 +900,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
return -ENOBUFS; return -ENOBUFS;
} }
ASSERT(S_ISREG(object->backer->d_inode->i_mode)); ASSERT(d_is_reg(object->backer));
cache = container_of(object->fscache.cache, cache = container_of(object->fscache.cache,
struct cachefiles_cache, cache); struct cachefiles_cache, cache);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册