]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
simplify gfs2_atomic_open()
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 12 Sep 2025 17:47:57 +0000 (13:47 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 17 Sep 2025 03:59:38 +0000 (23:59 -0400)
the difference from 9p et.al. is that on gfs2 the lookup side might
end up opening the file.  That's what the FMODE_OPENED check there
is about - and it might actually be seen with finish_open() having
failed, if it fails late enough.

Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/gfs2/inode.c

index 8760e7e20c9d842bf6f5ddca48386a162faaf47c..8a7ed80d9f2d6e829b240629bdd18b5e0d30b5fc 100644 (file)
@@ -1368,27 +1368,19 @@ static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry,
                            struct file *file, unsigned flags,
                            umode_t mode)
 {
-       struct dentry *d;
        bool excl = !!(flags & O_EXCL);
 
-       if (!d_in_lookup(dentry))
-               goto skip_lookup;
-
-       d = __gfs2_lookup(dir, dentry, file);
-       if (IS_ERR(d))
-               return PTR_ERR(d);
-       if (d != NULL)
-               dentry = d;
-       if (d_really_is_positive(dentry)) {
-               if (!(file->f_mode & FMODE_OPENED))
+       if (d_in_lookup(dentry)) {
+               struct dentry *d = __gfs2_lookup(dir, dentry, file);
+               if (file->f_mode & FMODE_OPENED) {
+                       if (IS_ERR(d))
+                               return PTR_ERR(d);
+                       dput(d);
+                       return excl && (flags & O_CREAT) ? -EEXIST : 0;
+               }
+               if (d || d_really_is_positive(dentry))
                        return finish_no_open(file, d);
-               dput(d);
-               return excl && (flags & O_CREAT) ? -EEXIST : 0;
        }
-
-       BUG_ON(d != NULL);
-
-skip_lookup:
        if (!(flags & O_CREAT))
                return -ENOENT;