[PVFS2-CVS]
commit by slang in pvfs2/src/io/trove/trove-dbpf: dbpf-attr-cache.c
dbpf-bstream.c dbpf-dspace.c dbpf-keyval.c dbpf-mgmt.c
dbpf-open-cache.c dbpf.h
CVS commit program
cvs at parl.clemson.edu
Wed Nov 9 20:27:06 EST 2005
Update of /projects/cvsroot/pvfs2/src/io/trove/trove-dbpf
In directory parlweb:/tmp/cvs-serv439/src/io/trove/trove-dbpf
Modified Files:
dbpf-attr-cache.c dbpf-bstream.c dbpf-dspace.c dbpf-keyval.c
dbpf-mgmt.c dbpf-open-cache.c dbpf.h
Log Message:
* malloc.h is obsolete in freebsd, check for it
* No error.h in freebsd
* linux allows Lu,Lx, and Ld to be interchangeable with llu,llx, and
lld. Other platforms (solaris, bsd) don't. Replaced all the L*
with ll*.
* bsd doesn't have mntent.h. use fstab.h and our own funcs.
* bsd doesn't know about ssize_t. Use size_t instead.
* bsd doesn't have asm errnos. Check for each of those
errno macros and if not defined define to -1
* check for db3/db.h db4/db.h header if db path is specified using
--with-db
* darwin has aio support builtin, doesn't need -lrt
* remove kernel stuff in pvfs2-types.h that sets WORDSIZE. gcc
defines __LP64__ on archs with 64bit longs so we use that instead.
* darwin's open doesn't accept O_LARGEFILE. off_t is an int64 by
default. define O_LARGEFILE if it hasn't been.
* need to run ranlib on darwin after libpvfs2.a gets installed to regenerate
table of contents
Index: dbpf-attr-cache.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/trove/trove-dbpf/dbpf-attr-cache.c,v
diff -p -u -r1.17 -r1.18
--- dbpf-attr-cache.c 29 Sep 2005 19:23:14 -0000 1.17
+++ dbpf-attr-cache.c 10 Nov 2005 01:27:06 -0000 1.18
@@ -195,8 +195,8 @@ dbpf_attr_cache_elem_t *dbpf_attr_cache_
gossip_debug(
GOSSIP_DBPF_ATTRCACHE_DEBUG,
"dbpf_cache_elem_lookup: cache "
- "elem matching %Lu returned (num_elems=%d)\n",
- Lu(key.handle), s_current_num_cache_elems);
+ "elem matching %llu returned (num_elems=%d)\n",
+ llu(key.handle), s_current_num_cache_elems);
}
}
return cache_elem;
@@ -216,8 +216,8 @@ int dbpf_attr_cache_ds_attr_update_cache
memcpy(&cache_elem->attr, src_ds_attr,
sizeof(TROVE_ds_attributes));
gossip_debug(GOSSIP_DBPF_ATTRCACHE_DEBUG, "Updating "
- "cached attributes for key %Lu\n",
- Lu(key.handle));
+ "cached attributes for key %llu\n",
+ llu(key.handle));
ret = 0;
}
}
@@ -237,8 +237,8 @@ int dbpf_attr_cache_ds_attr_update_cache
{
cache_elem->attr.k_size = k_size;
gossip_debug(GOSSIP_DBPF_ATTRCACHE_DEBUG, "Updating "
- "cached k_size for key %Lu\n",
- Lu(key.handle));
+ "cached k_size for key %llu\n",
+ llu(key.handle));
ret = 0;
}
}
@@ -258,8 +258,8 @@ int dbpf_attr_cache_ds_attr_update_cache
{
cache_elem->attr.b_size = b_size;
gossip_debug(GOSSIP_DBPF_ATTRCACHE_DEBUG, "Updating "
- "cached b_size for key %Lu\n",
- Lu(key.handle));
+ "cached b_size for key %llu\n",
+ llu(key.handle));
ret = 0;
}
}
@@ -304,9 +304,9 @@ dbpf_keyval_pair_cache_elem_t *dbpf_attr
{
gossip_debug(
GOSSIP_DBPF_ATTRCACHE_DEBUG, "Returning data %p "
- "based on key %Lu and key_str %s (data_sz=%d)\n",
+ "based on key %llu and key_str %s (data_sz=%d)\n",
cache_elem->keyval_pairs[i].data,
- Lu(cache_elem->key.handle), key,
+ llu(cache_elem->key.handle), key,
cache_elem->keyval_pairs[i].data_sz);
return &cache_elem->keyval_pairs[i];
}
@@ -335,8 +335,8 @@ int dbpf_attr_cache_elem_set_data_based_
gossip_debug(
GOSSIP_DBPF_ATTRCACHE_DEBUG,
"Setting data %p based on key "
- "%Lu and key_str %s (data_sz=%d)\n", data,
- Lu(key.handle), key_str, data_sz);
+ "%llu and key_str %s (data_sz=%d)\n", data,
+ llu(key.handle), key_str, data_sz);
if (cache_elem->keyval_pairs[i].data)
{
@@ -425,8 +425,8 @@ int dbpf_attr_cache_insert(
assert(sacrificial_lamb_key.handle != TROVE_HANDLE_NULL);
gossip_debug(
GOSSIP_DBPF_ATTRCACHE_DEBUG, "*** Cache is full -- "
- "removing key %Lu to insert key %Lu\n",
- Lu(sacrificial_lamb_key.handle), Lu(key.handle));
+ "removing key %llu to insert key %llu\n",
+ llu(sacrificial_lamb_key.handle), llu(key.handle));
dbpf_attr_cache_remove(sacrificial_lamb_key);
}
@@ -473,10 +473,10 @@ int dbpf_attr_cache_insert(
s_current_num_cache_elems++;
gossip_debug(
GOSSIP_DBPF_ATTRCACHE_DEBUG,
- "dbpf_attr_cache_insert: inserting %Lu "
- "(k_size is %Lu | b_size is %Lu)\n", Lu(key.handle),
- Lu(cache_elem->attr.k_size),
- Lu(cache_elem->attr.b_size));
+ "dbpf_attr_cache_insert: inserting %llu "
+ "(k_size is %llu | b_size is %llu)\n", llu(key.handle),
+ llu(cache_elem->attr.k_size),
+ llu(cache_elem->attr.b_size));
}
ret = 0;
}
@@ -501,7 +501,7 @@ int dbpf_attr_cache_remove(TROVE_object_
gossip_debug(
GOSSIP_DBPF_ATTRCACHE_DEBUG, "dbpf_attr_cache_remove: "
- "removing %Lu\n", Lu(key.handle));
+ "removing %llu\n", llu(key.handle));
/* free any keyval data cached as well */
if (s_cacheable_keyword_array)
Index: dbpf-bstream.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/trove/trove-dbpf/dbpf-bstream.c,v
diff -p -u -r1.56 -r1.57
--- dbpf-bstream.c 29 Sep 2005 19:23:14 -0000 1.56
+++ dbpf-bstream.c 10 Nov 2005 01:27:06 -0000 1.57
@@ -9,7 +9,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <stdlib.h>
+#ifdef HAVE_MALLOC_H
#include <malloc.h>
+#endif
#include <assert.h>
#include <errno.h>
@@ -86,7 +89,7 @@ static void aio_progress_notification(si
gossip_debug(
GOSSIP_TROVE_DEBUG," --- aio_progress_notification called "
- "with handle %Lu\n", Lu(op_p->handle));
+ "with handle %llu\n", llu(op_p->handle));
aiocb_p = op_p->u.b_rw_list.aiocb_array;
assert(aiocb_p);
@@ -297,8 +300,8 @@ static void start_delayed_ops_if_any(int
s_dbpf_ios_in_progress++;
gossip_debug(GOSSIP_TROVE_DEBUG, "%s: lio_listio posted %p "
- "(handle %Lu, ret %d))\n", __func__, cur_op,
- Lu(cur_op->op.handle), ret);
+ "(handle %llu, ret %d))\n", __func__, cur_op,
+ llu(cur_op->op.handle), ret);
#ifndef __PVFS2_TROVE_AIO_THREADED__
/*
@@ -373,8 +376,8 @@ static int issue_or_delay_io_operation(
return -trove_errno_to_trove_error(errno);
}
gossip_debug(GOSSIP_TROVE_DEBUG, "%s: lio_listio posted %p "
- "(handle %Lu, ret %d)\n", __func__, cur_op,
- Lu(cur_op->op.handle), ret);
+ "(handle %llu, ret %d)\n", __func__, cur_op,
+ llu(cur_op->op.handle), ret);
}
return 0;
}
@@ -697,9 +700,9 @@ static int dbpf_bstream_resize_op_svc(st
goto return_error;
}
- gossip_debug(GOSSIP_TROVE_DEBUG, " RESIZED bstream %Lu [fd = %d] "
- "to %Ld \n", Lu(op_p->handle), tmp_ref.fd,
- Ld(op_p->u.b_resize.size));
+ gossip_debug(GOSSIP_TROVE_DEBUG, " RESIZED bstream %llu [fd = %d] "
+ "to %lld \n", llu(op_p->handle), tmp_ref.fd,
+ lld(op_p->u.b_resize.size));
dbpf_open_cache_put(&tmp_ref);
Index: dbpf-dspace.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/trove/trove-dbpf/dbpf-dspace.c,v
diff -p -u -r1.124 -r1.125
--- dbpf-dspace.c 25 Oct 2005 18:01:00 -0000 1.124
+++ dbpf-dspace.c 10 Nov 2005 01:27:06 -0000 1.125
@@ -10,7 +10,10 @@
#include <string.h>
#include <db.h>
#include <time.h>
+#include <stdlib.h>
+#ifdef HAVE_MALLOC_H
#include <malloc.h>
+#endif
#include <assert.h>
#include "gossip.h"
@@ -190,7 +193,7 @@ static int dbpf_dspace_create_op_svc(str
new_handle = cur_extent.first;
trove_handle_set_used(op_p->coll_p->coll_id, new_handle);
gossip_debug(GOSSIP_TROVE_DEBUG, "new_handle was FORCED "
- "to be %Lu\n", Lu(new_handle));
+ "to be %llu\n", llu(new_handle));
}
else if (cur_extent.first == TROVE_HANDLE_NULL)
{
@@ -211,11 +214,11 @@ static int dbpf_dspace_create_op_svc(str
op_p->coll_p->coll_id, &op_p->u.d_create.extent_array);
}
- gossip_debug(GOSSIP_TROVE_DEBUG, "[%d extents] -- new_handle is %Lu "
- "(cur_extent is %Lu - %Lu)\n",
+ gossip_debug(GOSSIP_TROVE_DEBUG, "[%d extents] -- new_handle is %llu "
+ "(cur_extent is %llu - %llu)\n",
op_p->u.d_create.extent_array.extent_count,
- Lu(new_handle), Lu(cur_extent.first),
- Lu(cur_extent.last));
+ llu(new_handle), llu(cur_extent.first),
+ llu(cur_extent.last));
/*
if we got a zero handle, we're either completely out of handles
-- or else something terrible has happened
@@ -360,7 +363,7 @@ static int dbpf_dspace_remove_op_svc(str
goto return_error;
case 0:
gossip_debug(GOSSIP_TROVE_DEBUG, "removed dataspace with "
- "handle %Lu\n", Lu(op_p->handle));
+ "handle %llu\n", llu(op_p->handle));
break;
}
@@ -507,8 +510,8 @@ static int dbpf_dspace_iterate_handles_o
else if (ret != 0)
{
ret = -dbpf_db_error_to_trove_error(ret);
- gossip_err("failed to set cursor position at %Lu\n",
- Lu(dummy_handle));
+ gossip_err("failed to set cursor position at %llu\n",
+ llu(dummy_handle));
goto return_error;
}
}
@@ -718,17 +721,17 @@ static int dbpf_dspace_getattr(TROVE_col
#if 0
gossip_debug(
GOSSIP_TROVE_DEBUG, "ATTRIB: retrieved "
- "attributes from CACHE for key %Lu\n uid = %d, mode = %d, "
+ "attributes from CACHE for key %llu\n uid = %d, mode = %d, "
"type = %d, dfile_count = %d, dist_size = %d\n",
- Lu(handle), (int)ds_attr_p->uid, (int)ds_attr_p->mode,
+ llu(handle), (int)ds_attr_p->uid, (int)ds_attr_p->mode,
(int)ds_attr_p->type, (int)ds_attr_p->dfile_count,
(int)ds_attr_p->dist_size);
#endif
gossip_debug(GOSSIP_DBPF_ATTRCACHE_DEBUG, "dspace_getattr fast "
- "path attr cache hit on %Lu\n (dfile_count=%d | "
- "dist_size=%d | data_size=%Ld)\n", Lu(handle),
+ "path attr cache hit on %llu\n (dfile_count=%d | "
+ "dist_size=%d | data_size=%lld)\n", llu(handle),
ds_attr_p->dfile_count, ds_attr_p->dist_size,
- Ld(ds_attr_p->b_size));
+ lld(ds_attr_p->b_size));
UPDATE_PERF_METADATA_READ();
gen_mutex_unlock(&dbpf_attr_cache_mutex);
@@ -833,9 +836,9 @@ static int dbpf_dspace_setattr_op_svc(st
#if 0
gossip_debug(GOSSIP_TROVE_DEBUG, "ATTRIB: dspace_setattr storing "
- "attributes (2) on key %Lu\n uid = %d, mode = %d, "
+ "attributes (2) on key %llu\n uid = %d, mode = %d, "
"type = %d, dfile_count = %d, dist_size = %d\n",
- Lu(op_p->handle), (int) s_attr.uid, (int) s_attr.mode,
+ llu(op_p->handle), (int) s_attr.uid, (int) s_attr.mode,
(int) s_attr.type, (int) s_attr.dfile_count,
(int) s_attr.dist_size);
#endif
@@ -934,8 +937,8 @@ static int dbpf_dspace_getattr_op_svc(st
}
else
{
- gossip_err("Error: unable to stat handle %Lu (%Lx).\n",
- Lu(op_p->handle), Lu(op_p->handle));
+ gossip_err("Error: unable to stat handle %llu (%llx).\n",
+ llu(op_p->handle), llu(op_p->handle));
ret = -TROVE_EIO;
goto return_error;
}
@@ -968,11 +971,11 @@ static int dbpf_dspace_getattr_op_svc(st
gossip_debug(
GOSSIP_TROVE_DEBUG, "ATTRIB: retrieved attributes "
- "from DISK for key %Lu\n\tuid = %d, mode = %d, type = %d, "
- "dfile_count = %d, dist_size = %d\n\tb_size = %Ld, k_size = %Ld\n",
- Lu(op_p->handle), (int)s_attr.uid, (int)s_attr.mode,
+ "from DISK for key %llu\n\tuid = %d, mode = %d, type = %d, "
+ "dfile_count = %d, dist_size = %d\n\tb_size = %lld, k_size = %lld\n",
+ llu(op_p->handle), (int)s_attr.uid, (int)s_attr.mode,
(int)s_attr.type, (int)s_attr.dfile_count, (int)s_attr.dist_size,
- Lu(b_size), Lu(k_size));
+ llu(b_size), llu(k_size));
attr = op_p->u.d_getattr.attr_p;
trove_ds_stored_to_attr(s_attr, *attr, b_size, k_size);
@@ -1013,7 +1016,7 @@ static int dbpf_dspace_cancel(
#endif
gossip_debug(GOSSIP_TROVE_DEBUG, "dbpf_dspace_cancel called for "
- "id %Lu.\n", Lu(id));
+ "id %llu.\n", llu(id));
#ifdef __PVFS2_TROVE_THREADED__
Index: dbpf-keyval.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/trove/trove-dbpf/dbpf-keyval.c,v
diff -p -u -r1.53 -r1.54
--- dbpf-keyval.c 27 Oct 2005 18:43:08 -0000 1.53
+++ dbpf-keyval.c 10 Nov 2005 01:27:06 -0000 1.54
@@ -23,7 +23,10 @@
#include <string.h>
#include <db.h>
#include <time.h>
+#include <stdlib.h>
+#ifdef HAVE_MALLOC_H
#include <malloc.h>
+#endif
#include "trove.h"
#include "trove-internal.h"
@@ -144,8 +147,8 @@ static int dbpf_keyval_read_op_svc(struc
if (ret != 0)
{
gossip_debug(GOSSIP_TROVE_DEBUG,
- "warning: keyval read error on handle %Lu and "
- "key=%s (%s)\n", Lu(op_p->handle),
+ "warning: keyval read error on handle %llu and "
+ "key=%s (%s)\n", llu(op_p->handle),
(char *)key.data, db_strerror(ret));
/* if data buffer is too small returns a memory error */
Index: dbpf-mgmt.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/trove/trove-dbpf/dbpf-mgmt.c,v
diff -p -u -r1.63 -r1.64
--- dbpf-mgmt.c 18 Oct 2005 18:37:28 -0000 1.63
+++ dbpf-mgmt.c 10 Nov 2005 01:27:06 -0000 1.64
@@ -15,10 +15,44 @@
#include <string.h>
#include <db.h>
#include <time.h>
+#include <stdlib.h>
+#include "trove.h"
+
+#ifdef HAVE_MALLOC_H
#include <malloc.h>
+#endif
+
+#ifdef HAVE_SYS_VFS_H
+
+#include <sys/vfs.h>
+#define PINT_statfs_t struct statfs
+#define PINT_statfs_lookup(_path, _statfs) statfs(_path, (_statfs))
+#define PINT_statfs_bsize(_statfs) (_statfs)->f_bsize
+#define PINT_statfs_bavail(_statfs) (_statfs)->f_bavail
+#define PINT_statfs_bfree(_statfs) (_statfs)->f_bfree
+#define PINT_statfs_blocks(_statfs) (_statfs)->f_blocks
+
+#elif HAVE_SYS_MOUNT_H
+
+#include <sys/param.h>
+#include <sys/mount.h>
+
+#define PINT_statfs_t struct statfs
+#define PINT_statfs_lookup(_path, _statfs) statfs(_path, (_statfs))
+#define PINT_statfs_bsize(_statfs) (_statfs)->f_iosize
+#define PINT_statfs_bavail(_statfs) (_statfs)->f_bavail
+#define PINT_statfs_bfree(_statfs) (_statfs)->f_bfree
+#define PINT_statfs_blocks(_statfs) (_statfs)->f_blocks
+
+#else
+
+#error OS does not have sys/vfs.h or sys/mount.h.
+#error Cant stat mounted filesystems
+
+#endif
+
#include <errno.h>
#include <limits.h>
-#include <sys/vfs.h>
#include <dirent.h>
#include "trove.h"
@@ -95,11 +129,11 @@ static int dbpf_collection_getinfo(TROVE
case PVFS_COLLECTION_STATFS:
{
char path_name[PATH_MAX] = {0};
- struct statfs tmp_statfs;
+ PINT_statfs_t tmp_statfs;
TROVE_statfs *tmp_trove_statfs = (TROVE_statfs *)parameter;
DBPF_GET_STORAGE_DIRNAME(path_name, PATH_MAX, sto_p->name);
- ret = statfs(path_name, &tmp_statfs);
+ ret = PINT_statfs_lookup(path_name, &tmp_statfs);
if (ret < 0)
{
ret = -trove_errno_to_trove_error(errno);
@@ -113,11 +147,13 @@ static int dbpf_collection_getinfo(TROVE
both so that the client can properly compute all values.
*/
tmp_trove_statfs->bytes_available =
- (tmp_statfs.f_bsize * tmp_statfs.f_bavail);
+ (PINT_statfs_bsize(&tmp_statfs) *
+ PINT_statfs_bavail(&tmp_statfs));
tmp_trove_statfs->bytes_total =
- (tmp_statfs.f_bsize *
- (tmp_statfs.f_blocks -
- (tmp_statfs.f_bfree - tmp_statfs.f_bavail)));
+ (PINT_statfs_bsize(&tmp_statfs) *
+ (PINT_statfs_blocks(&tmp_statfs) -
+ PINT_statfs_bfree(&tmp_statfs) -
+ PINT_statfs_bavail(&tmp_statfs)));
return 1;
}
Index: dbpf-open-cache.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/trove/trove-dbpf/dbpf-open-cache.c,v
diff -p -u -r1.13 -r1.14
--- dbpf-open-cache.c 17 Sep 2004 21:15:43 -0000 1.13
+++ dbpf-open-cache.c 10 Nov 2005 01:27:06 -0000 1.14
@@ -487,7 +487,7 @@ int dbpf_open_cache_remove(
tmp_error = 0;
DBPF_GET_BSTREAM_FILENAME(filename, PATH_MAX,
- my_storage_p->name, coll_id, Lu(handle));
+ my_storage_p->name, coll_id, llu(handle));
ret = DBPF_UNLINK(filename);
if ((ret != 0) && (errno != ENOENT))
@@ -529,11 +529,11 @@ static int open_fd(
char filename[PATH_MAX] = {0};
gossip_debug(GOSSIP_DBPF_OPEN_CACHE_DEBUG,
- "dbpf_open_cache open_fd: opening fd %Lu, create: %d\n",
- Lu(handle), create_flag);
+ "dbpf_open_cache open_fd: opening fd %llu, create: %d\n",
+ llu(handle), create_flag);
DBPF_GET_BSTREAM_FILENAME(filename, PATH_MAX,
- my_storage_p->name, coll_id, Lu(handle));
+ my_storage_p->name, coll_id, llu(handle));
*fd = DBPF_OPEN(filename, O_RDWR, 0);
@@ -554,8 +554,8 @@ static int open_db(
char filename[PATH_MAX] = {0};
gossip_debug(GOSSIP_DBPF_OPEN_CACHE_DEBUG,
- "dbpf_open_cache open_db: opening db %Lu (%Lx).\n",
- Lu(handle), Lu(handle));
+ "dbpf_open_cache open_db: opening db %llu (%llx).\n",
+ llu(handle), llu(handle));
/* special case; ds attrib database */
if (handle == TROVE_HANDLE_NULL)
@@ -567,7 +567,7 @@ static int open_db(
{
/* normal case; keyval db */
DBPF_GET_KEYVAL_DBNAME(filename, PATH_MAX,
- my_storage_p->name, coll_id, Lu(handle));
+ my_storage_p->name, coll_id, llu(handle));
}
ret = db_create(db_pp, NULL, 0);
Index: dbpf.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/trove/trove-dbpf/dbpf.h,v
diff -p -u -r1.56 -r1.57
--- dbpf.h 27 Oct 2005 18:43:08 -0000 1.56
+++ dbpf.h 10 Nov 2005 01:27:06 -0000 1.57
@@ -119,17 +119,17 @@ do {
/* arguments are: buf, path_max, stoname, collid, handle */
#define DBPF_GET_BSTREAM_FILENAME(__b, __pm, __stoname, __cid, __handle) \
do { \
- snprintf(__b, __pm, "/%s/%08x/%s/%.8Lu/%08Lx.bstream", \
+ snprintf(__b, __pm, "/%s/%08x/%s/%.8llu/%08llx.bstream", \
__stoname, __cid, BSTREAM_DIRNAME, \
- Lu(DBPF_BSTREAM_GET_BUCKET(__handle, __cid)), Lu(__handle)); \
+ llu(DBPF_BSTREAM_GET_BUCKET(__handle, __cid)), llu(__handle)); \
} while (0)
/* arguments are: buf, path_max, stoname, collid, handle */
#define DBPF_GET_KEYVAL_DBNAME(__b, __pm, __stoname, __cid, __handle) \
do { \
- snprintf(__b, __pm, "/%s/%08x/%s/%.8Lu/%08Lx.keyval", __stoname, \
+ snprintf(__b, __pm, "/%s/%08x/%s/%.8llu/%08llx.keyval", __stoname, \
__cid, KEYVAL_DIRNAME, \
- Lu(DBPF_KEYVAL_GET_BUCKET(__handle, __cid)), Lu(__handle)); \
+ llu(DBPF_KEYVAL_GET_BUCKET(__handle, __cid)), llu(__handle)); \
} while (0)
extern struct TROVE_bstream_ops dbpf_bstream_ops;
More information about the PVFS2-CVS
mailing list