aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/gfs2/inode.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index a0b53d3bd8fa..2af69056a9fd 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -663,7 +663,7 @@ static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip,
663 663
664static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, 664static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
665 unsigned int mode, dev_t dev, const char *symname, 665 unsigned int mode, dev_t dev, const char *symname,
666 unsigned int size) 666 unsigned int size, int excl)
667{ 667{
668 const struct qstr *name = &dentry->d_name; 668 const struct qstr *name = &dentry->d_name;
669 struct gfs2_holder ghs[2]; 669 struct gfs2_holder ghs[2];
@@ -683,6 +683,12 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
683 goto fail; 683 goto fail;
684 684
685 error = create_ok(dip, name, mode); 685 error = create_ok(dip, name, mode);
686 if ((error == -EEXIST) && S_ISREG(mode) && !excl) {
687 inode = gfs2_lookupi(dir, &dentry->d_name, 0);
688 gfs2_glock_dq_uninit(ghs);
689 d_instantiate(dentry, inode);
690 return IS_ERR(inode) ? PTR_ERR(inode) : 0;
691 }
686 if (error) 692 if (error)
687 goto fail_gunlock; 693 goto fail_gunlock;
688 694
@@ -760,24 +766,10 @@ fail:
760static int gfs2_create(struct inode *dir, struct dentry *dentry, 766static int gfs2_create(struct inode *dir, struct dentry *dentry,
761 int mode, struct nameidata *nd) 767 int mode, struct nameidata *nd)
762{ 768{
763 struct inode *inode; 769 int excl = 0;
764 int ret; 770 if (nd && (nd->flags & LOOKUP_EXCL))
765 771 excl = 1;
766 for (;;) { 772 return gfs2_create_inode(dir, dentry, S_IFREG | mode, 0, NULL, 0, excl);
767 ret = gfs2_create_inode(dir, dentry, S_IFREG | mode, 0, NULL, 0);
768 if (ret != -EEXIST || (nd && (nd->flags & LOOKUP_EXCL)))
769 return ret;
770
771 inode = gfs2_lookupi(dir, &dentry->d_name, 0);
772 if (inode) {
773 if (!IS_ERR(inode))
774 break;
775 return PTR_ERR(inode);
776 }
777 }
778
779 d_instantiate(dentry, inode);
780 return 0;
781} 773}
782 774
783/** 775/**
@@ -1135,7 +1127,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
1135 if (size > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode) - 1) 1127 if (size > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode) - 1)
1136 return -ENAMETOOLONG; 1128 return -ENAMETOOLONG;
1137 1129
1138 return gfs2_create_inode(dir, dentry, S_IFLNK | S_IRWXUGO, 0, symname, size); 1130 return gfs2_create_inode(dir, dentry, S_IFLNK | S_IRWXUGO, 0, symname, size, 0);
1139} 1131}
1140 1132
1141/** 1133/**
@@ -1149,7 +1141,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
1149 1141
1150static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode) 1142static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
1151{ 1143{
1152 return gfs2_create_inode(dir, dentry, S_IFDIR | mode, 0, NULL, 0); 1144 return gfs2_create_inode(dir, dentry, S_IFDIR | mode, 0, NULL, 0, 0);
1153} 1145}
1154 1146
1155/** 1147/**
@@ -1164,7 +1156,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
1164static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, 1156static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode,
1165 dev_t dev) 1157 dev_t dev)
1166{ 1158{
1167 return gfs2_create_inode(dir, dentry, mode, dev, NULL, 0); 1159 return gfs2_create_inode(dir, dentry, mode, dev, NULL, 0, 0);
1168} 1160}
1169 1161
1170/* 1162/*