Skip to content

Commit

Permalink
Add prototypes
Browse files Browse the repository at this point in the history
Add prototypes/move prototypes to header files.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10470
  • Loading branch information
nivedita76 authored and jsai20 committed Mar 30, 2021
1 parent 443eebd commit ce771c1
Show file tree
Hide file tree
Showing 26 changed files with 169 additions and 163 deletions.
1 change: 1 addition & 0 deletions include/libzfs_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ int no_memory(libzfs_handle_t *);

int zfs_standard_error(libzfs_handle_t *, int, const char *);
int zfs_standard_error_fmt(libzfs_handle_t *, int, const char *, ...);
void zfs_setprop_error(libzfs_handle_t *, zfs_prop_t, int, char *);
int zpool_standard_error(libzfs_handle_t *, int, const char *);
int zpool_standard_error_fmt(libzfs_handle_t *, int, const char *, ...);

Expand Down
1 change: 1 addition & 0 deletions include/libzutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ extern void zfs_nicenum(uint64_t, char *, size_t);
extern void zfs_nicenum_format(uint64_t, char *, size_t,
enum zfs_nicenum_format);
extern void zfs_nicetime(uint64_t, char *, size_t);
extern void zfs_niceraw(uint64_t, char *, size_t);

#define nicenum(num, buf, size) zfs_nicenum(num, buf, size)

Expand Down
3 changes: 3 additions & 0 deletions include/os/freebsd/zfs/sys/vdev_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@
#define _SYS_VDEV_OS_H

extern int vdev_label_write_pad2(vdev_t *vd, const char *buf, size_t size);
extern int vdev_geom_read_pool_label(const char *name, nvlist_t ***configs,
uint64_t *count);

#endif
3 changes: 3 additions & 0 deletions include/os/freebsd/zfs/sys/zfs_vfsops.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ typedef struct zfid_long {
extern uint_t zfs_fsyncer_key;
extern int zfs_super_owner;

extern void zfs_init(void);
extern void zfs_fini(void);

extern int zfs_suspend_fs(zfsvfs_t *zfsvfs);
extern int zfs_resume_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds);
extern int zfs_end_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds);
Expand Down
31 changes: 18 additions & 13 deletions include/os/linux/spl/sys/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,27 +104,45 @@
trace_zfs_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
(uintptr_t)(arg3), (uintptr_t)(arg4))

#define PROTO_DTRACE_PROBE(name) \
noinline void trace_zfs_##name(void)
#define PROTO_DTRACE_PROBE1(name) \
noinline void trace_zfs_##name(uintptr_t)
#define PROTO_DTRACE_PROBE2(name) \
noinline void trace_zfs_##name(uintptr_t, uintptr_t)
#define PROTO_DTRACE_PROBE3(name) \
noinline void trace_zfs_##name(uintptr_t, uintptr_t, \
uintptr_t)
#define PROTO_DTRACE_PROBE4(name) \
noinline void trace_zfs_##name(uintptr_t, uintptr_t, \
uintptr_t, uintptr_t)

#if defined(CREATE_TRACE_POINTS)

#define FUNC_DTRACE_PROBE(name) \
PROTO_DTRACE_PROBE(name); \
noinline void trace_zfs_##name(void) { } \
EXPORT_SYMBOL(trace_zfs_##name)

#define FUNC_DTRACE_PROBE1(name) \
PROTO_DTRACE_PROBE1(name); \
noinline void trace_zfs_##name(uintptr_t arg1) { } \
EXPORT_SYMBOL(trace_zfs_##name)

#define FUNC_DTRACE_PROBE2(name) \
PROTO_DTRACE_PROBE2(name); \
noinline void trace_zfs_##name(uintptr_t arg1, \
uintptr_t arg2) { } \
EXPORT_SYMBOL(trace_zfs_##name)

#define FUNC_DTRACE_PROBE3(name) \
PROTO_DTRACE_PROBE3(name); \
noinline void trace_zfs_##name(uintptr_t arg1, \
uintptr_t arg2, uintptr_t arg3) { } \
EXPORT_SYMBOL(trace_zfs_##name)

#define FUNC_DTRACE_PROBE4(name) \
PROTO_DTRACE_PROBE4(name); \
noinline void trace_zfs_##name(uintptr_t arg1, \
uintptr_t arg2, uintptr_t arg3, uintptr_t arg4) { } \
EXPORT_SYMBOL(trace_zfs_##name)
Expand All @@ -146,19 +164,6 @@ EXPORT_SYMBOL(trace_zfs_##name)

#else /* CREATE_TRACE_POINTS */

#define PROTO_DTRACE_PROBE(name) \
noinline void trace_zfs_##name(void)
#define PROTO_DTRACE_PROBE1(name) \
noinline void trace_zfs_##name(uintptr_t)
#define PROTO_DTRACE_PROBE2(name) \
noinline void trace_zfs_##name(uintptr_t, uintptr_t)
#define PROTO_DTRACE_PROBE3(name) \
noinline void trace_zfs_##name(uintptr_t, uintptr_t, \
uintptr_t)
#define PROTO_DTRACE_PROBE4(name) \
noinline void trace_zfs_##name(uintptr_t, uintptr_t, \
uintptr_t, uintptr_t)

#define DEFINE_DTRACE_PROBE(name) PROTO_DTRACE_PROBE(name)
#define DEFINE_DTRACE_PROBE1(name) PROTO_DTRACE_PROBE1(name)
#define DEFINE_DTRACE_PROBE2(name) PROTO_DTRACE_PROBE2(name)
Expand Down
3 changes: 3 additions & 0 deletions include/os/linux/zfs/sys/zfs_vfsops.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ typedef struct zfid_long {
#define SHORT_FID_LEN (sizeof (zfid_short_t) - sizeof (uint16_t))
#define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t))

extern void zfs_init(void);
extern void zfs_fini(void);

extern int zfs_suspend_fs(zfsvfs_t *zfsvfs);
extern int zfs_resume_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds);
extern int zfs_end_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds);
Expand Down
1 change: 1 addition & 0 deletions include/sys/lua/luaconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
extern ssize_t lcompat_sprintf(char *, size_t size, const char *, ...);
extern int64_t lcompat_strtoll(const char *, char **);
extern int64_t lcompat_pow(int64_t, int64_t);
extern int lcompat_hashnum(int64_t);

