Login
Log in using an SSO provider:
Fedora Account System
Red Hat Associate
Red Hat Customer
Login using a Red Hat Bugzilla account
Forgot Password
Create an Account
Red Hat Bugzilla – Attachment 1491665 Details for
Bug 1463192
gfapi: discard glfs object when volume is deleted
Home
New
Search
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh90 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
[?]
This site requires JavaScript to be enabled to function correctly, please enable it.
Small test program
test-volume-recreate.c (text/plain), 4.30 KB, created by
Niels de Vos
on 2018-10-08 13:49:58 UTC
(
hide
)
Description:
Small test program
Filename:
MIME Type:
Creator:
Niels de Vos
Created:
2018-10-08 13:49:58 UTC
Size:
4.30 KB
patch
obsolete
>#include <fcntl.h> >#include <unistd.h> >#include <time.h> >#include <limits.h> >#include <string.h> >#include <stdio.h> >#include <stdlib.h> >#include <errno.h> >#include <glusterfs/api/glfs.h> >#include <glusterfs/api/glfs-handles.h> > >#define LOG_ERR(func, ret) \ > do { \ > if (ret != 0) { \ > fprintf(stderr, "%s : returned error %d (%s)\n", func, ret, \ > strerror(errno)); \ > goto out; \ > } else { \ > fprintf(stderr, "%s : returned %d\n", func, ret); \ > } \ > } while (0) > >static void >volume_create(char *hostname, char *volname, char *brick) >{ > char cmd[512]; > > /* delete any remaining contents on the brick */ > sprintf(cmd, "rm -rf %s", brick); > system(cmd); > > sprintf(cmd, "mkdir -p %s", brick); > system(cmd); > > sprintf(cmd, "gluster --mode=script volume create %s %s:%s force", volname, hostname, brick); > system(cmd); > > sprintf(cmd, "gluster --mode=script volume start %s", volname); > system(cmd); >} > >static void >volume_delete(char *volname) >{ > char cmd[512]; > > sprintf(cmd, "gluster --mode=script volume stop %s", volname); > system(cmd); > > sprintf(cmd, "gluster --mode=script volume delete %s", volname); > system(cmd); >} > >int >main(int argc, char *argv[]) >{ > int ret = 0; > glfs_t *fs = NULL; > struct glfs_object *root = NULL, *file_obj = NULL; > struct stat sb = { > 0, > }; > char readbuf[32], writebuf[32]; > char *filename = "file.txt"; > char *logfile = NULL; > char *volname = NULL; > char *hostname = NULL; > > if (argc != 4) { > fprintf(stderr, "Invalid argument\n"); > exit(1); > } > > hostname = argv[1]; > volname = argv[2]; > logfile = argv[3]; > > volume_create(hostname, volname, "/bricks/1st_vol"); > > fs = glfs_new(volname); > if (!fs) { > fprintf(stderr, "glfs_new: returned NULL\n"); > ret = -1; > } > > ret = glfs_set_volfile_server(fs, "tcp", hostname, 24007); > LOG_ERR("glfs_set_volfile_server", ret); > > ret = glfs_set_logging(fs, logfile, 7); > LOG_ERR("glfs_set_logging", ret); > > ret = glfs_init(fs); > LOG_ERR("glfs_init", ret); > > root = glfs_h_lookupat(fs, NULL, "/", &sb, 0); > if (root == NULL) { > fprintf(stderr, "glfs_h_lookupat: error on lookup of / ,%s\n", > strerror(errno)); > goto out; > } > > file_obj = glfs_h_creat(fs, root, filename, O_CREAT, 0644, &sb); > if (file_obj == NULL) { > fprintf(stderr, "glfs_h_creat: error on create of %s: from (%p),%s\n", > filename, root, strerror(errno)); > goto out; > } > > /* test read/write based on anonymous fd */ > memcpy(writebuf, "abcdefghijklmnopqrstuvwxyz012345", 32); > > ret = glfs_h_anonymous_write(fs, file_obj, writebuf, 32, 0); > if (ret < 0) > LOG_ERR("glfs_h_anonymous_write", ret); > > ret = glfs_h_anonymous_read(fs, file_obj, readbuf, 32, 0); > if (ret < 0) > LOG_ERR("glfs_h_anonymous_read", ret); > > if (memcmp(readbuf, writebuf, 32)) { > fprintf(stderr, "Failed to read what I wrote: %s %s\n", readbuf, > writebuf); > ret = -1; > goto out; > } > > volume_delete(volname); > volume_create(hostname, volname, "/bricks/2nd_vol"); > > /* sleep to allow reconnecting */ > sleep(10); > > ret = glfs_h_anonymous_write(fs, file_obj, writebuf, 32, 0); > if (ret < 0) > LOG_ERR("glfs_h_anonymous_write", ret); > > ret = glfs_h_anonymous_read(fs, file_obj, readbuf, 32, 0); > if (ret < 0) > LOG_ERR("glfs_h_anonymous_read", ret); > > if (memcmp(readbuf, writebuf, 32)) { > fprintf(stderr, "Failed to read what I wrote: %s %s\n", readbuf, > writebuf); > ret = -1; > goto out; > } > > ret = 0; >out: > if (file_obj) > glfs_h_close(file_obj); > > if (fs) { > ret = glfs_fini(fs); > fprintf(stderr, "glfs_fini(fs) returned %d \n", ret); > } > if (ret) > exit(1); > exit(0); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1463192
: 1491665