diff options
Diffstat (limited to 'fs/xfs/xfs_iops.c')
-rw-r--r-- | fs/xfs/xfs_iops.c | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index a00dcbc77e12..1cdc8034f54d 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -28,6 +28,7 @@ #include "xfs_ioctl.h" #include "xfs_xattr.h" #include "xfs_file.h" +#include "xfs_bmap.h" #include <linux/posix_acl.h> #include <linux/security.h> @@ -159,8 +160,6 @@ xfs_create_need_xattr( if (dir->i_sb->s_security) return true; #endif - if (xfs_has_parent(XFS_I(dir)->i_mount)) - return true; return false; } @@ -174,49 +173,55 @@ xfs_generic_create( dev_t rdev, struct file *tmpfile) /* unnamed file */ { - struct inode *inode; - struct xfs_inode *ip = NULL; - struct posix_acl *default_acl, *acl; - struct xfs_name name; - int error; + struct xfs_icreate_args args = { + .idmap = idmap, + .pip = XFS_I(dir), + .rdev = rdev, + .mode = mode, + }; + struct inode *inode; + struct xfs_inode *ip = NULL; + struct posix_acl *default_acl, *acl; + struct xfs_name name; + int error; /* * Irix uses Missed'em'V split, but doesn't want to see * the upper 5 bits of (14bit) major. */ - if (S_ISCHR(mode) || S_ISBLK(mode)) { - if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff)) + if (S_ISCHR(args.mode) || S_ISBLK(args.mode)) { + if (unlikely(!sysv_valid_dev(args.rdev) || + MAJOR(args.rdev) & ~0x1ff)) return -EINVAL; } else { - rdev = 0; + args.rdev = 0; } - error = posix_acl_create(dir, &mode, &default_acl, &acl); + error = posix_acl_create(dir, &args.mode, &default_acl, &acl); if (error) return error; /* Verify mode is valid also for tmpfile case */ - error = xfs_dentry_mode_to_name(&name, dentry, mode); + error = xfs_dentry_mode_to_name(&name, dentry, args.mode); if (unlikely(error)) goto out_free_acl; if (!tmpfile) { - error = xfs_create(idmap, XFS_I(dir), &name, mode, rdev, - xfs_create_need_xattr(dir, default_acl, acl), - &ip); + if (xfs_create_need_xattr(dir, default_acl, acl)) + args.flags |= XFS_ICREATE_INIT_XATTRS; + + error = xfs_create(&args, &name, &ip); } else { - bool init_xattrs = false; + args.flags |= XFS_ICREATE_TMPFILE; /* - * If this temporary file will be linkable, set up the file - * with an attr fork to receive a parent pointer. + * If this temporary file will not be linkable, don't bother + * creating an attr fork to receive a parent pointer. */ - if (!(tmpfile->f_flags & O_EXCL) && - xfs_has_parent(XFS_I(dir)->i_mount)) - init_xattrs = true; + if (tmpfile->f_flags & O_EXCL) + args.flags |= XFS_ICREATE_UNLINKABLE; - error = xfs_create_tmpfile(idmap, XFS_I(dir), mode, - init_xattrs, &ip); + error = xfs_create_tmpfile(&args, &ip); } if (unlikely(error)) goto out_free_acl; |