Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Change inode_operations.mkdir to return struct dentry *

Some filesystems, such as NFS, cifs, ceph, and fuse, do not have
complete control of sequencing on the actual filesystem (e.g. on a
different server) and may find that the inode created for a mkdir
request already exists in the icache and dcache by the time the mkdir
request returns. For example, if the filesystem is mounted twice the
directory could be visible on the other mount before it is on the
original mount, and a pair of name_to_handle_at(), open_by_handle_at()
calls could instantiate the directory inode with an IS_ROOT() dentry
before the first mkdir returns.

This means that the dentry passed to ->mkdir() may not be the one that
is associated with the inode after the ->mkdir() completes. Some
callers need to interact with the inode after the ->mkdir completes and
they currently need to perform a lookup in the (rare) case that the
dentry is no longer hashed.

This lookup-after-mkdir requires that the directory remains locked to
avoid races. Planned future patches to lock the dentry rather than the
directory will mean that this lookup cannot be performed atomically with
the mkdir.

To remove this barrier, this patch changes ->mkdir to return the
resulting dentry if it is different from the one passed in.
Possible returns are:
NULL - the directory was created and no other dentry was used
ERR_PTR() - an error occurred
non-NULL - this other dentry was spliced in

This patch only changes file-systems to return "ERR_PTR(err)" instead of
"err" or equivalent transformations. Subsequent patches will make
further changes to some file-systems to return a correct dentry.

Not all filesystems reliably result in a positive hashed dentry:

- NFS, cifs, hostfs will sometimes need to perform a lookup of
the name to get inode information. Races could result in this
returning something different. Note that this lookup is
non-atomic which is what we are trying to avoid. Placing the
lookup in filesystem code means it only happens when the filesystem
has no other option.
- kernfs and tracefs leave the dentry negative and the ->revalidate
operation ensures that lookup will be called to correctly populate
the dentry. This could be fixed but I don't think it is important
to any of the users of vfs_mkdir() which look at the dentry.

The recommendation to use
d_drop();d_splice_alias()
is ugly but fits with current practice. A planned future patch will
change this.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: NeilBrown <neilb@suse.de>
Link: https://lore.kernel.org/r/20250227013949.536172-2-neilb@suse.de
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

NeilBrown and committed by
Christian Brauner
88d5baf6 71628584

