Bug 1100568 - [barrier] O_SYNC writes from libgfapi are not barriered
Summary: [barrier] O_SYNC writes from libgfapi are not barriered
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Gluster Storage
Classification: Red Hat Storage
Component: core
Version: rhgs-3.0
Hardware: x86_64
OS: Linux
high
high
Target Milestone: ---
: RHGS 3.0.0
Assignee: Atin Mukherjee
QA Contact: SATHEESARAN
URL:
Whiteboard:
Depends On: 1090488
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-05-23 06:28 UTC by Atin Mukherjee
Modified: 2016-09-17 14:41 UTC (History)
9 users (show)

Fixed In Version: glusterfs-3.6.0.3-1.el6rhs
Doc Type: Bug Fix
Doc Text:
when barrier is enabled O_SYNC writes coming through gfapi were not getting blocked. Investigation revealed that code was checking the flag passed in argument instead of open fd's flag which was causing this problem.
Clone Of: 1090488
Environment:
Last Closed: 2014-09-22 19:39:15 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2014:1278 0 normal SHIPPED_LIVE Red Hat Storage Server 3.0 bug fix and enhancement update 2014-09-22 23:26:55 UTC

Description Atin Mukherjee 2014-05-23 06:28:16 UTC
+++ This bug was initially created as a clone of Bug #1090488 +++

Description of problem:
-----------------------
O_SYNC writes are barrier-ed with barrier feature.
This works well when the access mechanism is FUSE.
But not in the case of libgfapi access.

Version-Release number of selected component (if applicable):
-------------------------------------------------------------
mainline

How reproducible:
-----------------
Always

Steps to Reproduce:
-------------------
1. Write a C Program to write the file in O_SYNC mode using libgfapi access mechanism

Open the file :
glfs_fd_t fd2 = glfs_creat(fs1, file, O_WRONLY|O_SYNC, 0644);

Write to the file:
written = glfs_write( fd2, buffer, sizeof(buffer), 0 ); 

Actual results:
---------------
O_SYNC Writes are not getting blocked, when barrier is enabled

Expected results:
-----------------
O_SYNC writes should get blocked when barrier is enabled


Additional info:
----------------

Providing the test C Program which uses libgfapi to start O_SYNC writes :
#include "api/glfs.h"
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>

void barrier_owrite_test1( glfs_t *fs1, char *file) {
    int fd1;
    char buffer[256];
    glfs_fd_t *fd2;
    int written = 0;

    fd1 = open("/home/sas/smallfile", O_RDONLY);
    if( fd1 < 0 ) {
        printf( "Error:%s", strerror(errno) );
        return;
    }

    fd2 = glfs_open(fs1, file, O_WRONLY|O_SYNC|O_CREAT);
    if( fd2 == NULL ) {
        printf( "Error: %s\n",strerror(errno) );
        close( fd1 );
    }

    while( read(fd1,buffer,sizeof(buffer)) ) {
        written = glfs_write( fd2, buffer, sizeof(buffer), 0 );
        if( written <= 0 ) {
            printf( "Error: %s\n", strerror(errno) );
            break;
        }
    }
    close(fd1);
    glfs_close(fd2);
    fprintf( stdout, "file %s written with osync flag\n",file );
}

int main( int argc, char **argv )
{
    struct stat st = {0};
    int ret = -1;

    if ( argc != 3 ) {
        printf ("Usage: %s <volname> <hostname>\n", argv[0]);
        return -1;
    }

    glfs_t *fs = glfs_new (argv[1]);
    if (!fs) {
        fprintf (stderr, "glfs_new: returned NULL\n");
        return 1;
    }

    ret = glfs_set_volfile_server (fs, "tcp", argv[2], 24007);
    ret = glfs_set_logging (fs, "/tmp/gfapi-err.log", 7);
    ret = glfs_init (fs);

    // Below are the tests corresponding FOPS barriered
    barrier_fsync_test1(fs,argv[3]);

    glfs_fini(fs);
}

Information for compilation:
1. Install glusterfs-api and glusterfs-api-devel package
2. gcc -o <exe> $(pkg-config --libs --cflags glusterfs-api) <gfapi_app.c>

--- Additional comment from Anand Avati on 2014-04-24 08:42:54 EDT ---

REVIEW: http://review.gluster.org/7549 (glusterd-server : barrier O_SYNC write incorrect flag check) posted (#1) for review on master by Atin Mukherjee (amukherj)

--- Additional comment from Anand Avati on 2014-04-28 02:51:55 EDT ---

REVIEW: http://review.gluster.org/7549 (barrier : barrier O_SYNC write incorrect flag check) posted (#2) for review on master by Atin Mukherjee (amukherj)

--- Additional comment from Anand Avati on 2014-04-28 05:25:06 EDT ---

REVIEW: http://review.gluster.org/7549 (barrier : barrier O_SYNC write incorrect flag check) posted (#3) for review on master by Atin Mukherjee (amukherj)

--- Additional comment from Anand Avati on 2014-04-28 05:50:31 EDT ---

REVIEW: http://review.gluster.org/7549 (barrier : barrier O_SYNC write incorrect flag check) posted (#4) for review on master by Atin Mukherjee (amukherj)

--- Additional comment from Anand Avati on 2014-04-30 01:46:51 EDT ---

REVIEW: http://review.gluster.org/7549 (barrier : barrier O_SYNC write incorrect flag check) posted (#5) for review on master by Atin Mukherjee (amukherj)

--- Additional comment from Anand Avati on 2014-05-03 10:28:23 EDT ---

COMMIT: http://review.gluster.org/7549 committed in master by Vijay Bellur (vbellur) 
------
commit 11b0ea3d79445e3773d450132121387b67d7bc9a
Author: Atin Mukherjee <amukherj>
Date:   Wed Apr 23 17:21:41 2014 +0530

    barrier : barrier O_SYNC write incorrect flag check
    
    barrier_writev function was doing the following check to determine whether its a
    O_SYNC write or not:
            if (!(flags & O_SYNC))
    The problem here is this flag is not fd's flag and gfapi write does not copy
    open call fd's flag into write flag because of which O_SYNC writes were not
    getting barriered even if barrier was enabled.
    
    The check has been modified as:
            if (!(fd->flags & (O_SYNC | O_DSYNC)))
    
    Change-Id: I07b23852d150b81c7317100ca6d22d082ad897cd
    BUG: 1090488
    Signed-off-by: Atin Mukherjee <amukherj>
    Reviewed-on: http://review.gluster.org/7549
    Reviewed-by: Varun Shastry <vshastry>
    Reviewed-by: Santosh Pradhan <spradhan>
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Vijay Bellur <vbellur>

Comment 1 Atin Mukherjee 2014-05-23 06:34:09 UTC
RCA:

barrier_writev was checking passed in flags instead of fd's flag. Also the code didn't have O_DSYNC flag in this check.

Fix http://review.gluster.org/7549 is backported in downstream.

Comment 3 SATHEESARAN 2014-05-30 04:31:53 UTC
Tested with glusterfs -3.6.0.8-1.el6rhs
Volume type -  Distributed replicate volume with 2X2 bricks

O_SYNC writes using libgfapi are blocked when barrier was enabled on the volume.

marking this bug as verified

Comment 6 errata-xmlrpc 2014-09-22 19:39:15 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHEA-2014-1278.html


Note You need to log in before you can comment on or make changes to this bug.