Bug 762557 (GLUSTER-825)

Summary: when create() races both return success
Product: [Community] GlusterFS Reporter: Krishna Srinivas <krishna>
Component: posixAssignee: Raghavendra Bhat <rabhat>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: high    
Version: mainlineCC: amarts, gluster-bugs
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Krishna Srinivas 2010-04-16 23:27:59 UTC
On client side:
[2010-04-16 11:54:19] W [fuse-bridge.c:1913:fuse_writev_cbk] glusterfs-fuse: 575442787: WRITE => -1 (Operation not permitted)
[2010-04-16 11:54:19] W [fuse-bridge.c:1174:fuse_err_cbk] glusterfs-fuse: 575442788: FLUSH() ERR => -1 (Operation not permitted)

On server side:
[2010-04-16 11:54:07] E [posix.c:2245:posix_create] brick-posix: open on /clients/csb-archive/NAS-backup/mnt/scippy_images/00018212/00029288/00090152/DICOMDI
R failed: File exists

Looking at posix.c:

        op_ret = posix_lstat_with_gen (this, real_path, &stbuf);
        if ((op_ret == -1) && (errno == ENOENT)) {
                was_present = 0;
        }

        if (priv->o_direct)
                _flags |= O_DIRECT;

        _fd = open (real_path, _flags, mode);

        if (_fd == -1) {
                op_errno = errno;
                gf_log (this->name, GF_LOG_ERROR,
                        "open on %s failed: %s", loc->path,
                        strerror (op_errno));
                goto out;
        }


When open() fails op_ret is still 0 because previous posix_lstat_with_gen() returns 0
Hence when STACK_UNWIND is done it returns op_ret as 0. Application thinks create succeeded but when it calls write, fd_ctx_get returns -1, This -(-1) = 1 is EPERM is returned as op_errno by posix_writev which is Operation not permitted which is the error seen in fuse-bridge log on the client side.

Comment 1 Anand Avati 2010-04-27 06:38:13 UTC
PATCH: http://patches.gluster.com/patch/3170 in master (Set op_ret to -1 when open fails in posix_create)

Comment 2 Anand Avati 2010-04-27 06:38:29 UTC
PATCH: http://patches.gluster.com/patch/3169 in release-3.0 (Set op_ret to -1 when open fails in posix create)