/*
** ==================================================================
Expand Down
2 changes: 2 additions & 0 deletions include/sys/vdev_raidz_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ typedef struct raidz_map {
#define RAIDZ_ORIGINAL_IMPL (INT_MAX)

extern const raidz_impl_ops_t vdev_raidz_scalar_impl;
extern boolean_t raidz_will_scalar_work(void);

#if defined(__x86_64) && defined(HAVE_SSE2) /* only x86_64 for now */
extern const raidz_impl_ops_t vdev_raidz_sse2_impl;
#endif
Expand Down
1 change: 1 addition & 0 deletions include/sys/zil.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ extern void zil_itx_assign(zilog_t *zilog, itx_t *itx, dmu_tx_t *tx);
extern void zil_async_to_sync(zilog_t *zilog, uint64_t oid);
extern void zil_commit(zilog_t *zilog, uint64_t oid);
extern void zil_commit_impl(zilog_t *zilog, uint64_t oid);
extern void zil_remove_async(zilog_t *zilog, uint64_t oid);

extern int zil_reset(const char *osname, void *txarg);
extern int zil_claim(struct dsl_pool *dp,
Expand Down
5 changes: 5 additions & 0 deletions lib/libspl/include/umem.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ typedef struct umem_cache {
int cache_cflags;
} umem_cache_t;

/* Prototypes for functions to provide defaults for umem envvars */
const char *_umem_debug_init(void);
const char *_umem_options_init(void);
const char *_umem_logging_init(void);

static inline void *
umem_alloc(size_t size, int flags)
{
Expand Down
108 changes: 0 additions & 108 deletions lib/libzfs/libzfs_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1722,114 +1722,6 @@ zfs_fix_auto_resv(zfs_handle_t *zhp, nvlist_t *nvl)
return (1);
}

void
zfs_setprop_error(libzfs_handle_t *hdl, zfs_prop_t prop, int err,
char *errbuf)
{
switch (err) {

case ENOSPC:
/*
* For quotas and reservations, ENOSPC indicates
* something different; setting a quota or reservation
* doesn't use any disk space.
*/
switch (prop) {
case ZFS_PROP_QUOTA:
case ZFS_PROP_REFQUOTA:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"size is less than current used or "
"reserved space"));
(void) zfs_error(hdl, EZFS_PROPSPACE, errbuf);
break;

case ZFS_PROP_RESERVATION:
case ZFS_PROP_REFRESERVATION:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"size is greater than available space"));
(void) zfs_error(hdl, EZFS_PROPSPACE, errbuf);
break;

default:
(void) zfs_standard_error(hdl, err, errbuf);
break;
}
break;

case EBUSY:
(void) zfs_standard_error(hdl, EBUSY, errbuf);
break;

case EROFS:
(void) zfs_error(hdl, EZFS_DSREADONLY, errbuf);
break;

case E2BIG:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property value too long"));
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
break;

case ENOTSUP:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"pool and or dataset must be upgraded to set this "
"property or value"));
(void) zfs_error(hdl, EZFS_BADVERSION, errbuf);
break;

