aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2015-01-29 07:02:35 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-02-22 11:38:41 -0500
commite36cb0b89ce20b4f8786a57e8a6bc8476f577650 (patch)
tree68adea9f719915013dfd85e9b5872b5bc00b1c70 /fs
parent2c616d4d88de1dc5b1545eefdc2e291eeb9f2e9d (diff)
VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry)
Convert the following where appropriate: (1) S_ISLNK(dentry->d_inode) to d_is_symlink(dentry). (2) S_ISREG(dentry->d_inode) to d_is_reg(dentry). (3) S_ISDIR(dentry->d_inode) to d_is_dir(dentry). This is actually more complicated than it appears as some calls should be converted to d_can_lookup() instead. The difference is whether the directory in question is a real dir with a ->lookup op or whether it's a fake dir with a ->d_automount op. In some circumstances, we can subsume checks for dentry->d_inode not being NULL into this, provided we the code isn't in a filesystem that expects d_inode to be NULL if the dirent really *is* negative (ie. if we're going to use d_inode() rather than d_backing_inode() to get the inode pointer). Note that the dentry type field may be set to something other than DCACHE_MISS_TYPE when d_inode is NULL in the case of unionmount, where the VFS manages the fall-through from a negative dentry to a lower layer. In such a case, the dentry type of the negative union dentry is set to the same as the type of the lower dentry. However, if you know d_inode is not NULL at the call site, then you can use the d_is_xxx() functions even in a filesystem. There is one further complication: a 0,0 chardev dentry may be labelled DCACHE_WHITEOUT_TYPE rather than DCACHE_SPECIAL_TYPE. Strictly, this was intended for special directory entry types that don't have attached inodes. The following perl+coccinelle script was used: use strict; my @callers; open($fd, 'git grep -l \'S_IS[A-Z].*->d_inode\' |') || die "Can't grep for S_ISDIR and co. callers"; @callers = <$fd>; close($fd); unless (@callers) { print "No matches\n"; exit(0); } my @cocci = ( '@@', 'expression E;', '@@', '', '- S_ISLNK(E->d_inode->i_mode)', '+ d_is_symlink(E)', '', '@@', 'expression E;', '@@', '', '- S_ISDIR(E->d_inode->i_mode)', '+ d_is_dir(E)', '', '@@', 'expression E;', '@@', '', '- S_ISREG(E->d_inode->i_mode)', '+ d_is_reg(E)' ); my $coccifile = "tmp.sp.cocci"; open($fd, ">$coccifile") || die $coccifile; print($fd "$_\n") || die $coccifile foreach (@cocci); close($fd); foreach my $file (@callers) { chomp $file; print "Processing ", $file, "\n"; system("spatch", "--sp-file", $coccifile, $file, "--in-place", "--no-show-diff") == 0 || die "spatch failed"; } [AV: overlayfs parts skipped] 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/9p/vfs_inode.c2
-rw-r--r--fs/autofs4/expire.c2
-rw-r--r--fs/autofs4/root.c4
-rw-r--r--fs/btrfs/ioctl.c4
-rw-r--r--fs/cachefiles/daemon.c4
-rw-r--r--fs/cachefiles/namei.c16
-rw-r--r--fs/ceph/dir.c2
-rw-r--r--fs/ceph/file.c2
-rw-r--r--fs/coda/dir.c2
-rw-r--r--fs/debugfs/inode.c2
-rw-r--r--fs/ecryptfs/file.c2
-rw-r--r--fs/ecryptfs/inode.c4
-rw-r--r--fs/exportfs/expfs.c2
-rw-r--r--fs/fuse/dir.c2
-rw-r--r--fs/gfs2/dir.c2
-rw-r--r--fs/hfsplus/dir.c2
-rw-r--r--fs/hppfs/hppfs.c4
-rw-r--r--fs/jffs2/dir.c14
-rw-r--r--fs/jffs2/super.c2
-rw-r--r--fs/libfs.c2
-rw-r--r--fs/namei.c2
-rw-r--r--fs/namespace.c10
-rw-r--r--fs/nfsd/nfs4recover.c4
-rw-r--r--fs/nfsd/nfsfh.c8
-rw-r--r--fs/nfsd/vfs.c8
-rw-r--r--fs/notify/fanotify/fanotify.c6
-rw-r--r--fs/overlayfs/dir.c6
-rw-r--r--fs/posix_acl.c4
-rw-r--r--fs/reiserfs/xattr.c4
-rw-r--r--fs/xfs/xfs_ioctl.c2
30 files changed, 65 insertions, 65 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 9ee5343d4884..3662f1d1d9cf 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -1127,7 +1127,7 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
1127 } 1127 }
1128 1128
1129 /* Write all dirty data */ 1129 /* Write all dirty data */
1130 if (S_ISREG(dentry->d_inode->i_mode)) 1130 if (d_is_reg(dentry))
1131 filemap_write_and_wait(dentry->d_inode->i_mapping); 1131 filemap_write_and_wait(dentry->d_inode->i_mapping);
1132 1132
1133 retval = p9_client_wstat(fid, &wstat); 1133 retval = p9_client_wstat(fid, &wstat);
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index bfdbaba9c2ba..11dd118f75e2 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -374,7 +374,7 @@ static struct dentry *should_expire(struct dentry *dentry,
374 return NULL; 374 return NULL;
375 } 375 }
376 376
377 if (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)) { 377 if (dentry->d_inode && d_is_symlink(dentry)) {
378 DPRINTK("checking symlink %p %pd", dentry, dentry); 378 DPRINTK("checking symlink %p %pd", dentry, dentry);
379 /* 379 /*
380 * A symlink can't be "busy" in the usual sense so 380 * A symlink can't be "busy" in the usual sense so
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 7ba355b8d4ac..7e44fdd03e2d 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -371,7 +371,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
371 * having d_mountpoint() true, so there's no need to call back 371 * having d_mountpoint() true, so there's no need to call back
372 * to the daemon. 372 * to the daemon.
373 */ 373 */
374 if (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)) { 374 if (dentry->d_inode && d_is_symlink(dentry)) {
375 spin_unlock(&sbi->fs_lock); 375 spin_unlock(&sbi->fs_lock);
376 goto done; 376 goto done;
377 } 377 }
@@ -485,7 +485,7 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk)
485 * an incorrect ELOOP error return. 485 * an incorrect ELOOP error return.
486 */ 486 */
487 if ((!d_mountpoint(dentry) && !simple_empty(dentry)) || 487 if ((!d_mountpoint(dentry) && !simple_empty(dentry)) ||
488 (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode))) 488 (dentry->d_inode && d_is_symlink(dentry)))
489 status = -EISDIR; 489 status = -EISDIR;
490 } 490 }
491 spin_unlock(&sbi->fs_lock); 491 spin_unlock(&sbi->fs_lock);
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index d49fe8a0f6b5..74609b931ba5 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -776,11 +776,11 @@ static int btrfs_may_delete(struct inode *dir, struct dentry *victim, int isdir)
776 IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode)) 776 IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
777 return -EPERM; 777 return -EPERM;
778 if (isdir) { 778 if (isdir) {
779 if (!S_ISDIR(victim->d_inode->i_mode)) 779 if (!d_is_dir(victim))
780 return -ENOTDIR; 780 return -ENOTDIR;
781 if (IS_ROOT(victim)) 781 if (IS_ROOT(victim))
782 return -EBUSY; 782 return -EBUSY;
783 } else if (S_ISDIR(victim->d_inode->i_mode)) 783 } else if (d_is_dir(victim))
784 return -EISDIR; 784 return -EISDIR;
785 if (IS_DEADDIR(dir)) 785 if (IS_DEADDIR(dir))
786 return -ENOENT; 786 return -ENOENT;
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index ce1b115dcc28..d92840209863 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -574,7 +574,7 @@ static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args)
574 /* extract the directory dentry from the cwd */ 574 /* extract the directory dentry from the cwd */
575 get_fs_pwd(current->fs, &path); 575 get_fs_pwd(current->fs, &path);
576 576
577 if (!S_ISDIR(path.dentry->d_inode->i_mode)) 577 if (!d_is_dir(path.dentry))
578 goto notdir; 578 goto notdir;
579 579
580 cachefiles_begin_secure(cache, &saved_cred); 580 cachefiles_begin_secure(cache, &saved_cred);
@@ -646,7 +646,7 @@ static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args)
646 /* extract the directory dentry from the cwd */ 646 /* extract the directory dentry from the cwd */
647 get_fs_pwd(current->fs, &path); 647 get_fs_pwd(current->fs, &path);
648 648
649 if (!S_ISDIR(path.dentry->d_inode->i_mode)) 649 if (!d_is_dir(path.dentry))
650 goto notdir; 650 goto notdir;
651 651
652 cachefiles_begin_secure(cache, &saved_cred); 652 cachefiles_begin_secure(cache, &saved_cred);
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index 7f8e83f9d74e..d750e8cc0ab6 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -277,7 +277,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache,
277 _debug("remove %p from %p", rep, dir); 277 _debug("remove %p from %p", rep, dir);
278 278
279 /* non-directories can just be unlinked */ 279 /* non-directories can just be unlinked */
280 if (!S_ISDIR(rep->d_inode->i_mode)) { 280 if (!d_is_dir(rep)) {
281 _debug("unlink stale object"); 281 _debug("unlink stale object");
282 282
283 path.mnt = cache->mnt; 283 path.mnt = cache->mnt;
@@ -323,7 +323,7 @@ try_again:
323 return 0; 323 return 0;
324 } 324 }
325 325
326 if (!S_ISDIR(cache->graveyard->d_inode->i_mode)) { 326 if (!d_is_dir(cache->graveyard)) {
327 unlock_rename(cache->graveyard, dir); 327 unlock_rename(cache->graveyard, dir);
328 cachefiles_io_error(cache, "Graveyard no longer a directory"); 328 cachefiles_io_error(cache, "Graveyard no longer a directory");
329 return -EIO; 329 return -EIO;
@@ -475,7 +475,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent,
475 ASSERT(parent->dentry); 475 ASSERT(parent->dentry);
476 ASSERT(parent->dentry->d_inode); 476 ASSERT(parent->dentry->d_inode);
477 477
478 if (!(S_ISDIR(parent->dentry->d_inode->i_mode))) { 478 if (!(d_is_dir(parent->dentry))) {
479 // TODO: convert file to dir 479 // TODO: convert file to dir
480 _leave("looking up in none directory"); 480 _leave("looking up in none directory");
481 return -ENOBUFS; 481 return -ENOBUFS;
@@ -539,7 +539,7 @@ lookup_again:
539 _debug("mkdir -> %p{%p{ino=%lu}}", 539 _debug("mkdir -> %p{%p{ino=%lu}}",
540 next, next->d_inode, next->d_inode->i_ino); 540 next, next->d_inode, next->d_inode->i_ino);
541 541
542 } else if (!S_ISDIR(next->d_inode->i_mode)) { 542 } else if (!d_is_dir(next)) {
543 pr_err("inode %lu is not a directory\n", 543 pr_err("inode %lu is not a directory\n",
544 next->d_inode->i_ino); 544 next->d_inode->i_ino);
545 ret = -ENOBUFS; 545 ret = -ENOBUFS;
@@ -568,8 +568,8 @@ lookup_again:
568 _debug("create -> %p{%p{ino=%lu}}", 568 _debug("create -> %p{%p{ino=%lu}}",
569 next, next->d_inode, next->d_inode->i_ino); 569 next, next->d_inode, next->d_inode->i_ino);
570 570
571 } else if (!S_ISDIR(next->d_inode->i_mode) && 571 } else if (!d_is_dir(next) &&
572 !S_ISREG(next->d_inode->i_mode) 572 !d_is_reg(next)
573 ) { 573 ) {
574 pr_err("inode %lu is not a file or directory\n", 574 pr_err("inode %lu is not a file or directory\n",
575 next->d_inode->i_ino); 575 next->d_inode->i_ino);
@@ -642,7 +642,7 @@ lookup_again:
642 642
643 /* open a file interface onto a data file */ 643 /* open a file interface onto a data file */
644 if (object->type != FSCACHE_COOKIE_TYPE_INDEX) { 644 if (object->type != FSCACHE_COOKIE_TYPE_INDEX) {
645 if (S_ISREG(object->dentry->d_inode->i_mode)) { 645 if (d_is_reg(object->dentry)) {
646 const struct address_space_operations *aops; 646 const struct address_space_operations *aops;
647 647
648 ret = -EPERM; 648 ret = -EPERM;
@@ -763,7 +763,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
763 /* we need to make sure the subdir is a directory */ 763 /* we need to make sure the subdir is a directory */
764 ASSERT(subdir->d_inode); 764 ASSERT(subdir->d_inode);
765 765
766 if (!S_ISDIR(subdir->d_inode->i_mode)) { 766 if (!d_is_dir(subdir)) {
767 pr_err("%s is not a directory\n", dirname); 767 pr_err("%s is not a directory\n", dirname);
768 ret = -EIO; 768 ret = -EIO;
769 goto check_error; 769 goto check_error;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index c241603764fd..f099aefb0d19 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -902,7 +902,7 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry)
902 } else if (ceph_snap(dir) == CEPH_NOSNAP) { 902 } else if (ceph_snap(dir) == CEPH_NOSNAP) {
903 dout("unlink/rmdir dir %p dn %p inode %p\n", 903 dout("unlink/rmdir dir %p dn %p inode %p\n",
904 dir, dentry, inode); 904 dir, dentry, inode);
905 op = S_ISDIR(dentry->d_inode->i_mode) ? 905 op = d_is_dir(dentry) ?
906 CEPH_MDS_OP_RMDIR : CEPH_MDS_OP_UNLINK; 906 CEPH_MDS_OP_RMDIR : CEPH_MDS_OP_UNLINK;
907 } else 907 } else
908 goto out; 908 goto out;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 905986dd4c3c..851939c666f8 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -292,7 +292,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
292 } 292 }
293 if (err) 293 if (err)
294 goto out_req; 294 goto out_req;
295 if (dn || dentry->d_inode == NULL || S_ISLNK(dentry->d_inode->i_mode)) { 295 if (dn || dentry->d_inode == NULL || d_is_symlink(dentry)) {
296 /* make vfs retry on splice, ENOENT, or symlink */ 296 /* make vfs retry on splice, ENOENT, or symlink */
297 dout("atomic_open finish_no_open on dn %p\n", dn); 297 dout("atomic_open finish_no_open on dn %p\n", dn);
298 err = finish_no_open(file, dn); 298 err = finish_no_open(file, dn);
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 281ee011bb6a..60cb88c1dd2b 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -304,7 +304,7 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
304 (const char *) old_name, (const char *)new_name); 304 (const char *) old_name, (const char *)new_name);
305 if (!error) { 305 if (!error) {
306 if (new_dentry->d_inode) { 306 if (new_dentry->d_inode) {
307 if (S_ISDIR(new_dentry->d_inode->i_mode)) { 307 if (d_is_dir(new_dentry)) {
308 coda_dir_drop_nlink(old_dir); 308 coda_dir_drop_nlink(old_dir);
309 coda_dir_inc_nlink(new_dir); 309 coda_dir_inc_nlink(new_dir);
310 } 310 }
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 45b18a5e225c..90933645298c 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -690,7 +690,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
690 } 690 }
691 d_move(old_dentry, dentry); 691 d_move(old_dentry, dentry);
692 fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name, 692 fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name,
693 S_ISDIR(old_dentry->d_inode->i_mode), 693 d_is_dir(old_dentry),
694 NULL, old_dentry); 694 NULL, old_dentry);
695 fsnotify_oldname_free(old_name); 695 fsnotify_oldname_free(old_name);
696 unlock_rename(new_dir, old_dir); 696 unlock_rename(new_dir, old_dir);
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index 6f4e659f508f..b07731e68c0b 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -230,7 +230,7 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
230 } 230 }
231 ecryptfs_set_file_lower( 231 ecryptfs_set_file_lower(
232 file, ecryptfs_inode_to_private(inode)->lower_file); 232 file, ecryptfs_inode_to_private(inode)->lower_file);
233 if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) { 233 if (d_is_dir(ecryptfs_dentry)) {
234 ecryptfs_printk(KERN_DEBUG, "This is a directory\n"); 234 ecryptfs_printk(KERN_DEBUG, "This is a directory\n");
235 mutex_lock(&crypt_stat->cs_mutex); 235 mutex_lock(&crypt_stat->cs_mutex);
236 crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED); 236 crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 34b36a504059..b08b5187f662 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -907,9 +907,9 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
907 lower_inode = ecryptfs_inode_to_lower(inode); 907 lower_inode = ecryptfs_inode_to_lower(inode);
908 lower_dentry = ecryptfs_dentry_to_lower(dentry); 908 lower_dentry = ecryptfs_dentry_to_lower(dentry);
909 mutex_lock(&crypt_stat->cs_mutex); 909 mutex_lock(&crypt_stat->cs_mutex);
910 if (S_ISDIR(dentry->d_inode->i_mode)) 910 if (d_is_dir(dentry))
911 crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED); 911 crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
912 else if (S_ISREG(dentry->d_inode->i_mode) 912 else if (d_is_reg(dentry)
913 && (!(crypt_stat->flags & ECRYPTFS_POLICY_APPLIED) 913 && (!(crypt_stat->flags & ECRYPTFS_POLICY_APPLIED)
914 || !(crypt_stat->flags & ECRYPTFS_KEY_VALID))) { 914 || !(crypt_stat->flags & ECRYPTFS_KEY_VALID))) {
915 struct ecryptfs_mount_crypt_stat *mount_crypt_stat; 915 struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index fdfd206c737a..714cd37a6ba3 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -429,7 +429,7 @@ struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
429 if (IS_ERR(result)) 429 if (IS_ERR(result))
430 return result; 430 return result;
431 431
432 if (S_ISDIR(result->d_inode->i_mode)) { 432 if (d_is_dir(result)) {
433 /* 433 /*
434 * This request is for a directory. 434 * This request is for a directory.
435 * 435 *
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 08e7b1a9d5d0..1545b711ddcf 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -971,7 +971,7 @@ int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
971 err = -EBUSY; 971 err = -EBUSY;
972 goto badentry; 972 goto badentry;
973 } 973 }
974 if (S_ISDIR(entry->d_inode->i_mode)) { 974 if (d_is_dir(entry)) {
975 shrink_dcache_parent(entry); 975 shrink_dcache_parent(entry);
976 if (!simple_empty(entry)) { 976 if (!simple_empty(entry)) {
977 err = -ENOTEMPTY; 977 err = -ENOTEMPTY;
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 6371192961e2..487527b42d94 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -1809,7 +1809,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
1809 gfs2_consist_inode(dip); 1809 gfs2_consist_inode(dip);
1810 dip->i_entries--; 1810 dip->i_entries--;
1811 dip->i_inode.i_mtime = dip->i_inode.i_ctime = tv; 1811 dip->i_inode.i_mtime = dip->i_inode.i_ctime = tv;
1812 if (S_ISDIR(dentry->d_inode->i_mode)) 1812 if (d_is_dir(dentry))
1813 drop_nlink(&dip->i_inode); 1813 drop_nlink(&dip->i_inode);
1814 mark_inode_dirty(&dip->i_inode); 1814 mark_inode_dirty(&dip->i_inode);
1815 1815
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 435bea231cc6..f0235c1640af 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -530,7 +530,7 @@ static int hfsplus_rename(struct inode *old_dir, struct dentry *old_dentry,
530 530
531 /* Unlink destination if it already exists */ 531 /* Unlink destination if it already exists */
532 if (new_dentry->d_inode) { 532 if (new_dentry->d_inode) {
533 if (S_ISDIR(new_dentry->d_inode->i_mode)) 533 if (d_is_dir(new_dentry))
534 res = hfsplus_rmdir(new_dir, new_dentry); 534 res = hfsplus_rmdir(new_dir, new_dentry);
535 else 535 else
536 res = hfsplus_unlink(new_dir, new_dentry); 536 res = hfsplus_unlink(new_dir, new_dentry);
diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c
index 5f2755117ce7..043ac9d77262 100644
--- a/fs/hppfs/hppfs.c
+++ b/fs/hppfs/hppfs.c
@@ -678,10 +678,10 @@ static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
678 return NULL; 678 return NULL;
679 } 679 }
680 680
681 if (S_ISDIR(dentry->d_inode->i_mode)) { 681 if (d_is_dir(dentry)) {
682 inode->i_op = &hppfs_dir_iops; 682 inode->i_op = &hppfs_dir_iops;
683 inode->i_fop = &hppfs_dir_fops; 683 inode->i_fop = &hppfs_dir_fops;
684 } else if (S_ISLNK(dentry->d_inode->i_mode)) { 684 } else if (d_is_symlink(dentry)) {
685 inode->i_op = &hppfs_link_iops; 685 inode->i_op = &hppfs_link_iops;
686 inode->i_fop = &hppfs_file_fops; 686 inode->i_fop = &hppfs_file_fops;
687 } else { 687 } else {
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 938556025d64..f21b6fb5e4c4 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -252,7 +252,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de
252 if (!f->inocache) 252 if (!f->inocache)
253 return -EIO; 253 return -EIO;
254 254
255 if (S_ISDIR(old_dentry->d_inode->i_mode)) 255 if (d_is_dir(old_dentry))
256 return -EPERM; 256 return -EPERM;
257 257
258 /* XXX: This is ugly */ 258 /* XXX: This is ugly */
@@ -772,7 +772,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
772 */ 772 */
773 if (new_dentry->d_inode) { 773 if (new_dentry->d_inode) {
774 victim_f = JFFS2_INODE_INFO(new_dentry->d_inode); 774 victim_f = JFFS2_INODE_INFO(new_dentry->d_inode);
775 if (S_ISDIR(new_dentry->d_inode->i_mode)) { 775 if (d_is_dir(new_dentry)) {
776 struct jffs2_full_dirent *fd; 776 struct jffs2_full_dirent *fd;
777 777
778 mutex_lock(&victim_f->sem); 778 mutex_lock(&victim_f->sem);
@@ -807,7 +807,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
807 807
808 if (victim_f) { 808 if (victim_f) {
809 /* There was a victim. Kill it off nicely */ 809 /* There was a victim. Kill it off nicely */
810 if (S_ISDIR(new_dentry->d_inode->i_mode)) 810 if (d_is_dir(new_dentry))
811 clear_nlink(new_dentry->d_inode); 811 clear_nlink(new_dentry->d_inode);
812 else 812 else
813 drop_nlink(new_dentry->d_inode); 813 drop_nlink(new_dentry->d_inode);
@@ -815,7 +815,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
815 inode which didn't exist. */ 815 inode which didn't exist. */
816 if (victim_f->inocache) { 816 if (victim_f->inocache) {
817 mutex_lock(&victim_f->sem); 817 mutex_lock(&victim_f->sem);
818 if (S_ISDIR(new_dentry->d_inode->i_mode)) 818 if (d_is_dir(new_dentry))
819 victim_f->inocache->pino_nlink = 0; 819 victim_f->inocache->pino_nlink = 0;
820 else 820 else
821 victim_f->inocache->pino_nlink--; 821 victim_f->inocache->pino_nlink--;
@@ -825,7 +825,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
825 825
826 /* If it was a directory we moved, and there was no victim, 826 /* If it was a directory we moved, and there was no victim,
827 increase i_nlink on its new parent */ 827 increase i_nlink on its new parent */
828 if (S_ISDIR(old_dentry->d_inode->i_mode) && !victim_f) 828 if (d_is_dir(old_dentry) && !victim_f)
829 inc_nlink(new_dir_i); 829 inc_nlink(new_dir_i);
830 830
831 /* Unlink the original */ 831 /* Unlink the original */
@@ -839,7 +839,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
839 struct jffs2_inode_info *f = JFFS2_INODE_INFO(old_dentry->d_inode); 839 struct jffs2_inode_info *f = JFFS2_INODE_INFO(old_dentry->d_inode);
840 mutex_lock(&f->sem); 840 mutex_lock(&f->sem);
841 inc_nlink(old_dentry->d_inode); 841 inc_nlink(old_dentry->d_inode);
842 if (f->inocache && !S_ISDIR(old_dentry->d_inode->i_mode)) 842 if (f->inocache && !d_is_dir(old_dentry))
843 f->inocache->pino_nlink++; 843 f->inocache->pino_nlink++;
844 mutex_unlock(&f->sem); 844 mutex_unlock(&f->sem);
845 845
@@ -852,7 +852,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
852 return ret; 852 return ret;
853 } 853 }
854 854
855 if (S_ISDIR(old_dentry->d_inode->i_mode)) 855 if (d_is_dir(old_dentry))
856 drop_nlink(old_dir_i); 856 drop_nlink(old_dir_i);
857 857
858 new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = ITIME(now); 858 new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = ITIME(now);
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 0918f0e2e266..3d76f28a2ba9 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -138,7 +138,7 @@ static struct dentry *jffs2_get_parent(struct dentry *child)
138 struct jffs2_inode_info *f; 138 struct jffs2_inode_info *f;
139 uint32_t pino; 139 uint32_t pino;
140 140
141 BUG_ON(!S_ISDIR(child->d_inode->i_mode)); 141 BUG_ON(!d_is_dir(child));
142 142
143 f = JFFS2_INODE_INFO(child->d_inode); 143 f = JFFS2_INODE_INFO(child->d_inode);
144 144
diff --git a/fs/libfs.c b/fs/libfs.c
index b2ffdb045be4..0ab65122ee45 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -329,7 +329,7 @@ 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 = old_dentry->d_inode;
332 int they_are_dirs = S_ISDIR(old_dentry->d_inode->i_mode); 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;
diff --git a/fs/namei.c b/fs/namei.c
index 96ca11dea4a2..c83145af4bfc 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2814,7 +2814,7 @@ no_open:
2814 } else if (!dentry->d_inode) { 2814 } else if (!dentry->d_inode) {
2815 goto out; 2815 goto out;
2816 } else if ((open_flag & O_TRUNC) && 2816 } else if ((open_flag & O_TRUNC) &&
2817 S_ISREG(dentry->d_inode->i_mode)) { 2817 d_is_reg(dentry)) {
2818 goto out; 2818 goto out;
2819 } 2819 }
2820 /* will fail later, go on to get the right error */ 2820 /* will fail later, go on to get the right error */
diff --git a/fs/namespace.c b/fs/namespace.c
index 72a286e0d33e..82ef1405260e 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1907,8 +1907,8 @@ static int graft_tree(struct mount *mnt, struct mount *p, struct mountpoint *mp)
1907 if (mnt->mnt.mnt_sb->s_flags & MS_NOUSER) 1907 if (mnt->mnt.mnt_sb->s_flags & MS_NOUSER)
1908 return -EINVAL; 1908 return -EINVAL;
1909 1909
1910 if (S_ISDIR(mp->m_dentry->d_inode->i_mode) != 1910 if (d_is_dir(mp->m_dentry) !=
1911 S_ISDIR(mnt->mnt.mnt_root->d_inode->i_mode)) 1911 d_is_dir(mnt->mnt.mnt_root))
1912 return -ENOTDIR; 1912 return -ENOTDIR;
1913 1913
1914 return attach_recursive_mnt(mnt, p, mp, NULL); 1914 return attach_recursive_mnt(mnt, p, mp, NULL);
@@ -2180,8 +2180,8 @@ static int do_move_mount(struct path *path, const char *old_name)
2180 if (!mnt_has_parent(old)) 2180 if (!mnt_has_parent(old))
2181 goto out1; 2181 goto out1;
2182 2182
2183 if (S_ISDIR(path->dentry->d_inode->i_mode) != 2183 if (d_is_dir(path->dentry) !=
2184 S_ISDIR(old_path.dentry->d_inode->i_mode)) 2184 d_is_dir(old_path.dentry))
2185 goto out1; 2185 goto out1;
2186 /* 2186 /*
2187 * Don't move a mount residing in a shared parent. 2187 * Don't move a mount residing in a shared parent.
@@ -2271,7 +2271,7 @@ static int do_add_mount(struct mount *newmnt, struct path *path, int mnt_flags)
2271 goto unlock; 2271 goto unlock;
2272 2272
2273 err = -EINVAL; 2273 err = -EINVAL;
2274 if (S_ISLNK(newmnt->mnt.mnt_root->d_inode->i_mode)) 2274 if (d_is_symlink(newmnt->mnt.mnt_root))
2275 goto unlock; 2275 goto unlock;
2276 2276
2277 newmnt->mnt.mnt_flags = mnt_flags; 2277 newmnt->mnt.mnt_flags = mnt_flags;
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index cc6a76072009..1c307f02baa8 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -583,7 +583,7 @@ nfs4_reset_recoverydir(char *recdir)
583 if (status) 583 if (status)
584 return status; 584 return status;
585 status = -ENOTDIR; 585 status = -ENOTDIR;
586 if (S_ISDIR(path.dentry->d_inode->i_mode)) { 586 if (d_is_dir(path.dentry)) {
587 strcpy(user_recovery_dirname, recdir); 587 strcpy(user_recovery_dirname, recdir);
588 status = 0; 588 status = 0;
589 } 589 }
@@ -1426,7 +1426,7 @@ nfsd4_client_tracking_init(struct net *net)
1426 nn->client_tracking_ops = &nfsd4_legacy_tracking_ops; 1426 nn->client_tracking_ops = &nfsd4_legacy_tracking_ops;
1427 status = kern_path(nfs4_recoverydir(), LOOKUP_FOLLOW, &path); 1427 status = kern_path(nfs4_recoverydir(), LOOKUP_FOLLOW, &path);
1428 if (!status) { 1428 if (!status) {
1429 status = S_ISDIR(path.dentry->d_inode->i_mode); 1429 status = d_is_dir(path.dentry);
1430 path_put(&path); 1430 path_put(&path);
1431 if (status) 1431 if (status)
1432 goto do_init; 1432 goto do_init;
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index 965b478d50fc..e9fa966fc37f 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -114,8 +114,8 @@ static inline __be32 check_pseudo_root(struct svc_rqst *rqstp,
114 * We're exposing only the directories and symlinks that have to be 114 * We're exposing only the directories and symlinks that have to be
115 * traversed on the way to real exports: 115 * traversed on the way to real exports:
116 */ 116 */
117 if (unlikely(!S_ISDIR(dentry->d_inode->i_mode) && 117 if (unlikely(!d_is_dir(dentry) &&
118 !S_ISLNK(dentry->d_inode->i_mode))) 118 !d_is_symlink(dentry)))
119 return nfserr_stale; 119 return nfserr_stale;
120 /* 120 /*
121 * A pseudoroot export gives permission to access only one 121 * A pseudoroot export gives permission to access only one
@@ -259,7 +259,7 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
259 goto out; 259 goto out;
260 } 260 }
261 261
262 if (S_ISDIR(dentry->d_inode->i_mode) && 262 if (d_is_dir(dentry) &&
263 (dentry->d_flags & DCACHE_DISCONNECTED)) { 263 (dentry->d_flags & DCACHE_DISCONNECTED)) {
264 printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %pd2\n", 264 printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %pd2\n",
265 dentry); 265 dentry);
@@ -414,7 +414,7 @@ static inline void _fh_update_old(struct dentry *dentry,
414{ 414{
415 fh->ofh_ino = ino_t_to_u32(dentry->d_inode->i_ino); 415 fh->ofh_ino = ino_t_to_u32(dentry->d_inode->i_ino);
416 fh->ofh_generation = dentry->d_inode->i_generation; 416 fh->ofh_generation = dentry->d_inode->i_generation;
417 if (S_ISDIR(dentry->d_inode->i_mode) || 417 if (d_is_dir(dentry) ||
418 (exp->ex_flags & NFSEXP_NOSUBTREECHECK)) 418 (exp->ex_flags & NFSEXP_NOSUBTREECHECK))
419 fh->ofh_dirino = 0; 419 fh->ofh_dirino = 0;
420} 420}
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 5685c679dd93..368526582429 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -615,9 +615,9 @@ nfsd_access(struct svc_rqst *rqstp, struct svc_fh *fhp, u32 *access, u32 *suppor
615 export = fhp->fh_export; 615 export = fhp->fh_export;
616 dentry = fhp->fh_dentry; 616 dentry = fhp->fh_dentry;
617 617
618 if (S_ISREG(dentry->d_inode->i_mode)) 618 if (d_is_reg(dentry))
619 map = nfs3_regaccess; 619 map = nfs3_regaccess;
620 else if (S_ISDIR(dentry->d_inode->i_mode)) 620 else if (d_is_dir(dentry))
621 map = nfs3_diraccess; 621 map = nfs3_diraccess;
622 else 622 else
623 map = nfs3_anyaccess; 623 map = nfs3_anyaccess;
@@ -1402,7 +1402,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
1402 1402
1403 switch (createmode) { 1403 switch (createmode) {
1404 case NFS3_CREATE_UNCHECKED: 1404 case NFS3_CREATE_UNCHECKED:
1405 if (! S_ISREG(dchild->d_inode->i_mode)) 1405 if (! d_is_reg(dchild))
1406 goto out; 1406 goto out;
1407 else if (truncp) { 1407 else if (truncp) {
1408 /* in nfsv4, we need to treat this case a little 1408 /* in nfsv4, we need to treat this case a little
@@ -1615,7 +1615,7 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
1615 if (err) 1615 if (err)
1616 goto out; 1616 goto out;
1617 err = nfserr_isdir; 1617 err = nfserr_isdir;
1618 if (S_ISDIR(tfhp->fh_dentry->d_inode->i_mode)) 1618 if (d_is_dir(tfhp->fh_dentry))
1619 goto out; 1619 goto out;
1620 err = nfserr_perm; 1620 err = nfserr_perm;
1621 if (!len) 1621 if (!len)
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index 51ceb8107284..61fdbb826324 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -115,8 +115,8 @@ static bool fanotify_should_send_event(struct fsnotify_mark *inode_mark,
115 return false; 115 return false;
116 116
117 /* sorry, fanotify only gives a damn about files and dirs */ 117 /* sorry, fanotify only gives a damn about files and dirs */
118 if (!S_ISREG(path->dentry->d_inode->i_mode) && 118 if (!d_is_reg(path->dentry) &&
119 !S_ISDIR(path->dentry->d_inode->i_mode)) 119 !d_is_dir(path->dentry))
120 return false; 120 return false;
121 121
122 if (inode_mark && vfsmnt_mark) { 122 if (inode_mark && vfsmnt_mark) {
@@ -139,7 +139,7 @@ static bool fanotify_should_send_event(struct fsnotify_mark *inode_mark,
139 BUG(); 139 BUG();
140 } 140 }
141 141
142 if (S_ISDIR(path->dentry->d_inode->i_mode) && 142 if (d_is_dir(path->dentry) &&
143 !(marks_mask & FS_ISDIR & ~marks_ignored_mask)) 143 !(marks_mask & FS_ISDIR & ~marks_ignored_mask))
144 return false; 144 return false;
145 145
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 0dc4c33a0a1b..d139405d2bfa 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -19,7 +19,7 @@ void ovl_cleanup(struct inode *wdir, struct dentry *wdentry)
19 int err; 19 int err;
20 20
21 dget(wdentry); 21 dget(wdentry);
22 if (S_ISDIR(wdentry->d_inode->i_mode)) 22 if (d_is_dir(wdentry))
23 err = ovl_do_rmdir(wdir, wdentry); 23 err = ovl_do_rmdir(wdir, wdentry);
24 else 24 else
25 err = ovl_do_unlink(wdir, wdentry); 25 err = ovl_do_unlink(wdir, wdentry);
@@ -693,7 +693,7 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old,
693 bool new_create = false; 693 bool new_create = false;
694 bool cleanup_whiteout = false; 694 bool cleanup_whiteout = false;
695 bool overwrite = !(flags & RENAME_EXCHANGE); 695 bool overwrite = !(flags & RENAME_EXCHANGE);
696 bool is_dir = S_ISDIR(old->d_inode->i_mode); 696 bool is_dir = d_is_dir(old);
697 bool new_is_dir = false; 697 bool new_is_dir = false;
698 struct dentry *opaquedir = NULL; 698 struct dentry *opaquedir = NULL;
699 const struct cred *old_cred = NULL; 699 const struct cred *old_cred = NULL;
@@ -720,7 +720,7 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old,
720 if (err) 720 if (err)
721 goto out; 721 goto out;
722 722
723 if (S_ISDIR(new->d_inode->i_mode)) 723 if (d_is_dir(new))
724 new_is_dir = true; 724 new_is_dir = true;
725 725
726 new_type = ovl_path_type(new); 726 new_type = ovl_path_type(new);
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 515d31511d0d..3a48bb789c9f 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -776,7 +776,7 @@ posix_acl_xattr_get(struct dentry *dentry, const char *name,
776 776
777 if (!IS_POSIXACL(dentry->d_inode)) 777 if (!IS_POSIXACL(dentry->d_inode))
778 return -EOPNOTSUPP; 778 return -EOPNOTSUPP;
779 if (S_ISLNK(dentry->d_inode->i_mode)) 779 if (d_is_symlink(dentry))
780 return -EOPNOTSUPP; 780 return -EOPNOTSUPP;
781 781
782 acl = get_acl(dentry->d_inode, type); 782 acl = get_acl(dentry->d_inode, type);
@@ -836,7 +836,7 @@ posix_acl_xattr_list(struct dentry *dentry, char *list, size_t list_size,
836 836
837 if (!IS_POSIXACL(dentry->d_inode)) 837 if (!IS_POSIXACL(dentry->d_inode))
838 return -EOPNOTSUPP; 838 return -EOPNOTSUPP;
839 if (S_ISLNK(dentry->d_inode->i_mode)) 839 if (d_is_symlink(dentry))
840 return -EOPNOTSUPP; 840 return -EOPNOTSUPP;
841 841
842 if (type == ACL_TYPE_ACCESS) 842 if (type == ACL_TYPE_ACCESS)
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 04b06146bae2..4e781e697c90 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -266,7 +266,7 @@ static int reiserfs_for_each_xattr(struct inode *inode,
266 for (i = 0; !err && i < buf.count && buf.dentries[i]; i++) { 266 for (i = 0; !err && i < buf.count && buf.dentries[i]; i++) {
267 struct dentry *dentry = buf.dentries[i]; 267 struct dentry *dentry = buf.dentries[i];
268 268
269 if (!S_ISDIR(dentry->d_inode->i_mode)) 269 if (!d_is_dir(dentry))
270 err = action(dentry, data); 270 err = action(dentry, data);
271 271
272 dput(dentry); 272 dput(dentry);
@@ -322,7 +322,7 @@ static int delete_one_xattr(struct dentry *dentry, void *data)
322 struct inode *dir = dentry->d_parent->d_inode; 322 struct inode *dir = dentry->d_parent->d_inode;
323 323
324 /* This is the xattr dir, handle specially. */ 324 /* This is the xattr dir, handle specially. */
325 if (S_ISDIR(dentry->d_inode->i_mode)) 325 if (d_is_dir(dentry))
326 return xattr_rmdir(dir, dentry); 326 return xattr_rmdir(dir, dentry);
327 327
328 return xattr_unlink(dir, dentry); 328 return xattr_unlink(dir, dentry);
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index f7afb86c9148..fe3c0fe71e64 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -286,7 +286,7 @@ xfs_readlink_by_handle(
286 return PTR_ERR(dentry); 286 return PTR_ERR(dentry);
287 287
288 /* Restrict this handle operation to symlinks only. */ 288 /* Restrict this handle operation to symlinks only. */
289 if (!S_ISLNK(dentry->d_inode->i_mode)) { 289 if (!d_is_symlink(dentry)) {
290 error = -EINVAL; 290 error = -EINVAL;
291 goto out_dput; 291 goto out_dput;
292 } 292 }