Commit 482bd15f authored by ftessier's avatar ftessier
Browse files

Fix Lustre API issues with a local copy of header files and a patch for C++

parent 48f7d6dc
MPICXX = CC
MPI_CFLAGS = -g -O3 -I./topology/
MPI_CFLAGS += -DXC40 #-DDEBUG -DTIMING
MPI_CFLAGS = -g -O3 -I./topology/ -I./topology/include/
MPI_CFLAGS += -DXC40 -llustreapi #-DDEBUG -DTIMING
INSTALL_PATH = $(HOME)/install
......@@ -5,6 +5,10 @@
#include <stdlib.h>
#include "topology.hpp"
#include <pmi.h>
#include <lustre/lustreapi.h>
#include <lustre/lustre_user.h>
class Topology: public iTopology {
public:
/**********************/
......@@ -26,21 +30,48 @@ public:
int ProcessPerNode () {
return 0;
int ppn, err;
err = PMI_Get_numpes_on_smp ( &ppn );
if ( err != PMI_SUCCESS ) {
fprintf (stderr, "[ERROR] PMI_Get_numpes_on_smp failed!\n");
MPI_Abort (MPI_COMM_WORLD, -1);
}
return ppn;
}
/**********************/
/* |-- Network */
/**********************/
/*
* X : Rank 3 (Optics cables between groups : 12.5 Gbps)
* Y : Rank 2 (Copper cables between 6 backplanes : 14 Gbps)
* Z : Rank 1 (Copper cables between 16 aries routers in a backplane :14 Gbps)
* nid : Node identifier
*
* http://www.nersc.gov/users/computational-systems/edison/configuration/interconnect/
*
*/
int NetworkDimensions () {
return 0;
return 4;
}
/* |---- Coordinates */
void RankToCoordinates ( int rank, int* coord ) {
pmi_mesh_coord_t xyz;
int nid;
/* Hypothesis : PMI_rank == MPI_rank */
PMI_Get_nid(rank, &nid);
PMI_Get_meshcoord((pmi_nid_t) nid, &xyz);
coord[0] = xyz.mesh_x;
coord[1] = xyz.mesh_y;
coord[2] = xyz.mesh_z;
coord[3] = nid;
}
......
/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 only,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is included
* in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
* http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
* GPL HEADER END
*/
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
* Copyright (c) 2010, 2014, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
* Lustre is a trademark of Sun Microsystems, Inc.
*
* lustre/include/lustre/lustre_user.h
*
* Lustre public user-space interface definitions.
*/
#ifndef _LUSTRE_USER_H
#define _LUSTRE_USER_H
/** \defgroup lustreuser lustreuser
*
* @{
*/
#include <libcfs/types.h>
#ifdef __KERNEL__
# include <linux/quota.h>
# include <linux/string.h> /* snprintf() */
# include <linux/version.h>
#else /* !__KERNEL__ */
# define NEED_QUOTA_DEFS
# include <stdio.h> /* snprintf() */
# include <string.h>
# include <sys/quota.h>
# include <sys/stat.h>
#endif /* __KERNEL__ */
#include <lustre/ll_fiemap.h>
#if defined(__x86_64__) || defined(__ia64__) || defined(__ppc64__) || \
defined(__craynv) || defined(__mips64__) || defined(__powerpc64__)
typedef struct stat lstat_t;
# define lstat_f lstat
# define HAVE_LOV_USER_MDS_DATA
#elif defined(__USE_LARGEFILE64) || defined(__KERNEL__)
typedef struct stat64 lstat_t;
# define lstat_f lstat64
# define HAVE_LOV_USER_MDS_DATA
#endif
#define LUSTRE_EOF 0xffffffffffffffffULL
/* for statfs() */
#define LL_SUPER_MAGIC 0x0BD00BD0
#ifndef FSFILT_IOC_GETFLAGS
#define FSFILT_IOC_GETFLAGS _IOR('f', 1, long)
#define FSFILT_IOC_SETFLAGS _IOW('f', 2, long)
#define FSFILT_IOC_GETVERSION _IOR('f', 3, long)
#define FSFILT_IOC_SETVERSION _IOW('f', 4, long)
#define FSFILT_IOC_GETVERSION_OLD _IOR('v', 1, long)
#define FSFILT_IOC_SETVERSION_OLD _IOW('v', 2, long)
#endif
/* FIEMAP flags supported by Lustre */
#define LUSTRE_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_DEVICE_ORDER)
enum obd_statfs_state {
OS_STATE_DEGRADED = 0x00000001, /**< RAID degraded/rebuilding */
OS_STATE_READONLY = 0x00000002, /**< filesystem is read-only */
OS_STATE_RDONLY_1 = 0x00000004, /**< obsolete 1.6, was EROFS=30 */
OS_STATE_RDONLY_2 = 0x00000008, /**< obsolete 1.6, was EROFS=30 */
OS_STATE_RDONLY_3 = 0x00000010, /**< obsolete 1.6, was EROFS=30 */
};
struct obd_statfs {
__u64 os_type;
__u64 os_blocks;
__u64 os_bfree;
__u64 os_bavail;
__u64 os_files;
__u64 os_ffree;
__u8 os_fsid[40];
__u32 os_bsize;
__u32 os_namelen;
__u64 os_maxbytes;
__u32 os_state; /**< obd_statfs_state OS_STATE_* flag */
__u32 os_fprecreated; /* objs available now to the caller */
/* used in QoS code to find preferred
* OSTs */
__u32 os_spare2;
__u32 os_spare3;
__u32 os_spare4;
__u32 os_spare5;
__u32 os_spare6;
__u32 os_spare7;
__u32 os_spare8;
__u32 os_spare9;
};
/**
* File IDentifier.
*
* FID is a cluster-wide unique identifier of a file or an object (stripe).
* FIDs are never reused.
**/
struct lu_fid {
/**
* FID sequence. Sequence is a unit of migration: all files (objects)
* with FIDs from a given sequence are stored on the same server.
* Lustre should support 2^64 objects, so even if each sequence
* has only a single object we can still enumerate 2^64 objects.
**/
__u64 f_seq;
/* FID number within sequence. */
__u32 f_oid;
/**
* FID version, used to distinguish different versions (in the sense
* of snapshots, etc.) of the same file system object. Not currently
* used.
**/
__u32 f_ver;
};
static inline bool fid_is_zero(const struct lu_fid *fid)
{
return fid->f_seq == 0 && fid->f_oid == 0;
}
/* Currently, the filter_fid::ff_parent::f_ver is not the real parent
* MDT-object's FID::f_ver, instead it is the OST-object index in its
* parent MDT-object's layout EA. */
#define f_stripe_idx f_ver
struct filter_fid {
struct lu_fid ff_parent; /* ff_parent.f_ver == file stripe number */
};
/* keep this one for compatibility */
struct filter_fid_old {
struct lu_fid ff_parent;
__u64 ff_objid;
__u64 ff_seq;
};
/* Userspace should treat lu_fid as opaque, and only use the following methods
* to print or parse them. Other functions (e.g. compare, swab) could be moved
* here from lustre_idl.h if needed. */
typedef struct lu_fid lustre_fid;
/**
* Following struct for object attributes, that will be kept inode's EA.
* Introduced in 2.0 release (please see b15993, for details)
* Added to all objects since Lustre 2.4 as contains self FID
*/
struct lustre_mdt_attrs {
/**
* Bitfield for supported data in this structure. From enum lma_compat.
* lma_self_fid and lma_flags are always available.
*/
__u32 lma_compat;
/**
* Per-file incompat feature list. Lustre version should support all
* flags set in this field. The supported feature mask is available in
* LMA_INCOMPAT_SUPP.
*/
__u32 lma_incompat;
/** FID of this inode */
struct lu_fid lma_self_fid;
};
/**
* Prior to 2.4, the LMA structure also included SOM attributes which has since
* been moved to a dedicated xattr
* lma_flags was also removed because of lma_compat/incompat fields.
*/
#define LMA_OLD_SIZE (sizeof(struct lustre_mdt_attrs) + 5 * sizeof(__u64))
/**
* OST object IDentifier.
*/
struct ost_id {
union {
struct {
__u64 oi_id;
__u64 oi_seq;
} oi;
struct lu_fid oi_fid;
};
};
#define DOSTID LPX64":"LPU64
#define POSTID(oi) ostid_seq(oi), ostid_id(oi)
struct ll_futimes_3 {
__u64 lfu_atime_sec;
__u64 lfu_atime_nsec;
__u64 lfu_mtime_sec;
__u64 lfu_mtime_nsec;
__u64 lfu_ctime_sec;
__u64 lfu_ctime_nsec;
};
/*
* The ioctl naming rules:
* LL_* - works on the currently opened filehandle instead of parent dir
* *_OBD_* - gets data for both OSC or MDC (LOV, LMV indirectly)
* *_MDC_* - gets/sets data related to MDC
* *_LOV_* - gets/sets data related to OSC/LOV
* *FILE* - called on parent dir and passes in a filename
* *STRIPE* - set/get lov_user_md
* *INFO - set/get lov_user_mds_data
*/
/* lustre_ioctl.h 101-150 */
#define LL_IOC_GETFLAGS _IOR ('f', 151, long)
#define LL_IOC_SETFLAGS _IOW ('f', 152, long)
#define LL_IOC_CLRFLAGS _IOW ('f', 153, long)
#define LL_IOC_LOV_SETSTRIPE _IOW ('f', 154, long)
#define LL_IOC_LOV_GETSTRIPE _IOW ('f', 155, long)
#define LL_IOC_LOV_SETEA _IOW ('f', 156, long)
/* LL_IOC_RECREATE_OBJ 157 obsolete */
/* LL_IOC_RECREATE_FID 157 obsolete */
#define LL_IOC_GROUP_LOCK _IOW ('f', 158, long)
#define LL_IOC_GROUP_UNLOCK _IOW ('f', 159, long)
/* LL_IOC_QUOTACHECK 160 OBD_IOC_QUOTACHECK */
/* LL_IOC_POLL_QUOTACHECK 161 OBD_IOC_POLL_QUOTACHECK */
/* LL_IOC_QUOTACTL 162 OBD_IOC_QUOTACTL */
#define IOC_OBD_STATFS _IOWR('f', 164, struct obd_statfs *)
#define IOC_LOV_GETINFO _IOWR('f', 165, struct lov_user_mds_data *)
#define LL_IOC_FLUSHCTX _IOW ('f', 166, long)
#define LL_IOC_RMTACL _IOW ('f', 167, long)
#define LL_IOC_GETOBDCOUNT _IOR ('f', 168, long)
#define LL_IOC_LLOOP_ATTACH _IOWR('f', 169, long)
#define LL_IOC_LLOOP_DETACH _IOWR('f', 170, long)
#define LL_IOC_LLOOP_INFO _IOWR('f', 171, struct lu_fid)
#define LL_IOC_LLOOP_DETACH_BYDEV _IOWR('f', 172, long)
#define LL_IOC_PATH2FID _IOR ('f', 173, long)
#define LL_IOC_GET_CONNECT_FLAGS _IOWR('f', 174, __u64 *)
#define LL_IOC_GET_MDTIDX _IOR ('f', 175, int)
#define LL_IOC_FUTIMES_3 _IOWR('f', 176, struct ll_futimes_3)
/* lustre_ioctl.h 177-210 */
#define LL_IOC_HSM_STATE_GET _IOR('f', 211, struct hsm_user_state)
#define LL_IOC_HSM_STATE_SET _IOW('f', 212, struct hsm_state_set)
#define LL_IOC_HSM_CT_START _IOW('f', 213, struct lustre_kernelcomm)
#define LL_IOC_HSM_COPY_START _IOW('f', 214, struct hsm_copy *)
#define LL_IOC_HSM_COPY_END _IOW('f', 215, struct hsm_copy *)
#define LL_IOC_HSM_PROGRESS _IOW('f', 216, struct hsm_user_request)
#define LL_IOC_HSM_REQUEST _IOW('f', 217, struct hsm_user_request)
#define LL_IOC_DATA_VERSION _IOR('f', 218, struct ioc_data_version)
#define LL_IOC_LOV_SWAP_LAYOUTS _IOW('f', 219, \
struct lustre_swap_layouts)
#define LL_IOC_HSM_ACTION _IOR('f', 220, \
struct hsm_current_action)
/* lustre_ioctl.h 221-232 */
#define LL_IOC_LMV_SETSTRIPE _IOWR('f', 240, struct lmv_user_md)
#define LL_IOC_LMV_GETSTRIPE _IOWR('f', 241, struct lmv_user_md)
#define LL_IOC_REMOVE_ENTRY _IOWR('f', 242, __u64)
#define LL_IOC_SET_LEASE _IOWR('f', 243, long)
#define LL_IOC_GET_LEASE _IO('f', 244)
#define LL_IOC_HSM_IMPORT _IOWR('f', 245, struct hsm_user_import)
#define LL_IOC_LMV_SET_DEFAULT_STRIPE _IOWR('f', 246, struct lmv_user_md)
#define LL_IOC_MIGRATE _IOR('f', 247, int)
#define LL_IOC_FID2MDTIDX _IOWR('f', 248, struct lu_fid)
#define LL_IOC_GETPARENT _IOWR('f', 249, struct getparent)
#define LL_IOC_LOCK_AHEAD _IOWR('f', 251, \
struct llapi_lock_ahead_arg)
#define LL_IOC_REQUEST_ONLY _IO('f', 252)
/* Lease types for use as arg and return of LL_IOC_{GET,SET}_LEASE ioctl. */
enum ll_lease_type {
LL_LEASE_RDLCK = 0x1,
LL_LEASE_WRLCK = 0x2,
LL_LEASE_UNLCK = 0x4,
};
#define LL_STATFS_LMV 1
#define LL_STATFS_LOV 2
#define LL_STATFS_NODELAY 4
#define IOC_MDC_TYPE 'i'
#define IOC_MDC_LOOKUP _IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
#define IOC_MDC_GETFILESTRIPE _IOWR(IOC_MDC_TYPE, 21, struct lov_user_md *)
#define IOC_MDC_GETFILEINFO _IOWR(IOC_MDC_TYPE, 22, struct lov_user_mds_data *)
#define LL_IOC_MDC_GETINFO _IOWR(IOC_MDC_TYPE, 23, struct lov_user_mds_data *)
#define MAX_OBD_NAME 128 /* If this changes, a NEW ioctl must be added */
/* Define O_LOV_DELAY_CREATE to be a mask that is not useful for regular
* files, but are unlikely to be used in practice and are not harmful if
* used incorrectly. O_NOCTTY and FASYNC are only meaningful for character
* devices and are safe for use on new files. See LU-4209. */
/* To be compatible with old statically linked binary we keep the check for
* the older 0100000000 flag. This is already removed upstream. LU-812. */
#define O_LOV_DELAY_CREATE_1_8 0100000000 /* FMODE_NONOTIFY masked in 2.6.36 */
#define O_LOV_DELAY_CREATE_MASK (O_NOCTTY | FASYNC)
#define O_LOV_DELAY_CREATE (O_LOV_DELAY_CREATE_1_8 | \
O_LOV_DELAY_CREATE_MASK)
#define LL_FILE_IGNORE_LOCK 0x00000001
#define LL_FILE_GROUP_LOCKED 0x00000002
#define LL_FILE_READAHEA 0x00000004
#define LL_FILE_LOCKED_DIRECTIO 0x00000008 /* client-side locks with dio */
#define LL_FILE_LOCKLESS_IO 0x00000010 /* server-side locks with cio */
#define LL_FILE_RMTACL 0x00000020
#define LOV_USER_MAGIC_V1 0x0BD10BD0
#define LOV_USER_MAGIC LOV_USER_MAGIC_V1
#define LOV_USER_MAGIC_JOIN_V1 0x0BD20BD0
#define LOV_USER_MAGIC_V3 0x0BD30BD0
/* 0x0BD40BD0 is occupied by LOV_MAGIC_MIGRATE */
#define LOV_USER_MAGIC_SPECIFIC 0x0BD50BD0 /* for specific OSTs */
#define LMV_USER_MAGIC 0x0CD30CD0 /*default lmv magic*/
#define LOV_PATTERN_RAID0 0x001
#define LOV_PATTERN_RAID1 0x002
#define LOV_PATTERN_FIRST 0x100
#define LOV_PATTERN_CMOBD 0x200
#define LOV_PATTERN_F_MASK 0xffff0000
#define LOV_PATTERN_F_HOLE 0x40000000 /* there is hole in LOV EA */
#define LOV_PATTERN_F_RELEASED 0x80000000 /* HSM released file */
#define LOV_MAXPOOLNAME 15
#define LOV_POOLNAMEF "%.15s"
#define LOV_MIN_STRIPE_BITS 16 /* maximum PAGE_SIZE (ia64), power of 2 */
#define LOV_MIN_STRIPE_SIZE (1 << LOV_MIN_STRIPE_BITS)
#define LOV_MAX_STRIPE_COUNT_OLD 160
/* This calculation is crafted so that input of 4096 will result in 160
* which in turn is equal to old maximal stripe count.
* XXX: In fact this is too simpified for now, what it also need is to get
* ea_type argument to clearly know how much space each stripe consumes.
*
* The limit of 12 pages is somewhat arbitrary, but is a reasonably large
* allocation that is sufficient for the current generation of systems.
*
* (max buffer size - lov+rpc header) / sizeof(struct lov_ost_data_v1) */
#define LOV_MAX_STRIPE_COUNT 2000 /* ((12 * 4096 - 256) / 24) */
#define LOV_ALL_STRIPES 0xffff /* only valid for directories */
#define LOV_V1_INSANE_STRIPE_COUNT 65532 /* maximum stripe count bz13933 */
#define XATTR_LUSTRE_PREFIX "lustre."
#define XATTR_LUSTRE_LOV XATTR_LUSTRE_PREFIX"lov"
#define lov_user_ost_data lov_user_ost_data_v1
struct lov_user_ost_data_v1 { /* per-stripe data structure */
struct ost_id l_ost_oi; /* OST object ID */
__u32 l_ost_gen; /* generation of this OST index */
__u32 l_ost_idx; /* OST index in LOV */
} __attribute__((packed));
#define lov_user_md lov_user_md_v1
struct lov_user_md_v1 { /* LOV EA user data (host-endian) */
__u32 lmm_magic; /* magic number = LOV_USER_MAGIC_V1 */
__u32 lmm_pattern; /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
struct ost_id lmm_oi; /* LOV object ID */
__u32 lmm_stripe_size; /* size of stripe in bytes */
__u16 lmm_stripe_count; /* num stripes in use for this object */
union {
__u16 lmm_stripe_offset; /* starting stripe offset in
* lmm_objects, use when writing */
__u16 lmm_layout_gen; /* layout generation number
* used when reading */
};
struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
} __attribute__((packed, __may_alias__));
struct lov_user_md_v3 { /* LOV EA user data (host-endian) */
__u32 lmm_magic; /* magic number = LOV_USER_MAGIC_V3 */
__u32 lmm_pattern; /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
struct ost_id lmm_oi; /* LOV object ID */
__u32 lmm_stripe_size; /* size of stripe in bytes */
__u16 lmm_stripe_count; /* num stripes in use for this object */
union {
__u16 lmm_stripe_offset; /* starting stripe offset in
* lmm_objects, use when writing */
__u16 lmm_layout_gen; /* layout generation number
* used when reading */
};
char lmm_pool_name[LOV_MAXPOOLNAME + 1]; /* pool name */
struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
} __attribute__((packed));
static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic)
{
if (lmm_magic == LOV_USER_MAGIC_V1)
return sizeof(struct lov_user_md_v1) +
stripes * sizeof(struct lov_user_ost_data_v1);
return sizeof(struct lov_user_md_v3) +
stripes * sizeof(struct lov_user_ost_data_v1);
}
/* Compile with -D_LARGEFILE64_SOURCE or -D_GNU_SOURCE (or #define) to
* use this. It is unsafe to #define those values in this header as it
* is possible the application has already #included <sys/stat.h>. */
#ifdef HAVE_LOV_USER_MDS_DATA
#define lov_user_mds_data lov_user_mds_data_v1
struct lov_user_mds_data_v1 {
lstat_t lmd_st; /* MDS stat struct */
struct lov_user_md_v1 lmd_lmm; /* LOV EA V1 user data */
} __attribute__((packed));
struct lov_user_mds_data_v3 {
lstat_t lmd_st; /* MDS stat struct */
struct lov_user_md_v3 lmd_lmm; /* LOV EA V3 user data */
} __attribute__((packed));
#endif
struct lmv_user_mds_data {
struct lu_fid lum_fid;
__u32 lum_padding;
__u32 lum_mds;
};
enum lmv_hash_type {
LMV_HASH_TYPE_UNKNOWN = 0, /* 0 is reserved for testing purpose */
LMV_HASH_TYPE_ALL_CHARS = 1,
LMV_HASH_TYPE_FNV_1A_64 = 2,
};
#define LMV_HASH_NAME_ALL_CHARS "all_char"
#define LMV_HASH_NAME_FNV_1A_64 "fnv_1a_64"
/* Got this according to how get LOV_MAX_STRIPE_COUNT, see above,
* (max buffer size - lmv+rpc header) / sizeof(struct lmv_user_mds_data) */
#define LMV_MAX_STRIPE_COUNT 2000 /* ((12 * 4096 - 256) / 24) */
#define lmv_user_md lmv_user_md_v1
struct lmv_user_md_v1 {
__u32 lum_magic; /* must be the first field */
__u32 lum_stripe_count; /* dirstripe count */
__u32 lum_stripe_offset; /* MDT idx for default dirstripe */
__u32 lum_hash_type; /* Dir stripe policy */
__u32 lum_type; /* LMV type: default or normal */
__u32 lum_padding1;
__u32 lum_padding2;
__u32 lum_padding3;
char lum_pool_name[LOV_MAXPOOLNAME + 1];
struct lmv_user_mds_data lum_objects[0];
} __attribute__((packed));
static inline int lmv_user_md_size(int stripes, int lmm_magic)
{
return sizeof(struct lmv_user_md) +
stripes * sizeof(struct lmv_user_mds_data);
}
extern void lustre_swab_lmv_user_md(struct lmv_user_md *lum);
struct ll_recreate_obj {
__u64 lrc_id;
__u32 lrc_ost_idx;
};
struct ll_fid {
__u64 id; /* holds object id */
__u32 generation; /* holds object generation */
__u32 f_type; /* holds object type or stripe idx when passing it to
* OST for saving into EA. */
};
#define UUID_MAX 40
struct obd_uuid {
char uuid[UUID_MAX];
};
static inline bool obd_uuid_equals(const struct obd_uuid *u1,
const struct obd_uuid *u2)
{
return strcmp((char *)u1->uuid, (char *)u2->uuid) == 0;
}
static inline int obd_uuid_empty(struct obd_uuid *uuid)
{
return uuid->uuid[0] == '\0';
}
static inline void obd_str2uuid(struct obd_uuid *uuid, const char *tmp)
{
strncpy((char *)uuid->uuid, tmp, sizeof(*uuid));
uuid->uuid[sizeof(*uuid) - 1] = '\0';
}
/* For printf's only, make sure uuid is terminated */
static inline char *obd_uuid2str(const struct obd_uuid *uuid)
{
if (uuid == NULL)
return NULL;
if (uuid->uuid[sizeof(*uuid) - 1] != '\0') {
/* Obviously not safe, but for printfs, no real harm done...
we're always null-terminated, even in a race. */
static char temp[sizeof(*uuid)];
memcpy(temp, uuid->uuid, sizeof(*uuid) - 1);
temp[sizeof(*uuid) - 1] = '\0';
return temp;
}
return (char *)(uuid->uuid);
}
/* Extract fsname from uuid (or target name) of a target
e.g. (myfs-OST0007_UUID -> myfs)
see also deuuidify. */
static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen)
{
char *p;
strncpy(buf, uuid, buflen - 1);
buf[buflen - 1] = '\0';
p = strrchr(buf, '-');
if (p != NULL)
*p = '\0';
}
/* printf display format
e.g. printf("file FID is "DFID"\n", PFID(fid)); */
#define FID_NOBRACE_LEN 40
#define FID_LEN (FID_NOBRACE_LEN + 2)
#define DFID_NOBRACE LPX64":0x%x:0x%x"
#define DFID "["DFID_NOBRACE"]"
#define PFID(fid) \
(fid)->f_seq, \
(fid)->f_oid, \
(fid)->f_ver
/* scanf input parse format -- strip '[' first.
e.g. sscanf(fidstr, SFID, RFID(&fid)); */
/* #define SFID "0x"LPX64i":0x"LPSZX":0x"LPSZX""
liblustreapi.c:2893: warning: format '%lx' expects type 'long unsigned int *', but argument 4 has type 'unsigned int *'
liblustreapi.c:2893: warning: format '%lx' expects type 'long unsigned int *', but argument 5 has type 'unsigned int *'
*/
#define SFID "0x"LPX64i":0x%x:0x%x"
#define RFID(fid) \