storage/bd: Fix allocations/deallocations
Change-Id: I39c9eb083fc1c144fe6f011dd983b877fbbff0f7 BUG: 1075717 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/7230 Reviewed-by: Anand Avati <avati@redhat.com> Tested-by: Anand Avati <avati@redhat.com>
This commit is contained in:
parent
0ddd69a60e
commit
40b0bf5fc0
@ -7,7 +7,7 @@ LIBBD = -llvm2app -lrt
|
||||
bd_la_SOURCES = bd.c bd-helper.c bd-aio.c
|
||||
bd_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la $(LIBBD) $(LIBAIO)
|
||||
|
||||
noinst_HEADERS = bd.h bd-aio.h
|
||||
noinst_HEADERS = bd.h bd-aio.h bd-mem-types.h
|
||||
|
||||
AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \
|
||||
-I$(top_srcdir)/rpc/xdr/src \
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#ifdef HAVE_LIBAIO
|
||||
#include <libaio.h>
|
||||
#include "bd-mem-types.h"
|
||||
|
||||
struct bd_aio_cb {
|
||||
struct iocb iocb;
|
||||
@ -187,7 +188,7 @@ bd_aio_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
|
||||
goto err;
|
||||
}
|
||||
|
||||
paiocb = CALLOC (1, sizeof (*paiocb));
|
||||
paiocb = GF_CALLOC (1, sizeof (*paiocb), gf_bd_aio_cb);
|
||||
if (!paiocb) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
@ -314,7 +315,7 @@ bd_aio_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
|
||||
|
||||
_fd = bd_fd->fd;
|
||||
|
||||
paiocb = CALLOC (1, sizeof (*paiocb));
|
||||
paiocb = GF_CALLOC (1, sizeof (*paiocb), gf_bd_aio_cb);
|
||||
if (!paiocb) {
|
||||
op_errno = ENOMEM;
|
||||
goto err;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <linux/fs.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "bd.h"
|
||||
#include "bd-mem-types.h"
|
||||
#include "run.h"
|
||||
|
||||
int
|
||||
@ -242,7 +243,7 @@ __bd_fd_ctx_get (xlator_t *this, fd_t *fd, bd_fd_t **bdfd_p)
|
||||
}
|
||||
|
||||
uuid_utoa_r (fd->inode->gfid, gfid);
|
||||
asprintf (&devpath, "/dev/%s/%s", priv->vg, gfid);
|
||||
gf_asprintf (&devpath, "/dev/%s/%s", priv->vg, gfid);
|
||||
if (!devpath)
|
||||
goto out;
|
||||
|
||||
@ -268,7 +269,7 @@ __bd_fd_ctx_get (xlator_t *this, fd_t *fd, bd_fd_t **bdfd_p)
|
||||
|
||||
ret = 0;
|
||||
out:
|
||||
FREE (devpath);
|
||||
GF_FREE (devpath);
|
||||
if (ret) {
|
||||
close (_fd);
|
||||
GF_FREE (bdfd);
|
||||
@ -701,8 +702,8 @@ out:
|
||||
if (fd2 != -1)
|
||||
close (fd2);
|
||||
|
||||
FREE (spath);
|
||||
FREE (dpath);
|
||||
GF_FREE (spath);
|
||||
GF_FREE (dpath);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
27
xlators/storage/bd/src/bd-mem-types.h
Normal file
27
xlators/storage/bd/src/bd-mem-types.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright (c) 2008-2014 Red Hat, Inc. <http://www.redhat.com>
|
||||
This file is part of GlusterFS.
|
||||
|
||||
This file is licensed to you under your choice of the GNU Lesser
|
||||
General Public License, version 3 or any later version (LGPLv3 or
|
||||
later), or the GNU General Public License, version 2 (GPLv2), in all
|
||||
cases as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __BD_MEM_TYPES_H__
|
||||
#define __BD_MEM_TYPES_H__
|
||||
|
||||
#include "mem-types.h"
|
||||
|
||||
enum gf_bd_mem_types_ {
|
||||
gf_bd_private = gf_common_mt_end + 1,
|
||||
gf_bd_attr,
|
||||
gf_bd_fd,
|
||||
gf_bd_loc_t,
|
||||
gf_bd_int32_t,
|
||||
gf_bd_aio_cb,
|
||||
gf_bd_mt_end
|
||||
};
|
||||
|
||||
#endif
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "bd.h"
|
||||
#include "bd-aio.h"
|
||||
#include "bd-mem-types.h"
|
||||
#include "defaults.h"
|
||||
#include "glusterfs3-xdr.h"
|
||||
#include "run.h"
|
||||
@ -213,7 +214,7 @@ bd_forget (xlator_t *this, inode_t *inode)
|
||||
ret = bd_inode_ctx_get (inode, this, &bdatt);
|
||||
if (!ret) {
|
||||
inode_ctx_del (inode, this, &ctx);
|
||||
FREE (bdatt);
|
||||
GF_FREE (bdatt);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -236,7 +237,7 @@ bd_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
|
||||
entry->d_stat.ia_gfid, &type, &size)) {
|
||||
entry->d_stat.ia_size = size;
|
||||
entry->d_stat.ia_blocks = size / 512;
|
||||
FREE (type);
|
||||
GF_FREE (type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -653,7 +654,7 @@ bd_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
|
||||
goto posix;
|
||||
|
||||
uuid_utoa_r (fd->inode->gfid, gfid);
|
||||
asprintf (&devpath, "/dev/%s/%s", priv->vg, gfid);
|
||||
gf_asprintf (&devpath, "/dev/%s/%s", priv->vg, gfid);
|
||||
BD_VALIDATE_MEM_ALLOC (devpath, ret, out);
|
||||
|
||||
_fd = open (devpath, flags | O_LARGEFILE, 0);
|
||||
@ -688,7 +689,7 @@ posix:
|
||||
out:
|
||||
BD_STACK_UNWIND (open, frame, -1, ret, fd, NULL);
|
||||
|
||||
FREE (devpath);
|
||||
GF_FREE (devpath);
|
||||
if (ret) {
|
||||
close (_fd);
|
||||
GF_FREE (bd_fd);
|
||||
@ -1213,7 +1214,7 @@ bd_offload_dest_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
goto out;
|
||||
}
|
||||
|
||||
local->bdatt = CALLOC (1, sizeof (bd_attr_t));
|
||||
local->bdatt = GF_CALLOC (1, sizeof (bd_attr_t), gf_bd_attr);
|
||||
BD_VALIDATE_MEM_ALLOC (local->bdatt, op_errno, out);
|
||||
|
||||
STACK_WIND (frame, bd_offload_getx_cbk, FIRST_CHILD(this),
|
||||
@ -1303,7 +1304,7 @@ bd_offload (call_frame_t *frame, xlator_t *this, loc_t *loc,
|
||||
local->dict = dict_new ();
|
||||
BD_VALIDATE_MEM_ALLOC (local->dict, op_errno, out);
|
||||
|
||||
local->dloc = CALLOC (1, sizeof (loc_t));
|
||||
local->dloc = GF_CALLOC (1, sizeof (loc_t), gf_bd_loc_t);
|
||||
BD_VALIDATE_MEM_ALLOC (local->dloc, op_errno, out);
|
||||
|
||||
strncpy (param, local->data->data, local->data->len);
|
||||
@ -1923,7 +1924,7 @@ bd_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
|
||||
|
||||
memcpy (postbuf, &bdatt->iatt, sizeof (struct iatt));
|
||||
out:
|
||||
FREE (valid);
|
||||
GF_FREE (valid);
|
||||
BD_STACK_UNWIND (setattr, frame, op_ret, op_errno, prebuf,
|
||||
postbuf, xdata);
|
||||
return 0;
|
||||
@ -1948,7 +1949,7 @@ bd_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf,
|
||||
local = bd_local_init (frame, this);
|
||||
BD_VALIDATE_MEM_ALLOC (local, op_errno, out);
|
||||
|
||||
ck_valid = CALLOC (1, sizeof (valid));
|
||||
ck_valid = GF_CALLOC (1, sizeof (valid), gf_bd_int32_t);
|
||||
BD_VALIDATE_MEM_ALLOC (ck_valid, op_errno, out);
|
||||
|
||||
local->inode = inode_ref (loc->inode);
|
||||
@ -2268,6 +2269,7 @@ mem_acct_init (xlator_t *this)
|
||||
if (ret != 0)
|
||||
gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
|
||||
"failed");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -92,13 +92,6 @@
|
||||
|
||||
typedef char bd_gfid_t[GF_UUID_BUF_SIZE];
|
||||
|
||||
enum gf_bd_mem_types_ {
|
||||
gf_bd_private = gf_common_mt_end + 1,
|
||||
gf_bd_attr,
|
||||
gf_bd_fd,
|
||||
gf_bd_mt_end
|
||||
};
|
||||
|
||||
/**
|
||||
* bd_fd - internal structure
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user