+274 -225
+1 -1
Documentation/filesystems/locking.rst
··· 66 66 int (*link) (struct dentry *,struct inode *,struct dentry *); 67 67 int (*unlink) (struct inode *,struct dentry *); 68 68 int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *); 69 - int (*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t); 69 + struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t); 70 70 int (*rmdir) (struct inode *,struct dentry *); 71 71 int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t); 72 72 int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
+19
Documentation/filesystems/porting.rst
··· 1178 1178 1179 1179 LOOKUP_EXCL now means "target must not exist". It can be combined with 1180 1180 LOOK_CREATE or LOOKUP_RENAME_TARGET. 1181 + 1182 + --- 1183 + 1184 + ** mandatory** 1185 + 1186 + ->mkdir() now returns a 'struct dentry *'. If the created inode is 1187 + found to already be in cache and have a dentry (often IS_ROOT()), it will 1188 + need to be spliced into the given name in place of the given dentry. 1189 + That dentry now needs to be returned. If the original dentry is used, 1190 + NULL should be returned. Any error should be returned with 1191 + ERR_PTR(). 1192 + 1193 + In general, filesystems which use d_instantiate_new() to install the new 1194 + inode can safely return NULL. Filesystems which may not have an I_NEW inode 1195 + should use d_drop();d_splice_alias() and return the result of the latter. 1196 + 1197 + If a positive dentry cannot be returned for some reason, in-kernel 1198 + clients such as cachefiles, nfsd, smb/server may not perform ideally but 1199 + will fail-safe.
+21 -2
Documentation/filesystems/vfs.rst
··· 495 495 int (*link) (struct dentry *,struct inode *,struct dentry *); 496 496 int (*unlink) (struct inode *,struct dentry *); 497 497 int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *); 498 - int (*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t); 498 + struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t); 499 499 int (*rmdir) (struct inode *,struct dentry *); 500 500 int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t); 501 501 int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *, ··· 562 562 ``mkdir`` 563 563 called by the mkdir(2) system call. Only required if you want 564 564 to support creating subdirectories. You will probably need to 565 - call d_instantiate() just as you would in the create() method 565 + call d_instantiate_new() just as you would in the create() method. 566 + 567 + If d_instantiate_new() is not used and if the fh_to_dentry() 568 + export operation is provided, or if the storage might be 569 + accessible by another path (e.g. with a network filesystem) 570 + then more care may be needed. Importantly d_instantate() 571 + should not be used with an inode that is no longer I_NEW if there 572 + any chance that the inode could already be attached to a dentry. 573 + This is because of a hard rule in the VFS that a directory must 574 + only ever have one dentry. 575 + 576 + For example, if an NFS filesystem is mounted twice the new directory 577 + could be visible on the other mount before it is on the original 578 + mount, and a pair of name_to_handle_at(), open_by_handle_at() 579 + calls could instantiate the directory inode with an IS_ROOT() 580 + dentry before the first mkdir returns. 581 + 582 + If there is any chance this could happen, then the new inode 583 + should be d_drop()ed and attached with d_splice_alias(). The 584 + returned dentry (if any) should be returned by ->mkdir(). 566 585 567 586 ``rmdir`` 568 587 called by the rmdir(2) system call. Only required if you want
+3 -4
fs/9p/vfs_inode.c
··· 669 669 * 670 670 */ 671 671 672 - static int v9fs_vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 673 - struct dentry *dentry, umode_t mode) 672 + static struct dentry *v9fs_vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 673 + struct dentry *dentry, umode_t mode) 674 674 { 675 675 int err; 676 676 u32 perm; ··· 692 692 693 693 if (fid) 694 694 p9_fid_put(fid); 695 - 696 - return err; 695 + return ERR_PTR(err); 697 696 } 698 697 699 698 /**
+4 -4
fs/9p/vfs_inode_dotl.c
··· 350 350 * 351 351 */ 352 352 353 - static int v9fs_vfs_mkdir_dotl(struct mnt_idmap *idmap, 354 - struct inode *dir, struct dentry *dentry, 355 - umode_t omode) 353 + static struct dentry *v9fs_vfs_mkdir_dotl(struct mnt_idmap *idmap, 354 + struct inode *dir, struct dentry *dentry, 355 + umode_t omode) 356 356 { 357 357 int err; 358 358 struct v9fs_session_info *v9ses; ··· 417 417 p9_fid_put(fid); 418 418 v9fs_put_acl(dacl, pacl); 419 419 p9_fid_put(dfid); 420 - return err; 420 + return ERR_PTR(err); 421 421 } 422 422 423 423 static int
+1 -1
fs/affs/affs.h
··· 168 168 extern int affs_unlink(struct inode *dir, struct dentry *dentry); 169 169 extern int affs_create(struct mnt_idmap *idmap, struct inode *dir, 170 170 struct dentry *dentry, umode_t mode, bool); 171 - extern int affs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 171 + extern struct dentry *affs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 172 172 struct dentry *dentry, umode_t mode); 173 173 extern int affs_rmdir(struct inode *dir, struct dentry *dentry); 174 174 extern int affs_link(struct dentry *olddentry, struct inode *dir,
+4 -4
fs/affs/namei.c
··· 273 273 return 0; 274 274 } 275 275 276 - int 276 + struct dentry * 277 277 affs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 278 278 struct dentry *dentry, umode_t mode) 279 279 { ··· 285 285 286 286 inode = affs_new_inode(dir); 287 287 if (!inode) 288 - return -ENOSPC; 288 + return ERR_PTR(-ENOSPC); 289 289 290 290 inode->i_mode = S_IFDIR | mode; 291 291 affs_mode_to_prot(inode); ··· 298 298 clear_nlink(inode); 299 299 mark_inode_dirty(inode); 300 300 iput(inode); 301 - return error; 301 + return ERR_PTR(error); 302 302 } 303 - return 0; 303 + return NULL; 304 304 } 305 305 306 306 int
+6 -6
fs/afs/dir.c
··· 33 33 loff_t fpos, u64 ino, unsigned dtype); 34 34 static int afs_create(struct mnt_idmap *idmap, struct inode *dir, 35 35 struct dentry *dentry, umode_t mode, bool excl); 36 - static int afs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 37 - struct dentry *dentry, umode_t mode); 36 + static struct dentry *afs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 37 + struct dentry *dentry, umode_t mode); 38 38 static int afs_rmdir(struct inode *dir, struct dentry *dentry); 39 39 static int afs_unlink(struct inode *dir, struct dentry *dentry); 40 40 static int afs_link(struct dentry *from, struct inode *dir, ··· 1315 1315 /* 1316 1316 * create a directory on an AFS filesystem 1317 1317 */ 1318 - static int afs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 1319 - struct dentry *dentry, umode_t mode) 1318 + static struct dentry *afs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 1319 + struct dentry *dentry, umode_t mode) 1320 1320 { 1321 1321 struct afs_operation *op; 1322 1322 struct afs_vnode *dvnode = AFS_FS_I(dir); ··· 1328 1328 op = afs_alloc_operation(NULL, dvnode->volume); 1329 1329 if (IS_ERR(op)) { 1330 1330 d_drop(dentry); 1331 - return PTR_ERR(op); 1331 + return ERR_CAST(op); 1332 1332 } 1333 1333 1334 1334 fscache_use_cookie(afs_vnode_cache(dvnode), true); ··· 1344 1344 op->ops = &afs_mkdir_operation; 1345 1345 ret = afs_do_sync_operation(op); 1346 1346 afs_dir_unuse_cookie(dvnode, ret); 1347 - return ret; 1347 + return ERR_PTR(ret); 1348 1348 } 1349 1349 1350 1350 /*
+7 -7
fs/autofs/root.c
··· 15 15 struct dentry *, const char *); 16 16 static int autofs_dir_unlink(struct inode *, struct dentry *); 17 17 static int autofs_dir_rmdir(struct inode *, struct dentry *); 18 - static int autofs_dir_mkdir(struct mnt_idmap *, struct inode *, 19 - struct dentry *, umode_t); 18 + static struct dentry *autofs_dir_mkdir(struct mnt_idmap *, struct inode *, 19 + struct dentry *, umode_t); 20 20 static long autofs_root_ioctl(struct file *, unsigned int, unsigned long); 21 21 #ifdef CONFIG_COMPAT 22 22 static long autofs_root_compat_ioctl(struct file *, ··· 720 720 return 0; 721 721 } 722 722 723 - static int autofs_dir_mkdir(struct mnt_idmap *idmap, 724 - struct inode *dir, struct dentry *dentry, 725 - umode_t mode) 723 + static struct dentry *autofs_dir_mkdir(struct mnt_idmap *idmap, 724 + struct inode *dir, struct dentry *dentry, 725 + umode_t mode) 726 726 { 727 727 struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb); 728 728 struct autofs_info *ino = autofs_dentry_ino(dentry); ··· 739 739 740 740 inode = autofs_get_inode(dir->i_sb, S_IFDIR | mode); 741 741 if (!inode) 742 - return -ENOMEM; 742 + return ERR_PTR(-ENOMEM); 743 743 d_add(dentry, inode); 744 744 745 745 if (sbi->version < 5) ··· 751 751 inc_nlink(dir); 752 752 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); 753 753 754 - return 0; 754 + return NULL; 755 755 } 756 756 757 757 /* Get/set timeout ioctl() operation */
+3 -3
fs/bad_inode.c
··· 58 58 return -EIO; 59 59 } 60 60 61 - static int bad_inode_mkdir(struct mnt_idmap *idmap, struct inode *dir, 62 - struct dentry *dentry, umode_t mode) 61 + static struct dentry *bad_inode_mkdir(struct mnt_idmap *idmap, struct inode *dir, 62 + struct dentry *dentry, umode_t mode) 63 63 { 64 - return -EIO; 64 + return ERR_PTR(-EIO); 65 65 } 66 66 67 67 static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry)
+3 -3
fs/bcachefs/fs.c
··· 858 858 return bch2_err_class(ret); 859 859 } 860 860 861 - static int bch2_mkdir(struct mnt_idmap *idmap, 862 - struct inode *vdir, struct dentry *dentry, umode_t mode) 861 + static struct dentry *bch2_mkdir(struct mnt_idmap *idmap, 862 + struct inode *vdir, struct dentry *dentry, umode_t mode) 863 863 { 864 - return bch2_mknod(idmap, vdir, dentry, mode|S_IFDIR, 0); 864 + return ERR_PTR(bch2_mknod(idmap, vdir, dentry, mode|S_IFDIR, 0)); 865 865 } 866 866 867 867 static int bch2_rename2(struct mnt_idmap *idmap,
+4 -4
fs/btrfs/inode.c
··· 6739 6739 return err; 6740 6740 } 6741 6741 6742 - static int btrfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 6743 - struct dentry *dentry, umode_t mode) 6742 + static struct dentry *btrfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 6743 + struct dentry *dentry, umode_t mode) 6744 6744 { 6745 6745 struct inode *inode; 6746 6746 6747 6747 inode = new_inode(dir->i_sb); 6748 6748 if (!inode) 6749 - return -ENOMEM; 6749 + return ERR_PTR(-ENOMEM); 6750 6750 inode_init_owner(idmap, inode, dir, S_IFDIR | mode); 6751 6751 inode->i_op = &btrfs_dir_inode_operations; 6752 6752 inode->i_fop = &btrfs_dir_file_operations; 6753 - return btrfs_create_common(dir, dentry, inode); 6753 + return ERR_PTR(btrfs_create_common(dir, dentry, inode)); 6754 6754 } 6755 6755 6756 6756 static noinline int uncompress_inline(struct btrfs_path *path,
+4 -4
fs/ceph/dir.c
··· 1092 1092 return err; 1093 1093 } 1094 1094 1095 - static int ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir, 1096 - struct dentry *dentry, umode_t mode) 1095 + static struct dentry *ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir, 1096 + struct dentry *dentry, umode_t mode) 1097 1097 { 1098 1098 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb); 1099 1099 struct ceph_client *cl = mdsc->fsc->client; ··· 1104 1104 1105 1105 err = ceph_wait_on_conflict_unlink(dentry); 1106 1106 if (err) 1107 - return err; 1107 + return ERR_PTR(err); 1108 1108 1109 1109 if (ceph_snap(dir) == CEPH_SNAPDIR) { 1110 1110 /* mkdir .snap/foo is a MKSNAP */ ··· 1173 1173 else 1174 1174 d_drop(dentry); 1175 1175 ceph_release_acl_sec_ctx(&as_ctx); 1176 - return err; 1176 + return ERR_PTR(err); 1177 1177 } 1178 1178 1179 1179 static int ceph_link(struct dentry *old_dentry, struct inode *dir,
+7 -7
fs/coda/dir.c
··· 166 166 return error; 167 167 } 168 168 169 - static int coda_mkdir(struct mnt_idmap *idmap, struct inode *dir, 170 - struct dentry *de, umode_t mode) 169 + static struct dentry *coda_mkdir(struct mnt_idmap *idmap, struct inode *dir, 170 + struct dentry *de, umode_t mode) 171 171 { 172 172 struct inode *inode; 173 173 struct coda_vattr attrs; ··· 177 177 struct CodaFid newfid; 178 178 179 179 if (is_root_inode(dir) && coda_iscontrol(name, len)) 180 - return -EPERM; 180 + return ERR_PTR(-EPERM); 181 181 182 182 attrs.va_mode = mode; 183 - error = venus_mkdir(dir->i_sb, coda_i2f(dir), 183 + error = venus_mkdir(dir->i_sb, coda_i2f(dir), 184 184 name, len, &newfid, &attrs); 185 185 if (error) 186 186 goto err_out; 187 - 187 + 188 188 inode = coda_iget(dir->i_sb, &newfid, &attrs); 189 189 if (IS_ERR(inode)) { 190 190 error = PTR_ERR(inode); ··· 195 195 coda_dir_inc_nlink(dir); 196 196 coda_dir_update_mtime(dir); 197 197 d_instantiate(de, inode); 198 - return 0; 198 + return NULL; 199 199 err_out: 200 200 d_drop(de); 201 - return error; 201 + return ERR_PTR(error); 202 202 } 203 203 204 204 /* try to make de an entry in dir_inodde linked to source_de */
+3 -3
fs/configfs/dir.c
··· 1280 1280 } 1281 1281 EXPORT_SYMBOL(configfs_depend_item_unlocked); 1282 1282 1283 - static int configfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 1284 - struct dentry *dentry, umode_t mode) 1283 + static struct dentry *configfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 1284 + struct dentry *dentry, umode_t mode) 1285 1285 { 1286 1286 int ret = 0; 1287 1287 int module_got = 0; ··· 1461 1461 put_fragment(frag); 1462 1462 1463 1463 out: 1464 - return ret; 1464 + return ERR_PTR(ret); 1465 1465 } 1466 1466 1467 1467 static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
+3 -3
fs/ecryptfs/inode.c
··· 503 503 return rc; 504 504 } 505 505 506 - static int ecryptfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 507 - struct dentry *dentry, umode_t mode) 506 + static struct dentry *ecryptfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 507 + struct dentry *dentry, umode_t mode) 508 508 { 509 509 int rc; 510 510 struct dentry *lower_dentry; ··· 526 526 inode_unlock(lower_dir); 527 527 if (d_really_is_negative(dentry)) 528 528 d_drop(dentry); 529 - return rc; 529 + return ERR_PTR(rc); 530 530 } 531 531 532 532 static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
+4 -4
fs/exfat/namei.c
··· 835 835 return err; 836 836 } 837 837 838 - static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir, 839 - struct dentry *dentry, umode_t mode) 838 + static struct dentry *exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir, 839 + struct dentry *dentry, umode_t mode) 840 840 { 841 841 struct super_block *sb = dir->i_sb; 842 842 struct inode *inode; ··· 846 846 loff_t size = i_size_read(dir); 847 847 848 848 if (unlikely(exfat_forced_shutdown(sb))) 849 - return -EIO; 849 + return ERR_PTR(-EIO); 850 850 851 851 mutex_lock(&EXFAT_SB(sb)->s_lock); 852 852 exfat_set_volume_dirty(sb); ··· 877 877 878 878 unlock: 879 879 mutex_unlock(&EXFAT_SB(sb)->s_lock); 880 - return err; 880 + return ERR_PTR(err); 881 881 } 882 882 883 883 static int exfat_check_dir_empty(struct super_block *sb,
+5 -4
fs/ext2/namei.c
··· 225 225 return err; 226 226 } 227 227 228 - static int ext2_mkdir(struct mnt_idmap * idmap, 229 - struct inode * dir, struct dentry * dentry, umode_t mode) 228 + static struct dentry *ext2_mkdir(struct mnt_idmap * idmap, 229 + struct inode * dir, struct dentry * dentry, 230 + umode_t mode) 230 231 { 231 232 struct inode * inode; 232 233 int err; 233 234 234 235 err = dquot_initialize(dir); 235 236 if (err) 236 - return err; 237 + return ERR_PTR(err); 237 238 238 239 inode_inc_link_count(dir); 239 240 ··· 259 258 260 259 d_instantiate_new(dentry, inode); 261 260 out: 262 - return err; 261 + return ERR_PTR(err); 263 262 264 263 out_fail: 265 264 inode_dec_link_count(inode);
+5 -5
fs/ext4/namei.c
··· 3004 3004 return err; 3005 3005 } 3006 3006 3007 - static int ext4_mkdir(struct mnt_idmap *idmap, struct inode *dir, 3008 - struct dentry *dentry, umode_t mode) 3007 + static struct dentry *ext4_mkdir(struct mnt_idmap *idmap, struct inode *dir, 3008 + struct dentry *dentry, umode_t mode) 3009 3009 { 3010 3010 handle_t *handle; 3011 3011 struct inode *inode; 3012 3012 int err, err2 = 0, credits, retries = 0; 3013 3013 3014 3014 if (EXT4_DIR_LINK_MAX(dir)) 3015 - return -EMLINK; 3015 + return ERR_PTR(-EMLINK); 3016 3016 3017 3017 err = dquot_initialize(dir); 3018 3018 if (err) 3019 - return err; 3019 + return ERR_PTR(err); 3020 3020 3021 3021 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 3022 3022 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3); ··· 3066 3066 out_retry: 3067 3067 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) 3068 3068 goto retry; 3069 - return err; 3069 + return ERR_PTR(err); 3070 3070 } 3071 3071 3072 3072 /*
+7 -7
fs/f2fs/namei.c
··· 684 684 return err; 685 685 } 686 686 687 - static int f2fs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 688 - struct dentry *dentry, umode_t mode) 687 + static struct dentry *f2fs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 688 + struct dentry *dentry, umode_t mode) 689 689 { 690 690 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 691 691 struct inode *inode; 692 692 int err; 693 693 694 694 if (unlikely(f2fs_cp_error(sbi))) 695 - return -EIO; 695 + return ERR_PTR(-EIO); 696 696 697 697 err = f2fs_dquot_initialize(dir); 698 698 if (err) 699 - return err; 699 + return ERR_PTR(err); 700 700 701 701 inode = f2fs_new_inode(idmap, dir, S_IFDIR | mode, NULL); 702 702 if (IS_ERR(inode)) 703 - return PTR_ERR(inode); 703 + return ERR_CAST(inode); 704 704 705 705 inode->i_op = &f2fs_dir_inode_operations; 706 706 inode->i_fop = &f2fs_dir_operations; ··· 722 722 f2fs_sync_fs(sbi->sb, 1); 723 723 724 724 f2fs_balance_fs(sbi, true); 725 - return 0; 725 + return NULL; 726 726 727 727 out_fail: 728 728 clear_inode_flag(inode, FI_INC_LINK); 729 729 f2fs_handle_failed_inode(inode); 730 - return err; 730 + return ERR_PTR(err); 731 731 } 732 732 733 733 static int f2fs_rmdir(struct inode *dir, struct dentry *dentry)
+4 -4
fs/fat/namei_msdos.c
··· 339 339 } 340 340 341 341 /***** Make a directory */ 342 - static int msdos_mkdir(struct mnt_idmap *idmap, struct inode *dir, 343 - struct dentry *dentry, umode_t mode) 342 + static struct dentry *msdos_mkdir(struct mnt_idmap *idmap, struct inode *dir, 343 + struct dentry *dentry, umode_t mode) 344 344 { 345 345 struct super_block *sb = dir->i_sb; 346 346 struct fat_slot_info sinfo; ··· 389 389 390 390 mutex_unlock(&MSDOS_SB(sb)->s_lock); 391 391 fat_flush_inodes(sb, dir, inode); 392 - return 0; 392 + return NULL; 393 393 394 394 out_free: 395 395 fat_free_clusters(dir, cluster); 396 396 out: 397 397 mutex_unlock(&MSDOS_SB(sb)->s_lock); 398 - return err; 398 + return ERR_PTR(err); 399 399 } 400 400 401 401 /***** Unlink a file */
+4 -4
fs/fat/namei_vfat.c
··· 841 841 return err; 842 842 } 843 843 844 - static int vfat_mkdir(struct mnt_idmap *idmap, struct inode *dir, 845 - struct dentry *dentry, umode_t mode) 844 + static struct dentry *vfat_mkdir(struct mnt_idmap *idmap, struct inode *dir, 845 + struct dentry *dentry, umode_t mode) 846 846 { 847 847 struct super_block *sb = dir->i_sb; 848 848 struct inode *inode; ··· 877 877 d_instantiate(dentry, inode); 878 878 879 879 mutex_unlock(&MSDOS_SB(sb)->s_lock); 880 - return 0; 880 + return NULL; 881 881 882 882 out_free: 883 883 fat_free_clusters(dir, cluster); 884 884 out: 885 885 mutex_unlock(&MSDOS_SB(sb)->s_lock); 886 - return err; 886 + return ERR_PTR(err); 887 887 } 888 888 889 889 static int vfat_get_dotdot_de(struct inode *inode, struct buffer_head **bh,
+3 -3
fs/fuse/dir.c
··· 898 898 return err; 899 899 } 900 900 901 - static int fuse_mkdir(struct mnt_idmap *idmap, struct inode *dir, 902 - struct dentry *entry, umode_t mode) 901 + static struct dentry *fuse_mkdir(struct mnt_idmap *idmap, struct inode *dir, 902 + struct dentry *entry, umode_t mode) 903 903 { 904 904 struct fuse_mkdir_in inarg; 905 905 struct fuse_mount *fm = get_fuse_mount(dir); ··· 917 917 args.in_args[0].value = &inarg; 918 918 args.in_args[1].size = entry->d_name.len + 1; 919 919 args.in_args[1].value = entry->d_name.name; 920 - return create_new_entry(idmap, fm, &args, dir, entry, S_IFDIR); 920 + return ERR_PTR(create_new_entry(idmap, fm, &args, dir, entry, S_IFDIR)); 921 921 } 922 922 923 923 static int fuse_symlink(struct mnt_idmap *idmap, struct inode *dir,
+5 -4
fs/gfs2/inode.c
··· 1248 1248 * @dentry: The dentry of the new directory 1249 1249 * @mode: The mode of the new directory 1250 1250 * 1251 - * Returns: errno 1251 + * Returns: the dentry, or ERR_PTR(errno) 1252 1252 */ 1253 1253 1254 - static int gfs2_mkdir(struct mnt_idmap *idmap, struct inode *dir, 1255 - struct dentry *dentry, umode_t mode) 1254 + static struct dentry *gfs2_mkdir(struct mnt_idmap *idmap, struct inode *dir, 1255 + struct dentry *dentry, umode_t mode) 1256 1256 { 1257 1257 unsigned dsize = gfs2_max_stuffed_size(GFS2_I(dir)); 1258 - return gfs2_create_inode(dir, dentry, NULL, S_IFDIR | mode, 0, NULL, dsize, 0); 1258 + 1259 + return ERR_PTR(gfs2_create_inode(dir, dentry, NULL, S_IFDIR | mode, 0, NULL, dsize, 0)); 1259 1260 } 1260 1261 1261 1262 /**
+5 -5
fs/hfs/dir.c
··· 219 219 * in a directory, given the inode for the parent directory and the 220 220 * name (and its length) of the new directory. 221 221 */ 222 - static int hfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 223 - struct dentry *dentry, umode_t mode) 222 + static struct dentry *hfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 223 + struct dentry *dentry, umode_t mode) 224 224 { 225 225 struct inode *inode; 226 226 int res; 227 227 228 228 inode = hfs_new_inode(dir, &dentry->d_name, S_IFDIR | mode); 229 229 if (!inode) 230 - return -ENOMEM; 230 + return ERR_PTR(-ENOMEM); 231 231 232 232 res = hfs_cat_create(inode->i_ino, dir, &dentry->d_name, inode); 233 233 if (res) { 234 234 clear_nlink(inode); 235 235 hfs_delete_inode(inode); 236 236 iput(inode); 237 - return res; 237 + return ERR_PTR(res); 238 238 } 239 239 d_instantiate(dentry, inode); 240 240 mark_inode_dirty(inode); 241 - return 0; 241 + return NULL; 242 242 } 243 243 244 244 /*
+3 -3
fs/hfsplus/dir.c
··· 523 523 return hfsplus_mknod(&nop_mnt_idmap, dir, dentry, mode, 0); 524 524 } 525 525 526 - static int hfsplus_mkdir(struct mnt_idmap *idmap, struct inode *dir, 527 - struct dentry *dentry, umode_t mode) 526 + static struct dentry *hfsplus_mkdir(struct mnt_idmap *idmap, struct inode *dir, 527 + struct dentry *dentry, umode_t mode) 528 528 { 529 - return hfsplus_mknod(&nop_mnt_idmap, dir, dentry, mode | S_IFDIR, 0); 529 + return ERR_PTR(hfsplus_mknod(&nop_mnt_idmap, dir, dentry, mode | S_IFDIR, 0)); 530 530 } 531 531 532 532 static int hfsplus_rename(struct mnt_idmap *idmap,
+4 -4
fs/hostfs/hostfs_kern.c
··· 679 679 return err; 680 680 } 681 681 682 - static int hostfs_mkdir(struct mnt_idmap *idmap, struct inode *ino, 683 - struct dentry *dentry, umode_t mode) 682 + static struct dentry *hostfs_mkdir(struct mnt_idmap *idmap, struct inode *ino, 683 + struct dentry *dentry, umode_t mode) 684 684 { 685 685 char *file; 686 686 int err; 687 687 688 688 if ((file = dentry_name(dentry)) == NULL) 689 - return -ENOMEM; 689 + return ERR_PTR(-ENOMEM); 690 690 err = do_mkdir(file, mode); 691 691 __putname(file); 692 - return err; 692 + return ERR_PTR(err); 693 693 } 694 694 695 695 static int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
+5 -5
fs/hpfs/namei.c
··· 19 19 hpfs_write_inode_nolock(dir); 20 20 } 21 21 22 - static int hpfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 23 - struct dentry *dentry, umode_t mode) 22 + static struct dentry *hpfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 23 + struct dentry *dentry, umode_t mode) 24 24 { 25 25 const unsigned char *name = dentry->d_name.name; 26 26 unsigned len = dentry->d_name.len; ··· 35 35 int r; 36 36 struct hpfs_dirent dee; 37 37 int err; 38 - if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err; 38 + if ((err = hpfs_chk_name(name, &len))) return ERR_PTR(err==-ENOENT ? -EINVAL : err); 39 39 hpfs_lock(dir->i_sb); 40 40 err = -ENOSPC; 41 41 fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); ··· 112 112 hpfs_update_directory_times(dir); 113 113 d_instantiate(dentry, result); 114 114 hpfs_unlock(dir->i_sb); 115 - return 0; 115 + return NULL; 116 116 bail3: 117 117 iput(result); 118 118 bail2: ··· 123 123 hpfs_free_sectors(dir->i_sb, fno, 1); 124 124 bail: 125 125 hpfs_unlock(dir->i_sb); 126 - return err; 126 + return ERR_PTR(err); 127 127 } 128 128 129 129 static int hpfs_create(struct mnt_idmap *idmap, struct inode *dir,
+3 -3
fs/hugetlbfs/inode.c
··· 991 991 return 0; 992 992 } 993 993 994 - static int hugetlbfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 995 - struct dentry *dentry, umode_t mode) 994 + static struct dentry *hugetlbfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 995 + struct dentry *dentry, umode_t mode) 996 996 { 997 997 int retval = hugetlbfs_mknod(idmap, dir, dentry, 998 998 mode | S_IFDIR, 0); 999 999 if (!retval) 1000 1000 inc_nlink(dir); 1001 - return retval; 1001 + return ERR_PTR(retval); 1002 1002 } 1003 1003 1004 1004 static int hugetlbfs_create(struct mnt_idmap *idmap,
+9 -9
fs/jffs2/dir.c
··· 32 32 static int jffs2_unlink (struct inode *,struct dentry *); 33 33 static int jffs2_symlink (struct mnt_idmap *, struct inode *, 34 34 struct dentry *, const char *); 35 - static int jffs2_mkdir (struct mnt_idmap *, struct inode *,struct dentry *, 36 - umode_t); 35 + static struct dentry *jffs2_mkdir (struct mnt_idmap *, struct inode *,struct dentry *, 36 + umode_t); 37 37 static int jffs2_rmdir (struct inode *,struct dentry *); 38 38 static int jffs2_mknod (struct mnt_idmap *, struct inode *,struct dentry *, 39 39 umode_t,dev_t); ··· 446 446 } 447 447 448 448 449 - static int jffs2_mkdir (struct mnt_idmap *idmap, struct inode *dir_i, 450 - struct dentry *dentry, umode_t mode) 449 + static struct dentry *jffs2_mkdir (struct mnt_idmap *idmap, struct inode *dir_i, 450 + struct dentry *dentry, umode_t mode) 451 451 { 452 452 struct jffs2_inode_info *f, *dir_f; 453 453 struct jffs2_sb_info *c; ··· 464 464 465 465 ri = jffs2_alloc_raw_inode(); 466 466 if (!ri) 467 - return -ENOMEM; 467 + return ERR_PTR(-ENOMEM); 468 468 469 469 c = JFFS2_SB_INFO(dir_i->i_sb); 470 470 ··· 477 477 478 478 if (ret) { 479 479 jffs2_free_raw_inode(ri); 480 - return ret; 480 + return ERR_PTR(ret); 481 481 } 482 482 483 483 inode = jffs2_new_inode(dir_i, mode, ri); ··· 485 485 if (IS_ERR(inode)) { 486 486 jffs2_free_raw_inode(ri); 487 487 jffs2_complete_reservation(c); 488 - return PTR_ERR(inode); 488 + return ERR_CAST(inode); 489 489 } 490 490 491 491 inode->i_op = &jffs2_dir_inode_operations; ··· 584 584 jffs2_complete_reservation(c); 585 585 586 586 d_instantiate_new(dentry, inode); 587 - return 0; 587 + return NULL; 588 588 589 589 fail: 590 590 iget_failed(inode); 591 - return ret; 591 + return ERR_PTR(ret); 592 592 } 593 593 594 594 static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)
+4 -4
fs/jfs/namei.c
··· 187 187 * dentry - dentry of child directory 188 188 * mode - create mode (rwxrwxrwx). 189 189 * 190 - * RETURN: Errors from subroutines 190 + * RETURN: ERR_PTR() of errors from subroutines. 191 191 * 192 192 * note: 193 193 * EACCES: user needs search+write permission on the parent directory 194 194 */ 195 - static int jfs_mkdir(struct mnt_idmap *idmap, struct inode *dip, 196 - struct dentry *dentry, umode_t mode) 195 + static struct dentry *jfs_mkdir(struct mnt_idmap *idmap, struct inode *dip, 196 + struct dentry *dentry, umode_t mode) 197 197 { 198 198 int rc = 0; 199 199 tid_t tid; /* transaction id */ ··· 308 308 out1: 309 309 310 310 jfs_info("jfs_mkdir: rc:%d", rc); 311 - return rc; 311 + return ERR_PTR(rc); 312 312 } 313 313 314 314 /*
+6 -6
fs/kernfs/dir.c
··· 1230 1230 return d_splice_alias(inode, dentry); 1231 1231 } 1232 1232 1233 - static int kernfs_iop_mkdir(struct mnt_idmap *idmap, 1234 - struct inode *dir, struct dentry *dentry, 1235 - umode_t mode) 1233 + static struct dentry *kernfs_iop_mkdir(struct mnt_idmap *idmap, 1234 + struct inode *dir, struct dentry *dentry, 1235 + umode_t mode) 1236 1236 { 1237 1237 struct kernfs_node *parent = dir->i_private; 1238 1238 struct kernfs_syscall_ops *scops = kernfs_root(parent)->syscall_ops; 1239 1239 int ret; 1240 1240 1241 1241 if (!scops || !scops->mkdir) 1242 - return -EPERM; 1242 + return ERR_PTR(-EPERM); 1243 1243 1244 1244 if (!kernfs_get_active(parent)) 1245 - return -ENODEV; 1245 + return ERR_PTR(-ENODEV); 1246 1246 1247 1247 ret = scops->mkdir(parent, dentry->d_name.name, mode); 1248 1248 1249 1249 kernfs_put_active(parent); 1250 - return ret; 1250 + return ERR_PTR(ret); 1251 1251 } 1252 1252 1253 1253 static int kernfs_iop_rmdir(struct inode *dir, struct dentry *dentry)
+4 -4
fs/minix/namei.c
··· 104 104 return add_nondir(dentry, inode); 105 105 } 106 106 107 - static int minix_mkdir(struct mnt_idmap *idmap, struct inode *dir, 108 - struct dentry *dentry, umode_t mode) 107 + static struct dentry *minix_mkdir(struct mnt_idmap *idmap, struct inode *dir, 108 + struct dentry *dentry, umode_t mode) 109 109 { 110 110 struct inode * inode; 111 111 int err; 112 112 113 113 inode = minix_new_inode(dir, S_IFDIR | mode); 114 114 if (IS_ERR(inode)) 115 - return PTR_ERR(inode); 115 + return ERR_CAST(inode); 116 116 117 117 inode_inc_link_count(dir); 118 118 minix_set_inode(inode, 0); ··· 128 128 129 129 d_instantiate(dentry, inode); 130 130 out: 131 - return err; 131 + return ERR_PTR(err); 132 132 133 133 out_fail: 134 134 inode_dec_link_count(inode);
+12 -3
fs/namei.c
··· 4293 4293 { 4294 4294 int error; 4295 4295 unsigned max_links = dir->i_sb->s_max_links; 4296 + struct dentry *de; 4296 4297 4297 4298 error = may_create(idmap, dir, dentry); 4298 4299 if (error) ··· 4310 4309 if (max_links && dir->i_nlink >= max_links) 4311 4310 return -EMLINK; 4312 4311 4313 - error = dir->i_op->mkdir(idmap, dir, dentry, mode); 4314 - if (!error) 4312 + de = dir->i_op->mkdir(idmap, dir, dentry, mode); 4313 + if (IS_ERR(de)) 4314 + return PTR_ERR(de); 4315 + if (de) { 4316 + fsnotify_mkdir(dir, de); 4317 + /* Cannot return de yet */ 4318 + dput(de); 4319 + } else { 4315 4320 fsnotify_mkdir(dir, dentry); 4316 - return error; 4321 + } 4322 + 4323 + return 0; 4317 4324 } 4318 4325 EXPORT_SYMBOL(vfs_mkdir); 4319 4326
+4 -4
fs/nfs/dir.c
··· 2422 2422 /* 2423 2423 * See comments for nfs_proc_create regarding failed operations. 2424 2424 */ 2425 - int nfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 2426 - struct dentry *dentry, umode_t mode) 2425 + struct dentry *nfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 2426 + struct dentry *dentry, umode_t mode) 2427 2427 { 2428 2428 struct iattr attr; 2429 2429 int error; ··· 2439 2439 trace_nfs_mkdir_exit(dir, dentry, error); 2440 2440 if (error != 0) 2441 2441 goto out_err; 2442 - return 0; 2442 + return NULL; 2443 2443 out_err: 2444 2444 d_drop(dentry); 2445 - return error; 2445 + return ERR_PTR(error); 2446 2446 } 2447 2447 EXPORT_SYMBOL_GPL(nfs_mkdir); 2448 2448
+2 -2
fs/nfs/internal.h
··· 400 400 void nfs_d_prune_case_insensitive_aliases(struct inode *inode); 401 401 int nfs_create(struct mnt_idmap *, struct inode *, struct dentry *, 402 402 umode_t, bool); 403 - int nfs_mkdir(struct mnt_idmap *, struct inode *, struct dentry *, 404 - umode_t); 403 + struct dentry *nfs_mkdir(struct mnt_idmap *, struct inode *, struct dentry *, 404 + umode_t); 405 405 int nfs_rmdir(struct inode *, struct dentry *); 406 406 int nfs_unlink(struct inode *, struct dentry *); 407 407 int nfs_symlink(struct mnt_idmap *, struct inode *, struct dentry *,
+4 -4
fs/nilfs2/namei.c
··· 218 218 return err; 219 219 } 220 220 221 - static int nilfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 222 - struct dentry *dentry, umode_t mode) 221 + static struct dentry *nilfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 222 + struct dentry *dentry, umode_t mode) 223 223 { 224 224 struct inode *inode; 225 225 struct nilfs_transaction_info ti; ··· 227 227 228 228 err = nilfs_transaction_begin(dir->i_sb, &ti, 1); 229 229 if (err) 230 - return err; 230 + return ERR_PTR(err); 231 231 232 232 inc_nlink(dir); 233 233 ··· 258 258 else 259 259 nilfs_transaction_abort(dir->i_sb); 260 260 261 - return err; 261 + return ERR_PTR(err); 262 262 263 263 out_fail: 264 264 drop_nlink(inode);
+4 -4
fs/ntfs3/namei.c
··· 201 201 /* 202 202 * ntfs_mkdir- inode_operations::mkdir 203 203 */ 204 - static int ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 205 - struct dentry *dentry, umode_t mode) 204 + static struct dentry *ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 205 + struct dentry *dentry, umode_t mode) 206 206 { 207 - return ntfs_create_inode(idmap, dir, dentry, NULL, S_IFDIR | mode, 0, 208 - NULL, 0, NULL); 207 + return ERR_PTR(ntfs_create_inode(idmap, dir, dentry, NULL, S_IFDIR | mode, 0, 208 + NULL, 0, NULL)); 209 209 } 210 210 211 211 /*
+5 -5
fs/ocfs2/dlmfs/dlmfs.c
··· 402 402 * File creation. Allocate an inode, and we're done.. 403 403 */ 404 404 /* SMP-safe */ 405 - static int dlmfs_mkdir(struct mnt_idmap * idmap, 406 - struct inode * dir, 407 - struct dentry * dentry, 408 - umode_t mode) 405 + static struct dentry *dlmfs_mkdir(struct mnt_idmap * idmap, 406 + struct inode * dir, 407 + struct dentry * dentry, 408 + umode_t mode) 409 409 { 410 410 int status; 411 411 struct inode *inode = NULL; ··· 448 448 bail: 449 449 if (status < 0) 450 450 iput(inode); 451 - return status; 451 + return ERR_PTR(status); 452 452 } 453 453 454 454 static int dlmfs_create(struct mnt_idmap *idmap,
+5 -5
fs/ocfs2/namei.c
··· 644 644 suballoc_loc, suballoc_bit); 645 645 } 646 646 647 - static int ocfs2_mkdir(struct mnt_idmap *idmap, 648 - struct inode *dir, 649 - struct dentry *dentry, 650 - umode_t mode) 647 + static struct dentry *ocfs2_mkdir(struct mnt_idmap *idmap, 648 + struct inode *dir, 649 + struct dentry *dentry, 650 + umode_t mode) 651 651 { 652 652 int ret; 653 653 ··· 657 657 if (ret) 658 658 mlog_errno(ret); 659 659 660 - return ret; 660 + return ERR_PTR(ret); 661 661 } 662 662 663 663 static int ocfs2_create(struct mnt_idmap *idmap,
+3 -3
fs/omfs/dir.c
··· 279 279 return err; 280 280 } 281 281 282 - static int omfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 283 - struct dentry *dentry, umode_t mode) 282 + static struct dentry *omfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 283 + struct dentry *dentry, umode_t mode) 284 284 { 285 - return omfs_add_node(dir, dentry, mode | S_IFDIR); 285 + return ERR_PTR(omfs_add_node(dir, dentry, mode | S_IFDIR)); 286 286 } 287 287 288 288 static int omfs_create(struct mnt_idmap *idmap, struct inode *dir,
+4 -4
fs/orangefs/namei.c
··· 300 300 return ret; 301 301 } 302 302 303 - static int orangefs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 304 - struct dentry *dentry, umode_t mode) 303 + static struct dentry *orangefs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 304 + struct dentry *dentry, umode_t mode) 305 305 { 306 306 struct orangefs_inode_s *parent = ORANGEFS_I(dir); 307 307 struct orangefs_kernel_op_s *new_op; ··· 312 312 313 313 new_op = op_alloc(ORANGEFS_VFS_OP_MKDIR); 314 314 if (!new_op) 315 - return -ENOMEM; 315 + return ERR_PTR(-ENOMEM); 316 316 317 317 new_op->upcall.req.mkdir.parent_refn = parent->refn; 318 318 ··· 366 366 __orangefs_setattr(dir, &iattr); 367 367 out: 368 368 op_release(new_op); 369 - return ret; 369 + return ERR_PTR(ret); 370 370 } 371 371 372 372 static int orangefs_rename(struct mnt_idmap *idmap,
+5 -4
fs/overlayfs/dir.c
··· 282 282 * XXX: if we ever use ovl_obtain_alias() to decode directory 283 283 * file handles, need to use ovl_get_inode_locked() and 284 284 * d_instantiate_new() here to prevent from creating two 285 - * hashed directory inode aliases. 285 + * hashed directory inode aliases. We then need to return 286 + * the obtained alias to ovl_mkdir(). 286 287 */ 287 288 inode = ovl_get_inode(dentry->d_sb, &oip); 288 289 if (IS_ERR(inode)) ··· 688 687 return ovl_create_object(dentry, (mode & 07777) | S_IFREG, 0, NULL); 689 688 } 690 689 691 - static int ovl_mkdir(struct mnt_idmap *idmap, struct inode *dir, 692 - struct dentry *dentry, umode_t mode) 690 + static struct dentry *ovl_mkdir(struct mnt_idmap *idmap, struct inode *dir, 691 + struct dentry *dentry, umode_t mode) 693 692 { 694 - return ovl_create_object(dentry, (mode & 07777) | S_IFDIR, 0, NULL); 693 + return ERR_PTR(ovl_create_object(dentry, (mode & 07777) | S_IFDIR, 0, NULL)); 695 694 } 696 695 697 696 static int ovl_mknod(struct mnt_idmap *idmap, struct inode *dir,
+3 -3
fs/ramfs/inode.c
··· 119 119 return error; 120 120 } 121 121 122 - static int ramfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 123 - struct dentry *dentry, umode_t mode) 122 + static struct dentry *ramfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 123 + struct dentry *dentry, umode_t mode) 124 124 { 125 125 int retval = ramfs_mknod(&nop_mnt_idmap, dir, dentry, mode | S_IFDIR, 0); 126 126 if (!retval) 127 127 inc_nlink(dir); 128 - return retval; 128 + return ERR_PTR(retval); 129 129 } 130 130 131 131 static int ramfs_create(struct mnt_idmap *idmap, struct inode *dir,
+2 -2
fs/smb/client/cifsfs.h
··· 59 59 extern int cifs_hardlink(struct dentry *, struct inode *, struct dentry *); 60 60 extern int cifs_mknod(struct mnt_idmap *, struct inode *, struct dentry *, 61 61 umode_t, dev_t); 62 - extern int cifs_mkdir(struct mnt_idmap *, struct inode *, struct dentry *, 63 - umode_t); 62 + extern struct dentry *cifs_mkdir(struct mnt_idmap *, struct inode *, struct dentry *, 63 + umode_t); 64 64 extern int cifs_rmdir(struct inode *, struct dentry *); 65 65 extern int cifs_rename2(struct mnt_idmap *, struct inode *, 66 66 struct dentry *, struct inode *, struct dentry *,
+5 -5
fs/smb/client/inode.c
··· 2207 2207 } 2208 2208 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ 2209 2209 2210 - int cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode, 2211 - struct dentry *direntry, umode_t mode) 2210 + struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode, 2211 + struct dentry *direntry, umode_t mode) 2212 2212 { 2213 2213 int rc = 0; 2214 2214 unsigned int xid; ··· 2224 2224 2225 2225 cifs_sb = CIFS_SB(inode->i_sb); 2226 2226 if (unlikely(cifs_forced_shutdown(cifs_sb))) 2227 - return -EIO; 2227 + return ERR_PTR(-EIO); 2228 2228 tlink = cifs_sb_tlink(cifs_sb); 2229 2229 if (IS_ERR(tlink)) 2230 - return PTR_ERR(tlink); 2230 + return ERR_CAST(tlink); 2231 2231 tcon = tlink_tcon(tlink); 2232 2232 2233 2233 xid = get_xid(); ··· 2283 2283 free_dentry_path(page); 2284 2284 free_xid(xid); 2285 2285 cifs_put_tlink(tlink); 2286 - return rc; 2286 + return ERR_PTR(rc); 2287 2287 } 2288 2288 2289 2289 int cifs_rmdir(struct inode *inode, struct dentry *direntry)
+3 -3
fs/sysv/namei.c
··· 110 110 return add_nondir(dentry, inode); 111 111 } 112 112 113 - static int sysv_mkdir(struct mnt_idmap *idmap, struct inode *dir, 114 - struct dentry *dentry, umode_t mode) 113 + static struct dentry *sysv_mkdir(struct mnt_idmap *idmap, struct inode *dir, 114 + struct dentry *dentry, umode_t mode) 115 115 { 116 116 struct inode * inode; 117 117 int err; ··· 137 137 138 138 d_instantiate(dentry, inode); 139 139 out: 140 - return err; 140 + return ERR_PTR(err); 141 141 142 142 out_fail: 143 143 inode_dec_link_count(inode);
+5 -5
fs/tracefs/inode.c
··· 109 109 return name; 110 110 } 111 111 112 - static int tracefs_syscall_mkdir(struct mnt_idmap *idmap, 113 - struct inode *inode, struct dentry *dentry, 114 - umode_t mode) 112 + static struct dentry *tracefs_syscall_mkdir(struct mnt_idmap *idmap, 113 + struct inode *inode, struct dentry *dentry, 114 + umode_t mode) 115 115 { 116 116 struct tracefs_inode *ti; 117 117 char *name; ··· 119 119 120 120 name = get_dname(dentry); 121 121 if (!name) 122 - return -ENOMEM; 122 + return ERR_PTR(-ENOMEM); 123 123 124 124 /* 125 125 * This is a new directory that does not take the default of ··· 141 141 142 142 kfree(name); 143 143 144 - return ret; 144 + return ERR_PTR(ret); 145 145 } 146 146 147 147 static int tracefs_syscall_rmdir(struct inode *inode, struct dentry *dentry)
+5 -5
fs/ubifs/dir.c
··· 1002 1002 return err; 1003 1003 } 1004 1004 1005 - static int ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 1006 - struct dentry *dentry, umode_t mode) 1005 + static struct dentry *ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 1006 + struct dentry *dentry, umode_t mode) 1007 1007 { 1008 1008 struct inode *inode; 1009 1009 struct ubifs_inode *dir_ui = ubifs_inode(dir); ··· 1023 1023 1024 1024 err = ubifs_budget_space(c, &req); 1025 1025 if (err) 1026 - return err; 1026 + return ERR_PTR(err); 1027 1027 1028 1028 err = ubifs_prepare_create(dir, dentry, &nm); 1029 1029 if (err) ··· 1060 1060 ubifs_release_budget(c, &req); 1061 1061 d_instantiate(dentry, inode); 1062 1062 fscrypt_free_filename(&nm); 1063 - return 0; 1063 + return NULL; 1064 1064 1065 1065 out_cancel: 1066 1066 dir->i_size -= sz_change; ··· 1074 1074 fscrypt_free_filename(&nm); 1075 1075 out_budg: 1076 1076 ubifs_release_budget(c, &req); 1077 - return err; 1077 + return ERR_PTR(err); 1078 1078 } 1079 1079 1080 1080 static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+6 -6
fs/udf/namei.c
··· 419 419 return udf_add_nondir(dentry, inode); 420 420 } 421 421 422 - static int udf_mkdir(struct mnt_idmap *idmap, struct inode *dir, 423 - struct dentry *dentry, umode_t mode) 422 + static struct dentry *udf_mkdir(struct mnt_idmap *idmap, struct inode *dir, 423 + struct dentry *dentry, umode_t mode) 424 424 { 425 425 struct inode *inode; 426 426 struct udf_fileident_iter iter; ··· 430 430 431 431 inode = udf_new_inode(dir, S_IFDIR | mode); 432 432 if (IS_ERR(inode)) 433 - return PTR_ERR(inode); 433 + return ERR_CAST(inode); 434 434 435 435 iinfo = UDF_I(inode); 436 436 inode->i_op = &udf_dir_inode_operations; ··· 439 439 if (err) { 440 440 clear_nlink(inode); 441 441 discard_new_inode(inode); 442 - return err; 442 + return ERR_PTR(err); 443 443 } 444 444 set_nlink(inode, 2); 445 445 iter.fi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); ··· 456 456 if (err) { 457 457 clear_nlink(inode); 458 458 discard_new_inode(inode); 459 - return err; 459 + return ERR_PTR(err); 460 460 } 461 461 iter.fi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); 462 462 iter.fi.icb.extLocation = cpu_to_lelb(iinfo->i_location); ··· 471 471 mark_inode_dirty(dir); 472 472 d_instantiate_new(dentry, inode); 473 473 474 - return 0; 474 + return NULL; 475 475 } 476 476 477 477 static int empty_dir(struct inode *dir)
+4 -4
fs/ufs/namei.c
··· 166 166 return error; 167 167 } 168 168 169 - static int ufs_mkdir(struct mnt_idmap * idmap, struct inode * dir, 170 - struct dentry * dentry, umode_t mode) 169 + static struct dentry *ufs_mkdir(struct mnt_idmap * idmap, struct inode * dir, 170 + struct dentry * dentry, umode_t mode) 171 171 { 172 172 struct inode * inode; 173 173 int err; ··· 194 194 goto out_fail; 195 195 196 196 d_instantiate_new(dentry, inode); 197 - return 0; 197 + return NULL; 198 198 199 199 out_fail: 200 200 inode_dec_link_count(inode); ··· 202 202 discard_new_inode(inode); 203 203 out_dir: 204 204 inode_dec_link_count(dir); 205 - return err; 205 + return ERR_PTR(err); 206 206 } 207 207 208 208 static int ufs_unlink(struct inode *dir, struct dentry *dentry)
+4 -4
fs/vboxsf/dir.c
··· 303 303 return vboxsf_dir_create(parent, dentry, mode, false, excl, NULL); 304 304 } 305 305 306 - static int vboxsf_dir_mkdir(struct mnt_idmap *idmap, 307 - struct inode *parent, struct dentry *dentry, 308 - umode_t mode) 306 + static struct dentry *vboxsf_dir_mkdir(struct mnt_idmap *idmap, 307 + struct inode *parent, struct dentry *dentry, 308 + umode_t mode) 309 309 { 310 - return vboxsf_dir_create(parent, dentry, mode, true, true, NULL); 310 + return ERR_PTR(vboxsf_dir_create(parent, dentry, mode, true, true, NULL)); 311 311 } 312 312 313 313 static int vboxsf_dir_atomic_open(struct inode *parent, struct dentry *dentry,
+2 -2
fs/xfs/xfs_iops.c
··· 298 298 return xfs_generic_create(idmap, dir, dentry, mode, 0, NULL); 299 299 } 300 300 301 - STATIC int 301 + STATIC struct dentry * 302 302 xfs_vn_mkdir( 303 303 struct mnt_idmap *idmap, 304 304 struct inode *dir, 305 305 struct dentry *dentry, 306 306 umode_t mode) 307 307 { 308 - return xfs_generic_create(idmap, dir, dentry, mode | S_IFDIR, 0, NULL); 308 + return ERR_PTR(xfs_generic_create(idmap, dir, dentry, mode | S_IFDIR, 0, NULL)); 309 309 } 310 310 311 311 STATIC struct dentry *
+2 -2
include/linux/fs.h
··· 2211 2211 int (*unlink) (struct inode *,struct dentry *); 2212 2212 int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *, 2213 2213 const char *); 2214 - int (*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *, 2215 - umode_t); 2214 + struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *, 2215 + struct dentry *, umode_t); 2216 2216 int (*rmdir) (struct inode *,struct dentry *); 2217 2217 int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *, 2218 2218 umode_t,dev_t);
+4 -4
kernel/bpf/inode.c
··· 150 150 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); 151 151 } 152 152 153 - static int bpf_mkdir(struct mnt_idmap *idmap, struct inode *dir, 154 - struct dentry *dentry, umode_t mode) 153 + static struct dentry *bpf_mkdir(struct mnt_idmap *idmap, struct inode *dir, 154 + struct dentry *dentry, umode_t mode) 155 155 { 156 156 struct inode *inode; 157 157 158 158 inode = bpf_get_inode(dir->i_sb, dir, mode | S_IFDIR); 159 159 if (IS_ERR(inode)) 160 - return PTR_ERR(inode); 160 + return ERR_CAST(inode); 161 161 162 162 inode->i_op = &bpf_dir_iops; 163 163 inode->i_fop = &simple_dir_operations; ··· 166 166 inc_nlink(dir); 167 167 168 168 bpf_dentry_finalize(dentry, inode, dir); 169 - return 0; 169 + return NULL; 170 170 } 171 171 172 172 struct map_iter {
+4 -4
mm/shmem.c
··· 3889 3889 return error; 3890 3890 } 3891 3891 3892 - static int shmem_mkdir(struct mnt_idmap *idmap, struct inode *dir, 3893 - struct dentry *dentry, umode_t mode) 3892 + static struct dentry *shmem_mkdir(struct mnt_idmap *idmap, struct inode *dir, 3893 + struct dentry *dentry, umode_t mode) 3894 3894 { 3895 3895 int error; 3896 3896 3897 3897 error = shmem_mknod(idmap, dir, dentry, mode | S_IFDIR, 0); 3898 3898 if (error) 3899 - return error; 3899 + return ERR_PTR(error); 3900 3900 inc_nlink(dir); 3901 - return 0; 3901 + return NULL; 3902 3902 } 3903 3903 3904 3904 static int shmem_create(struct mnt_idmap *idmap, struct inode *dir,
+4 -4
security/apparmor/apparmorfs.c
··· 1795 1795 return error; 1796 1796 } 1797 1797 1798 - static int ns_mkdir_op(struct mnt_idmap *idmap, struct inode *dir, 1799 - struct dentry *dentry, umode_t mode) 1798 + static struct dentry *ns_mkdir_op(struct mnt_idmap *idmap, struct inode *dir, 1799 + struct dentry *dentry, umode_t mode) 1800 1800 { 1801 1801 struct aa_ns *ns, *parent; 1802 1802 /* TODO: improve permission check */ ··· 1808 1808 AA_MAY_LOAD_POLICY); 1809 1809 end_current_label_crit_section(label); 1810 1810 if (error) 1811 - return error; 1811 + return ERR_PTR(error); 1812 1812 1813 1813 parent = aa_get_ns(dir->i_private); 1814 1814 AA_BUG(d_inode(ns_subns_dir(parent)) != dir); ··· 1843 1843 mutex_unlock(&parent->lock); 1844 1844 aa_put_ns(parent); 1845 1845 1846 - return error; 1846 + return ERR_PTR(error); 1847 1847 } 1848 1848 1849 1849 static int ns_rmdir_op(struct inode *dir, struct dentry *dentry)