case ERANGE:
if (prop == ZFS_PROP_COMPRESSION ||
prop == ZFS_PROP_DNODESIZE ||
prop == ZFS_PROP_RECORDSIZE) {
(void) zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property setting is not allowed on "
"bootable datasets"));
(void) zfs_error(hdl, EZFS_NOTSUP, errbuf);
} else if (prop == ZFS_PROP_CHECKSUM ||
prop == ZFS_PROP_DEDUP) {
(void) zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property setting is not allowed on "
"root pools"));
(void) zfs_error(hdl, EZFS_NOTSUP, errbuf);
} else {
(void) zfs_standard_error(hdl, err, errbuf);
}
break;

case EINVAL:
if (prop == ZPROP_INVAL) {
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
} else {
(void) zfs_standard_error(hdl, err, errbuf);
}
break;

case EACCES:
if (prop == ZFS_PROP_KEYLOCATION) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"keylocation may only be set on encryption roots"));
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
} else {
(void) zfs_standard_error(hdl, err, errbuf);
}
break;

case EOVERFLOW:
/*
* This platform can't address a volume this big.
*/
#ifdef _ILP32
if (prop == ZFS_PROP_VOLSIZE) {
(void) zfs_error(hdl, EZFS_VOLTOOBIG, errbuf);
break;
}
#endif
/* FALLTHROUGH */
default:
(void) zfs_standard_error(hdl, err, errbuf);
}
}

static boolean_t
zfs_is_namespace_prop(zfs_prop_t prop)
{
Expand Down
3 changes: 0 additions & 3 deletions lib/libzfs/libzfs_sendrecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@
#include <sys/socket.h>
#include <sys/sha2.h>

/* in libzfs_dataset.c */
extern void zfs_setprop_error(libzfs_handle_t *, zfs_prop_t, int, char *);

static int zfs_receive_impl(libzfs_handle_t *, const char *, const char *,
recvflags_t *, int, const char *, nvlist_t *, avl_tree_t *, char **,
const char *, nvlist_t *);
Expand Down
108 changes: 108 additions & 0 deletions lib/libzfs/libzfs_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,114 @@ zfs_standard_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...)
return (-1);
}

void
zfs_setprop_error(libzfs_handle_t *hdl, zfs_prop_t prop, int err,
char *errbuf)
{
switch (err) {

case ENOSPC:
/*
* For quotas and reservations, ENOSPC indicates
* something different; setting a quota or reservation
* doesn't use any disk space.
*/
switch (prop) {
case ZFS_PROP_QUOTA:
case ZFS_PROP_REFQUOTA:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"size is less than current used or "
"reserved space"));
(void) zfs_error(hdl, EZFS_PROPSPACE, errbuf);
break;

case ZFS_PROP_RESERVATION:
case ZFS_PROP_REFRESERVATION:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"size is greater than available space"));
(void) zfs_error(hdl, EZFS_PROPSPACE, errbuf);
break;

default:
(void) zfs_standard_error(hdl, err, errbuf);
break;
}
break;

case EBUSY:
(void) zfs_standard_error(hdl, EBUSY, errbuf);
break;

case EROFS:
(void) zfs_error(hdl, EZFS_DSREADONLY, errbuf);
break;

case E2BIG:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property value too long"));
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
break;

case ENOTSUP:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"pool and or dataset must be upgraded to set this "
"property or value"));
(void) zfs_error(hdl, EZFS_BADVERSION, errbuf);
break;

case ERANGE:
if (prop == ZFS_PROP_COMPRESSION ||
prop == ZFS_PROP_DNODESIZE ||
prop == ZFS_PROP_RECORDSIZE) {
(void) zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property setting is not allowed on "
"bootable datasets"));
(void) zfs_error(hdl, EZFS_NOTSUP, errbuf);
} else if (prop == ZFS_PROP_CHECKSUM ||
prop == ZFS_PROP_DEDUP) {
(void) zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property setting is not allowed on "
"root pools"));
(void) zfs_error(hdl, EZFS_NOTSUP, errbuf);
} else {
(void) zfs_standard_error(hdl, err, errbuf);
}
break;

case EINVAL:
if (prop == ZPROP_INVAL) {
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
} else {
(void) zfs_standard_error(hdl, err, errbuf);
}
break;

case EACCES:
if (prop == ZFS_PROP_KEYLOCATION) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"keylocation may only be set on encryption roots"));
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
} else {
(void) zfs_standard_error(hdl, err, errbuf);
}
break;

case EOVERFLOW:
/*
* This platform can't address a volume this big.
*/
#ifdef _ILP32
if (prop == ZFS_PROP_VOLSIZE) {
(void) zfs_error(hdl, EZFS_VOLTOOBIG, errbuf);
break;
}
#endif
/* FALLTHROUGH */
default:
(void) zfs_standard_error(hdl, err, errbuf);
}
}

int
zpool_standard_error(libzfs_handle_t *hdl, int error, const char *msg)
{
Expand Down
Loading

0 comments on commit ce771c1

Please sign in to comment.